/** * Main function generating the BE scaffolding * * @return void */ public function render() { $this->executeHook('renderPreProcess'); // Prepare the scaffolding, at this point extension may still add javascript and css $logo = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Views\\LogoView'); $logo->setLogo('gfx/typo3logo_mini.png'); // Create backend scaffolding $backendScaffolding = ' <div id="typo3-top-container" class="x-hide-display"> <div id="typo3-logo">' . $logo->render() . '</div> <div id="typo3-top" class="typo3-top-toolbar">' . $this->renderToolbar() . '</div> </div>'; /****************************************************** * Now put the complete backend document together ******************************************************/ foreach ($this->cssFiles as $cssFileName => $cssFile) { $this->pageRenderer->addCssFile($cssFile); // Load addditional css files to overwrite existing core styles if (!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) { $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]); } } if (!empty($this->css)) { $this->pageRenderer->addCssInlineBlock('BackendInlineCSS', $this->css); } foreach ($this->jsFiles as $jsFile) { $this->pageRenderer->addJsFile($jsFile); } $this->generateJavascript(); $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js, FALSE); $this->loadResourcesForRegisteredNavigationComponents(); // Add state provider $GLOBALS['TBE_TEMPLATE']->setExtDirectStateProvider(); $states = $GLOBALS['BE_USER']->uc['BackendComponents']['States']; // Save states in BE_USER->uc $extOnReadyCode = ' Ext.state.Manager.setProvider(new TYPO3.state.ExtDirectProvider({ key: "BackendComponents.States", autoRead: false })); '; if ($states) { $extOnReadyCode .= 'Ext.state.Manager.getProvider().initState(' . json_encode($states) . ');'; } $extOnReadyCode .= ' TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration); if (typeof console === "undefined") { console = TYPO3.Backend.DebugConsole; } TYPO3.ContextHelpWindow.init();'; $this->pageRenderer->addExtOnReadyCode($extOnReadyCode); // Set document title: $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [TYPO3 ' . TYPO3_version . ']' : 'TYPO3 ' . TYPO3_version; $this->content = $backendScaffolding; // Renders the module page $this->content = $GLOBALS['TBE_TEMPLATE']->render($title, $this->content); $hookConfiguration = array('content' => &$this->content); $this->executeHook('renderPostProcess', $hookConfiguration); echo $this->content; }
/** * test add JS handler */ public function testAddExtOnReadyCode() { $expectedReturnValue1 = 'Ext.onReady(function() {'; $expectedReturnValue2 = 'var x = "testvar";'; $this->fixture->loadExtJS(); $this->fixture->addExtOnReadyCode('var x = "testvar";'); $out = $this->fixture->render(); $this->assertContains($expectedReturnValue1, $out); $this->assertContains($expectedReturnValue2, $out); }
/** * method that adds JS files within the page renderer * * @param array $parameters : An array of available parameters while adding JS to the page renderer * @param \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer : The parent object that triggered this hook * * @return void */ protected function addJS($parameters, &$pageRenderer) { $formprotection = FormProtectionFactory::get(); if (count($parameters['jsFiles'])) { if (method_exists($GLOBALS['SOBE']->doc, 'issueCommand')) { /** @var \TYPO3\CMS\Backend\Clipboard\Clipboard $clipObj */ $clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard'); // Start clipboard $clipObj->initializeClipboard(); $clipBoardHasContent = FALSE; if (isset($clipObj->clipData['normal']['el']) && strpos(key($clipObj->clipData['normal']['el']), 'tt_content') !== FALSE) { $pasteURL = str_replace('&', '&', $clipObj->pasteUrl('tt_content', 'DD_PASTE_UID', 0)); if (isset($clipObj->clipData['normal']['mode'])) { $clipBoardHasContent = 'copy'; } else { $clipBoardHasContent = 'move'; } } $moveParams = '&cmd[tt_content][DD_DRAG_UID][move]=DD_DROP_UID'; $moveURL = str_replace('&', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($moveParams, 1))); $copyParams = '&cmd[tt_content][DD_DRAG_UID][copy]=DD_DROP_UID&DDcopy=1'; $copyURL = str_replace('&', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($copyParams, 1))); // add JavaScript library $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/dbNewContentElWizardFixDTM.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = ''); // add JavaScript library $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsDD.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = ''); // add JavaScript library $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsListView.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = ''); if (!$pageRenderer->getCharSet()) { $pageRenderer->setCharSet($GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : 'utf-8'); } if (is_array($clipObj->clipData['normal']['el'])) { $arrCBKeys = array_keys($clipObj->clipData['normal']['el']); $intFirstCBEl = str_replace('tt_content|', '', $arrCBKeys[0]); } // pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys $pageRenderer->addInlineLanguageLabelFile('EXT:gridelements/Resources/Private/Language/locallang_db.xml', 'tx_gridelements_js'); $pRaddExtOnReadyCode = ' TYPO3.l10n = { localize: function(langKey){ return TYPO3.lang[langKey]; } } '; $allowedCTypesAndGridTypesClassesByColPos = array(); $layoutSetup = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', intval(GeneralUtility::_GP('id')), $this); if (is_array($layoutSetup) && !empty($layoutSetup['__config']['backend_layout.']['rows.'])) { foreach ($layoutSetup['__config']['backend_layout.']['rows.'] as $rows) { foreach ($rows as $row) { if (!empty($layoutSetup['__config']['backend_layout.']['rows.'])) { foreach ($row as $col) { $classes = ''; if ($col['allowed']) { $allowed = explode(',', $col['allowed']); foreach ($allowed as $ctypes) { $ctypes = trim($ctypes); if ($ctypes === '*') { $classes = 't3-allow-all'; break; } else { $ctypes = explode(',', $ctypes); foreach ($ctypes as $ctype) { $classes .= 't3-allow-' . $ctype . ' '; } } } } else { $classes = 't3-allow-all'; } if ($col['allowedGridTypes']) { $allowedGridTypes = explode(',', $col['allowedGridTypes']); $classes .= 't3-allow-gridelements_pi1 '; foreach ($allowedGridTypes as $gridTypes) { $gridTypes = trim($gridTypes); if ($gridTypes !== '*') { $gridTypes = explode(',', $gridTypes); foreach ($gridTypes as $gridType) { $classes .= 't3-allow-gridtype-' . $gridType . ' '; } } } } else { if ($classes !== 't3-allow-all') { $classes .= 't3-allow-gridelements_pi1 '; } } $allowedCTypesAndGridTypesClassesByColPos[] = $col['colPos'] . ':' . trim($classes); } } } } } // add Ext.onReady() code from file $modTSconfig = BackendUtility::getModTSconfig((int) GeneralUtility::_GP('id'), 'mod.web_layout'); $pageRenderer->addExtOnReadyCode($pRaddExtOnReadyCode . "\n\t\t\t\t\t\ttop.pageColumnsAllowedCTypes = '" . join('|', $allowedCTypesAndGridTypesClassesByColPos) . "';\n\t\t\t\t\t\ttop.pasteURL = '" . $pasteURL . "';\n\t\t\t\t\t\ttop.moveURL = '" . $moveURL . "';\n\t\t\t\t\t\ttop.copyURL = '" . $copyURL . "';\n\t\t\t\t\t\ttop.pasteTpl = '" . str_replace('&redirect=1', '', str_replace('DDcopy=1', 'DDcopy=1&reference=DD_REFYN', $copyURL)) . "';\n\t\t\t\t\t\ttop.DDtceActionToken = '" . $formprotection->generateToken('tceAction') . "';\n\t\t\t\t\t\ttop.DDtoken = '" . $formprotection->generateToken('editRecord') . "';\n\t\t\t\t\t\ttop.DDpid = '" . (int) GeneralUtility::_GP('id') . "';\n\t\t\t\t\t\ttop.DDclipboardfilled = '" . ($clipBoardHasContent ? $clipBoardHasContent : 'false') . "';\n\t\t\t\t\t\ttop.pasteReferenceAllowed = '" . ($GLOBALS['BE_USER']->checkAuthMode('tt_content', 'CType', 11, 'explicitAllow') ? 'true' : 'false') . "';\n\t\t\t\t\t\ttop.newElementWizard = '" . ($modTSconfig['properties']['disableNewContentElementWizard'] ? 'false' : 'true') . "';\n\t\t\t\t\t\ttop.DDclipboardElId = '" . $intFirstCBEl . "';\n\t\t\t\t\t" . str_replace(array('top.skipDraggableDetails = 0;', 'insert_ext_baseurl_here', 'insert_server_time_here', 'top.geSprites = {};', "top.backPath = '';"), array($GLOBALS['BE_USER']->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'top.skipDraggableDetails = true;' : 'top.skipDraggableDetails = false;', GeneralUtility::locationHeaderUrl('/' . ExtensionManagementUtility::siteRelPath('gridelements')), time() . '000', "top.geSprites = {\n\t\t\t\t\t\t\tcopyfrompage: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-copyfrompage') . "',\n\t\t\t\t\t\t\t\tpastecopy: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-pastecopy') . "',\n\t\t\t\t\t\t\t\tpasteref: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-pasteref') . "'\n\t\t\t\t\t\t\t};", "top.backPath = '" . $GLOBALS['BACK_PATH'] . "';"), file_get_contents(ExtensionManagementUtility::extPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsDD_onReady.js')), TRUE); } } }
/** * Main function generating the BE scaffolding * * @return void */ public function render() { $this->executeHook('renderPreProcess'); // Prepare the scaffolding, at this point extension may still add javascript and css $view = $this->getFluidTemplateObject($this->templatePath . 'Backend/Main.html'); // Render the TYPO3 logo in the left corner $logoUrl = $GLOBALS['TBE_STYLES']['logo'] ?: 'sysext/backend/Resources/Public/Images/typo3-topbar@2x.png'; $logoPath = GeneralUtility::resolveBackPath(PATH_typo3 . $logoUrl); list($logoWidth, $logoHeight) = @getimagesize($logoPath); // High-resolution? if (strpos($logoUrl, '@2x.') !== false) { $logoWidth = $logoWidth / 2; $logoHeight = $logoHeight / 2; } $view->assign('logoUrl', $logoUrl); $view->assign('logoWidth', $logoWidth); $view->assign('logoHeight', $logoHeight); $view->assign('logoLink', TYPO3_URL_GENERAL); $view->assign('applicationVersion', TYPO3_version); $view->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); $view->assign('moduleMenu', $this->generateModuleMenu()); $view->assign('toolbar', $this->renderToolbar()); /****************************************************** * Now put the complete backend document together ******************************************************/ foreach ($this->cssFiles as $cssFileName => $cssFile) { $this->pageRenderer->addCssFile($cssFile); // Load additional css files to overwrite existing core styles if (!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) { $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]); } } if (!empty($this->css)) { $this->pageRenderer->addCssInlineBlock('BackendInlineCSS', $this->css); } foreach ($this->jsFiles as $jsFile) { $this->pageRenderer->addJsFile($jsFile); } $this->generateJavascript(); $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js, false); $this->loadResourcesForRegisteredNavigationComponents(); // Add state provider $this->getDocumentTemplate()->setExtDirectStateProvider(); $states = $this->getBackendUser()->uc['BackendComponents']['States']; // Save states in BE_USER->uc $extOnReadyCode = ' Ext.state.Manager.setProvider(new TYPO3.state.ExtDirectProvider({ key: "BackendComponents.States", autoRead: false })); '; if ($states) { $extOnReadyCode .= 'Ext.state.Manager.getProvider().initState(' . json_encode($states) . ');'; } $extOnReadyCode .= ' TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration); if (typeof console === "undefined") { console = TYPO3.Backend.DebugConsole; }'; $this->pageRenderer->addExtOnReadyCode($extOnReadyCode); // Set document title: $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [TYPO3 CMS ' . TYPO3_version . ']' : 'TYPO3 CMS ' . TYPO3_version; // Renders the module page $this->content = $this->getDocumentTemplate()->render($title, $view->render()); $hookConfiguration = array('content' => &$this->content); $this->executeHook('renderPostProcess', $hookConfiguration); }
/** * Makes a collapseable section. See reports module for an example * * @param string $title * @param string $html * @param string $id * @param string $saveStatePointer * @return string * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8. Use HTML bootstrap classes, localStorage etc. */ public function collapseableSection($title, $html, $id, $saveStatePointer = '') { GeneralUtility::logDeprecatedFunction(); $hasSave = (bool) $saveStatePointer; $collapsedStyle = $collapsedClass = ''; if ($hasSave) { /** @var $userSettingsController \TYPO3\CMS\Backend\Controller\UserSettingsController */ $userSettingsController = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\UserSettingsController::class); $value = $userSettingsController->process('get', $saveStatePointer . '.' . $id); if ($value) { $collapsedStyle = ' style="display: none"'; $collapsedClass = ' collapsed'; } else { $collapsedStyle = ''; $collapsedClass = ' expanded'; } } $this->pageRenderer->loadExtJS(); $this->pageRenderer->addExtOnReadyCode(' Ext.select("h2.section-header").each(function(element){ element.on("click", function(event, tag) { var state = 0, el = Ext.fly(tag), div = el.next("div"), saveKey = el.getAttribute("rel"); if (el.hasClass("collapsed")) { el.removeClass("collapsed").addClass("expanded"); div.slideIn("t", { easing: "easeIn", duration: .5 }); } else { el.removeClass("expanded").addClass("collapsed"); div.slideOut("t", { easing: "easeOut", duration: .5, remove: false, useDisplay: true }); state = 1; } if (saveKey) { try { top.TYPO3.Storage.Persistent.set(saveKey + "." + tag.id, state); } catch(e) {} } }); }); '); return ' <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2> <div' . $collapsedStyle . '>' . $html . '</div> '; }
/** * Returns page start * This includes the proper header with charset, title, meta tag and beginning body-tag. * * @param string $title HTML Page title for the header * @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType) * @see endPage() */ public function startPage($title) { // hook pre start page if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) { $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook']; if (is_array($preStartPageHook)) { $hookParameters = array('title' => &$title); foreach ($preStartPageHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } // alternative template for Header and Footer if ($this->pageHeaderFooterTemplateFile) { $file = GeneralUtility::getFileAbsFileName($this->pageHeaderFooterTemplateFile, true); if ($file) { $this->pageRenderer->setTemplateFile($file); } } // Disable rendering of XHTML tags $this->pageRenderer->setRenderXhtml(false); $languageCode = $this->pageRenderer->getLanguage() === 'default' ? 'en' : $this->pageRenderer->getLanguage(); $this->pageRenderer->setHtmlTag('<html lang="' . $languageCode . '">'); $headerStart = '<!DOCTYPE html>'; $this->pageRenderer->setXmlPrologAndDocType($headerStart); $this->pageRenderer->setHeadTag('<head>' . LF . '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID) . ' -->'); header('Content-Type:text/html;charset=utf-8'); $this->pageRenderer->setCharSet('utf-8'); $this->pageRenderer->addMetaTag($this->generator()); $this->pageRenderer->addMetaTag('<meta name="robots" content="noindex,follow">'); $this->pageRenderer->addMetaTag('<meta charset="utf-8">'); $this->pageRenderer->addMetaTag('<meta name="viewport" content="width=device-width, initial-scale=1">'); $this->pageRenderer->setFavIcon($this->getBackendFavicon()); if ($this->useCompatibilityTag) { $this->pageRenderer->addMetaTag($this->xUaCompatible($this->xUaCompatibilityVersion)); } $this->pageRenderer->setTitle($title); // add docstyles $this->docStyle(); if ($this->extDirectStateProvider) { $this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/JavaScript/ExtDirect.StateProvider.js'); } $this->pageRenderer->addHeaderData($this->JScode); foreach ($this->JScodeArray as $name => $code) { $this->pageRenderer->addJsInlineCode($name, $code, false); } if ($this->extJScode) { $this->pageRenderer->addExtOnReadyCode($this->extJScode); } // Load jquery and twbs JS libraries on every backend request $this->pageRenderer->loadJquery(); // Note: please do not reference "bootstrap" outside of the TYPO3 Core (not in your own extensions) // as this is preliminary as long as Twitter bootstrap does not support AMD modules // this logic will be changed once Twitter bootstrap 4 is included $this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('core') . 'Resources/Public/JavaScript/Contrib/bootstrap/bootstrap.js'); // hook for additional headerData if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) { $preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook']; if (is_array($preHeaderRenderHook)) { $hookParameters = array('pageRenderer' => &$this->pageRenderer); foreach ($preHeaderRenderHook as $hookFunction) { GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } // Construct page header. $str = $this->pageRenderer->render(PageRenderer::PART_HEADER); $this->JScode = $this->extJScode = ''; $this->JScodeArray = array(); $this->endOfPageJsBlock = $this->pageRenderer->render(PageRenderer::PART_FOOTER); $str .= $this->docBodyTagBegin() . ($this->divClass ? ' <!-- Wrapping DIV-section for whole page BEGIN --> <div class="' . $this->divClass . '"> ' : '') . trim($this->form); return $str; }
/** * Makes a collapseable section. See reports module for an example * * @param string $title * @param string $html * @param string $id * @param string $saveStatePointer * @return string */ public function collapseableSection($title, $html, $id, $saveStatePointer = '') { $hasSave = $saveStatePointer ? TRUE : FALSE; $collapsedStyle = $collapsedClass = ''; if ($hasSave) { /** @var $settings \TYPO3\CMS\Backend\User\ExtDirect\BackendUserSettingsDataProvider */ $settings = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider'); $value = $settings->get($saveStatePointer . '.' . $id); if ($value) { $collapsedStyle = ' style="display: none"'; $collapsedClass = ' collapsed'; } else { $collapsedStyle = ''; $collapsedClass = ' expanded'; } } $this->pageRenderer->loadExtJS(); $this->pageRenderer->addExtOnReadyCode(' Ext.select("h2.section-header").each(function(element){ element.on("click", function(event, tag) { var state = 0, el = Ext.fly(tag), div = el.next("div"), saveKey = el.getAttribute("rel"); if (el.hasClass("collapsed")) { el.removeClass("collapsed").addClass("expanded"); div.slideIn("t", { easing: "easeIn", duration: .5 }); } else { el.removeClass("expanded").addClass("collapsed"); div.slideOut("t", { easing: "easeOut", duration: .5, remove: false, useDisplay: true }); state = 1; } if (saveKey) { try { top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {}); } catch(e) {} } }); }); '); return ' <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2> <div' . $collapsedStyle . '>' . $html . '</div> '; }
/** * Main function generating the BE scaffolding * * @return void */ public function render() { // Needed for the hooks below, as they previously were located in the global scope // Caution: do not use the global variable anymore but only reference "$this", or use the "renderPreProcess" $GLOBALS['TYPO3backend'] = $TYPO3backend = $this; // Include extensions which may add css, javascript or toolbar items if (is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) { include_once $additionalBackendItem; } } // Process ExtJS module js and css if (is_array($GLOBALS['TBE_MODULES']['_configuration'])) { foreach ($GLOBALS['TBE_MODULES']['_configuration'] as $moduleConfig) { if (is_array($moduleConfig['cssFiles'])) { foreach ($moduleConfig['cssFiles'] as $cssFileName => $cssFile) { $files = array(GeneralUtility::getFileAbsFileName($cssFile)); $files = GeneralUtility::removePrefixPathFromList($files, PATH_site); $this->addCssFile($cssFileName, '../' . $files[0]); } } if (is_array($moduleConfig['jsFiles'])) { foreach ($moduleConfig['jsFiles'] as $jsFile) { $files = array(GeneralUtility::getFileAbsFileName($jsFile)); $files = GeneralUtility::removePrefixPathFromList($files, PATH_site); $this->addJavascriptFile('../' . $files[0]); } } } } $this->executeHook('renderPreProcess'); // Prepare the scaffolding, at this point extension may still add javascript and css $view = $this->getFluidTemplateObject($this->templatePath . 'Backend/Main.html'); // Render the TYPO3 logo in the left corner $logoUrl = $GLOBALS['TBE_STYLES']['logo'] ?: 'sysext/backend/Resources/Public/Images/typo3-topbar@2x.png'; $logoPath = GeneralUtility::resolveBackPath(PATH_typo3 . $logoUrl); list($logoWidth, $logoHeight) = @getimagesize($logoPath); // High-resolution? if (strpos($logoUrl, '@2x.') !== FALSE) { $logoWidth = $logoWidth / 2; $logoHeight = $logoHeight / 2; } $view->assign('logoUrl', $logoUrl); $view->assign('logoWidth', $logoWidth); $view->assign('logoHeight', $logoHeight); $view->assign('logoLink', TYPO3_URL_GENERAL); $view->assign('applicationVersion', TYPO3_version); $view->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); $view->assign('moduleMenu', $this->generateModuleMenu()); $view->assign('toolbar', $this->renderToolbar()); /****************************************************** * Now put the complete backend document together ******************************************************/ foreach ($this->cssFiles as $cssFileName => $cssFile) { $this->pageRenderer->addCssFile($cssFile); // Load additional css files to overwrite existing core styles if (!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) { $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]); } } if (!empty($this->css)) { $this->pageRenderer->addCssInlineBlock('BackendInlineCSS', $this->css); } foreach ($this->jsFiles as $jsFile) { $this->pageRenderer->addJsFile($jsFile); } $this->generateJavascript(); $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js, FALSE); $this->loadResourcesForRegisteredNavigationComponents(); // Add state provider $this->getDocumentTemplate()->setExtDirectStateProvider(); $states = $this->getBackendUser()->uc['BackendComponents']['States']; // Save states in BE_USER->uc $extOnReadyCode = ' Ext.state.Manager.setProvider(new TYPO3.state.ExtDirectProvider({ key: "BackendComponents.States", autoRead: false })); '; if ($states) { $extOnReadyCode .= 'Ext.state.Manager.getProvider().initState(' . json_encode($states) . ');'; } $extOnReadyCode .= ' TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration); if (typeof console === "undefined") { console = TYPO3.Backend.DebugConsole; }'; $this->pageRenderer->addExtOnReadyCode($extOnReadyCode); // Set document title: $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [TYPO3 CMS ' . TYPO3_version . ']' : 'TYPO3 CMS ' . TYPO3_version; // Renders the module page $this->content = $this->getDocumentTemplate()->render($title, $view->render()); $hookConfiguration = array('content' => &$this->content); $this->executeHook('renderPostProcess', $hookConfiguration); echo $this->content; }
/** * Create TabPanel to split the report and the checkLink functions * * @return void */ protected function createTabs() { $panelCheck = ''; if ($this->modTS['showCheckLinkTab'] == 1) { $panelCheck = ', { title: TYPO3.l10n.localize(\'CheckLink\'), html: ' . json_encode($this->flush()) . ', }'; } $this->render(); $js = 'var panel = new Ext.TabPanel( { renderTo: \'linkvalidator-modfuncreport\', id: \'linkvalidator-main\', plain: true, activeTab: 0, bodyStyle: \'padding:10px;\', items : [ { autoHeight: true, title: TYPO3.l10n.localize(\'Report\'), html: ' . json_encode($this->flush(TRUE)) . ' }' . $panelCheck . ' ] }); '; $this->pageRenderer->addExtOnReadyCode($js); }
/** * Main function generating the BE scaffolding * * @return void */ public function render() { $this->executeHook('renderPreProcess'); // Prepare the scaffolding, at this point extension may still add javascript and css $view = $this->getFluidTemplateObject($this->templatePath . 'Backend/Main.html'); // Extension Configuration to find the TYPO3 logo in the left corner $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'], ['allowed_classes' => false]); $logoPath = ''; if (!empty($extConf['backendLogo'])) { $customBackendLogo = GeneralUtility::getFileAbsFileName($extConf['backendLogo']); if (!empty($customBackendLogo)) { $logoPath = $customBackendLogo; } } // if no custom logo was set or the path is invalid, use the original one if (empty($logoPath)) { $logoPath = GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Images/typo3_logo_orange.svg'); $logoWidth = 22; $logoHeight = 22; } else { // set width/height for custom logo $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $logoPath); $logoWidth = $imageInfo->getWidth() ?? '22'; $logoHeight = $imageInfo->getHeight() ?? '22'; // High-resolution? if (strpos($logoPath, '@2x.') !== false) { $logoWidth /= 2; $logoHeight /= 2; } } $view->assign('logoUrl', PathUtility::getAbsoluteWebPath($logoPath)); $view->assign('logoWidth', $logoWidth); $view->assign('logoHeight', $logoHeight); $view->assign('applicationVersion', TYPO3_version); $view->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); $view->assign('moduleMenu', $this->generateModuleMenu()); $view->assign('toolbar', $this->renderToolbar()); /****************************************************** * Now put the complete backend document together ******************************************************/ foreach ($this->cssFiles as $cssFileName => $cssFile) { $this->pageRenderer->addCssFile($cssFile); // Load additional css files to overwrite existing core styles if (!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) { $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]); } } if (!empty($this->css)) { $this->pageRenderer->addCssInlineBlock('BackendInlineCSS', $this->css); } foreach ($this->jsFiles as $jsFile) { $this->pageRenderer->addJsFile($jsFile); } $this->generateJavascript(); $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js, false); $this->loadResourcesForRegisteredNavigationComponents(); // Add state provider $this->getDocumentTemplate()->setExtDirectStateProvider(); $states = $this->getBackendUser()->uc['BackendComponents']['States']; // Save states in BE_USER->uc $extOnReadyCode = ' Ext.state.Manager.setProvider(new TYPO3.state.ExtDirectProvider({ key: "BackendComponents.States", autoRead: false })); '; if ($states) { $extOnReadyCode .= 'Ext.state.Manager.getProvider().initState(' . json_encode($states) . ');'; } $this->pageRenderer->addExtOnReadyCode($extOnReadyCode); // Set document title: $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' [TYPO3 CMS ' . TYPO3_version . ']' : 'TYPO3 CMS ' . TYPO3_version; // Renders the module page $this->content = $this->getDocumentTemplate()->render($title, $view->render()); $hookConfiguration = ['content' => &$this->content]; $this->executeHook('renderPostProcess', $hookConfiguration); }