示例#1
0
    /**
     * Sets the startup module from either GETvars module and mpdParams or user configuration.
     *
     * @return	void
     */
    protected function setStartupModule()
    {
        $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
        if (!$startModule) {
            if ($GLOBALS['BE_USER']->uc['startModule']) {
                $startModule = $GLOBALS['BE_USER']->uc['startModule'];
            } else {
                if ($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
                    $startModule = 'user_task';
                }
            }
        }
        $moduleParameters = t3lib_div::_GET('modParams');
        if ($startModule) {
            $this->pageRenderer->addExtOnReadyCode('
			// start in module:
		function startInModule(modName, cMR_flag, addGetVars)	{
			Ext.onReady(function() {
				top.goToModule(modName, cMR_flag, addGetVars);
			});
		}

		startInModule(\'' . $startModule . '\', false, ' . t3lib_div::quoteJSvalue($moduleParameters) . ');
			');
        }
    }
示例#2
0
    /**
     * Returns page start
     * This includes the proper header with charset, title, meta tag and beginning body-tag.
     *
     * @param	string		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()
     */
    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) {
                    t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        $this->pageRenderer->backPath = $this->backPath;
        // alternative template for Header and Footer
        if ($this->pageHeaderFooterTemplateFile) {
            $file = t3lib_div::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE);
            if ($file) {
                $this->pageRenderer->setTemplateFile($file);
            }
        }
        // For debugging: If this outputs "QuirksMode"/"BackCompat" (IE) the browser runs in quirks-mode. Otherwise the value is "CSS1Compat"
        #		$this->JScodeArray[]='alert(document.compatMode);';
        // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
        $this->initCharset();
        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->getPageRenderer()->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 'html_5':
                $headerStart = '<!DOCTYPE html>' . LF;
                $htmlTag = '<html>';
                // disable rendering of XHTML tags
                $this->getPageRenderer()->setRenderXhtml(FALSE);
                break;
                // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
            // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
            case 'xhtml_trans':
            default:
                $headerStart = '<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
        }
        $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('tab.js');
        }
        // Get the browser info
        $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::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 ($this->docType !== 'html_3' && $this->docType !== 'html_5') {
            // 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());
        if ($this->useCompatibilityTag) {
            $this->pageRenderer->addMetaTag($this->xUaCompatible());
        }
        $this->pageRenderer->setTitle($title);
        // add docstyles
        $this->docStyle();
        // add jsCode - has to go to headerData as it may contain the script tags already
        $this->pageRenderer->addHeaderData($this->JScode);
        foreach ($this->JScodeArray as $name => $code) {
            $this->pageRenderer->addJsInlineCode($name, $code);
        }
        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) {
                    t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        // Construct page header.
        $str = $this->pageRenderer->render(t3lib_PageRenderer::PART_HEADER);
        $this->JScodeLibArray = array();
        $this->JScode = $this->extJScode = '';
        $this->JScodeArray = array();
        $this->endOfPageJsBlock = $this->pageRenderer->render(t3lib_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;
    }
示例#3
0
    /**
     * Makes a collapseable section. See reports module for an example
     *
     * @param  string  $title
     * @param  string  $html
     * @param  string  $id
     * @param  string $saveStatePointer
     * @return string
     */
    public function collapseableSection($title, $html, $id, $saveStatePointer = '')
    {
        $hasSave = $saveStatePointer ? TRUE : FALSE;
        $collapsedStyle = $collapsedClass = '';
        if ($hasSave) {
            /** @var $settings extDirect_DataProvider_BackendUserSettings */
            $settings = t3lib_div::makeInstance('extDirect_DataProvider_BackendUserSettings');
            $value = $settings->get($saveStatePointer . '.' . $id);
            if ($value) {
                $collapsedStyle = ' style="display: none"';
                $collapsedClass = ' collapsed';
            } else {
                $collapsedStyle = '';
                $collapsedClass = ' expanded';
            }
        }
        $this->pageRenderer->loadExtJS();
        $this->pageRenderer->addExtOnReadyCode('
			Ext.select("h2.section-header").each(function(element){
				element.on("click", function(event, tag) {
					var state = 0,
						el = Ext.fly(tag),
						div = el.next("div"),
						saveKey = el.getAttribute("rel");
					if (el.hasClass("collapsed")) {
						el.removeClass("collapsed").addClass("expanded");
						div.slideIn("t", {
							easing: "easeIn",
							duration: .5
						});
					} else {
						el.removeClass("expanded").addClass("collapsed");
						div.slideOut("t", {
							easing: "easeOut",
							duration: .5,
							remove: false,
							useDisplay: true
						});
						state = 1;
					}
					if (saveKey) {
						try {
							top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {});
						} catch(e) {}
					}
				});
			});
		');
        return '
		  <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2>
		  <div' . $collapsedStyle . '>' . $html . '</div>
		';
    }
示例#4
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 = t3lib_div::makeInstance('TYPO3Logo');
        $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);
        $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;
    }