123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- if ( ! function_exists('heading'))
- {
-
- function heading($data = '', $h = '1', $attributes = '')
- {
- return '<h'.$h._stringify_attributes($attributes).'>'.$data.'</h'.$h.'>';
- }
- }
- if ( ! function_exists('ul'))
- {
-
- function ul($list, $attributes = '')
- {
- return _list('ul', $list, $attributes);
- }
- }
- if ( ! function_exists('ol'))
- {
-
- function ol($list, $attributes = '')
- {
- return _list('ol', $list, $attributes);
- }
- }
- if ( ! function_exists('_list'))
- {
-
- function _list($type = 'ul', $list = array(), $attributes = '', $depth = 0)
- {
-
- if ( ! is_array($list))
- {
- return $list;
- }
-
- $out = str_repeat(' ', $depth)
-
- .'<'.$type._stringify_attributes($attributes).">\n";
-
-
- static $_last_list_item = '';
- foreach ($list as $key => $val)
- {
- $_last_list_item = $key;
- $out .= str_repeat(' ', $depth + 2).'<li>';
- if ( ! is_array($val))
- {
- $out .= $val;
- }
- else
- {
- $out .= $_last_list_item."\n"._list($type, $val, '', $depth + 4).str_repeat(' ', $depth + 2);
- }
- $out .= "</li>\n";
- }
-
- return $out.str_repeat(' ', $depth).'</'.$type.">\n";
- }
- }
- if ( ! function_exists('img'))
- {
-
- function img($src = '', $index_page = FALSE, $attributes = '')
- {
- if ( ! is_array($src) )
- {
- $src = array('src' => $src);
- }
-
- if ( ! isset($src['alt']))
- {
- $src['alt'] = '';
- }
- $img = '<img';
- foreach ($src as $k => $v)
- {
- if ($k === 'src' && ! preg_match('#^([a-z]+:)?//#i', $v))
- {
- if ($index_page === TRUE)
- {
- $img .= ' src="'.get_instance()->config->site_url($v).'"';
- }
- else
- {
- $img .= ' src="'.get_instance()->config->slash_item('base_url').$v.'"';
- }
- }
- else
- {
- $img .= ' '.$k.'="'.$v.'"';
- }
- }
- return $img._stringify_attributes($attributes).' />';
- }
- }
- if ( ! function_exists('doctype'))
- {
-
- function doctype($type = 'xhtml1-strict')
- {
- static $doctypes;
- if ( ! is_array($doctypes))
- {
- if (file_exists(APPPATH.'config/doctypes.php'))
- {
- include(APPPATH.'config/doctypes.php');
- }
- if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
- }
- if (empty($_doctypes) OR ! is_array($_doctypes))
- {
- $doctypes = array();
- return FALSE;
- }
- $doctypes = $_doctypes;
- }
- return isset($doctypes[$type]) ? $doctypes[$type] : FALSE;
- }
- }
- if ( ! function_exists('link_tag'))
- {
-
- function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
- {
- $CI =& get_instance();
- $link = '<link ';
- if (is_array($href))
- {
- foreach ($href as $k => $v)
- {
- if ($k === 'href' && ! preg_match('#^([a-z]+:)?//#i', $v))
- {
- if ($index_page === TRUE)
- {
- $link .= 'href="'.$CI->config->site_url($v).'" ';
- }
- else
- {
- $link .= 'href="'.$CI->config->slash_item('base_url').$v.'" ';
- }
- }
- else
- {
- $link .= $k.'="'.$v.'" ';
- }
- }
- }
- else
- {
- if (preg_match('#^([a-z]+:)?//#i', $href))
- {
- $link .= 'href="'.$href.'" ';
- }
- elseif ($index_page === TRUE)
- {
- $link .= 'href="'.$CI->config->site_url($href).'" ';
- }
- else
- {
- $link .= 'href="'.$CI->config->slash_item('base_url').$href.'" ';
- }
- $link .= 'rel="'.$rel.'" type="'.$type.'" ';
- if ($media !== '')
- {
- $link .= 'media="'.$media.'" ';
- }
- if ($title !== '')
- {
- $link .= 'title="'.$title.'" ';
- }
- }
- return $link."/>\n";
- }
- }
- if ( ! function_exists('meta'))
- {
-
- function meta($name = '', $content = '', $type = 'name', $newline = "\n")
- {
-
-
- if ( ! is_array($name))
- {
- $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
- }
- elseif (isset($name['name']))
- {
-
- $name = array($name);
- }
- $str = '';
- foreach ($name as $meta)
- {
- $type = (isset($meta['type']) && $meta['type'] !== 'name') ? 'http-equiv' : 'name';
- $name = isset($meta['name']) ? $meta['name'] : '';
- $content = isset($meta['content']) ? $meta['content'] : '';
- $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
- $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
- }
- return $str;
- }
- }
- if ( ! function_exists('br'))
- {
-
- function br($count = 1)
- {
- return str_repeat('<br />', $count);
- }
- }
- if ( ! function_exists('nbs'))
- {
-
- function nbs($num = 1)
- {
- return str_repeat(' ', $num);
- }
- }
|