html_helper.php
Go to the documentation of this file.00001 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 if ( ! function_exists('heading'))
00042 {
00043 function heading($data = '', $h = '1')
00044 {
00045 return "<h".$h.">".$data."</h".$h.">";
00046 }
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 if ( ! function_exists('ul'))
00062 {
00063 function ul($list, $attributes = '')
00064 {
00065 return _list('ul', $list, $attributes);
00066 }
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 if ( ! function_exists('ol'))
00082 {
00083 function ol($list, $attributes = '')
00084 {
00085 return _list('ol', $list, $attributes);
00086 }
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 if ( ! function_exists('_list'))
00104 {
00105 function _list($type = 'ul', $list, $attributes = '', $depth = 0)
00106 {
00107
00108 if ( ! is_array($list))
00109 {
00110 return $list;
00111 }
00112
00113
00114 $out = str_repeat(" ", $depth);
00115
00116
00117 if (is_array($attributes))
00118 {
00119 $atts = '';
00120 foreach ($attributes as $key => $val)
00121 {
00122 $atts .= ' ' . $key . '="' . $val . '"';
00123 }
00124 $attributes = $atts;
00125 }
00126
00127
00128 $out .= "<".$type.$attributes.">\n";
00129
00130
00131
00132
00133 static $_last_list_item = '';
00134 foreach ($list as $key => $val)
00135 {
00136 $_last_list_item = $key;
00137
00138 $out .= str_repeat(" ", $depth + 2);
00139 $out .= "<li>";
00140
00141 if ( ! is_array($val))
00142 {
00143 $out .= $val;
00144 }
00145 else
00146 {
00147 $out .= $_last_list_item."\n";
00148 $out .= _list($type, $val, '', $depth + 4);
00149 $out .= str_repeat(" ", $depth + 2);
00150 }
00151
00152 $out .= "</li>\n";
00153 }
00154
00155
00156 $out .= str_repeat(" ", $depth);
00157
00158
00159 $out .= "</".$type.">\n";
00160
00161 return $out;
00162 }
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 if ( ! function_exists('br'))
00175 {
00176 function br($num = 1)
00177 {
00178 return str_repeat("<br />", $num);
00179 }
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 if ( ! function_exists('img'))
00194 {
00195 function img($src = '', $index_page = FALSE)
00196 {
00197 if ( ! is_array($src) )
00198 {
00199 $src = array('src' => $src);
00200 }
00201
00202 $img = '<img';
00203
00204 foreach ($src as $k=>$v)
00205 {
00206
00207 if ($k == 'src' AND strpos($v, '://') === FALSE)
00208 {
00209 $CI =& get_instance();
00210
00211 if ($index_page === TRUE)
00212 {
00213 $img .= ' src="'.$CI->config->site_url($v).'" ';
00214 }
00215 else
00216 {
00217 $img .= ' src="'.$CI->config->slash_item('base_url').$v.'" ';
00218 }
00219 }
00220 else
00221 {
00222 $img .= " $k=\"$v\" ";
00223 }
00224 }
00225
00226 $img .= '/>';
00227
00228 return $img;
00229 }
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 if ( ! function_exists('link_tag'))
00249 {
00250 function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
00251 {
00252 $CI =& get_instance();
00253
00254 $link = '<link ';
00255
00256 if (is_array($href))
00257 {
00258 foreach ($href as $k=>$v)
00259 {
00260 if ($k == 'href' AND strpos($v, '://') === FALSE)
00261 {
00262 if ($index_page === TRUE)
00263 {
00264 $link .= ' href="'.$CI->config->site_url($v).'" ';
00265 }
00266 else
00267 {
00268 $link .= ' href="'.$CI->config->slash_item('base_url').$v.'" ';
00269 }
00270 }
00271 else
00272 {
00273 $link .= "$k=\"$v\" ";
00274 }
00275 }
00276
00277 $link .= "/>\n";
00278 }
00279 else
00280 {
00281 if ( strpos($href, '://') !== FALSE)
00282 {
00283 $link .= ' href="'.$href.'" ';
00284 }
00285 elseif ($index_page === TRUE)
00286 {
00287 $link .= ' href="'.$CI->config->site_url($href).'" ';
00288 }
00289 else
00290 {
00291 $link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
00292 }
00293
00294 $link .= 'rel="'.$rel.'" type="'.$type.'" ';
00295
00296 if ($media != '')
00297 {
00298 $link .= 'media="'.$media.'" ';
00299 }
00300
00301 if ($title != '')
00302 {
00303 $link .= 'title="'.$title.'" ';
00304 }
00305
00306 $link .= '/>'."\n";
00307 }
00308
00309
00310 return $link;
00311 }
00312 }
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 if ( ! function_exists('meta'))
00324 {
00325 function meta($meta = array(), $newline = "\n")
00326 {
00327 $str = '';
00328 foreach ($meta as $key => $val)
00329 {
00330 $str .= '<meta http-equiv="'.$key.'" content="'.$val.'" />'.$newline;
00331 }
00332
00333 return $str;
00334 }
00335 }
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346 if ( ! function_exists('nbs'))
00347 {
00348 function nbs($num = 1)
00349 {
00350 return str_repeat(" ", $num);
00351 }
00352 }
00353
00354
00355
00356