diff options
author | Rick Ellis <rick.ellis@ellislab.com> | 2008-10-23 22:46:18 +0200 |
---|---|---|
committer | Rick Ellis <rick.ellis@ellislab.com> | 2008-10-23 22:46:18 +0200 |
commit | f63b9f20afad7c5f494970285c8141cef7ec016f (patch) | |
tree | e49fce0d7d3bb8fa5de422a261afb6552ae43317 /system/helpers | |
parent | a6f5ad0588af7c391f8a4ee053d3fe5220df9865 (diff) |
Improved meta function
Diffstat (limited to 'system/helpers')
-rw-r--r-- | system/helpers/html_helper.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index e175c4c05..ef5a84a4d 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -322,12 +322,32 @@ if ( ! function_exists('link_tag')) */
if ( ! function_exists('meta'))
{
- function meta($meta = array(), $newline = "\n")
+ function meta($name = '', $content = '', $type = 'name', $newline = "\n")
{
+ // Since we allow the data to be passes as a string, a simple array
+ // or a multidimensional one, we need to do a little prepping.
+ if ( ! is_array($name))
+ {
+ $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
+ }
+ else
+ {
+ // Turn single array into multidimensional
+ if (isset($name['name']))
+ {
+ $name = array($name);
+ }
+ }
+
$str = '';
- foreach ($meta as $key => $val)
+ foreach ($name as $meta)
{
- $str .= '<meta http-equiv="'.$key.'" content="'.$val.'" />'.$newline;
+ $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
+ $name = ( ! isset($meta['name'])) ? '' : $meta['name'];
+ $content = ( ! isset($meta['content'])) ? '' : $meta['content'];
+ $newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline'];
+
+ $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
}
return $str;
|