Ticket #514: MY_html.php
| File MY_html.php, 1.0 kB (added by schnoodles, 10 months ago) |
|---|
| Line | |
|---|---|
| 1 | <?php defined('SYSPATH') or die('No direct script access.'); |
| 2 | /** |
| 3 | * HTML helper class. |
| 4 | * |
| 5 | * $Id:html.php 2096 2008-02-21 15:45:35Z Shadowhand $ |
| 6 | * |
| 7 | * @package Core |
| 8 | * @author Kohana Team |
| 9 | * @copyright (c) 2007-2008 Kohana Team |
| 10 | * @license http://kohanaphp.com/license.html |
| 11 | */ |
| 12 | class html extends html_Core { |
| 13 | |
| 14 | /** |
| 15 | * Creates a meta tag. |
| 16 | * |
| 17 | * @param string|array tag name, or an array of tags |
| 18 | * @param string tag value |
| 19 | * @return string |
| 20 | */ |
| 21 | public static function meta($tag, $value = NULL) |
| 22 | { |
| 23 | if (is_array($tag)) |
| 24 | { |
| 25 | $tags = array(); |
| 26 | foreach ($tag as $t => $v) |
| 27 | { |
| 28 | // Build each tag and add it to the array |
| 29 | $tags[] = html::meta($t, $v); |
| 30 | } |
| 31 | |
| 32 | // Return all of the tags as a string |
| 33 | return implode("\n", $tags); |
| 34 | } |
| 35 | |
| 36 | // HTTP type meta tags |
| 37 | $http = array('content-type', 'expires', 'refresh', 'set-cookie'); |
| 38 | |
| 39 | // Set the type attribute |
| 40 | $attr = in_array($tag, $http) ? 'http-equiv' : 'name'; |
| 41 | |
| 42 | return '<meta '.$attr.'="'.$tag.'" content="'.$value.'" />'; |
| 43 | } |
| 44 | |
| 45 | } // End html |
