*/ class Mage_XmlConnect_Model_Tabs { /** * Store enabled application design tabs * * @var array */ protected $_enabledTabs = array(); /** * Store disabled application design tabs * * @var array */ protected $_disabledTabs = array(); /** * Set enabled and disabled application tabs * * @param string $data */ public function __construct($data) { $this->_enabledTabs = Mage::helper('xmlconnect')->getDefaultApplicationDesignTabs(); if (is_string($data)) { $data = json_decode($data); if (is_object($data)) { $this->_enabledTabs = $data->enabledTabs; $this->_disabledTabs = $data->disabledTabs; } } $this->_translateLabel($this->_enabledTabs); $this->_translateLabel($this->_disabledTabs); } /** * Translate Label fields * * @param array &$tabItems * @return Mage_XmlConnect_Model_Tabs */ protected function _translateLabel(&$tabItems) { if (is_array($tabItems)) { foreach ($tabItems as $id => $tab) { $tempTab = $tabItems[$id]; if (is_array($tab)) { if (isset($tab['label'])) { $tempTab['label'] = Mage::helper('xmlconnect')->getTabLabel($tab['action']); } else { $tempTab['label'] = ''; } } else { if (isset($tab->label)) { $tempTab->label = Mage::helper('xmlconnect')->getTabLabel($tab->action); } } } } return $this; } /** * Getter for enabled tabs * * @return array */ public function getEnabledTabs() { return $this->_enabledTabs; } /** * Getter for disabled tabs * * @return array */ public function getDisabledTabs() { return $this->_disabledTabs; } /** * Collect tabs with images * * @return array */ public function getRenderTabs() { $result = array(); foreach ($this->_enabledTabs as $tab) { $tab->image = Mage::getDesign()->getSkinUrl('images/xmlconnect/' . $tab->image); $result[] = $tab; } return $result; } }