‪TYPO3CMS  10.4
DocumentTemplate.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Log\LoggerAwareInterface;
19 use Psr\Log\LoggerAwareTrait;
37 
53 class ‪DocumentTemplate implements LoggerAwareInterface
54 {
55  use LoggerAwareTrait;
56 
57  // Vars you typically might want to/should set from outside after making instance of this class:
64  public ‪$form = '';
65 
71  public ‪$JScode = '';
72 
78  public ‪$JScodeArray = ['jumpToUrl' => '
79 function jumpToUrl(URL) {
80  console.warn(\'jumpToUrl() has been marked as deprecated.\');
81  window.location.href = URL;
82  return false;
83 }
84  '];
85 
91  public ‪$postCode = '';
92 
98  public ‪$moduleTemplate = '';
99 
106 
112  public ‪$scriptID = '';
113 
119  public ‪$bodyTagId = '';
120 
126  public ‪$bodyTagAdditions = '';
127 
134  public ‪$inDocStylesArray = [];
135 
141  public ‪$styleSheetFile = '';
142 
148  public ‪$styleSheetFile2 = '';
149 
155  public ‪$styleSheetFile_post = '';
156 
162  protected ‪$useCompatibilityTag = false;
163 
169  protected ‪$xUaCompatibilityVersion = 'IE=edge';
170 
171  // Skinning
177  protected ‪$stylesheetsSkins = [
178  'structure' => 'Resources/Public/Css/structure/',
179  'visual' => 'Resources/Public/Css/visual/'
180  ];
181 
187  public ‪$divClass = '';
188 
192  public ‪$pageHeaderBlock = '';
193 
197  public ‪$endOfPageJsBlock = '';
198 
202  protected ‪$pageRenderer;
203 
209  protected ‪$pageHeaderFooterTemplateFile = '';
210 
216  public ‪$showFlashMessages = true;
217 
221  protected ‪$iconFactory;
222 
226  protected ‪$templateService;
227 
231  public function ‪__construct()
232  {
233  $this->‪initPageRenderer();
234  trigger_error(__CLASS__ . ' will be removed in TYPO3 v11. Use ModuleTemplate API instead.', E_USER_DEPRECATED);
235 
236  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
237 
238  // initialize Marker Support
239  $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
240 
241  // Setting default scriptID, trim forward slash from route
242  $this->scriptID = ltrim(GeneralUtility::_GET('route'), '/');
243  $this->bodyTagId = preg_replace('/[^A-Za-z0-9-]/', '-', $this->scriptID);
244  // Individual configuration per script? If so, make a recursive merge of the arrays:
245  if (is_array(‪$GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID] ?? false)) {
246  // Make copy
247  $ovr = ‪$GLOBALS['TBE_STYLES']['scriptIDindex'][‪$this->scriptID];
248  // merge styles.
250  // Have to unset - otherwise the second instantiation will do it again!
251  unset(‪$GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID]);
252  }
253  // Main Stylesheets:
254  if (!empty(‪$GLOBALS['TBE_STYLES']['stylesheet'])) {
255  $this->styleSheetFile = ‪$GLOBALS['TBE_STYLES']['stylesheet'];
256  }
257  if (!empty(‪$GLOBALS['TBE_STYLES']['stylesheet2'])) {
258  $this->styleSheetFile2 = ‪$GLOBALS['TBE_STYLES']['stylesheet2'];
259  }
260  if (!empty(‪$GLOBALS['TBE_STYLES']['styleSheetFile_post'])) {
261  $this->styleSheetFile_post = ‪$GLOBALS['TBE_STYLES']['styleSheetFile_post'];
262  }
263  if (!empty(‪$GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'])) {
264  $this->inDocStylesArray['TBEstyle'] = ‪$GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'];
265  }
266  // include all stylesheets
267  foreach ($this->‪getSkinStylesheetDirectories() as $stylesheetDirectory) {
268  $this->‪addStyleSheetDirectory($stylesheetDirectory);
269  }
270  }
271 
275  protected function ‪initPageRenderer()
276  {
277  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
278  $this->pageRenderer->setLanguage($this->‪getLanguageService()->lang);
279  $this->pageRenderer->enableConcatenateCss();
280  $this->pageRenderer->enableConcatenateJavascript();
281  $this->pageRenderer->enableCompressCss();
282  $this->pageRenderer->enableCompressJavascript();
283  $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/GlobalEventHandler');
284  $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ActionDispatcher');
285  if (‪$GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
286  $this->pageRenderer->enableDebugMode();
287  }
288  }
289 
290  /*****************************************
291  *
292  * EVALUATION FUNCTIONS
293  * Various centralized processing
294  *
295  *****************************************/
296 
307  public function ‪makeShortcutIcon($gvList, $setList, $modName, $motherModName = '', $classes = '')
308  {
309  $gvList = 'route,' . $gvList;
310  $storeUrl = $this->‪makeShortcutUrl($gvList, $setList);
311  $pathInfo = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
312  if ((int)$motherModName === 1) {
313  $motherModule = 'top.currentModuleLoaded';
314  } elseif ($motherModName) {
315  $motherModule = GeneralUtility::quoteJSvalue((string)$motherModName);
316  } else {
317  $motherModule = '\'\'';
318  }
319  $confirmationText = GeneralUtility::quoteJSvalue($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark'));
320 
321  $shortcutUrl = $pathInfo['path'] . '?' . $storeUrl;
322  $shortcutRepository = GeneralUtility::makeInstance(ShortcutRepository::class);
323  $shortcutExist = $shortcutRepository->shortcutExists($shortcutUrl);
324 
325  if ($shortcutExist) {
326  return '<a class="active ' . htmlspecialchars($classes) . '" title="">' .
327  $this->iconFactory->getIcon('actions-system-shortcut-active', ‪Icon::SIZE_SMALL)->render() . '</a>';
328  }
329  $url = GeneralUtility::quoteJSvalue(rawurlencode($shortcutUrl));
330  $onClick = 'top.TYPO3.ShortcutMenu.createShortcut(' . GeneralUtility::quoteJSvalue(rawurlencode($modName)) .
331  ', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ', this);return false;';
332 
333  return '<a href="#" class="' . htmlspecialchars($classes) . '" onclick="' . htmlspecialchars($onClick) . '" title="' .
334  htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark')) . '">' .
335  $this->iconFactory->getIcon('actions-system-shortcut-new', ‪Icon::SIZE_SMALL)->render() . '</a>';
336  }
337 
348  public function ‪makeShortcutUrl($gvList, $setList)
349  {
350  $GET = GeneralUtility::_GET();
351  $storeArray = array_merge(
352  GeneralUtility::compileSelectedGetVarsFromArray($gvList, $GET),
353  ['SET' => GeneralUtility::compileSelectedGetVarsFromArray($setList, (array)‪$GLOBALS['SOBE']->MOD_SETTINGS)]
354  );
355  return ‪HttpUtility::buildQueryString($storeArray, '&');
356  }
357 
365  public function ‪redirectUrls($thisLocation = '')
366  {
367  $thisLocation = $thisLocation ?: GeneralUtility::linkThisScript([
368  'CB' => '',
369  'SET' => '',
370  'cmd' => '',
371  'popViewId' => ''
372  ]);
373  $out = '
374  // @deprecated
375  var T3_RETURN_URL = ' . GeneralUtility::quoteJSvalue(str_replace('%20', '', rawurlencode(GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))))) . ';
376  // @deprecated
377  var T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(str_replace('%20', '', rawurlencode($thisLocation))) . '
378  ';
379  return $out;
380  }
381 
387  public function ‪useCompatibilityTag(‪$useCompatibilityTag = true)
388  {
390  }
391 
392  /*****************************************
393  *
394  * PAGE BUILDING FUNCTIONS.
395  * Use this to build the HTML of your backend modules
396  *
397  *****************************************/
406  public function ‪startPage($title)
407  {
408  // hook pre start page
409  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'] ?? [] as $hookFunction) {
410  $hookParameters = [
411  'title' => &$title
412  ];
413  GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
414  }
415  // alternative template for Header and Footer
416  if ($this->pageHeaderFooterTemplateFile) {
417  $file = GeneralUtility::getFileAbsFileName($this->pageHeaderFooterTemplateFile);
418  if ($file) {
419  $this->pageRenderer->setTemplateFile($file);
420  }
421  }
422 
423  // Disable rendering of XHTML tags
424  $this->pageRenderer->setRenderXhtml(false);
425 
426  $languageCode = $this->pageRenderer->getLanguage() === 'default' ? 'en' : $this->pageRenderer->getLanguage();
427  $this->pageRenderer->setHtmlTag('<html lang="' . htmlspecialchars($languageCode) . '">');
428 
429  $headerStart = '<!DOCTYPE html>';
430  $this->pageRenderer->setXmlPrologAndDocType($headerStart);
431  $this->pageRenderer->setCharSet('utf-8');
432  $this->pageRenderer->setMetaTag('name', 'generator', $this->‪generator());
433  $this->pageRenderer->setMetaTag('name', 'robots', 'noindex,follow');
434  $this->pageRenderer->setMetaTag('name', 'viewport', 'width=device-width, initial-scale=1');
435  $this->pageRenderer->setFavIcon($this->‪getBackendFavicon());
436  if ($this->‪useCompatibilityTag) {
437  $this->pageRenderer->setMetaTag('http-equiv', 'X-UA-Compatible', $this->xUaCompatibilityVersion);
438  }
439  $this->pageRenderer->setTitle($title);
440  // add docstyles
441  $this->‪docStyle();
442  $this->pageRenderer->addHeaderData($this->JScode);
443  foreach ($this->JScodeArray as $name => $code) {
444  $this->pageRenderer->addJsInlineCode($name, $code, false);
445  }
446 
447  // Note: please do not reference "bootstrap" outside of the TYPO3 Core (not in your own extensions)
448  // as this is preliminary as long as Twitter bootstrap does not support AMD modules
449  // this logic will be changed once Twitter bootstrap 4 is included
450  // @todo
451  $this->pageRenderer->addJsFile('EXT:core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap.js');
452 
453  // csh manual require js module & moduleUrl
454  if (TYPO3_MODE === 'BE' && $this->‪getBackendUser() && !empty($this->‪getBackendUser()->user)) {
455  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
456  $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextHelp');
457  $this->pageRenderer->addInlineSetting(
458  'ContextHelp',
459  'moduleUrl',
460  (string)$uriBuilder->buildUriFromRoute('help_cshmanual', ['action' => 'detail'])
461  );
462  }
463 
464  // hook for additional headerData
465  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'] ?? [] as $hookFunction) {
466  $hookParameters = [
467  'pageRenderer' => &‪$this->pageRenderer
468  ];
469  GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
470  }
471  // Construct page header.
472  $str = $this->pageRenderer->render(‪PageRenderer::PART_HEADER);
473  $this->JScode = '';
474  $this->JScodeArray = [];
475  $this->endOfPageJsBlock = $this->pageRenderer->render(‪PageRenderer::PART_FOOTER);
476  $str .= $this->‪docBodyTagBegin() . ($this->divClass ? '
477 
478 <!-- Wrapping DIV-section for whole page BEGIN -->
479 <div class="' . $this->divClass . '">
480 ' : '') . trim($this->form);
481  return $str;
482  }
483 
490  public function ‪endPage()
491  {
492  $str = $this->postCode . GeneralUtility::wrapJS(‪BackendUtility::getUpdateSignalCode()) . ($this->form ? '
493 </form>' : '');
494  // If something is in buffer like debug, put it to end of page
495  if (ob_get_contents()) {
496  $str .= ob_get_clean();
497  if (!headers_sent()) {
498  header('Content-Encoding: None');
499  }
500  }
501  $str .= ($this->divClass ? '
502 
503 <!-- Wrapping DIV-section for whole page END -->
504 </div>' : '') . $this->endOfPageJsBlock;
505 
506  // Logging: Can't find better place to put it:
507  $this->logger->debug('END of BACKEND session', ['_FLUSH' => true]);
508  return $str;
509  }
510 
518  public function ‪render($title, $content)
519  {
520  $pageContent = $this->‪startPage($title);
521  $pageContent .= $content;
522  $pageContent .= $this->‪endPage();
523  return $this->‪insertStylesAndJS($pageContent);
524  }
525 
532  public function ‪docBodyTagBegin()
533  {
534  return '<body ' . trim($this->bodyTagAdditions . ($this->bodyTagId ? ' id="' . $this->bodyTagId . '"' : '')) . '>';
535  }
536 
540  public function ‪docStyle()
541  {
542  // Implode it all:
543  $inDocStyles = implode(LF, $this->inDocStylesArray);
544 
545  // Reset styles so they won't be added again in insertStylesAndJS()
546  $this->inDocStylesArray = [];
547 
548  if ($this->styleSheetFile) {
549  $this->pageRenderer->addCssFile($this->styleSheetFile);
550  }
551  if ($this->styleSheetFile2) {
552  $this->pageRenderer->addCssFile($this->styleSheetFile2);
553  }
554 
555  if ($inDocStyles !== '') {
556  $this->pageRenderer->addCssInlineBlock('inDocStyles', $inDocStyles . LF . '/*###POSTCSSMARKER###*/');
557  }
558 
559  if ($this->styleSheetFile_post) {
560  $this->pageRenderer->addCssFile($this->styleSheetFile_post);
561  }
562  }
563 
569  public function ‪addStyleSheetDirectory($path)
570  {
571  $path = GeneralUtility::getFileAbsFileName($path);
572  // Read all files in directory and sort them alphabetically
573  foreach (GeneralUtility::getFilesInDir($path, 'css', true) as $cssFile) {
574  $this->pageRenderer->addCssFile($cssFile);
575  }
576  }
577 
587  public function ‪insertStylesAndJS($content)
588  {
589  $styles = LF . implode(LF, $this->inDocStylesArray);
590  $content = str_replace('/*###POSTCSSMARKER###*/', $styles, $content);
591 
592  // Insert accumulated JS
593  $jscode = $this->JScode . LF . GeneralUtility::wrapJS(implode(LF, $this->JScodeArray));
594  $content = str_replace('<!--###POSTJSMARKER###-->', $jscode, $content);
595  return $content;
596  }
597 
603  public function ‪getSkinStylesheetDirectories()
604  {
605  $stylesheetDirectories = [];
606  // Stylesheets from skins
607  // merge default css directories ($this->stylesheetsSkin) with additional ones and include them
608  if (is_array(‪$GLOBALS['TBE_STYLES']['skins'])) {
609  // loop over all registered skins
610  foreach (‪$GLOBALS['TBE_STYLES']['skins'] as $skinExtKey => $skin) {
611  $skinStylesheetDirs = ‪$this->stylesheetsSkins;
612  // Skins can add custom stylesheetDirectories using
613  // $GLOBALS['TBE_STYLES']['skins']['your_extension_key']['stylesheetDirectories']
614  if (is_array($skin['stylesheetDirectories'])) {
615  $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
616  }
617  // Add all registered directories
618  foreach ($skinStylesheetDirs as $stylesheetDir) {
619  // for EXT:myskin/stylesheets/ syntax
620  if (strpos($stylesheetDir, 'EXT:') === 0) {
621  [$extKey, $path] = explode('/', substr($stylesheetDir, 4), 2);
622  if (!empty($extKey) && ‪ExtensionManagementUtility::isLoaded($extKey) && !empty($path)) {
623  $stylesheetDirectories[] = ‪ExtensionManagementUtility::extPath($extKey) . $path;
624  }
625  } else {
626  // For relative paths
627  $stylesheetDirectories[] = ‪ExtensionManagementUtility::extPath($skinExtKey) . $stylesheetDir;
628  }
629  }
630  }
631  }
632  return $stylesheetDirectories;
633  }
634 
640  public function ‪generator()
641  {
642  return GeneralUtility::makeInstance(Typo3Information::class)->getHtmlGeneratorTagContent();
643  }
644 
645  /*****************************************
646  *
647  * OTHER ELEMENTS
648  * Tables, buttons, formatting dimmed/red strings
649  *
650  ******************************************/
658  public function ‪getHtmlTemplate($filename)
659  {
660  // setting the name of the original HTML template
661  $this->moduleTemplateFilename = $filename;
662  if (‪$GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
663  $filename = ‪$GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
664  }
665  $filename = GeneralUtility::getFileAbsFileName($filename);
666  return $filename !== '' ? file_get_contents($filename) : '';
667  }
668 
674  public function ‪setModuleTemplate($filename)
675  {
676  $this->moduleTemplate = $this->‪getHtmlTemplate($filename);
677  }
678 
689  public function ‪moduleBody($pageRecord = [], $buttons = [], $markerArray = [], $subpartArray = [])
690  {
691  // Get the HTML template for the module
692  $moduleBody = $this->templateService->getSubpart($this->moduleTemplate, '###FULLDOC###');
693  // Add CSS
694  $this->inDocStylesArray[] = 'html { overflow: hidden; }';
695  // Get the page path for the docheader
696  $markerArray['PAGEPATH'] = $this->‪getPagePath($pageRecord);
697  // Get the page info for the docheader
698  $markerArray['PAGEINFO'] = $this->‪getPageInfo($pageRecord);
699  // Get all the buttons for the docheader
700  $docHeaderButtons = $this->‪getDocHeaderButtons($buttons);
701  // Merge docheader buttons with the marker array
702  $markerArray = array_merge($markerArray, $docHeaderButtons);
703  // replacing subparts
704  foreach ($subpartArray as $marker => $content) {
705  $moduleBody = $this->templateService->substituteSubpart($moduleBody, $marker, $content);
706  }
707  // adding flash messages
708  if ($this->showFlashMessages) {
709  $flashMessages = $this->‪getFlashMessages();
710  if (!empty($flashMessages)) {
711  $markerArray['FLASHMESSAGES'] = $flashMessages;
712  // If there is no dedicated marker for the messages present
713  // then force them to appear before the content
714  if (strpos($moduleBody, '###FLASHMESSAGES###') === false) {
715  $moduleBody = str_replace('###CONTENT###', '###FLASHMESSAGES######CONTENT###', $moduleBody);
716  }
717  }
718  }
719  // Hook for adding more markers/content to the page, like the version selector
720  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'] ?? [] as $funcRef) {
721  $params = [
722  'moduleTemplateFilename' => &‪$this->moduleTemplateFilename,
723  'moduleTemplate' => &‪$this->moduleTemplate,
724  'moduleBody' => &$moduleBody,
725  'markers' => &$markerArray,
726  'parentObject' => &$this
727  ];
728  GeneralUtility::callUserFunction($funcRef, $params, $this);
729  }
730  // Replacing all markers with the finished markers and return the HTML content
731  return $this->templateService->substituteMarkerArray($moduleBody, $markerArray, '###|###');
732  }
733 
739  public function ‪getFlashMessages()
740  {
742  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
744  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
745  return $defaultFlashMessageQueue->renderFlashMessages();
746  }
747 
754  protected function ‪getDocHeaderButtons($buttons)
755  {
756  $markers = [];
757  // Fill buttons for left and right float
758  $floats = ['left', 'right'];
759  foreach ($floats as $key) {
760  // Get the template for each float
761  $buttonTemplate = $this->templateService->getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
762  // Fill the button markers in this float
763  $buttonTemplate = $this->templateService->substituteMarkerArray($buttonTemplate, $buttons, '###|###', true);
764  // getting the wrap for each group
765  $buttonWrap = $this->templateService->getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
766  // looping through the groups (max 6) and remove the empty groups
767  for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
768  $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
769  $buttonGroup = $this->templateService->getSubpart($buttonTemplate, $buttonMarker);
770  if (trim($buttonGroup)) {
771  if ($buttonWrap) {
772  $buttonGroup = $this->templateService->substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
773  }
774  $buttonTemplate = $this->templateService->substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
775  }
776  }
777  // Replace the marker with the template and remove all line breaks (for IE compat)
778  $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF, '', $buttonTemplate);
779  }
780  // Hook for manipulating docHeaderButtons
781  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] ?? [] as $funcRef) {
782  $params = [
783  'buttons' => $buttons,
784  'markers' => &$markers,
785  'pObj' => &$this
786  ];
787  GeneralUtility::callUserFunction($funcRef, $params, $this);
788  }
789  return $markers;
790  }
791 
798  protected function ‪getPagePath($pageRecord)
799  {
800  // Is this a real page
801  if (is_array($pageRecord) && $pageRecord['uid']) {
802  $title = substr($pageRecord['_thePathFull'], 0, -1);
803  // Remove current page title
804  $pos = strrpos($title, $pageRecord['title']);
805  if ($pos !== false) {
806  $title = substr($title, 0, $pos);
807  }
808  } else {
809  $title = '';
810  }
811  // Setting the path of the page
812  $pagePath = htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
813  // crop the title to title limit (or 50, if not defined)
814  $cropLength = empty(‪$GLOBALS['BE_USER']->uc['titleLen']) ? 50 : (int)‪$GLOBALS['BE_USER']->uc['titleLen'];
815  $croppedTitle = GeneralUtility::fixed_lgd_cs($title, -$cropLength);
816  if ($croppedTitle !== $title) {
817  $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
818  } else {
819  $pagePath .= htmlspecialchars($title);
820  }
821  $pagePath .= '</span>';
822  return $pagePath;
823  }
824 
831  protected function ‪getPageInfo($pageRecord)
832  {
833  // Add icon with context menu, etc:
834  // If there IS a real page
835  if (is_array($pageRecord) && $pageRecord['uid']) {
836  $alttext = ‪BackendUtility::getRecordIconAltText($pageRecord, 'pages');
837  $iconImg = '<span title="' . htmlspecialchars($alttext) . '">' . $this->iconFactory->getIconForRecord('pages', $pageRecord, ‪Icon::SIZE_SMALL)->render() . '</span>';
838  // Make Icon:
839  $theIcon = ‪BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
840  $uid = $pageRecord['uid'];
841  $title = ‪BackendUtility::getRecordTitle('pages', $pageRecord);
842  } else {
843  // On root-level of page tree
844  // Make Icon
845  $iconImg = '<span title="' . htmlspecialchars(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '">' . $this->iconFactory->getIcon('apps-pagetree-root', ‪Icon::SIZE_SMALL)->render() . '</span>';
846  if (‪$GLOBALS['BE_USER']->isAdmin()) {
847  $theIcon = ‪BackendUtility::wrapClickMenuOnIcon($iconImg, 'pages');
848  } else {
849  $theIcon = $iconImg;
850  }
851  $uid = '0';
852  $title = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
853  }
854  // Setting icon with context menu + uid
855  $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . '&nbsp;[' . $uid . ']</strong>';
856  return $pageInfo;
857  }
858 
864  protected function ‪getBackendFavicon()
865  {
866  $backendFavicon = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('backend', 'backendFavicon');
867  if (!empty($backendFavicon)) {
868  $path = $this->‪getUriForFileName($backendFavicon);
869  } else {
870  $path = ‪ExtensionManagementUtility::extPath('backend') . 'Resources/Public/Icons/favicon.ico';
871  }
873  }
874 
883  protected function ‪getUriForFileName($filename)
884  {
885  if (strpos($filename, '://')) {
886  return $filename;
887  }
888  $urlPrefix = '';
889  if (strpos($filename, 'EXT:') === 0) {
890  $absoluteFilename = GeneralUtility::getFileAbsFileName($filename);
891  $filename = '';
892  if ($absoluteFilename !== '') {
893  $filename = ‪PathUtility::getAbsoluteWebPath($absoluteFilename);
894  }
895  } elseif (strpos($filename, '/') !== 0) {
896  $urlPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
897  }
898  return $urlPrefix . $filename;
899  }
900 
904  protected function ‪getBackendUser()
905  {
906  return ‪$GLOBALS['BE_USER'] ?? null;
907  }
908 
912  protected function ‪getLanguageService(): ?LanguageService
913  {
914  return ‪$GLOBALS['LANG'] ?? null;
915  }
916 }
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$pageRenderer
‪PageRenderer $pageRenderer
Definition: DocumentTemplate.php:182
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$moduleTemplate
‪string $moduleTemplate
Definition: DocumentTemplate.php:93
‪TYPO3\CMS\Backend\Backend\Shortcut\ShortcutRepository
Definition: ShortcutRepository.php:44
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$scriptID
‪string $scriptID
Definition: DocumentTemplate.php:105
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getUriForFileName
‪string getUriForFileName($filename)
Definition: DocumentTemplate.php:859
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Core\Information\Typo3Information
Definition: Typo3Information.php:26
‪TYPO3\CMS\Backend\Template\DocumentTemplate\insertStylesAndJS
‪string insertStylesAndJS($content)
Definition: DocumentTemplate.php:563
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getHtmlTemplate
‪string getHtmlTemplate($filename)
Definition: DocumentTemplate.php:634
‪TYPO3\CMS\Backend\Template\DocumentTemplate\makeShortcutUrl
‪string makeShortcutUrl($gvList, $setList)
Definition: DocumentTemplate.php:324
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$pageHeaderFooterTemplateFile
‪string $pageHeaderFooterTemplateFile
Definition: DocumentTemplate.php:188
‪TYPO3\CMS\Backend\Template\DocumentTemplate\makeShortcutIcon
‪string makeShortcutIcon($gvList, $setList, $modName, $motherModName='', $classes='')
Definition: DocumentTemplate.php:283
‪TYPO3\CMS\Core\Configuration\ExtensionConfiguration
Definition: ExtensionConfiguration.php:45
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getBackendUser
‪BackendUserAuthentication null getBackendUser()
Definition: DocumentTemplate.php:880
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$xUaCompatibilityVersion
‪string $xUaCompatibilityVersion
Definition: DocumentTemplate.php:154
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$JScode
‪string $JScode
Definition: DocumentTemplate.php:69
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$showFlashMessages
‪bool $showFlashMessages
Definition: DocumentTemplate.php:194
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordIconAltText
‪static string getRecordIconAltText($row, $table='pages')
Definition: BackendUtility.php:1357
‪TYPO3\CMS\Backend\Template\DocumentTemplate\moduleBody
‪string moduleBody($pageRecord=[], $buttons=[], $markerArray=[], $subpartArray=[])
Definition: DocumentTemplate.php:665
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Core\Utility\ArrayUtility\mergeRecursiveWithOverrule
‪static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
Definition: ArrayUtility.php:654
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$styleSheetFile
‪string $styleSheetFile
Definition: DocumentTemplate.php:130
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$styleSheetFile2
‪string $styleSheetFile2
Definition: DocumentTemplate.php:136
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$bodyTagAdditions
‪string $bodyTagAdditions
Definition: DocumentTemplate.php:117
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$inDocStylesArray
‪array $inDocStylesArray
Definition: DocumentTemplate.php:124
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getBackendFavicon
‪string getBackendFavicon()
Definition: DocumentTemplate.php:840
‪TYPO3\CMS\Backend\Template\DocumentTemplate\startPage
‪string startPage($title)
Definition: DocumentTemplate.php:382
‪TYPO3\CMS\Backend\Template\DocumentTemplate\__construct
‪__construct()
Definition: DocumentTemplate.php:207
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$postCode
‪string $postCode
Definition: DocumentTemplate.php:87
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$moduleTemplateFilename
‪string $moduleTemplateFilename
Definition: DocumentTemplate.php:99
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪TYPO3\CMS\Backend\Utility\BackendUtility\wrapClickMenuOnIcon
‪static string wrapClickMenuOnIcon( $content, $table, $uid=0, $context='', $_addParams='', $_enDisItems='', $returnTagParameters=false)
Definition: BackendUtility.php:2510
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:42
‪TYPO3\CMS\Backend\Template\DocumentTemplate
Definition: DocumentTemplate.php:54
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$styleSheetFile_post
‪string $styleSheetFile_post
Definition: DocumentTemplate.php:142
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Core\Page\PageRenderer\PART_FOOTER
‪const PART_FOOTER
Definition: PageRenderer.php:46
‪TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString
‪static string buildQueryString(array $parameters, string $prependCharacter='', bool $skipEmptyParameters=false)
Definition: HttpUtility.php:163
‪TYPO3\CMS\Backend\Template
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle
‪static string getRecordTitle($table, $row, $prep=false, $forceResult=true)
Definition: BackendUtility.php:1541
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getPagePath
‪string getPagePath($pageRecord)
Definition: DocumentTemplate.php:774
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getSkinStylesheetDirectories
‪array getSkinStylesheetDirectories()
Definition: DocumentTemplate.php:579
‪TYPO3\CMS\Backend\Template\DocumentTemplate\docBodyTagBegin
‪string docBodyTagBegin()
Definition: DocumentTemplate.php:508
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$templateService
‪MarkerBasedTemplateService $templateService
Definition: DocumentTemplate.php:202
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$iconFactory
‪IconFactory $iconFactory
Definition: DocumentTemplate.php:198
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$endOfPageJsBlock
‪string $endOfPageJsBlock
Definition: DocumentTemplate.php:178
‪TYPO3\CMS\Backend\Template\DocumentTemplate\docStyle
‪docStyle()
Definition: DocumentTemplate.php:516
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getPageInfo
‪string getPageInfo($pageRecord)
Definition: DocumentTemplate.php:807
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$JScodeArray
‪array $JScodeArray
Definition: DocumentTemplate.php:75
‪TYPO3\CMS\Backend\Template\DocumentTemplate\render
‪string render($title, $content)
Definition: DocumentTemplate.php:494
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$stylesheetsSkins
‪array $stylesheetsSkins
Definition: DocumentTemplate.php:161
‪TYPO3\CMS\Backend\Template\DocumentTemplate\redirectUrls
‪string redirectUrls($thisLocation='')
Definition: DocumentTemplate.php:341
‪TYPO3\CMS\Backend\Template\DocumentTemplate\generator
‪string generator()
Definition: DocumentTemplate.php:616
‪TYPO3\CMS\Backend\Template\DocumentTemplate\addStyleSheetDirectory
‪addStyleSheetDirectory($path)
Definition: DocumentTemplate.php:545
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$useCompatibilityTag
‪bool $useCompatibilityTag
Definition: DocumentTemplate.php:148
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getLanguageService
‪LanguageService null getLanguageService()
Definition: DocumentTemplate.php:888
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\extPath
‪static string extPath($key, $script='')
Definition: ExtensionManagementUtility.php:127
‪TYPO3\CMS\Backend\Template\DocumentTemplate\initPageRenderer
‪initPageRenderer()
Definition: DocumentTemplate.php:251
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$pageHeaderBlock
‪string $pageHeaderBlock
Definition: DocumentTemplate.php:174
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:24
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$divClass
‪string $divClass
Definition: DocumentTemplate.php:170
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Template\DocumentTemplate\setModuleTemplate
‪setModuleTemplate($filename)
Definition: DocumentTemplate.php:650
‪TYPO3\CMS\Backend\Template\DocumentTemplate\endPage
‪string endPage()
Definition: DocumentTemplate.php:466
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getFlashMessages
‪string getFlashMessages()
Definition: DocumentTemplate.php:715
‪TYPO3\CMS\Core\Service\MarkerBasedTemplateService
Definition: MarkerBasedTemplateService.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$form
‪string $form
Definition: DocumentTemplate.php:63
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:43
‪TYPO3\CMS\Backend\Utility\BackendUtility\getUpdateSignalCode
‪static string getUpdateSignalCode()
Definition: BackendUtility.php:2824
‪TYPO3\CMS\Core\Page\PageRenderer\PART_HEADER
‪const PART_HEADER
Definition: PageRenderer.php:45
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded
‪static bool isLoaded($key)
Definition: ExtensionManagementUtility.php:114
‪TYPO3\CMS\Backend\Template\DocumentTemplate\useCompatibilityTag
‪useCompatibilityTag($useCompatibilityTag=true)
Definition: DocumentTemplate.php:363
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27
‪TYPO3\CMS\Backend\Template\DocumentTemplate\getDocHeaderButtons
‪array getDocHeaderButtons($buttons)
Definition: DocumentTemplate.php:730
‪TYPO3\CMS\Backend\Template\DocumentTemplate\$bodyTagId
‪string $bodyTagId
Definition: DocumentTemplate.php:111