public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL) { if (preg_match('/^admin\\/(?<controller>[^\\/]++)(?:\\/(?<action>[^\\/\\.]++))?/i', $uri, $matches)) { if (isset($matches['action']) and $matches['action'] == 'details') { $matches['action'] = 'index'; } if (!Auth::instance()->has_role(rtrim($matches['controller'] . '.' . $matches['action'], '.'))) { return ''; } } return parent::anchor($uri, $title, $attributes, $protocol); }
public static function attributes(array $attributes = NULL) { if (empty($attributes)) { return ''; } foreach ($attributes as $key => $value) { if (is_array($value)) { $attributes[$key] = implode(' ', $value); } } return parent::attributes($attributes); }
public static function attributes(array $attributes = NULL) { // data-* attrubtes as an array if (isset($attributes['data']) and is_array($attributes['data'])) { $attributes = HTML::data_attributes($attributes['data']) + $attributes; unset($attributes['data']); } // class as an array if (isset($attributes['class']) and is_array($attributes['class'])) { $attributes['class'] = HTML::class_names($attributes['class']); } // id as an array if (isset($attributes['id']) and is_array($attributes['id'])) { $attributes['id'] = HTML::id_names($attributes['id']); } // style as an array if (isset($attributes['style']) and is_array($attributes['style'])) { $attributes['style'] = HTML::style_attributes($attributes['style']); } return parent::attributes($attributes); }
/** * Creates a image link. * * echo HTML::image('media/img/logo.png', array('alt' => 'My Company')); * * @param string file name * @param array default attributes * @param mixed protocol to pass to URL::base() * @param boolean include the index page * @return string * @uses URL::base * @uses HTML::attributes */ public static function image($file, array $attributes = NULL, $protocol = NULL, $index = FALSE) { $file = Swiftriver::get_cdn_url($file); return parent::image($file, $attributes, $protocol, $index); }