Exemple #1
0
 /**
  * Returns array of elements from clipboard to insert into GROUP element box.
  *
  * @param string $allowed Allowed elements, Eg "pages,tt_content", "gif,jpg,jpeg,png
  * @param string $mode Mode of relations: "db" or "file
  * @return array Array of elements in values (keys are insignificant), if none found, empty array.
  */
 protected function getClipboardElements($allowed, $mode)
 {
     if (!is_object($this->clipboard)) {
         $this->clipboard = GeneralUtility::makeInstance(Clipboard::class);
         $this->clipboard->initializeClipboard();
     }
     $output = [];
     switch ($mode) {
         case 'file_reference':
         case 'file':
             $elFromTable = $this->clipboard->elFromTable('_FILE');
             $allowedExts = GeneralUtility::trimExplode(',', $allowed, true);
             // If there are a set of allowed extensions, filter the content:
             if ($allowedExts) {
                 foreach ($elFromTable as $elValue) {
                     $pI = pathinfo($elValue);
                     $ext = strtolower($pI['extension']);
                     if (in_array($ext, $allowedExts)) {
                         $output[] = $elValue;
                     }
                 }
             } else {
                 // If all is allowed, insert all: (This does NOT respect any disallowed extensions,
                 // but those will be filtered away by the backend DataHandler)
                 $output = $elFromTable;
             }
             break;
         case 'db':
             $allowedTables = GeneralUtility::trimExplode(',', $allowed, true);
             // All tables allowed for relation:
             if (trim($allowedTables[0]) === '*') {
                 $output = $this->clipboard->elFromTable('');
             } else {
                 // Only some tables, filter them:
                 foreach ($allowedTables as $tablename) {
                     $elFromTable = $this->clipboard->elFromTable($tablename);
                     $output = array_merge($output, $elFromTable);
                 }
             }
             $output = array_keys($output);
             break;
     }
     return $output;
 }
Exemple #2
0
 /**
  * @param string $relativeTo
  * @param boolean $reference
  * @return string
  */
 public static function createIconWithUrl($relativeTo, $reference = FALSE)
 {
     $reference = (bool) $reference;
     $data = self::getClipBoardData($reference);
     if (NULL === $data) {
         return '';
     }
     if (TRUE === $reference) {
         $icon = MiscellaneousUtility::getIcon('actions-insert-reference');
         $title = LocalizationUtility::translate('paste_reference', 'Flux');
     } else {
         $icon = MiscellaneousUtility::getIcon('actions-document-paste-after');
         $title = LocalizationUtility::translate('paste', 'Flux');
     }
     $clipBoard = new Clipboard();
     $clipBoard->initializeClipboard();
     $uri = $clipBoard->pasteUrl('tt_content', $relativeTo);
     return MiscellaneousUtility::wrapLink($icon, $uri, $title);
 }
 /**
  * Initializes the clipboard for generating paste links
  *
  * @return void
  *
  * @see \TYPO3\CMS\Recordlist\RecordList::main()
  * @see \TYPO3\CMS\Backend\Controller\ClickMenuController::main()
  * @see \TYPO3\CMS\Filelist\Controller\FileListController::main()
  */
 protected function initializeClipboard()
 {
     // Start clipboard
     $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
     // Initialize - reads the clipboard content from the user session
     $this->clipboard->initializeClipboard();
     // This locks the clipboard to the Normal for this request.
     $this->clipboard->lockToNormal();
     // Clean up pad
     $this->clipboard->cleanCurrent();
     // Save the clipboard content
     $this->clipboard->endClipboard();
 }