diff options
Diffstat (limited to 'app/Helper/UrlHelper.php')
-rw-r--r-- | app/Helper/UrlHelper.php | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/app/Helper/UrlHelper.php b/app/Helper/UrlHelper.php index 2127c69e..94412cf5 100644 --- a/app/Helper/UrlHelper.php +++ b/app/Helper/UrlHelper.php @@ -42,29 +42,67 @@ class UrlHelper extends Base */ public function button($icon, $label, $controller, $action, array $params = array(), $class = '') { - $icon = '<i class="fa '.$icon.' fa-fw"></i> '; + $html = '<i class="fa fa-'.$icon.' fa-fw"></i> '.$label; $class = 'btn '.$class; - return $this->link($icon.$label, $controller, $action, $params, false, $class); + return $this->link($html, $controller, $action, $params, false, $class); + } + + /** + * Link element with icon + * + * @access public + * @param string $icon Icon name + * @param string $label Link label + * @param string $controller Controller name + * @param string $action Action name + * @param array $params Url parameters + * @param boolean $csrf Add a CSRF token + * @param string $class CSS class attribute + * @param string $title Link title + * @param boolean $newTab Open the link in a new tab + * @param string $anchor Link Anchor + * @param bool $absolute + * @return string + */ + public function icon($icon, $label, $controller, $action, array $params = array(), $csrf = false, $class = '', $title = '', $newTab = false, $anchor = '', $absolute = false) + { + $html = '<i class="fa fa-fw fa-'.$icon.'" aria-hidden="true"></i>'.$label; + return $this->helper->url->link($html, $controller, $action, $params, $csrf, $class, $title, $newTab, $anchor, $absolute); } /** * Link element * * @access public - * @param string $label Link label - * @param string $controller Controller name - * @param string $action Action name - * @param array $params Url parameters - * @param boolean $csrf Add a CSRF token - * @param string $class CSS class attribute - * @param string $title - * @param boolean $new_tab Open the link in a new tab - * @param string $anchor Link Anchor + * @param string $label Link label + * @param string $controller Controller name + * @param string $action Action name + * @param array $params Url parameters + * @param boolean $csrf Add a CSRF token + * @param string $class CSS class attribute + * @param string $title Link title + * @param boolean $newTab Open the link in a new tab + * @param string $anchor Link Anchor + * @param bool $absolute + * @return string + */ + public function link($label, $controller, $action, array $params = array(), $csrf = false, $class = '', $title = '', $newTab = false, $anchor = '', $absolute = false) + { + return '<a href="'.$this->href($controller, $action, $params, $csrf, $anchor, $absolute).'" class="'.$class.'" title=\''.$title.'\' '.($newTab ? 'target="_blank"' : '').'>'.$label.'</a>'; + } + + /** + * Absolute link + * + * @param string $label + * @param string $controller + * @param string $action + * @param array $params * @return string */ - public function link($label, $controller, $action, array $params = array(), $csrf = false, $class = '', $title = '', $new_tab = false, $anchor = '') + public function absoluteLink($label, $controller, $action, array $params = array()) { - return '<a href="'.$this->href($controller, $action, $params, $csrf, $anchor).'" class="'.$class.'" title=\''.$title.'\' '.($new_tab ? 'target="_blank"' : '').'>'.$label.'</a>'; + return $this->link($label, $controller, $action, $params, false, '', '', true, '', true); } /** @@ -155,7 +193,7 @@ class UrlHelper extends Base /** * Build relative url * - * @access private + * @access protected * @param string $separator Querystring argument separator * @param string $controller Controller name * @param string $action Action name @@ -165,7 +203,7 @@ class UrlHelper extends Base * @param boolean $absolute Absolute or relative link * @return string */ - private function build($separator, $controller, $action, array $params = array(), $csrf = false, $anchor = '', $absolute = false) + protected function build($separator, $controller, $action, array $params = array(), $csrf = false, $anchor = '', $absolute = false) { $path = $this->route->findUrl($controller, $action, $params); $qs = array(); |