Пример #1
0
 /**
  * Sets mandatory parameters for the view (pageRenderer)
  *
  * @return void
  */
 protected function setupPage()
 {
     // Yes, hardcoded on purpose
     $this->pageRenderer->setXmlPrologAndDocType('<!DOCTYPE html>');
     $this->pageRenderer->setCharSet('utf-8');
     $this->pageRenderer->setLanguage('default');
     $this->pageRenderer->addMetaTag('<meta name="viewport" content="width=device-width, initial-scale=1">');
 }
Пример #2
0
    /**
     * 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('&amp;', '&', $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('&amp;', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($moveParams, 1)));
                $copyParams = '&cmd[tt_content][DD_DRAG_UID][copy]=DD_DROP_UID&DDcopy=1';
                $copyURL = str_replace('&amp;', '&', 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);
            }
        }
    }
Пример #3
0
    /**
     * 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 (!empty($this->JScodeLibArray)) {
            GeneralUtility::deprecationLog('DocumentTemplate->JScodeLibArray is deprecated since TYPO3 CMS 7. Use the functionality within pageRenderer directly');
            foreach ($this->JScodeLibArray as $library) {
                $this->pageRenderer->addHeaderData($library);
            }
        }
        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;
    }
Пример #4
0
    /**
     * 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
     * @param boolean $includeCsh flag for including CSH
     * @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()
     * @todo Define visibility
     */
    public function startPage($title, $includeCsh = TRUE)
    {
        // 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);
                }
            }
        }
        $this->pageRenderer->backPath = $this->backPath;
        // alternative template for Header and Footer
        if ($this->pageHeaderFooterTemplateFile) {
            $file = GeneralUtility::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE);
            if ($file) {
                $this->pageRenderer->setTemplateFile($file);
            }
        }
        // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
        header('Content-Type:text/html;charset=' . $this->charset);
        // Standard HTML tag
        $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
        switch ($this->docType) {
            case 'html_3':
                $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
                $htmlTag = '<html>';
                // Disable rendering of XHTML tags
                $this->pageRenderer->setRenderXhtml(FALSE);
                break;
            case 'xhtml_strict':
                $headerStart = '<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
                break;
            case 'xhtml_frames':
                $headerStart = '<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
                break;
            case 'xhtml_trans':
                $headerStart = '<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
                break;
            case 'html5':
            default:
                // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
                $headerStart = '<!DOCTYPE html>' . LF;
                $htmlTag = '<html>';
                // Disable rendering of XHTML tags
                $this->pageRenderer->setRenderXhtml(FALSE);
        }
        $this->pageRenderer->setHtmlTag($htmlTag);
        // This loads the tabulator-in-textarea feature. It automatically modifies
        // every textarea which is found.
        if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) {
            $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/tab.js');
        }
        // Include the JS for the Context Sensitive Help
        if ($includeCsh) {
            $this->loadCshJavascript();
        }
        // Get the browser info
        $browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo(GeneralUtility::getIndpEnv('HTTP_USER_AGENT'));
        // Set the XML prologue
        $xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset . '"?>';
        // Set the XML stylesheet
        $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
        // Add the XML prologue for XHTML doctypes
        if (strpos($this->docType, 'xhtml') !== FALSE) {
            // Put the XML prologue before or after the doctype declaration according to browser
            if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
                $headerStart = $headerStart . LF . $xmlPrologue;
            } else {
                $headerStart = $xmlPrologue . LF . $headerStart;
            }
            // Add the xml stylesheet according to doctype
            if ($this->docType !== 'xhtml_frames') {
                $headerStart = $headerStart . LF . $xmlStylesheet;
            }
        }
        $this->pageRenderer->setXmlPrologAndDocType($headerStart);
        $this->pageRenderer->setHeadTag('<head>' . LF . '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID) . ' -->');
        $this->pageRenderer->setCharSet($this->charset);
        $this->pageRenderer->addMetaTag($this->generator());
        $this->pageRenderer->addMetaTag('<meta name="robots" content="noindex,follow" />');
        $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($this->backPath . 'sysext/backend/Resources/Public/JavaScript/ExtDirect.StateProvider.js');
        }
        // Add jsCode for overriding the console with a debug panel connection
        $this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', 'if (typeof top.Ext === "object") {
				top.Ext.onReady(function() {
					if (typeof console === "undefined") {
						if (top && top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.DebugConsole) {
							console = top.TYPO3.Backend.DebugConsole;
						} else {
							console = {
								log: Ext.log,
								info: Ext.log,
								warn: Ext.log,
								error: Ext.log
							};
						}
					}
				});
			}
			', FALSE);
        $this->pageRenderer->addHeaderData($this->JScode);
        foreach ($this->JScodeArray as $name => $code) {
            $this->pageRenderer->addJsInlineCode($name, $code, FALSE);
        }
        if (count($this->JScodeLibArray)) {
            foreach ($this->JScodeLibArray as $library) {
                $this->pageRenderer->addHeaderData($library);
            }
        }
        if ($this->extJScode) {
            $this->pageRenderer->addExtOnReadyCode($this->extJScode);
        }
        // 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->JScodeLibArray = array();
        $this->JScode = $this->extJScode = '';
        $this->JScodeArray = array();
        $this->endOfPageJsBlock = $this->pageRenderer->render(PageRenderer::PART_FOOTER);
        if ($this->docType == 'xhtml_frames') {
            return $str;
        } else {
            $str .= $this->docBodyTagBegin() . ($this->divClass ? '

<!-- Wrapping DIV-section for whole page BEGIN -->
<div class="' . $this->divClass . '">
' : '') . trim($this->form);
        }
        return $str;
    }
Пример #5
0
 /**
  * wrapper function called by hook (\TYPO3\CMS\Core\Page\PageRenderer->render-preProcess)
  *
  * @param array $parameters : An array of available parameters
  * @param \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer : The parent object that triggered this hook
  *
  * @return void
  */
 public function addJSCSS($parameters, &$pageRenderer)
 {
     if (get_class($GLOBALS['SOBE']) === 'TYPO3\\CMS\\Recordlist\\RecordList') {
         $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady');
         return;
     }
     if (get_class($GLOBALS['SOBE']) === 'TYPO3\\CMS\\Backend\\Controller\\PageLayoutController') {
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady');
         $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragDrop');
         $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragInWizard');
         /** @var Clipboard $clipObj */
         $clipObj = GeneralUtility::makeInstance(Clipboard::class);
         // Start clipboard
         $clipObj->initializeClipboard();
         $clipObj->lockToNormal();
         if (!$pageRenderer->getCharSet()) {
             $pageRenderer->setCharSet($GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : 'utf-8');
         }
         // 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');
         $pAddExtOnReadyCode = '
             TYPO3.l10n = {
                 localize: function(langKey){
                     return TYPO3.lang[langKey];
                 }
             }
         ';
         $allowedContentTypesClassesByColPos = array();
         $allowedGridTypesClassesByColPos = 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 = '';
                             $gridClasses = '';
                             if ($col['allowed']) {
                                 $allowed = explode(',', $col['allowed']);
                                 foreach ($allowed as $contentTypes) {
                                     $contentTypes = trim($contentTypes);
                                     if ($contentTypes === '*') {
                                         $classes = 't3-allow-all';
                                         break;
                                     } else {
                                         $contentTypes = explode(',', $contentTypes);
                                         foreach ($contentTypes as $contentType) {
                                             $classes .= 't3-allow-' . $contentType . ' ';
                                         }
                                     }
                                 }
                             } 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) {
                                             $gridClasses .= 't3-allow-gridtype t3-allow-gridtype-' . $gridType . ' ';
                                         }
                                     }
                                 }
                                 if ($classes !== 't3-allow-all') {
                                     $classes .= 't3-allow-gridelements_pi1 ';
                                 }
                             }
                             $allowedContentTypesClassesByColPos[$col['colPos']] .= ' ' . trim($classes);
                             $allowedGridTypesClassesByColPos[$col['colPos']] .= ' ' . trim($gridClasses);
                         }
                     }
                 }
             }
         }
         // add Ext.onReady() code from file
         $pAddExtOnReadyCode .= "\n            top.pageColumnsAllowedCTypes = " . json_encode($allowedContentTypesClassesByColPos) . ";\n            top.pageColumnsAllowedGridTypes = " . json_encode($allowedGridTypesClassesByColPos) . ";\n            top.pasteReferenceAllowed = " . ($this->getBackendUser()->checkAuthMode('tt_content', 'CType', 'shortcut', 'explicitAllow') ? 'true' : 'false') . ";\n            top.skipDraggableDetails = " . ($this->getBackendUser()->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'true' : 'false') . ";\n            top.backPath = '" . $GLOBALS['BACK_PATH'] . "';\n            top.browserUrl = '" . BackendUtility::getModuleUrl('wizard_element_browser') . "'";
         $elFromTable = $clipObj->elFromTable('tt_content');
         if (!empty($elFromTable)) {
             $pasteItem = substr(key($elFromTable), 11);
             $pasteRecord = BackendUtility::getRecord('tt_content', (int) $pasteItem);
             $pasteTitle = $pasteRecord['header'] ? $pasteRecord['header'] : $pasteItem;
             $copyMode = $clipObj->clipData['normal']['mode'] ? '-' . $clipObj->clipData['normal']['mode'] : '';
             $pAddExtOnReadyCode .= "\n                    top.pasteIntoLinkTemplate = " . json_encode('<a data-pasteitem="' . $pasteItem . '" data-pastetitle="' . $pasteTitle . '" class="t3js-paste t3js-paste' . $copyMode . ' t3js-paste-into btn btn-default" title="' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_js.pasteinto') . '">' . $iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>') . ";\n                    top.pasteAfterLinkTemplate = " . json_encode('<a data-pasteitem="' . $pasteItem . '" data-pastetitle="' . $pasteTitle . '"  class="t3js-paste t3js-paste' . $copyMode . ' t3js-paste-after btn btn-default" title="' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_js.pasteafter') . '">' . $iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>') . ";";
             if ($this->getBackendUser()->checkAuthMode('tt_content', 'CType', 'shortcut', 'explicitAllow')) {
                 $pAddExtOnReadyCode .= "\n                        top.pasteReferencesAllowed = true;";
             }
         } else {
             $pAddExtOnReadyCode .= "\n                    top.pasteIntoLinkTemplate = '';\n                    top.pasteAfterLinkTemplate = '';";
         }
         $pAddExtOnReadyCode .= "\n                    top.copyFromAnotherPageLinkTemplate = " . json_encode('<a class="t3js-paste-new btn btn-default" title="' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_js.copyfrompage') . '">' . $iconFactory->getIcon('actions-insert-reference', Icon::SIZE_SMALL)->render() . '</a>') . ";";
         $pageRenderer->addJsInlineCode('gridelementsExtOnReady', $pAddExtOnReadyCode);
     }
 }
Пример #6
0
 public function setUp()
 {
     $this->fixture = new \TYPO3\CMS\Core\Page\PageRenderer();
     $this->fixture->setCharSet($GLOBALS['LANG']->charSet);
 }
Пример #7
0
    /**
     * 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
     * @param bool $includeCsh flag for including CSH
     * @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, $includeCsh = TRUE)
    {
        // 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);
                }
            }
        }
        $this->pageRenderer->backPath = $this->backPath;
        // 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 . '">');
        // Include the JS for the Context Sensitive Help
        // @todo: right now this is a hard dependency on csh manual, as the whole help system should be moved to
        // the extension. The core provides a API for adding help, and rendering help, but the rendering
        // should be up to the extension itself
        if ($includeCsh && ExtensionManagementUtility::isLoaded('cshmanual')) {
            $this->loadCshJavascript();
        }
        $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($this->backPath . 'sysext/backend/Resources/Public/JavaScript/ExtDirect.StateProvider.js');
        }
        // Add jsCode for overriding the console with a debug panel connection
        $this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', 'if (typeof top.Ext === "object") {
				top.Ext.onReady(function() {
					if (typeof console === "undefined") {
						if (top && top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.DebugConsole) {
							console = top.TYPO3.Backend.DebugConsole;
						} else {
							console = {
								log: Ext.log,
								info: Ext.log,
								warn: Ext.log,
								error: Ext.log
							};
						}
					}
				});
			}
			', FALSE);
        $this->pageRenderer->addHeaderData($this->JScode);
        foreach ($this->JScodeArray as $name => $code) {
            $this->pageRenderer->addJsInlineCode($name, $code, FALSE);
        }
        if (count($this->JScodeLibArray)) {
            GeneralUtility::deprecationLog('DocumentTemplate->JScodeLibArray is deprecated since TYPO3 CMS 7. Use the functionality within pageRenderer directly');
            foreach ($this->JScodeLibArray as $library) {
                $this->pageRenderer->addHeaderData($library);
            }
        }
        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($this->backPath . 'sysext/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;
    }