Project

General

Profile

Bug #19829 » 10144.diff

Administrator Admin, 2009-01-15 11:04

View differences:

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.
// flags for JS-libraries
protected $addPrototype = false;
protected $addScriptaculous = false;
protected $scriptaculousModules = array (
'builder' => false,
'effects' => false,
'dragdrop' => false,
'controls' => false,
'slider' => false
);
protected $addExtJS = false;
protected $extJSDebug = false;
/**
* Constructor
* Imports relevant parts from global $TBE_STYLES (colorscheme)
......
'.$generator.'
<title>'.htmlspecialchars($title).'</title>
'.$this->docStyle().'
'.implode("\n", $this->JScodeLibArray).'
' . $this->renderJSlibraries() . implode("\n", $this->JScodeLibArray).'
'.$this->JScode.'
'.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
<!--###POSTJSMARKER###-->
......
$pageInfo = $theIcon . '<em>[pid: ' . $pageRecord['uid'] . ']</em>';
return $pageInfo;
}
/**
* 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() {
$libTags = '';
if ($this->addPrototype) {
// render prototype inclusion
$libTags .= '<!-- include prototype -->';
$libTags .= chr(10) . '<script type="text/javascript" src="contrib/prototype/prototype.js"></script>';
// remove prototype from JScodeLibArray
$this->removeLibFromArray('prototype');
}
if ($this->addScriptaculous) {
// render scriptaculous inclusion
$libTags .= chr(10) . '<!-- include scriptaculous -->';
$mods = array();
foreach ($this->scriptaculousModules as $key => $value) {
if ($this->scriptaculousModules[$key]) {
$mods[] = $key;
}
}
// solve dependencies
if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
$mods = array_merge(array('effects'), $mods);
}
if (count($mods)) {
$moduleLoadString = '?load=' . implode(',', $mods);
}
$libTags .= chr(10) . '<script type="text/javascript" src="contrib/scriptaculous/scriptaculous.js' . $moduleLoadString . '"></script>';
// remove scriptaculous from JScodeLibArray
$this->removeLibFromArray('scriptaculous');
}
if ($this->addExtJS) {
// render extJS inclusion
$libTags .= chr(10) . '<!-- include extJS -->';
if ($this->addPrototype) {
// add prototype adapter
$libTags .= chr(10) . '<script type="text/javascript" src="contrib/extjs/adapter/prototype/ext-prototype-adapter.js"></script>';
} else {
// add extJS adapter
$libTags .= chr(10) . '<script type="text/javascript" src="contrib/extjs/adapter/ext/ext-base.js"></script>';
}
if ($this->extJSDebug) {
$libTags .= chr(10) . '<script type="text/javascript" src="contrib/extjs/ext-all-debug.js"></script>';
} else {
$libTags .= chr(10) . '<script type="text/javascript" src="contrib/extjs/ext-all.js"></script>';
}
// set clear.gif
$this->extJScode .= 'Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(t3lib_div::locationHeaderUrl('gfx/clear.gif')) . '";';
// remove extjs from JScodeLibArray
$this->removeLibFromArray('extjs');
}
return $libTags ? chr(10) . chr(10) . $libTags . chr(10) . chr(10) : '';
}
/**
*
* @param string $lib it will delete loading lib from general JScodeLibArray because lib is loaded already.
*/
protected function removeLibFromArray($lib) {
if (count($this->JScodeLibArray)) {
$scripts = array_keys($this->JScodeLibArray);
foreach ($scripts as $script) {
if (strpos('/' . $lib, $script)) {
unset ($this->JScodeLibArray[$script]);
}
}
}
}
/**
* 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 = '') {
$this->addScriptaculous = true;
if ($modules) {
$this->loadScriptaculousModules($modules);
}
}
/**
* call this function if you need additional modules for scriptaculous library
* @param string $modules
*/
public function loadScriptaculousModules($modules) {
if ($modules) {
if ($modules == 'all') {
foreach ($this->scriptaculousModules as $key => $value) {
$this->scriptaculousModules[$key] = true;
}
} else {
$mods = t3lib_div::trimExplode(',', $modules);
foreach ($mods as $mod) {
if (isset($this->scriptaculousModules[strtolower($mod)])) {
$this->scriptaculousModules[strtolower($mod)] = true;
}
}
}
}
}
/**
* call this function if you need the extJS library
* @param string $css
*/
public function loadExtJS($css = true, $theme = true) {
if (!$this->addExtJS) {
$this->addExtJS = true;
if ($css) {
if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
$this->addStyleSheet('ext-all', $GLOBALS['TBE_STYLES']['extJS']['all'], 'ext-all');
} else {
$this->addStyleSheet('ext-all', 'contrib/extjs/resources/css/ext-all.css', 'ext-all');
}
}
if ($theme) {
if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
$this->addStyleSheet('ext-theme', $GLOBALS['TBE_STYLES']['extJS']['theme'], 'ext-theme');
} else {
$this->addStyleSheet('ext-theme', 'contrib/extjs/resources/css/xtheme-gray.css', 'ext-theme');
}
}
}
}
/**
* call this function to load debug version of extJS. Use this for development only
*/
public function setExtJSDebug() {
$this->extJSDebug = 1;
}
}
(1-1/2)