Anchor.php

Go to the documentation of this file.
00001 <?php
00002 
00031 class Robo47_View_Helper_Anchor extends Zend_View_Helper_HtmlElement
00032 {
00033 
00037     protected $_router = null;
00038 
00043     public function __construct(Zend_Controller_Router_Interface $router = null)
00044     {
00045         $this->setRouter($router);
00046     }
00047 
00054     public function setRouter(Zend_Controller_Router_Interface $router = null)
00055     {
00056         if (null === $router) {
00057             $this->_router = Zend_Controller_Front::getInstance()->getRouter();
00058         } else {
00059             $this->_router = $router;
00060         }
00061         return $this;
00062     }
00063 
00069     public function getRouter()
00070     {
00071         return $this->_router;
00072     }
00073 
00087     public function anchor(array $urlOptions, $name, $linkname,
00088         $params = array(), $reset = false, $encode = true)
00089     {
00090         $router = $this->_router;
00091         $href = $router->assemble($urlOptions, $name, $reset, $encode);
00092         $link = '<a href="' . $href . '"';
00093         $link .= $this->_htmlAttribs($params);
00094         $link .= '>' . $linkname . '</a>';
00095         return $link;
00096     }
00097 }