/ Published in: PHP
My Kohana HTML Helper
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class html extends html_Core { public static function lianchor(array $links, $curr_check = NULL, $li_active_class = NULL, $a_active_class = NULL) { $output = null; foreach($links as $link => $name) { $li_class = null; $a_class = null; if($link == $curr_check) { if($li_active_class != NULL) if($a_active_class != NULL) } $output .= '<li'.parent::attributes($li_class).'>'.parent::anchor($link, $name, $a_class).'</li>'."\n"; } return $output; } public static function script($script, $index = FALSE) { $compiled = ''; { foreach ($script as $name) { $compiled .= html::script($name, $index); } } else { { // Add the suffix only when it's not already present $script = url::base((bool) $index).$script; } if (substr_compare($script, '.js', -3, 3, FALSE) !== 0 && substr_compare($script, '/', -1, 1, FALSE) !== 0) { // Add the javascript suffix $script .= '.js'; } $compiled = '<script type="text/javascript" src="'.$script.'"></script>'; } return $compiled."\n"; } public static function image($src = NULL, $alt = NULL, $index = FALSE) { // Create attribute list { $attributes += $alt; } { // Add alt to attributes $attributes['alt'] = $alt; } else { $attributes['alt'] = ''; } { // Make the src attribute into an absolute URL $attributes['src'] = url::base($index).$attributes['src']; } return '<img'.html::attributes($attributes).' />'; } }