/**
  * @param array $arguments
  * @param callable $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  *
  * @return string
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     $id = GeneralUtility::_GP('id');
     $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
     // Add icon with clickmenu, etc:
     /** @var IconFactory $iconFactory */
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     if ($pageRecord['uid']) {
         // If there IS a real page
         $altText = BackendUtility::getRecordIconAltText($pageRecord, 'pages');
         $theIcon = '<span title="' . $altText . '">' . $iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>';
         // Make Icon:
         $theIcon = BackendUtility::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 = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $iconFactory->getIcon('apps-pagetree-page-domain', Icon::SIZE_SMALL)->render() . '</span>';
         if ($GLOBALS['BE_USER']->user['admin']) {
             $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'pages', 0);
         }
     }
     return $theIcon;
 }
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * Entry method
  *
  * @return array As defined in initializeResultArray() of AbstractNode
  */
 public function render()
 {
     $languageService = $this->getLanguageService();
     $backendUser = $this->getBackendUserAuthentication();
     $table = $this->data['tableName'];
     $row = $this->data['databaseRow'];
     $options = $this->data;
     if (empty($this->data['fieldListToRender'])) {
         $options['renderType'] = 'fullRecordContainer';
     } else {
         $options['renderType'] = 'listOfFieldsContainer';
     }
     $result = $this->nodeFactory->create($options)->render();
     $childHtml = $result['html'];
     $recordPath = '';
     // @todo: what is this >= 0 check for? wsol cases?!
     if ($this->data['effectivePid'] >= 0) {
         $permissionsClause = $backendUser->getPagePermsClause(1);
         $recordPath = BackendUtility::getRecordPath($this->data['effectivePid'], $permissionsClause, 15);
     }
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $icon = '<span title="' . htmlspecialchars($recordPath) . '">' . $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     // @todo: Could this be done in a more clever way? Does it work at all?
     $tableTitle = $languageService->sL($this->data['processedTca']['ctrl']['title']);
     if ($this->data['command'] === 'new') {
         $newOrUid = ' <span class="typo3-TCEforms-newToken">' . $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.new', true) . '</span>';
         // @todo: There is quite some stuff do to for WS overlays ...
         $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $this->data['effectivePid'], 'title');
         $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
         if ($table === 'pages') {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.createNewPage', true);
             $pageTitle = sprintf($label, $tableTitle);
         } else {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.createNewRecord', true);
             if ($this->data['effectivePid'] === 0) {
                 $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.createNewRecordRootLevel', true);
             }
             $pageTitle = sprintf($label, $tableTitle, $pageTitle);
         }
     } else {
         $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid'], 1, '', '+copy,info,edit,view');
         $newOrUid = ' <span class="typo3-TCEforms-recUid">[' . htmlspecialchars($row['uid']) . ']</span>';
         // @todo: getRecordTitlePrep applies an htmlspecialchars here
         $recordLabel = BackendUtility::getRecordTitlePrep($this->data['recordTitle']);
         if ($table === 'pages') {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editPage', true);
             $pageTitle = sprintf($label, $tableTitle, $recordLabel);
         } else {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editRecord', true);
             $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $row['pid'], 'uid,title');
             $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
             if (empty($recordLabel)) {
                 $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editRecordNoTitle', true);
             }
             if ($this->data['effectivePid'] === 0) {
                 $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editRecordRootLevel', true);
             }
             if (!empty($recordLabel)) {
                 // Use record title and prepend an edit label.
                 $pageTitle = sprintf($label, $tableTitle, $recordLabel, $pageTitle);
             } else {
                 // Leave out the record title since it is not set.
                 $pageTitle = sprintf($label, $tableTitle, $pageTitle);
             }
         }
     }
     $html = array();
     $html[] = '<h1>' . $pageTitle . '</h1>';
     $html[] = '<div class="typo3-TCEforms">';
     $html[] = $childHtml;
     $html[] = '<div class="help-block text-right">';
     $html[] = $icon . ' <strong>' . htmlspecialchars($tableTitle) . '</strong>' . ' ' . $newOrUid;
     $html[] = '</div>';
     $html[] = '</div>';
     $result['html'] = implode(LF, $html);
     return $result;
 }
Exemplo n.º 4
0
    /**
     * Prints the selector box form-field for the db/file/select elements (multiple)
     *
     * @param string $fName Form element name
     * @param string $mode Mode "db", "file" (internal_type for the "group" type) OR blank (then for the "select" type)
     * @param string $allowed Commalist of "allowed
     * @param array $itemArray The array of items. For "select" and "group"/"file" this is just a set of value. For "db" its an array of arrays with table/uid pairs.
     * @param string $selector Alternative selector box.
     * @param array $params An array of additional parameters, eg: "size", "info", "headers" (array with "selector" and "items"), "noBrowser", "thumbnails
     * @param null $_ unused (onFocus in the past), will be removed in TYPO3 CMS 9
     * @param string $table (optional) Table name processing for
     * @param string $field (optional) Field of table name processing for
     * @param string $uid (optional) uid of table record processing for
     * @param array $config (optional) The TCA field config
     * @return string The form fields for the selection.
     * @throws \UnexpectedValueException
     * @todo: Hack this mess into pieces and inline to group / select element depending on what they need
     */
    protected function dbFileIcons($fName, $mode, $allowed, $itemArray, $selector = '', $params = [], $_ = null, $table = '', $field = '', $uid = '', $config = [])
    {
        $languageService = $this->getLanguageService();
        $disabled = '';
        if ($params['readOnly']) {
            $disabled = ' disabled="disabled"';
        }
        // INIT
        $uidList = [];
        $opt = [];
        $itemArrayC = 0;
        // Creating <option> elements:
        if (is_array($itemArray)) {
            $itemArrayC = count($itemArray);
            switch ($mode) {
                case 'db':
                    foreach ($itemArray as $pp) {
                        $pRec = BackendUtility::getRecordWSOL($pp['table'], $pp['id']);
                        if (is_array($pRec)) {
                            $pTitle = BackendUtility::getRecordTitle($pp['table'], $pRec, false, true);
                            $pUid = $pp['table'] . '_' . $pp['id'];
                            $uidList[] = $pUid;
                            $title = htmlspecialchars($pTitle);
                            $opt[] = '<option value="' . htmlspecialchars($pUid) . '" title="' . $title . '">' . $title . '</option>';
                        }
                    }
                    break;
                case 'file_reference':
                case 'file':
                    foreach ($itemArray as $item) {
                        $itemParts = explode('|', $item);
                        $uidList[] = $pUid = $pTitle = $itemParts[0];
                        $title = htmlspecialchars(rawurldecode($itemParts[1]));
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($itemParts[0])) . '" title="' . $title . '">' . $title . '</option>';
                    }
                    break;
                case 'folder':
                    foreach ($itemArray as $pp) {
                        $pParts = explode('|', $pp);
                        $uidList[] = $pUid = $pTitle = $pParts[0];
                        $title = htmlspecialchars(rawurldecode($pParts[0]));
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pParts[0])) . '" title="' . $title . '">' . $title . '</option>';
                    }
                    break;
                default:
                    foreach ($itemArray as $pp) {
                        $pParts = explode('|', $pp, 2);
                        $uidList[] = $pUid = $pParts[0];
                        $pTitle = $pParts[1];
                        $title = htmlspecialchars(rawurldecode($pTitle));
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pUid)) . '" title="' . $title . '">' . $title . '</option>';
                    }
            }
        }
        // Create selector box of the options
        $sSize = $params['autoSizeMax'] ? MathUtility::forceIntegerInRange($itemArrayC + 1, MathUtility::forceIntegerInRange($params['size'], 1), $params['autoSizeMax']) : $params['size'];
        if (!$selector) {
            $maxItems = (int) ($params['maxitems'] ?? 0);
            $size = (int) ($params['size'] ?? 0);
            $classes = ['form-control', 'tceforms-multiselect'];
            if ($maxItems === 1) {
                $classes[] = 'form-select-no-siblings';
            }
            $isMultiple = $maxItems !== 1 && $size !== 1;
            $selector = '<select id="' . StringUtility::getUniqueId('tceforms-multiselect-') . '" ' . ($params['noList'] ? 'style="display: none"' : 'size="' . $sSize . '" class="' . implode(' ', $classes) . '"') . ($isMultiple ? ' multiple="multiple"' : '') . ' data-formengine-input-name="' . htmlspecialchars($fName) . '" ' . $this->getValidationDataAsDataAttribute($config) . $params['style'] . $disabled . '>' . implode('', $opt) . '</select>';
        }
        $icons = ['L' => [], 'R' => []];
        $rOnClickInline = '';
        if (!$params['readOnly'] && !$params['noList']) {
            if (!$params['noBrowser']) {
                // Check against inline uniqueness
                /** @var InlineStackProcessor $inlineStackProcessor */
                $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
                $inlineStackProcessor->initializeByGivenStructure($this->data['inlineStructure']);
                $aOnClickInline = '';
                if ($this->data['isInlineChild'] && $this->data['inlineParentUid']) {
                    if ($this->data['inlineParentConfig']['foreign_table'] === $table && $this->data['inlineParentConfig']['foreign_unique'] === $field) {
                        $objectPrefix = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']) . '-' . $table;
                        $aOnClickInline = $objectPrefix . '|inline.checkUniqueElement|inline.setUniqueElement';
                        $rOnClickInline = 'inline.revertUnique(' . GeneralUtility::quoteJSvalue($objectPrefix) . ',null,' . GeneralUtility::quoteJSvalue($uid) . ');';
                    }
                }
                if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserType'])) {
                    $elementBrowserType = $config['appearance']['elementBrowserType'];
                } else {
                    $elementBrowserType = $mode;
                }
                if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserAllowed'])) {
                    $elementBrowserAllowed = $config['appearance']['elementBrowserAllowed'];
                } else {
                    $elementBrowserAllowed = $allowed;
                }
                $aOnClick = 'setFormValueOpenBrowser(' . GeneralUtility::quoteJSvalue($elementBrowserType) . ',' . GeneralUtility::quoteJSvalue($fName . '|||' . $elementBrowserAllowed . '|' . $aOnClickInline) . '); return false;';
                $icons['R'][] = '
					<a href="#"
						onclick="' . htmlspecialchars($aOnClick) . '"
						class="btn btn-default"
						title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.browse_' . ($mode == 'db' ? 'db' : 'file'))) . '">
						' . $this->iconFactory->getIcon('actions-insert-record', Icon::SIZE_SMALL)->render() . '
					</a>';
            }
            if (!$params['dontShowMoveIcons']) {
                if ($sSize >= 5) {
                    $icons['L'][] = '
						<a href="#"
							class="btn btn-default t3js-btn-moveoption-top"
							data-fieldname="' . $fName . '"
							title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_to_top')) . '">
							' . $this->iconFactory->getIcon('actions-move-to-top', Icon::SIZE_SMALL)->render() . '
						</a>';
                }
                $icons['L'][] = '
					<a href="#"
						class="btn btn-default t3js-btn-moveoption-up"
						data-fieldname="' . $fName . '"
						title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_up')) . '">
						' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '
					</a>';
                $icons['L'][] = '
					<a href="#"
						class="btn btn-default t3js-btn-moveoption-down"
						data-fieldname="' . $fName . '"
						title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_down')) . '">
						' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '
					</a>';
                if ($sSize >= 5) {
                    $icons['L'][] = '
						<a href="#"
							class="btn btn-default t3js-btn-moveoption-bottom"
							data-fieldname="' . $fName . '"
							title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_to_bottom')) . '">
							' . $this->iconFactory->getIcon('actions-move-to-bottom', Icon::SIZE_SMALL)->render() . '
						</a>';
                }
            }
            $clipElements = $this->getClipboardElements($allowed, $mode);
            if (!empty($clipElements)) {
                $aOnClick = '';
                foreach ($clipElements as $elValue) {
                    if ($mode == 'db') {
                        list($itemTable, $itemUid) = explode('|', $elValue);
                        $recordTitle = BackendUtility::getRecordTitle($itemTable, BackendUtility::getRecordWSOL($itemTable, $itemUid));
                        $itemTitle = GeneralUtility::quoteJSvalue($recordTitle);
                        $elValue = $itemTable . '_' . $itemUid;
                    } else {
                        // 'file', 'file_reference' and 'folder' mode
                        $itemTitle = 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(basename($elValue))) . ')';
                    }
                    $aOnClick .= 'setFormValueFromBrowseWin(' . GeneralUtility::quoteJSvalue($fName) . ',unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(str_replace('%20', ' ', $elValue))) . '),' . $itemTitle . ',' . $itemTitle . ');';
                }
                $aOnClick .= 'return false;';
                $icons['R'][] = '
					<a href="#"
						class="btn btn-default"
						onclick="' . htmlspecialchars($aOnClick) . '"
						title="' . htmlspecialchars(sprintf($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clipInsert_' . ($mode == 'db' ? 'db' : 'file')), count($clipElements))) . '">
						' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '
					</a>';
            }
        }
        if (!$params['readOnly'] && !$params['noDelete']) {
            $icons['L'][] = '
				<a href="#"
					class="btn btn-default t3js-btn-removeoption"
					onClick="' . $rOnClickInline . '"
					data-fieldname="' . $fName . '"
					title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.remove_selected')) . '">
					' . $this->iconFactory->getIcon('actions-selection-delete', Icon::SIZE_SMALL)->render() . '
				</a>';
        }
        // Thumbnails
        $imagesOnly = false;
        if ($params['thumbnails'] && $params['allowed']) {
            // In case we have thumbnails, check if only images are allowed.
            // In this case, render them below the field, instead of to the right
            $allowedExtensionList = $params['allowed'];
            $imageExtensionList = GeneralUtility::trimExplode(',', strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), true);
            $imagesOnly = true;
            foreach ($allowedExtensionList as $allowedExtension) {
                if (!ArrayUtility::inArray($imageExtensionList, $allowedExtension)) {
                    $imagesOnly = false;
                    break;
                }
            }
        }
        $thumbnails = '';
        if (is_array($params['thumbnails']) && !empty($params['thumbnails'])) {
            if ($imagesOnly) {
                $thumbnails .= '<ul class="list-inline">';
                foreach ($params['thumbnails'] as $thumbnail) {
                    $thumbnails .= '<li><span class="thumbnail">' . $thumbnail['image'] . '</span></li>';
                }
                $thumbnails .= '</ul>';
            } else {
                $thumbnails .= '<div class="table-fit"><table class="table table-white"><tbody>';
                foreach ($params['thumbnails'] as $thumbnail) {
                    $thumbnails .= '
						<tr>
							<td class="col-icon">
								' . ($config['internal_type'] === 'db' ? BackendUtility::wrapClickMenuOnIcon($thumbnail['image'], $thumbnail['table'], $thumbnail['uid'], 1, '', '+copy,info,edit,view') : $thumbnail['image']) . '
							</td>
							<td class="col-title">
								' . ($config['internal_type'] === 'db' ? BackendUtility::wrapClickMenuOnIcon($thumbnail['name'], $thumbnail['table'], $thumbnail['uid'], 1, '', '+copy,info,edit,view') : $thumbnail['name']) . '
								' . ($config['internal_type'] === 'db' ? ' <span class="text-muted">[' . $thumbnail['uid'] . ']</span>' : '') . '
							</td>
						</tr>
						';
                }
                $thumbnails .= '</tbody></table></div>';
            }
        }
        // Allowed Tables
        $allowedTables = '';
        if (is_array($params['allowedTables']) && !empty($params['allowedTables']) && !$params['hideAllowedTables']) {
            $allowedTables .= '<div class="help-block">';
            foreach ($params['allowedTables'] as $key => $item) {
                if (is_array($item)) {
                    if (empty($params['readOnly'])) {
                        $allowedTables .= '<a href="#" onClick="' . htmlspecialchars($item['onClick']) . '" class="btn btn-default">' . $item['icon'] . ' ' . htmlspecialchars($item['name']) . '</a> ';
                    } else {
                        $allowedTables .= '<span>' . htmlspecialchars($item['name']) . '</span> ';
                    }
                } elseif ($key === 'name') {
                    $allowedTables .= '<span>' . htmlspecialchars($item) . '</span> ';
                }
            }
            $allowedTables .= '</div>';
        }
        // Allowed
        $allowedList = '';
        if (is_array($params['allowed']) && !empty($params['allowed'])) {
            foreach ($params['allowed'] as $item) {
                $allowedList .= '<span class="label label-success">' . strtoupper($item) . '</span> ';
            }
        }
        // Disallowed
        $disallowedList = '';
        if (is_array($params['disallowed']) && !empty($params['disallowed'])) {
            foreach ($params['disallowed'] as $item) {
                $disallowedList .= '<span class="label label-danger">' . strtoupper($item) . '</span> ';
            }
        }
        // Rightbox
        $rightbox = $params['rightbox'] ?: '';
        // Hook: dbFileIcons_postProcess (requested by FAL-team for use with the "fal" extension)
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['dbFileIcons'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['dbFileIcons'] as $classRef) {
                $hookObject = GeneralUtility::getUserObj($classRef);
                if (!$hookObject instanceof DatabaseFileIconsHookInterface) {
                    throw new \UnexpectedValueException($classRef . ' must implement interface ' . DatabaseFileIconsHookInterface::class, 1290167704);
                }
                $additionalParams = ['mode' => $mode, 'allowed' => $allowed, 'itemArray' => $itemArray, 'table' => $table, 'field' => $field, 'uid' => $uid, 'config' => $GLOBALS['TCA'][$table]['columns'][$field]];
                $hookObject->dbFileIcons_postProcess($params, $selector, $thumbnails, $icons, $rightbox, $fName, $uidList, $additionalParams, $this);
            }
        }
        // Output
        $str = '
			' . ($params['headers']['selector'] ? '<label>' . $params['headers']['selector'] . '</label>' : '') . '
			<div class="form-wizards-wrap form-wizards-aside">
				<div class="form-wizards-element">
					' . $selector . '
					' . (!$params['noList'] && !empty($allowedTables) ? $allowedTables : '') . '
					' . (!$params['noList'] && (!empty($allowedList) || !empty($disallowedList)) ? '<div class="help-block">' . $allowedList . $disallowedList . ' </div>' : '') . '
				</div>
				' . (!empty($icons['L']) ? '<div class="form-wizards-items"><div class="btn-group-vertical">' . implode('', $icons['L']) . '</div></div>' : '') . '
				' . (!empty($icons['R']) ? '<div class="form-wizards-items"><div class="btn-group-vertical">' . implode('', $icons['R']) . '</div></div>' : '') . '
			</div>
			';
        if ($rightbox) {
            $str = '
				<div class="form-multigroup-wrap t3js-formengine-field-group">
					<div class="form-multigroup-item form-multigroup-element">' . $str . '</div>
					<div class="form-multigroup-item form-multigroup-element">
						' . ($params['headers']['items'] ? '<label>' . $params['headers']['items'] . '</label>' : '') . '
						' . ($params['headers']['selectorbox'] ? '<div class="form-multigroup-item-wizard">' . $params['headers']['selectorbox'] . '</div>' : '') . '
						' . $rightbox . '
					</div>
				</div>
				';
        }
        $str .= $thumbnails;
        // Creating the hidden field which contains the actual value as a comma list.
        $str .= '<input type="hidden" name="' . $fName . '" value="' . htmlspecialchars(implode(',', $uidList)) . '" />';
        return $str;
    }
Exemplo n.º 5
0
 /**
  * This returns tablerows for the files in the array $items['sorting'].
  *
  * @param File[] $files File items
  * @return string HTML table rows.
  */
 public function formatFileList(array $files)
 {
     $out = '';
     // first two keys are "0" (default) and "-1" (multiple), after that comes the "other languages"
     $allSystemLanguages = GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages();
     $systemLanguages = array_filter($allSystemLanguages, function ($languageRecord) {
         if ($languageRecord['uid'] === -1 || $languageRecord['uid'] === 0 || !$this->getBackendUser()->checkLanguageAccess($languageRecord['uid'])) {
             return false;
         } else {
             return true;
         }
     });
     foreach ($files as $fileObject) {
         // Initialization
         $this->counter++;
         $this->totalbytes += $fileObject->getSize();
         $ext = $fileObject->getExtension();
         $fileName = trim($fileObject->getName());
         // The icon with link
         $theIcon = '<span title="' . htmlspecialchars($fileName . ' [' . (int) $fileObject->getUid() . ']') . '">' . $this->iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL)->render() . '</span>';
         if ($this->clickMenus) {
             $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, $fileObject->getCombinedIdentifier());
         }
         // Preparing and getting the data-array
         $theData = array();
         foreach ($this->fieldArray as $field) {
             switch ($field) {
                 case 'size':
                     $theData[$field] = GeneralUtility::formatSize($fileObject->getSize(), $this->getLanguageService()->getLL('byteSizeUnits', true));
                     break;
                 case 'rw':
                     $theData[$field] = '' . (!$fileObject->checkActionPermission('read') ? ' ' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('read', true) . '</strong>') . (!$fileObject->checkActionPermission('write') ? '' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('write', true) . '</strong>');
                     break;
                 case 'fileext':
                     $theData[$field] = strtoupper($ext);
                     break;
                 case 'tstamp':
                     $theData[$field] = BackendUtility::date($fileObject->getModificationTime());
                     break;
                 case '_CONTROL_':
                     $theData[$field] = $this->makeEdit($fileObject);
                     break;
                 case '_CLIPBOARD_':
                     $theData[$field] = $this->makeClip($fileObject);
                     break;
                 case '_LOCALIZATION_':
                     if (!empty($systemLanguages) && $fileObject->isIndexed() && $fileObject->checkActionPermission('write') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) {
                         $metaDataRecord = $fileObject->_getMetaData();
                         $translations = $this->getTranslationsForMetaData($metaDataRecord);
                         $languageCode = '';
                         foreach ($systemLanguages as $language) {
                             $languageId = $language['uid'];
                             $flagIcon = $language['flagIcon'];
                             if (array_key_exists($languageId, $translations)) {
                                 $title = htmlspecialchars(sprintf($this->getLanguageService()->getLL('editMetadataForLanguage'), $language['title']));
                                 // @todo the overlay for the flag needs to be added ($flagIcon . '-overlay')
                                 $urlParameters = ['edit' => ['sys_file_metadata' => [$translations[$languageId]['uid'] => 'edit']], 'returnUrl' => $this->listURL()];
                                 $flagButtonIcon = $this->iconFactory->getIcon($flagIcon, Icon::SIZE_SMALL, 'overlay-edit')->render();
                                 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                                 $languageCode .= '<a href="' . htmlspecialchars($url) . '" class="btn btn-default" title="' . $title . '">' . $flagButtonIcon . '</a>';
                             } else {
                                 $parameters = ['justLocalized' => 'sys_file_metadata:' . $metaDataRecord['uid'] . ':' . $languageId, 'returnUrl' => $this->listURL()];
                                 $returnUrl = BackendUtility::getModuleUrl('record_edit', $parameters);
                                 $href = BackendUtility::getLinkToDataHandlerAction('&cmd[sys_file_metadata][' . $metaDataRecord['uid'] . '][localize]=' . $languageId, $returnUrl);
                                 $flagButtonIcon = '<span title="' . htmlspecialchars(sprintf($this->getLanguageService()->getLL('createMetadataForLanguage'), $language['title'])) . '">' . $this->iconFactory->getIcon($flagIcon, Icon::SIZE_SMALL, 'overlay-new')->render() . '</span>';
                                 $languageCode .= '<a href="' . htmlspecialchars($href) . '" class="btn btn-default">' . $flagButtonIcon . '</a> ';
                             }
                         }
                         // Hide flag button bar when not translated yet
                         $theData[$field] = ' <div class="localisationData btn-group" data-fileid="' . $fileObject->getUid() . '"' . (empty($translations) ? ' style="display: none;"' : '') . '>' . $languageCode . '</div>';
                         $theData[$field] .= '<a class="btn btn-default filelist-translationToggler" data-fileid="' . $fileObject->getUid() . '">' . '<span title="' . $this->getLanguageService()->getLL('translateMetadata', true) . '">' . $this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL)->render() . '</span>' . '</a>';
                     }
                     break;
                 case '_REF_':
                     $theData[$field] = $this->makeRef($fileObject);
                     break;
                 case 'file':
                     // Edit metadata of file
                     $theData[$field] = $this->linkWrapFile(htmlspecialchars($fileName), $fileObject);
                     if ($fileObject->isMissing()) {
                         $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                         $theData[$field] .= $flashMessage->render();
                         // Thumbnails?
                     } elseif ($this->thumbs && ($this->isImage($ext) || $this->isMediaFile($ext))) {
                         $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array());
                         if ($processedFile) {
                             $thumbUrl = $processedFile->getPublicUrl(true);
                             $theData[$field] .= '<br /><img src="' . $thumbUrl . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'title="' . htmlspecialchars($fileName) . '" alt="" />';
                         }
                     }
                     break;
                 default:
                     $theData[$field] = '';
                     if ($fileObject->hasProperty($field)) {
                         $theData[$field] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getProperty($field), $this->fixedL));
                     }
             }
         }
         $out .= $this->addelement(1, $theIcon, $theData);
     }
     return $out;
 }
Exemplo n.º 6
0
 /**
  * Wrapping $title in a-tags.
  *
  * @param string $title Title string
  * @param \TYPO3\CMS\Core\Resource\Folder $folderObject the folder record
  * @param int $bank Bank pointer (which mount point number)
  * @return string
  * @internal
  */
 public function wrapTitle($title, $folderObject, $bank = 0)
 {
     // Check storage access to wrap with click menu
     if ($folderObject instanceof InaccessibleFolder) {
         return $title;
     }
     $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($folderObject)) . ', this, ' . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($folderObject)) . ', ' . $bank . ');';
     $clickMenuParts = BackendUtility::wrapClickMenuOnIcon('', $folderObject->getCombinedIdentifier(), '', 0, '&bank=' . $this->bank, '', true);
     return '<a href="#" title="' . htmlspecialchars(strip_tags($title)) . '" onclick="' . htmlspecialchars($aOnClick) . '" ' . GeneralUtility::implodeAttributes($clickMenuParts) . '>' . $title . '</a>';
 }
Exemplo n.º 7
0
 /**
  * Setting page icon with clickmenu + uid for docheader
  *
  * @param array $pageRecord Current page
  * @return string Page info
  */
 protected function getPageInfo($pageRecord)
 {
     // Add icon with clickmenu, etc:
     // If there IS a real page
     if (is_array($pageRecord) && $pageRecord['uid']) {
         $alttext = BackendUtility::getRecordIconAltText($pageRecord, 'pages');
         $iconImg = '<span title="' . htmlspecialchars($alttext) . '">' . $this->iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>';
         // Make Icon:
         $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
         $uid = $pageRecord['uid'];
         $title = BackendUtility::getRecordTitle('pages', $pageRecord);
     } else {
         // On root-level of page tree
         // Make Icon
         $iconImg = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $this->iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render() . '</span>';
         if ($GLOBALS['BE_USER']->user['admin']) {
             $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', 0);
         } else {
             $theIcon = $iconImg;
         }
         $uid = '0';
         $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
     }
     // Setting icon with clickmenu + uid
     $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . '&nbsp;[' . $uid . ']</strong>';
     return $pageInfo;
 }
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param mixed[] $row Current record
  * @param int $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 int $indent Indent from left.
  * @param integer $level
  * @param string $expanded
  *
  * @return string Table row for the element
  * @access private
  * @see getTable()
  */
 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0, $level = 0, $expanded = '')
 {
     if (!is_array($row)) {
         return '';
     }
     $rowOutput = '';
     $id_orig = null;
     // If in search mode, make sure the preview will show the correct page
     if ((string) $this->searchString !== '') {
         $id_orig = $this->id;
         $this->id = $row['pid'];
     }
     // 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';
     }
     $row_bgColor = ' class="' . $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 = BackendUtility::getRecordIconAltText($row, $table);
     $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
     $iconImg = '<span title="' . $altText . '" ' . $additionalStyle . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // Preparing and getting the data-array
     $theData = array();
     $localizationMarkerClass = '';
     $lC2 = '';
     foreach ($this->fieldArray as $fCol) {
         if ($fCol == $titleCol) {
             $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
             $warning = '';
             // If the record is edit-locked	by another user, we will show a little warning sign:
             $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
             if ($lockInfo) {
                 $warning = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
             }
             $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
             // Render thumbnails, if:
             // - a thumbnail column exists
             // - there is content in it
             // - the thumbnail column is visible for the current type
             $type = 0;
             if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
                 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
                 $type = $row[$typeColumn];
             }
             // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
             // if 0 doesn't exist)
             if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
                 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
             }
             $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
             if ($this->thumbs && trim($row[$thumbsCol]) && preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1) {
                 $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
             }
             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, $level);
         } elseif ($fCol == '_CLIPBOARD_') {
             $theData[$fCol] = $this->makeClip($table, $row);
         } elseif ($fCol == '_LOCALIZATION_') {
             list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
             $theData[$fCol] = $lC1;
         } elseif ($fCol != '_LOCALIZATION_b') {
             $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
             $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
             if ($this->csvOutput) {
                 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
             }
         } elseif ($fCol == '_LOCALIZATION_b') {
             $theData[$fCol] = $lC2;
         } else {
             $theData[$fCol] = htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']));
         }
     }
     // Reset the ID if it was overwritten
     if ((string) $this->searchString !== '') {
         $this->id = $id_orig;
     }
     // Add row to CSV list:
     if ($this->csvOutput) {
         $this->addToCSV($row);
     }
     // Add classes to table cells
     $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
     $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
     if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
         $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';
     /**
      * @hook checkChildren
      * @date 2014-02-11
      * @request Alexander Grein <*****@*****.**>
      */
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
             $hookObject = GeneralUtility::getUserObj($classData);
             if (is_object($hookObject) && method_exists($hookObject, 'checkChildren')) {
                 $hookObject->checkChildren($table, $row, $level, $theData, $this);
             }
         }
     }
     // Create element in table cells:
     $theData['uid'] = $row['uid'];
     if ($table === 'tt_content') {
         $theData['tx_gridelements_container'] = $row['tx_gridelements_container'];
     }
     if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
         $theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
     }
     $rowOutput .= $this->addElement(1, $theIcon, $theData, $row_bgColor, '', '', '', $level);
     if ($this->localizationView && $this->l10nEnabled) {
         // For each available translation, render the record:
         if (is_array($this->translations)) {
             foreach ($this->translations as $lRow) {
                 // $lRow isn't always what we want - if record was moved we've to work with the
                 // placeholder records otherwise the list is messed up a bit
                 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
                     $where = 't3ver_move_id="' . (int) $lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility::deleteClause($table);
                     $tmpRow = BackendUtility::getRecordRaw($table, $where, $this->selFieldList);
                     $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                 }
                 // In offline workspace, look for alternative record:
                 BackendUtility::workspaceOL($table, $lRow, $this->backendUser->workspace, true);
                 if (is_array($lRow) && $this->backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                     $this->currentIdList[] = $lRow['uid'];
                     if ($row['tx_gridelements_container']) {
                         $lRow['_CSSCLASS'] = 't3-gridelements-child" data-trigger-container="' . $row['tx_gridelements_container'] . $expanded;
                     }
                     $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 20, $level);
                 }
             }
         }
     }
     if ($theData['_EXPANDABLE_'] && $level < 8 && ($row['l18n_parent'] == 0 || !$this->localizationView)) {
         if (!empty($theData['_CHILDREN_'])) {
             $expanded = $this->expandedGridelements[$row['uid']] ? '" style="display: table-row;' : '';
             $lastGridColumn = '';
             $originalMoveUp = $this->showMoveUp;
             $originalMoveDown = $this->showMoveDown;
             $prevPrevUid = (int) $theData['_CHILDREN_'][0]['uid'];
             $prevUid = (int) $theData['_CHILDREN_'][1]['uid'];
             foreach ($theData['_CHILDREN_'] as $key => $child) {
                 if ($key > 1) {
                     if ($prevUid) {
                         $this->currentTable['prev'][$child['uid']] = $prevPrevUid;
                         $this->currentTable['next'][$prevUid] = -(int) $child['uid'];
                         $this->currentTable['prevUid'][$child['uid']] = $prevUid;
                     }
                     $prevPrevUid = isset($this->currentTable['prev'][$child['uid']]) ? -$prevUid : $row['pid'];
                     $prevUid = $child['uid'];
                 }
             }
             foreach ($theData['_CHILDREN_'] as $key => $child) {
                 if (isset($child['tx_gridelements_columns']) && $child['tx_gridelements_columns'] != $lastGridColumn) {
                     $lastGridColumn = $child['tx_gridelements_columns'];
                     $this->showMoveUp = false;
                     $rowOutput .= '<tr class="t3-gridelements-child" data-trigger-container="' . ($this->localizationView && $row['l18n_parent'] ? $row['l18n_parent'] : $row['uid']) . $expanded . '" data-grid-container="' . $row['uid'] . '">
                                 <td colspan="2"></td>
                                 <td colspan="' . (count($this->fieldArray) - 1 + $this->maxDepth) . '" style="padding:5px;">
                                     <br />
                                     <strong>' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName') . ' ' . ($backendLayoutColumns[$child['tx_gridelements_columns']] ? $backendLayoutColumns[$child['tx_gridelements_columns']] : (int) $child['tx_gridelements_columns']) . '</strong>
                                 </td>
                             </tr>';
                 } else {
                     $this->showMoveUp = true;
                 }
                 if (isset($child['tx_gridelements_columns']) && isset($theData['_CHILDREN_'][$key + 1]) && $child['tx_gridelements_columns'] != $theData['_CHILDREN_'][$key + 1]['tx_gridelements_columns']) {
                     $this->showMoveDown = false;
                 } else {
                     $this->showMoveDown = true;
                 }
                 $this->currentIdList[] = $child['uid'];
                 if ($row['CType'] === 'gridelements_pi1') {
                     $this->currentContainerIdList[] = $row['uid'];
                 }
                 $child['_CSSCLASS'] = 't3-gridelements-child" data-trigger-container="' . ($this->localizationView && $row['l18n_parent'] ? $row['l18n_parent'] : $row['uid']) . $expanded;
                 $rowOutput .= $this->renderListRow($table, $child, $cc, $titleCol, $thumbsCol, 0, $level + 1, $expanded);
             }
             $this->showMoveUp = $originalMoveUp;
             $this->showMoveDown = $originalMoveDown;
         }
     }
     // Finally, return table row element:
     return $rowOutput;
 }
 /**
  * Main function of class
  *
  * @return string HTML output
  */
 public function main()
 {
     $pageId = (int) GeneralUtility::_GP('id');
     if ($pageId === 0) {
         $this->view->assign('pageZero', 1);
         $this->view->assign('overviewOfPagesUsingTSConfig', $this->getOverviewOfPagesUsingTSConfig());
     } else {
         if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
             $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, null, true);
             $lines = array();
             $pUids = array();
             foreach ($TSparts as $k => $v) {
                 if ($k != 'uid_0') {
                     $line = array();
                     if ($k == 'defaultPageTSconfig') {
                         $line['defaultPageTSconfig'] = 1;
                     } else {
                         $pUids[] = substr($k, 4);
                         $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
                         $icon = $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL);
                         $editIdList = substr($k, 4);
                         $urlParameters = ['edit' => ['pages' => [$editIdList => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                         $line['editIcon'] = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                         $line['editTitle'] = 'editTSconfig';
                         $line['title'] = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']) . ' ' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $row));
                     }
                     $tsparser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
                     $tsparser->lineNumberOffset = 0;
                     $line['content'] = $tsparser->doSyntaxHighlight(trim($v) . LF);
                     $lines[] = $line;
                 }
             }
             if (!empty($pUids)) {
                 $urlParameters = ['edit' => ['pages' => [implode(',', $pUids) => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                 $editIcon = htmlspecialchars($url);
                 $editTitle = 'editTSconfig_all';
             } else {
                 $editIcon = '';
                 $editTitle = '';
             }
             $this->view->assign('tsconfParts99', 1);
             $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', null, '|'));
             $this->view->assign('lines', $lines);
             $this->view->assign('editIcon', $editIcon);
             $this->view->assign('editTitle', $editTitle);
         } else {
             $this->view->assign('tsconfParts99', 0);
             // Defined global here!
             $tmpl = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
             // Do not log time-performance information
             $tmpl->tt_track = 0;
             $tmpl->fixedLgd = 0;
             $tmpl->linkObjects = 0;
             $tmpl->bType = '';
             $tmpl->ext_expandAllNotes = 1;
             $tmpl->ext_noPMicons = 1;
             $beUser = $this->getBackendUser();
             switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
                 case '1':
                     $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
                     break;
                 case '1a':
                     $modTSconfig = $beUser->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1b':
                     $modTSconfig = $beUser->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1c':
                     $modTSconfig = $beUser->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1d':
                     $modTSconfig = $beUser->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1e':
                     $modTSconfig = $beUser->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1f':
                     $modTSconfig = $beUser->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1g':
                     $modTSconfig = $beUser->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '2':
                     $modTSconfig = $beUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '5':
                     $modTSconfig = $beUser->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '6':
                     $modTSconfig = $beUser->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '3':
                     $modTSconfig = $beUser->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '4':
                     $modTSconfig = $beUser->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 default:
                     $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
             }
             $modTSconfig = $modTSconfig['properties'];
             if (!is_array($modTSconfig)) {
                 $modTSconfig = array();
             }
             $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', null, '|'));
             $this->view->assign('tree', $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']));
         }
         $this->view->assign('alphaSort', BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"'));
         $this->view->assign('dropdownMenu', BackendUtility::getDropdownMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']));
     }
     return $this->view->render();
 }
Exemplo n.º 10
0
 /**
  * Get the rendered page title including onclick menu
  *
  * @param $detailPid
  * @return string
  */
 public function getPageRecordData($detailPid)
 {
     $pageRecord = BackendUtilityCore::getRecord('pages', $detailPid);
     if (is_array($pageRecord)) {
         $data = '<span title="Uid: ' . htmlspecialchars($pageRecord['uid']) . '">' . $this->iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>' . htmlspecialchars(BackendUtilityCore::getRecordTitle('pages', $pageRecord));
         $content = BackendUtilityCore::wrapClickMenuOnIcon($data, 'pages', $pageRecord['uid'], true, '', '+info,edit');
     } else {
         /** @var $message FlashMessage */
         $text = sprintf($this->getLanguageService()->sL(self::LLPATH . 'pagemodule.pageNotAvailable', true), $detailPid);
         $message = GeneralUtility::makeInstance(FlashMessage::class, $text, '', FlashMessage::WARNING);
         $content = $message->render();
     }
     return $content;
 }
    /**
     * Main function of class
     *
     * @return string HTML output
     */
    public function main()
    {
        if ((int) GeneralUtility::_GP('id') === 0) {
            $lang = $this->getLanguageService();
            return '<div class="nowrap"><div class="table-fit"><table class="table table-striped table-hover" id="tsconfig-overview">' . '<thead>' . '<tr>' . '<th>' . $lang->getLL('pagetitle') . '</th>' . '<th>' . $lang->getLL('included_tsconfig_files') . '</th>' . '<th>' . $lang->getLL('written_tsconfig_lines') . '</th>' . '</tr>' . '</thead>' . '<tbody>' . implode('', $this->getOverviewOfPagesUsingTSConfig()) . '</tbody>' . '</table></div>';
        } else {
            $menu = '<div class="form-inline form-inline-spaced">';
            $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
            $menu .= '<div class="checkbox"><label for="checkTsconf_alphaSort">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"') . ' ' . $this->getLanguageService()->getLL('sort_alphabetic', true) . '</label></div>';
            $menu .= '</div>';
            $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->getLL('tsconf_title')) . '</h1>';
            if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
                $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, null, true);
                $lines = array();
                $pUids = array();
                foreach ($TSparts as $k => $v) {
                    if ($k != 'uid_0') {
                        if ($k == 'defaultPageTSconfig') {
                            $pTitle = '<strong>' . $this->getLanguageService()->getLL('editTSconfig_default', true) . '</strong>';
                            $editIcon = '';
                        } else {
                            $pUids[] = substr($k, 4);
                            $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
                            $icon = $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL);
                            $pTitle = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']) . ' ' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $row));
                            $editIdList = substr($k, 4);
                            $urlParameters = ['edit' => ['pages' => [$editIdList => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                            $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                            $editIcon = '<a href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->getLL('editTSconfig', true) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
                        }
                        $TScontent = nl2br(htmlspecialchars(trim($v) . LF));
                        $tsparser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
                        $tsparser->lineNumberOffset = 0;
                        $TScontent = $tsparser->doSyntaxHighlight(trim($v) . LF);
                        $lines[] = '
							<tr><td nowrap="nowrap" class="bgColor5">' . $pTitle . '</td></tr>
							<tr><td nowrap="nowrap" class="bgColor4">' . $TScontent . $editIcon . '</td></tr>
							<tr><td>&nbsp;</td></tr>
						';
                    }
                }
                if (!empty($pUids)) {
                    $urlParameters = ['edit' => ['pages' => [implode(',', $pUids) => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                    $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                    $editIcon = '<a href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->getLL('editTSconfig_all', true) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '<strong>' . $this->getLanguageService()->getLL('editTSconfig_all', true) . '</strong>' . '</a>';
                } else {
                    $editIcon = '';
                }
                $theOutput .= '<div>';
                $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', null, '<span class="btn btn-default btn-sm">|</span>') . $menu . '
						<!-- Edit fields: -->
						<table border="0" cellpadding="0" cellspacing="1">' . implode('', $lines) . '</table><br />' . $editIcon;
                $theOutput .= '</div>';
            } else {
                // Defined global here!
                $tmpl = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
                // Do not log time-performance information
                $tmpl->tt_track = 0;
                $tmpl->fixedLgd = 0;
                $tmpl->linkObjects = 0;
                $tmpl->bType = '';
                $tmpl->ext_expandAllNotes = 1;
                $tmpl->ext_noPMicons = 1;
                $beUser = $this->getBackendUser();
                switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
                    case '1':
                        $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
                        break;
                    case '1a':
                        $modTSconfig = $beUser->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1b':
                        $modTSconfig = $beUser->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1c':
                        $modTSconfig = $beUser->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1d':
                        $modTSconfig = $beUser->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1e':
                        $modTSconfig = $beUser->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1f':
                        $modTSconfig = $beUser->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1g':
                        $modTSconfig = $beUser->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '2':
                        $modTSconfig = $beUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '5':
                        $modTSconfig = $beUser->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '6':
                        $modTSconfig = $beUser->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '3':
                        $modTSconfig = $beUser->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '4':
                        $modTSconfig = $beUser->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    default:
                        $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
                }
                $modTSconfig = $modTSconfig['properties'];
                if (!is_array($modTSconfig)) {
                    $modTSconfig = array();
                }
                $csh = BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', null, '<span class="btn btn-default btn-sm">|</span>');
                $tree = $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']);
                $theOutput .= '<div>';
                $theOutput .= $csh . $menu . '<div class="nowrap">' . $tree . '</div>';
                $theOutput .= '</div>';
            }
        }
        return $theOutput;
    }
Exemplo n.º 12
0
    /**
     * Rendering the localization information table.
     *
     * @param array $tree The Page tree data
     * @return string HTML for the localization information table.
     */
    public function renderL10nTable(&$tree)
    {
        $lang = $this->getLanguageService();
        // System languages retrieved:
        $languages = $this->getSystemLanguages();
        // Title length:
        $titleLen = $this->getBackendUser()->uc['titleLen'];
        // Put together the TREE:
        $output = '';
        $newOL_js = [];
        $langRecUids = [];
        foreach ($tree->tree as $data) {
            $tCells = [];
            $langRecUids[0][] = $data['row']['uid'];
            // Page icons / titles etc.
            $tCells[] = '<td' . ($data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '') . '>' . ($data['depthData'] ?: '') . BackendUtility::wrapClickMenuOnIcon($data['HTML'], 'pages', $data['row']['uid']) . '<a href="#" onclick="' . htmlspecialchars('top.loadEditId(' . (int) $data['row']['uid'] . ',"&SET[language]=0"); return false;') . '" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPage') . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($data['row']['title'], $titleLen)) . '</a>' . ((string) $data['row']['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($data['row']['nav_title'], $titleLen)) . '</em>]' : '') . '</td>';
            // DEFAULT language:
            // "View page" link is created:
            $viewPageLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($data['row']['uid'], '', '', '', '', '&L=###LANG_UID###')) . '" class="btn btn-default" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
            $status = GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'danger' : 'success';
            // Create links:
            $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => ['pages' => [$data['row']['uid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
            $info = str_replace('###LANG_UID###', '0', $viewPageLink);
            $info .= '<a href="' . htmlspecialchars($editUrl) . '" class="btn btn-default" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editDefaultLanguagePage') . '">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>';
            $info .= '&nbsp;';
            $info .= GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? '<span title="' . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.1')) . '">D</span>' : '&nbsp;';
            $info .= GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) ? '<span title="' . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.2')) . '">N</span>' : '&nbsp;';
            // Put into cell:
            $tCells[] = '<td class="' . $status . ' col-border-left"><div class="btn-group">' . $info . '</div></td>';
            $tCells[] = '<td class="' . $status . '" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_CEcount') . '" align="center">' . $this->getContentElementCount($data['row']['uid'], 0) . '</td>';
            $modSharedTSconfig = BackendUtility::getModTSconfig($data['row']['uid'], 'mod.SHARED');
            $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], true) : [];
            // Traverse system languages:
            foreach ($languages as $langRow) {
                if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int) $this->pObj->MOD_SETTINGS['lang'] === (int) $langRow['uid']) {
                    $row = $this->getLangStatus($data['row']['uid'], $langRow['uid']);
                    $info = '';
                    if (is_array($row)) {
                        $langRecUids[$langRow['uid']][] = $row['uid'];
                        $status = $row['_HIDDEN'] ? GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'danger' : '' : 'success';
                        $icon = $this->iconFactory->getIconForRecord('pages_language_overlay', $row, Icon::SIZE_SMALL)->render();
                        $info = $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen)) . ((string) $row['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) . '</em>]' : '') . ($row['_COUNT'] > 1 ? '<div>' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_badThingThereAre') . '</div>' : '');
                        $tCells[] = '<td class="' . $status . ' col-border-left">' . '<a href="#" onclick="' . htmlspecialchars('top.loadEditId(' . (int) $data['row']['uid'] . ',"&SET[language]=' . $langRow['uid'] . '"); return false;') . '" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPageLang') . '">' . $info . '</a></td>';
                        // Edit whole record:
                        // Create links:
                        $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => ['pages_language_overlay' => [$row['uid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
                        $info = str_replace('###LANG_UID###', $langRow['uid'], $viewPageLink);
                        $info .= '<a href="' . htmlspecialchars($editUrl) . '" class="btn btn-default" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLanguageOverlayRecord') . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
                        $tCells[] = '<td class="' . $status . '"><div class="btn-group">' . $info . '</div></td>';
                        $tCells[] = '<td class="' . $status . '" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_CEcount') . '" align="center">' . $this->getContentElementCount($data['row']['uid'], $langRow['uid']) . '</td>';
                    } else {
                        if (in_array($langRow['uid'], $disableLanguages)) {
                            // Language has been disabled for this page
                            $status = 'danger';
                            $info = '';
                        } else {
                            $status = GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'danger' : '';
                            $info = '<div class="btn-group"><label class="btn btn-default btn-checkbox">';
                            $info .= '<input type="checkbox" name="newOL[' . $langRow['uid'] . '][' . $data['row']['uid'] . ']" value="1" />';
                            $info .= '<span class="t3-icon fa"></span></label></div>';
                            $newOL_js[$langRow['uid']] .= '
								+(document.webinfoForm[' . GeneralUtility::quoteJSvalue('newOL[' . $langRow['uid'] . '][' . $data['row']['uid'] . ']') . '].checked ? ' . GeneralUtility::quoteJSvalue('&edit[pages_language_overlay][' . $data['row']['uid'] . ']=new') . ' : \'\')
							';
                        }
                        $tCells[] = '<td class="' . $status . ' col-border-left">&nbsp;</td>';
                        $tCells[] = '<td class="' . $status . '">&nbsp;</td>';
                        $tCells[] = '<td class="' . $status . '">' . $info . '</td>';
                    }
                }
            }
            $output .= '
				<tr>
					' . implode('
					', $tCells) . '
				</tr>';
        }
        // Put together HEADER:
        $tCells = [];
        $tCells[] = '<td>' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_page') . ':</td>';
        if (is_array($langRecUids[0])) {
            $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => ['pages' => [implode(',', $langRecUids[0]) => 'edit']], 'columnsOnly' => 'title,nav_title,l18n_cfg,hidden', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
            $editIco = '<a href="' . htmlspecialchars($editUrl) . '" class="btn btn-default" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editPageProperties') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
        } else {
            $editIco = '';
        }
        $tCells[] = '<td class="col-border-left" colspan="2">' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_default') . ':' . $editIco . '</td>';
        foreach ($languages as $langRow) {
            if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int) $this->pObj->MOD_SETTINGS['lang'] === (int) $langRow['uid']) {
                // Title:
                $tCells[] = '<td class="col-border-left">' . htmlspecialchars($langRow['title']) . '</td>';
                // Edit language overlay records:
                if (is_array($langRecUids[$langRow['uid']])) {
                    $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => ['pages_language_overlay' => [implode(',', $langRecUids[$langRow['uid']]) => 'edit']], 'columnsOnly' => 'title,nav_title,hidden', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
                    $editButton = '<a href="' . htmlspecialchars($editUrl) . '" class="btn btn-default" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLangOverlays') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
                } else {
                    $editButton = '';
                }
                // Create new overlay records:
                $params = '&columnsOnly=title,hidden,sys_language_uid&overrideVals[pages_language_overlay][sys_language_uid]=' . $langRow['uid'];
                $onClick = BackendUtility::editOnClick($params);
                if (!empty($newOL_js[$langRow['uid']])) {
                    $onClickArray = explode('?', $onClick, 2);
                    $lastElement = array_pop($onClickArray);
                    array_push($onClickArray, '\'' . $newOL_js[$langRow['uid']] . ' + \'&' . $lastElement);
                    $onClick = implode('?', $onClickArray);
                }
                $newButton = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($onClick) . '" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_getlangsta_createNewTranslationHeaders') . '">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . '</a>';
                $tCells[] = '<td class="btn-group">' . $editButton . $newButton . '</td>';
                $tCells[] = '<td>&nbsp;</td>';
            }
        }
        $output = '<div class="table-fit">' . '<table class="table table-striped table-hover" id="langTable">' . '<thead>' . '<tr>' . implode('', $tCells) . '</tr>' . '</thead>' . '<tbody>' . $output . '</tbody>' . '</table>' . '</div>';
        return $output;
    }
Exemplo n.º 13
0
 /**
  * Wrapping $title in a-tags.
  *
  * @param string $title Title string
  * @param string $row Item record
  * @param int $bank Bank pointer (which mount point number)
  * @return string
  * @access private
  */
 public function wrapTitle($title, $row, $bank = 0)
 {
     // Hook for overriding the page title
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay'])) {
         $_params = array('title' => &$title, 'row' => &$row);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay'] as $_funcRef) {
             GeneralUtility::callUserFunction($_funcRef, $_params, $this);
         }
         unset($_params);
     }
     $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($row)) . ',' . $bank . ');';
     $clickMenuParts = BackendUtility::wrapClickMenuOnIcon('', 'pages', $row['uid'], 0, '&bank=' . $this->bank, '', true);
     $thePageTitle = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"' . GeneralUtility::implodeAttributes($clickMenuParts) . '>' . $title . '</a>';
     // Wrap title in a drag/drop span.
     return '<span class="list-tree-title dragTitle" id="dragTitleID_' . $row['uid'] . '">' . $thePageTitle . '</span>';
 }
Exemplo n.º 14
0
 /**
  * Setting page icon with clickMenu + uid for docheader
  *
  * @return string Record info
  */
 public function getRecordInformation()
 {
     $pageRecord = $this->recordArray;
     if (empty($pageRecord)) {
         return '';
     }
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $uid = '';
     $title = '';
     $additionalInfo = !empty($pageRecord['_additional_info']) ? $pageRecord['_additional_info'] : '';
     // Add icon with clickMenu, etc:
     // If there IS a real page
     if (is_array($pageRecord) && $pageRecord['uid']) {
         $toolTip = BackendUtility::getRecordToolTip($pageRecord, 'pages');
         $iconImg = '<span ' . $toolTip . '>' . $iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>';
         // Make Icon:
         $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
         $uid = $pageRecord['uid'];
         $title = BackendUtility::getRecordTitle('pages', $pageRecord);
         // If the module is about a FAL resource
     } elseif (is_array($pageRecord) && !empty($pageRecord['combined_identifier'])) {
         try {
             $resourceObject = ResourceFactory::getInstance()->getInstance()->getObjectFromCombinedIdentifier($pageRecord['combined_identifier']);
             $fileMountTitle = $resourceObject->getStorage()->getFileMounts()[$resourceObject->getIdentifier()]['title'];
             $title = $fileMountTitle ?: $resourceObject->getName();
             // If this is a folder but not in within file mount boundaries this is the root folder
             if ($resourceObject instanceof FolderInterface && !$resourceObject->getStorage()->isWithinFileMountBoundaries($resourceObject)) {
                 $iconImg = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForResource($resourceObject, Icon::SIZE_SMALL, null, array('mount-root' => true))->render() . '</span>';
             } else {
                 $iconImg = '<span title="' . htmlspecialchars($title) . '">' . $iconFactory->getIconForResource($resourceObject, Icon::SIZE_SMALL)->render() . '</span>';
             }
             $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, $pageRecord['combined_identifier']);
         } catch (ResourceDoesNotExistException $e) {
             $theIcon = '';
         }
     } else {
         // On root-level of page tree
         // Make Icon
         $iconImg = '<span title="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render() . '</span>';
         if ($this->getBackendUser()->isAdmin()) {
             $theIcon = BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', 0);
         } else {
             $theIcon = $iconImg;
         }
         $uid = '0';
         $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
     }
     // Setting icon with clickMenu + uid
     return $theIcon . ' <strong>' . htmlspecialchars($title) . ($uid !== '' ? '&nbsp;[' . $uid . ']' : '') . '</strong>' . (!empty($additionalInfo) ? ' ' . htmlspecialchars($additionalInfo) : '');
 }
Exemplo n.º 15
0
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param mixed[] $row Current record
  * @param int $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 int $indent Indent from left.
  * @return string Table row for the element
  * @access private
  * @see getTable()
  */
 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
 {
     if (!is_array($row)) {
         return '';
     }
     $rowOutput = '';
     $id_orig = null;
     // If in search mode, make sure the preview will show the correct page
     if ((string) $this->searchString !== '') {
         $id_orig = $this->id;
         $this->id = $row['pid'];
     }
     // 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';
     }
     $row_bgColor = ' class="' . $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
     $toolTip = BackendUtility::getRecordToolTip($row, $table);
     $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
     $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // Preparing and getting the data-array
     $theData = array();
     $localizationMarkerClass = '';
     foreach ($this->fieldArray as $fCol) {
         if ($fCol == $titleCol) {
             $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
             $warning = '';
             // If the record is edit-locked	by another user, we will show a little warning sign:
             $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
             if ($lockInfo) {
                 $warning = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
             }
             $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
             // Render thumbnails, if:
             // - a thumbnail column exists
             // - there is content in it
             // - the thumbnail column is visible for the current type
             $type = 0;
             if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
                 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
                 $type = $row[$typeColumn];
             }
             // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
             // if 0 doesn't exist)
             if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
                 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
             }
             $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
             if ($this->thumbs && trim($row[$thumbsCol]) && preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1) {
                 $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
             }
             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 == '_CLIPBOARD_') {
             $theData[$fCol] = $this->makeClip($table, $row);
         } elseif ($fCol == '_LOCALIZATION_') {
             list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
             $theData[$fCol] = $lC1;
             $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
         } elseif ($fCol == '_LOCALIZATION_b') {
             // deliberately empty
         } else {
             $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
             $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
             $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
             if ($this->csvOutput) {
                 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
             }
         }
     }
     // Reset the ID if it was overwritten
     if ((string) $this->searchString !== '') {
         $this->id = $id_orig;
     }
     // Add row to CSV list:
     if ($this->csvOutput) {
         $this->addToCSV($row);
     }
     // Add classes to table cells
     $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
     $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
     if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
         $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:
     $theData['uid'] = $row['uid'];
     if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
         $theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
     }
     $rowOutput .= $this->addElement(1, $theIcon, $theData, $row_bgColor);
     // Finally, return table row element:
     return $rowOutput;
 }
 /**
  * Entry method
  *
  * @return array As defined in initializeResultArray() of AbstractNode
  */
 public function render()
 {
     $languageService = $this->getLanguageService();
     $backendUser = $this->getBackendUserAuthentication();
     $table = $this->data['tableName'];
     $row = $this->data['databaseRow'];
     $options = $this->data;
     if (empty($this->data['fieldListToRender'])) {
         $options['renderType'] = 'fullRecordContainer';
     } else {
         $options['renderType'] = 'listOfFieldsContainer';
     }
     $result = $this->nodeFactory->create($options)->render();
     $childHtml = $result['html'];
     $recordPath = '';
     // @todo: what is this >= 0 check for? wsol cases?!
     if ($this->data['effectivePid'] >= 0) {
         $permissionsClause = $backendUser->getPagePermsClause(1);
         $recordPath = BackendUtility::getRecordPath($this->data['effectivePid'], $permissionsClause, 15);
     }
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $icon = '<span title="' . htmlspecialchars($recordPath) . '">' . $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     // @todo: Could this be done in a more clever way? Does it work at all?
     $tableTitle = $languageService->sL($this->data['processedTca']['ctrl']['title']);
     if ($this->data['command'] === 'new') {
         $newOrUid = ' <span class="typo3-TCEforms-newToken">' . $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.new', true) . '</span>';
         // @todo: There is quite some stuff do to for WS overlays ...
         $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $this->data['effectivePid'], 'title');
         $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
         if ($table === 'pages') {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.createNewPage', true);
             $pageTitle = sprintf($label, $tableTitle);
         } else {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.createNewRecord', true);
             if ($this->data['effectivePid'] === 0) {
                 $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.createNewRecordRootLevel', true);
             }
             $pageTitle = sprintf($label, $tableTitle, $pageTitle);
         }
     } else {
         $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid'], 1, '', '+copy,info,edit,view');
         $newOrUid = ' <span class="typo3-TCEforms-recUid">[' . htmlspecialchars($row['uid']) . ']</span>';
         // @todo: getRecordTitlePrep applies an htmlspecialchars here
         $recordLabel = BackendUtility::getRecordTitlePrep($this->data['recordTitle']);
         if ($table === 'pages') {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editPage', true);
             $pageTitle = sprintf($label, $tableTitle, $recordLabel);
         } else {
             $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editRecord', true);
             $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $row['pid'], 'uid,title');
             $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
             if (empty($recordLabel)) {
                 $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editRecordNoTitle', true);
             }
             if ($this->data['effectivePid'] === 0) {
                 $label = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.editRecordRootLevel', true);
             }
             if (!empty($recordLabel)) {
                 // Use record title and prepend an edit label.
                 $pageTitle = sprintf($label, $tableTitle, $recordLabel, $pageTitle);
             } else {
                 // Leave out the record title since it is not set.
                 $pageTitle = sprintf($label, $tableTitle, $pageTitle);
             }
         }
     }
     $view = GeneralUtility::makeInstance(StandaloneView::class);
     $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/OuterWrapContainer.html'));
     $descriptionColumn = !empty($this->data['processedTca']['ctrl']['descriptionColumn']) ? $this->data['processedTca']['ctrl']['descriptionColumn'] : null;
     if ($descriptionColumn !== null) {
         $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.recordInformation');
         $content = $this->data['databaseRow'][$descriptionColumn];
         $view->assignMultiple(['infoBoxMessageTitle' => $title, 'infoBoxMessage' => $content]);
     }
     $view->assignMultiple(array('pageTitle' => $pageTitle, 'childHtml' => $childHtml, 'icon' => $icon, 'tableTitle' => $tableTitle, 'newOrUid' => $newOrUid));
     $result['html'] = $view->render();
     return $result;
 }
Exemplo n.º 17
0
 /**
  * Wrapping the image tag, $icon, for the row, $row (except for mount points)
  *
  * @param string $icon The image tag for the icon
  * @param array $row The row for the current element
  * @return string The processed icon input value.
  * @access private
  */
 public function wrapIcon($icon, $row)
 {
     // Wrap icon in click-menu link.
     $theIcon = '';
     if (!$this->ext_IconMode) {
         $theIcon = BackendUtility::wrapClickMenuOnIcon($icon, $this->treeName, $this->getId($row), 0);
     } elseif ($this->ext_IconMode === 'titlelink') {
         $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($row)) . ',' . $this->bank . ');';
         $theIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
     }
     return $theIcon;
 }
Exemplo n.º 18
0
 /**
  * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
  *
  * @param string $table Table name
  * @param array $row Record array
  * @return string HTML for the icon
  */
 public function getIcon($table, $row)
 {
     // Initialization
     $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
     $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     $this->counter++;
     // The icon with link
     if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
         $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
     }
     return $icon;
 }
Exemplo n.º 19
0
 /**
  * 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 ? BackendUtility::wrapClickMenuOnIcon($fileIcon, $absFilePath, 0, 1, '', '+copy,info,edit,view') : $fileIcon) . $imgPath . '</span>';
         }
         return implode('<br />', $imgs);
     } else {
         return nl2br(htmlspecialchars($value));
     }
 }