00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Customer_Block_Account_Navigation extends Mage_Core_Block_Template
00036 {
00037
00038 protected $_links = array();
00039
00040 protected $_activeLink = false;
00041
00042 public function addLink($name, $path, $label, $urlParams=array())
00043 {
00044 $this->_links[$name] = new Varien_Object(array(
00045 'name' => $name,
00046 'path' => $path,
00047 'label' => $label,
00048 'url' => $this->getUrl($path, $urlParams),
00049 ));
00050 return $this;
00051 }
00052
00053 public function setActive($path)
00054 {
00055 $this->_activeLink = $this->_completePath($path);
00056 return $this;
00057 }
00058
00059 public function getLinks()
00060 {
00061 return $this->_links;
00062 }
00063
00064 public function isActive($link)
00065 {
00066 if (empty($this->_activeLink)) {
00067 $this->_activeLink = $this->getAction()->getFullActionName('/');
00068 }
00069 if ($this->_completePath($link->getPath()) == $this->_activeLink) {
00070 return true;
00071 }
00072 return false;
00073 }
00074
00075 protected function _completePath($path)
00076 {
00077 $path = rtrim($path, '/');
00078 switch (sizeof(explode('/', $path))) {
00079 case 1:
00080 $path .= '/index';
00081
00082
00083 case 2:
00084 $path .= '/index';
00085 }
00086 return $path;
00087 }
00088
00089 }