1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5
* An open source application development framework for PHP 5.1.6 or newer
8
* @author ExpressionEngine Dev Team
9
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10
* @license http://codeigniter.com/user_guide/license.html
11
* @link http://codeigniter.com
16
// ------------------------------------------------------------------------
19
* CodeIgniter HTML Helpers
21
* @package CodeIgniter
24
* @author ExpressionEngine Dev Team
25
* @link http://codeigniter.com/user_guide/helpers/html_helper.html
28
// ------------------------------------------------------------------------
33
* Generates an HTML heading tag. First param is the data.
34
* Second param is the size of the heading tag.
41
if ( ! function_exists('heading'))
43
function heading($data = '', $h = '1', $attributes = '')
45
$attributes = ($attributes != '') ? ' '.$attributes : $attributes;
46
return "<h".$h.$attributes.">".$data."</h".$h.">";
50
// ------------------------------------------------------------------------
55
* Generates an HTML unordered list from an single or multi-dimensional array.
62
if ( ! function_exists('ul'))
64
function ul($list, $attributes = '')
66
return _list('ul', $list, $attributes);
70
// ------------------------------------------------------------------------
75
* Generates an HTML ordered list from an single or multi-dimensional array.
82
if ( ! function_exists('ol'))
84
function ol($list, $attributes = '')
86
return _list('ol', $list, $attributes);
90
// ------------------------------------------------------------------------
95
* Generates an HTML ordered list from an single or multi-dimensional array.
104
if ( ! function_exists('_list'))
106
function _list($type = 'ul', $list, $attributes = '', $depth = 0)
108
// If an array wasn't submitted there's nothing to do...
109
if ( ! is_array($list))
114
// Set the indentation based on the depth
115
$out = str_repeat(" ", $depth);
117
// Were any attributes submitted? If so generate a string
118
if (is_array($attributes))
121
foreach ($attributes as $key => $val)
123
$atts .= ' ' . $key . '="' . $val . '"';
127
elseif (is_string($attributes) AND strlen($attributes) > 0)
129
$attributes = ' '. $attributes;
132
// Write the opening list tag
133
$out .= "<".$type.$attributes.">\n";
135
// Cycle through the list elements. If an array is
136
// encountered we will recursively call _list()
138
static $_last_list_item = '';
139
foreach ($list as $key => $val)
141
$_last_list_item = $key;
143
$out .= str_repeat(" ", $depth + 2);
146
if ( ! is_array($val))
152
$out .= $_last_list_item."\n";
153
$out .= _list($type, $val, '', $depth + 4);
154
$out .= str_repeat(" ", $depth + 2);
160
// Set the indentation for the closing tag
161
$out .= str_repeat(" ", $depth);
163
// Write the closing list tag
164
$out .= "</".$type.">\n";
170
// ------------------------------------------------------------------------
173
* Generates HTML BR tags based on number supplied
179
if ( ! function_exists('br'))
181
function br($num = 1)
183
return str_repeat("<br />", $num);
187
// ------------------------------------------------------------------------
192
* Generates an <img /> element
198
if ( ! function_exists('img'))
200
function img($src = '', $index_page = FALSE)
202
if ( ! is_array($src) )
204
$src = array('src' => $src);
207
// If there is no alt attribute defined, set it to an empty string
208
if ( ! isset($src['alt']))
215
foreach ($src as $k=>$v)
218
if ($k == 'src' AND strpos($v, '://') === FALSE)
220
$CI =& get_instance();
222
if ($index_page === TRUE)
224
$img .= ' src="'.$CI->config->site_url($v).'"';
228
$img .= ' src="'.$CI->config->slash_item('base_url').$v.'"';
233
$img .= " $k=\"$v\"";
243
// ------------------------------------------------------------------------
248
* Generates a page document type declaration
250
* Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
251
* html4-strict, html4-trans, and html4-frame. Values are saved in the
252
* doctypes config file.
255
* @param string type The doctype to be generated
258
if ( ! function_exists('doctype'))
260
function doctype($type = 'xhtml1-strict')
264
if ( ! is_array($_doctypes))
266
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
268
include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
270
elseif (is_file(APPPATH.'config/doctypes.php'))
272
include(APPPATH.'config/doctypes.php');
275
if ( ! is_array($_doctypes))
281
if (isset($_doctypes[$type]))
283
return $_doctypes[$type];
292
// ------------------------------------------------------------------------
297
* Generates link to a CSS file
300
* @param mixed stylesheet hrefs or an array
303
* @param string title
304
* @param string media
305
* @param boolean should index_page be added to the css path
308
if ( ! function_exists('link_tag'))
310
function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
312
$CI =& get_instance();
318
foreach ($href as $k=>$v)
320
if ($k == 'href' AND strpos($v, '://') === FALSE)
322
if ($index_page === TRUE)
324
$link .= 'href="'.$CI->config->site_url($v).'" ';
328
$link .= 'href="'.$CI->config->slash_item('base_url').$v.'" ';
333
$link .= "$k=\"$v\" ";
341
if ( strpos($href, '://') !== FALSE)
343
$link .= 'href="'.$href.'" ';
345
elseif ($index_page === TRUE)
347
$link .= 'href="'.$CI->config->site_url($href).'" ';
351
$link .= 'href="'.$CI->config->slash_item('base_url').$href.'" ';
354
$link .= 'rel="'.$rel.'" type="'.$type.'" ';
358
$link .= 'media="'.$media.'" ';
363
$link .= 'title="'.$title.'" ';
374
// ------------------------------------------------------------------------
377
* Generates meta tags from an array of key/values
383
if ( ! function_exists('meta'))
385
function meta($name = '', $content = '', $type = 'name', $newline = "\n")
387
// Since we allow the data to be passes as a string, a simple array
388
// or a multidimensional one, we need to do a little prepping.
389
if ( ! is_array($name))
391
$name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
395
// Turn single array into multidimensional
396
if (isset($name['name']))
398
$name = array($name);
403
foreach ($name as $meta)
405
$type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
406
$name = ( ! isset($meta['name'])) ? '' : $meta['name'];
407
$content = ( ! isset($meta['content'])) ? '' : $meta['content'];
408
$newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline'];
410
$str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
417
// ------------------------------------------------------------------------
420
* Generates non-breaking space entities based on number supplied
426
if ( ! function_exists('nbs'))
428
function nbs($num = 1)
430
return str_repeat(" ", $num);
435
/* End of file html_helper.php */
436
/* Location: ./system/helpers/html_helper.php */
b'\\ No newline at end of file'