1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_XmlConnect
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * XmlConnect Tabs model
29: *
30: * @category Mage
31: * @package Mage_Xmlconnect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_XmlConnect_Model_Tabs
35: {
36: /**
37: * Store enabled application design tabs
38: *
39: * @var array
40: */
41: protected $_enabledTabs = array();
42:
43: /**
44: * Store disabled application design tabs
45: *
46: * @var array
47: */
48: protected $_disabledTabs = array();
49:
50: /**
51: * Set enabled and disabled application tabs
52: *
53: * @param string $data
54: */
55: public function __construct($data)
56: {
57: $this->_enabledTabs = Mage::helper('xmlconnect')->getDefaultApplicationDesignTabs();
58: if (is_string($data)) {
59: $data = json_decode($data);
60: if (is_object($data)) {
61: $this->_enabledTabs = $data->enabledTabs;
62: $this->_disabledTabs = $data->disabledTabs;
63: }
64: }
65: $this->_translateLabel($this->_enabledTabs);
66: $this->_translateLabel($this->_disabledTabs);
67: }
68:
69: /**
70: * Translate Label fields
71: *
72: * @param array &$tabItems
73: * @return Mage_XmlConnect_Model_Tabs
74: */
75: protected function _translateLabel(&$tabItems)
76: {
77: if (is_array($tabItems)) {
78: foreach ($tabItems as $id => $tab) {
79: $tempTab = $tabItems[$id];
80:
81: if (is_array($tab)) {
82: if (isset($tab['label'])) {
83: $tempTab['label'] = Mage::helper('xmlconnect')->getTabLabel($tab['action']);
84: } else {
85: $tempTab['label'] = '';
86: }
87: } else {
88: if (isset($tab->label)) {
89: $tempTab->label = Mage::helper('xmlconnect')->getTabLabel($tab->action);
90: }
91: }
92: }
93: }
94: return $this;
95: }
96:
97: /**
98: * Getter for enabled tabs
99: *
100: * @return array
101: */
102: public function getEnabledTabs()
103: {
104: return $this->_enabledTabs;
105: }
106:
107: /**
108: * Getter for disabled tabs
109: *
110: * @return array
111: */
112: public function getDisabledTabs()
113: {
114: return $this->_disabledTabs;
115: }
116:
117: /**
118: * Collect tabs with images
119: *
120: * @return array
121: */
122: public function getRenderTabs()
123: {
124: $result = array();
125: foreach ($this->_enabledTabs as $tab) {
126: $tab->image = Mage::getDesign()->getSkinUrl('images/xmlconnect/' . $tab->image);
127: $result[] = $tab;
128: }
129:
130: return $result;
131: }
132: }
133: