From f63b9f20afad7c5f494970285c8141cef7ec016f Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Thu, 23 Oct 2008 20:46:18 +0000 Subject: Improved meta function --- system/helpers/html_helper.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'system') 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 .= ''.$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 .= ''.$newline; } return $str; -- cgit v1.2.3-24-g4f1b