Bug #20661 » pageinclude_for BE.diff
typo3/template.php (working copy) | ||
---|---|---|
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;
|
||
// available adapters for extJs
|
||
const EXTJS_ADAPTER_JQUERY = 'jquery';
|
||
const EXTJS_ADAPTER_PROTOTYPE = 'prototype';
|
||
const EXTJS_ADAPTER_YUI = 'yui';
|
||
var $pageHeaderBlock = '';
|
||
var $endOfPageJsBlock = '';
|
||
|
||
var $hasDocheader = true;
|
||
|
||
// class for render the header / footer
|
||
var $pageIncludes;
|
||
var $pageHeaderFooterTemplateFile = ''; // alternative template file
|
||
|
||
/**
|
||
* Constructor
|
||
* Imports relevant parts from global $TBE_STYLES (colorscheme)
|
||
... | ... | |
// Background image
|
||
if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
|
||
|
||
$this->pageIncludes = t3lib_div::makeInstance('t3lib_pageIncludes');
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
// 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->pageIncludes->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
|
||
header ('Content-Type:text/html;charset='.$this->charset);
|
||
$this->pageIncludes->backPath = $this->backPath;
|
||
|
||
// Standard HTML tag
|
||
$htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
|
||
$this->pageIncludes->setHtmlTag('<html xmlns="http://www.w3.org/1999/xhtml">');
|
||
switch($this->docType) {
|
||
case 'html_3':
|
||
... | ... | |
}
|
||
}
|
||
$this->pageIncludes->setXmlPrologAndDocType($headerStart);
|
||
$this->pageIncludes->setHeadTag('<head>' . chr(10). '<!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->');
|
||
$this->pageIncludes->addMetaData($this->initCharset());
|
||
$this->pageIncludes->addMetaData($this->generator());
|
||
$this->pageIncludes->setTitle($title);
|
||
|
||
// add docstyles
|
||
$this->docStyle();
|
||
|
||
|
||
// add jsCode - has to go to headerData as it may contain the script tags already
|
||
$this->pageIncludes->addHeaderData($this->JScode);
|
||
|
||
foreach ($this->JScodeArray as $name => $code) {
|
||
$this->pageIncludes->addJsInlineCode($name, $code);
|
||
}
|
||
|
||
if ($this->extJScode) {
|
||
$this->pageIncludes->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###-->
|
||
|
||
$str = $this->pageIncludes->render();
|
||
|
||
$str .= '<!--###POSTJSMARKER###-->
|
||
</head>
|
||
';
|
||
$this->JScodeLibArray = array();
|
||
$this->JScode = $this->extJScode = '';
|
||
$this->JScodeArray = array();
|
||
$this->endOfPageJsBlock = $this->pageIncludes->render(1);
|
||
|
||
|
||
if ($this->docType=='xhtml_frames') {
|
||
return $str;
|
||
} else
|
||
$str.=$this->docBodyTagBegin().
|
||
($this->divClass?'
|
||
$str .= $this->docBodyTagBegin() .
|
||
($this->divClass ? '
|
||
<!-- Wrapping DIV-section for whole page BEGIN -->
|
||
<div class="'.$this->divClass.'">
|
||
':'').trim($this->form);
|
||
return $str;
|
||
':'') . trim($this->form);
|
||
|
||
return $str;
|
||
}
|
||
/**
|
||
... | ... | |
$this->parseTime().
|
||
($this->form?'
|
||
</form>':'');
|
||
|
||
if ($this->docType!='xhtml_frames') {
|
||
$str .= ($this->divClass?'
|
||
<!-- Wrapping DIV-section for whole page END -->
|
||
</div>':'').'
|
||
</div>':'') . $this->endOfPageJsBlock .'
|
||
</body> ';
|
||
}
|
||
... | ... | |
$this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
|
||
// Implode it all:
|
||
$inDocStyles = implode('
|
||
',$this->inDocStylesArray);
|
||
$inDocStyles = implode(chr(10), $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();
|
||
return '
|
||
'.$style;
|
||
if ($this->styleSheetFile) {
|
||
$this->pageIncludes->addCssFile($this->backPath . $this->styleSheetFile);
|
||
}
|
||
if ($this->styleSheetFile2) {
|
||
$this->pageIncludes->addCssFile($this->backPath . $this->styleSheetFile2);
|
||
}
|
||
|
||
$this->pageIncludes->addCssInlineBlock('inDocStyles', $inDocStyles . chr(10) . '/*###POSTCSSMARKER###*/');
|
||
if ($this->styleSheetFile_post) {
|
||
$this->pageIncludes->addCssFile($this->backPath . $this->styleSheetFile_post);
|
||
}
|
||
|
||
}
|
||
/**
|
||
... | ... | |
* @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->pageIncludes->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->pageIncludes->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
|
||
*
|
||
* @return array Deprecated: Includes the code already in the doc, so the return array is always empty.
|
||
... | ... | |
*/
|
||
/**
|
||
* 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->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('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;
|
||
$this->pageIncludes->loadPrototype();
|
||
}
|
||
/**
|
||
... | ... | |
* @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;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$this->pageIncludes->loadScriptaculous($modules='');
|
||
}
|
||
/**
|
||
... | ... | |
* @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', $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', $GLOBALS['TBE_STYLES']['extJS']['theme']);
|
||
} else {
|
||
$this->addStyleSheet('ext-theme', $this->backPath . 'contrib/extjs/resources/css/xtheme-gray.css');
|
||
}
|
||
}
|
||
}
|
||
$this->pageIncludes->loadExtJs($css, $theme, $adapter);
|
||
}
|
||
/**
|