‪TYPO3CMS  ‪main
TYPO3\CMS\Backend\Clipboard\Clipboard Class Reference

Public Member Functions

 __construct (IconFactory $iconFactory, UriBuilder $uriBuilder, ResourceFactory $resourceFactory)
 initializeClipboard (?ServerRequestInterface $request=null)
 lockToNormal ()
 setCmd (array $cmd)
 setCurrentPad (string $padIdentifier)
 endClipboard ()
array cleanUpCBC (array $CBarr, string $table, bool $removeDeselected=false)
 getClipboardData (string $table='')
 hasElements ()
string selUrlDB (string $table, int $uid, bool $copy=false, bool $deselect=false)
string selUrlFile (string $path, bool $copy=false, bool $deselect=false)
 pasteUrl (string $table, $identifier, bool $setRedirect=true, array $update=null)
string confirmMsgText (string $table, $reference, string $type, array $selectedElements, string $columnLabel='')
 removeElement (string $elementKey)
string currentMode ()
 cleanCurrent ()
array elFromTable (string $matchTable='', string $padIdentifier='')
string isSelected (string $table, $identifier)
array getSelectedRecord ()

Public Attributes

array $clipData = []
bool $changed = false
string $current = ''
bool $lockToNormal = false
int $numberOfPads = 3

Protected Member Functions

array getTabItems (string $padIdentifier, string $currentTable)
array getLocalizations (string $table, array $parentRecord, bool $isRequestedTable)
 getTabInfo (string $padIdentifier, string $table='')
 linkItemText (string $itemText, $reference, bool $isRequestedTable)
string clipboardLabel (string $key)
 saveClipboard ()
bool isElements ()
 getLanguageService ()
 getBackendUser ()
 buildUrl (array $parameters=[])

Protected Attributes

IconFactory $iconFactory
UriBuilder $uriBuilder
ResourceFactory $resourceFactory
ServerRequestInterface $request = null

Detailed Description

TYPO3 clipboard for records and files

This class is a specific Backend implementation and is not considered part of the Public TYPO3 API.

Definition at line 47 of file Clipboard.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Clipboard\Clipboard::__construct ( IconFactory  $iconFactory,
UriBuilder  $uriBuilder,
ResourceFactory  $resourceFactory 

Member Function Documentation

◆ buildUrl()

TYPO3\CMS\Backend\Clipboard\Clipboard::buildUrl ( array  $parameters = [])

Builds a URL to the current module with the received parameters, merged / replaced by additional parameters.

Definition at line 783 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\pasteUrl(), TYPO3\CMS\Backend\Clipboard\Clipboard\selUrlDB(), and TYPO3\CMS\Backend\Clipboard\Clipboard\selUrlFile().

◆ cleanCurrent()

TYPO3\CMS\Backend\Clipboard\Clipboard::cleanCurrent ( )

This traverses the elements on the current clipboard pane and unsets elements which does not exist anymore or are disabled.

Definition at line 665 of file Clipboard.php.

References TYPO3\CMS\Webhooks\Message\$uid.

Referenced by TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider\initClipboard().

◆ cleanUpCBC()

array TYPO3\CMS\Backend\Clipboard\Clipboard::cleanUpCBC ( array  $CBarr,
string  $table,
bool  $removeDeselected = false 

Cleans up an incoming element array $CBarr (Array selecting/deselecting elements)

array$CBarr‪Element array from outside ("key" => "selected/deselected")
string$table‪The 'table which is allowed'. Must be set.
bool$removeDeselected‪Can be set in order to remove entries which are marked for deselection.
‪array Processed input $CBarr

Definition at line 223 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Controller\RecordListController\deleteRecords().

◆ clipboardLabel()

string TYPO3\CMS\Backend\Clipboard\Clipboard::clipboardLabel ( string  $key)

Clipboard label - getting from "EXT:core/Resources/Private/Language/locallang_core.xlf:"

string$key‪Label Key
‪string htmspecialchared' label

Definition at line 621 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\getLanguageService().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getTabInfo().

◆ confirmMsgText()

string TYPO3\CMS\Backend\Clipboard\Clipboard::confirmMsgText ( string  $table,
string  $type,
array  $selectedElements,
string  $columnLabel = '' 

Returns confirm JavaScript message

string$table‪Table name
array | string$reference‪For records its an array, for files its a string (path)
array$selectedElements‪Array of selected elements
string$columnLabel‪Name of the content column
‪string the text for a confirm message

Definition at line 564 of file Clipboard.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Authentication\JsConfirmation\COPY_MOVE_PASTE, TYPO3\CMS\Backend\Clipboard\Clipboard\currentMode(), TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs(), TYPO3\CMS\Backend\Clipboard\Clipboard\getBackendUser(), TYPO3\CMS\Backend\Clipboard\Clipboard\getLanguageService(), and TYPO3\CMS\Backend\Clipboard\Clipboard\getSelectedRecord().

Referenced by TYPO3\CMS\Backend\Controller\RecordListController\getDocHeaderButtons().

◆ currentMode()

◆ elFromTable()

array TYPO3\CMS\Backend\Clipboard\Clipboard::elFromTable ( string  $matchTable = '',
string  $padIdentifier = '' 

Counts the number of elements from the table $matchTable. If $matchTable is blank, all tables (except '_FILE' of course) is counted.

string$matchTable‪Table to match/count for.
string$padIdentifier‪Can optionally be used to set another pad than the current.
‪array Array with keys from the CB.

Definition at line 699 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\$current, $GLOBALS, and TYPO3\CMS\Webhooks\Message\$uid.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getClipboardData(), TYPO3\CMS\Backend\Controller\RecordListController\getDocHeaderButtons(), TYPO3\CMS\Backend\Clipboard\Clipboard\getSelectedRecord(), TYPO3\CMS\Backend\Clipboard\Clipboard\getTabInfo(), TYPO3\CMS\Backend\Controller\SimpleDataHandlerController\setDeleteCmd(), TYPO3\CMS\Backend\Controller\File\FileController\setDeleteCmd(), TYPO3\CMS\Backend\Controller\SimpleDataHandlerController\setPasteCmd(), and TYPO3\CMS\Backend\Controller\File\FileController\setPasteCmd().

◆ endClipboard()

TYPO3\CMS\Backend\Clipboard\Clipboard::endClipboard ( )

◆ getBackendUser()

◆ getClipboardData()

◆ getLanguageService()

TYPO3\CMS\Backend\Clipboard\Clipboard::getLanguageService ( )

◆ getLocalizations()

array TYPO3\CMS\Backend\Clipboard\Clipboard::getLocalizations ( string  $table,
array  $parentRecord,
bool  $isRequestedTable 

Gets all localizations of the current record.

string$table‪The table
array$parentRecord‪The parent record
bool$isRequestedTable‪Whether the element is from the requested table
‪array HTML table rows

Definition at line 385 of file Clipboard.php.

References $GLOBALS, TYPO3\CMS\Webhooks\Message\$record, TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs(), TYPO3\CMS\Backend\Clipboard\Clipboard\getBackendUser(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getTabItems().

◆ getSelectedRecord()

array TYPO3\CMS\Backend\Clipboard\Clipboard::getSelectedRecord ( )

Returns the first element on the current clipboard Makes sense only for DB records - not files!

‪array Element record with extra field _RECORD_TITLE set to the title of the record

Definition at line 746 of file Clipboard.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Backend\Clipboard\Clipboard\elFromTable(), and TYPO3\CMS\Backend\Clipboard\Clipboard\isSelected().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\confirmMsgText().

◆ getTabInfo()

TYPO3\CMS\Backend\Clipboard\Clipboard::getTabInfo ( string  $padIdentifier,
string  $table = '' 

Additional information for the tab. This is either the current copyMode (for "normal") or the elements count, for numeric tabs. Latter will not be shown, in case no elements exist for the tab.

string$padIdentifier‪Identifier for the clipboard pad
string$table‪The table name to count for elements

Definition at line 451 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\clipboardLabel(), and TYPO3\CMS\Backend\Clipboard\Clipboard\elFromTable().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getClipboardData().

◆ getTabItems()

◆ hasElements()

TYPO3\CMS\Backend\Clipboard\Clipboard::hasElements ( )

Returns true if the clipboard contains elements

Definition at line 367 of file Clipboard.php.

◆ initializeClipboard()

◆ isElements()

bool TYPO3\CMS\Backend\Clipboard\Clipboard::isElements ( )

Reports if the current pad has elements (does not check file/DB type OR if file/DBrecord exists or not. Only counting array)

‪bool TRUE if elements exist.

Definition at line 764 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\setCurrentPad().

◆ isSelected()

string TYPO3\CMS\Backend\Clipboard\Clipboard::isSelected ( string  $table,

Verifies if the item $table/$uid is on the current pad. If the pad is "normal" and the element exists, the mode value is returned. Thus you'll know if the item was copied or cut.

string$table‪Table name, (_FILE for files...)
string | int$identifier‪Either the records' uid or a filepath
‪string If selected the current mode is returned, otherwise an empty string

Definition at line 733 of file Clipboard.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Backend\Clipboard\Clipboard\currentMode().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getSelectedRecord().

◆ linkItemText()

TYPO3\CMS\Backend\Clipboard\Clipboard::linkItemText ( string  $itemText,
bool  $isRequestedTable 

Wraps the title of the element in a link to the page/folder where they originate from. Will be wrapped into "muted" style in case the element is not from the currently requested table.

string$itemText‪Title of element - must be htmlspecialchar'ed on beforehand.
array | string$reference‪If array, a record is expected. If string, its the folders' combined identifier
bool$isRequestedTable‪Whether the element is from the requested table

Definition at line 469 of file Clipboard.php.

References TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getTabItems().

◆ lockToNormal()

TYPO3\CMS\Backend\Clipboard\Clipboard::lockToNormal ( )

Call this method after initialization if you want to lock the clipboard to operate on the normal pad only. Trying to switch pad through ->setCmd will not work. This is used by the clickmenu since it only allows operation on single elements at a time (that is the "normal" pad)

Definition at line 130 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider\initClipboard(), and TYPO3\CMS\Backend\Clipboard\Clipboard\setCurrentPad().

◆ pasteUrl()

TYPO3\CMS\Backend\Clipboard\Clipboard::pasteUrl ( string  $table,
bool  $setRedirect = true,
array  $update = null 

pasteUrl of the element (database and file) For the meaning of $table and $uid, please read from ->makePasteCmdArray!!! The URL will point to tce_file or tce_db depending in $table

string$table‪Tablename (_FILE for files)
string | int$identifier‪"destination": can be positive or negative indicating how the paste is done (paste into / paste after). For files, this is the combined identifier.
bool$setRedirect‪If set, then the redirect URL will point back to the current script, but with CB reset.
array | null$update‪Additional key/value pairs which should get set in the moved/copied record (via DataHandler)

Definition at line 537 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\$current, TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Backend\Clipboard\Clipboard\buildUrl().

Referenced by TYPO3\CMS\Backend\Controller\RecordListController\getDocHeaderButtons().

◆ removeElement()

TYPO3\CMS\Backend\Clipboard\Clipboard::removeElement ( string  $elementKey)

◆ saveClipboard()

TYPO3\CMS\Backend\Clipboard\Clipboard::saveClipboard ( )

Saves the clipboard, no questions asked. Use ->endClipboard normally (as it checks if changes has been done so saving is necessary)

Definition at line 646 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\getBackendUser().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\endClipboard().

◆ selUrlDB()

string TYPO3\CMS\Backend\Clipboard\Clipboard::selUrlDB ( string  $table,
int  $uid,
bool  $copy = false,
bool  $deselect = false 

Returns the select-url for database elements

string$table‪Table name
int$uid‪Uid of record
bool$copy‪If set, copymode will be enabled
bool$deselect‪If set, the link will deselect, otherwise select.
‪string URL linking to the current script but with the CB array set to select the element with table/uid

Definition at line 498 of file Clipboard.php.

References TYPO3\CMS\Webhooks\Message\$uid, and TYPO3\CMS\Backend\Clipboard\Clipboard\buildUrl().

◆ selUrlFile()

string TYPO3\CMS\Backend\Clipboard\Clipboard::selUrlFile ( string  $path,
bool  $copy = false,
bool  $deselect = false 

Returns the select-url for files

bool$copy‪If set, copymode will be enabled
bool$deselect‪If set, the link will deselect, otherwise select.
‪string URL linking to the current script but with the CB array set to select the path

Definition at line 516 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\buildUrl().

◆ setCmd()

TYPO3\CMS\Backend\Clipboard\Clipboard::setCmd ( array  $cmd)

The array $cmd may hold various keys which notes some action to take. Normally perform only one action at a time. In scripts like db_list.php / filelist/mod1/index.php the GET-var CB is used to control the clipboard.

Selecting / Deselecting elements Array $cmd['el'] has keys = element-ident, value = element value (see description of clipData array in header) Selecting elements for 'copy' should be done by simultaneously setting setCopyMode.

array$cmd‪Array of actions, see function description

Definition at line 147 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\$current, TYPO3\CMS\Backend\Clipboard\Clipboard\removeElement(), and TYPO3\CMS\Backend\Clipboard\Clipboard\setCurrentPad().

◆ setCurrentPad()

TYPO3\CMS\Backend\Clipboard\Clipboard::setCurrentPad ( string  $padIdentifier)

Setting the current pad on clipboard

string$padIdentifier‪Key in the array $this->clipData

Definition at line 188 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\$current, TYPO3\CMS\Backend\Clipboard\Clipboard\isElements(), and TYPO3\CMS\Backend\Clipboard\Clipboard\lockToNormal().

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\setCmd().

Member Data Documentation

◆ $changed

bool TYPO3\CMS\Backend\Clipboard\Clipboard::$changed = false

Definition at line 70 of file Clipboard.php.

◆ $clipData

array TYPO3\CMS\Backend\Clipboard\Clipboard::$clipData = []

Clipboard data kept here

Keys: 'normal' 'tab_[x]' where x is >=1 and denotes the pad-number 'mode' : 'copy' means copy-mode, default = moving ('cut') 'el' : Array of elements: DB: keys = '[tablename]|[uid]' eg. 'tt_content:123' DB: values = 1 (basically insignificant) FILE: keys = '_FILE|[md5 of path]' eg. '_FILE|9ebc7e5c74' FILE: values = The full filepath, eg. '/www/htdocs/typo3/32/dummy/fileadmin/sem1_3_examples/alternative_index.php' or 'C:/www/htdocs/typo3/32/dummy/fileadmin/sem1_3_examples/alternative_index.php'

'current' pointer to current tab (among the above...)

The virtual tablename '_FILE' will always indicate files/folders. When checking for elements from eg. 'all tables' (by using an empty string) '_FILE' entries are excluded (so in effect only DB elements are counted)

Definition at line 68 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\initializeClipboard().

◆ $current

◆ $iconFactory

IconFactory TYPO3\CMS\Backend\Clipboard\Clipboard::$iconFactory

Definition at line 78 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\__construct().

◆ $lockToNormal

bool TYPO3\CMS\Backend\Clipboard\Clipboard::$lockToNormal = false

Definition at line 74 of file Clipboard.php.

◆ $numberOfPads

int TYPO3\CMS\Backend\Clipboard\Clipboard::$numberOfPads = 3

◆ $request

ServerRequestInterface TYPO3\CMS\Backend\Clipboard\Clipboard::$request = null

◆ $resourceFactory

ResourceFactory TYPO3\CMS\Backend\Clipboard\Clipboard::$resourceFactory

Definition at line 80 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\__construct().

◆ $uriBuilder

UriBuilder TYPO3\CMS\Backend\Clipboard\Clipboard::$uriBuilder

Definition at line 79 of file Clipboard.php.

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\__construct().