1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-13 01:54:12 +02:00

Fixes #1344 - ejs_preload legacy javascript removed. Replaced with e107::link($attributes); for adding 'prefetch' and other <link> tags to the head.

This commit is contained in:
Cameron
2016-02-09 15:57:07 -08:00
parent 61f2712c09
commit fee3764dff
5 changed files with 94 additions and 18 deletions

View File

@@ -150,6 +150,14 @@ class e_jsmanager
*/
protected $_index_all = array();
/**
* Registered link tags files by type (core|theme|plugin|other)
*
* @var array
*/
protected $_e_link = array();
/**
* Registered CSS files by type (core|theme|plugin|other)
*
@@ -783,6 +791,62 @@ class e_jsmanager
}
}
/**
* Add a <link> tag to the head.
* @param array $attributes key>value pairs
* @example addLink(array('rel'=>'prefetch', 'href'=>THEME.'images/browsers.png'));
*/
public function addLink($attributes=array())
{
if(!empty($attributes))
{
$this->_e_link[] = $attributes;
}
}
/**
* Render all link tags. (other than css)
* @return null
*/
public function renderLinks()
{
if(empty($this->_e_link))
{
return null;
}
$text = '';
foreach($this->_e_link as $v)
{
if(!empty($v['type']))
{
if($v['type'] == 'text/css' || $v['rel'] == 'stylesheet') // not for this purpose. use e107::css();
{
continue;
}
}
$text .= "\n<link";
foreach($v as $key=>$val)
{
if(!empty($val))
{
$text .= " ".$key."=\"".$val."\"";
}
}
$text .= " />";
}
echo $text;
}
/**
* Require JS file(s). Used by corresponding public proxy methods.
*