Mage_Page_Block_Template_Links Class Reference

Inheritance diagram for Mage_Page_Block_Template_Links:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getLinks ()
 addLink ($label, $url='', $title='', $prepare=false, $urlParams=array(), $position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='')
 removeLinkByUrl ($url)

Protected Member Functions

 _construct ()
 _prepareParams ($params)
 _beforeToHtml ()

Protected Attributes

 $_links = array()


Detailed Description

Definition at line 35 of file Links.php.


Member Function Documentation

_beforeToHtml (  )  [protected]

Set first/last

Returns:
Mage_Page_Block_Template_Links

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 154 of file Links.php.

00155     {
00156         if (!empty($this->_links)) {
00157             reset($this->_links);
00158             $this->_links[key($this->_links)]->setIsFirst(true);
00159             end($this->_links);
00160             $this->_links[key($this->_links)]->setIsLast(true);
00161         }
00162         return parent::_beforeToHtml();
00163     }

_construct (  )  [protected]

Set default template

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 49 of file Links.php.

00050     {
00051         $this->setTemplate('page/template/links.phtml');
00052     }

_prepareParams ( params  )  [protected]

Prepare tag attributes

Parameters:
string|array $params
Returns:
string

Definition at line 135 of file Links.php.

00136     {
00137         if (is_string($params)) {
00138             return $params;
00139         } elseif (is_array($params)) {
00140             $result = '';
00141             foreach ($params as $key=>$value) {
00142                 $result .= ' ' . $key . '="' . addslashes($value) . '"';
00143             }
00144             return $result;
00145         }
00146         return '';
00147     }

addLink ( label,
url = '',
title = '',
prepare = false,
urlParams = array(),
position = null,
liParams = null,
aParams = null,
beforeText = '',
afterText = '' 
)

Add link to the list

Parameters:
string $label
string $url
string $title
boolean $prepare
array $urlParams
int $position
string|array $liParams
string|array $aParams
string $beforeText
string $afterText
Returns:
Mage_Page_Block_Template_Links

Definition at line 79 of file Links.php.

00081     {
00082         if (is_null($label) || false===$label) {
00083             return $this;
00084         }
00085         $link = new Varien_Object(array(
00086             'label'         => $label,
00087             'url'           => ($prepare ? $this->getUrl($url, (is_array($urlParams) ? $urlParams : array())) : $url),
00088             'title'         => $title,
00089             'li_params'     => $this->_prepareParams($liParams),
00090             'a_params'      => $this->_prepareParams($aParams),
00091             'before_text'   => $beforeText,
00092             'after_text'    => $afterText,
00093         ));
00094 
00095         if (intval($position) > 0) {
00096             while (isset($this->_links[$position])) {
00097                 $position++;
00098             }
00099             $this->_links[$position] = $link;
00100             ksort($this->_links);
00101         } else {
00102             $position = 0;
00103             foreach ($this->_links as $k=>$v) {
00104                 $position = $k;
00105             }
00106             $this->_links[$position+10] = $link;
00107         }
00108 
00109         return $this;
00110     }

getLinks (  ) 

Get all links

Returns:
array

Definition at line 59 of file Links.php.

00060     {
00061         return $this->_links;
00062     }

removeLinkByUrl ( url  ) 

Removes link by url

Parameters:
string $url
Returns:
Mage_Page_Block_Template_Links

Definition at line 118 of file Links.php.

00119     {
00120         foreach ($this->_links as $k => $v) {
00121             if ($v->getUrl() == $url) {
00122                 unset($this->_links[$k]);
00123             }
00124         }
00125 
00126         return $this;
00127     }


Member Data Documentation

$_links = array() [protected]

Definition at line 43 of file Links.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:30 2009 for Magento by  doxygen 1.5.8