1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-13 18:14:26 +02:00

Meta-data clean-up and enhancements.

This commit is contained in:
CaMer0n
2012-05-11 03:52:57 +00:00
parent c244d683f8
commit 6ca55ce728
5 changed files with 204 additions and 11 deletions

View File

@@ -98,6 +98,13 @@ class e_jsmanager
* @var array
*/
protected $_e_css_src = array();
/**
* Meta
*
* @var array
*/
protected $_e_meta = array();
/**
* Runtime location
@@ -281,6 +288,19 @@ class e_jsmanager
$this->addJs('inline_css', $css_content, $media);
return $this;
}
/**
* Add Meta code to site header
*
* @param string $name
* @param string $content
* @return e_jsmanager
*/
public function coreMeta($name, $content = '')
{
$this->addJs('core_meta', $name, $content);
return $this;
}
/**
* Add Core JS library file(s) for inclusion from e_jslib routine
@@ -543,7 +563,7 @@ class e_jsmanager
return $this;
}
if($type == 'core' && substr($file_path,0,4)=='http' ) // Core using CDN.
if($type == 'core' && !is_array($file_path) && substr($file_path,0,4)=='http' ) // Core using CDN.
{
$type = 'header';
$runtime_location = 1;
@@ -618,6 +638,13 @@ class e_jsmanager
return $this;
break;
break;
case 'core_meta':
$this->_e_meta['core'][] = $file_path."|".$runtime_location;
$registry = &$this->_e_meta['core'];
return $this;
break;
break;
case 'header':
$file_path = $tp->createConstants($file_path, 'mix');
@@ -752,6 +779,11 @@ class e_jsmanager
$this->renderInline($this->_e_css_src, 'Inline CSS', 'css');
$this->_e_css_src = array();
break;
case 'core_meta':
$this->renderMeta($this->_e_meta, 'Meta', 'core');
$this->_e_meta['core'] = array();
break;
case 'footer':
if(true === $zone)
@@ -928,6 +960,46 @@ class e_jsmanager
break;
}
}
/**
* Render Meta source array
*
* @param array $js_content_array
* @param string $label added as comment if non-empty
* @return void
*/
function renderMeta($content_array, $label = '',$type = 'core')
{
if(empty($content_array))
{
return '';
}
$content_array[$type] = array_unique($content_array[$type]); //TODO quick fix, we need better control!
echo "\n";
if($label)
{
echo "<!-- [JSManager] ".$label." -->\n";
}
foreach($content_array[$type] as $met)
{
list($name,$content) = explode("|",$met);
echo "\n";
echo '<meta name="'.$name.'" content="'.$content.'" />';
}
echo "\n\n";
}
/**
* Returns true if currently running in