‪TYPO3CMS  11.5
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)
 
 printClipboard (string $table='')
 
 getClipboardData (string $table='')
 
bool hasElements ()
 
string selUrlDB (string $table, int $uid, bool $copy=false, bool $deselect=false)
 
string selUrlFile (string $path, bool $copy=false, bool $deselect=false)
 
string 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)
 
string getTabInfo (string $padIdentifier, string $table='')
 
string linkItemText (string $itemText, $reference, bool $isRequestedTable)
 
string clipboardLabel (string $key)
 
 saveClipboard ()
 
bool isElements ()
 
LanguageService getLanguageService ()
 
BackendUserAuthentication getBackendUser ()
 
string 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 48 of file Clipboard.php.

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ buildUrl()

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

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

Parameters
array$parameters
Returns
‪string

Definition at line 816 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 685 of file Clipboard.php.

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)

Parameters
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.
Returns
‪array Processed input $CBarr

Definition at line 226 of file Clipboard.php.

◆ clipboardLabel()

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

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

Parameters
string$key‪Label Key
Returns
‪string htmspecialchared' label

Definition at line 641 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,
  $reference,
string  $type,
array  $selectedElements,
string  $columnLabel = '' 
)

Returns confirm JavaScript message

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

Definition at line 584 of file Clipboard.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Type\Bitmask\JsConfirmation\COPY_MOVE_PASTE, TYPO3\CMS\Backend\Clipboard\Clipboard\currentMode(), TYPO3\CMS\Backend\Clipboard\Clipboard\getBackendUser(), TYPO3\CMS\Backend\Clipboard\Clipboard\getLanguageService(), TYPO3\CMS\Backend\Clipboard\Clipboard\getSelectedRecord(), and TYPO3\CMS\Core\Localization\LanguageService\sL().

Referenced by TYPO3\CMS\Recordlist\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.

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

Definition at line 719 of file Clipboard.php.

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

Referenced by TYPO3\CMS\Backend\Clipboard\Clipboard\getClipboardData(), TYPO3\CMS\Recordlist\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()

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

◆ getLocalizations()

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

Gets all localizations of the current record.

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

Definition at line 402 of file Clipboard.php.

References $GLOBALS, TYPO3\CMS\Backend\Clipboard\Clipboard\getBackendUser(), TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL.

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!

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

Definition at line 766 of file Clipboard.php.

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

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

◆ getTabInfo()

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

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.

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

Definition at line 469 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()

array TYPO3\CMS\Backend\Clipboard\Clipboard::getTabItems ( string  $padIdentifier,
string  $currentTable 
)
protected

◆ hasElements()

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

Returns true if the clipboard contains elements

Returns
‪bool

Definition at line 384 of file Clipboard.php.

◆ initializeClipboard()

◆ isElements()

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

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

Returns
‪bool TRUE if elements exist.

Definition at line 784 of file Clipboard.php.

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

◆ isSelected()

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

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.

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

Definition at line 753 of file Clipboard.php.

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

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

◆ linkItemText()

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

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.

Parameters
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
Returns
‪string

Definition at line 488 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 133 of file Clipboard.php.

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

◆ pasteUrl()

string TYPO3\CMS\Backend\Clipboard\Clipboard::pasteUrl ( string  $table,
  $identifier,
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

Parameters
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)
Returns
‪string

Definition at line 557 of file Clipboard.php.

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

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

◆ printClipboard()

TYPO3\CMS\Backend\Clipboard\Clipboard::printClipboard ( string  $table = '')
Deprecated:
‪Backwards compatibility for some extensions. Will be removed in v12.

Definition at line 240 of file Clipboard.php.

◆ removeElement()

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

◆ saveClipboard()

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

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

Definition at line 666 of file Clipboard.php.

References TYPO3\CMS\Backend\Clipboard\Clipboard\getBackendUser(), and TYPO3\CMS\Core\Authentication\AbstractUserAuthentication\pushModuleData().

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

Parameters
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.
Returns
‪string URL linking to the current script but with the CB array set to select the element with table/uid

Definition at line 517 of file Clipboard.php.

References 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

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

Definition at line 535 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.

Parameters
array$cmd‪Array of actions, see function description

Definition at line 150 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

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

Definition at line 191 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 73 of file Clipboard.php.

◆ $clipData

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

◆ $current

◆ $iconFactory

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

Definition at line 81 of file Clipboard.php.

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

◆ $lockToNormal

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

Definition at line 77 of file Clipboard.php.

◆ $numberOfPads

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

◆ $request

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

◆ $resourceFactory

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

Definition at line 83 of file Clipboard.php.

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

◆ $uriBuilder

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

Definition at line 82 of file Clipboard.php.

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