mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
Support of inline script tag attributes via js manager (set '$post' to e.g. '|async defer'
This commit is contained in:
@@ -1667,8 +1667,8 @@ class e107
|
|||||||
|
|
||||||
case 'footer':
|
case 'footer':
|
||||||
// data is e.g. '{e_PLUGIN}myplugin/jslib/myplug.js'
|
// data is e.g. '{e_PLUGIN}myplugin/jslib/myplug.js'
|
||||||
if(null !== $zone) $jshandler->footerFile($data, $zone);
|
if(null !== $zone) $jshandler->footerFile($data, $zone, $pre, $post);
|
||||||
else $jshandler->footerFile($data);
|
else $jshandler->footerFile($data, 5, $pre, $post);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// $type is plugin name
|
// $type is plugin name
|
||||||
|
@@ -512,9 +512,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 headerCore($file_path, $zone = 2)
|
public function headerCore($file_path, $zone = 2, $pre = '', $post = '')
|
||||||
{
|
{
|
||||||
$this->headerFile('{e_WEB_JS}'.trim($file_path, '/'), $zone);
|
$this->headerFile('{e_WEB_JS}'.trim($file_path, '/'), $zone, $pre, $post);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,9 +539,9 @@ class e_jsmanager
|
|||||||
* @param integer $zone 1-5 (see header.php) - REMOVED, actually we need to prevent zone change
|
* @param integer $zone 1-5 (see header.php) - REMOVED, actually we need to prevent zone change
|
||||||
* @return e_jsmanager
|
* @return e_jsmanager
|
||||||
*/
|
*/
|
||||||
public function headerPlugin($plugname, $file_path)
|
public function headerPlugin($plugname, $file_path, $pre, $post)
|
||||||
{
|
{
|
||||||
$this->headerFile('{e_PLUGIN}'.$plugname.'/'.trim($file_path, '/'), 2); // Zone 2 - after libraries
|
$this->headerFile('{e_PLUGIN}'.$plugname.'/'.trim($file_path, '/'), 2, $pre, $post); // Zone 2 - after libraries
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,9 +572,9 @@ class e_jsmanager
|
|||||||
* @param integer $priority 1-5 (see footer.php)
|
* @param integer $priority 1-5 (see footer.php)
|
||||||
* @return e_jsmanager
|
* @return e_jsmanager
|
||||||
*/
|
*/
|
||||||
public function footerFile($file_path, $priority = 5)
|
public function footerFile($file_path, $priority = 5, $pre = '', $post = '')
|
||||||
{
|
{
|
||||||
$this->addJs('footer', $file_path, $priority);
|
$this->addJs('footer', $file_path, $priority, $pre, $post);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,7 +845,7 @@ class e_jsmanager
|
|||||||
{
|
{
|
||||||
case 'core':
|
case 'core':
|
||||||
// added direct CDN support
|
// added direct CDN support
|
||||||
$file_path = (strpos($file_path, 'http') !== 0 ? '{e_WEB_JS}' : '').trim($file_path, '/');
|
$file_path = (strpos($file_path, 'http') !== 0 ? '{e_WEB_JS}' : '').trim($file_path, '/')."|{$pre}|{$post}";
|
||||||
$registry = &$this->_e_jslib_core;
|
$registry = &$this->_e_jslib_core;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1140,7 +1140,7 @@ 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 || strpos($path, '//') === 0) continue; // not allowed
|
||||||
|
|
||||||
$path = explode('|', $path, 3);
|
$path = explode('|', $path, 3);
|
||||||
$pre = varset($path[1], '');
|
$pre = varset($path[1], '');
|
||||||
@@ -1164,7 +1164,7 @@ class e_jsmanager
|
|||||||
{
|
{
|
||||||
// CDN fix, ignore URLs inside consolidation script, render as external scripts
|
// CDN fix, ignore URLs inside consolidation script, render as external scripts
|
||||||
$isExternal = false;
|
$isExternal = false;
|
||||||
if(strpos($path, 'http') === 0)
|
if(strpos($path, 'http') === 0 || strpos($path, '//') === 0)
|
||||||
{
|
{
|
||||||
if($external !== 'css') $isExternal = true;
|
if($external !== 'css') $isExternal = true;
|
||||||
}
|
}
|
||||||
@@ -1185,11 +1185,13 @@ class e_jsmanager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = explode('|', $path, 3);
|
$path = explode('|', $path, 4);
|
||||||
$pre = varset($path[1], '');
|
$pre = varset($path[1], '');
|
||||||
if($pre) $pre .= "\n";
|
if($pre) $pre .= "\n";
|
||||||
$post = varset($path[2], '');
|
$post = varset($path[2], '');
|
||||||
if($post) $post = "\n".$post;
|
if($post) $post = "\n".$post;
|
||||||
|
$inline = isset($path[3]) ? $path[3] : '';
|
||||||
|
if($inline) $inline = " ".$inline;
|
||||||
$path = $path[0];
|
$path = $path[0];
|
||||||
|
|
||||||
if($external)
|
if($external)
|
||||||
@@ -1204,7 +1206,7 @@ class e_jsmanager
|
|||||||
}
|
}
|
||||||
$path = $tp->replaceConstants($path, 'abs').'?'.$this->getCacheId();
|
$path = $tp->replaceConstants($path, 'abs').'?'.$this->getCacheId();
|
||||||
}
|
}
|
||||||
echo $pre.'<script type="text/javascript" src="'.$path.'"></script>'.$post;
|
echo $pre.'<script type="text/javascript" src="'.$path.'"'.$inline.'></script>'.$post;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user