]> dev.renevier.net Git - syj.git/blob - application/views/helpers/Anchor.php
version 0.1
[syj.git] / application / views / helpers / Anchor.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_View_Helper_Anchor extends Zend_View_Helper_HtmlElement
6 {
7     public function Anchor($href, $text = null, array $attribs=array()) {
8         $lang = Zend_Controller_Front::getInstance()->getRequest()->getQuery('lang');
9         if ($lang) {
10             $translator = Zend_Registry::get('Zend_Translate');
11             $adapter = $translator->getAdapter();
12             if ($adapter->isAvailable($lang)) {
13                 $href = $this->view->addParamToUrl($href, 'lang', $lang);
14             }
15         }
16
17         $attribs = array_merge(array('href' => $href), $attribs);
18         if (!isset($text)) {
19             $text = $href;
20         }
21         $html = '<a' . $this->_htmlAttribs($attribs) . '>' . $this->view->escape($text) . '</a>';
22         return $html;
23     }
24 }
25