Esempio n. 1
0
 /**
  * Load RequireJS code.
  *
  * @return void
  * @api
  */
 public function render()
 {
     $content = $this->renderChildren();
     $this->pageRenderer->addJsInlineCode('vidi-inline', $content);
     $configuration['paths']['Fab/Vidi'] = '../typo3conf/ext/vidi/Resources/Public/JavaScript';
     $this->pageRenderer->addRequireJsConfiguration($configuration);
     $this->pageRenderer->loadRequireJsModule('Fab/Vidi/Vidi/Main');
 }
Esempio n. 2
0
    /**
     * 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 inline
  */
 public function testAddJsInlineCode()
 {
     $expectedReturnValue = 'var x = "testvar"';
     $this->fixture->addJsInlineCode('test', 'var x = "testvar"');
     $out = $this->fixture->render();
     $this->assertContains($expectedReturnValue, $out);
 }
Esempio n. 4
0
 /**
  * Add JS inline code
  *
  * @param string $name
  * @param string $block
  * @param boolean $compress
  * @param boolean $forceOnTop
  * @param string $position
  */
 public function addJSInlineCode($name, $block, $compress = true, $forceOnTop = false, $position = 'footer')
 {
     if ($position === 'header') {
         $this->pageRenderer->addJsInlineCode($name, $block, $compress, $forceOnTop);
     } else {
         $this->pageRenderer->addJsFooterInlineCode($name, $block, $compress, $forceOnTop);
     }
 }
Esempio n. 5
0
    /**
     * Main function of the module. Write the content to $this->content
     * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
        if ($BE_USER->user["admin"]) {
            // Draw the header.
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("template");
            $this->doc->backPath = $BACK_PATH;
            $this->pageRenderer = $this->doc->getPageRenderer();
            // Include Ext JS
            $this->pageRenderer->loadExtJS(true, true);
            $this->pageRenderer->enableExtJSQuickTips();
            $this->pageRenderer->enableExtJsDebug();
            $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js', 'text/javascript', FALSE, FALSE);
            $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeTree.js', 'text/javascript', FALSE, FALSE);
            //Add caretaker css
            $this->pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.nodetree.css', 'stylesheet', 'all', '', FALSE);
            // storage Pid
            $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']);
            $storagePid = (int) $confArray['storagePid'];
            $this->pageRenderer->addJsInlineCode('Caretaker_Nodetree', '
			Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
			Ext.ns("tx.caretaker");
			Ext.onReady(function() {
				tx.caretaker.view = new Ext.Viewport({
					layout: "fit",
					items: {
						id: "cartaker-tree",
						xtype: "caretaker-nodetree",
						autoScroll: true,
						dataUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::treeloader\'],
						addUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new",
						editUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[tx_caretaker_###NODE_TYPE###][###NODE_UID###]=edit",
						hideUrl: "' . $PATH_TYPO3 . 'tce_db.php?&data[tx_caretaker_###NODE_TYPE###][###NODE_UID###][hidden]=1",
						unhideUrl: "' . $PATH_TYPO3 . 'tce_db.php?&data[tx_caretaker_###NODE_TYPE###][###NODE_UID###][hidden]=0"
					}
				});

				tx_caretaker_updateTreeById = function( id ){
					tx_caretaker_tree = Ext.getCmp("cartaker-tree");
					tx_caretaker_tree.reloadTreePartial( id );
				}
			});
			');
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->doc->form = '';
        } else {
            // If no access or if not admin
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->content .= $this->doc->header($LANG->getLL("title"));
            $this->content .= $this->doc->spacer(5);
            $this->content .= $this->doc->spacer(10);
        }
    }
 /**
  * Returns JS callback for the given action
  *
  * @param null $action
  * @param array $arguments
  * @param null $controller
  * @param null $extensionName
  * @param null $pluginName
  * @param string $format
  * @param string $section
  * @return string
  */
 public function getAjaxFunction($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $format = '', $section = 'footer')
 {
     // current element needs to have additional logic...
     $this->hijaxEventDispatcher->setIsHijaxElement(true);
     $request = $this->mvcDispatcher->getCurrentRequest();
     if ($request) {
         if ($action === NULL) {
             $action = $request->getControllerActionName();
         }
         if ($controller === NULL) {
             $controller = $request->getControllerName();
         }
         if ($extensionName === NULL) {
             $extensionName = $request->getControllerExtensionName();
         }
         if ($pluginName === NULL && TYPO3_MODE === 'FE') {
             $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controller, $action);
         }
         if ($pluginName === NULL) {
             $pluginName = $request->getPluginName();
         }
     }
     $settings = array('extension' => $extensionName, 'plugin' => $pluginName, 'controller' => $controller, 'format' => $format ? $format : 'html', 'action' => $action, 'arguments' => $arguments, 'settingsHash' => $this->mvcDispatcher->getCurrentListener() ? $this->mvcDispatcher->getCurrentListener()->getId() : '', 'namespace' => $extensionName && $pluginName ? $this->extensionService->getPluginNamespace($extensionName, $pluginName) : '');
     $functionName = 'extbaseHijax_' . md5(serialize($settings));
     $content = "; {$functionName}=function(settings, pendingElement, loaders) {";
     foreach ($settings as $k => $v) {
         $content .= "if (typeof settings.{$k} == 'undefined') settings.{$k}=" . json_encode($v) . ";";
     }
     $content .= "return jQuery.hijax(settings, pendingElement, loaders);};";
     if ($this->isCached()) {
         if ($section == 'footer') {
             $this->pageRenderer->addJsFooterInlineCode(md5($content), $content, FALSE, TRUE);
         } else {
             $this->pageRenderer->addJsInlineCode(md5($content), $content, FALSE, TRUE);
         }
     } else {
         // additionalFooterData not possible in USER_INT
         $GLOBALS['TSFE']->additionalHeaderData[md5($content)] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
     }
     return $functionName;
 }
Esempio n. 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 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;
    }
Esempio n. 8
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);
     }
 }
Esempio n. 9
0
    /**
     * Main function of the module. Write the content to $this->content
     * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree
     *
     * @return void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
        if ($BE_USER->user["admin"]) {
            // find node
            $node_repository = tx_caretaker_NodeRepository::getInstance();
            $node = $node_repository->id2node($this->node_id, true);
            if (!$node) {
                $node = $node_repository->getRootNode();
            }
            // Draw the header.
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->pageRenderer = $this->doc->getPageRenderer();
            // Include Ext JS
            $this->pageRenderer->loadExtJS();
            $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js');
            $panels = array();
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['caretaker']['extJsBackendPanels'] as $extJsBackendPanel) {
                // register JS
                foreach ($extJsBackendPanel['jsIncludes'] as $jsInclude) {
                    $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($jsInclude));
                    $this->pageRenderer->addJsFile($filename);
                }
                // register CSS
                foreach ($extJsBackendPanel['cssIncludes'] as $cssInclude) {
                    $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($cssInclude));
                    $this->pageRenderer->addCssFile($filename);
                }
                // add ExtJs Panel
                $panels[$extJsBackendPanel['id']] = $extJsBackendPanel['xtype'];
            }
            $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeToolbar.js');
            // Enable debug mode for Ext JS
            $this->pageRenderer->enableExtJsDebug();
            // storage Pid
            $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']);
            $storagePid = (int) $confArray['storagePid'];
            //Add caretaker css
            $this->pageRenderer->addCssFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.overview.css');
            $pluginItems = array();
            foreach ($panels as $id => $xtype) {
                $pluginItems[] = '{ id: "' . $id . '", xtype: "' . $xtype . '" , back_path: back_path , node_id: node_id }';
            }
            $this->pageRenderer->addJsInlineCode('Caretaker_Overview', '
				Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
				Ext.namespace("tx","tx.caretaker");

				Ext.onReady( function() {

					var back_path   = "' . $this->doc->backPath . '";
					var back_url    = "' . urlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) . '";
					var path_typo3  = "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/";
					var	add_url     = "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new";
					var node_id     = "' . $node->getCaretakerNodeId() . '";
					var node_type   = "' . strtolower($node->getType()) . '";
					var node_hidden = "' . $node->getHidden() . '";
					var node_uid    = "' . $node->getUid() . '";
					var node_title  = "' . htmlspecialchars($node->getTitle() ? $node->getTitle() : '[no title]') . '( ' . ($node->getTypeDescription() ? htmlspecialchars($node->getTypeDescription()) : $node->getType()) . ' )" ;
					var node_state  = "' . $node->getTestResult()->getState() . '" ;
					var node_state_info  = "' . $node->getTestResult()->getStateInfo() . '" ;

					tx.caretaker.view = new Ext.Viewport({
						layout: "fit",
						items: {
								xtype    : "panel",
								id       : "node",
								autoScroll: true,
								title    : node_title,
								iconCls  : "icon-caretaker-type-" + node_type,
								tbar     : {
									xtype: "caretaker-nodetoolbar",
									back_path: back_path,
									path_typo3: path_typo3,
									back_url: back_url,
									add_url :add_url,
									node_id: node_id,
									node_type: node_type,
									node_uid: node_uid,
									node_hidden: node_hidden,
									node_state: node_state,
									node_state_info: node_state_info
								},
								items    : [
									{
										xtype    : "panel",
										padding  : "10",
										layout   : "fit",
										id       : "caretaker-panels",
										items    : [
											' . implode(chr(10) . ',', $pluginItems) . chr(10) . '
										]
									}
								],
						}
					 });
				});
			');
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->doc->form = '';
        } else {
            // If no access or if not admin
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->content .= $this->doc->header($LANG->getLL("title"));
            $this->content .= $this->doc->spacer(5);
            $this->content .= $this->doc->spacer(10);
        }
    }
 /**
  * @param string $src
  * @param string $type
  * @param boolean $compress
  * @param boolean $forceOnTop
  * @param string $allWrap
  * @param boolean $excludeFromConcatenation
  * @param string $section
  * @param boolean $preventMarkupUpdateOnAjaxLoad
  * @param boolean $moveToExternalFile
  * @param boolean $noCache
  * @param string $name
  * 
  * @return string
  */
 public function render($src = "", $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $excludeFromConcatenation = FALSE, $section = 'footer', $preventMarkupUpdateOnAjaxLoad = false, $moveToExternalFile = false, $noCache = false, $name = '')
 {
     $content = $this->renderChildren();
     if ($this->ajaxDispatcher->getIsActive()) {
         if ($preventMarkupUpdateOnAjaxLoad) {
             $this->ajaxDispatcher->setPreventMarkupUpdateOnAjaxLoad(true);
         }
         // need to just echo the code in ajax call
         if (!$src) {
             if ($compress) {
                 $content = $this->compressScript($content);
             }
             return \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
         } else {
             return '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>';
         }
     } else {
         if ($this->isCached()) {
             if ($noCache) {
                 if ($src) {
                     $content = '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>';
                 } else {
                     if ($compress) {
                         $content = $this->compressScript($content);
                     }
                     $content = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
                 }
                 $tslibFE = GeneralUtility::makeInstance('EssentialDots\\ExtbaseHijax\\Tslib\\FE\\Hook');
                 /* @var $tslibFE \EssentialDots\ExtbaseHijax\Tslib\FE\Hook */
                 if ($section == 'footer') {
                     $tslibFE->addNonCacheableFooterCode($name ? $name : md5($content), $content);
                 } else {
                     $tslibFE->addNonCacheableHeaderCode($name ? $name : md5($content), $content);
                 }
                 return '';
             } else {
                 if (!$src && $moveToExternalFile) {
                     $src = 'typo3temp' . DIRECTORY_SEPARATOR . 'extbase_hijax' . DIRECTORY_SEPARATOR . md5($content) . '.js';
                     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(PATH_site . $src, $content);
                     if ($GLOBALS['TSFE']) {
                         if ($GLOBALS['TSFE']->baseUrl) {
                             $src = $GLOBALS['TSFE']->baseUrl . $src;
                         } elseif ($GLOBALS['TSFE']->absRefPrefix) {
                             $src = $GLOBALS['TSFE']->absRefPrefix . $src;
                         }
                     }
                 }
                 if (!$src) {
                     if ($section == 'footer') {
                         $this->pageRenderer->addJsFooterInlineCode($name ? $name : md5($content), $content, $compress, $forceOnTop);
                     } else {
                         $this->pageRenderer->addJsInlineCode($name ? $name : md5($content), $content, $compress, $forceOnTop);
                     }
                 } else {
                     if ($section == 'footer') {
                         $this->pageRenderer->addJsFooterFile($src, $type, $compress, $forceOnTop, $allWrap, $excludeFromConcatenation);
                     } else {
                         $this->pageRenderer->addJsFile($src, $type, $compress, $forceOnTop, $allWrap, $excludeFromConcatenation);
                     }
                 }
             }
         } else {
             // additionalFooterData not possible in USER_INT
             if (!$src) {
                 $GLOBALS['TSFE']->additionalHeaderData[$name ? $name : md5($content)] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
             } else {
                 $GLOBALS['TSFE']->additionalHeaderData[$name ? $name : md5($content)] = '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>';
             }
         }
     }
     return '';
 }
    /**
     * Draws the RTE as an iframe
     *
     * @param 	object		Reference to parent object, which is an instance of the TCEforms.
     * @param 	string		The table name
     * @param 	string		The field name
     * @param 	array		The current row from which field is being rendered
     * @param 	array		Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param 	array		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param 	array		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param 	string		Record "type" field value.
     * @param 	string		Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param 	integer		PID value of record (true parent page id)
     * @return 	string		HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE(&$parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ?: '';
        // Get the host URL
        $this->hostURL = '';
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        $this->elementParts[0] = $table;
        $this->elementParts[1] = $row['uid'];
        $this->tscPID = $thePidValue;
        $this->thePid = $thePidValue;
        // Record "type" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "type" value for record
        // RTE configuration
        $pageTSConfig = $TSFE->getPagesTSconfig();
        if (is_array($pageTSConfig) && is_array($pageTSConfig['RTE.'])) {
            $this->RTEsetup = $pageTSConfig['RTE.'];
        }
        if (is_array($thisConfig) && !empty($thisConfig)) {
            $this->thisConfig = $thisConfig;
        } elseif (is_array($this->RTEsetup['default.']) && is_array($this->RTEsetup['default.']['FE.'])) {
            $this->thisConfig = $this->RTEsetup['default.']['FE.'];
        }
        // Special configuration (line) and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows:
        $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Language
        $TSFE->initLLvars();
        $this->language = $TSFE->lang;
        $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
            if ($this->contentLanguageUid) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $languagesUidsList = $this->contentLanguageUid;
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            } else {
                $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ?: 'en';
                $selectFields = 'lg_iso_2, lg_typo3';
                $tableAB = 'static_languages';
                $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            }
        }
        $this->contentISOLanguage = $this->contentISOLanguage ?: ($GLOBALS['TSFE']->sys_language_isocode ?: 'en');
        $this->contentTypo3Language = $this->contentTypo3Language ?: $GLOBALS['TSFE']->lang;
        if ($this->contentTypo3Language == 'default') {
            $this->contentTypo3Language = 'en';
        }
        // Character set
        $this->charset = $TSFE->renderCharset;
        $this->OutputCharset = $TSFE->metaCharset ?: $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ?: 'utf-8';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ?: $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 610;
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? (int) $this->thisConfig['RTEWidthOverride'] : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = (int) $this->thisConfig['RTEHeightOverride'];
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ?: ($this->RTEdivStyle ?: 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ?: 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $this->getPageRenderer();
        // Register RTE in JS
        $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '', $textAreaId));
        // Set the save option for the RTE:
        $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
        if (!is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $this->pageRenderer->loadExtJs();
            $this->pageRenderer->enableExtJSQuickTips();
        }
        $this->pageRenderer->addJsFile($this->getFullFileName('typo3/js/extjs/ux/ext.resizable.js'));
        $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/contrib/extjs/resources/css/ext-all-notheme.css');
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/sysext/t3skin/extjs/xtheme-t3skin.css');
        $this->addSkin();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/js/extjs/ux/resize.css');
        // Add RTE JavaScript
        $this->addRteJsFiles($this->TCEform->RTEcounter);
        $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait', $this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; ' . htmlspecialchars($this->RTEWrapStyle) . '">
			<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        return $item;
    }
Esempio n. 12
0
    /**
     * 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;
    }
Esempio n. 13
0
    /**
     * Draws the RTE as an iframe
     *
     * @param FormEngine $_ Reference to parent object, which is an instance of the TCEforms. Obsolete DUMMY object only!
     * @param string $table The table name
     * @param string $field The field name
     * @param array $row The current row from which field is being rendered
     * @param array $PA Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param array $specConf "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param array $thisConfig Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param string $RTEtypeVal Record "type" field value.
     * @param string $RTErelPath Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param int $thePidValue PID value of record (true parent page id)
     * @param array $globalOptions Global options like 'readonly' for all elements. This is a hack until RTE is an own type
     * @param array $resultArray Initialized final result array that is returned later filled with content. This is a hack until RTE is an own type
     * @param string $validatationDataAttribute the validation data attribute.
     * @return string HTML code for RTE!
     */
    public function drawRTE($_, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue, $globalOptions, $resultArray, $validatationDataAttribute = '')
    {
        $languageService = $this->getLanguageService();
        $backendUser = $this->getBackendUserAuthentication();
        $database = $this->getDatabaseConnection();
        $this->globalOptions = $globalOptions;
        $languageService->includeLLFile('EXT:rtehtmlarea/locallang.xlf');
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        $this->userUid = 'BE_' . $GLOBALS['BE_USER']->user['uid'];
        // Draw real RTE
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = ExtensionManagementUtility::extRelPath('rtehtmlarea');
        // Get the site URL
        $this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
        // Get the host URL
        $this->hostURL = $this->siteURL . TYPO3_mainDir;
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        // Form element name
        $this->elementParts = explode('][', preg_replace('/\\]$/', '', preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $this->elementId)));
        // Find the page PIDs:
        list($this->tscPID, $this->thePid) = BackendUtility::getTSCpid(trim($this->elementParts[0]), trim($this->elementParts[1]), $thePidValue);
        // Record "types" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "types" value for record
        // Find "thisConfig" for record/editor:
        unset($this->RTEsetup);
        $this->RTEsetup = $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->tscPID));
        $this->thisConfig = $thisConfig;
        // Special configuration and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId));
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Languages: interface and content
        $this->language = $GLOBALS['LANG']->lang;
        if ($this->language === 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
        if ($this->contentLanguageUid) {
            $this->contentISOLanguage = $this->language;
            if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid = ' . intval($this->contentLanguageUid);
                $whereClause .= BackendUtility::BEenableFields($tableA);
                $whereClause .= BackendUtility::deleteClause($tableA);
                $res = $database->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $database->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                }
            }
        } else {
            $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ?: 'en';
            $languageCodeParts = explode('_', $this->contentISOLanguage);
            $this->contentISOLanguage = strtolower($languageCodeParts[0]) . ($languageCodeParts[1] ? '_' . strtoupper($languageCodeParts[1]) : '');
            // Find the configured language in the list of localization locales
            /** @var $locales \TYPO3\CMS\Core\Localization\Locales */
            $locales = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\Locales::class);
            // If not found, default to 'en'
            if (!in_array($this->contentISOLanguage, $locales->getLocales())) {
                $this->contentISOLanguage = 'en';
            }
        }
        // Create content laguage service
        $this->contentLanguageService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
        $this->contentTypo3Language = $this->contentISOLanguage === 'en' ? 'default' : $this->contentISOLanguage;
        $this->contentLanguageService->init($this->contentTypo3Language);
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        // Check if wizard_rte called this for fullscreen edtition
        if (GeneralUtility::_GP('M') === 'wizard_rte') {
            $this->fullScreen = TRUE;
            $RTEWidth = '100%';
            $RTEHeight = '100%';
            $RTEPaddingRight = '0';
            $editorWrapWidth = '100%';
        } else {
            $options = $GLOBALS['BE_USER']->userTS['options.'];
            $RTEWidth = 530 + (isset($options['RTELargeWidthIncrement']) ? (int) $options['RTELargeWidthIncrement'] : 150);
            /** @var InlineStackProcessor  $inlineStackProcessor */
            $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
            $inlineStackProcessor->initializeByGivenStructure($globalOptions['inlineStructure']);
            $inlineStructureDepth = $inlineStackProcessor->getStructureDepth();
            $RTEWidth -= $inlineStructureDepth > 0 ? ($inlineStructureDepth + 1) * 12 : 0;
            $RTEWidthOverride = is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth']) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride']);
            if ($RTEWidthOverride) {
                if (strstr($RTEWidthOverride, '%')) {
                    if ($this->client['browser'] != 'msie') {
                        $RTEWidth = (int) $RTEWidthOverride > 0 ? $RTEWidthOverride : '100%';
                    }
                } else {
                    $RTEWidth = (int) $RTEWidthOverride > 0 ? (int) $RTEWidthOverride : $RTEWidth;
                }
            }
            $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px';
            $RTEHeight = 380 + (isset($options['RTELargeHeightIncrement']) ? (int) $options['RTELargeHeightIncrement'] : 0);
            $RTEHeightOverride = is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && (int) $GLOBALS['BE_USER']->uc['rteHeight'] ? (int) $GLOBALS['BE_USER']->uc['rteHeight'] : (int) $this->thisConfig['RTEHeightOverride'];
            $RTEHeight = $RTEHeightOverride > 0 ? $RTEHeightOverride : $RTEHeight;
            $RTEPaddingRight = '2px';
            $editorWrapWidth = '99%';
        }
        $editorWrapHeight = '100%';
        $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px ' . $RTEPaddingRight . ' 2px 2px;';
        /* =======================================
         * LOAD CSS AND JAVASCRIPT
         * =======================================
         */
        $this->pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
        // Preloading the pageStyle and including RTE skin stylesheets
        $resultArray = $this->addPageStyle($resultArray);
        $resultArray = $this->addSkin($resultArray);
        // Register RTE in JS
        $resultArray['additionalJavaScriptPost'][] = $this->registerRTEinJS(NULL, $table, $row['uid'], $field, $textAreaId);
        // Set the save option for the RTE
        $resultArray['additionalJavaScriptSubmit'][] = $this->setSaveRTE(NULL, 'editform', $textAreaId, $PA['itemFormElName']);
        // Loading ExtJs inline code
        $this->pageRenderer->enableExtJSQuickTips();
        // Add TYPO3 notifications JavaScript
        $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
        // Add RTE JavaScript
        $this->addRteJsFiles();
        $this->pageRenderer->addJsFile($this->createJavaScriptLanguageLabelsFromFiles());
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // Draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $languageService->getLL('Please wait') . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
			<textarea id="RTEarea' . $textAreaId . '" ' . $validatationDataAttribute . ' name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle, ENT_COMPAT, 'UTF-8', FALSE) . '">' . GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        $resultArray['html'] = $item;
        return $resultArray;
    }
    /**
     * Main method of modfuncreport
     *
     * @return string Module content
     */
    public function main()
    {
        $GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf');
        $this->searchLevel = GeneralUtility::_GP('search_levels');
        if (isset($this->pObj->id)) {
            $this->modTS = BackendUtility::getModTSconfig($this->pObj->id, 'mod.linkvalidator');
            $this->modTS = $this->modTS['properties'];
        }
        $update = GeneralUtility::_GP('updateLinkList');
        $prefix = '';
        if (!empty($update)) {
            $prefix = 'check';
        }
        $set = GeneralUtility::_GP($prefix . 'SET');
        $this->pObj->handleExternalFunctionValue();
        if (isset($this->searchLevel)) {
            $this->pObj->MOD_SETTINGS['searchlevel'] = $this->searchLevel;
        } else {
            $this->searchLevel = $this->pObj->MOD_SETTINGS['searchlevel'];
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
                // Compile list of all available types. Used for checking with button "Check Links".
                if (strpos($this->modTS['linktypes'], $linkType) !== FALSE) {
                    $this->availableOptions[$linkType] = 1;
                }
                // Compile list of types currently selected by the checkboxes
                if ($this->pObj->MOD_SETTINGS[$linkType] && empty($set) || $set[$linkType]) {
                    $this->checkOpt[$linkType] = 1;
                    $this->pObj->MOD_SETTINGS[$linkType] = 1;
                } else {
                    $this->pObj->MOD_SETTINGS[$linkType] = 0;
                    unset($this->checkOpt[$linkType]);
                }
            }
        }
        $GLOBALS['BE_USER']->pushModuleData('web_info', $this->pObj->MOD_SETTINGS);
        $this->initialize();
        // Localization
        $this->pageRenderer->addInlineLanguageLabelFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('linkvalidator', 'Resources/Private/Language/Module/locallang.xlf'));
        $this->pageRenderer->addJsInlineCode('linkvalidator', 'function toggleActionButton(prefix) {
			var buttonDisable = true;
			Ext.select(\'.\' + prefix ,false).each(function(checkBox,i){
			checkDom = checkBox.dom;
			if (checkDom.checked){
				buttonDisable = false;
			}

			});
			if (prefix == \'check\'){
				checkSub = document.getElementById(\'updateLinkList\');
			} else {
				checkSub = document.getElementById(\'refreshLinkList\');
			}
			checkSub.disabled = buttonDisable;
		}');
        // Add JS
        $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
        $this->pageRenderer->addJsFile($this->doc->backPath . 'sysext/backend/Resources/Public/JavaScript/flashmessages.js');
        $this->pageRenderer->addJsFile($this->doc->backPath . 'sysext/backend/Resources/Public/JavaScript/iframepanel.js');
        if ($this->modTS['showCheckLinkTab'] == 1) {
            $this->updateListHtml = '<input type="submit" name="updateLinkList" id="updateLinkList" value="' . $GLOBALS['LANG']->getLL('label_update') . '"/>';
        }
        $this->refreshListHtml = '<input type="submit" name="refreshLinkList" id="refreshLinkList" value="' . $GLOBALS['LANG']->getLL('label_refresh') . '"/>';
        $this->processor = GeneralUtility::makeInstance('TYPO3\\CMS\\Linkvalidator\\LinkAnalyzer');
        $this->updateBrokenLinks();
        $brokenLinkOverView = $this->processor->getLinkCounts($this->pObj->id);
        $this->checkOptHtml = $this->getCheckOptions($brokenLinkOverView);
        $this->checkOptHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check');
        $this->createTabs();
        return '<div id="linkvalidator-modfuncreport"></div>';
    }
Esempio n. 15
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;
    }
Esempio n. 16
0
    /**
     * 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);
    }
Esempio n. 17
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;
    }
Esempio n. 18
0
 /**
  * Wrapper function for adding JS inline blocks
  *
  * @return void
  */
 protected function setJavaScriptCodeArray()
 {
     foreach ($this->javascriptCodeArray as $name => $code) {
         $this->pageRenderer->addJsInlineCode($name, $code, false);
     }
 }
Esempio n. 19
0
    /**
     * 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);
    }