ND_EasyConfig - Version 0.1.0

Version Notes

Easiest way to access System -> Configuration menu

Download this release

Release Info

Developer Nikul Doshi
Extension ND_EasyConfig
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/ND/EasyConfig/Block/Adminhtml/Page/Menu.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ND_EasyConfig_Block_Adminhtml_Page_Menu extends Mage_Adminhtml_Block_Page_Menu
3
+ {
4
+ protected $_tabs = null;
5
+ protected $_configMenu = null;
6
+
7
+ protected function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->prepareConfigMenu();
11
+ }
12
+
13
+ public function addTab($code, $config)
14
+ {
15
+ $tab = new Varien_Object($config);
16
+ $tab->setId($code);
17
+ $this->_tabs[$code] = $tab;
18
+ return $this;
19
+ }
20
+
21
+ public function getTab($code)
22
+ {
23
+ if(isset($this->_tabs[$code])) {
24
+ return $this->_tabs[$code];
25
+ }
26
+
27
+ return null;
28
+ }
29
+
30
+ public function addSection($code, $tabCode, $config)
31
+ {
32
+ if($tab = $this->getTab($tabCode)) {
33
+ if(!$tab->getSections()) {
34
+ $tab->setSections(new Varien_Data_Collection());
35
+ }
36
+ $section = new Varien_Object($config);
37
+ $section->setId($code);
38
+ $tab->getSections()->addItem($section);
39
+ }
40
+ return $this;
41
+ }
42
+
43
+ protected function _sort($a, $b)
44
+ {
45
+ return (int)$a->sort_order < (int)$b->sort_order ? -1 : ((int)$a->sort_order > (int)$b->sort_order ? 1 : 0);
46
+ }
47
+
48
+ public function prepareConfigMenu()
49
+ {
50
+ $websiteCode = $this->getRequest()->getParam('website');
51
+ $storeCode = $this->getRequest()->getParam('store');
52
+ $configFields = Mage::getSingleton('adminhtml/config');
53
+ $sections = $configFields->getSections();
54
+ $tabs = (array)$configFields->getTabs()->children();
55
+ $url = Mage::getModel('adminhtml/url');
56
+ $tabMenu = $sectionMenu = array();
57
+ $sections = (array)$sections;
58
+
59
+ usort($sections, array($this, '_sort'));
60
+ usort($tabs, array($this, '_sort'));
61
+
62
+ foreach ($tabs as $tab) {
63
+ $helperName = $configFields->getAttributeModule($tab);
64
+ $label = Mage::helper($helperName)->__((string)$tab->label);
65
+
66
+ $this->addTab($tab->getName(), array(
67
+ 'label' => $label,
68
+ 'class' => (string) $tab->class
69
+ ));
70
+
71
+ $tabMenu['name'][] = $tab->getName();
72
+ $tabMenu['label'][] = $label;
73
+ }
74
+
75
+ $s=0;foreach ($sections as $section) {
76
+ Mage::dispatchEvent('adminhtml_block_system_config_init_tab_sections_before', array('section' => $section));
77
+ $hasChildren = $configFields->hasChildren($section, $websiteCode, $storeCode);
78
+
79
+ $code = $section->getName();
80
+ //$sectionAllowed = $this->checkSectionPermissions($code);
81
+
82
+ $helperName = $configFields->getAttributeModule($section);
83
+ $label = Mage::helper($helperName)->__((string)$section->label);
84
+ if ($hasChildren) {
85
+ $this->addSection($code, (string)$section->tab, array(
86
+ 'class' => (string)$section->class,
87
+ 'label' => $label,
88
+ 'url' => $url->getUrl('adminhtml/system_config', array('_current'=>true, 'section'=>$code)),
89
+ ));
90
+ }
91
+ /* For single menu without submenu sections */
92
+ //$sectionMenu[$s]['name'] = $code;
93
+ //$sectionMenu[$s]['label'] = $label;
94
+ //$sectionMenu[$s]['url'] = $url->getUrl('*/*/*', array('_current'=>true, 'section'=>$code));
95
+ $s++;
96
+ }
97
+
98
+ $n=0; foreach($this->_tabs as $tab){
99
+ $this->_configMenu[$n] = $tab->getData();
100
+ if($tab->getSections()) {
101
+ $this->_configMenu[$n]['url'] = '#';
102
+ $this->_configMenu[$n]['click'] = 'return false';
103
+ foreach($tab->getSections() as $section) {
104
+ $this->_configMenu[$n]['children'][] = $section->getData();
105
+ }
106
+ unset($this->_configMenu[$n]['sections']);
107
+ }
108
+ $n++;
109
+ }
110
+ }
111
+
112
+ public function getMenuLevel($menu, $level = 0)
113
+ {
114
+ $html = '<ul ' . (!$level ? 'id="nav"' : '') . '>' . PHP_EOL;
115
+ foreach ($menu as $item) {
116
+ $isConfig = ($item['label']=='Configuration') ? true : false;
117
+ if($isConfig) {
118
+ $item['children'] = $this->_configMenu;
119
+ }
120
+ $html .= '<li ' . ((!empty($item['children']) || $isConfig) ? 'onmouseover="Element.addClassName(this,\'over\')" '
121
+ . 'onmouseout="Element.removeClassName(this,\'over\')"' : '') . ' class="'
122
+ . (!$level && !empty($item['active']) ? ' active' : '') . ' '
123
+ . (!empty($item['children']) ? ' parent' : '')
124
+ . (!empty($level) && !empty($item['last']) ? ' last' : '')
125
+ . ' level' . $level . '"> <a href="' . $item['url'] . '" '
126
+ . (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
127
+ . (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'
128
+ . ($level === 0 && !empty($item['active']) ? 'active' : '') . '"><span>'
129
+ . $item['label'] . '</span></a>' . PHP_EOL;
130
+
131
+ if (!empty($item['children'])) {
132
+ $html .= $this->getMenuLevel($item['children'], $level + 1);
133
+ }
134
+ $html .= '</li>' . PHP_EOL;
135
+ }
136
+ $html .= '</ul>' . PHP_EOL;
137
+
138
+ return $html;
139
+ }
140
+ }
app/code/local/ND/EasyConfig/etc/config.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ND_EasyConfig>
5
+ <version>0.1.0</version>
6
+ </ND_EasyConfig>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <easyconfig>
11
+ <class>ND_EasyConfig_Block</class>
12
+ </easyconfig>
13
+ <adminhtml>
14
+ <rewrite>
15
+ <page_menu>ND_EasyConfig_Block_Adminhtml_Page_Menu</page_menu>
16
+ </rewrite>
17
+ </adminhtml>
18
+ </blocks>
19
+ </global>
20
+ </config>
app/etc/modules/ND_EasyConfig.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ND_EasyConfig>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </ND_EasyConfig>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ND_EasyConfig</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easiest way to access System -&gt; Configuration menu</summary>
10
+ <description>Easiest way to access System -&gt; Configuration menu</description>
11
+ <notes>Easiest way to access System -&gt; Configuration menu</notes>
12
+ <authors><author><name>Nikul Doshi</name><user>nikulonline</user><email>nikulonline@gmail.com</email></author></authors>
13
+ <date>2016-01-30</date>
14
+ <time>11:05:40</time>
15
+ <contents><target name="magelocal"><dir name="ND"><dir name="EasyConfig"><dir name="Block"><dir name="Adminhtml"><dir name="Page"><file name="Menu.php" hash="c06db2a55d1ffc156819786e663654d1"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="f853f51de8a9ad5242f446c0a9272f19"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ND_EasyConfig.xml" hash="5b8d7a1f322e7240d15b9b559631defc"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>