mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Allow IE conditions when adding JS (theme and url only at this time)
This commit is contained in:
@@ -1598,7 +1598,7 @@ class e107
|
|||||||
* @param integer $zone [optional] leave it null for default zone
|
* @param integer $zone [optional] leave it null for default zone
|
||||||
* @param string $dep dependence : null | prototype | jquery
|
* @param string $dep dependence : null | prototype | jquery
|
||||||
*/
|
*/
|
||||||
public static function js($type, $data, $dep = null, $zone = null)
|
public static function js($type, $data, $dep = null, $zone = null, $pre = '', $post = '')
|
||||||
{
|
{
|
||||||
$jshandler = e107::getJs();
|
$jshandler = e107::getJs();
|
||||||
$jshandler->setDependency($dep);
|
$jshandler->setDependency($dep);
|
||||||
@@ -1618,8 +1618,8 @@ class e107
|
|||||||
|
|
||||||
case 'theme':
|
case 'theme':
|
||||||
// data is e.g. 'jslib/mytheme.js'
|
// data is e.g. 'jslib/mytheme.js'
|
||||||
if(null !== $zone) $jshandler->headerTheme($data, $zone);
|
if(null !== $zone) $jshandler->headerTheme($data, $zone, $pre, $post);
|
||||||
else $jshandler->headerTheme($data);
|
else $jshandler->headerTheme($data, 5, $pre, $post);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'inline':
|
case 'inline':
|
||||||
@@ -1636,8 +1636,8 @@ class e107
|
|||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
// data is e.g. 'http://cdn.somesite.com/some.js'
|
// data is e.g. 'http://cdn.somesite.com/some.js'
|
||||||
if(null !== $zone) $jshandler->headerFile($data, $zone);
|
if(null !== $zone) $jshandler->headerFile($data, $zone, $pre, $post);
|
||||||
else $jshandler->headerFile($data);
|
else $jshandler->headerFile($data, 5, $pre, $post);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'footer':
|
case 'footer':
|
||||||
|
@@ -498,9 +498,9 @@ class e_jsmanager
|
|||||||
* @param integer $zone 1-5 (see header.php)
|
* @param integer $zone 1-5 (see header.php)
|
||||||
* @return e_jsmanager
|
* @return e_jsmanager
|
||||||
*/
|
*/
|
||||||
public function headerFile($file_path, $zone = 5)
|
public function headerFile($file_path, $zone = 5, $pre = '', $post = '')
|
||||||
{
|
{
|
||||||
$this->addJs('header', $file_path, $zone);
|
$this->addJs('header', $file_path, $zone, $pre, $post);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,9 +524,9 @@ class e_jsmanager
|
|||||||
* @param integer $zone 1-5 (see header.php)
|
* @param integer $zone 1-5 (see header.php)
|
||||||
* @return e_jsmanager
|
* @return e_jsmanager
|
||||||
*/
|
*/
|
||||||
public function headerTheme($file_path, $zone = 5)
|
public function headerTheme($file_path, $zone = 5, $pre = '', $post = '')
|
||||||
{
|
{
|
||||||
$this->headerFile(THEME.trim($file_path, '/'), $zone);
|
$this->headerFile(THEME.trim($file_path, '/'), $zone, $pre, $post);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,13 +850,13 @@ class e_jsmanager
|
|||||||
|
|
||||||
case 'plugin':
|
case 'plugin':
|
||||||
$file_path = explode(':', $file_path);
|
$file_path = explode(':', $file_path);
|
||||||
$file_path = '{e_PLUGIN}'.$file_path[0].'/'.trim($file_path[1], '/');
|
$file_path = '{e_PLUGIN}'.$file_path[0].'/'.trim($file_path[1], '/')."|{$pre}|{$post}";
|
||||||
$registry = &$this->_e_jslib_plugin;
|
$registry = &$this->_e_jslib_plugin;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'theme':
|
case 'theme':
|
||||||
$file_path = '{e_THEME}'.$this->getCurrentTheme().'/'.trim($file_path, '/');
|
$file_path = '{e_THEME}'.$this->getCurrentTheme().'/'.trim($file_path, '/')."|{$pre}|{$post}";
|
||||||
echo "file-Path = ".$file_path;
|
//echo "file-Path = ".$file_path;
|
||||||
$registry = &$this->_e_jslib_theme;
|
$registry = &$this->_e_jslib_theme;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -884,7 +884,7 @@ class e_jsmanager
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'other_css':
|
case 'other_css':
|
||||||
$file_path = $runtime_location.'|'.$tp->createConstants($file_path, 'mix');
|
$file_path = $runtime_location.'|'.$tp->createConstants($file_path, 'mix')."|{$pre}|{$post}";
|
||||||
if(!isset($this->_e_css['other'])) $this->_e_css['other'] = array();
|
if(!isset($this->_e_css['other'])) $this->_e_css['other'] = array();
|
||||||
$registry = &$this->_e_css['other'];
|
$registry = &$this->_e_css['other'];
|
||||||
$runtime = true;
|
$runtime = true;
|
||||||
@@ -898,7 +898,7 @@ class e_jsmanager
|
|||||||
|
|
||||||
|
|
||||||
case 'header':
|
case 'header':
|
||||||
$file_path = $tp->createConstants($file_path, 'mix');
|
$file_path = $tp->createConstants($file_path, 'mix')."|{$pre}|{$post}";
|
||||||
$zone = intval($runtime_location);
|
$zone = intval($runtime_location);
|
||||||
if($zone > 5 || $zone < 1)
|
if($zone > 5 || $zone < 1)
|
||||||
{
|
{
|
||||||
@@ -913,7 +913,7 @@ class e_jsmanager
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'footer':
|
case 'footer':
|
||||||
$file_path = $tp->createConstants($file_path, 'mix');
|
$file_path = $tp->createConstants($file_path, 'mix')."|{$pre}|{$post}";
|
||||||
$zone = intval($runtime_location);
|
$zone = intval($runtime_location);
|
||||||
if($zone > 5 || $zone < 1)
|
if($zone > 5 || $zone < 1)
|
||||||
{
|
{
|
||||||
@@ -1139,10 +1139,17 @@ class e_jsmanager
|
|||||||
}
|
}
|
||||||
elseif($external) //true or 'js'
|
elseif($external) //true or 'js'
|
||||||
{
|
{
|
||||||
|
|
||||||
if(strpos($path, 'http') === 0) continue; // not allowed
|
if(strpos($path, 'http') === 0) continue; // not allowed
|
||||||
|
|
||||||
|
$path = explode('|', $path, 3);
|
||||||
|
$pre = varset($path[1], '');
|
||||||
|
if($pre) $pre .= "\n";
|
||||||
|
$post = varset($path[2], '');
|
||||||
|
if($post) $post = "\n".$post;
|
||||||
|
$path = $path[0];
|
||||||
|
|
||||||
$path = $tp->replaceConstants($path, 'abs').'?external=1&'.$this->getCacheId();
|
$path = $tp->replaceConstants($path, 'abs').'?external=1&'.$this->getCacheId();
|
||||||
echo '<script type="text/javascript" src="'.$path.'"></script>';
|
echo $pre.'<script type="text/javascript" src="'.$path.'"></script>'.$post;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1176,6 +1183,14 @@ class e_jsmanager
|
|||||||
echo "\n";
|
echo "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$path = explode('|', $path, 3);
|
||||||
|
$pre = varset($path[1], '');
|
||||||
|
if($pre) $pre .= "\n";
|
||||||
|
$post = varset($path[2], '');
|
||||||
|
if($post) $post = "\n".$post;
|
||||||
|
$path = $path[0];
|
||||||
|
|
||||||
if($external)
|
if($external)
|
||||||
{
|
{
|
||||||
// Never use CacheID on a CDN script, always render if it's CDN
|
// Never use CacheID on a CDN script, always render if it's CDN
|
||||||
@@ -1188,7 +1203,7 @@ class e_jsmanager
|
|||||||
}
|
}
|
||||||
$path = $tp->replaceConstants($path, 'abs').'?'.$this->getCacheId();
|
$path = $tp->replaceConstants($path, 'abs').'?'.$this->getCacheId();
|
||||||
}
|
}
|
||||||
echo '<script type="text/javascript" src="'.$path.'"></script>';
|
echo $pre.'<script type="text/javascript" src="'.$path.'"></script>'.$post;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user