Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 1 | <?php |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
darwinel | 871754a | 2014-02-11 17:34:57 +0100 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 27 | defined('BASEPATH') OR exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 28 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 29 | /** |
| 30 | * CodeIgniter HTML Helpers |
| 31 | * |
| 32 | * @package CodeIgniter |
| 33 | * @subpackage Helpers |
| 34 | * @category Helpers |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 35 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 36 | * @link http://codeigniter.com/user_guide/helpers/html_helper.html |
| 37 | */ |
| 38 | |
| 39 | // ------------------------------------------------------------------------ |
| 40 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 41 | if ( ! function_exists('heading')) |
| 42 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 43 | /** |
| 44 | * Heading |
| 45 | * |
| 46 | * Generates an HTML heading tag. |
| 47 | * |
| 48 | * @param string content |
| 49 | * @param int heading level |
| 50 | * @param string |
| 51 | * @return string |
| 52 | */ |
Greg Aker | 826429c | 2011-04-18 09:40:19 -0500 | [diff] [blame] | 53 | function heading($data = '', $h = '1', $attributes = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 54 | { |
Eric Barnes | acedd2b | 2012-07-29 00:15:40 -0400 | [diff] [blame] | 55 | return '<h'.$h._stringify_attributes($attributes).'>'.$data.'</h'.$h.'>'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 56 | } |
| 57 | } |
| 58 | |
| 59 | // ------------------------------------------------------------------------ |
| 60 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 61 | if ( ! function_exists('ul')) |
| 62 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 63 | /** |
| 64 | * Unordered List |
| 65 | * |
| 66 | * Generates an HTML unordered list from an single or multi-dimensional array. |
| 67 | * |
| 68 | * @param array |
| 69 | * @param mixed |
| 70 | * @return string |
| 71 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 72 | function ul($list, $attributes = '') |
| 73 | { |
| 74 | return _list('ul', $list, $attributes); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // ------------------------------------------------------------------------ |
| 79 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 80 | if ( ! function_exists('ol')) |
| 81 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 82 | /** |
| 83 | * Ordered List |
| 84 | * |
| 85 | * Generates an HTML ordered list from an single or multi-dimensional array. |
| 86 | * |
| 87 | * @param array |
| 88 | * @param mixed |
| 89 | * @return string |
| 90 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 91 | function ol($list, $attributes = '') |
| 92 | { |
| 93 | return _list('ol', $list, $attributes); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // ------------------------------------------------------------------------ |
| 98 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 99 | if ( ! function_exists('_list')) |
| 100 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 101 | /** |
| 102 | * Generates the list |
| 103 | * |
| 104 | * Generates an HTML ordered list from an single or multi-dimensional array. |
| 105 | * |
| 106 | * @param string |
| 107 | * @param mixed |
| 108 | * @param mixed |
| 109 | * @param int |
| 110 | * @return string |
| 111 | */ |
Rasmus Lerdorf | e736f49 | 2013-05-18 10:25:03 -0400 | [diff] [blame] | 112 | function _list($type = 'ul', $list = array(), $attributes = '', $depth = 0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 113 | { |
| 114 | // If an array wasn't submitted there's nothing to do... |
| 115 | if ( ! is_array($list)) |
| 116 | { |
| 117 | return $list; |
| 118 | } |
| 119 | |
| 120 | // Set the indentation based on the depth |
Andrey Andreev | ea41c8a | 2014-02-26 18:31:02 +0200 | [diff] [blame] | 121 | $out = str_repeat(' ', $depth) |
| 122 | // Write the opening list tag |
| 123 | .'<'.$type._stringify_attributes($attributes).">\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 124 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 125 | |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 126 | // Cycle through the list elements. If an array is |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 127 | // encountered we will recursively call _list() |
| 128 | |
| 129 | static $_last_list_item = ''; |
| 130 | foreach ($list as $key => $val) |
| 131 | { |
| 132 | $_last_list_item = $key; |
| 133 | |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 134 | $out .= str_repeat(' ', $depth + 2).'<li>'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 135 | |
| 136 | if ( ! is_array($val)) |
| 137 | { |
| 138 | $out .= $val; |
| 139 | } |
| 140 | else |
| 141 | { |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 142 | $out .= $_last_list_item."\n"._list($type, $val, '', $depth + 4).str_repeat(' ', $depth + 2); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | $out .= "</li>\n"; |
| 146 | } |
| 147 | |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 148 | // Set the indentation for the closing tag and apply it |
| 149 | return $out.str_repeat(' ', $depth).'</'.$type.">\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
| 153 | // ------------------------------------------------------------------------ |
| 154 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 155 | if ( ! function_exists('img')) |
| 156 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 157 | /** |
| 158 | * Image |
| 159 | * |
| 160 | * Generates an <img /> element |
| 161 | * |
| 162 | * @param mixed |
| 163 | * @param bool |
Eric Barnes | 62ab8b2 | 2012-07-28 14:57:04 -0400 | [diff] [blame] | 164 | * @param mixed |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 165 | * @return string |
| 166 | */ |
Eric Barnes | 62ab8b2 | 2012-07-28 14:57:04 -0400 | [diff] [blame] | 167 | function img($src = '', $index_page = FALSE, $attributes = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 168 | { |
| 169 | if ( ! is_array($src) ) |
| 170 | { |
| 171 | $src = array('src' => $src); |
| 172 | } |
| 173 | |
Derek Allard | a0905f3 | 2010-07-05 08:11:33 -0400 | [diff] [blame] | 174 | // If there is no alt attribute defined, set it to an empty string |
| 175 | if ( ! isset($src['alt'])) |
| 176 | { |
| 177 | $src['alt'] = ''; |
| 178 | } |
| 179 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 180 | $img = '<img'; |
| 181 | |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 182 | foreach ($src as $k => $v) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 183 | { |
Andrey Andreev | d2e3a6f | 2014-03-12 16:22:46 +0200 | [diff] [blame] | 184 | if ($k === 'src' && ! preg_match('#^([a-z]+:)?//#i', $v)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 185 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 186 | if ($index_page === TRUE) |
| 187 | { |
Andrey Andreev | 119d8a7 | 2014-01-08 15:27:53 +0200 | [diff] [blame] | 188 | $img .= ' src="'.get_instance()->config->site_url($v).'"'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 189 | } |
| 190 | else |
| 191 | { |
Andrey Andreev | 119d8a7 | 2014-01-08 15:27:53 +0200 | [diff] [blame] | 192 | $img .= ' src="'.get_instance()->config->slash_item('base_url').$v.'"'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | else |
| 196 | { |
Andrey Andreev | 2046b1a | 2012-03-26 21:07:04 +0300 | [diff] [blame] | 197 | $img .= ' '.$k.'="'.$v.'"'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 198 | } |
| 199 | } |
| 200 | |
Andrey Andreev | 6a64f85 | 2012-08-15 11:16:47 +0300 | [diff] [blame] | 201 | return $img._stringify_attributes($attributes).' />'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
| 205 | // ------------------------------------------------------------------------ |
| 206 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 207 | if ( ! function_exists('doctype')) |
| 208 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 209 | /** |
| 210 | * Doctype |
| 211 | * |
| 212 | * Generates a page document type declaration |
| 213 | * |
Przemyslaw Tomaszewski | 8711aeb | 2012-07-22 03:28:41 +0200 | [diff] [blame] | 214 | * Examples of valid options: html5, xhtml-11, xhtml-strict, xhtml-trans, |
| 215 | * xhtml-frame, html4-strict, html4-trans, and html4-frame. |
| 216 | * All values are saved in the doctypes config file. |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 217 | * |
| 218 | * @param string type The doctype to be generated |
| 219 | * @return string |
| 220 | */ |
Derek Allard | 93bddd1 | 2009-04-14 19:27:38 +0000 | [diff] [blame] | 221 | function doctype($type = 'xhtml1-strict') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 222 | { |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 223 | static $doctypes; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 224 | |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 225 | if ( ! is_array($doctypes)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 226 | { |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 227 | if (file_exists(APPPATH.'config/doctypes.php')) |
Greg Aker | d96f882 | 2011-12-27 16:23:47 -0600 | [diff] [blame] | 228 | { |
| 229 | include(APPPATH.'config/doctypes.php'); |
| 230 | } |
Eric Barnes | 9280834 | 2011-03-18 09:02:37 -0400 | [diff] [blame] | 231 | |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 232 | if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 233 | { |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 234 | include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); |
| 235 | } |
| 236 | |
| 237 | if (empty($_doctypes) OR ! is_array($_doctypes)) |
| 238 | { |
| 239 | $doctypes = array(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 240 | return FALSE; |
| 241 | } |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 242 | |
| 243 | $doctypes = $_doctypes; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 244 | } |
| 245 | |
Andrey Andreev | 0687911 | 2013-01-29 15:05:02 +0200 | [diff] [blame] | 246 | return isset($doctypes[$type]) ? $doctypes[$type] : FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
| 250 | // ------------------------------------------------------------------------ |
| 251 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 252 | if ( ! function_exists('link_tag')) |
| 253 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 254 | /** |
| 255 | * Link |
| 256 | * |
| 257 | * Generates link to a CSS file |
| 258 | * |
| 259 | * @param mixed stylesheet hrefs or an array |
| 260 | * @param string rel |
| 261 | * @param string type |
| 262 | * @param string title |
| 263 | * @param string media |
| 264 | * @param bool should index_page be added to the css path |
| 265 | * @return string |
| 266 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 267 | function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE) |
| 268 | { |
| 269 | $CI =& get_instance(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 270 | $link = '<link '; |
| 271 | |
| 272 | if (is_array($href)) |
| 273 | { |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 274 | foreach ($href as $k => $v) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 275 | { |
Andrey Andreev | d2e3a6f | 2014-03-12 16:22:46 +0200 | [diff] [blame] | 276 | if ($k === 'href' && ! preg_match('#^([a-z]+:)?//#i', $v)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 277 | { |
| 278 | if ($index_page === TRUE) |
| 279 | { |
Derek Allard | 76763bb | 2009-09-16 11:25:20 +0000 | [diff] [blame] | 280 | $link .= 'href="'.$CI->config->site_url($v).'" '; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 281 | } |
| 282 | else |
| 283 | { |
Derek Allard | 76763bb | 2009-09-16 11:25:20 +0000 | [diff] [blame] | 284 | $link .= 'href="'.$CI->config->slash_item('base_url').$v.'" '; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | else |
| 288 | { |
Andrey Andreev | 2046b1a | 2012-03-26 21:07:04 +0300 | [diff] [blame] | 289 | $link .= $k.'="'.$v.'" '; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 290 | } |
| 291 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 292 | } |
| 293 | else |
| 294 | { |
Emmanuel Grognet | 60f78b4 | 2014-05-16 08:25:15 +0200 | [diff] [blame] | 295 | if (preg_match('#^([a-z]+:)?//#i', $href)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 296 | { |
Derek Allard | 292dcd8 | 2009-09-16 11:26:32 +0000 | [diff] [blame] | 297 | $link .= 'href="'.$href.'" '; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 298 | } |
| 299 | elseif ($index_page === TRUE) |
| 300 | { |
Derek Allard | 76763bb | 2009-09-16 11:25:20 +0000 | [diff] [blame] | 301 | $link .= 'href="'.$CI->config->site_url($href).'" '; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 302 | } |
| 303 | else |
| 304 | { |
Derek Allard | 76763bb | 2009-09-16 11:25:20 +0000 | [diff] [blame] | 305 | $link .= 'href="'.$CI->config->slash_item('base_url').$href.'" '; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | $link .= 'rel="'.$rel.'" type="'.$type.'" '; |
| 309 | |
Alex Bilbie | 773ccc3 | 2012-06-02 11:11:08 +0100 | [diff] [blame] | 310 | if ($media !== '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 311 | { |
| 312 | $link .= 'media="'.$media.'" '; |
| 313 | } |
| 314 | |
Alex Bilbie | 773ccc3 | 2012-06-02 11:11:08 +0100 | [diff] [blame] | 315 | if ($title !== '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 316 | { |
| 317 | $link .= 'title="'.$title.'" '; |
| 318 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 319 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 320 | |
Andrey Andreev | 2046b1a | 2012-03-26 21:07:04 +0300 | [diff] [blame] | 321 | return $link."/>\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | |
| 325 | // ------------------------------------------------------------------------ |
| 326 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 327 | if ( ! function_exists('meta')) |
| 328 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 329 | /** |
| 330 | * Generates meta tags from an array of key/values |
| 331 | * |
| 332 | * @param array |
| 333 | * @param string |
| 334 | * @param string |
| 335 | * @param string |
| 336 | * @return string |
| 337 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 338 | function meta($name = '', $content = '', $type = 'name', $newline = "\n") |
| 339 | { |
| 340 | // Since we allow the data to be passes as a string, a simple array |
| 341 | // or a multidimensional one, we need to do a little prepping. |
| 342 | if ( ! is_array($name)) |
| 343 | { |
| 344 | $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline)); |
| 345 | } |
Andrey Andreev | 2046b1a | 2012-03-26 21:07:04 +0300 | [diff] [blame] | 346 | elseif (isset($name['name'])) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 347 | { |
| 348 | // Turn single array into multidimensional |
Andrey Andreev | 2046b1a | 2012-03-26 21:07:04 +0300 | [diff] [blame] | 349 | $name = array($name); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | $str = ''; |
| 353 | foreach ($name as $meta) |
| 354 | { |
Andrey Andreev | ea41c8a | 2014-02-26 18:31:02 +0200 | [diff] [blame] | 355 | $type = (isset($meta['type']) && $meta['type'] !== 'name') ? 'http-equiv' : 'name'; |
Andrey Andreev | ae31eb5 | 2012-05-17 14:54:15 +0300 | [diff] [blame] | 356 | $name = isset($meta['name']) ? $meta['name'] : ''; |
| 357 | $content = isset($meta['content']) ? $meta['content'] : ''; |
| 358 | $newline = isset($meta['newline']) ? $meta['newline'] : "\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 359 | |
| 360 | $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline; |
| 361 | } |
| 362 | |
| 363 | return $str; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | // ------------------------------------------------------------------------ |
| 368 | |
Andrey Andreev | ea41c8a | 2014-02-26 18:31:02 +0200 | [diff] [blame] | 369 | if ( ! function_exists('br')) |
| 370 | { |
| 371 | /** |
| 372 | * Generates HTML BR tags based on number supplied |
| 373 | * |
Andrey Andreev | 59f0426 | 2014-02-26 19:04:36 +0200 | [diff] [blame] | 374 | * @deprecated 3.0.0 Use str_repeat() instead |
Andrey Andreev | ea41c8a | 2014-02-26 18:31:02 +0200 | [diff] [blame] | 375 | * @param int $count Number of times to repeat the tag |
| 376 | * @return string |
| 377 | */ |
| 378 | function br($count = 1) |
| 379 | { |
| 380 | return str_repeat('<br />', $count); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | // ------------------------------------------------------------------------ |
| 385 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 386 | if ( ! function_exists('nbs')) |
| 387 | { |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 388 | /** |
| 389 | * Generates non-breaking space entities based on number supplied |
| 390 | * |
Andrey Andreev | 59f0426 | 2014-02-26 19:04:36 +0200 | [diff] [blame] | 391 | * @deprecated 3.0.0 Use str_repeat() instead |
Timothy Warren | 01b129a | 2012-04-27 11:36:50 -0400 | [diff] [blame] | 392 | * @param int |
| 393 | * @return string |
| 394 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 395 | function nbs($num = 1) |
| 396 | { |
Andrey Andreev | 1e6b72c | 2012-01-06 19:09:22 +0200 | [diff] [blame] | 397 | return str_repeat(' ', $num); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 401 | /* End of file html_helper.php */ |
Andrey Andreev | c5a7c5f | 2013-07-17 20:10:09 +0300 | [diff] [blame] | 402 | /* Location: ./system/helpers/html_helper.php */ |