Changeset 2096

Show
Ignore:
Timestamp:
02/21/2008 09:45:35 AM (9 months ago)
Author:
Shadowhand
Message:

Added html::meta(), fixing #423.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/helpers/html.php

    r2066 r2096  
    187187 
    188188        /** 
     189         * Creates a meta tag. 
     190         * 
     191         * @param   string|array   tag name, or an array of tags 
     192         * @param   string         tag value 
     193         * @return  string 
     194         */ 
     195        public static function meta($tag, $value = NULL) 
     196        { 
     197                if (is_array($tag)) 
     198                { 
     199                        $tags = array(); 
     200                        foreach ($tag as $t => $v) 
     201                        { 
     202                                // Build each tag and add it to the array 
     203                                $tags[] = html::meta($t, $v); 
     204                        } 
     205 
     206                        // Return all of the tags as a string 
     207                        return implode("\n", $tags); 
     208                } 
     209 
     210                // HTTP type meta tags 
     211                $http = array('content-type', 'expires', 'refresh', 'set-cookie'); 
     212 
     213                // Set the type attribute 
     214                $attr = in_array($tag, $http) ? 'http-equiv' : 'name'; 
     215 
     216                return '<meta '.$attr.'="'.$value.'" />'; 
     217        } 
     218 
     219        /** 
    189220         * Creates a stylesheet link. 
    190221         *