/** * Preview of a content element. * * @param array $row : Record row of tt_content * @return string */ private function getPi1Preview($row) { if ($row['image']) { $image = \TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode($row, 'tt_content', 'image', $GLOBALS['BACK_PATH']); } $previewHtml = '<a href="#" onclick="' . \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit') . '" />' . $text . '</a>' . $image; return $previewHtml; }
/** * Render different label for media elements * * @param array $params configuration * @return void */ public function getUserLabelMedia(array &$params) { $ll = 'LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:'; $typeInfo = $additionalHtmlContent = ''; $type = $GLOBALS['LANG']->sL($ll . 'tx_news_domain_model_media.type.I.' . $params['row']['type']); // Add additional info based on type switch ((int) $params['row']['type']) { // Image case Media::MEDIA_TYPE_IMAGE: $typeInfo .= $this->getTitleFromFields('title,alt,caption,image', $params['row']); if (!empty($params['row']['image'])) { $params['row']['image'] = $this->splitFileName($params['row']['image']); try { $additionalHtmlContent = '<br />' . BackendUtilityCore::thumbCode($params['row'], 'tx_news_domain_model_media', 'image', $GLOBALS['BACK_PATH'], '', NULL, 0, '', '', FALSE); } catch (\TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException $exception) { $additionalHtmlContent = '<br />' . htmlspecialchars($params['row']['image']); } } break; // Audio & Video // Audio & Video case Media::MEDIA_TYPE_MULTIMEDIA: $typeInfo .= $this->getTitleFromFields('caption,multimedia', $params['row']); break; // HTML // HTML case Media::MEDIA_TYPE_HTML: // Don't show html value as this could get a XSS $typeInfo .= $params['row']['caption']; break; default: $typeInfo .= $params['row']['caption']; } $title = !empty($typeInfo) ? $type . ': ' . $typeInfo : $type; $title = htmlspecialchars($title) . $additionalHtmlContent; // Hook to modify the label, especially useful when using custom media relations if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['mediaLabel'])) { $params = array('params' => $params, 'title' => $title); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['mediaLabel'] as $reference) { $title = GeneralUtility::callUserFunction($reference, $params, $this); } } // Preview if ($params['row']['showinpreview']) { $label = htmlspecialchars($GLOBALS['LANG']->sL($ll . 'tx_news_domain_model_media.show')); $icon = '../' . ExtensionManagementUtility::siteRelPath('news') . 'Resources/Public/Icons/preview.gif'; $title .= ' <img title="' . $label . '" src="' . $icon . '" />'; } // Show the [No title] if empty if (empty($title)) { $title = BackendUtilityCore::getNoRecordTitle(TRUE); } $params['title'] = $title; }
/** * Create thumbnail code for record/field but not linked * * @param mixed[] $row Record array * @param string $table Table (record is from) * @param string $field Field name for which thumbnail are to be rendered. * @return string HTML for thumbnails, if any. */ public function getThumbCodeUnlinked($row, $table, $field) { return BackendUtility::thumbCode($row, $table, $field, '', '', null, 0, '', '', false); }
/** * Create thumbnail code for record/field * * @param mixed[] $row Record array * @param string $table Table (record is from) * @param string $field Field name for which thumbnail are to be rendered. * @return string HTML for thumbnails, if any. */ public function thumbCode($row, $table, $field) { return BackendUtility::thumbCode($row, $table, $field); }
/** * 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; }
/** * Rendering preview output of a field value which is not shown as a form field but just outputted. * * @param string $value The value to output * @param array $config Configuration for field. * @param string $field Name of field. * @return string HTML formatted output */ protected function previewFieldValue($value, $config, $field = '') { if ($config['config']['type'] === 'group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) { // Ignore upload folder if internal_type is file_reference if ($config['config']['internal_type'] === 'file_reference') { $config['config']['uploadfolder'] = ''; } $table = 'tt_content'; // Making the array of file items: $itemArray = GeneralUtility::trimExplode(',', $value, true); // Showing thumbnails: $thumbnail = ''; $imgs = array(); $iconFactory = GeneralUtility::makeInstance(IconFactory::class); foreach ($itemArray as $imgRead) { $imgParts = explode('|', $imgRead); $imgPath = rawurldecode($imgParts[0]); $rowCopy = array(); $rowCopy[$field] = $imgPath; // Icon + click menu: $absFilePath = GeneralUtility::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath); $fileInformation = pathinfo($imgPath); $title = $fileInformation['basename'] . ($absFilePath && @is_file($absFilePath)) ? ' (' . GeneralUtility::formatSize(filesize($absFilePath)) . ')' : ' - FILE NOT FOUND!'; $fileIcon = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForFileExtension($fileInformation['extension'], Icon::SIZE_SMALL)->render() . '</span>'; $imgs[] = '<span class="text-nowrap">' . BackendUtility::thumbCode($rowCopy, $table, $field, '', 'thumbs.php', $config['config']['uploadfolder'], 0, ' align="middle"') . ($absFilePath ? $this->getControllerDocumentTemplate()->wrapClickMenuOnIcon($fileIcon, $absFilePath, 0, 1, '', '+copy,info,edit,view') : $fileIcon) . $imgPath . '</span>'; } return implode('<br />', $imgs); } else { return nl2br(htmlspecialchars($value)); } }
/** * Fetch further information to current selected workspace record. * * @param \stdClass $parameter * @return array $data */ public function getRowDetails($parameter) { $diffReturnArray = array(); $liveReturnArray = array(); /** @var $diffUtility \TYPO3\CMS\Core\Utility\DiffUtility */ $diffUtility = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Utility\DiffUtility::class); /** @var $parseObj \TYPO3\CMS\Core\Html\RteHtmlParser */ $parseObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\RteHtmlParser::class); $liveRecord = BackendUtility::getRecord($parameter->table, $parameter->t3ver_oid); $versionRecord = BackendUtility::getRecord($parameter->table, $parameter->uid); $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $icon_Live = $iconFactory->getIconForRecord($parameter->table, $liveRecord, Icon::SIZE_SMALL)->render(); $icon_Workspace = $iconFactory->getIconForRecord($parameter->table, $versionRecord, Icon::SIZE_SMALL)->render(); $stagePosition = $this->getStagesService()->getPositionOfCurrentStage($parameter->stage); $fieldsOfRecords = array_keys($liveRecord); if ($GLOBALS['TCA'][$parameter->table]) { if ($GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']) { $fieldsOfRecords = $GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']; $fieldsOfRecords = GeneralUtility::trimExplode(',', $fieldsOfRecords, true); } } foreach ($fieldsOfRecords as $fieldName) { if (empty($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config'])) { continue; } // Get the field's label. If not available, use the field name $fieldTitle = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($parameter->table, $fieldName)); if (empty($fieldTitle)) { $fieldTitle = $fieldName; } // Gets the TCA configuration for the current field $configuration = $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']; // check for exclude fields if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0 || GeneralUtility::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) { // call diff class only if there is a difference if ($configuration['type'] === 'inline' && $configuration['foreign_table'] === 'sys_file_reference') { $useThumbnails = false; if (!empty($configuration['foreign_selector_fieldTcaOverride']['config']['appearance']['elementBrowserAllowed']) && !empty($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])) { $fileExtensions = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], true); $allowedExtensions = GeneralUtility::trimExplode(',', $configuration['foreign_selector_fieldTcaOverride']['config']['appearance']['elementBrowserAllowed'], true); $differentExtensions = array_diff($allowedExtensions, $fileExtensions); $useThumbnails = empty($differentExtensions); } $liveFileReferences = BackendUtility::resolveFileReferences($parameter->table, $fieldName, $liveRecord, 0); $versionFileReferences = BackendUtility::resolveFileReferences($parameter->table, $fieldName, $versionRecord, $this->getCurrentWorkspace()); $fileReferenceDifferences = $this->prepareFileReferenceDifferences($liveFileReferences, $versionFileReferences, $useThumbnails); if ($fileReferenceDifferences === null) { continue; } $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $fileReferenceDifferences['differences']); $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $fileReferenceDifferences['live']); } elseif ((string) $liveRecord[$fieldName] !== (string) $versionRecord[$fieldName]) { // Select the human readable values before diff $liveRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $liveRecord[$fieldName], 0, 1, false, $liveRecord['uid']); $versionRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $versionRecord[$fieldName], 0, 1, false, $versionRecord['uid']); if ($configuration['type'] == 'group' && $configuration['internal_type'] == 'file') { $versionThumb = BackendUtility::thumbCode($versionRecord, $parameter->table, $fieldName, ''); $liveThumb = BackendUtility::thumbCode($liveRecord, $parameter->table, $fieldName, ''); $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $versionThumb); $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $liveThumb); } else { $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $diffUtility->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName])); $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $parseObj->TS_images_rte($liveRecord[$fieldName])); } } } } // Hook for modifying the difference and live arrays // (this may be used by custom or dynamically-defined fields) if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'] as $className) { $hookObject = GeneralUtility::getUserObj($className); if (method_exists($hookObject, 'modifyDifferenceArray')) { $hookObject->modifyDifferenceArray($parameter, $diffReturnArray, $liveReturnArray, $diffUtility); } } } $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table); return array('total' => 1, 'data' => array(array('diff' => $diffReturnArray, 'live_record' => $liveReturnArray, 'icon_Live' => $icon_Live, 'icon_Workspace' => $icon_Workspace, 'comments' => $commentsForRecord, 'path_Live' => htmlspecialchars($parameter->path_Live), 'label_Stage' => htmlspecialchars($parameter->label_Stage), 'stage_position' => (int) $stagePosition['position'], 'stage_count' => (int) $stagePosition['count']))); }
/** * Fetch futher information to current selected worspace record. * * @param object $parameter * @return array $data */ public function getRowDetails($parameter) { $diffReturnArray = array(); $liveReturnArray = array(); /** @var $t3lib_diff \TYPO3\CMS\Core\Utility\DiffUtility */ $t3lib_diff = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility'); /** @var $parseObj \TYPO3\CMS\Core\Html\RteHtmlParser */ $parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser'); $liveRecord = BackendUtility::getRecord($parameter->table, $parameter->t3ver_oid); $versionRecord = BackendUtility::getRecord($parameter->table, $parameter->uid); $icon_Live = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($parameter->table, $liveRecord); $icon_Workspace = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($parameter->table, $versionRecord); $stagePosition = $this->getStagesService()->getPositionOfCurrentStage($parameter->stage); $fieldsOfRecords = array_keys($liveRecord); if ($GLOBALS['TCA'][$parameter->table]) { if ($GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']) { $fieldsOfRecords = $GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']; $fieldsOfRecords = GeneralUtility::trimExplode(',', $fieldsOfRecords, TRUE); } } foreach ($fieldsOfRecords as $fieldName) { // check for exclude fields if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0 || GeneralUtility::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) { // call diff class only if there is a difference if ((string) $liveRecord[$fieldName] !== (string) $versionRecord[$fieldName]) { // Select the human readable values before diff $liveRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $liveRecord[$fieldName], 0, 1, FALSE, $liveRecord['uid']); $versionRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $versionRecord[$fieldName], 0, 1, FALSE, $versionRecord['uid']); // Get the field's label. If not available, use the field name $fieldTitle = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($parameter->table, $fieldName)); if (empty($fieldTitle)) { $fieldTitle = $fieldName; } if ($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['type'] == 'group' && $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['internal_type'] == 'file') { $versionThumb = BackendUtility::thumbCode($versionRecord, $parameter->table, $fieldName, ''); $liveThumb = BackendUtility::thumbCode($liveRecord, $parameter->table, $fieldName, ''); $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $versionThumb); $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $liveThumb); } else { $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName])); $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $parseObj->TS_images_rte($liveRecord[$fieldName])); } } } } // Hook for modifying the difference and live arrays // (this may be used by custom or dynamically-defined fields) if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'] as $className) { $hookObject =& GeneralUtility::getUserObj($className); $hookObject->modifyDifferenceArray($parameter, $diffReturnArray, $liveReturnArray, $t3lib_diff); } } $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table); return array('total' => 1, 'data' => array(array('diff' => $diffReturnArray, 'live_record' => $liveReturnArray, 'path_Live' => $parameter->path_Live, 'label_Stage' => $parameter->label_Stage, 'stage_position' => $stagePosition['position'], 'stage_count' => $stagePosition['count'], 'comments' => $commentsForRecord, 'icon_Live' => $icon_Live, 'icon_Workspace' => $icon_Workspace))); }
/** * Rendering preview output of a field value which is not shown as a form field but just outputted. * * @param string $value The value to output * @param array $config Configuration for field. * @param string $field Name of field. * @return string HTML formatted output * @todo Define visibility */ public function previewFieldValue($value, $config, $field = '') { if ($config['config']['type'] === 'group' && ($config['config']['internal_type'] === 'file' || $config['config']['internal_type'] === 'file_reference')) { // Ignore uploadfolder if internal_type is file_reference if ($config['config']['internal_type'] === 'file_reference') { $config['config']['uploadfolder'] = ''; } $show_thumbs = TRUE; $table = 'tt_content'; // Making the array of file items: $itemArray = GeneralUtility::trimExplode(',', $value, TRUE); // Showing thumbnails: $thumbsnail = ''; if ($show_thumbs) { $imgs = array(); foreach ($itemArray as $imgRead) { $imgP = explode('|', $imgRead); $imgPath = rawurldecode($imgP[0]); $rowCopy = array(); $rowCopy[$field] = $imgPath; // Icon + clickmenu: $absFilePath = GeneralUtility::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath); $fileInformation = pathinfo($imgPath); $fileIcon = IconUtility::getSpriteIconForFile($imgPath, array('title' => htmlspecialchars($fileInformation['basename'] . ($absFilePath && @is_file($absFilePath) ? ' (' . GeneralUtility::formatSize(filesize($absFilePath)) . 'bytes)' : ' - FILE NOT FOUND!')))); $imgs[] = '<span class="nobr">' . BackendUtility::thumbCode($rowCopy, $table, $field, $this->backPath, 'thumbs.php', $config['config']['uploadfolder'], 0, ' align="middle"') . ($absFilePath ? $this->getClickMenu($fileIcon, $absFilePath) : $fileIcon) . $imgPath . '</span>'; } $thumbsnail = implode('<br />', $imgs); } return $thumbsnail; } else { return nl2br(htmlspecialchars($value)); } }
/** * Renders HTML table with all available template resources/files in the current rootline that could be copied * * @param integer $id The uid of the current page * @param integer $template_uid The uid of the template record to be rendered (only if more than one template on the current page) * @return string HTML table with all available template resources/files in the current rootline that could be copied * @todo Define visibility */ public function resourceListForCopy($id, $template_uid) { global $tmpl; $sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $rootLine = $sys_page->getRootLine($id); // This generates the constants/config + hierarchy info for the template. $tmpl->runThroughTemplates($rootLine, $template_uid); $theResources = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tmpl->resources, 1); foreach ($theResources as $k => $v) { $fI = pathinfo($v); if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->pObj->textExtensions, strtolower($fI['extension']))) { $path = PATH_site . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $v; $thumb = \TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], ''); $out .= '<tr><td' . $bgcol . ' nowrap="nowrap">' . $v . ' </td><td' . $bgcol . ' nowrap="nowrap"> ' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(@filesize($path)) . ' </td><td' . $bgcol . '>' . trim($thumb) . '</td><td><input type="Checkbox" name="data[makecopy_resource][' . $k . ']" value="' . htmlspecialchars($v) . '"></td></tr>'; } } $out = $out ? '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>' : ''; return $out; }
/** * Create thumbnail code for record/field * * @param array $row Record array * @param string $table Table (record is from) * @param string $field Field name for which thumbsnail are to be rendered. * @return string HTML for thumbnails, if any. * @todo Define visibility */ public function thumbCode($row, $table, $field) { return \TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode($row, $table, $field, $this->backPath); }
/** * Create thumbnail code for record/field but not linked * * @param mixed[] $row Record array * @param string $table Table (record is from) * @param string $field Field name for which thumbnail are to be rendered. * @return string HTML for thumbnails, if any. */ public function getThumbCodeUnlinked($row, $table, $field) { return BackendUtility::thumbCode($row, $table, $field, $this->backPath, '', NULL, 0, '', '', FALSE); }
/** * Render attribute rows. * * @param \mysqli_result $result Result * * @return string */ protected function renderAttributeRows(\mysqli_result $result) { $language = $this->getLanguageService(); $database = $this->getDatabaseConnection(); /** * Record list. * * @var \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList $recordList */ $recordList = GeneralUtility::makeInstance('TYPO3\\CMS\\Recordlist\\RecordList\\DatabaseRecordList'); $recordList->backPath = $this->getBackPath(); $recordList->initializeLanguages(); $output = ''; $table = 'tx_commerce_attributes'; while ($attribute = $database->sql_fetch_assoc($result)) { $refCountMsg = BackendUtility::referenceCount($table, $attribute['uid'], ' ' . $language->sL('LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'), $this->getReferenceCount($table, $attribute['uid'])); $editParams = '&edit[' . $table . '][' . (int) $attribute['uid'] . ']=edit'; $deleteParams = '&cmd[' . $table . '][' . (int) $attribute['uid'] . '][delete]=1'; $output .= '<tr><td class="bgColor4" align="center" valign="top"> ' . BackendUtility::thumbCode($attribute, 'tx_commerce_attributes', 'icon', $this->getBackPath()) . '</td>'; if ($attribute['internal_title']) { $output .= '<td valign="top" class="bgColor4"><strong>' . htmlspecialchars($attribute['internal_title']) . '</strong> (' . htmlspecialchars($attribute['title']) . ')'; } else { $output .= '<td valign="top" class="bgColor4"><strong>' . htmlspecialchars($attribute['title']) . '</strong>'; } $catCount = $this->fetchRelationCount('tx_commerce_categories_attributes_mm', $attribute['uid']); $proCount = $this->fetchRelationCount('tx_commerce_products_attributes_mm', $attribute['uid']); // Select language versions $resLocalVersion = $this->fetchAttributeTranslation($attribute['uid']); if ($database->sql_num_rows($resLocalVersion)) { $output .= '<table >'; while ($localAttributes = $database->sql_fetch_assoc($resLocalVersion)) { $output .= '<tr><td> '; $output .= '</td><td>'; if ($localAttributes['internal_title']) { $output .= htmlspecialchars($localAttributes['internal_title']) . ' (' . htmlspecialchars($localAttributes['title']) . ')'; } else { $output .= htmlspecialchars($localAttributes['title']); } $output .= '</td><td>'; $output .= $recordList->languageFlag($localAttributes['sys_language_uid']); $output .= '</td></tr>'; } $output .= '</table>'; } $output .= '<br />' . $language->getLL('usage'); $output .= ' <strong>' . $language->getLL('categories') . '</strong>: ' . $catCount; $output .= ' <strong>' . $language->getLL('products') . '</strong>: ' . $proCount; $output .= '</td>'; $onClickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($editParams, $this->getBackPath(), -1)) . '"'; $output .= '<td><a href="#" ' . $onClickAction . '>' . IconUtility::getSpriteIcon('actions-document-open', array('title' => $language->getLL('edit', true))) . '</a>'; $output .= '<a href="#" onclick="' . htmlspecialchars('if (confirm(' . $language->JScharCode($language->getLL('deleteWarningManufacturer') . ' "' . $attribute['title'] . '" ' . $refCountMsg) . ')) {jumpToUrl(\'' . $this->doc->issueCommand($deleteParams, -1) . '\');} return false;') . '">' . IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $language->getLL('delete', true))) . '</a>'; $output .= '</td><td>'; if ($attribute['has_valuelist'] == 1) { $valueRes = $database->exec_SELECTquery('*', 'tx_commerce_attribute_values', 'attributes_uid = ' . (int) $attribute['uid'] . ' AND hidden = 0 AND deleted = 0', '', 'sorting'); if ($database->sql_num_rows($valueRes)) { $output .= '<table border="0">'; while ($value = $database->sql_fetch_assoc($valueRes)) { $output .= '<tr><td>' . htmlspecialchars($value['value']) . '</td></tr>'; } $output .= '</table>'; } else { $output .= $language->getLL('no_values'); } } else { $output .= $language->getLL('no_valuelist'); } $output .= '</td></tr>'; } return $output; }
/** * Adds content to all data fields in $out array * * @param array Array of fields to display. Each field name has a special feature which is that the field name can be specified as more field names. Eg. "field1,field2;field3". Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell. * @param string Table name * @param array Record array * @param array Array to which the data is added * @param [type] $noEdit: ... * @return array $out array returned after processing. * @see makeOrdinaryList() */ function dataFields($fieldArr, $table, $row, $out = array(), $noEdit = FALSE) { global $TCA; // Check table validity: if ($TCA[$table]) { $thumbsCol = $TCA[$table]['ctrl']['thumbnail']; $url = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php'; $thumbsize = $this->lTSprop['imageSize']; // Traverse fields: foreach ($fieldArr as $fieldName) { if ($TCA[$table]['columns'][$fieldName]) { // Each field has its own cell (if configured in TCA) if ($fieldName == $thumbsCol) { // If the column is a thumbnail column: if ($this->thumbs) { $val = \TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode($row, $table, $fieldName, $this->backPath, $this->thumbScript, NULL, 0, '', $thumbsize); } else { $val = str_replace(',', ', ', basename($row[$fieldName])); } } else { // ... otherwise just render the output: $val = nl2br(htmlspecialchars(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(\TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']), 250)))); if ($this->lTSprop['clickTitleMode'] == 'view') { if ($this->singlePid) { $val = $this->linkSingleView($url, $val, $row['uid']); } } elseif ($this->lTSprop['clickTitleMode'] == 'edit') { if (!$noEdit) { $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; $lTitle = ' title="' . $GLOBALS['LANG']->getLL('edit', 1) . '"'; $val = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick($params, $this->backPath, $this->returnUrl)) . '"' . $lTitle . '>' . $val . '</a>'; } } } $out[$fieldName] = $val; } else { // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode the field name with ";" and check each value there as a TCA configured field) $theFields = explode(';', $fieldName); // Traverse fields, separated by ";" (displayed in a single cell). foreach ($theFields as $fName2) { if ($TCA[$table]['columns'][$fName2]) { $out[$fieldName] .= '<b>' . $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'], 1) . '</b>' . ' ' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(\TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']), 25)) . '<br />'; } } } // If no value, add a nbsp. if (!$out[$fieldName]) { $out[$fieldName] = ' '; } // Wrap in dimmed-span tags if record is "disabled" if ($this->isDisabled($table, $row)) { $out[$fieldName] = $GLOBALS['TBE_TEMPLATE']->dfw($out[$fieldName]); } } } return $out; }