]> dev.renevier.net Git - syj.git/blob - application/views/helpers/Anchor.php
redirection after path creation is decided by server (php), not guessed by client...
[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(), $escape = true) {
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         $content = $escape ? $this->view->escape($text) : $text;
22         $html = '<a' . $this->_htmlAttribs($attribs) . '>' . $content . '</a>';
23         return $html;
24     }
25 }
26