/** * @param array|NULL $backendUser * @param int $size * @param bool $showIcon * @return string */ public function render(array $backendUser = NULL, $size = 32, $showIcon = FALSE) { $size = (int) $size; if (!is_array($backendUser)) { $backendUser = $this->getBackendUser()->user; } $image = parent::render($backendUser, $size, $showIcon); if (!StringUtility::beginsWith($image, '<span class="avatar"><span class="avatar-image"></span>') || empty($backendUser['email'])) { return $image; } $cachedFilePath = PATH_site . 'typo3temp/t3gravatar/'; $cachedFileName = sha1($backendUser['email'] . $size) . '.jpg'; if (!file_exists($cachedFilePath . $cachedFileName)) { $gravatar = 'https://www.gravatar.com/avatar/' . md5(strtolower($backendUser['email'])) . '?s=' . $size . '&d=404'; $gravatarImage = GeneralUtility::getUrl($gravatar); if (empty($gravatarImage)) { return $image; } GeneralUtility::writeFileToTypo3tempDir($cachedFileName, $gravatarImage); } // Icon $icon = ''; if ($showIcon) { $icon = '<span class="avatar-icon">' . IconUtility::getSpriteIconForRecord('be_users', $backendUser) . '</span>'; } $relativeFilePath = PathUtility::getRelativePath(PATH_typo3, $cachedFilePath); return '<span class="avatar"><span class="avatar-image">' . '<img src="' . $relativeFilePath . $cachedFileName . '" width="' . $size . '" height="' . $size . '" /></span>' . $icon . '</span>'; }
/** * Render javascript in header * * @return string the rendered page info icon * @see template::getPageInfo() Note: can't call this method as it's protected! */ public function render() { $doc = $this->getDocInstance(); $id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1)); // Add icon with clickmenu, etc: if ($pageRecord['uid']) { // If there IS a real page $alttext = BackendUtility::getRecordIconAltText($pageRecord, 'pages'); $iconImg = IconUtility::getSpriteIconForRecord('pages', $pageRecord, array('title' => htmlspecialchars($alttext))); // Make Icon: $theIcon = $doc->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']); } else { // On root-level of page tree // Make Icon $iconImg = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_website.gif') . ' alt="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '" />'; if ($GLOBALS['BE_USER']->user['admin']) { $theIcon = $doc->wrapClickMenuOnIcon($iconImg, 'pages', 0); } else { $theIcon = $iconImg; } } // Setting icon with clickmenu + uid $pageInfo = $theIcon . '<em>[pid: ' . $pageRecord['uid'] . ']</em>'; return $pageInfo; }
/** * Displays spriteIcon for database table and object * * @param string $table * @param object $object * * @return string * @see t3lib_iconWorks::getSpriteIconForRecord($table, $row) */ public function render($table, $object) { if (!is_object($object) || !method_exists($object, 'getUid')) { return ''; } $row = array('uid' => $object->getUid(), 'startTime' => FALSE, 'endTime' => FALSE); if (method_exists($object, 'getIsDisabled')) { $row['disable'] = $object->getIsDisabled(); } if ($table === 'be_users' && $object instanceof BackendUser) { $row['admin'] = $object->getIsAdministrator(); } if (method_exists($object, 'getStartDateAndTime')) { $row['startTime'] = $object->getStartDateAndTime(); } if (method_exists($object, 'getEndDateAndTime')) { $row['endTime'] = $object->getEndDateAndTime(); } // @todo Remove this when 6.2 is no longer relevant if (version_compare(TYPO3_branch, '7.0', '<')) { $icon = IconUtility::getSpriteIconForRecord($table, $row); } else { /* @var $iconFactory \TYPO3\CMS\Core\Imaging\IconFactory */ $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $icon = $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render(); } return $icon; }
/** * @param array $arguments * @param callable $renderChildrenClosure * @param RenderingContextInterface $renderingContext * * @return string * @throws Exception */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $object = $arguments['object']; $table = $arguments['table']; if (!is_object($object) || !method_exists($object, 'getUid')) { return ''; } $row = array('uid' => $object->getUid(), 'startTime' => FALSE, 'endTime' => FALSE); if (method_exists($object, 'getIsDisabled')) { $row['disable'] = $object->getIsDisabled(); } if (method_exists($object, 'getHidden')) { $row['hidden'] = $object->getHidden(); } if ($table === 'be_users' && $object instanceof BackendUser) { $row['admin'] = $object->getIsAdministrator(); } if (method_exists($object, 'getStartDateAndTime')) { $row['startTime'] = $object->getStartDateAndTime(); } if (method_exists($object, 'getEndDateAndTime')) { $row['endTime'] = $object->getEndDateAndTime(); } return IconUtility::getSpriteIconForRecord($table, $row); }
/** * Render the sprite icon * * @param string $table table name * @param integer $uid uid of record * @param string $title title * @return string sprite icon */ public function render($table, $uid, $title) { $icon = ''; $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $uid); if (is_array($row)) { $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($title))); } return $icon; }
/** * Main processing, creating the list of new record tables to select from. * * @return void */ public function main() { // if commerce parameter is missing use default controller if (!GeneralUtility::_GP('parentCategory')) { parent::main(); return; } // If there was a page - or if the user is admin // (admins has access to the root) we proceed: if ($this->pageinfo['uid'] || $this->getBackendUserAuthentication()->isAdmin()) { // Acquiring TSconfig for this module/current page: $this->web_list_modTSconfig = BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod.web_list'); // allow only commerce related tables $this->allowedNewTables = array('tx_commerce_categories', 'tx_commerce_products'); $this->deniedNewTables = GeneralUtility::trimExplode(',', $this->web_list_modTSconfig['properties']['deniedNewTables'], true); // Acquiring TSconfig for this module/parent page: $this->web_list_modTSconfig_pid = BackendUtility::getModTSconfig($this->pageinfo['pid'], 'mod.web_list'); $this->allowedNewTables_pid = GeneralUtility::trimExplode(',', $this->web_list_modTSconfig_pid['properties']['allowedNewTables'], true); $this->deniedNewTables_pid = GeneralUtility::trimExplode(',', $this->web_list_modTSconfig_pid['properties']['deniedNewTables'], true); // More init: if (!$this->showNewRecLink('pages')) { $this->newPagesInto = 0; } if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid)) { $this->newPagesAfter = 0; } // Set header-HTML and return_url if (is_array($this->pageinfo) && $this->pageinfo['uid']) { $iconImgTag = IconUtility::getSpriteIconForRecord('pages', $this->pageinfo, array('title' => htmlspecialchars($this->pageinfo['_thePath']))); $title = strip_tags($this->pageinfo[SettingsFactory::getInstance()->getTcaValue('pages.ctrl.label')]); } else { $iconImgTag = IconUtility::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($this->pageinfo['_thePath']))); $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } $this->code = '<span class="typo3-moduleHeader">' . $this->doc->wrapClickMenuOnIcon($iconImgTag, 'pages', $this->pageinfo['uid']) . htmlspecialchars(GeneralUtility::fixed_lgd_cs($title, 45)) . '</span><br />'; $this->R_URI = $this->returnUrl; // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard) // Regular new element: if (!$this->pagesOnly) { $this->regularNew(); } elseif ($this->showNewRecLink('pages')) { // Pages only wizard $this->pagesOnly(); } // Add all the content to an output section $this->content .= $this->doc->section('', $this->code); // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers['CSH'] = $docHeaderButtons['csh']; $markers['CONTENT'] = $this->content; // Build the <body> for the module $this->content = $this->doc->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:db_new.php.pagetitle')); $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); $this->content .= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); } }
/** * Wrapping the title in a link, if applicable. * * @param string $title Title, ready for output. * @param array $v The record * @param bool $ext_pArrPages If set, pages clicked will return immediately, otherwise reload page. * @return string Wrapping title string. */ public function wrapTitle($title, $v, $ext_pArrPages) { if ($ext_pArrPages) { $ficon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $v); $onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($ficon) . ',\'\',1);'; } else { $onClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['uid']) . ');'; } return '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $title . '</a>'; }
/** * Iterates through elements of $each and renders child nodes * * @param array $record The tt_content record * @param boolean $oncludeTitle If title should be included in output, * @return string */ public function render($record) { $shortcutContent = ''; $tableName = 'tt_content'; if (is_array($record)) { $altText = BackendUtility::getRecordIconAltText($record, $tableName); $iconImg = IconUtility::getSpriteIconForRecord($tableName, $record, array('title' => $altText)); if ($this->getBackendUser()->recordEditAccessInternals($tableName, $record)) { $iconImg = BackendUtility::wrapClickMenuOnIcon($iconImg, $tableName, $record['uid'], 1, '', '+copy,info,edit,view'); } $link = $this->linkEditContent(htmlspecialchars(BackendUtility::getRecordTitle($tableName, $record)), $record); $shortcutContent = $iconImg . $link; } return $shortcutContent; }
/** * Transforms the rows for the deleted records * * @param array $deletedRowsArray Array with table as key and array with all deleted rows * @param int $totalDeleted Number of deleted records in total * @return string JSON array */ public function transform($deletedRowsArray, $totalDeleted) { $total = 0; $jsonArray = array('rows' => array()); if (is_array($deletedRowsArray)) { $lang = $this->getLanguageService(); $backendUser = $this->getBackendUser(); foreach ($deletedRowsArray as $table => $rows) { $total += count($deletedRowsArray[$table]); foreach ($rows as $row) { $pageTitle = $this->getPageTitle((int) $row['pid']); $backendUser = BackendUtility::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', FALSE); $jsonArray['rows'][] = array('uid' => $row['uid'], 'pid' => $row['pid'], 'icon' => IconUtility::getSpriteIconForRecord($table, $row), 'pageTitle' => RecyclerUtility::getUtf8String($pageTitle), 'table' => $table, 'crdate' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]), 'tstamp' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]), 'owner' => htmlspecialchars($backendUser['username']), 'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'tableTitle' => RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])), 'title' => htmlspecialchars(RecyclerUtility::getUtf8String(BackendUtility::getRecordTitle($table, $row))), 'path' => RecyclerUtility::getRecordPath($row['pid'])); } } } $jsonArray['total'] = $totalDeleted; return $jsonArray; }
/** * Displays spriteIcon for database table and object * * @param string $table * @param object $object * @return string * @see \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row) */ public function render($table, $object) { if (!is_object($object) || !method_exists($object, 'getUid')) { return ''; } $row = array('uid' => $object->getUid(), 'startTime' => FALSE, 'endTime' => FALSE); if (method_exists($object, 'getIsDisabled')) { $row['disable'] = $object->getIsDisabled(); } if ($table === 'be_users' && $object instanceof \TYPO3\CMS\Beuser\Domain\Model\BackendUser) { $row['admin'] = $object->getIsAdministrator(); } if (method_exists($object, 'getStartDateAndTime')) { $row['startTime'] = $object->getStartDateAndTime(); } if (method_exists($object, 'getEndDateAndTime')) { $row['endTime'] = $object->getEndDateAndTime(); } return \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row); }
/** * @param array $arguments * @param callable $renderChildrenClosure * @param RenderingContextInterface $renderingContext * * @return string */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $doc = GeneralUtility::makeInstance(DocumentTemplate::class); $id = GeneralUtility::_GP('id'); $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1)); // Add icon with clickmenu, etc: if ($pageRecord['uid']) { // If there IS a real page $alttext = BackendUtility::getRecordIconAltText($pageRecord, 'pages'); $theIcon = IconUtility::getSpriteIconForRecord('pages', $pageRecord, array('title' => htmlspecialchars($alttext))); // Make Icon: $theIcon = $doc->wrapClickMenuOnIcon($theIcon, 'pages', $pageRecord['uid']); // Setting icon with clickmenu + uid $theIcon .= ' <em>[PID: ' . $pageRecord['uid'] . ']</em>'; } else { // On root-level of page tree // Make Icon $theIcon = IconUtility::getSpriteIcon('apps-pagetree-page-domain', array('title' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']))); if ($GLOBALS['BE_USER']->user['admin']) { $theIcon = $doc->wrapClickMenuOnIcon($theIcon, 'pages', 0); } } return $theIcon; }
/** * Render the list * * @param array $pArray * @param array $lines * @param integer $c * @return array * @todo Define visibility */ public function renderList($pArray, $lines = array(), $c = 0) { if (is_array($pArray)) { reset($pArray); static $i; foreach ($pArray as $k => $v) { if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) { if (isset($pArray[$k . '_'])) { $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '"> <td nowrap><img src="clear.gif" width="1" height="1" hspace=' . $c * 10 . ' align="top">' . '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('id' => $k))) . '">' . IconUtility::getSpriteIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $k), array('title' => 'ID: ' . $k)) . GeneralUtility::fixed_lgd_cs($pArray[$k], 30) . '</a></td> <td>' . $pArray[$k . '_']['count'] . '</td> <td>' . ($pArray[$k . '_']['root_max_val'] > 0 ? IconUtility::getSpriteIcon('status-status-checked') : ' ') . '</td> <td>' . ($pArray[$k . '_']['root_min_val'] == 0 ? IconUtility::getSpriteIcon('status-status-checked') : ' ') . '</td> </tr>'; } else { $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '"> <td nowrap ><img src="clear.gif" width="1" height="1" hspace=' . $c * 10 . ' align=top>' . IconUtility::getSpriteIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $k)) . GeneralUtility::fixed_lgd_cs($pArray[$k], 30) . '</td> <td></td> <td></td> <td></td> </tr>'; } $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1); } } } return $lines; }
/** * This will render a selector box into which elements from either * the file system or database can be inserted. Relations. * * @return array As defined in initializeResultArray() of AbstractNode */ public function render() { $table = $this->globalOptions['table']; $fieldName = $this->globalOptions['fieldName']; $row = $this->globalOptions['databaseRow']; $parameterArray = $this->globalOptions['parameterArray']; $config = $parameterArray['fieldConf']['config']; $show_thumbs = $config['show_thumbs']; $resultArray = $this->initializeResultArray(); $size = isset($config['size']) ? (int)$config['size'] : $this->minimumInputWidth; $maxitems = MathUtility::forceIntegerInRange($config['maxitems'], 0); if (!$maxitems) { $maxitems = 100000; } $minitems = MathUtility::forceIntegerInRange($config['minitems'], 0); $thumbnails = array(); $allowed = GeneralUtility::trimExplode(',', $config['allowed'], TRUE); $disallowed = GeneralUtility::trimExplode(',', $config['disallowed'], TRUE); $disabled = ($this->isGlobalReadonly() || $config['readOnly']); $info = array(); $parameterArray['itemFormElID_file'] = $parameterArray['itemFormElID'] . '_files'; // whether the list and delete controls should be disabled $noList = isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'list'); $noDelete = isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'delete'); // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. $specConf = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']); // Register properties in requiredElements $resultArray['requiredElements'][$parameterArray['itemFormElName']] = array( $minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $fieldName ); $tabAndInlineStack = $this->globalOptions['tabAndInlineStack']; if (!empty($tabAndInlineStack) && preg_match('/^(.+\\])\\[(\\w+)\\]$/', $parameterArray['itemFormElName'], $match)) { array_shift($match); $resultArray['requiredNested'][$parameterArray['itemFormElName']] = array( 'parts' => $match, 'level' => $tabAndInlineStack, ); } // If maxitems==1 then automatically replace the current item (in list and file selector) if ($maxitems === 1) { $resultArray['additionalJavaScriptPost'][] = 'TBE_EDITOR.clearBeforeSettingFormValueFromBrowseWin[' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . '] = { itemFormElID_file: ' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElID_file']) . ' }'; $parameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . ', \'Remove\'); ' . $parameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged']; } elseif ($noList) { // If the list controls have been removed and the maximum number is reached, remove the first entry to avoid "write once" field $parameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = 'setFormValueManipulate(' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . ', \'RemoveFirstIfFull\', ' . GeneralUtility::quoteJSvalue($maxitems) . '); ' . $parameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged']; } $html = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '"' . $disabled . ' />'; // Acting according to either "file" or "db" type: switch ((string)$config['internal_type']) { case 'file_reference': $config['uploadfolder'] = ''; // Fall through case 'file': // Creating string showing allowed types: if (!count($allowed)) { $allowed = array('*'); } // Making the array of file items: $itemArray = GeneralUtility::trimExplode(',', $parameterArray['itemFormElValue'], TRUE); $fileFactory = ResourceFactory::getInstance(); // Correct the filename for the FAL items foreach ($itemArray as &$fileItem) { list($fileUid, $fileLabel) = explode('|', $fileItem); if (MathUtility::canBeInterpretedAsInteger($fileUid)) { $fileObject = $fileFactory->getFileObject($fileUid); $fileLabel = $fileObject->getName(); } $fileItem = $fileUid . '|' . $fileLabel; } // Showing thumbnails: if ($show_thumbs) { foreach ($itemArray as $imgRead) { $imgP = explode('|', $imgRead); $imgPath = rawurldecode($imgP[0]); // FAL icon production if (MathUtility::canBeInterpretedAsInteger($imgP[0])) { $fileObject = $fileFactory->getFileObject($imgP[0]); if ($fileObject->isMissing()) { $thumbnails[] = array( 'message' => \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject)->render() ); } elseif (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getExtension())) { $thumbnails[] = array( 'name' => htmlspecialchars($fileObject->getName()), 'image' => $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array())->getPublicUrl(TRUE) ); } else { // Icon $thumbnails[] = array( 'name' => htmlspecialchars($fileObject->getName()), 'image' => IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName())) ); } } else { $rowCopy = array(); $rowCopy[$fieldName] = $imgPath; try { $thumbnails[] = array( 'name' => $imgPath, 'image' => BackendUtility::thumbCode( $rowCopy, $table, $fieldName, '', '', $config['uploadfolder'], 0, ' align="middle"' ) ); } catch (\Exception $exception) { /** @var $flashMessage FlashMessage */ $message = $exception->getMessage(); $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, htmlspecialchars($message), '', FlashMessage::ERROR, TRUE ); /** @var $flashMessageService FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); $logMessage = $message . ' (' . $table . ':' . $row['uid'] . ')'; GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING); } } } } // Creating the element: $params = array( 'size' => $size, 'allowed' => $allowed, 'disallowed' => $disallowed, 'dontShowMoveIcons' => $maxitems <= 1, 'autoSizeMax' => MathUtility::forceIntegerInRange($config['autoSizeMax'], 0), 'maxitems' => $maxitems, 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : '', 'thumbnails' => $thumbnails, 'readOnly' => $disabled, 'noBrowser' => $noList || isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'browser'), 'noList' => $noList, 'noDelete' => $noDelete ); $html .= $this->dbFileIcons( $parameterArray['itemFormElName'], 'file', implode(',', $allowed), $itemArray, '', $params, $parameterArray['onFocus'], '', '', '', $config); if (!$disabled && !(isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'upload'))) { // Adding the upload field: $isDirectFileUploadEnabled = (bool)$this->getBackendUserAuthentication()->uc['edit_docModuleUpload']; if ($isDirectFileUploadEnabled && $config['uploadfolder']) { // Insert the multiple attribute to enable HTML5 multiple file upload $multipleAttribute = ''; $multipleFilenameSuffix = ''; if (isset($config['maxitems']) && $config['maxitems'] > 1) { $multipleAttribute = ' multiple="multiple"'; $multipleFilenameSuffix = '[]'; } $html .= ' <div id="' . $parameterArray['itemFormElID_file'] . '"> <input type="file"' . $multipleAttribute . ' name="data_files' . $this->globalOptions['elementBaseName'] . $multipleFilenameSuffix . '" size="35" onchange="' . implode('', $parameterArray['fieldChangeFunc']) . '" /> </div>'; } } break; case 'folder': // If the element is of the internal type "folder": // Array of folder items: $itemArray = GeneralUtility::trimExplode(',', $parameterArray['itemFormElValue'], TRUE); // Creating the element: $params = array( 'size' => $size, 'dontShowMoveIcons' => $maxitems <= 1, 'autoSizeMax' => MathUtility::forceIntegerInRange($config['autoSizeMax'], 0), 'maxitems' => $maxitems, 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : '', 'readOnly' => $disabled, 'noBrowser' => $noList || isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'browser'), 'noList' => $noList ); $html .= $this->dbFileIcons( $parameterArray['itemFormElName'], 'folder', '', $itemArray, '', $params, $parameterArray['onFocus'] ); break; case 'db': // If the element is of the internal type "db": // Creating string showing allowed types: $onlySingleTableAllowed = FALSE; $languageService = $this->getLanguageService(); $allowedTables = array(); if ($allowed[0] === '*') { $allowedTables = array( 'name' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.allTables')) ); } elseif ($allowed) { $onlySingleTableAllowed = count($allowed) == 1; foreach ($allowed as $allowedTable) { $allowedTables[] = array( 'name' => htmlspecialchars($languageService->sL($GLOBALS['TCA'][$allowedTable]['ctrl']['title'])), 'icon' => IconUtility::getSpriteIconForRecord($allowedTable, array()), 'onClick' => 'setFormValueOpenBrowser(\'db\', ' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName'] . '|||' . $allowedTable) . '); return false;' ); } } $perms_clause = $this->getBackendUserAuthentication()->getPagePermsClause(1); $itemArray = array(); // Thumbnails: $temp_itemArray = GeneralUtility::trimExplode(',', $parameterArray['itemFormElValue'], TRUE); foreach ($temp_itemArray as $dbRead) { $recordParts = explode('|', $dbRead); list($this_table, $this_uid) = BackendUtility::splitTable_Uid($recordParts[0]); // For the case that no table was found and only a single table is defined to be allowed, use that one: if (!$this_table && $onlySingleTableAllowed) { $this_table = $allowed; } $itemArray[] = array('table' => $this_table, 'id' => $this_uid); if (!$disabled && $show_thumbs) { $rr = BackendUtility::getRecordWSOL($this_table, $this_uid); $thumbnails[] = array( 'name' => BackendUtility::getRecordTitle($this_table, $rr, TRUE), 'image' => IconUtility::getSpriteIconForRecord($this_table, $rr), 'path' => BackendUtility::getRecordPath($rr['pid'], $perms_clause, 15), 'uid' => $rr['uid'], 'table' => $this_table ); } } // Creating the element: $params = array( 'size' => $size, 'dontShowMoveIcons' => $maxitems <= 1, 'autoSizeMax' => MathUtility::forceIntegerInRange($config['autoSizeMax'], 0), 'maxitems' => $maxitems, 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : '', 'info' => $info, 'allowedTables' => $allowedTables, 'thumbnails' => $thumbnails, 'readOnly' => $disabled, 'noBrowser' => $noList || isset($config['disable_controls']) && GeneralUtility::inList($config['disable_controls'], 'browser'), 'noList' => $noList ); $html .= $this->dbFileIcons( $parameterArray['itemFormElName'], 'db', implode(',', $allowed), $itemArray, '', $params, $parameterArray['onFocus'], $table, $fieldName, $row['uid'], $config ); break; } // Wizards: $altItem = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />'; if (!$disabled) { $html = $this->renderWizards( array( $html, $altItem ), $config['wizards'], $table, $row, $fieldName, $parameterArray, $parameterArray['itemFormElName'], $specConf ); } $resultArray['html'] = $html; return $resultArray; }
/** * Create record header (includes teh record icon, record title etc.) * * @param array $row Record row. * @return string HTML */ public function getRecordHeader($row) { $line = IconUtility::getSpriteIconForRecord('tt_content', $row, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($row, 'tt_content')))); $line .= BackendUtility::getRecordTitle('tt_content', $row, TRUE); return $this->wrapRecordTitle($line, $row); }
/** * Gets the icon for the shortcut * * @param array $row * @param array $shortcut * @return string Shortcut icon as img tag */ protected function getShortcutIcon($row, $shortcut) { $databaseConnection = $this->getDatabaseConnection(); $languageService = $this->getLanguageService(); $titleAttribute = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut', TRUE); switch ($row['module_name']) { case 'xMOD_alt_doc.php': $table = $shortcut['table']; $recordid = $shortcut['recordid']; $icon = ''; if ($shortcut['type'] == 'edit') { // Creating the list of fields to include in the SQL query: $selectFields = $this->fieldArray; $selectFields[] = 'uid'; $selectFields[] = 'pid'; if ($table == 'pages') { $selectFields[] = 'module'; $selectFields[] = 'extendToSubpages'; $selectFields[] = 'doktype'; } if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) { $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']); } if ($GLOBALS['TCA'][$table]['ctrl']['type']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type']; } if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) { $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column']; } if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { $selectFields[] = 't3ver_state'; } // Unique list! $selectFields = array_unique($selectFields); $permissionClause = $table === 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : ''; $sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table)); $result = $databaseConnection->exec_SELECT_queryArray($sqlQueryParts); $row = $databaseConnection->sql_fetch_assoc($result); $icon = IconUtility::getSpriteIconForRecord($table, (array) $row, array('title' => $titleAttribute)); } elseif ($shortcut['type'] == 'new') { $icon = IconUtility::getSpriteIconForRecord($table, array(), array('title' => $titleAttribute)); } break; case 'file_edit': $icon = IconUtility::getSpriteIcon('mimetypes-text-html', array('title' => $titleAttribute)); break; case 'wizard_rte': $icon = IconUtility::getSpriteIcon('mimetypes-word', array('title' => $titleAttribute)); break; default: if ($languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']) { $icon = $languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']; // Change icon of fileadmin references - otherwise it doesn't differ with Web->List $icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon); if (GeneralUtility::isAbsPath($icon)) { $icon = '../' . PathUtility::stripPathSitePrefix($icon); } // @todo: hardcoded width as we don't have a way to address module icons with an API yet. $icon = '<img src="' . htmlspecialchars($icon) . '" alt="' . $titleAttribute . '" width="16">'; } else { $icon = IconUtility::getSpriteIcon('empty-empty', array('title' => $titleAttribute)); } } return $icon; }
/** * [Describe function...] * * @param [type] $arr: ... * @param [type] $depthData: ... * @param [type] $keyArray: ... * @param [type] $first: ... * @return [type] ... * @todo Define visibility */ public function ext_getTemplateHierarchyArr($arr, $depthData, $keyArray, $first = 0) { $keyArr = array(); foreach ($arr as $key => $value) { $key = preg_replace('/\\.$/', '', $key); if (substr($key, -1) != '.') { $keyArr[$key] = 1; } } $a = 0; $c = count($keyArr); static $i = 0; foreach ($keyArr as $key => $value) { $HTML = ''; $a++; $deeper = is_array($arr[$key . '.']); $row = $arr[$key]; $PM = 'join'; $LN = $a == $c ? 'blank' : 'line'; $BTM = $a == $c ? 'top' : ''; $PM = 'join'; $HTML .= $depthData; $alttext = '[' . $row['templateID'] . ']'; $alttext .= $row['pid'] ? ' - ' . BackendUtility::getRecordPath($row['pid'], $GLOBALS['SOBE']->perms_clause, 20) : ''; $icon = substr($row['templateID'], 0, 3) == 'sys' ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('sys_template', $row, array('title' => $alttext)) : \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('mimetypes-x-content-template-static', array('title' => $alttext)); if (in_array($row['templateID'], $this->clearList_const) || in_array($row['templateID'], $this->clearList_setup)) { $urlParameters = array('id' => $GLOBALS['SOBE']->id, 'template' => $row['templateID']); $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters); $A_B = '<a href="' . htmlspecialchars($aHref) . '">'; $A_E = '</a>'; if (GeneralUtility::_GP('template') == $row['templateID']) { $A_B = '<strong>' . $A_B; $A_E .= '</strong>'; } } else { $A_B = ''; $A_E = ''; } $HTML .= ($first ? '' : IconUtility::getSpriteIcon('treeline-' . $PM . $BTM)) . $icon . $A_B . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . $A_E . ' '; $RL = $this->ext_getRootlineNumber($row['pid']); $keyArray[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '"> <td nowrap="nowrap">' . $HTML . '</td> <td align="center">' . ($row['root'] ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '') . ' </td> <td align="center">' . ($row['clConf'] ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '') . ' ' . '</td> <td align="center">' . ($row['clConst'] ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '') . ' ' . '</td> <td align="center">' . ($row['pid'] ?: '') . '</td> <td align="center">' . (strcmp($RL, '') ? $RL : '') . '</td> <td>' . ($row['next'] ? ' ' . $row['next'] . ' ' : '') . '</td> </tr>'; if ($deeper) { $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key . '.'], $depthData . ($first ? '' : IconUtility::getSpriteIcon('treeline-' . $LN)), $keyArray); } } return $keyArray; }
/** * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc. * Later on the command-icons are inserted here. * * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...) * @param string $foreign_table The foreign_table we create a header for * @param array $rec The current record of that foreign_table * @param array $config content of $PA['fieldConf']['config'] * @param boolean $isVirtualRecord * @return string The HTML code of the header * @todo Define visibility */ public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE) { // Init: $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid']; // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter) // Pre-Processing: $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec); $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE; $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE; // Get the record title/label for a record: // Try using a self-defined user function only for formatted labels if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) { $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'] : array(), 'parent' => array('uid' => $parentUid, 'config' => $config)); // callUserFunction requires a third parameter, but we don't want to give $this as reference! $null = NULL; GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null); $recTitle = $params['title']; // Try using a normal self-defined user function } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) { $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config)); // callUserFunction requires a third parameter, but we don't want to give $this as reference! $null = NULL; GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null); $recTitle = $params['title']; } elseif ($hasForeignLabel || $hasSymmetricLabel) { $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label']; $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol); // Render title for everything else than group/db: if ($foreignConfig['type'] != 'groupdb') { $recTitle = BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE); } else { // $recTitle could be something like: "tx_table_123|...", $valueParts = GeneralUtility::trimExplode('|', $rec[$titleCol]); $itemParts = GeneralUtility::revExplode('_', $valueParts[0], 2); $recTemp = BackendUtility::getRecordWSOL($itemParts[0], $itemParts[1]); $recTitle = BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE); } $recTitle = BackendUtility::getRecordTitlePrep($recTitle); if (trim($recTitle) === '') { $recTitle = BackendUtility::getNoRecordTitle(TRUE); } } else { $recTitle = BackendUtility::getRecordTitle($foreign_table, $rec, TRUE); } $altText = BackendUtility::getRecordIconAltText($rec, $foreign_table); $iconImg = IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon')); $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>'; $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord); $thumbnail = FALSE; // Renders a thumbnail for the header if (!empty($config['appearance']['headerThumbnail']['field'])) { $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']]; $firstElement = array_shift(GeneralUtility::trimExplode(',', $fieldValue)); $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement)); if (!empty($fileUid)) { $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid); if ($fileObject && $fileObject->isMissing()) { $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject); $thumbnail = $flashMessage->render(); } elseif ($fileObject) { $imageSetup = $config['appearance']['headerThumbnail']; unset($imageSetup['field']); $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup); $processedImage = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup); // Only use a thumbnail if the processing was successful. if (!$processedImage->usesOriginalFile()) { $imageUrl = $processedImage->getPublicUrl(TRUE); $thumbnail = '<img class="t3-form-field-header-inline-thumbnail-image" src="' . $imageUrl . '" alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '">'; } } } } if (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail) { $headerClasses = ' t3-form-field-header-inline-has-thumbnail'; $mediaContainer = '<div class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>'; } else { $headerClasses = ' t3-form-field-header-inline-has-icon'; $mediaContainer = '<div class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>'; } $header = '<div class="t3-form-field-header-inline-wrap' . $headerClasses . '">' . '<div class="t3-form-field-header-inline-ctrl">' . $ctrl . '</div>' . '<div class="t3-form-field-header-inline-body">' . $mediaContainer . '<div class="t3-form-field-header-inline-summary">' . $label . '</div>' . '</div>' . '</div>'; return $header; }
/** * For TYPO3 Element Browser: This lists all content elements from the given list of tables * * @param string $tables Comma separated list of tables. Set to "*" if you want all tables. * @return string HTML output. * @todo Define visibility */ public function TBE_expandPage($tables) { $out = ''; if ($this->expandPage >= 0 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->expandPage) && $GLOBALS['BE_USER']->isInWebMount($this->expandPage)) { // Set array with table names to list: if (trim($tables) === '*') { $tablesArr = array_keys($GLOBALS['TCA']); } else { $tablesArr = GeneralUtility::trimExplode(',', $tables, TRUE); } reset($tablesArr); // Headline for selecting records: $out .= $this->barheader($GLOBALS['LANG']->getLL('selectRecords') . ':'); // Create the header, showing the current page for which the listing is. // Includes link to the page itself, if pages are amount allowed tables. $titleLen = (int) $GLOBALS['BE_USER']->uc['titleLen']; $mainPageRec = BackendUtility::getRecordWSOL('pages', $this->expandPage); $ATag = ''; $ATag_e = ''; $ATag2 = ''; $picon = ''; if (is_array($mainPageRec)) { $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec); if (in_array('pages', $tablesArr)) { $ATag = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',1);">'; $ATag2 = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',0);">'; $ATag_e = '</a>'; } } $pBicon = $ATag2 ? '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : ''; $pText = htmlspecialchars(GeneralUtility::fixed_lgd_cs($mainPageRec['title'], $titleLen)); $out .= $picon . $ATag2 . $pBicon . $ATag_e . $ATag . $pText . $ATag_e . '<br />'; // Initialize the record listing: $id = $this->expandPage; $pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000); $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); $pageInfo = BackendUtility::readPageAccess($id, $perms_clause); // Generate the record list: /** @var $dbList \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */ if (is_object($this->recordList)) { $dbList = $this->recordList; } else { $dbList = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList'); } $dbList->thisScript = $this->thisScript; $dbList->backPath = $GLOBALS['BACK_PATH']; $dbList->thumbs = 0; $dbList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo); $dbList->noControlPanels = 1; $dbList->clickMenuEnabled = 0; $dbList->tableList = implode(',', $tablesArr); $pArr = explode('|', $this->bparams); // a string like "data[pages][79][storage_pid]" $fieldPointerString = $pArr[0]; // parts like: data, pages], 79], storage_pid] $fieldPointerParts = explode('[', $fieldPointerString); $relatingTableName = substr($fieldPointerParts[1], 0, -1); $relatingFieldName = substr($fieldPointerParts[3], 0, -1); if ($relatingTableName && $relatingFieldName) { $dbList->setRelatingTableAndField($relatingTableName, $relatingFieldName); } $dbList->start($id, GeneralUtility::_GP('table'), $pointer, GeneralUtility::_GP('search_field'), GeneralUtility::_GP('search_levels'), GeneralUtility::_GP('showLimit')); $dbList->setDispFields(); $dbList->generateList(); // Add the HTML for the record list to output variable: $out .= $dbList->HTMLcode; // Add support for fieldselectbox in singleTableMode if ($dbList->table) { $out .= $dbList->fieldSelectBox($dbList->table); } $out .= $dbList->getSearchBox(); } // Return accumulated content: return $out; }
/** * Make 1st level clickmenu: * * @param string $table The absolute path * @param integer $srcId UID for the current record. * @param integer $dstId Destination ID * @return string HTML content * @todo Define visibility */ public function printDragDropClickMenu($table, $srcId, $dstId) { $menuItems = array(); // If the drag and drop menu should apply to PAGES use this set of menu items if ($table == 'pages') { // Move Into: $menuItems['movePage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'into'); // Move After: $menuItems['movePage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'after'); // Copy Into: $menuItems['copyPage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'into'); // Copy After: $menuItems['copyPage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'after'); } // If the drag and drop menu should apply to FOLDERS use this set of menu items if ($table == 'folders') { // Move Into: $menuItems['moveFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'move'); // Copy Into: $menuItems['copyFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'copy'); } // Adding external elements to the menuItems array $menuItems = $this->processingByExtClassArray($menuItems, 'dragDrop_' . $table, $srcId); // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar // Processing by external functions? $menuItems = $this->externalProcessingOfDBMenuItems($menuItems); // Return the printed elements: return $this->printItems($menuItems, \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $this->rec, array('title' => \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $this->rec, TRUE)))); }
/** * Main * * @return string * @todo Define visibility */ public function main() { $theOutput = ''; // Initializes the module. Done in this function because we may need to re-initialize if data is submitted! // Checking for more than one template an if, set a menu... $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; } // BUGBUG: Should we check if the uset may at all read and write template-records??? $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize if ($existTemplate) { $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('currentTemplate', TRUE), \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('sys_template', $GLOBALS['tplRow']) . '<strong>' . $this->pObj->linkWrapTemplateTitle($GLOBALS['tplRow']['title']) . '</strong>' . htmlspecialchars(trim($GLOBALS['tplRow']['sitetitle']) ? ' (' . $GLOBALS['tplRow']['sitetitle'] . ')' : '')); } if ($manyTemplatesMenu) { $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu); } $GLOBALS['tmpl']->clearList_const_temp = array_flip($GLOBALS['tmpl']->clearList_const); $GLOBALS['tmpl']->clearList_setup_temp = array_flip($GLOBALS['tmpl']->clearList_setup); $pointer = count($GLOBALS['tmpl']->hierarchyInfo); $hierarchyInfo = $GLOBALS['tmpl']->ext_process_hierarchyInfo(array(), $pointer); $head = '<thead><tr>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('title', TRUE) . '</th>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('rootlevel', TRUE) . '</th>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('clearSetup', TRUE) . '</th>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('clearConstants', TRUE) . '</th>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('pid', TRUE) . '</th>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('rootline', TRUE) . '</th>'; $head .= '<th>' . $GLOBALS['LANG']->getLL('nextLevel', TRUE) . '</th>'; $head .= '</tr></thead>'; $hierar = implode(array_reverse($GLOBALS['tmpl']->ext_getTemplateHierarchyArr($hierarchyInfo, '', array(), 1)), ''); $hierar = '<table class="t3-table" id="ts-analyzer">' . $head . $hierar . '</table>'; $theOutput .= $this->pObj->doc->spacer(5); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateHierarchy', TRUE), $hierar, 0, 1); $urlParameters = array('id' => $GLOBALS['SOBE']->id, 'template' => 'all'); $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters); $completeLink = '<p><a href="' . htmlspecialchars($aHref) . '" class="t3-button">' . $GLOBALS['LANG']->getLL('viewCompleteTS', TRUE) . '</a></p>'; $theOutput .= $this->pObj->doc->spacer(5); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('completeTS', TRUE), $completeLink, 0, 1); $theOutput .= $this->pObj->doc->spacer(15); // Output options $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('displayOptions', TRUE), '', FALSE, TRUE); $addParams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') ? '&template=' . \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') : ''; $theOutput .= '<div class="tst-analyzer-options">' . '<div class="checkbox"><label for="checkTs_analyzer_checkLinenum">' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkLinenum]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], '', $addParams, 'id="checkTs_analyzer_checkLinenum"') . $GLOBALS['LANG']->getLL('lineNumbers', TRUE) . '</label></div>' . '<div class="checkbox"><label for="checkTs_analyzer_checkSyntax">' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkSyntax]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], '', $addParams, 'id="checkTs_analyzer_checkSyntax"') . $GLOBALS['LANG']->getLL('syntaxHighlight', TRUE) . '</label> ' . '</label></div>'; if (!$this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax']) { $theOutput .= '<div class="checkbox"><label for="checkTs_analyzer_checkComments">' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkComments]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], '', $addParams, 'id="checkTs_analyzer_checkComments"') . $GLOBALS['LANG']->getLL('comments', TRUE) . '</label></div>' . '<div class="checkbox"><label for="checkTs_analyzer_checkCrop">' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkCrop]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], '', $addParams, 'id="checkTs_analyzer_checkCrop"') . $GLOBALS['LANG']->getLL('cropLines', TRUE) . '</label></div>'; } $theOutput .= '</div>'; $theOutput .= $this->pObj->doc->spacer(25); // Output Constants if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template')) { $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants', TRUE), '', 0, 1); $theOutput .= $this->pObj->doc->sectionEnd(); $theOutput .= ' <table class="t3-table ts-typoscript"> '; // Don't know why -2 and not 0... :-) But works. $GLOBALS['tmpl']->ext_lineNumberOffset = 0; $GLOBALS['tmpl']->ext_lineNumberOffset_mode = 'const'; foreach ($GLOBALS['tmpl']->constants as $key => $val) { $currentTemplateId = $GLOBALS['tmpl']->hierarchyInfo[$key]['templateID']; if ($currentTemplateId == \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') || \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') == 'all') { $theOutput .= ' <tr> <td><strong>' . htmlspecialchars($GLOBALS['tmpl']->hierarchyInfo[$key]['title']) . '</strong></td> </tr> <tr> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td nowrap="nowrap">' . $GLOBALS['tmpl']->ext_outputTS(array($val), $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0) . '</td></tr></table> </td> </tr> '; if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') != 'all') { break; } } $GLOBALS['tmpl']->ext_lineNumberOffset += count(explode(LF, $val)) + 1; } $theOutput .= ' </table> '; } // Output setup if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template')) { $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup', TRUE), '', 0, 1); $theOutput .= $this->pObj->doc->sectionEnd(); $theOutput .= ' <table class="t3-table ts-typoscript"> '; $GLOBALS['tmpl']->ext_lineNumberOffset = 0; $GLOBALS['tmpl']->ext_lineNumberOffset_mode = 'setup'; foreach ($GLOBALS['tmpl']->config as $key => $val) { $currentTemplateId = $GLOBALS['tmpl']->hierarchyInfo[$key]['templateID']; if ($currentTemplateId == \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') || \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') == 'all') { $theOutput .= ' <tr> <td><strong>' . htmlspecialchars($GLOBALS['tmpl']->hierarchyInfo[$key]['title']) . '</strong></td></tr> <tr> <td><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td nowrap="nowrap">' . $GLOBALS['tmpl']->ext_outputTS(array($val), $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0) . '</td></tr></table> </td> </tr> '; if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') != 'all') { break; } } $GLOBALS['tmpl']->ext_lineNumberOffset += count(explode(LF, $val)) + 1; } $theOutput .= ' </table> '; } return $theOutput; }
/** * Gets all localizations of the current record. * * @param string $table The table * @param array $parentRec The current record * @param string $bgColClass Class for the background color of a column * @param string $pad Pad reference * @return string HTML table rows * @todo Define visibility */ public function getLocalizations($table, $parentRec, $bgColClass, $pad) { $lines = array(); $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl']; if ($table != 'pages' && \TYPO3\CMS\Backend\Utility\BackendUtility::isTableLocalizable($table) && !$tcaCtrl['transOrigPointerTable']) { $where = array(); $where[] = $tcaCtrl['transOrigPointerField'] . '=' . intval($parentRec['uid']); $where[] = $tcaCtrl['languageField'] . '<>0'; if (isset($tcaCtrl['delete']) && $tcaCtrl['delete']) { $where[] = $tcaCtrl['delete'] . '=0'; } if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) { $where[] = 't3ver_wsid=' . $parentRec['t3ver_wsid']; } $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, implode(' AND ', $where)); if (is_array($rows)) { $modeData = ''; if ($pad == 'normal') { $mode = $this->clipData['normal']['mode'] == 'copy' ? 'copy' : 'cut'; $modeData = ' <strong>(' . $this->clLabel($mode, 'cm') . ')</strong>'; } foreach ($rows as $rec) { $lines[] = ' <tr> <td class="' . $bgColClass . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $rec, array('style' => 'margin-left: 38px;')) . '</td> <td class="' . $bgColClass . '" nowrap="nowrap" width="95%"> ' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) . $modeData . ' </td> <td class="' . $bgColClass . '" align="center" nowrap="nowrap"> </td> </tr>'; } } } return implode('', $lines); }
/** * Returns the recent documents list as an array * * @param array $document * @param string $md5sum * @param bool $isRecentDoc * @param bool $isFirstDoc * @return array All recent documents as list-items */ protected function renderMenuEntry($document, $md5sum, $isRecentDoc = FALSE, $isFirstDoc = FALSE) { $table = $document[3]['table']; $uid = $document[3]['uid']; $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $uid); if (!is_array($record)) { // Record seems to be deleted return ''; } $label = htmlspecialchars(strip_tags(htmlspecialchars_decode($document[0]))); $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $record); $link = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_edit') . '&' . $document[2]; $pageId = (int) $document[3]['uid']; if ($document[3]['table'] !== 'pages') { $pageId = (int) $document[3]['pid']; } $onClickCode = 'jump(' . GeneralUtility::quoteJSvalue($link) . ', \'web_list\', \'web\', ' . $pageId . '); TYPO3.OpendocsMenu.toggleMenu(); return false;'; if (!$isRecentDoc) { $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE); // Open document $closeIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-close'); $entry = ' <li class="opendoc"> <a href="#" class="dropdown-list-link dropdown-link-list-add-close" onclick="' . htmlspecialchars($onClickCode) . '" target="content">' . $icon . ' ' . $label . '</a> <a href="#" class="dropdown-list-link-close" data-opendocsidentifier="' . $md5sum . '" title="' . $title . '">' . $closeIcon . '</a> </li>'; } else { // Recently used document $entry = ' <li> <a href="#" class="dropdown-list-link" onclick="' . htmlspecialchars($onClickCode) . '" target="content">' . $icon . ' ' . $label . '</a> </li>'; } return $entry; }
/** * Displays one line of the broken links table * * @param string $table Name of database table * @param array $row Record row to be processed * @param array $brokenLinksItemTemplate Markup of the template to be used * @return string HTML of the rendered row */ protected function renderTableRow($table, array $row, $brokenLinksItemTemplate) { $markerArray = array(); $fieldName = ''; // Restore the linktype object $hookObj = $this->hookObjectsArr[$row['link_type']]; // Construct link to edit the content element $requestUri = GeneralUtility::getIndpEnv('REQUEST_URI') . '&id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel; $actionLink = '<a href="#" onclick="'; $actionLink .= htmlspecialchars(BackendUtility::editOnClick('&edit[' . $table . '][' . $row['record_uid'] . ']=edit', '', $requestUri)); $actionLink .= '" title="' . $this->getLanguageService()->getLL('list.edit') . '">'; $actionLink .= IconUtility::getSpriteIcon('actions-document-open'); $actionLink .= '</a>'; $elementHeadline = $row['headline']; if (empty($elementHeadline)) { $elementHeadline = '<i>' . $this->getLanguageService()->getLL('list.no.headline') . '</i>'; } // Get the language label for the field from TCA if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) { $fieldName = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']); // Crop colon from end if present if (substr($fieldName, '-1', '1') === ':') { $fieldName = substr($fieldName, '0', strlen($fieldName) - 1); } } // Fallback, if there is no label $fieldName = !empty($fieldName) ? $fieldName : $row['field']; // column "Element" $element = IconUtility::getSpriteIconForRecord($table, $row, array('title' => $table . ':' . $row['record_uid'])); $element .= $elementHeadline; $element .= ' ' . sprintf($this->getLanguageService()->getLL('list.field'), $fieldName); $markerArray['actionlink'] = $actionLink; $markerArray['path'] = BackendUtility::getRecordPath($row['record_pid'], '', 0, 0); $markerArray['element'] = $element; $markerArray['headlink'] = $row['link_title']; $markerArray['linktarget'] = $hookObj->getBrokenUrl($row); $response = unserialize($row['url_response']); if ($response['valid']) { $linkMessage = '<span class="valid">' . $this->getLanguageService()->getLL('list.msg.ok') . '</span>'; } else { $linkMessage = '<span class="error">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>'; } $markerArray['linkmessage'] = $linkMessage; $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']); $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']); $markerArray['lastcheck'] = sprintf($this->getLanguageService()->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime); // Return the table html code as string return HtmlParser::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE); }
/** * Return a page tree * * @param integer $pageUid page to start with * @param integer $treeLevel count of levels * @return \TYPO3\CMS\Backend\Tree\View\PageTreeView * @throws \Exception */ public static function pageTree($pageUid, $treeLevel) { if (TYPO3_MODE !== 'BE') { throw new \Exception('Page::pageTree does only work in the backend!'); } /* @var $tree \TYPO3\CMS\Backend\Tree\View\PageTreeView */ $tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView'); $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1)); $treeStartingRecord = BackendUtility::getRecord('pages', $pageUid); BackendUtility::workspaceOL('pages', $treeStartingRecord); // Creating top icon; the current page $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => IconUtility::getSpriteIconForRecord('pages', $treeStartingRecord)); $tree->getTree($pageUid, $treeLevel, ''); return $tree; }
/** * Process the Database operation to get the search result. * * @param string $tableName Database table name * @param string $where * @param string $orderBy * @param string $limit MySql Limit notation * @return array * @see t3lib_db::exec_SELECT_queryArray() * @see t3lib_db::sql_num_rows() * @see t3lib_db::sql_fetch_assoc() * @see t3lib_iconWorks::getSpriteIconForRecord() * @see getTitleFromCurrentRow() * @see getEditLink() */ protected function getRecordArray($tableName, $where, $orderBy, $limit) { $collect = array(); $isFirst = TRUE; $queryParts = array('SELECT' => '*', 'FROM' => $tableName, 'WHERE' => $where, 'ORDERBY' => $orderBy, 'LIMIT' => $limit); $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $collect[] = array('id' => $tableName . ':' . $row['uid'], 'pageId' => $tableName === 'pages' ? $row['uid'] : $row['pid'], 'recordTitle' => $isFirst ? $this->getRecordTitlePrep($this->getTitleOfCurrentRecordType($tableName), self::GROUP_TITLE_MAX_LENGTH) : '', 'iconHTML' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($tableName, $row), 'title' => $this->getRecordTitlePrep($this->getTitleFromCurrentRow($tableName, $row), self::RECORD_TITLE_MAX_LENGTH), 'editLink' => $this->getEditLink($tableName, $row)); $isFirst = FALSE; } $GLOBALS['TYPO3_DB']->sql_free_result($result); return $collect; }
/** * Main * * @return string */ public function main() { $lang = $this->getLanguageService(); $POST = GeneralUtility::_POST(); $documentTemplate = $this->getDocumentTemplate(); // Checking for more than one template an if, set a menu... $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; } $bType = $this->pObj->MOD_SETTINGS['ts_browser_type']; $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); $tplRow = $this->getTemplateRow(); // initialize $theOutput = ''; if ($existTemplate) { $content = ' ' . IconUtility::getSpriteIconForRecord('sys_template', $tplRow) . ' <strong>' . $this->pObj->linkWrapTemplateTitle($tplRow['title'], $bType == 'setup' ? 'config' : 'constants') . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' (' . $tplRow['sitetitle'] . ')' : ''); $theOutput .= $this->pObj->doc->section($lang->getLL('currentTemplate'), $content); if ($manyTemplatesMenu) { $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu); } $theOutput .= $this->pObj->doc->spacer(10); if ($POST['add_property'] || $POST['update_value'] || $POST['clear_object']) { // add property $line = ''; if (is_array($POST['data'])) { $name = key($POST['data']); if ($POST['data'][$name]['name'] !== '') { // Workaround for this special case: User adds a key and submits by pressing the return key. The form however will use "add_property" which is the name of the first submit button in this form. unset($POST['update_value']); $POST['add_property'] = 'Add'; } if ($POST['add_property']) { $property = trim($POST['data'][$name]['name']); if (preg_replace('/[^a-zA-Z0-9_\\.]*/', '', $property) != $property) { $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noSpaces') . '<br />' . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), FlashMessage::ERROR); $this->addFlashMessage($badPropertyMessage); } else { $pline = $name . '.' . $property . ' = ' . trim($POST['data'][$name]['propertyValue']); $propertyAddedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('propertyAdded')); $this->addFlashMessage($propertyAddedMessage); $line .= LF . $pline; } } elseif ($POST['update_value']) { $pline = $name . ' = ' . trim($POST['data'][$name]['value']); $updatedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('valueUpdated')); $this->addFlashMessage($updatedMessage); $line .= LF . $pline; } elseif ($POST['clear_object']) { if ($POST['data'][$name]['clearValue']) { $pline = $name . ' >'; $objectClearedMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($pline), $lang->getLL('objectCleared')); $this->addFlashMessage($objectClearedMessage); $line .= LF . $pline; } } } if ($line) { $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; // Set the data to be saved $recData = array(); $field = $bType == 'setup' ? 'config' : 'constants'; $recData['sys_template'][$saveId][$field] = $tplRow[$field] . $line; // Create new tce-object $tce = GeneralUtility::makeInstance(DataHandler::class); $tce->stripslashes_values = FALSE; // Initialize $tce->start($recData, array()); // Saved the stuff $tce->process_datamap(); // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php) $tce->clear_cacheCmd('all'); // re-read the template ... $this->initialize_editor($this->pObj->id, $template_uid); } } } $tsbr = GeneralUtility::_GET('tsbr'); $templateService = $this->getExtendedTemplateService(); $update = 0; if (is_array($tsbr)) { // If any plus-signs were clicked, it's registred. $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]); $update = 1; } if ($POST['Submit']) { // If any POST-vars are send, update the condition array $this->pObj->MOD_SETTINGS['tsbrowser_conditions'] = $POST['conditions']; $update = 1; } if ($update) { $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS); } $templateService->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions']; $templateService->matchAlternative[] = 'dummydummydummydummydummydummydummydummydummydummydummy'; // This is just here to make sure that at least one element is in the array so that the tsparser actually uses this array to match. $templateService->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const']; if ($this->pObj->sObj && $templateService->constantMode) { $templateService->constantMode = 'untouched'; } $templateService->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch']; $templateService->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']; $templateService->linkObjects = TRUE; $templateService->ext_regLinenumbers = TRUE; $templateService->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments']; $templateService->bType = $bType; if ($this->pObj->MOD_SETTINGS['ts_browser_type'] == 'const') { $templateService->ext_constants_BRP = (int) GeneralUtility::_GP('breakPointLN'); } else { $templateService->ext_config_BRP = (int) GeneralUtility::_GP('breakPointLN'); } $templateService->generateConfig(); if ($bType == 'setup') { $theSetup = $templateService->setup; } else { $theSetup = $templateService->setup_constants; } // EDIT A VALUE: if ($this->pObj->sObj) { list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : ''); if ($existTemplate) { // Value $out = ''; $out .= htmlspecialchars($this->pObj->sObj) . ' =<br />'; $out .= '<input type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][value]" value="' . htmlspecialchars($theSetupValue) . '"' . $documentTemplate->formWidth(40) . ' />'; $out .= '<input class="btn btn-default" type="submit" name="update_value" value="' . $lang->getLL('updateButton') . '" />'; $theOutput .= $this->pObj->doc->section($lang->getLL('editProperty'), $out, 0, 0); // Property $out = '<span class="text-nowrap">' . htmlspecialchars($this->pObj->sObj) . '.'; $out .= '<input type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][name]"' . $documentTemplate->formWidth(20) . ' /> = </span><br />'; $out .= '<input type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][propertyValue]"' . $documentTemplate->formWidth(40) . ' />'; $out .= '<input class="btn btn-default" type="submit" name="add_property" value="' . $lang->getLL('addButton') . '" />'; $theOutput .= $this->pObj->doc->spacer(20); $theOutput .= $this->pObj->doc->section($lang->getLL('addProperty'), $out, 0, 0); // clear $out = htmlspecialchars($this->pObj->sObj) . ' <strong>' . $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('clear'), 'toUpper') . '</strong> '; $out .= '<input type="checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) . '][clearValue]" value="1" />'; $out .= '<input class="btn btn-default" type="submit" name="clear_object" value="' . $lang->getLL('clearButton') . '" />'; $theOutput .= $this->pObj->doc->spacer(20); $theOutput .= $this->pObj->doc->section($lang->getLL('clearObject'), $out, 0, 0); $theOutput .= $this->pObj->doc->spacer(10); } else { $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noCurrentTemplate'), $lang->getLL('edit'), FlashMessage::ERROR); $this->addFlashMessage($noTemplateMessage); $theOutput .= htmlspecialchars($this->pObj->sObj) . ' = <strong>' . htmlspecialchars($theSetupValue) . '</strong>'; $theOutput .= $this->pObj->doc->spacer(10); } // Links: $out = ''; $urlParameters = array('id' => $this->pObj->id); $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters); if (!$this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$this->pObj->sObj]) { if (!empty($theSetup)) { $out = '<a href="' . htmlspecialchars($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj)) . '">'; $out .= sprintf($lang->getLL('addKey'), htmlspecialchars($this->pObj->sObj)); } } else { $out = '<a href="' . htmlspecialchars($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0') . '">'; $out .= sprintf($lang->getLL('removeKey'), htmlspecialchars($this->pObj->sObj)); } if ($out) { $theOutput .= $this->pObj->doc->divider(5); $theOutput .= $this->pObj->doc->section('', $out); } // back $out = $lang->getLL('back'); $out = '<a href="' . htmlspecialchars($aHref) . '"><strong>' . $out . '</strong></a>'; $theOutput .= $this->pObj->doc->divider(5); $theOutput .= $this->pObj->doc->section('', $out); } else { $templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]; if (GeneralUtility::_POST('search') && GeneralUtility::_POST('search_field')) { // If any POST-vars are send, update the condition array $templateService->tsbrowser_depthKeys = $templateService->ext_getSearchKeys($theSetup, '', GeneralUtility::_POST('search_field'), array()); } $theOutput .= ' <div class="tsob-menu"> <div class="form-inline">'; if (is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1) { $theOutput .= ' <div class="form-group"> <label class="control-label">' . $lang->getLL('browse') . '</label>' . BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']) . ' </div>'; } if (is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1) { $theOutput .= ' <div class="form-group"> <label class="control-label" for="ts_browser_toplevel_' . $bType . '">' . $lang->getLL('objectList') . '</label> ' . BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_toplevel_' . $bType . ']', $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) . ' </div>'; } $theOutput .= ' <div class="form-group"> <label class="control-label" for="search_field">' . $lang->getLL('search') . '</label> <input class="form-control" type="search" name="search_field" id="search_field" value="' . htmlspecialchars($POST['search_field']) . '"' . $documentTemplate->formWidth(20) . '/> </div> <input class="btn btn-default tsob-search-submit" type="submit" name="search" value="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:search') . '" /> </div> <div class="checkbox"> <label for="checkTs_browser_regexsearch"> ' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"') . $lang->getLL('regExp') . ' </label> </div> </div>'; $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType]; if (!$theKey || !str_replace('-', '', $theKey)) { $theKey = ''; } list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : ''); $tree = $templateService->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']); $tree = $templateService->substituteCMarkers($tree); $urlParameters = array('id' => $this->pObj->id); $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters); // Parser Errors: $pEkey = $bType == 'setup' ? 'config' : 'constants'; if (!empty($templateService->parserErrors[$pEkey])) { $errMsg = array(); foreach ($templateService->parserErrors[$pEkey] as $inf) { $errorLink = ' <a href="' . htmlspecialchars($aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-' . $inf[2]) . '">' . $lang->getLL('errorShowDetails') . '</a>'; $errMsg[] = $inf[1] . ': ' . $inf[0] . $errorLink; } $theOutput .= $this->pObj->doc->spacer(10); $title = $lang->getLL('errorsWarnings'); $message = '<p>' . implode($errMsg, '<br />') . '</p>'; $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html')); $view->assignMultiple(array('title' => $title, 'message' => $message, 'state' => InfoboxViewHelper::STATE_WARNING)); $theOutput .= $view->render(); } if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) { $remove = '<a href="' . htmlspecialchars($aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0') . '">' . $lang->getLL('removeKey') . '</a>'; } else { $remove = ''; } $label = $theKey ? $theKey : ($bType == 'setup' ? $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('setupRoot'), 'toUpper') : $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('constantRoot'), 'toUpper')); $theOutput .= $this->pObj->doc->sectionEnd(); $theOutput .= '<div class="panel panel-space panel-default">'; $theOutput .= '<div class="panel-heading">'; $theOutput .= '<strong>' . $label . ' ' . $remove . '</strong>'; $theOutput .= '</div>'; $theOutput .= '<div class="panel-body">' . $tree . '</div>'; $theOutput .= '</div>'; // second row options $menu = '<div class="tsob-menu-row2">'; $menu .= '<div class="checkbox"><label for="checkTs_browser_showComments">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS['ts_browser_showComments'], '', '', 'id="checkTs_browser_showComments"'); $menu .= $lang->getLL('displayComments') . '</label></div>'; $menu .= '<div class="checkbox"><label for="checkTs_browser_alphaSort">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS['ts_browser_alphaSort'], '', '', 'id="checkTs_browser_alphaSort"'); $menu .= $lang->getLL('sortAlphabetically') . '</label></div>'; $menu .= '<div class="checkbox"><label for="checkTs_browser_fixedLgd">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'], '', '', 'id="checkTs_browser_fixedLgd"'); $menu .= $lang->getLL('cropLines') . '</label></div>'; if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) { $menu .= '<br /><br /><label>' . $lang->getLL('displayConstants') . '</label>'; $menu .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']); } $menu .= '</div>'; $theOutput .= $this->pObj->doc->section($lang->getLL('displayOptions'), '<span class="text-nowrap">' . $menu . '</span>', 0, 1); // Conditions: if (is_array($templateService->sections) && !empty($templateService->sections)) { $theOutput .= $this->pObj->doc->section($lang->getLL('conditions'), '', 0, 1); $out = ''; foreach ($templateService->sections as $key => $val) { $out .= '<div class="checkbox"><label for="check' . $key . '">'; $out .= '<input class="checkbox" type="checkbox" name="conditions[' . $key . ']" id="check' . $key . '" value="' . htmlspecialchars($val) . '"' . ($this->pObj->MOD_SETTINGS['tsbrowser_conditions'][$key] ? ' checked' : '') . ' />' . $templateService->substituteCMarkers(htmlspecialchars($val)); $out .= '</label></div>'; } $theOutput .= '<div class="tsob-menu-row2">' . $out . '</div><input class="btn btn-default" type="submit" name="Submit" value="' . $lang->getLL('setConditions') . '" />'; } // Ending section: $theOutput .= $this->pObj->doc->sectionEnd(); } return $theOutput; }
/** * Get icon for the row. * If $this->iconPath and $this->iconName is set, * try to get icon based on those values. * * @param array $row Item row. * * @return string Image tag. */ public function getIcon(array $row) { if ($this->iconPath && $this->iconName) { $icon = '<img' . IconUtility::skinImg('', $this->iconPath . $this->iconName, 'width="18" height="16"') . ' alt=""' . ($this->showDefaultTitleAttribute ? ' title="UID: ' . $row['uid'] . '"' : '') . ' />'; } else { $icon = IconUtility::getSpriteIconForRecord($this->table, $row, array('title' => $this->showDefaultTitleAttribute ? 'UID: ' . $row['uid'] : $this->getTitleAttrib($row), 'class' => 'c-recIcon')); } return $this->wrapIcon($icon, $row); }
/** * Rendering a single row for the list * * @param string $table Table name * @param array $row Current record * @param integer $cc Counter, counting for each time an element is rendered (used for alternating colors) * @param string $titleCol Table field (column) where header value is found * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found * @param integer $indent Indent from left. * @return string Table row for the element * @access private * @see getTable() * @todo Define visibility */ public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0) { $iOut = ''; // If in search mode, make sure the preview will show the correct page if (strlen($this->searchString)) { $id_orig = $this->id; $this->id = $row['pid']; } if (is_array($row)) { // Add special classes for first and last row $rowSpecial = ''; if ($cc == 1 && $indent == 0) { $rowSpecial .= ' firstcol'; } if ($cc == $this->totalRowCount || $cc == $this->iLimit) { $rowSpecial .= ' lastcol'; } // Background color, if any: if ($this->alternateBgColors) { $row_bgColor = $cc % 2 ? ' class="db_list_normal' . $rowSpecial . '"' : ' class="db_list_alt' . $rowSpecial . '"'; } else { $row_bgColor = ' class="db_list_normal' . $rowSpecial . '"'; } // Overriding with versions background color if any: $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor; // Incr. counter. $this->counter++; // The icon with link $alttext = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($row, $table); $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => $indent ? ' margin-left: ' . $indent . 'px;' : '')); $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg; // Preparing and getting the data-array $theData = array(); foreach ($this->fieldArray as $fCol) { if ($fCol == $titleCol) { $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $row, FALSE, TRUE); // If the record is edit-locked by another user, we will show a little warning sign: if ($lockInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::isRecordLocked($table, $row['uid'])) { $warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-warning-in-use') . '</a>'; } $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row); // Render thumbsnails if a thumbnail column exists and there is content in it: if ($this->thumbs && trim($row[$thumbsCol])) { $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol); } $localizationMarkerClass = ''; if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) { // It's a translated record with a language parent $localizationMarkerClass = ' localization'; } } elseif ($fCol == 'pid') { $theData[$fCol] = $row[$fCol]; } elseif ($fCol == '_PATH_') { $theData[$fCol] = $this->recPath($row['pid']); } elseif ($fCol == '_REF_') { $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']); } elseif ($fCol == '_CONTROL_') { $theData[$fCol] = $this->makeControl($table, $row); } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') { $theData[$fCol] = ' '; } elseif ($fCol == '_CLIPBOARD_') { $theData[$fCol] = $this->makeClip($table, $row); } elseif ($fCol == '_LOCALIZATION_') { list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row); $theData[$fCol] = $lC1; $theData[$fCol . 'b'] = $lC2; } elseif ($fCol == '_LOCALIZATION_b') { } else { $tmpProc = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']); $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]); if ($this->csvOutput) { $row[$fCol] = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']); } } } // Reset the ID if it was overwritten if (strlen($this->searchString)) { $this->id = $id_orig; } // Add row to CSV list: if ($this->csvOutput) { $this->addToCSV($row, $table); } // Add classes to table cells $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass; if (!$this->dontShowClipControlPanels) { $this->addElement_tdCssClass['_CONTROL_'] = 'col-control'; $this->addElement_tdCssClass['_AFTERCONTROL_'] = 'col-control-space'; $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard'; } $this->addElement_tdCssClass['_PATH_'] = 'col-path'; $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa'; $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb'; // Create element in table cells: $iOut .= $this->addelement(1, $theIcon, $theData, $row_bgColor); // Finally, return table row element: return $iOut; } }
/** * Creates a node with the given record information * * @param array $record * @param int $mountPoint * @return \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode */ public static function getNewNode($record, $mountPoint = 0) { if (self::$titleLength === NULL) { self::$useNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle'); self::$addIdAsPrefix = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle'); self::$addDomainName = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle'); self::$backgroundColors = $GLOBALS['BE_USER']->getTSConfigProp('options.pageTree.backgroundColor'); self::$titleLength = (int) $GLOBALS['BE_USER']->uc['titleLen']; } /** @var $subNode \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode */ $subNode = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode::class); $subNode->setRecord($record); $subNode->setCls($record['_CSSCLASS']); $subNode->setType('pages'); $subNode->setId($record['uid']); $subNode->setMountPoint($mountPoint); $subNode->setWorkspaceId($record['_ORIG_uid'] ?: $record['uid']); $subNode->setBackgroundColor(self::$backgroundColors[$record['uid']]); $field = 'title'; $text = $record['title']; if (self::$useNavTitle && trim($record['nav_title']) !== '') { $field = 'nav_title'; $text = $record['nav_title']; } if (trim($text) === '') { $visibleText = '[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']'; } else { $visibleText = $text; } $visibleText = GeneralUtility::fixed_lgd_cs($visibleText, self::$titleLength); $suffix = ''; if (self::$addDomainName) { $domain = self::getDomainName($record['uid']); $suffix = $domain !== '' ? ' [' . $domain . ']' : ''; } $qtip = str_replace(' - ', '<br />', htmlspecialchars(BackendUtility::titleAttribForPages($record, '', FALSE))); $prefix = ''; $lockInfo = BackendUtility::isRecordLocked('pages', $record['uid']); if (is_array($lockInfo)) { $qtip .= '<br />' . htmlspecialchars($lockInfo['msg']); $prefix .= IconUtility::getSpriteIcon('status-warning-in-use', array('class' => 'typo3-pagetree-status')); } // Call stats information hook $stat = ''; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) { $_params = array('pages', $record['uid']); $fakeThis = NULL; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) { $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $fakeThis); } } $prefix .= htmlspecialchars(self::$addIdAsPrefix ? '[' . $record['uid'] . '] ' : ''); $subNode->setEditableText($text); $subNode->setText(htmlspecialchars($visibleText), $field, $prefix, htmlspecialchars($suffix) . $stat); $subNode->setQTip($qtip); if ((int) $record['uid'] !== 0) { $spriteIconCode = IconUtility::getSpriteIconForRecord('pages', $record); } else { $spriteIconCode = IconUtility::getSpriteIcon('apps-pagetree-root'); } $subNode->setSpriteIconCode($spriteIconCode); if (!$subNode->canCreateNewPages() || VersionState::cast($record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) { $subNode->setIsDropTarget(FALSE); } if (!$subNode->canBeEdited() || !$subNode->canBeRemoved() || VersionState::cast($record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) { $subNode->setDraggable(FALSE); } return $subNode; }
/** * Add entries for a single record * * @param string $table Table name * @param int $uid Record uid * @param array $lines Output lines array (is passed by reference and modified) * @param string $preCode Pre-HTML code * @param bool $checkImportInPidRecord If you want import validation, you can set this so it checks if the import can take place on the specified page. * @return void */ public function singleRecordLines($table, $uid, &$lines, $preCode, $checkImportInPidRecord = FALSE) { // Get record: $record = $this->dat['header']['records'][$table][$uid]; unset($this->remainHeader['records'][$table][$uid]); if (!is_array($record) && !($table === 'pages' && !$uid)) { $this->error('MISSING RECORD: ' . $table . ':' . $uid, 1); } // Begin to create the line arrays information record, pInfo: $pInfo = array(); $pInfo['ref'] = $table . ':' . $uid; // Unknown table name: if ($table === '_SOFTREF_') { $pInfo['preCode'] = $preCode; $pInfo['title'] = '<em>' . $GLOBALS['LANG']->getLL('impexpcore_singlereco_softReferencesFiles', TRUE) . '</em>'; } elseif (!isset($GLOBALS['TCA'][$table])) { // Unknown table name: $pInfo['preCode'] = $preCode; $pInfo['msg'] = 'UNKNOWN TABLE \'' . $pInfo['ref'] . '\''; $pInfo['title'] = '<em>' . htmlspecialchars($record['title']) . '</em>'; } else { // Otherwise, set table icon and title. // Import Validation (triggered by $this->display_import_pid_record) will show messages if import is not possible of various items. if (is_array($this->display_import_pid_record) && !empty($this->display_import_pid_record)) { if ($checkImportInPidRecord) { if (!$GLOBALS['BE_USER']->doesUserHaveAccess($this->display_import_pid_record, $table === 'pages' ? 8 : 16)) { $pInfo['msg'] .= '\'' . $pInfo['ref'] . '\' cannot be INSERTED on this page! '; } if (!$this->checkDokType($table, $this->display_import_pid_record['doktype']) && !$GLOBALS['TCA'][$table]['ctrl']['rootLevel']) { $pInfo['msg'] .= '\'' . $table . '\' cannot be INSERTED on this page type (change page type to \'Folder\'.) '; } } if (!$GLOBALS['BE_USER']->check('tables_modify', $table)) { $pInfo['msg'] .= 'You are not allowed to CREATE \'' . $table . '\' tables! '; } if ($GLOBALS['TCA'][$table]['ctrl']['readOnly']) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' is READ ONLY! '; } if ($GLOBALS['TCA'][$table]['ctrl']['adminOnly'] && !$GLOBALS['BE_USER']->isAdmin()) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' is ADMIN ONLY! '; } if ($GLOBALS['TCA'][$table]['ctrl']['is_static']) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' is a STATIC TABLE! '; } if ((int) $GLOBALS['TCA'][$table]['ctrl']['rootLevel'] === 1) { $pInfo['msg'] .= 'TABLE \'' . $table . '\' will be inserted on ROOT LEVEL! '; } $diffInverse = FALSE; $recInf = NULL; if ($this->update) { // In case of update-PREVIEW we swap the diff-sources. $diffInverse = TRUE; $recInf = $this->doesRecordExist($table, $uid, $this->showDiff ? '*' : ''); $pInfo['updatePath'] = $recInf ? htmlspecialchars($this->getRecordPath($recInf['pid'])) : '<strong>NEW!</strong>'; // Mode selector: $optValues = array(); $optValues[] = $recInf ? $GLOBALS['LANG']->getLL('impexpcore_singlereco_update') : $GLOBALS['LANG']->getLL('impexpcore_singlereco_insert'); if ($recInf) { $optValues['as_new'] = $GLOBALS['LANG']->getLL('impexpcore_singlereco_importAsNew'); } if ($recInf) { if (!$this->global_ignore_pid) { $optValues['ignore_pid'] = $GLOBALS['LANG']->getLL('impexpcore_singlereco_ignorePid'); } else { $optValues['respect_pid'] = $GLOBALS['LANG']->getLL('impexpcore_singlereco_respectPid'); } } if (!$recInf && $GLOBALS['BE_USER']->isAdmin()) { $optValues['force_uid'] = sprintf($GLOBALS['LANG']->getLL('impexpcore_singlereco_forceUidSAdmin'), $uid); } $optValues['exclude'] = $GLOBALS['LANG']->getLL('impexpcore_singlereco_exclude'); if ($table === 'sys_file') { $pInfo['updateMode'] = ''; } else { $pInfo['updateMode'] = $this->renderSelectBox('tx_impexp[import_mode][' . $table . ':' . $uid . ']', $this->import_mode[$table . ':' . $uid], $optValues); } } // Diff vieiw: if ($this->showDiff) { // For IMPORTS, get new id: if ($newUid = $this->import_mapId[$table][$uid]) { $diffInverse = FALSE; $recInf = $this->doesRecordExist($table, $newUid, '*'); BackendUtility::workspaceOL($table, $recInf); } if (is_array($recInf)) { $pInfo['showDiffContent'] = $this->compareRecords($recInf, $this->dat['records'][$table . ':' . $uid]['data'], $table, $diffInverse); } } } $pInfo['preCode'] = $preCode . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, (array) $this->dat['records'][$table . ':' . $uid]['data'], array('title' => htmlspecialchars($table . ':' . $uid))); $pInfo['title'] = htmlspecialchars($record['title']); // View page: if ($table === 'pages') { $viewID = $this->mode === 'export' ? $uid : ($this->doesImport ? $this->import_mapId['pages'][$uid] : 0); if ($viewID) { $pInfo['title'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($viewID, $GLOBALS['BACK_PATH'])) . 'return false;">' . $pInfo['title'] . '</a>'; } } } $pInfo['class'] = $table == 'pages' ? 'bgColor4-20' : 'bgColor4'; $pInfo['type'] = 'record'; $pInfo['size'] = $record['size']; $lines[] = $pInfo; // File relations: if (is_array($record['filerefs'])) { $this->addFiles($record['filerefs'], $lines, $preCode); } // DB relations if (is_array($record['rels'])) { $this->addRelations($record['rels'], $lines, $preCode); } // Soft ref if (!empty($record['softrefs'])) { $preCode_A = $preCode . ' '; $preCode_B = $preCode . ' '; foreach ($record['softrefs'] as $info) { $pInfo = array(); $pInfo['preCode'] = $preCode_A . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-reference-soft'); $pInfo['title'] = '<em>' . $info['field'] . ', "' . $info['spKey'] . '" </em>: <span title="' . htmlspecialchars($info['matchString']) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['matchString'], 60)) . '</span>'; if ($info['subst']['type']) { if (strlen($info['subst']['title'])) { $pInfo['title'] .= '<br/>' . $preCode_B . '<strong>' . $GLOBALS['LANG']->getLL('impexpcore_singlereco_title', TRUE) . '</strong> ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst']['title'], 60)); } if (strlen($info['subst']['description'])) { $pInfo['title'] .= '<br/>' . $preCode_B . '<strong>' . $GLOBALS['LANG']->getLL('impexpcore_singlereco_descr', TRUE) . '</strong> ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst']['description'], 60)); } $pInfo['title'] .= '<br/>' . $preCode_B . ($info['subst']['type'] == 'file' ? $GLOBALS['LANG']->getLL('impexpcore_singlereco_filename', TRUE) . ' <strong>' . $info['subst']['relFileName'] . '</strong>' : '') . ($info['subst']['type'] == 'string' ? $GLOBALS['LANG']->getLL('impexpcore_singlereco_value', TRUE) . ' <strong>' . $info['subst']['tokenValue'] . '</strong>' : '') . ($info['subst']['type'] == 'db' ? $GLOBALS['LANG']->getLL('impexpcore_softrefsel_record', TRUE) . ' <strong>' . $info['subst']['recordRef'] . '</strong>' : ''); } $pInfo['ref'] = 'SOFTREF'; $pInfo['size'] = ''; $pInfo['class'] = 'bgColor3'; $pInfo['type'] = 'softref'; $pInfo['_softRefInfo'] = $info; $pInfo['type'] = 'softref'; if ($info['error'] && !GeneralUtility::inList('editable,exclude', $this->softrefCfg[$info['subst']['tokenID']]['mode'])) { $pInfo['msg'] .= $info['error']; } $lines[] = $pInfo; // Add relations: if ($info['subst']['type'] == 'db') { list($tempTable, $tempUid) = explode(':', $info['subst']['recordRef']); $this->addRelations(array(array('table' => $tempTable, 'id' => $tempUid, 'tokenID' => $info['subst']['tokenID'])), $lines, $preCode_B, array(), ''); } // Add files: if ($info['subst']['type'] == 'file') { $this->addFiles(array($info['file_ID']), $lines, $preCode_B, '', $info['subst']['tokenID']); } } } }