Mage_Adminhtml_Block_Widget_Tabs Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Widget_Tabs:

Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Api_Editroles Mage_Adminhtml_Block_Api_Edituser Mage_Adminhtml_Block_Api_Tab_Rolesusers Mage_Adminhtml_Block_Api_Tab_Userroles Mage_Adminhtml_Block_Api_User_Edit_Tabs Mage_Adminhtml_Block_Catalog_Category_Tabs Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tabs Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tabs Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs Mage_Adminhtml_Block_Cms_Page_Edit_Tabs Mage_Adminhtml_Block_Customer_Edit_Tabs Mage_Adminhtml_Block_Dashboard_Diagrams Mage_Adminhtml_Block_Dashboard_Grids Mage_Adminhtml_Block_Extensions_Custom_Edit_Tabs Mage_Adminhtml_Block_Extensions_Local_Edit_Tabs Mage_Adminhtml_Block_Extensions_Remote_Edit_Tabs Mage_Adminhtml_Block_Permissions_Editroles Mage_Adminhtml_Block_Permissions_Edituser Mage_Adminhtml_Block_Permissions_Tab_Rolesusers Mage_Adminhtml_Block_Permissions_Tab_Userroles Mage_Adminhtml_Block_Permissions_User_Edit_Tabs Mage_Adminhtml_Block_Poll_Edit_Tabs Mage_Adminhtml_Block_Promo_Catalog_Edit_Tabs Mage_Adminhtml_Block_Promo_Quote_Edit_Tabs Mage_Adminhtml_Block_Rating_Edit_Tabs Mage_Adminhtml_Block_Sales_Order_View_Tabs Mage_Adminhtml_Block_System_Config_Dwstree Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tabs Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tabs Mage_Adminhtml_Block_System_Currency_Edit_Tabs Mage_Adminhtml_Block_System_Design_Edit_Tabs

List of all members.

Public Member Functions

 getDestElementId ()
 setDestElementId ($elementId)
 addTab ($tabId, $tab)
 getActiveTabId ()
 setActiveTab ($tabId)
 getJsObjectName ()
 getTabsIds ()
 getTabId ($tab, $withPrefix=true)
 canShowTab ($tab)
 getTabIsHidden ($tab)
 getTabUrl ($tab)
 getTabTitle ($tab)
 getTabClass ($tab)
 getTabLabel ($tab)
 getTabContent ($tab)
 bindShadowTabs ($tabOneId, $tabTwoId)
 getAllShadowTabs ($asJson=true)

Protected Member Functions

 _construct ()
 _setActiveTab ($tabId)
 _beforeToHtml ()

Protected Attributes

 $_tabs = array()
 $_activeTab = null
 $_destElementId = 'content'


Detailed Description

Definition at line 34 of file Tabs.php.


Member Function Documentation

_beforeToHtml (  )  [protected]

Before rendering html, but after trying to load cache

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Reimplemented in Mage_Adminhtml_Block_Api_Editroles, Mage_Adminhtml_Block_Api_Edituser, Mage_Adminhtml_Block_Api_User_Edit_Tabs, Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tabs, Mage_Adminhtml_Block_Cms_Page_Edit_Tabs, Mage_Adminhtml_Block_Customer_Edit_Tabs, Mage_Adminhtml_Block_Extensions_Custom_Edit_Tabs, Mage_Adminhtml_Block_Extensions_Local_Edit_Tabs, Mage_Adminhtml_Block_Extensions_Remote_Edit_Tabs, Mage_Adminhtml_Block_Permissions_Edituser, Mage_Adminhtml_Block_Permissions_User_Edit_Tabs, Mage_Adminhtml_Block_Poll_Edit_Tabs, Mage_Adminhtml_Block_Promo_Catalog_Edit_Tabs, Mage_Adminhtml_Block_Promo_Quote_Edit_Tabs, Mage_Adminhtml_Block_Rating_Edit_Tabs, Mage_Adminhtml_Block_Sales_Order_View_Tabs, Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tabs, Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tabs, and Mage_Adminhtml_Block_System_Currency_Edit_Tabs.

Definition at line 177 of file Tabs.php.

00178     {
00179         if ($activeTab = $this->getRequest()->getParam('active_tab')) {
00180             $this->setActiveTab($activeTab);
00181         } elseif ($activeTabId = Mage::getSingleton('admin/session')->getActiveTabId()) {
00182             $this->_setActiveTab($activeTabId);
00183         }
00184 
00185         $_new = array();
00186         foreach( $this->_tabs  as $key => $tab ) {
00187             foreach( $this->_tabs  as $k => $t ) {
00188                 if( $t->getAfter() == $key ) {
00189                     $_new[$key] = $tab;
00190                     $_new[$k] = $t;
00191                 } else {
00192                     if( !$tab->getAfter() || !in_array($tab->getAfter(), array_keys($this->_tabs)) ) {
00193                         $_new[$key] = $tab;
00194                     }
00195                 }
00196             }
00197         }
00198 
00199         $this->_tabs = $_new;
00200         unset($_new);
00201 
00202         $this->assign('tabs', $this->_tabs);
00203         return parent::_beforeToHtml();
00204     }

_construct (  )  [protected]

Internal constructor, that is called from real constructor

Please override this one instead of overriding real __construct constructor

Please override this one instead of overriding real __construct constructor

Reimplemented from Mage_Core_Block_Abstract.

Reimplemented in Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute_Tabs.

Definition at line 57 of file Tabs.php.

00058     {
00059         $this->setTemplate('widget/tabs.phtml');
00060     }

_setActiveTab ( tabId  )  [protected]

Set Active Tab

Parameters:
string $tabId
Returns:
Mage_Adminhtml_Block_Widget_Tabs

Definition at line 165 of file Tabs.php.

00166     {
00167         foreach ($this->_tabs as $id => $tab) {
00168             if ($this->getTabId($tab) == $tabId) {
00169                 $this->_activeTab = $id;
00170                 $tab->setActive(true);
00171                 return $this;
00172             }
00173         }
00174         return $this;
00175     }

addTab ( tabId,
tab 
)

Add new tab

Parameters:
string $tabId
array|Varien_Object $tab
Returns:
Mage_Adminhtml_Block_Widget_Tabs

Definition at line 85 of file Tabs.php.

00086     {
00087         if (is_array($tab)) {
00088             $this->_tabs[$tabId] = new Varien_Object($tab);
00089         }
00090         elseif ($tab instanceof Varien_Object) {
00091             $this->_tabs[$tabId] = $tab;
00092             if (!$this->_tabs[$tabId]->hasTabId()) {
00093                 $this->_tabs[$tabId]->setTabId($tabId);
00094             }
00095         }
00096         elseif (is_string($tab)) {
00097             if (strpos($tab, '/')) {
00098                 $this->_tabs[$tabId] = $this->getLayout()->createBlock($tab);
00099             }
00100             elseif ($this->getChild($tab)) {
00101                 $this->_tabs[$tabId] = $this->getChild($tab);
00102             }
00103             else {
00104                 $this->_tabs[$tabId] = null;
00105             }
00106 
00107             if (!($this->_tabs[$tabId] instanceof Mage_Adminhtml_Block_Widget_Tab_Interface)) {
00108                 throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration'));
00109             }
00110             $this->_tabs[$tabId]->setTabId($tabId);
00111 
00112             if (is_null($this->_activeTab)) $this->_activeTab = $tabId;
00113             return $this;
00114         }
00115         else {
00116             throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration'));
00117         }
00118 
00119         if (is_null($this->_tabs[$tabId]->getUrl())) {
00120             $this->_tabs[$tabId]->setUrl('#');
00121         }
00122 
00123         if (!$this->_tabs[$tabId]->getTitle()) {
00124             $this->_tabs[$tabId]->setTitle($this->_tabs[$tabId]->getLabel());
00125         }
00126 
00127         $this->_tabs[$tabId]->setId($tabId);
00128 
00129         if (is_null($this->_activeTab)) $this->_activeTab = $tabId;
00130         if (true === $this->_tabs[$tabId]->getActive()) $this->setActiveTab($tabId);
00131 
00132         return $this;
00133     }

bindShadowTabs ( tabOneId,
tabTwoId 
)

Mark tabs as dependant of each other Arbitrary number of tabs can be specified, but at least two

Parameters:
string $tabOneId
string $tabTwoId
string $tabNId...

Definition at line 303 of file Tabs.php.

00304     {
00305         $tabs = array();
00306         $args = func_get_args();
00307         if ((!empty($args)) && (count($args) > 1)) {
00308             foreach ($args as $tabId) {
00309                 if (isset($this->_tabs[$tabId])) {
00310                     $tabs[$tabId] = $tabId;
00311                 }
00312             }
00313             $blockId = $this->getId();
00314             foreach ($tabs as $tabId) {
00315                 foreach ($tabs as $tabToId) {
00316                     if ($tabId !== $tabToId) {
00317                         if (!$this->_tabs[$tabToId]->getData('shadow_tabs')) {
00318                             $this->_tabs[$tabToId]->setData('shadow_tabs', array());
00319                         }
00320                         $this->_tabs[$tabToId]->setData('shadow_tabs', array_merge(
00321                             $this->_tabs[$tabToId]->getData('shadow_tabs'),
00322                             array($blockId . '_' . $tabId)
00323                         ));
00324                     }
00325                 }
00326             }
00327         }
00328     }

canShowTab ( tab  ) 

Definition at line 226 of file Tabs.php.

00227     {
00228         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00229             return $tab->canShowTab();
00230         }
00231         return true;
00232     }

getActiveTabId (  ) 

Definition at line 135 of file Tabs.php.

00136     {
00137         return $this->getTabId($this->_tabs[$this->_activeTab]);
00138     }

getAllShadowTabs ( asJson = true  ) 

Obtain shadow tabs information

Parameters:
bool $asJson
Returns:
array|string

Definition at line 336 of file Tabs.php.

00337     {
00338         $result = array();
00339         if (!empty($this->_tabs)) {
00340             $blockId = $this->getId();
00341             foreach (array_keys($this->_tabs) as $tabId) {
00342                 if ($this->_tabs[$tabId]->getData('shadow_tabs')) {
00343                     $result[$blockId . '_' . $tabId] = $this->_tabs[$tabId]->getData('shadow_tabs');
00344                 }
00345             }
00346         }
00347         if ($asJson) {
00348             return Zend_Json::encode($result);
00349         }
00350         return $result;
00351     }

getDestElementId (  ) 

retrieve destination html element id

Returns:
string

Definition at line 67 of file Tabs.php.

00068     {
00069         return $this->_destElementId;
00070     }

getJsObjectName (  ) 

Definition at line 206 of file Tabs.php.

00207     {
00208         return $this->getId() . 'JsTabs';
00209     }

getTabClass ( tab  ) 

Definition at line 264 of file Tabs.php.

00265     {
00266         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00267             if (method_exists($tab, 'getTabClass')) {
00268                 return $tab->getTabClass();
00269             }
00270             return '';
00271         }
00272         return $tab->getClass();
00273     }

getTabContent ( tab  ) 

Definition at line 284 of file Tabs.php.

00285     {
00286         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00287             if ($tab->getSkipGenerateContent()) {
00288                 return '';
00289             }
00290             return $tab->toHtml();
00291         }
00292         return $tab->getContent();
00293     }

getTabId ( tab,
withPrefix = true 
)

Definition at line 218 of file Tabs.php.

00219     {
00220         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00221             return ($withPrefix ? $this->getId().'_' : '').$tab->getTabId();
00222         }
00223         return ($withPrefix ? $this->getId().'_' : '').$tab->getId();
00224     }

getTabIsHidden ( tab  ) 

Definition at line 234 of file Tabs.php.

00235     {
00236         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00237             return $tab->isHidden();
00238         }
00239         return $tab->getIsHidden();
00240     }

getTabLabel ( tab  ) 

Definition at line 276 of file Tabs.php.

00277     {
00278         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00279             return $tab->getTabLabel();
00280         }
00281         return $tab->getLabel();
00282     }

getTabsIds (  ) 

Definition at line 211 of file Tabs.php.

00212     {
00213         if (empty($this->_tabs))
00214             return array();
00215         return array_keys($this->_tabs);
00216     }

getTabTitle ( tab  ) 

Definition at line 256 of file Tabs.php.

00257     {
00258         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00259             return $tab->getTabTitle();
00260         }
00261         return $tab->getTitle();
00262     }

getTabUrl ( tab  ) 

Definition at line 242 of file Tabs.php.

00243     {
00244         if ($tab instanceof Mage_Adminhtml_Block_Widget_Tab_Interface) {
00245             if (method_exists($tab, 'getTabUrl')) {
00246                 return $tab->getTabUrl();
00247             }
00248             return '#';
00249         }
00250         if (!is_null($tab->getUrl())) {
00251             return $tab->getUrl();
00252         }
00253         return '#';
00254     }

setActiveTab ( tabId  ) 

Set Active Tab

Parameters:
string $tabId
Returns:
Mage_Adminhtml_Block_Widget_Tabs

Definition at line 146 of file Tabs.php.

00147     {
00148         if (isset($this->_tabs[$tabId])) {
00149             $this->_activeTab = $tabId;
00150             if (!(is_null($this->_activeTab)) && ($tabId !== $this->_activeTab)) {
00151                 foreach ($this->_tabs as $id => $tab) {
00152                     $tab->setActive($id === $tabId);
00153                 }
00154             }
00155         }
00156         return $this;
00157     }

setDestElementId ( elementId  ) 

Definition at line 72 of file Tabs.php.

00073     {
00074         $this->_destElementId = $elementId;
00075         return $this;
00076     }


Member Data Documentation

$_activeTab = null [protected]

Definition at line 48 of file Tabs.php.

$_destElementId = 'content' [protected]

Definition at line 55 of file Tabs.php.

$_tabs = array() [protected]

Definition at line 41 of file Tabs.php.


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

Generated on Sat Jul 4 17:23:10 2009 for Magento by  doxygen 1.5.8