2009-09-06 Steffen Kamper <info@sk-typo3.de>
+ * Added feature #11397: Add class for rendering HTML page in BE and FE
* Updated swfobjects from version 2.1 to version 2.2
* Added feature #11370: Inconsistent Login Screen doesn't show system required errors (thanks to Jens Hoffmann, Susanne Moog and Steffen Gebert)
--- /dev/null
+<?php\r
+/***************************************************************\r
+ * Copyright notice\r
+ *\r
+ * (c) 2009 Steffen Kamper (info@sk-typo3.de)\r
+ * All rights reserved\r
+ *\r
+ * This script is part of the TYPO3 project. The TYPO3 project is\r
+ * free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * The GNU General Public License can be found at\r
+ * http://www.gnu.org/copyleft/gpl.html.\r
+ * A copy is found in the textfile GPL.txt and important notices to the license\r
+ * from the author is found in LICENSE.txt distributed with these scripts.\r
+ *\r
+ *\r
+ * This script is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * This copyright notice MUST APPEAR in all copies of the script!\r
+ ***************************************************************/\r
+\r
+/**\r
+ * TYPO3 pageRender class (new in TYPO3 4.3.0)\r
+ * This class render the HTML of a webpage, usable for BE and FE\r
+ *\r
+ * @author Steffen Kamper <info@sk-typo3.de>\r
+ * @package TYPO3\r
+ * @subpackage t3lib\r
+ * $Id:$\r
+ */\r
+abstract class t3lib_pageRender implements t3lib_Singleton {\r
+ \r
+ protected $compressJavascript = FALSE;\r
+ protected $compressCss = FALSE;\r
+ protected $removeLineBreaksFromTemplate = FALSE;\r
+\r
+ protected $concatenateFiles = FALSE;\r
+\r
+ protected $moveJsFromHeaderToFooter = FALSE;\r
+\r
+ protected $csConvObj;\r
+ protected $lang;\r
+\r
+ // static array containing associative array for the included files\r
+ protected static $jsFiles = array ();\r
+ protected static $jsFooterFiles = array ();\r
+ protected static $jsLibs = array ();\r
+ protected static $jsFooterLibs = array ();\r
+ protected static $cssFiles = array ();\r
+\r
+ protected $title;\r
+ protected $charSet;\r
+ protected $favIcon;\r
+ protected $baseUrl;\r
+\r
+ // static header blocks\r
+ protected $xmlPrologAndDocType = '';\r
+ protected $metaTags = array ();\r
+ protected $inlineComments = array ();\r
+ protected $headerData = array ();\r
+ protected $footerData = array ();\r
+ protected $titleTag = '<title>|</title>';\r
+ protected $metaCharsetTag = '<meta http-equiv="Content-Type" content="text/html; charset=|" />';\r
+ protected $htmlTag = '<html>';\r
+ protected $headTag = '<head>';\r
+ protected $baseUrlTag = '<base href="|" />';\r
+ protected $iconMimeType = '';\r
+ protected $shortcutTag = '<link rel="shortcut icon" href="%1$s"%2$s />\r
+<link rel="icon" href="%1$s"%2$s />';\r
+\r
+ // static inline code blocks\r
+ protected $jsInline = array ();\r
+ protected $extOnReadyCode = array ();\r
+ protected $cssInline = array ();\r
+\r
+ protected $bodyContent;\r
+\r
+ protected $templateFile;\r
+\r
+ protected $jsLibraryNames = array ('prototype', 'scriptaculous', 'extjs');\r
+\r
+ const PART_COMPLETE = 0;\r
+ const PART_HEADER = 1;\r
+ const PART_FOOTER = 2;\r
+\r
+ // internal flags for JS-libraries\r
+ protected $addPrototype = FALSE;\r
+ protected $addScriptaculous = FALSE;\r
+ protected $addScriptaculousModules = array ('builder' => FALSE, 'effects' => FALSE, 'dragdrop' => FALSE, 'controls' => FALSE, 'slider' => FALSE);\r
+ protected $addExtJS = FALSE;\r
+ protected $addExtCore = FALSE;\r
+ protected $extJSadapter = 'ext/ext-base.js';\r
+\r
+ protected $enableExtJsDebug = FALSE;\r
+ protected $enableExtCoreDebug = FALSE;\r
+\r
+ // available adapters for extJs\r
+ const EXTJS_ADAPTER_JQUERY = 'jquery';\r
+ const EXTJS_ADAPTER_PROTOTYPE = 'prototype';\r
+ const EXTJS_ADAPTER_YUI = 'yui';\r
+\r
+ protected $enableExtJSQuickTips = false;\r
+\r
+ protected $inlineLanguageLabels = array ();\r
+ protected $inlineSettings = array ();\r
+\r
+ protected $inlineJavascriptWrap = array ();\r
+\r
+ // used by BE modules\r
+ public $backPath;\r
+\r
+ /**\r
+ * Constructor\r
+ *\r
+ * @param string $templateFile declare the used template file. Omit this parameter will use default template\r
+ * @param string $backPath relative path to typo3-folder. It varies for BE modules, in FE it will be typo3/\r
+ * @return void\r
+ */\r
+ public function __construct($templateFile = '', $backPath = '') {\r
+\r
+ $this->reset();\r
+\r
+ if (strlen($templateFile)) {\r
+ $this->templateFile = $templateFile;\r
+ }\r
+ $this->backPath = $backPath;\r
+ \r
+ $this->inlineJavascriptWrap = array(\r
+ '<script type="text/javascript">' . chr(10) . '/*<![CDATA[*/' . chr(10) . '<!-- ' . chr(10),\r
+ '// -->' . chr(10) . '/*]]>*/' . chr(10) . '</script>' . chr(10)\r
+ );\r
+ $this->inlineCssWrap = array(\r
+ '<style type="text/css">' . chr(10) . '/*<![CDATA[*/' . chr(10) . '<!-- ' . chr(10),\r
+ '-->' . chr(10) . '/*]]>*/' . chr(10) . '</style>' . chr(10)\r
+ );\r
+\r
+ }\r
+\r
+ /**\r
+ * reset all vars to initial values\r
+ * \r
+ * @return void\r
+ */\r
+ protected function reset() {\r
+ $this->templateFile = TYPO3_mainDir . 'templates/pagerender_be.html';\r
+ $this->jsFiles = array ();\r
+ $this->jsFooterFiles = array ();\r
+ $this->jsInline = array ();\r
+ $this->jsFooterInline = array ();\r
+ $this->jsLibs = array ();\r
+ $this->cssFiles = array ();\r
+ $this->cssInline = array ();\r
+ $this->metaTags = array ();\r
+ $this->inlineComments = array ();\r
+ $this->headerData = array ();\r
+ $this->footerData = array ();\r
+ $this->extOnReadyCode = array ();\r
+ }\r
+ /*****************************************************/\r
+ /* */\r
+ /* Public Setters */\r
+ /* */\r
+ /* */\r
+ /*****************************************************/\r
+\r
+ /**\r
+ * Sets the title\r
+ *\r
+ * @param string $title title of webpage\r
+ * @return void\r
+ */\r
+ public function setTitle($title) {\r
+ $this->title = $title;\r
+ }\r
+\r
+ /**\r
+ * Sets xml prolog and docType\r
+ *\r
+ * @param string $xmlPrologAndDocType complete tags for xml prolog and docType\r
+ * @return void\r
+ */\r
+ public function setXmlPrologAndDocType($xmlPrologAndDocType) {\r
+ $this->xmlPrologAndDocType = $xmlPrologAndDocType;\r
+ }\r
+\r
+ /**\r
+ * Sets meta charset\r
+ * @return void\r
+ *\r
+ * @param string $charSet used charset\r
+ */\r
+ public function setCharSet($charSet) {\r
+ $this->charSet = $charSet;\r
+ }\r
+\r
+ /**\r
+ * Sets html tag\r
+ *\r
+ * @param string $htmlTag html tag\r
+ * @return void\r
+ */\r
+ public function setHtmlTag($htmlTag) {\r
+ $this->htmlTag = $htmlTag;\r
+ }\r
+\r
+ /**\r
+ * Sets head tag\r
+ *\r
+ * @param string $tag head tag\r
+ * @return void\r
+ */\r
+ public function setHeadTag($headTag) {\r
+ $this->headTag = $headTag;\r
+ }\r
+\r
+ /**\r
+ * Sets favicon\r
+ *\r
+ * @param string $favIcon\r
+ * @return void\r
+ */\r
+ public function setFavIcon($favIcon) {\r
+ $this->favIcon = $favIcon;\r
+ }\r
+\r
+ /**\r
+ * Sets icon mime type\r
+ *\r
+ * @param string $iconMimeType\r
+ * @return void\r
+ */\r
+ public function setIconMimeType($iconMimeType) {\r
+ $this->iconMimeType = $iconMimeType;\r
+ }\r
+\r
+ /**\r
+ * Sets base url\r
+ *\r
+ * @param string $url\r
+ * @return void\r
+ */\r
+ public function setBaseUrl($baseUrl) {\r
+ $this->baseUrl = $baseUrl;\r
+ }\r
+\r
+ /**\r
+ * Sets template file\r
+ *\r
+ * @param string $file\r
+ * @return void\r
+ */\r
+ public function setTemplateFile($file) {\r
+ $this->templateFile = $file;\r
+ }\r
+\r
+ /**\r
+ * Sets Content for Body\r
+ *\r
+ * @param string $content\r
+ * @return void\r
+ */\r
+ public function setBodyContent($content) {\r
+ $this->bodyContent = $content;\r
+ }\r
+\r
+ /*****************************************************/\r
+ /* */\r
+ /* Public Enablers */\r
+ /* */\r
+ /* */\r
+ /*****************************************************/\r
+ /**\r
+ * Enables MoveJsFromHeaderToFooter\r
+ *\r
+ * @param void\r
+ * @return void\r
+ */\r
+ public function enableMoveJsFromHeaderToFooter() {\r
+ $this->moveJsFromHeaderToFooter = TRUE;\r
+ }\r
+\r
+ /**\r
+ * Enables compression of javascript\r
+ *\r
+ * @param void\r
+ * @return void\r
+ */\r
+ public function enableCompressJavascript() {\r
+ $this->compressJavascript = TRUE;\r
+ }\r
+\r
+ /**\r
+ * Enables compression of css\r
+ *\r
+ * @param void\r
+ * @return void\r
+ */\r
+ public function enableCompressCss() {\r
+ $this->compressCss = TRUE;\r
+ }\r
+\r
+ /**\r
+ /**\r
+ * Enables concatenation of js/css files\r
+ *\r
+ * @param void\r
+ * @return void\r
+ */\r
+ public function enableConcatenateFiles() {\r
+ $this->concatenateFiles = TRUE;\r
+ }\r
+\r
+ /**\r
+ * Sets removal of all line breaks in template\r
+ *\r
+ * @param void\r
+ * @return void\r
+ */\r
+ public function enableRemoveLineBreaksFromTemplate() {\r
+ $this->removeLineBreaksFromTemplate = TRUE;\r
+ }\r
+\r
+ /*****************************************************/\r
+ /* */\r
+ /* Public Getters */\r
+ /* */\r
+ /* */\r
+ /*****************************************************/\r
+\r
+ /**\r
+ * Gets the title\r
+ *\r
+ * @return string $title title of webpage\r
+ */\r
+ public function getTitle() {\r
+ return $this->title;\r
+ }\r
+\r
+ /**\r
+ * Gets the charSet\r
+ *\r
+ * @return string $charSet\r
+ */\r
+ public function getCharSet() {\r
+ return $this->charSet;\r
+ }\r
+\r
+ /**\r
+ * Gets html tag\r
+ *\r
+ * @return string $htmlTag html tag\r
+ */\r
+ public function getHtmlTag() {\r
+ return $this->htmlTag;\r
+ }\r
+\r
+ /**\r
+ * Gets head tag\r
+ *\r
+ * @return string $tag head tag\r
+ */\r
+ public function getHeadTag() {\r
+ return $this->headTag;\r
+ }\r
+\r
+ /**\r
+ * Gets favicon\r
+ *\r
+ * @return string $favIcon\r
+ */\r
+ public function getFavIcon() {\r
+ return $this->favIcon;\r
+ }\r
+\r
+ /**\r
+ * Gets icon mime type\r
+ *\r
+ * @return string $iconMimeType\r
+ */\r
+ public function getIconMimeType() {\r
+ return $this->iconMimeType;\r
+ }\r
+\r
+ /**\r
+ * Gets base url\r
+ *\r
+ * @return string $url\r
+ */\r
+ public function getBaseUrl() {\r
+ return $this->baseUrl;\r
+ }\r
+\r
+ /**\r
+ * Gets template file\r
+ *\r
+ * @return string $file\r
+ */\r
+ public function getTemplateFile($file) {\r
+ return $this->templateFile;\r
+ }\r
+\r
+ /**\r
+ * Gets MoveJsFromHeaderToFooter\r
+ *\r
+ * @return boolean \r
+ */\r
+ public function getMoveJsFromHeaderToFooter() {\r
+ return $this->moveJsFromHeaderToFooter;\r
+ }\r
+\r
+ /**\r
+ * Gets compress of javascript\r
+ *\r
+ * @return boolean \r
+ */\r
+ public function getCompressJavascript() {\r
+ return $this->compressJavascript;\r
+ }\r
+\r
+ /**\r
+ * Gets compress of css\r
+ *\r
+ * @return boolean \r
+ */\r
+ public function getCompressCss() {\r
+ return $this->compressCss;\r
+ }\r
+\r
+ /**\r
+ * Gets concatenate of files\r
+ *\r
+ * @return boolean \r
+ */\r
+ public function getConcatenateFiles() {\r
+ return $this->concatenateFiles;\r
+ }\r
+\r
+ /**\r
+ * Gets remove of empty lines from template\r
+ *\r
+ * @return boolean \r
+ */\r
+ public function getRemoveLineBreaksFromTemplate() {\r
+ return $this->removeLineBreaksFromTemplate;\r
+ }\r
+\r
+ /**\r
+ * Gets content for body\r
+ *\r
+ * @return string\r
+ */\r
+ public function getBodyContent() {\r
+ return $this->bodyContent;\r
+ }\r
+\r
+ /*****************************************************/\r
+ /* */\r
+ /* Public Function to add Data */\r
+ /* */\r
+ /* */\r
+ /*****************************************************/\r
+ \r
+ /**\r
+ * Adds meta data\r
+ *\r
+ * @param string $meta meta data (complete metatag)\r
+ * @return void\r
+ */\r
+ public function addMetaTag($meta) {\r
+ if (!in_array($meta, $this->metaTags)) {\r
+ $this->metaTags[] = $meta;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds inline HTML comment\r
+ *\r
+ * @param string $comment\r
+ * @return void\r
+ */\r
+ public function addInlineComment($comment) {\r
+ if (!in_array($comment, $this->inlineComments)) {\r
+ $this->inlineComments[] = $comment;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds header data\r
+ *\r
+ * @param string $data free header data for HTML header\r
+ * @return void\r
+ */\r
+ public function addHeaderData($data) {\r
+ if (!in_array($data, $this->headerData)) {\r
+ $this->headerData[] = $data;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds footer data\r
+ *\r
+ * @param string $data free header data for HTML header\r
+ * @return void\r
+ */\r
+ public function addFooterData($data) {\r
+ if (!in_array($data, $this->footerData)) {\r
+ $this->footerData[] = $data;\r
+ }\r
+ }\r
+\r
+ /* Javascript Files */\r
+ \r
+ /**\r
+ * Adds JS Library. JS Library block is rendered on top of the JS files.\r
+ *\r
+ * @param string $name\r
+ * @param string $file\r
+ * @param string $type\r
+ * @param boolean $compressed flag if library is compressed\r
+ * @param boolean $forceOnTop flag if added library should be inserted at begin of this block\r
+ * @param string $allWrap\r
+ * @return void\r
+ */\r
+ public function addJsLibrary($name, $file, $type = 'text/javascript', $compressed = TRUE, $forceOnTop = FALSE, $allWrap = '') {\r
+ if (!in_array(strtolower($name), $this->jsLibs)) {\r
+ $this->jsLibs[strtolower($name)] = array (\r
+ 'file' => $file, \r
+ 'type' => $type, \r
+ 'section' => self::PART_HEADER,\r
+ 'compressed' => $compressed, \r
+ 'forceOnTop' => $forceOnTop,\r
+ 'allWrap' => $allWrap\r
+ );\r
+ }\r
+ \r
+ }\r
+\r
+ /**\r
+ * Adds JS Library to Footer. JS Library block is rendered on top of the Footer JS files.\r
+ *\r
+ * @param string $name\r
+ * @param string $file\r
+ * @param string $type\r
+ * @param boolean $compressed flag if library is compressed\r
+ * @param boolean $forceOnTop flag if added library should be inserted at begin of this block\r
+ * @param string $allWrap\r
+ * @return void\r
+ */\r
+ public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compressed = TRUE, $forceOnTop = FALSE, $allWrap = '') {\r
+ if (!in_array(strtolower($name), $this->jsLibs)) {\r
+ $this->jsLibs[strtolower($name)] = array (\r
+ 'file' => $file, \r
+ 'type' => $type, \r
+ 'section' => self::PART_FOOTER,\r
+ 'compressed' => $compressed, \r
+ 'forceOnTop' => $forceOnTop,\r
+ 'allWrap' => $allWrap\r
+ );\r
+ }\r
+ \r
+ }\r
+\r
+ /**\r
+ * Adds JS file\r
+ *\r
+ * @param string $file\r
+ * @param string $type\r
+ * @param boolean $compressed\r
+ * @param boolean $forceOnTop\r
+ * @param string $allWrap\r
+ * @return void\r
+ */\r
+ public function addJsFile($file, $type = 'text/javascript', $compressed = FALSE, $forceOnTop = FALSE, $allWrap = '') {\r
+ if (!isset($this->jsFiles[$file])) {\r
+ $this->jsFiles[$file] = array (\r
+ 'type' => $type, \r
+ 'section' => self::PART_HEADER, \r
+ 'compressed' => $compressed, \r
+ 'forceOnTop' => $forceOnTop, \r
+ 'allWrap' => $allWrap\r
+ );\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds JS file to footer\r
+ *\r
+ * @param string $file\r
+ * @param string $type\r
+ * @param boolean $compressed\r
+ * @param boolean $forceOnTop\r
+ * @return void\r
+ */\r
+ public function addJsFooterFile($file, $type = 'text/javascript', $compressed = FALSE, $forceOnTop = FALSE, $allWrap = '') {\r
+ if (!isset($this->jsFiles[$file])) {\r
+ $this->jsFiles[$file] = array (\r
+ 'type' => $type, \r
+ 'section' => self::PART_FOOTER, \r
+ 'compressed' => $compressed, \r
+ 'forceOnTop' => $forceOnTop, \r
+ 'allWrap' => $allWrap\r
+ );\r
+ }\r
+ }\r
+\r
+ /*Javascript Inline Blocks */\r
+ \r
+ /**\r
+ * Adds JS inline code\r
+ *\r
+ * @param string $name\r
+ * @param string $block\r
+ * @param boolean $compressed\r
+ * @param boolean $forceOnTop\r
+ * @return void\r
+ */\r
+ public function addJsInlineCode($name, $block, $compressed = FALSE, $forceOnTop = FALSE) {\r
+ if (!isset($this->jsInline[$name])) {\r
+ $this->jsInline[$name] = array (\r
+ 'code' => $block . chr(10),\r
+ 'section' => self::PART_HEADER, \r
+ 'compressed' => $compressed,\r
+ 'forceOnTop' => $forceOnTop\r
+ );\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds JS inline code to footer\r
+ *\r
+ * @param string $name\r
+ * @param string $block\r
+ * @param boolean $compressed\r
+ * @param boolean $forceOnTop\r
+ * @return void\r
+ */\r
+ public function addJsFooterInlineCode($name, $block, $compressed = FALSE, $forceOnTop = FALSE) {\r
+ if (!isset($this->jsInline[$name])) {\r
+ $this->jsInline[$name] = array (\r
+ 'code' => $block . chr(10),\r
+ 'section' => self::PART_FOOTER,\r
+ 'compressed' => $compressed,\r
+ 'forceOnTop' => $forceOnTop\r
+ );\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds Ext.onready code, which will be wrapped in Ext.onReady(function() {...});\r
+ *\r
+ * @param string $block\r
+ * @return void\r
+ */\r
+ public function addExtOnReadyCode($block) {\r
+ if (!in_array($block, $this->extOnReadyCode)) {\r
+ $this->extOnReadyCode[] = $block;\r
+ }\r
+ }\r
+\r
+ /* CSS Files */\r
+ \r
+ /**\r
+ * Adds CSS file\r
+ *\r
+ * @param string $file\r
+ * @param string $rel\r
+ * @param string $media\r
+ * @param string $title\r
+ * @param boolean $compressed\r
+ * @param boolean $forceOnTop\r
+ * @return void\r
+ */\r
+ public function addCssFile($file, $rel = 'stylesheet', $media = 'screen', $title = '', $compressed = FALSE, $forceOnTop = FALSE, $allWrap = '') {\r
+ if (!isset($this->cssFiles[$file])) {\r
+ $this->cssFiles[$file] = array ('rel' => $rel, 'media' => $media, 'title' => $title, 'compressed' => $compressed, 'forceOnTop' => $forceOnTop, 'allWrap' => $allWrap);\r
+ }\r
+ }\r
+\r
+ /*CSS Inline Blocks */\r
+ \r
+ /**\r
+ * Adds CSS inline code\r
+ *\r
+ * @param string $name\r
+ * @param string $block\r
+ * @param boolean $compressed\r
+ * @param boolean $forceOnTop\r
+ * @return void\r
+ */\r
+ public function addCssInlineBlock($name, $block, $compressed = FALSE, $forceOnTop = FALSE) {\r
+ if (!isset($this->cssInline[$name])) {\r
+ $this->cssInline[$name] = array ('code' => $block, 'compressed' => $compressed, 'forceOnTop' => $forceOnTop);\r
+ }\r
+ }\r
+\r
+ /* JS Libraries */\r
+ \r
+ /**\r
+ * call function if you need the prototype library\r
+ *\r
+ * @return void\r
+ */\r
+ public function loadPrototype() {\r
+ $this->addPrototype = TRUE;\r
+ }\r
+\r
+ /**\r
+ * call function if you need the Scriptaculous library\r
+ *\r
+ * @param string $modules add modules you need. use "all" if you need complete modules\r
+ * @return void\r
+ */\r
+ public function loadScriptaculous($modules = '') {\r
+ // Scriptaculous require prototype, so load prototype too.\r
+ $this->addPrototype = TRUE;\r
+ $this->addScriptaculous = TRUE;\r
+ if ($modules) {\r
+ if ($modules == 'all') {\r
+ foreach ($this->addScriptaculousModules as $key => $value) {\r
+ $this->addScriptaculousModules[$key] = TRUE;\r
+ }\r
+ } else {\r
+ $mods = t3lib_div::trimExplode(',', $modules);\r
+ foreach ($mods as $mod) {\r
+ if (isset($this->addScriptaculousModules[strtolower($mod)])) {\r
+ $this->addScriptaculousModules[strtolower($mod)] = TRUE;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * call this function if you need the extJS library\r
+ *\r
+ * @param boolean $css flag, if set the ext-css will be loaded\r
+ * @param boolean $theme flag, if set the ext-theme "grey" will be loaded\r
+ * @param string $adapter choose alternative adapter, possible values: yui, prototype, jquery\r
+ * @return void\r
+ */\r
+ public function loadExtJS($css = TRUE, $theme = TRUE, $adapter = '') {\r
+ if ($adapter) {\r
+ // empty $adapter will always load the ext adapter\r
+ switch (t3lib_div::strtolower(trim($adapter))) {\r
+ case self::EXTJS_ADAPTER_YUI :\r
+ $this->extJSadapter = 'yui/ext-yui-adapter.js';\r
+ break;\r
+ case self::EXTJS_ADAPTER_PROTOTYPE :\r
+ $this->extJSadapter = 'prototype/ext-prototype-adapter.js';\r
+ break;\r
+ case self::EXTJS_ADAPTER_JQUERY :\r
+ $this->extJSadapter = 'jquery/ext-jquery-adapter.js';\r
+ break;\r
+ }\r
+ }\r
+ if (!$this->addExtJS) {\r
+ $this->addExtJS = TRUE;\r
+ if ($theme) {\r
+ if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {\r
+ $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'screen', '', FALSE, TRUE);\r
+ } else {\r
+ $this->addCssFile($this->backPath . 'contrib/extjs/resources/css/xtheme-blue.css', 'stylesheet', 'screen', '', FALSE, TRUE);\r
+ }\r
+ }\r
+ if ($css) {\r
+ if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {\r
+ $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'screen', '', FALSE, TRUE);\r
+ } else {\r
+ $this->addCssFile($this->backPath . 'contrib/extjs/resources/css/ext-all-notheme.css', 'stylesheet', 'screen', '', FALSE, TRUE);\r
+ }\r
+ }\r
+ \r
+ }\r
+ }\r
+\r
+ /**\r
+ * Enables ExtJs QuickTips\r
+ * Need extJs loaded\r
+ * \r
+ * @return void\r
+ * \r
+ */\r
+ public function enableExtJSQuickTips() {\r
+ $this->enableExtJSQuickTips = TRUE;\r
+ }\r
+\r
+\r
+ /**\r
+ * call function if you need the ExtCore library\r
+ *\r
+ * @return void\r
+ */\r
+ public function loadExtCore() {\r
+ $this->addExtCore = TRUE;\r
+ }\r
+\r
+ /** \r
+ * call this function to load debug version of ExtJS. Use this for development only\r
+ *\r
+ */\r
+ public function enableExtJsDebug() {\r
+ $this->enableExtJsDebug = TRUE;\r
+ }\r
+\r
+ /**\r
+ * call this function to load debug version of ExtCore. Use this for development only\r
+ *\r
+ * @return void\r
+ */\r
+ public function enableExtCoreDebug() {\r
+ $this->enableExtCoreDebug = TRUE;\r
+ }\r
+\r
+ /**\r
+ * Adds Javascript Inline Label. This will occur in TYPO3.lang - object\r
+ * The label can be used in scripts with TYPO3.lang.<key>\r
+ * Need extJs loaded\r
+ * \r
+ * @param string $key\r
+ * @param string $value\r
+ * @return void\r
+ */\r
+ public function addInlineLanguageLabel($key, $value) {\r
+ $this->inlineLanguageLabels[$key] = $value;\r
+ }\r
+\r
+ /**\r
+ * Adds Javascript Inline Label Array. This will occur in TYPO3.lang - object\r
+ * The label can be used in scripts with TYPO3.lang.<key>\r
+ * Array will be merged with existing array.\r
+ * Need extJs loaded \r
+ * \r
+ * @param array $array\r
+ * @return void\r
+ */\r
+ public function addInlineLanguageLabelArray(array $array) {\r
+ $this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $array);\r
+ }\r
+\r
+ /**\r
+ * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object\r
+ * The label can be used in scripts with TYPO3.setting.<key>\r
+ * Need extJs loaded \r
+ * \r
+ * @param string $namespace\r
+ * @param string $key\r
+ * @param string $value\r
+ * @return void\r
+ */\r
+ public function addInlineSetting($namespace, $key, $value) {\r
+ if ($namespace) {\r
+ if (strpos($namespace, '.')) {\r
+ $parts = explode('.', $namespace);\r
+ $a = &$this->inlineSettings;\r
+ foreach ($parts as $part) {\r
+ $a = &$a[$part];\r
+ }\r
+ $a[$key] = $value;\r
+ } else {\r
+ $this->inlineSettings[$namespace][$key] = $value;\r
+ }\r
+ } else {\r
+ $this->inlineSettings[$key] = $value;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds Javascript Inline Setting. This will occur in TYPO3.settings - object\r
+ * The label can be used in scripts with TYPO3.setting.<key>\r
+ * Array will be merged with existing array.\r
+ * Need extJs loaded \r
+ * \r
+ * @param string $namespace\r
+ * @param array $array\r
+ * @return void\r
+ */\r
+ public function addInlineSettingArray($namespace, array $array) {\r
+ if ($namespace) {\r
+ if (strpos($namespace, '.')) {\r
+ $parts = explode('.', $namespace);\r
+ $a = &$this->inlineSettings;\r
+ foreach ($parts as $part) {\r
+ $a = &$a[$part];\r
+ }\r
+ $a = array_merge((array) $a, $array);\r
+ } else {\r
+ $this->inlineSettings[$namespace] = array_merge((array) $this->inlineSettings[$namespace], $array);\r
+ }\r
+ } else {\r
+ $this->inlineSettings = array_merge($this->inlineSettings, $array);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds content to body content\r
+ *\r
+ * @param string $content\r
+ * @return void\r
+ */\r
+ public function addBodyContent($content) {\r
+ $this->bodyContent .= $content;\r
+ }\r
+\r
+ /*****************************************************/\r
+ /* */\r
+ /* Render Functions */\r
+ /* */\r
+ /* */\r
+ /*****************************************************/\r
+ \r
+ /**\r
+ * render the section (Header or Footer)\r
+ *\r
+ * @param int $part section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER\r
+ * @return string content of rendered section\r
+ */\r
+ public function render($part = self::PART_COMPLETE) {\r
+\r
+ $jsFiles = '';\r
+ $cssFiles = '';\r
+ $cssInline = '';\r
+ $jsInline = '';\r
+ $jsFooterInline = '';\r
+ $jsFooterLibs = '';\r
+ $jsFooterFiles = '';\r
+ $noJS = FALSE;\r
+\r
+ $jsLibs = $this->renderJsLibraries();\r
+\r
+ if ($this->compressCss || $this->compressJavascript) {\r
+ // do the file compression\r
+ $this->doCompress();\r
+ }\r
+ if ($this->concatenateFiles) {\r
+ // do the file concatenation\r
+ $this->doConcatenate();\r
+ }\r
+\r
+ $metaTags = implode(chr(10), $this->metaTags);\r
+\r
+ if (count($this->cssFiles)) {\r
+ foreach ($this->cssFiles as $file => $properties) {\r
+ $tag = '<link rel="' . $properties['rel'] . '" type="text/css" href="' . $file . '" media="' . $properties['media'] . '"' . ($properties['title'] ? ' title="' . $properties['title'] . '"' : '') . ' />';\r
+ if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {\r
+ $tag = str_replace('|', $tag, $properties['allWrap']);\r
+ }\r
+ if ($properties['forceOnTop']) {\r
+ $cssFiles = $tag . chr(10) . $cssFiles;\r
+ } else {\r
+ $cssFiles .= chr(10) . $tag;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (count($this->cssInline)) {\r
+ \r
+ foreach ($this->cssInline as $name => $properties) {\r
+ if ($properties['forceOnTop']) {\r
+ $cssInline = '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10) . $cssInline;\r
+ } else {\r
+ $cssInline .= '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10);\r
+ }\r
+ }\r
+ $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1];\r
+\r
+ }\r
+\r
+ if (count($this->jsLibs)) {\r
+ foreach ($this->jsLibs as $name => $properties) {\r
+ $tag = '<script src="' . $properties['file'] . '" type="' . $properties['type'] . '"></script>';\r
+ if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {\r
+ $tag = str_replace('|', $tag, $properties['allWrap']);\r
+ }\r
+ if ($properties['forceOnTop']) {\r
+ if ($properties['section'] === self::PART_HEADER) {\r
+ $jsLibs = $tag . chr(10) . $jsLibs;\r
+ } else {\r
+ $jsFooterLibs = $tag . chr(10) . $jsFooterLibs;\r
+ }\r
+ } else {\r
+ if ($properties['section'] === self::PART_HEADER) {\r
+ $jsLibs .= chr(10) . $tag;\r
+ } else {\r
+ $jsFooterLibs .= chr(10) . $tag;\r
+ }\r
+ }\r
+ \r
+ }\r
+ }\r
+\r
+ if (count($this->jsFiles)) {\r
+ foreach ($this->jsFiles as $file => $properties) {\r
+ $tag = '<script src="' . $file . '" type="' . $properties['type'] . '"></script>';\r
+ if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {\r
+ $tag = str_replace('|', $tag, $properties['allWrap']);\r
+ }\r
+ if ($properties['forceOnTop']) {\r
+ if ($properties['section'] === self::PART_HEADER) {\r
+ $jsFiles = $tag . chr(10) . $jsFiles;\r
+ } else {\r
+ $jsFooterFiles = $tag . chr(10) . $jsFooterFiles;\r
+ }\r
+ } else {\r
+ if ($properties['section'] === self::PART_HEADER) {\r
+ $jsFiles .= chr(10) . $tag;\r
+ } else {\r
+ $jsFooterFiles .= chr(10) . $tag;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (count($this->jsInline)) {\r
+ foreach ($this->jsInline as $name => $properties) {\r
+ if ($properties['forceOnTop']) {\r
+ if ($properties['section'] === self::PART_HEADER) {\r
+ $jsInline = '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10) . $jsInline; \r
+ } else {\r
+ $jsFooterInline = '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10) . $jsFooterInline;\r
+ }\r
+ } else {\r
+ if ($properties['section'] === self::PART_HEADER) {\r
+ $jsInline .= '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10);\r
+ } else {\r
+ $jsFooterInline .= '/*' . htmlspecialchars($name) . '*/' . chr(10) . $properties['code'] . chr(10);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ if ($jsInline) {\r
+ $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1];\r
+ }\r
+\r
+ if ($jsFooterInline) {\r
+ $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1];\r
+ }\r
+\r
+\r
+ // get template\r
+ $templateFile = t3lib_div::getFileAbsFileName($this->templateFile, TRUE);\r
+ $template = t3lib_div::getURL($templateFile);\r
+\r
+ if ($this->removeEmptyLinesFromTemplate) {\r
+ $template = strtr($template, array(chr(10) => '', chr(13) => ''));\r
+ }\r
+ if ($part != self::PART_COMPLETE) {\r
+ $templatePart = explode('###BODY###', $template);\r
+ $template = $templatePart[$part - 1];\r
+ }\r
+\r
+ if ($this->moveJsFromHeaderToFooter) {\r
+ $jsFooterLibs = $jsLibs . chr(10) . $jsFooterLibs;\r
+ $jsLibs = '';\r
+ $jsFooterFiles = $jsFiles . chr(10) . $jsFooterFiles;\r
+ $jsFiles = '';\r
+ $jsFooterInline = $jsInline . chr(10) . $jsFooterInline;\r
+ $jsInline = '';\r
+ } \r
+\r
+ $markerArray = array(\r
+ 'XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType, \r
+ 'HTMLTAG' => $this->htmlTag, \r
+ 'HEADTAG' => $this->headTag, \r
+ 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '', \r
+ 'INLINECOMMENT' => $this->inlineComments ? chr(10) . chr(10) . '<!-- ' . chr(10) . implode(chr(10), $this->inlineComments) . '-->' . chr(10) . chr(10) : '', \r
+ 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '',\r
+ 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '', \r
+ 'CSS_INCLUDE' => $cssFiles, \r
+ 'CSS_INLINE' => $cssInline, \r
+ 'JS_INLINE' => $jsInline, \r
+ 'JS_INCLUDE' => $jsFiles, \r
+ 'JS_LIBS' => $jsLibs, \r
+ 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '', \r
+ 'META' => $metaTags, \r
+ 'HEADERDATA' => $this->headerData ? implode(chr(10), $this->headerData) : '', \r
+ 'FOOTERDATA' => $this->footerData ? implode(chr(10), $this->footerData) : '', \r
+ 'JS_LIBS_FOOTER' => $jsFooterLibs, \r
+ 'JS_INCLUDE_FOOTER' => $jsFooterFiles, \r
+ 'JS_INLINE_FOOTER' => $jsFooterInline,\r
+ 'BODY' => $this->bodyContent, \r
+ );\r
+\r
+ $markerArray = array_map('trim', $markerArray);\r
+\r
+ $this->reset();\r
+ return trim(t3lib_parsehtml::substituteMarkerArray($template, $markerArray, '###|###'));\r
+ }\r
+\r
+ /**\r
+ * helper function for render the javascript libraries\r
+ *\r
+ * @return string content with javascript libraries\r
+ */\r
+ protected function renderJsLibraries() {\r
+ $out = '';\r
+\r
+ if ($this->addPrototype) {\r
+ $out .= '<script src="' . $this->backPath . 'contrib/prototype/prototype.js" type="text/javascript"></script>' . chr(10);\r
+ unset($this->jsFiles[$this->backPath . 'contrib/prototype/prototype.js']);\r
+ }\r
+\r
+ if ($this->addScriptaculous) {\r
+ $mods = array ();\r
+ foreach ($this->addScriptaculousModules as $key => $value) {\r
+ if ($this->addScriptaculousModules[$key]) {\r
+ $mods[] = $key;\r
+ }\r
+ }\r
+ // resolve dependencies\r
+ if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {\r
+ $mods = array_merge(array('effects'), $mods);\r
+ }\r
+\r
+ if (count($mods)) {\r
+ $moduleLoadString = '?load=' . implode(',', $mods);\r
+ }\r
+\r
+ $out .= '<script src="' . $this->backPath . 'contrib/scriptaculous/scriptaculous.js' . $moduleLoadString . '" type="text/javascript"></script>' . chr(10);\r
+ unset($this->jsFiles[$this->backPath . 'contrib/scriptaculous/scriptaculous.js' . $moduleLoadString]);\r
+ }\r
+\r
+ // include extCore\r
+ if ($this->addExtCore) {\r
+ $out .= '<script src="' . $this->backPath . 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js" type="text/javascript"></script>' . chr(10);\r
+ unset($this->jsFiles[$this->backPath . 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js']);\r
+ }\r
+\r
+ // include extJS\r
+ if ($this->addExtJS) {\r
+ // use the base adapter all the time\r
+ $out .= '<script src="' . $this->backPath . 'contrib/extjs/adapter/' . $this->extJSadapter . '" type="text/javascript"></script>' . chr(10);\r
+ $out .= '<script src="' . $this->backPath . 'contrib/extjs/ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js" type="text/javascript"></script>' . chr(10);\r
+\r
+ // add extJS localization\r
+ $localeMap = $this->csConvObj->isoArray; // load standard ISO mapping and modify for use with ExtJS\r
+ $localeMap[''] = 'en';\r
+ $localeMap['default'] = 'en';\r
+ $localeMap['gr'] = 'el_GR'; // Greek\r
+ $localeMap['no'] = 'no_BO'; // Norwegian Bokmaal\r
+ $localeMap['se'] = 'se_SV'; // Swedish\r
+\r
+\r
+ $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;\r
+ // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!\r
+ $extJsLocaleFile = 'contrib/extjs/locale/ext-lang-' . $extJsLang . '-min.js';\r
+ if (file_exists(PATH_typo3 . $extJsLocaleFile)) {\r
+ $out .= '<script src="' . $this->backPath . $extJsLocaleFile . '" type="text/javascript"></script>' . chr(10);\r
+ }\r
+\r
+\r
+ // remove extjs from JScodeLibArray\r
+ unset(\r
+ $this->jsFiles[$this->backPath . 'contrib/extjs/ext-all.js'], $this->jsFiles[$this->backPath . 'contrib/extjs/ext-all-debug.js']\r
+ );\r
+ }\r
+ if ($this->addExtCore || $this->addExtJS) {\r
+ // set clear.gif, move it on top, add handler code\r
+ $code = '';\r
+ if (count($this->extOnReadyCode)) {\r
+ foreach ($this->extOnReadyCode as $block) {\r
+ $code .= $block;\r
+ }\r
+ }\r
+\r
+ $out .= $this->inlineJavascriptWrap[0] . '\r
+ Ext.ns("TYPO3");\r
+ Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . chr(10) . \r
+ 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' . 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' .\r
+ 'Ext.onReady(function() {' .\r
+ ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . chr(10) : '') . $code .\r
+ ' });' . $this->inlineJavascriptWrap[1];\r
+ unset ($this->extOnReadyCode);\r
+ }\r
+\r
+ return $out;\r
+ }\r
+\r
+ /*****************************************************/\r
+ /* */\r
+ /* Tools */\r
+ /* */\r
+ /* */\r
+ /*****************************************************/\r
+ \r
+ /**\r
+ * concatenate files into one file\r
+ * registered handler\r
+ * TODO: implement own method\r
+ *\r
+ * @return void\r
+ */\r
+ protected function doConcatenate() {\r
+ // traverse the arrays, concatenate in one file\r
+ // then remove concatenated files from array and add the concatenated file\r
+\r
+\r
+ // extern concatination\r
+ if ($this->concatenateFiles && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['concatenateHandler']) {\r
+ // use extern concatenate routine\r
+ $params = array (\r
+ 'jsLibs' => &$this->jsLibs, \r
+ 'jsFiles' => &$this->jsFiles, \r
+ 'jsFooterFiles' => &$this->jsFiles, \r
+ 'cssFiles' => &$this->cssFiles,\r
+ );\r
+ t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['concatenateHandler'], $params, $this);\r
+ } else {\r
+ // own method, nothing implemented atm\r
+\r
+\r
+ }\r
+ }\r
+\r
+ /**\r
+ * compress inline code\r
+ *\r
+ */\r
+ protected function doCompress() {\r
+\r
+ if ($this->compressJavascript && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler']) {\r
+ // use extern compress routine\r
+ $params = array (\r
+ 'jsInline' => &$this->jsInline, \r
+ 'jsFooterInline' => &$this->jsFooterInline\r
+ );\r
+ t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['jsCompressHandler'], $params, $this);\r
+ } else {\r
+ // traverse the arrays, compress files\r
+ $this->compressError = '';\r
+ \r
+ if ($this->compressJavascript) {\r
+ if (count($this->jsInline)) {\r
+ foreach ($this->jsInline as $name => $properties) {\r
+ if (!$properties['compressed']) {\r
+ $error = '';\r
+ $this->jsInline[$name]['code'] = t3lib_div::minifyJavaScript($properties['code'], $error);\r
+ if ($error) {\r
+ $this->compressError .= 'Error with minify JS Inline Block "' . $name . '": ' . $error . chr(10);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if ($this->compressCss && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler']) {\r
+ // use extern compress routine\r
+ $params = array (\r
+ 'cssInline' => &$this->cssInline\r
+ );\r
+ t3lib_div::callUserFunction($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['cssCompressHandler'], $params, $this);\r
+ } else {\r
+ if ($this->compressCss) {\r
+ // own method, nothing implemented atm\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
+\r
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pagerender.php']) {\r
+ include_once ($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pagerender.php']);\r
+}\r
+?>
\ No newline at end of file
't3lib_matchcondition' => PATH_t3lib . 'class.t3lib_matchcondition.php',
't3lib_modsettings' => PATH_t3lib . 'class.t3lib_modsettings.php',
't3lib_pageselect' => PATH_t3lib . 'class.t3lib_page.php',
+ 't3lib_pagerender' => PATH_t3lib . 'class.t3lib_pagerender.php',
't3lib_pageselect_getpagehook' => PATH_t3lib . 'interfaces/interface.t3lib_pageselect_getpagehook.php',
't3lib_pagetree' => PATH_t3lib . 'class.t3lib_pagetree.php',
't3lib_parsehtml' => PATH_t3lib . 'class.t3lib_parsehtml.php',
* @package TYPO3
* @subpackage tslib
*/
- class tslib_fe {
+ class tslib_fe extends t3lib_pageRender {
// CURRENT PAGE:
var $id=''; // The page id (int)
}
$this->initCaches();
+ parent::__construct(TYPO3_mainDir . 'templates/pagerender_fe.html');
}
/**
$this->config['FEData'] = $this->tmpl->setup['FEData'];
$this->config['FEData.'] = $this->tmpl->setup['FEData.'];
+
+ // class for render Header and Footer parts
+ $template = '';
+ if ($this->pSetup['pageHeaderFooterTemplateFile']) {
+ $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
+ if ($file) {
+ $this->setTemplateFile($file);
+ }
+ }
+
}
$GLOBALS['TT']->pull();
} else {
* @return void
*/
public static function renderContentWithHeader($pageContent) {
+
+ $GLOBALS['TSFE']->backPath = 'typo3/';
+
+ if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) {
+ $GLOBALS['TSFE']->enableMoveJsFromHeaderToFooter();
+ }
+
+ if ($GLOBALS['TSFE']->config['config']['pageRenderTemplateFile']) {
+ $file = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->config['config']['pageRenderTemplateFile']);
+ if ($file) {
+ $GLOBALS['TSFE']->setTemplateFile($file);
+ }
+ }
+
$customContent = $GLOBALS['TSFE']->config['config']['headerComment'];
- if (trim($customContent)) {
- $customContent = chr(10).$customContent;
- } else $customContent='';
+ if (trim($customContent)) {
+ $GLOBALS['TSFE']->addInlineComment($customContent);
+ }
// Setting charset:
$theCharset = $GLOBALS['TSFE']->metaCharset;
// Reset the content variables:
- $GLOBALS['TSFE']->content='';
- $htmlTagAttributes = array();
+ $GLOBALS['TSFE']->content = '';
+ $htmlTagAttributes = array ();
$htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
// Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
- if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
+ if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
$htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
}
// Setting document type:
- $docTypeParts = array();
- // Part 1: XML prologue
- switch((string)$GLOBALS['TSFE']->config['config']['xmlprologue']) {
- case 'none':
- break;
- case 'xml_10':
- $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
- break;
- case 'xml_11':
- $docTypeParts[]='<?xml version="1.1" encoding="'.$theCharset.'"?>';
- break;
- case '':
- if ($GLOBALS['TSFE']->xhtmlVersion) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
- break;
- default:
- $docTypeParts[]=$GLOBALS['TSFE']->config['config']['xmlprologue'];
+ $docTypeParts = array ();
+ // Part 1: XML prologue
+ switch ((string) $GLOBALS['TSFE']->config['config']['xmlprologue']) {
+ case 'none' :
+ break;
+ case 'xml_10' :
+ $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
+ break;
+ case 'xml_11' :
+ $docTypeParts[] = '<?xml version="1.1" encoding="' . $theCharset . '"?>';
+ break;
+ case '' :
+ if ($GLOBALS['TSFE']->xhtmlVersion)
+ $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
+ break;
+ default :
+ $docTypeParts[] = $GLOBALS['TSFE']->config['config']['xmlprologue'];
}
- // Part 2: DTD
- if ($GLOBALS['TSFE']->config['config']['doctype']) {
- switch((string)$GLOBALS['TSFE']->config['config']['doctype']) {
- case 'xhtml_trans':
- $docTypeParts[]='<!DOCTYPE html
+ // Part 2: DTD
+ if ($GLOBALS['TSFE']->config['config']['doctype']) {
+ switch ((string) $GLOBALS['TSFE']->config['config']['doctype']) {
+ case 'xhtml_trans' :
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
- break;
- case 'xhtml_strict':
- $docTypeParts[]='<!DOCTYPE html
+ break;
+ case 'xhtml_strict' :
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
- break;
- case 'xhtml_frames':
- $docTypeParts[]='<!DOCTYPE html
+ break;
+ case 'xhtml_frames' :
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
- break;
- case 'xhtml_basic':
- $docTypeParts[]='<!DOCTYPE html
+ break;
+ case 'xhtml_basic' :
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
- break;
- case 'xhtml_11':
- $docTypeParts[]='<!DOCTYPE html
+ break;
+ case 'xhtml_11' :
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
- break;
- case 'xhtml_2':
- $docTypeParts[]='<!DOCTYPE html
+ break;
+ case 'xhtml_2' :
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 2.0//EN"
"http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
- break;
- case 'none':
- break;
- default:
+ break;
+ case 'none' :
+ break;
+ default :
$docTypeParts[] = $GLOBALS['TSFE']->config['config']['doctype'];
}
} else {
- $docTypeParts[]='<!DOCTYPE html
+ $docTypeParts[] = '<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
}
- if ($GLOBALS['TSFE']->xhtmlVersion) {
-
- // Setting <html> tag attributes:
- $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
+ if ($GLOBALS['TSFE']->xhtmlVersion) {
+
+ // Setting <html> tag attributes:
+ $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
$htmlTagAttributes['xml:lang'] = $htmlLang;
- if ($GLOBALS['TSFE']->xhtmlVersion < 110) {
- $htmlTagAttributes['lang'] = $htmlLang;
+ if ($GLOBALS['TSFE']->xhtmlVersion < 110) {
+ $htmlTagAttributes['lang'] = $htmlLang;
}
}
// Swap XML and doctype order around (for MSIE / Opera standards compliance)
- if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
+ if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
$docTypeParts = array_reverse($docTypeParts);
}
// Adding doctype parts:
- $GLOBALS['TSFE']->content.= count($docTypeParts) ? implode(chr(10),$docTypeParts).chr(10) : '';
+ if (count($docTypeParts)) {
+ $GLOBALS['TSFE']->setXmlPrologAndDocType(implode(chr(10), $docTypeParts));
+ }
// Begin header section:
- if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'],'none')) {
+ if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'], 'none')) {
$_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeAttributes($htmlTagAttributes);
} else {
$_attr = '';
}
- $GLOBALS['TSFE']->content.='<html'.($_attr ? ' '.$_attr : '').'>';
+ $GLOBALS['TSFE']->setHtmlTag('<html' . ($_attr ? ' ' . $_attr : '') . '>');
// Head tag:
$headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
- $GLOBALS['TSFE']->content.= chr(10).$headTag;
+ $GLOBALS['TSFE']->setHeadTag($headTag);
// Setting charset meta tag:
- $GLOBALS['TSFE']->content.='
- <meta http-equiv="Content-Type" content="text/html; charset='.$theCharset.'" />';
-
- $GLOBALS['TSFE']->content.='
+ $GLOBALS['TSFE']->setCharSet($theCharset);
-<!-- '.($customContent?$customContent.chr(10):'').'
+ $GLOBALS['TSFE']->addInlineComment('
This website is powered by TYPO3 - inspiring people to share!
TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
TYPO3 is copyright 1998-2009 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
Information and contribution at http://typo3.com/ and http://typo3.org/
--->
-';
-
+');
if ($GLOBALS['TSFE']->baseUrl) {
- $GLOBALS['TSFE']->content.='
- <base href="'.htmlspecialchars($GLOBALS['TSFE']->baseUrl).'" />';
+ $GLOBALS['TSFE']->setBaseUrl($GLOBALS['TSFE']->baseUrl);
}
if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
if (($finfo = @finfo_open(FILEINFO_MIME))) {
$iconMimeType = ' type="' . finfo_file($finfo, $favIcon) . '"';
finfo_close($finfo);
+ $GLOBALS['TSFE']->setIconMimeType($iconMimeType);
}
}
-
- $GLOBALS['TSFE']->content.= '
- <link rel="shortcut icon" href="'.htmlspecialchars($favIcon).'"'.$iconMimeType.' />
- <link rel="icon" href="'.htmlspecialchars($favIcon).'"'.$iconMimeType.' />';
+ $GLOBALS['TSFE']->setFavIcon($favIcon);
+
}
// Including CSS files
- if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
- $temp_styleLines=array();
- foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key=>$iCSScode) {
- if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
- $temp_styleLines[]='/* default styles for extension "'.substr($key,0,-1).'" */'.chr(10).$iCSScode['_CSS_DEFAULT_STYLE'];
+ if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
+ $temp_styleLines = array ();
+ foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key => $iCSScode) {
+ if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
+ $temp_styleLines[] = '/* default styles for extension "' . substr($key, 0, - 1) . '" */' . chr(10) . $iCSScode['_CSS_DEFAULT_STYLE'];
}
}
- if (count($temp_styleLines)) {
- if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
- $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile(implode(chr(10),$temp_styleLines),'css');
+ if (count($temp_styleLines)) {
+ if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
+ $GLOBALS['TSFE']->addCssFile(TSpagegen::inline2TempFile(implode(chr(10), $temp_styleLines), 'css'));
} else {
- $GLOBALS['TSFE']->content.='
- <style type="text/css">
- /*<![CDATA[*/
- <!--
- '.implode(chr(10),$temp_styleLines).'
- -->
- /*]]>*/
- </style>';
+ $GLOBALS['TSFE']->addCssInlineBlock('TSFEinlineStyle', implode(chr(10), $temp_styleLines));
}
}
}
- if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
+ if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
$ss = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
- if ($ss) {
- $GLOBALS['TSFE']->content.='
- <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($ss).'" />';
- }
- }
- if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
- foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key=>$iCSSfile) {
- if (!is_array($iCSSfile)) {
- $ss=$GLOBALS['TSFE']->tmpl->getFileName($iCSSfile);
- if ($ss) {
- if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['import']) {
- if (substr($ss,0,1)!='/') { // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
- $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/'.$ss;
+ if ($ss) {
+ $GLOBALS['TSFE']->addCssFile($ss);
+ }
+ }
+
+ /**********************************************************************/
+ /* includeCSS
+ /* config.includeCSS {
+ /*
+ /* }
+ /**********************************************************************/
+
+ if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
+ foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key => $CSSfile) {
+ if (! is_array($CSSfile)) {
+ $ss = $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external'] ? $CSSfile : $GLOBALS['TSFE']->tmpl->getFileName($CSSfile);
+ if ($ss) {
+ if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['import']) {
+ if (! $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external'] && substr($ss, 0, 1) != '/') { // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
+ $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
}
- $GLOBALS['TSFE']->content.='
- <style type="text/css">
- <!--
- @import url("'.htmlspecialchars($ss).'") '.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).';
- -->
- </style>
- ';
+ $GLOBALS['TSFE']->addCssInlineBlock(
+ 'import_' . $key,
+ '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media']) . ';',
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compressed'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
+ ''
+ );
} else {
- $GLOBALS['TSFE']->content.='
- <link rel="'.($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['alternate'] ? 'alternate stylesheet' : 'stylesheet').'" type="text/css" href="'.htmlspecialchars($ss).'"'.
- ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title'] ? ' title="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title']).'"' : '').
- ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media'] ? ' media="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).'"' : '').
- ' />';
+ $GLOBALS['TSFE']->addCssFile(
+ htmlspecialchars($ss),
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['alternate'] ? 'alternate stylesheet' : 'stylesheet',
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] : 'screen',
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] : '',
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compressed'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap']);
+
}
}
}
}
// Stylesheets
- $style='';
- $style.=trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']).chr(10);
-
- if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
+ $style = '';
+ if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
$pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
$RTEclasses = $pageTSConfig['RTE.']['classes.'];
- if (is_array($RTEclasses)) {
- foreach ($RTEclasses as $RTEclassName=>$RTEvalueArray) {
- if ($RTEvalueArray['value']) {
- $style.='
-.'.substr($RTEclassName,0,-1).' {'.$RTEvalueArray['value'].'}';
+ if (is_array($RTEclasses)) {
+ foreach ($RTEclasses as $RTEclassName => $RTEvalueArray) {
+ if ($RTEvalueArray['value']) {
+ $style .= '
+.' . substr($RTEclassName, 0, - 1) . ' {' . $RTEvalueArray['value'] . '}';
}
}
}
- if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
- $mSOa_tList = t3lib_div::trimExplode(',',strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']),1);
- foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key=>$mSOa_value) {
- if (!is_array($mSOa_value) && (in_array('*',$mSOa_tList)||in_array($mSOa_key,$mSOa_tList))) {
- $style.='
-'.$mSOa_key.' {'.$mSOa_value.'}';
+ if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
+ $mSOa_tList = t3lib_div::trimExplode(',', strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']), 1);
+ foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key => $mSOa_value) {
+ if (! is_array($mSOa_value) && (in_array('*', $mSOa_tList) || in_array($mSOa_key, $mSOa_tList))) {
+ $style .= '
+' . $mSOa_key . ' {' . $mSOa_value . '}';
}
}
}
}
// Setting body tag margins in CSS:
- if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
+ if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
$margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
- $style.='
- BODY {margin: '.$margins.'px '.$margins.'px '.$margins.'px '.$margins.'px;}';
+ $style .= '
+ BODY {margin: ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px;}';
}
- if ($GLOBALS['TSFE']->pSetup['noLinkUnderline']) {
+ if ($GLOBALS['TSFE']->pSetup['noLinkUnderline']) {
$GLOBALS['TSFE']->logDeprecatedTyposcript('config.noLinkUnderline');
- $style.='
+ $style .= '
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: none}';
}
- if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
+ if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
$GLOBALS['TSFE']->logDeprecatedTyposcript('config.hover');
- $style.='
- A:hover {color: '.trim($GLOBALS['TSFE']->pSetup['hover']).';}';
+ $style .= '
+ A:hover {color: ' . trim($GLOBALS['TSFE']->pSetup['hover']) . ';}';
}
- if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
+ if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
$GLOBALS['TSFE']->logDeprecatedTyposcript('config.hoverStyle');
- $style.='
- A:hover {'.trim($GLOBALS['TSFE']->pSetup['hoverStyle']).'}';
+ $style .= '
+ A:hover {' . trim($GLOBALS['TSFE']->pSetup['hoverStyle']) . '}';
}
- if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
+ if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
$GLOBALS['TSFE']->logDeprecatedTyposcript('config.smallFormFields');
- $style.='
+ $style .= '
SELECT { font-family: Verdana, Arial, Helvetica; font-size: 10px }
TEXTAREA { font-family: Verdana, Arial, Helvetica; font-size: 10px}
INPUT { font-family: Verdana, Arial, Helvetica; font-size: 10px }';
}
- if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
- $style.='
+ if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
+ $style .= '
/* Default styles for the Admin Panel */
TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
TABLE.typo3-editPanel TD { border: 0px; }
';
}
+ // CSS_inlineStyle from TS
+ $style .= trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']);
+ $style .= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['cssInline.'], 'cssInline.');
- if (trim($style)) {
- if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
- $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($style, 'css');
+ if (trim($style)) {
+ if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
+ $GLOBALS['TSFE']->addCssFile(TSpagegen::inline2TempFile($style, 'css'));
} else {
- $GLOBALS['TSFE']->content.='
- <style type="text/css">
- /*<![CDATA[*/
- <!--'.$style.'
- -->
- /*]]>*/
- </style>';
+ $GLOBALS['TSFE']->addCssInlineBlock('additionalTSFEInlineStyle', $style);
}
}
- // JavaScript files
- if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
- foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key=>$JSfile) {
- if (!is_array($JSfile)) {
- $ss = $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
- if ($ss) {
- $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['type'];
- if (!$type) $type = 'text/javascript';
-
- $GLOBALS['TSFE']->content.='
- <script src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss) . '" type="' . htmlspecialchars($type) . '"></script>';
- }
+ // Javascript Libraries
+ if (is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.'])) {
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Prototype']) {
+ $GLOBALS['TSFE']->loadPrototype();
+ }
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous']) {
+ $modules = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] : '';
+ $GLOBALS['TSFE']->loadScriptaculous($modules);
+ }
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore']) {
+ $GLOBALS['TSFE']->loadExtCore();
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore.']['debug']) {
+ $GLOBALS['TSFE']->enableExtCoreDebug();
+ }
+ }
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) {
+ $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE;
+ $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE;
+ $adapter = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] : '';
+ $GLOBALS['TSFE']->loadExtJs($css, $theme, $adapter);
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['debug']) {
+ $GLOBALS['TSFE']->enableExtJsDebug();
+ }
+ if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['quickTips']) {
+ $GLOBALS['TSFE']->enableExtJSQuickTips();
}
}
}
+ // JavaScript library files
+ if (is_array($GLOBALS['TSFE']->pSetup['includeJSlibs.'])) {
+ foreach ($GLOBALS['TSFE']->pSetup['includeJSlibs.'] as $key => $JSfile) {
+ $ss = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
+ if ($ss) {
+ $type = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['type'];
+ if (! $type) {
+ $type = 'text/javascript';
+ }
+ $GLOBALS['TSFE']->addJsLibrary(
+ htmlspecialchars($key),
+ htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
+ htmlspecialchars($type),
+ $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['compressed'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap']
+ );
+ }
+
+ }
+ }
+ if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'])) {
+ foreach ($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'] as $key => $JSfile) {
+ $ss = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
+ if ($ss) {
+ $type = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['type'];
+ if (! $type) {
+ $type = 'text/javascript';
+ }
+ $GLOBALS['TSFE']->addJsFooterLibrary(
+ htmlspecialchars($key),
+ htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
+ htmlspecialchars($type),
+ $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['compressed'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap']
+ );
+ }
+
+ }
+ }
+ // JavaScript files
+ if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
+ foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) {
+ if (!is_array($JSfile)) {
+ $ss = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
+ if ($ss) {
+ $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['type'];
+ if (! $type) {
+ $type = 'text/javascript';
+ }
+ $GLOBALS['TSFE']->addJsFile(
+ htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
+ htmlspecialchars($type),
+ $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['compressed'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
+ );
+ }
+ }
+ }
+ }
+ if (is_array($GLOBALS['TSFE']->pSetup['includeFooterJS.'])) {
+ foreach ($GLOBALS['TSFE']->pSetup['includeFooterJS.'] as $key => $JSfile) {
+ if (!is_array($JSfile)) {
+ $ss = $GLOBALS['TSFE']->pSetup['includeFooterJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
+ if ($ss) {
+ $type = $GLOBALS['TSFE']->pSetup['includeFooterJS.'][$key . '.']['type'];
+ if (! $type) {
+ $type = 'text/javascript';
+ }
+ $GLOBALS['TSFE']->addJsFooterFile(
+ htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
+ htmlspecialchars($type),
+ $GLOBALS['TSFE']->pSetup['includeFooterJS.'][$key . '.']['compressed'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
+ $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
+ );
+ }
+ }
+ }
+ }
// Headerdata
- if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
- $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'],'headerData.');
+ if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
+ $GLOBALS['TSFE']->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.'));
+ }
+
+ // Footerdata
+ if (is_array($GLOBALS['TSFE']->pSetup['footerData.'])) {
+ $GLOBALS['TSFE']->addFooterData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['footerData.'], 'footerData.'));
}
// Title
- $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle(
- $GLOBALS['TSFE']->altPageTitle?$GLOBALS['TSFE']->altPageTitle:$GLOBALS['TSFE']->page['title'],
- $GLOBALS['TSFE']->config['config']['noPageTitle'],
- $GLOBALS['TSFE']->config['config']['pageTitleFirst']
- );
- if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
- $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array(), $titleTagContent);
+ $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle($GLOBALS['TSFE']->altPageTitle ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'], $GLOBALS['TSFE']->config['config']['noPageTitle'], $GLOBALS['TSFE']->config['config']['pageTitleFirst']);
+ if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
+ $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array (), $titleTagContent);
}
- if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle'])!==2) {
- $GLOBALS['TSFE']->content.='
- <title>'.htmlspecialchars($titleTagContent).'</title>';
+ if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {
+ $GLOBALS['TSFE']->setTitle($titleTagContent);
}
- $GLOBALS['TSFE']->content.='
- <meta name="generator" content="TYPO3 '.TYPO3_branch.' CMS" />';
- $conf=$GLOBALS['TSFE']->pSetup['meta.'];
- if (is_array($conf)) {
+ $GLOBALS['TSFE']->addMetaTag('<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS" />');
+
+ $conf = $GLOBALS['TSFE']->pSetup['meta.'];
+ if (is_array($conf)) {
foreach ($conf as $theKey => $theValue) {
- if (!strstr($theKey,'.') || !isset($conf[substr($theKey,0,-1)])) { // Only if 1) the property is set but not the value itself, 2) the value and/or any property
- if (strstr($theKey,'.')) {
- $theKey = substr($theKey,0,-1);
+ if (! strstr($theKey, '.') || ! isset($conf[substr($theKey, 0, - 1)])) { // Only if 1) the property is set but not the value itself, 2) the value and/or any property
+ if (strstr($theKey, '.')) {
+ $theKey = substr($theKey, 0, - 1);
}
- $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey],$conf[$theKey.'.']);
+ $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey], $conf[$theKey . '.']);
$key = $theKey;
- if (trim($val)) {
- $a='name';
- if (strtolower($key)=='refresh') {$a='http-equiv';}
- $GLOBALS['TSFE']->content.= '
- <meta '.$a.'="'.$key.'" content="'.htmlspecialchars(trim($val)).'" />';
+ if (trim($val)) {
+ $a = 'name';
+ if (strtolower($key) == 'refresh') {
+ $a = 'http-equiv';
+ }
+ $GLOBALS['TSFE']->addMetaTag('<meta ' . $a . '="' . $key . '" content="' . htmlspecialchars(trim($val)) . '" />');
}
}
}
unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
- if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
- // Storing the JSCode and JSImgCode vars...
+ if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
+ // Storing the JSCode and JSImgCode vars...
$GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
$GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
- $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
- $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
- $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
+ $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
+ $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
+ $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
- $GLOBALS['TSFE']->additionalHeaderData = array('<!--HD_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->'); // Clearing the array
- $GLOBALS['TSFE']->divSection.= '<!--TDS_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->';
+
+ $GLOBALS['TSFE']->additionalHeaderData = array ('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->'); // Clearing the array
+ $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
} else {
$GLOBALS['TSFE']->INTincScript_loadJSCode();
}
$JSef = TSpagegen::JSeventFunctions();
// Adding default Java Script:
- $_scriptCode = '
+ $scriptJsCode = '
var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
var version = "";
' . $JSef[0];
if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
- $_scriptCode.= '
+ $scriptJsCode .= '
// decrypt helper function
function decryptCharcode(n,start,end,offset) {
n = n + offset;
}
// decrypt spam-protected emails
function linkTo_UnCryptMailto(s) {
- location.href = decryptString(s,'.($GLOBALS['TSFE']->spamProtectEmailAddresses*-1).');
+ location.href = decryptString(s,' . ($GLOBALS['TSFE']->spamProtectEmailAddresses * - 1) . ');
}
';
}
//add inline JS
- $_inlineJS = '';
- // defined in TS with page.inlineJS
- if (is_array($GLOBALS['TSFE']->pSetup['inlineJS.'])) {
- $GLOBALS['TSFE']->inlineJS[]= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['inlineJS.'],'inlineJS.');
- }
+ $inlineJS = '';
+
// defined in php
- if(is_array($GLOBALS['TSFE']->inlineJS)) {
- foreach($GLOBALS['TSFE']->inlineJS as $key=>$val) {
- if(!is_array($val)) {
- $_inlineJS .= chr(10).$val.chr(10);
+ if (is_array($GLOBALS['TSFE']->inlineJS)) {
+ foreach ($GLOBALS['TSFE']->inlineJS as $key => $val) {
+ if (! is_array($val)) {
+ $inlineJS .= chr(10) . $val . chr(10);
}
}
}
+ // defined in TS with page.inlineJS
+ // Javascript inline code
+ $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.');
+ if ($inline) {
+ $inlineJS .= chr(10) . $inline . chr(10);
+ }
+
+ // Javascript inline code for Footer
+ $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.');
+
// Should minify?
if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
+ $GLOBALS['TSFE']->enableCompressJavascript();
$minifyErrorScript = $minifyErrorInline = '';
- $_scriptCode = t3lib_div::minifyJavaScript($_scriptCode,$minifyErrorScript);
+ $scriptJsCode = t3lib_div::minifyJavaScript($scriptJsCode, $minifyErrorScript);
if ($minifyErrorScript) {
$GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3);
}
- if ($_inlineJS) {
- $_inlineJS = t3lib_div::minifyJavaScript($_inlineJS,$minifyErrorInline);
+ if ($inlineJS) {
+ $inlineJS = t3lib_div::minifyJavaScript($inlineJS, $minifyErrorInline);
+ if ($minifyErrorInline) {
+ $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
+ }
+ }
+ if ($inlineFooterJs) {
+ $inlineFooterJs = t3lib_div::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
if ($minifyErrorInline) {
$GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
}
}
+
}
- if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
+ if (! $GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
// inlude default and inlineJS
- $GLOBALS['TSFE']->content.='
- <script type="text/javascript">
- /*<![CDATA[*/
- <!--'.$_scriptCode.$_inlineJS.'
- // -->
- /*]]>*/
- </script>';
- } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS']==='external') {
+ if ($scriptJsCode) {
+ $GLOBALS['TSFE']->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['minifyJS']);
+ }
+ if ($inlineJS) {
+ $GLOBALS['TSFE']->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
+ }
+ if ($inlineFooterJs) {
+ $GLOBALS['TSFE']->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
+ }
+ } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
// put default and inlineJS in external file
- $GLOBALS['TSFE']->content.= TSpagegen::inline2TempFile($_scriptCode.$_inlineJS, 'js');
- } elseif ($_inlineJS) {
+ $GLOBALS['TSFE']->addJsFile(TSpagegen::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
+ if ($inlineFooterJs) {
+ $GLOBALS['TSFE']->addJsFooterFile(TSpagegen::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
+ }
+ } else {
// include only inlineJS
- $GLOBALS['TSFE']->content.='
- <script type="text/javascript">
- /*<![CDATA[*/
- <!--'.$_inlineJS.'
- // -->
- /*]]>*/
- </script>';
- }
-
- $GLOBALS['TSFE']->content.= chr(10).implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).'
-</head>';
- if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
+ if ($inlineJS) {
+ $GLOBALS['TSFE']->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
+ }
+ if ($inlineFooterJs) {
+ $GLOBALS['TSFE']->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
+ }
+ }
+
+ // ExtJS specific code
+ if (is_array($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.'])) {
+ $GLOBALS['TSFE']->addInlineLanguageLabelArray($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.']);
+ }
+
+ if (is_array($GLOBALS['TSFE']->pSetup['inlineSettings.'])) {
+ $GLOBALS['TSFE']->addInlineSettingArray('TS', $GLOBALS['TSFE']->pSetup['inlineSettings.']);
+ }
+
+ if (is_array($GLOBALS['TSFE']->pSetup['extOnReady.'])) {
+ $GLOBALS['TSFE']->addExtOnReadyCode($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['extOnReady.'], 'extOnReady.'));
+ }
+
+ // compression and concatenate settings
+ if ($GLOBALS['TSFE']->config['config']['minifyCSS']) {
+ $GLOBALS['TSFE']->enableCompressCss();
+ }
+ if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
+ $GLOBALS['TSFE']->enableCompressJavascript();
+ }
+ if ($GLOBALS['TSFE']->config['config']['concatenateJsAndCss']) {
+ $GLOBALS['TSFE']->enableConcatenateFiles();
+ }
+
+ // add header data block
+ if ($GLOBALS['TSFE']->additionalHeaderData) {
+ $GLOBALS['TSFE']->addHeaderData(implode(chr(10), $GLOBALS['TSFE']->additionalHeaderData));
+ }
+
+ // add footer data block
+ if ($GLOBALS['TSFE']->additionalFooterData) {
+ $GLOBALS['TSFE']->addFooterData(implode(chr(10), $GLOBALS['TSFE']->additionalFooterData));
+ }
+
+ // Header complete, now add content
+
+
+ if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
$fs = t3lib_div::makeInstance('tslib_frameset');
- $GLOBALS['TSFE']->content.= $fs->make($GLOBALS['TSFE']->pSetup['frameSet.']);
- $GLOBALS['TSFE']->content.= chr(10).'<noframes>'.chr(10);
+ $GLOBALS['TSFE']->addBodyContent($fs->make($GLOBALS['TSFE']->pSetup['frameSet.']));
+ $GLOBALS['TSFE']->addBodyContent(chr(10) . '<noframes>' . chr(10));
}
// Bodytag:
- $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'],$GLOBALS['TSFE']->pSetup['bodyTagCObject.'],'bodyTagCObject') : '';
- if (!$defBT) $defBT = $GLOBALS['TSFE']->defaultBodyTag;
+ $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
+ if (! $defBT)
+ $defBT = $GLOBALS['TSFE']->defaultBodyTag;
$bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
- if ($bgImg=$GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'],$GLOBALS['TSFE']->pSetup['bgImg.'])) {
- $bodyTag = preg_replace('/>$/','',trim($bodyTag)).' background="'.$GLOBALS["TSFE"]->absRefPrefix.$bgImg[3].'">';
+ if ($bgImg = $GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'], $GLOBALS['TSFE']->pSetup['bgImg.'])) {
+ $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS["TSFE"]->absRefPrefix . $bgImg[3] . '">';
}
- if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
+ if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
$margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
- if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
+ if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
// Setting margins in CSS, see above
} else {
- $bodyTag = preg_replace('/>$/','',trim($bodyTag)).' leftmargin="'.$margins.'" topmargin="'.$margins.'" marginwidth="'.$margins.'" marginheight="'.$margins.'">';
+ $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
}
}
- if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
- $bodyTag = preg_replace('/>$/','',trim($bodyTag)).' '.trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']).'>';
+ if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
+ $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
}
- if (count($JSef[1])) { // Event functions:
- $bodyTag = preg_replace('/>$/','',trim($bodyTag)).' '.trim(implode(' ',$JSef[1])).'>';
+ if (count($JSef[1])) { // Event functions:
+ $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
}
- $GLOBALS['TSFE']->content.= chr(10).$bodyTag;
-
+ $GLOBALS['TSFE']->addBodyContent(chr(10) . $bodyTag);
// Div-sections
- if ($GLOBALS['TSFE']->divSection) {
- $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->divSection;
+ if ($GLOBALS['TSFE']->divSection) {
+ $GLOBALS['TSFE']->addBodyContent(chr(10) . $GLOBALS['TSFE']->divSection);
}
// Page content
- $GLOBALS['TSFE']->content.= chr(10).$pageContent;
+ $GLOBALS['TSFE']->addBodyContent(chr(10) . $pageContent);
+
+ // Render complete page
+ $GLOBALS['TSFE']->content = $GLOBALS['TSFE']->render();
// Ending page
- $GLOBALS['TSFE']->content.= chr(10).'</body>';
- if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
- $GLOBALS['TSFE']->content.= chr(10).'</noframes>';
+ if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
+ $GLOBALS['TSFE']->content .= chr(10) . '</noframes>';
}
- $GLOBALS['TSFE']->content.=chr(10).'</html>';
+
}
* @param string Extension: "css" or "js"
* @return string <script> or <link> tag for the file.
*/
- public static function inline2TempFile($str,$ext) {
+ public static function inline2TempFile($str, $ext) {
// Create filename / tags:
$script = '';
- switch($ext) {
- case 'js':
- $script = 'typo3temp/javascript_'.substr(md5($str),0,10).'.js';
- $output = '
- <script type="text/javascript" src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'"></script>';
+ switch ($ext) {
+ case 'js' :
+ $script = 'typo3temp/javascript_' . substr(md5($str), 0, 10) . '.js';
+ $output = $GLOBALS['TSFE']->absRefPrefix . $script;
break;
- case 'css':
- $script = 'typo3temp/stylesheet_'.substr(md5($str),0,10).'.css';
- $output = '
- <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'" />';
+ case 'css' :
+ $script = 'typo3temp/stylesheet_' . substr(md5($str), 0, 10) . '.css';
+ $output = $GLOBALS['TSFE']->absRefPrefix . $script;
break;
}
// Write file:
- if ($script) {
- if (!@is_file(PATH_site.$script)) {
- t3lib_div::writeFile(PATH_site.$script,$str);
+ if ($script) {
+ if (! @is_file(PATH_site . $script)) {
+ t3lib_div::writeFile(PATH_site . $script, $str);
}
}
* @package TYPO3
* @subpackage core
*/
-class template {
+class template extends t3lib_pageRender {
// Vars you typically might want to/should set from outside after making instance of this class:
var $backPath = ''; // 'backPath' pointing back to the PATH_typo3
var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
var $divClass = ''; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
- // internal flags for JS-libraries
- protected $addPrototype = false;
- protected $addScriptaculousModules = array(
- 'builder' => false,
- 'effects' => false,
- 'dragdrop' => false,
- 'controls' => false,
- 'slider' => false
- );
- protected $addExtJS = false;
- protected $extJSadapter = 'ext/ext-base.js';
- protected $enableExtJsDebug = false;
+ var $pageHeaderBlock = '';
+ var $endOfPageJsBlock = '';
+
+ var $hasDocheader = true;
+
+ // class for render the header / footer
- // available adapters for extJs
- const EXTJS_ADAPTER_JQUERY = 'jquery';
- const EXTJS_ADAPTER_PROTOTYPE = 'prototype';
- const EXTJS_ADAPTER_YUI = 'yui';
+ var $pageHeaderFooterTemplateFile = ''; // alternative template file
/**
*/
function template() {
global $TBE_STYLES;
+ parent::__construct(TYPO3_mainDir . 'templates/pagerender_be.html');
// Setting default scriptID:
if (($temp_M = (string) t3lib_div::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
}
}
- // Get META tag containing the currently selected charset for backend output. The function sets $this->charSet.
- $charSet = $this->initCharset();
- $generator = $this->generator();
-
+ // alternative template for Header and Footer
+ if ($this->pageHeaderFooterTemplateFile) {
+ $file = t3lib_div::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE);
+ if ($file) {
+ $this->setAlternativeTemplateFile($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">';
+ $this->setHtmlTag('<html xmlns="http://www.w3.org/1999/xhtml">');
switch($this->docType) {
case 'html_3':
}
}
+ $this->setXmlPrologAndDocType($headerStart);
+ $this->setHeadTag('<head>' . chr(10). '<!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->');
+ $this->setCharSet($this->charset);
+ $this->addMetaTag($this->generator());
+ $this->setTitle($title);
+
+ // add docstyles
+ $this->docStyle();
+
+
+ // add jsCode - has to go to headerData as it may contain the script tags already
+ $this->addHeaderData($this->JScode);
+
+ foreach ($this->JScodeArray as $name => $code) {
+ $this->addJsInlineCode($name, $code);
+ }
+
+ if (count($this->JScodeLibArray)) {
+ foreach($this->JScodeLibArray as $library) {
+ $this->addHeaderData($library);
+ }
+ }
+
+ if ($this->extJScode) {
+ $this->addJsHandlerCode($this->extJScode, t3lib_pageIncludes::JSHANDLER_EXTONREADY);
+ }
+
// Construct page header.
- $str = $headerStart . chr(10) . $htmlTag . '
-<head>
- <!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->
- '.$charSet.'
- '.$generator.'
- <title>'.htmlspecialchars($title).'</title>
- '.$this->docStyle().'
- ' . $this->renderJSlibraries() . '
- '.$this->JScode.'
- '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).
- ($this->extJScode ? $this->wrapScriptTags('Ext.onReady(function() {' . chr(10) . $this->extJScode . chr(10) . '});') : '') .
- '
- <!--###POSTJSMARKER###-->
-</head>
-';
+ $str = $this->render(1);
+
$this->JScodeLibArray = array();
$this->JScode = $this->extJScode = '';
$this->JScodeArray = array();
+ $this->endOfPageJsBlock = $this->render(2);
+
if ($this->docType=='xhtml_frames') {
return $str;
} else
$str .= ($this->divClass?'
<!-- Wrapping DIV-section for whole page END -->
-</div>':'').'
-</body> ';
+</div>':'') . $this->endOfPageJsBlock ;
}
- $str .= '</html>';
// Logging: Can't find better place to put it:
if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => true));
$this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
// Implode it all:
- $inDocStyles = implode('
- ',$this->inDocStylesArray);
-
- // The default color scheme should also in full be represented in the stylesheet.
- $style=trim('
- '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
- '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
- <style type="text/css" id="internalStyle">
- /*<![CDATA[*/
- '.trim($inDocStyles).'
- /*###POSTCSSMARKER###*/
- /*]]>*/
- </style>
- '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'').'
- '.implode("\n", $this->additionalStyleSheets)
- )
- ;
- $this->inDocStyles='';
- $this->inDocStylesArray=array();
+ $inDocStyles = implode(chr(10), $this->inDocStylesArray);
+
+ if ($this->styleSheetFile) {
+ $this->addCssFile($this->backPath . $this->styleSheetFile);
+ }
+ if ($this->styleSheetFile2) {
+ $this->addCssFile($this->backPath . $this->styleSheetFile2);
+ }
+
+ $this->addCssInlineBlock('inDocStyles', $inDocStyles . chr(10) . '/*###POSTCSSMARKER###*/');
+ if ($this->styleSheetFile_post) {
+ $this->addCssFile($this->backPath . $this->styleSheetFile_post);
+ }
- return '
- '.$style;
}
/**
* @return void
*/
function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
- if (!isset($this->additionalStyleSheets[$key])) {
- $this->additionalStyleSheets[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '"' . ($title ? (' title="' . $title . '"') : '') . ' />';
+ $this->addCssFile($this->backPath . $href, $relation, $title);
}
- }
/**
* Insert post rendering document style into already rendered content
* @return void
*/
function loadJavascriptLib($lib) {
- if (!isset($this->JScodeLibArray[$lib])) {
- $this->JScodeLibArray[$lib] = '<script type="text/javascript" src="' . $this->backPath . $lib . '"></script>';
+ $this->addJsFile($this->backPath . $lib);
}
- }
- /**
- *
- * @param string $lib it will remove lib from general JScodeLibArray because lib is loaded already.
- */
- protected function removeJavascriptLib($lib) {
- if (count($this->JScodeLibArray)) {
- $scripts = array_keys($this->JScodeLibArray);
- foreach ($scripts as $script) {
- if (strpos($script, '/' . $lib . '/') !== false) {
- unset ($this->JScodeLibArray[$script]);
- }
- }
- }
- }
/**
* Includes the necessary Javascript function for the clickmenu (context sensitive menus) in the document
}
- /**
- * Following functions are help function for JS library include.
- * They enable loading the libraries prototype, scriptaculous and extJS from contrib-directory
- */
- /**
- * Function for render the JS-libraries in header
- * Load order is prototype / scriptaculous / extJS
- */
- protected function renderJSlibraries() {
- $libs = array();
-
- // include prototype
- if ($this->addPrototype) {
- $libs[] = 'contrib/prototype/prototype.js';
- // remove prototype from JScodeLibArray
- $this->removeJavascriptLib('prototype');
- }
- // include scriptaculous
- if ($this->addScriptaculous) {
- $mods = array();
- foreach ($this->addScriptaculousModules as $key => $value) {
- if ($this->addScriptaculousModules[$key]) {
- $mods[] = $key;
- }
- }
- // resolve dependencies
- if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
- $mods = array_merge(array('effects'), $mods);
- }
-
- if (count($mods)) {
- $moduleLoadString = '?load=' . implode(',', $mods);
- }
- $libs[] = 'contrib/scriptaculous/scriptaculous.js' . $moduleLoadString;
- // remove scriptaculous from JScodeLibArray
- $this->removeJavascriptLib('scriptaculous');
}
- // include extJS
- if ($this->addExtJS) {
- // use the base adapter all the time
- $libs[] = 'contrib/extjs/adapter/' . ($this->enableExtJsDebug ? str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter);
- $libs[] = 'contrib/extjs/ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js';
-
- // add extJS localization
- $localeMap = $GLOBAL['LANG']->csConvObj->isoArray; // load standard ISO mapping and modify for use with ExtJS
- $localeMap[''] = 'en';
- $localeMap['default'] = 'en';
- $localeMap['gr'] = 'el_GR'; // Greek
- $localeMap['no'] = 'no_BO'; // Norwegian Bokmaal
- $localeMap['se'] = 'se_SV'; // Swedish
- $extJsLang = isset($localeMap[$GLOBALS['BE_USER']->uc['lang']]) ? $localeMap[$GLOBALS['BE_USER']->uc['lang']] : $GLOBALS['BE_USER']->uc['lang'];
- // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
- $extJsLocaleFile = 'contrib/extjs/locale/ext-lang-' . $extJsLang . '-min.js';
- if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
- $libs[] = $extJsLocaleFile;
- }
- // set clear.gif
- $this->extJScode .= 'Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div::locationHeaderUrl('gfx/clear.gif')) . '";';
- // remove extjs from JScodeLibArray
- $this->removeJavascriptLib('contrib/extjs');
- }
-
- foreach ($libs as &$lib) {
- $lib = '<script type="text/javascript" src="' . $this->backPath . $lib . '"></script>';
- }
-
- // add other JavascriptLibs and return it
- $libs = array_merge($libs, $this->JScodeLibArray);
- return count($libs) ? chr(10) . chr(10) . implode(chr(10), $libs) . chr(10) . chr(10) : '';
- }
-
- /**
- * call function if you need the prototype library
- */
- public function loadPrototype() {
- $this->addPrototype = true;
- }
-
- /**
- * call function if you need the Scriptaculous library
- * @param string $modules add modules you need. use "all" if you need complete modules
- */
- public function loadScriptaculous($modules='') {
- // Scriptaculous require prototype, so load prototype too.
- $this->addPrototype = true;
- $this->addScriptaculous = true;
- if ($modules) {
- if ($modules == 'all') {
- foreach ($this->addScriptaculousModules as $key => $value) {
- $this->addScriptaculousModules[$key] = true;
- }
- } else {
- $mods = t3lib_div::trimExplode(',', $modules);
- foreach ($mods as $mod) {
- if (isset($this->addScriptaculousModules[strtolower($mod)])) {
- $this->addScriptaculousModules[strtolower($mod)] = true;
- }
- }
- }
- }
- }
-
- /**
- * call this function if you need the extJS library
- * @param boolean $css flag, if set the ext-css will be loaded
- * @param boolean $theme flag, if set the ext-theme "grey" will be loaded
- * @param string $adapter choose alternative adapter, possible values: yui, prototype, jquery
- */
- public function loadExtJS($css = true, $theme = true, $adapter = '') {
- if ($adapter) {
- // empty $adapter will always load the ext adapter
- switch (t3lib_div::strtolower(trim($adapter))) {
- case template::EXTJS_ADAPTER_YUI:
- $this->extJSadapter = 'yui/ext-yui-adapter.js';
- break;
- case template::EXTJS_ADAPTER_PROTOTYPE:
- $this->extJSadapter = 'prototype/ext-prototype-adapter.js';
- break;
- case template::EXTJS_ADAPTER_JQUERY:
- $this->extJSadapter = 'jquery/ext-jquery-adapter.js';
- break;
- }
- }
- if (!$this->addExtJS) {
- $this->addExtJS = true;
- if ($css) {
- if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
- $this->addStyleSheet('ext-all', $this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all']);
- } else {
- $this->addStyleSheet('ext-all', $this->backPath . 'contrib/extjs/resources/css/ext-all-notheme.css');
- }
- }
- if ($theme) {
- if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
- $this->addStyleSheet('ext-theme', $this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme']);
- } else {
- $this->addStyleSheet('ext-theme', $this->backPath . 'contrib/extjs/resources/css/xtheme-blue.css');
- }
- }
- }
- }
-
- /**
- * call this function to load debug version of extJS. Use this for development only
- */
- public function enableExtJsDebug() {
- $this->enableExtJsDebug = true;
- }
-
-
-}
-
// ******************************
// Extension classes of the template class.
--- /dev/null
+###XMLPROLOG_DOCTYPE###\r
+###HTMLTAG###\r
+###HEADTAG###\r
+\r
+###METACHARSET###\r
+###INLINECOMMENT###\r
+\r
+###BASEURL###\r
+###SHORTCUT###\r
+###TITLE###\r
+###META###\r
+\r
+###CSS_INCLUDE###\r
+###CSS_INLINE###\r
+\r
+###JS_LIBS###\r
+###JS_INCLUDE###\r
+###JS_INLINE###\r
+\r
+###HEADERDATA###\r
+<!--###POSTJSMARKER###-->\r
+</head>\r
+###BODY###\r
+###JS_LIBS_FOOTER###\r
+###JS_INCLUDE_FOOTER###\r
+###JS_INLINE_FOOTER###\r
+###FOOTERDATA###\r
+</body>\r
+</html>\r
--- /dev/null
+###XMLPROLOG_DOCTYPE###\r
+###HTMLTAG###\r
+###HEADTAG###\r
+\r
+###METACHARSET###\r
+###INLINECOMMENT###\r
+\r
+###BASEURL###\r
+###SHORTCUT###\r
+###TITLE###\r
+###META###\r
+\r
+###CSS_INCLUDE###\r
+###CSS_INLINE###\r
+\r
+###JS_LIBS###\r
+###JS_INCLUDE###\r
+###JS_INLINE###\r
+\r
+###HEADERDATA###\r
+</head>\r
+###BODY###\r
+###JS_LIBS_FOOTER###\r
+###JS_INCLUDE_FOOTER###\r
+###JS_INLINE_FOOTER###\r
+###FOOTERDATA###\r
+</body>\r
+</html>\r