X-Git-Url: https://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff_plain/7f13ea614e46778b179d8e947ee0df74a4fe6282..fd69f6b9ca2f4a963d6ee7e948dabde9488996c1:/typo3/template.php diff --git a/typo3/template.php b/typo3/template.php index 8d1dff0..dd41001 100644 --- a/typo3/template.php +++ b/typo3/template.php @@ -132,7 +132,8 @@ if (!defined('TYPO3_MODE')) die("Can't include this file directly."); * @return string Output string (in the old days this was wrapped in tags) * @deprecated since TYPO3 3.6 */ -function fw($str) { +function fw($str) { + t3lib_div::logDeprecatedFunction(); return $str; } @@ -178,7 +179,6 @@ class template { var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value). var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php) var $endJS=1; // If set, then a JavaScript section will be outputted in the bottom of page which will try and update the top.busy session expiry object. - protected $additionalStyleSheets=array(); // Links to additional style sheets // TYPO3 Colorscheme. // If you want to change this, please do so through a skin using the global var $TBE_STYLES @@ -189,12 +189,32 @@ class template { var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light. var $hoverColor = '#254D7B'; - var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3) + var $styleSheetFile = ''; // Filename of stylesheet (relative to PATH_typo3) var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3) var $styleSheetFile_post = ''; // Filename of a post-stylesheet - included right after all inline styles. var $backGroundImage = ''; // Background image of page (relative to PATH_typo3) var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array + /** + * Whether to use the X-UA-Compatible meta tag + * @var boolean + */ + protected $useCompatibilityTag = TRUE; + + // Skinning + // stylesheets from core + protected $stylesheetsCore = array( + 'structure' => 'stylesheets/structure/', + 'visual' => 'stylesheets/visual/', + 'generatedSprites' => '../typo3temp/sprites/', + ); + + // include these CSS directories from skins by default + protected $stylesheetsSkins = array( + 'structure' => 'stylesheets/structure/', + 'visual' => 'stylesheets/visual/', + ); + // DEV: var $parseTimeFlag = 0; // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to false when releasing TYPO3. Only for dev. @@ -215,6 +235,12 @@ class template { protected $pageRenderer; protected $pageHeaderFooterTemplateFile = ''; // alternative template file + /** + * Whether flashmessages should be rendered or not + * + * @var $showFlashMessages + */ + public $showFlashMessages = TRUE; /** * Constructor @@ -263,6 +289,11 @@ class template { if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post']; if ($TBE_STYLES['inDocStyles_TBEstyle']) $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle']; + // include all stylesheets + foreach ($this->getSkinStylesheetDirectories() as $stylesheetDirectory) { + $this->addStylesheetDirectory($stylesheetDirectory); + } + // Background image if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background']; } @@ -279,6 +310,10 @@ class template { $this->pageRenderer->setTemplateFile( TYPO3_mainDir . 'templates/template_page_backend.html' ); + $this->pageRenderer->setLanguage($GLOBALS['LANG']->lang); + $this->pageRenderer->enableConcatenateFiles(); + $this->pageRenderer->enableCompressCss(); + $this->pageRenderer->enableCompressJavascript(); } return $this->pageRenderer; } @@ -419,7 +454,7 @@ class template { $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,''); if ($table=='pages') $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0); } else { - $iconImgTag='backPath,'gfx/i/_icon_website.gif',$wHattribs='width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'; + $iconImgTag = t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-domain', array('title' => htmlspecialchars($path))); $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } @@ -475,7 +510,8 @@ class template { .'\''.rawurlencode($pathInfo['path']."?".$storeUrl).$mMN.'\'' .');return false;'; - $sIcon = ''; + $sIcon = '' + . t3lib_iconworks::getSpriteIcon('actions-system-shortcut-new') . ''; return $sIcon; } @@ -600,6 +636,16 @@ class template { } } + /** + * Defines whether to use the X-UA-Compatible meta tag. + * + * @param boolean $useCompatibilityTag Whether to use the tag + * @return void + */ + public function useCompatibilityTag($useCompatibilityTag = TRUE) { + $this->useCompatibilityTag = (bool) $useCompatibilityTag; + } + @@ -657,12 +703,14 @@ class template { header ('Content-Type:text/html;charset='.$this->charset); // Standard HTML tag - $this->pageRenderer->setHtmlTag(''); + $htmlTag = ''; switch($this->docType) { case 'html_3': $headerStart = ''; $htmlTag = ''; + // disable rendering of XHTML tags + $this->getPageRenderer()->setRenderXhtml(FALSE); break; case 'xhtml_strict': $headerStart = ''; + PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'; + break; + case 'html_5': + $headerStart = '' . LF; + $htmlTag = ''; + // 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 = ''; } + $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']) { @@ -698,24 +754,27 @@ class template { $xmlStylesheet = ''; // Add the XML prologue for XHTML doctypes - if ($this->docType !== 'html_3') { + 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 . chr(10) . $xmlPrologue; + $headerStart = $headerStart . LF . $xmlPrologue; } else { - $headerStart = $xmlPrologue . chr(10) . $headerStart; + $headerStart = $xmlPrologue . LF . $headerStart; } // Add the xml stylesheet according to doctype if ($this->docType !== 'xhtml_frames') { - $headerStart = $headerStart . chr(10) . $xmlStylesheet; + $headerStart = $headerStart . LF . $xmlStylesheet; } } $this->pageRenderer->setXmlPrologAndDocType($headerStart); - $this->pageRenderer->setHeadTag('' . chr(10). ''); + $this->pageRenderer->setHeadTag('' . LF. ''); $this->pageRenderer->setCharSet($this->charset); $this->pageRenderer->addMetaTag($this->generator()); + if ($this->useCompatibilityTag) { + $this->pageRenderer->addMetaTag($this->xUaCompatible()); + } $this->pageRenderer->setTitle($title); // add docstyles @@ -774,8 +833,13 @@ $str.=$this->docBodyTagBegin(). $this->parseTime(). ($this->form?' ':''); + // if something is in buffer like debug, put it to end of page + if (ob_get_contents()) { + $str .= ob_get_clean(); + header('Content-Encoding: None'); + } - if ($this->docType!='xhtml_frames') { + if ($this->docType !== 'xhtml_frames') { $str .= ($this->divClass?' @@ -878,14 +942,17 @@ $str.=$this->docBodyTagBegin(). * @param string Additional attributes to h-tag, eg. ' class=""' * @return string HTML content */ - function sectionHeader($label,$sH=FALSE,$addAttrib='') { - $tag = ($sH?'h3':'h4'); + function sectionHeader($label, $sH=FALSE, $addAttrib='') { + $tag = ($sH ? 'h3' : 'h4'); + if ($addAttrib && substr($addAttrib, 0, 1) !== ' ') { + $addAttrib = ' ' . $addAttrib; + } $str=' - <'.$tag.$addAttrib.'>'.$label.' + <' . $tag . $addAttrib . '>' . $label . ' '; - return $this->sectionBegin().$str; + return $this->sectionBegin() . $str; } /** @@ -984,7 +1051,7 @@ $str.=$this->docBodyTagBegin(). $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle; // Implode it all: - $inDocStyles = implode(chr(10), $this->inDocStylesArray); + $inDocStyles = implode(LF, $this->inDocStylesArray); if ($this->styleSheetFile) { $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile); @@ -993,10 +1060,10 @@ $str.=$this->docBodyTagBegin(). $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile2); } - $this->pageRenderer->addCssInlineBlock('inDocStyles', $inDocStyles . chr(10) . '/*###POSTCSSMARKER###*/'); + $this->pageRenderer->addCssInlineBlock('inDocStyles', $inDocStyles . LF . '/*###POSTCSSMARKER###*/'); if ($this->styleSheetFile_post) { $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile_post); - } + } } @@ -1015,7 +1082,26 @@ $str.=$this->docBodyTagBegin(). } else { $file = $this->backPath . $href; } - $this->pageRenderer->addCssFile($file, $relation, $title); + $this->pageRenderer->addCssFile($file, $relation, 'screen', $title); + } + + /** + * Add all *.css files of the directory $path to the stylesheets + * + * @param string directory to add + * @return void + */ + function addStyleSheetDirectory($path) { + // calculation needed, when TYPO3 source is used via a symlink + // absolute path to the stylesheets + $filePath = dirname(t3lib_div::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $path; + // clean the path + $resolvedPath = t3lib_div::resolveBackPath($filePath); + // read all files in directory and sort them alphabetically + $files = t3lib_div::getFilesInDir($resolvedPath, 'css', FALSE, 1); + foreach ($files as $file) { + $this->pageRenderer->addCssFile($GLOBALS['BACK_PATH'] . $path . $file, 'stylesheet', 'all'); + } } /** @@ -1028,17 +1114,61 @@ $str.=$this->docBodyTagBegin(). function insertStylesAndJS($content) { // insert accumulated CSS $this->inDocStylesArray[] = $this->inDocStyles; - $styles = "\n".implode("\n", $this->inDocStylesArray); + $styles = LF.implode(LF, $this->inDocStylesArray); $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content); // insert accumulated JS - $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray)); + $jscode = $this->JScode.LF.$this->wrapScriptTags(implode(LF, $this->JScodeArray)); $content = str_replace('',$jscode,$content); return $content; } /** + * Returns an array of all stylesheet directories belonging to core and skins + * + * @return array Stylesheet directories + */ + public function getSkinStylesheetDirectories() { + $stylesheetDirectories = array(); + + // add default core stylesheets + foreach ($this->stylesheetsCore as $stylesheetDir) { + $stylesheetDirectories[] = $stylesheetDir; + } + + // Stylesheets from skins + // merge default css directories ($this->stylesheetsSkin) with additional ones and include them + if (is_array($GLOBALS['TBE_STYLES']['skins'])) { + // loop over all registered skins + foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinExtKey => $skin) { + $skinStylesheetDirs = $this->stylesheetsSkins; + + // skins can add custom stylesheetDirectories using + // $TBE_STYLES['skins'][$_EXTKEY]['stylesheetDirectories'] + if (is_array($skin['stylesheetDirectories'])) { + $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']); + } + + // add all registered directories + foreach ($skinStylesheetDirs as $stylesheetDir) { + // for EXT:myskin/stylesheets/ syntax + if (substr($stylesheetDir, 0, 4) === 'EXT:') { + list($extKey, $path) = explode('/', substr($stylesheetDir, 4), 2); + if (strcmp($extKey, '') && t3lib_extMgm::isLoaded($extKey) && strcmp($path, '')) { + $stylesheetDirectories[] = t3lib_extMgm::extRelPath($extKey) . $path; + } + } else { + // for relative paths + $stylesheetDirectories[] = t3lib_extMgm::extRelPath($skinExtKey) . $stylesheetDir; + } + } + } + } + return $stylesheetDirectories; + } + + /** * Initialize the charset. * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class) * Returns the meta-tag for the document header @@ -1062,6 +1192,15 @@ $str.=$this->docBodyTagBegin(). return ''; } + /** + * Returns X-UA-Compatible meta tag + * + * @param string $content Content of the compatible tag (default: IE-8) + * @return string + */ + public function xUaCompatible($content = 'IE=8') { + return ''; + } @@ -1093,22 +1232,22 @@ $str.=$this->docBodyTagBegin(). function icons($type, $styleAttribValue='') { switch($type) { case '3': - $icon = 'gfx/icon_fatalerror.gif'; + $icon = 'status-dialog-error'; break; case '2': - $icon = 'gfx/icon_warning.gif'; + $icon = 'status-dialog-warning'; break; case '1': - $icon = 'gfx/icon_note.gif'; + $icon = 'status-dialog-notification'; break; case '-1': - $icon = 'gfx/icon_ok.gif'; + $icon = 'status-dialog-ok'; break; default: break; } if ($icon) { - return 'backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />'; + return t3lib_iconWorks::getSpriteIcon($icon); } } @@ -1170,14 +1309,14 @@ $str.=$this->docBodyTagBegin(). function wrapScriptTags($string, $linebreak=TRUE) { if(trim($string)) { //