/** * 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 CSS inline and force on top */ public function testAddCssInlineBlockForceOnTop() { $expectedReturnValue = '/*general1*/' . LF . 'h1 {margin:20px;}' . LF . '/*general*/' . LF . 'body {margin:20px;}'; $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}'); $this->fixture->addCssInlineBlock('general1', 'h1 {margin:20px;}', NULL, TRUE); $out = $this->fixture->render(); $this->assertContains($expectedReturnValue, $out); }
/** * 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); }
/** * Outputting document style * * @return string HTML style section/link tags */ public function docStyle() { // Implode it all: $inDocStyles = implode(LF, $this->inDocStylesArray); // Reset styles so they won't be added again in insertStylesAndJS() $this->inDocStylesArray = array(); if ($this->styleSheetFile) { $this->pageRenderer->addCssFile($this->styleSheetFile); } if ($this->styleSheetFile2) { $this->pageRenderer->addCssFile($this->styleSheetFile2); } if ($inDocStyles !== '') { $this->pageRenderer->addCssInlineBlock('inDocStyles', $inDocStyles . LF . '/*###POSTCSSMARKER###*/'); } if ($this->styleSheetFile_post) { $this->pageRenderer->addCssFile($this->styleSheetFile_post); } }
/** * Outputting document style * * @return string HTML style section/link tags * @todo Define visibility */ public function docStyle() { // Request background image: if ($this->backGroundImage) { $this->inDocStylesArray[] = ' BODY { background-image: url(' . $this->backPath . $this->backGroundImage . '); }'; } // Add inDoc styles variables as well: $this->inDocStylesArray[] = $this->inDocStyles; $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle; // Implode it all: $inDocStyles = implode(LF, $this->inDocStylesArray); // Reset styles so they won't be added again in insertStylesAndJS() $this->inDocStylesArray = array(); $this->inDocStyles = ''; $this->inDocStyles_TBEstyle = ''; if ($this->styleSheetFile) { $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile); } if ($this->styleSheetFile2) { $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile2); } $this->pageRenderer->addCssInlineBlock('inDocStyles', $inDocStyles . LF . '/*###POSTCSSMARKER###*/'); if ($this->styleSheetFile_post) { $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile_post); } }
/** * 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; }
/** * @param $name * @param $block * @param bool $compress * @param bool $forceOnTop * @return void */ public function addCssInlineBlock($name, $block, $compress = false, $forceOnTop = false) { $this->pageRenderer->addCssInlineBlock($name, $block, $compress, $forceOnTop); }
/** * 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); }