JScriptz_MegaMenu2 - Version 1.8.1.0

Version Notes

This is a mega nav extension that allows you to control your top menu links and the content below them through the admin interface. It supports HTML, Video, Tabbed Jquery, and even has a nifty contact us form.

Download this release

Release Info

Developer Jason Lotzer
Extension JScriptz_MegaMenu2
Version 1.8.1.0
Comparing to
See all releases


Code changes from version 1.8.0.0 to 1.8.1.0

Files changed (88) hide show
  1. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Helper/Wysiwyg.php +40 -40
  2. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem.php +33 -33
  3. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Abstract.php +180 -180
  4. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit.php +36 -36
  5. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Form.php +197 -197
  6. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Form.php +110 -110
  7. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Stores.php +44 -44
  8. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tabs.php +63 -63
  9. app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Tree.php +299 -299
  10. app/code/community/JScriptz/MegaMenu2/Controller/Adminhtml/MegaMenu2.php +56 -56
  11. app/code/community/JScriptz/MegaMenu2/Helper/Data.php +21 -21
  12. app/code/community/JScriptz/MegaMenu2/Helper/Menuitem.php +37 -37
  13. app/code/community/JScriptz/MegaMenu2/Model/Menuitem.php +301 -301
  14. app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem.php +549 -549
  15. app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Collection.php +203 -203
  16. app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Tree.php +386 -386
  17. app/code/community/JScriptz/MegaMenu2/Model/Resource/Setup.php +22 -22
  18. app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/MenuitemController.php +307 -307
  19. app/code/community/JScriptz/MegaMenu2/data/jscriptz_megamenu2_setup/data-install-0.0.1.php +233 -233
  20. app/code/community/JScriptz/MegaMenu2/etc/adminhtml.xml +58 -58
  21. app/code/community/JScriptz/MegaMenu2/etc/config.xml +105 -105
  22. app/code/community/JScriptz/MegaMenu2/sql/jscriptz_megamenu2_setup/install-0.0.1.php +52 -52
  23. app/design/adminhtml/default/default/layout/jscriptz_megamenu2.xml +27 -27
  24. app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/edit.phtml +148 -148
  25. app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/edit/form.phtml +157 -157
  26. app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/tree.phtml +374 -374
  27. app/design/frontend/base/default/layout/jscriptz_megamenu2.xml +27 -27
  28. app/design/frontend/base/default/template/jscriptz/html/topmenu.phtml +1 -1
  29. app/etc/modules/JScriptz_MegaMenu2.xml +25 -25
  30. package.xml +5 -5
  31. skin/frontend/base/default/images/jscriptz_megamenu2/Thumbs.db +0 -0
  32. skin/frontend/base/default/images/jscriptz_megamenu2/add-cart-mini.png +0 -0
  33. skin/frontend/base/default/images/jscriptz_megamenu2/bg-checkout.png +0 -0
  34. skin/frontend/base/default/images/jscriptz_megamenu2/bg-product-tab.png +0 -0
  35. skin/frontend/base/default/images/jscriptz_megamenu2/bg-search.png +0 -0
  36. skin/frontend/base/default/images/jscriptz_megamenu2/bg-select.png +0 -0
  37. skin/frontend/base/default/images/jscriptz_megamenu2/bg-slider.png +0 -0
  38. skin/frontend/base/default/images/jscriptz_megamenu2/cart.png +0 -0
  39. skin/frontend/base/default/images/jscriptz_megamenu2/checkbox.png +0 -0
  40. skin/frontend/base/default/images/jscriptz_megamenu2/collapsed.gif +0 -0
  41. skin/frontend/base/default/images/jscriptz_megamenu2/collapsed.png +0 -0
  42. skin/frontend/base/default/images/jscriptz_megamenu2/comments-link.png +0 -0
  43. skin/frontend/base/default/images/jscriptz_megamenu2/dotted.png +0 -0
  44. skin/frontend/base/default/images/jscriptz_megamenu2/expanded.gif +0 -0
  45. skin/frontend/base/default/images/jscriptz_megamenu2/expanded.png +0 -0
  46. skin/frontend/base/default/images/jscriptz_megamenu2/glyphicons-halflings-white.png +0 -0
  47. skin/frontend/base/default/images/jscriptz_megamenu2/glyphicons-halflings.png +0 -0
  48. skin/frontend/base/default/images/jscriptz_megamenu2/home-icon.png +0 -0
  49. skin/frontend/base/default/images/jscriptz_megamenu2/icons/Thumbs.db +0 -0
  50. skin/frontend/base/default/images/jscriptz_megamenu2/icons/mini-icons-white.png +0 -0
  51. skin/frontend/base/default/images/jscriptz_megamenu2/leftArrow.png +0 -0
  52. skin/frontend/base/default/images/jscriptz_megamenu2/line1.gif +0 -0
  53. skin/frontend/base/default/images/jscriptz_megamenu2/line1.png +0 -0
  54. skin/frontend/base/default/images/jscriptz_megamenu2/line2.gif +0 -0
  55. skin/frontend/base/default/images/jscriptz_megamenu2/line2.png +0 -0
  56. skin/frontend/base/default/images/jscriptz_megamenu2/loading.gif +0 -0
  57. skin/frontend/base/default/images/jscriptz_megamenu2/menu-sidebar-active.png +0 -0
  58. skin/frontend/base/default/images/jscriptz_megamenu2/menu-sidebar.png +0 -0
  59. skin/frontend/base/default/images/jscriptz_megamenu2/mini-icons-white.png +0 -0
  60. skin/frontend/base/default/images/jscriptz_megamenu2/moogaloop.swf +0 -0
  61. skin/frontend/base/default/images/jscriptz_megamenu2/page_bg.png +0 -0
  62. skin/frontend/base/default/images/jscriptz_megamenu2/product01@2x.jpg +0 -0
  63. skin/frontend/base/default/images/jscriptz_megamenu2/product02@2x.jpg +0 -0
  64. skin/frontend/base/default/images/jscriptz_megamenu2/product03@2x.jpg +0 -0
  65. skin/frontend/base/default/images/jscriptz_megamenu2/product04@2x.jpg +0 -0
  66. skin/frontend/base/default/images/jscriptz_megamenu2/product05@2x.jpg +0 -0
  67. skin/frontend/base/default/images/jscriptz_megamenu2/product06@2x.jpg +0 -0
  68. skin/frontend/base/default/images/jscriptz_megamenu2/product07@2x.jpg +0 -0
  69. skin/frontend/base/default/images/jscriptz_megamenu2/product08@2x.jpg +0 -0
  70. skin/frontend/base/default/images/jscriptz_megamenu2/product09@2x.jpg +0 -0
  71. skin/frontend/base/default/images/jscriptz_megamenu2/product10@2x.jpg +0 -0
  72. skin/frontend/base/default/images/jscriptz_megamenu2/product11@2x.jpg +0 -0
  73. skin/frontend/base/default/images/jscriptz_megamenu2/radio.png +0 -0
  74. skin/frontend/base/default/images/jscriptz_megamenu2/rating-box.png +0 -0
  75. skin/frontend/base/default/images/jscriptz_megamenu2/rating.png +0 -0
  76. skin/frontend/base/default/images/jscriptz_megamenu2/rightArrow.png +0 -0
  77. skin/frontend/base/default/images/jscriptz_megamenu2/select.png +0 -0
  78. skin/frontend/base/default/images/jscriptz_megamenu2/separator.png +0 -0
  79. skin/frontend/base/default/images/jscriptz_megamenu2/shadow.png +0 -0
  80. skin/frontend/base/default/images/jscriptz_megamenu2/slider-sep.png +0 -0
  81. skin/frontend/base/default/images/jscriptz_megamenu2/sort-down.png +0 -0
  82. skin/frontend/base/default/images/jscriptz_megamenu2/sort-up.png +0 -0
  83. skin/frontend/base/default/images/jscriptz_megamenu2/tab.jpg +0 -0
  84. skin/frontend/base/default/images/jscriptz_megamenu2/tab.png +0 -0
  85. skin/frontend/base/default/images/jscriptz_megamenu2/tab_key.jpg +0 -0
  86. skin/frontend/base/default/images/jscriptz_megamenu2/tick.png +0 -0
  87. skin/frontend/base/default/images/jscriptz_megamenu2/toggle.png +0 -0
  88. skin/frontend/base/default/images/jscriptz_megamenu2/up.png +0 -0
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Helper/Wysiwyg.php CHANGED
@@ -1,43 +1,43 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * MegaMenu2 textarea attribute WYSIWYG button
19
- * @category JScriptz
20
- * @package JScriptz_MegaMenu2
21
-
22
- */
23
- class JScriptz_MegaMenu2_Block_Adminhtml_Helper_Wysiwyg extends Varien_Data_Form_Element_Textarea
24
- {
25
- /**
26
- * Retrieve additional html and put it at the end of element html
27
- * @access public
28
- * @return string
29
- */
30
- public function getAfterElementHtml(){
31
- $html = parent::getAfterElementHtml();
32
- $disabled = ($this->getDisabled() || $this->getReadonly());
33
- $html .= Mage::getSingleton('core/layout')
34
- ->createBlock('adminhtml/widget_button', '', array(
35
- 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'),
36
- 'type'=> 'button',
37
- 'disabled' => $disabled,
38
- 'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg',
39
- 'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')'
40
- ))->toHtml();
41
- return $html;
42
- }
43
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MegaMenu2 textarea attribute WYSIWYG button
19
+ * @category JScriptz
20
+ * @package JScriptz_MegaMenu2
21
+
22
+ */
23
+ class JScriptz_MegaMenu2_Block_Adminhtml_Helper_Wysiwyg extends Varien_Data_Form_Element_Textarea
24
+ {
25
+ /**
26
+ * Retrieve additional html and put it at the end of element html
27
+ * @access public
28
+ * @return string
29
+ */
30
+ public function getAfterElementHtml(){
31
+ $html = parent::getAfterElementHtml();
32
+ $disabled = ($this->getDisabled() || $this->getReadonly());
33
+ $html .= Mage::getSingleton('core/layout')
34
+ ->createBlock('adminhtml/widget_button', '', array(
35
+ 'label' => Mage::helper('catalog')->__('WYSIWYG Editor'),
36
+ 'type'=> 'button',
37
+ 'disabled' => $disabled,
38
+ 'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg',
39
+ 'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')'
40
+ ))->toHtml();
41
+ return $html;
42
+ }
43
  }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item admin block
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem extends Mage_Adminhtml_Block_Widget_Grid_Container{
24
- /**
25
- * constructor
26
- * @access public
27
- * @return void
28
- */
29
- public function __construct(){
30
- $this->_controller = 'adminhtml_menuitem';
31
- $this->_blockGroup = 'megamenu2';
32
- $this->_headerText = Mage::helper('megamenu2')->__('Menu Item');
33
- $this->_addButtonLabel = Mage::helper('megamenu2')->__('Add Menu Item');
34
- parent::__construct();
35
- }
36
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item admin block
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem extends Mage_Adminhtml_Block_Widget_Grid_Container{
24
+ /**
25
+ * constructor
26
+ * @access public
27
+ * @return void
28
+ */
29
+ public function __construct(){
30
+ $this->_controller = 'adminhtml_menuitem';
31
+ $this->_blockGroup = 'megamenu2';
32
+ $this->_headerText = Mage::helper('megamenu2')->__('Menu Item');
33
+ $this->_addButtonLabel = Mage::helper('megamenu2')->__('Add Menu Item');
34
+ parent::__construct();
35
+ }
36
  }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Abstract.php CHANGED
@@ -1,182 +1,182 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item admin block abstract
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract extends Mage_Adminhtml_Block_Template{
25
- /**
26
- * get current menu item
27
- * @access public
28
- * @return JScriptz_MegaMenu2_Model_Entity
29
- */
30
- public function getMenuitem(){
31
- return Mage::registry('menuitem');
32
- }
33
- /**
34
- * get current menu item id
35
- * @access public
36
- * @return int
37
- */
38
- public function getMenuitemId(){
39
- if ($this->getMenuitem()) {
40
- return $this->getMenuitem()->getId();
41
- }
42
- return null;
43
- }
44
- /**
45
- * get current menu item Link Title
46
- * @access public
47
- * @return string
48
- */
49
- public function getMenuitemLinktitle(){
50
- return $this->getMenuitem()->getLinktitle();
51
- }
52
- /**
53
- * get current menu item path
54
- * @access public
55
- * @return string
56
- */
57
- public function getMenuitemPath(){
58
- if ($this->getMenuitem()) {
59
- return $this->getMenuitem()->getPath();
60
- }
61
- return Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
62
- }
63
- /**
64
- * check if there is a root menu item
65
- * @access public
66
- * @return bool
67
- */
68
- public function hasRootMenuitem(){
69
- $root = $this->getRoot();
70
- if ($root && $root->getId()) {
71
- return true;
72
- }
73
- return false;
74
- }
75
- /**
76
- * get the root
77
- * @access publoc
78
- * @param JScriptz_MegaMenu2_Model_Menuitem|null $parentNodeMenuitem
79
- * @param int $recursionLevel
80
- * @return Varien_Data_Tree_Node
81
- */
82
- public function getRoot($parentNodeMenuitem = null, $recursionLevel = 3){
83
- if (!is_null($parentNodeMenuitem) && $parentNodeMenuitem->getId()) {
84
- return $this->getNode($parentNodeMenuitem, $recursionLevel);
85
- }
86
- $root = Mage::registry('root');
87
- if (is_null($root)) {
88
- $rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
89
- $tree = Mage::getResourceSingleton('megamenu2/menuitem_tree')
90
- ->load(null, $recursionLevel);
91
- if ($this->getMenuitem()) {
92
- $tree->loadEnsuredNodes($this->getMenuitem(), $tree->getNodeById($rootId));
93
- }
94
- $tree->addCollectionData($this->getMenuitemCollection());
95
- $root = $tree->getNodeById($rootId);
96
- if ($root && $rootId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
97
- $root->setIsVisible(true);
98
- }
99
- elseif($root && $root->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
100
- $root->setLinktitle(Mage::helper('megamenu2')->__('Root'));
101
- }
102
- Mage::register('root', $root);
103
- }
104
- return $root;
105
- }
106
-
107
- /**
108
- * Get and register menu items root by specified menu items IDs
109
- * @accsess public
110
- * @param array $ids
111
- * @return Varien_Data_Tree_Node
112
- */
113
- public function getRootByIds($ids){
114
- $root = Mage::registry('root');
115
- if (null === $root) {
116
- $menuitemTreeResource = Mage::getResourceSingleton('megamenu2/menuitem_tree');
117
- $ids = $menuitemTreeResource->getExistingMenuitemIdsBySpecifiedIds($ids);
118
- $tree = $menuitemTreeResource->loadByIds($ids);
119
- $rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
120
- $root = $tree->getNodeById($rootId);
121
- if ($root && $rootId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
122
- $root->setIsVisible(true);
123
- }
124
- else if($root && $root->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
125
- $root->setName(Mage::helper('megamenu2')->__('Root'));
126
- }
127
- $tree->addCollectionData($this->getMenuitemCollection());
128
- Mage::register('root', $root);
129
- }
130
- return $root;
131
- }
132
- /**
133
- * get specific node
134
- * @access public
135
- * @param JScriptz_MegaMenu2_Model_Menuitem $parentNodeMenuitem
136
- * @param $int $recursionLevel
137
- * @return Varien_Data_Tree_Node
138
- */
139
- public function getNode($parentNodeMenuitem, $recursionLevel = 2){
140
- $tree = Mage::getResourceModel('megamenu2/menuitem_tree');
141
- $nodeId = $parentNodeMenuitem->getId();
142
- $parentId = $parentNodeMenuitem->getParentId();
143
- $node = $tree->loadNode($nodeId);
144
- $node->loadChildren($recursionLevel);
145
- if ($node && $nodeId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
146
- $node->setIsVisible(true);
147
- }
148
- elseif($node && $node->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
149
- $node->setLinktitle(Mage::helper('megamenu2')->__('Root'));
150
- }
151
- $tree->addCollectionData($this->getMenuitemCollection());
152
- return $node;
153
- }
154
- /**
155
- * get url for saving data
156
- * @access public
157
- * @param array $args
158
- * @return string
159
- */
160
- public function getSaveUrl(array $args = array()){
161
- $params = array('_current'=>true);
162
- $params = array_merge($params, $args);
163
- return $this->getUrl('*/*/save', $params);
164
- }
165
- /**
166
- * get url for edit
167
- * @access public
168
- * @param array $args
169
- * @return string
170
- */
171
- public function getEditUrl(){
172
- return $this->getUrl("*/MegaMenu2_menuitem/edit", array('_current'=>true, '_query'=>false, 'id'=>null, 'parent'=>null));
173
- }
174
- /**
175
- * Return root ids
176
- * @access public
177
- * @return array
178
- */
179
- public function getRootIds(){
180
- return array(Mage::helper('megamenu2/menuitem')->getRootMenuitemId());
181
- }
182
- }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item admin block abstract
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract extends Mage_Adminhtml_Block_Template{
25
+ /**
26
+ * get current menu item
27
+ * @access public
28
+ * @return JScriptz_MegaMenu2_Model_Entity
29
+ */
30
+ public function getMenuitem(){
31
+ return Mage::registry('menuitem');
32
+ }
33
+ /**
34
+ * get current menu item id
35
+ * @access public
36
+ * @return int
37
+ */
38
+ public function getMenuitemId(){
39
+ if ($this->getMenuitem()) {
40
+ return $this->getMenuitem()->getId();
41
+ }
42
+ return null;
43
+ }
44
+ /**
45
+ * get current menu item Link Title
46
+ * @access public
47
+ * @return string
48
+ */
49
+ public function getMenuitemLinktitle(){
50
+ return $this->getMenuitem()->getLinktitle();
51
+ }
52
+ /**
53
+ * get current menu item path
54
+ * @access public
55
+ * @return string
56
+ */
57
+ public function getMenuitemPath(){
58
+ if ($this->getMenuitem()) {
59
+ return $this->getMenuitem()->getPath();
60
+ }
61
+ return Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
62
+ }
63
+ /**
64
+ * check if there is a root menu item
65
+ * @access public
66
+ * @return bool
67
+ */
68
+ public function hasRootMenuitem(){
69
+ $root = $this->getRoot();
70
+ if ($root && $root->getId()) {
71
+ return true;
72
+ }
73
+ return false;
74
+ }
75
+ /**
76
+ * get the root
77
+ * @access publoc
78
+ * @param JScriptz_MegaMenu2_Model_Menuitem|null $parentNodeMenuitem
79
+ * @param int $recursionLevel
80
+ * @return Varien_Data_Tree_Node
81
+ */
82
+ public function getRoot($parentNodeMenuitem = null, $recursionLevel = 3){
83
+ if (!is_null($parentNodeMenuitem) && $parentNodeMenuitem->getId()) {
84
+ return $this->getNode($parentNodeMenuitem, $recursionLevel);
85
+ }
86
+ $root = Mage::registry('root');
87
+ if (is_null($root)) {
88
+ $rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
89
+ $tree = Mage::getResourceSingleton('megamenu2/menuitem_tree')
90
+ ->load(null, $recursionLevel);
91
+ if ($this->getMenuitem()) {
92
+ $tree->loadEnsuredNodes($this->getMenuitem(), $tree->getNodeById($rootId));
93
+ }
94
+ $tree->addCollectionData($this->getMenuitemCollection());
95
+ $root = $tree->getNodeById($rootId);
96
+ if ($root && $rootId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
97
+ $root->setIsVisible(true);
98
+ }
99
+ elseif($root && $root->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
100
+ $root->setLinktitle(Mage::helper('megamenu2')->__('Root'));
101
+ }
102
+ Mage::register('root', $root);
103
+ }
104
+ return $root;
105
+ }
106
+
107
+ /**
108
+ * Get and register menu items root by specified menu items IDs
109
+ * @accsess public
110
+ * @param array $ids
111
+ * @return Varien_Data_Tree_Node
112
+ */
113
+ public function getRootByIds($ids){
114
+ $root = Mage::registry('root');
115
+ if (null === $root) {
116
+ $menuitemTreeResource = Mage::getResourceSingleton('megamenu2/menuitem_tree');
117
+ $ids = $menuitemTreeResource->getExistingMenuitemIdsBySpecifiedIds($ids);
118
+ $tree = $menuitemTreeResource->loadByIds($ids);
119
+ $rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
120
+ $root = $tree->getNodeById($rootId);
121
+ if ($root && $rootId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
122
+ $root->setIsVisible(true);
123
+ }
124
+ else if($root && $root->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
125
+ $root->setName(Mage::helper('megamenu2')->__('Root'));
126
+ }
127
+ $tree->addCollectionData($this->getMenuitemCollection());
128
+ Mage::register('root', $root);
129
+ }
130
+ return $root;
131
+ }
132
+ /**
133
+ * get specific node
134
+ * @access public
135
+ * @param JScriptz_MegaMenu2_Model_Menuitem $parentNodeMenuitem
136
+ * @param $int $recursionLevel
137
+ * @return Varien_Data_Tree_Node
138
+ */
139
+ public function getNode($parentNodeMenuitem, $recursionLevel = 2){
140
+ $tree = Mage::getResourceModel('megamenu2/menuitem_tree');
141
+ $nodeId = $parentNodeMenuitem->getId();
142
+ $parentId = $parentNodeMenuitem->getParentId();
143
+ $node = $tree->loadNode($nodeId);
144
+ $node->loadChildren($recursionLevel);
145
+ if ($node && $nodeId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
146
+ $node->setIsVisible(true);
147
+ }
148
+ elseif($node && $node->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
149
+ $node->setLinktitle(Mage::helper('megamenu2')->__('Root'));
150
+ }
151
+ $tree->addCollectionData($this->getMenuitemCollection());
152
+ return $node;
153
+ }
154
+ /**
155
+ * get url for saving data
156
+ * @access public
157
+ * @param array $args
158
+ * @return string
159
+ */
160
+ public function getSaveUrl(array $args = array()){
161
+ $params = array('_current'=>true);
162
+ $params = array_merge($params, $args);
163
+ return $this->getUrl('*/*/save', $params);
164
+ }
165
+ /**
166
+ * get url for edit
167
+ * @access public
168
+ * @param array $args
169
+ * @return string
170
+ */
171
+ public function getEditUrl(){
172
+ return $this->getUrl("*/MegaMenu2_menuitem/edit", array('_current'=>true, '_query'=>false, 'id'=>null, 'parent'=>null));
173
+ }
174
+ /**
175
+ * Return root ids
176
+ * @access public
177
+ * @return array
178
+ */
179
+ public function getRootIds(){
180
+ return array(Mage::helper('megamenu2/menuitem')->getRootMenuitemId());
181
+ }
182
+ }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit.php CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item admin edit form
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
25
- /**
26
- * constructor
27
- * @access public
28
- * @return void
29
- */
30
- public function __construct(){
31
- $this->_objectId = 'entity_id';
32
- $this->_blockGroup = 'megamenu2';
33
- $this->_controller = 'adminhtml_menuitem';
34
- $this->_mode = 'edit';
35
- parent::__construct();
36
- $this->setTemplate('jscriptz_megamenu2/menuitem/edit.phtml');
37
- }
38
- }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item admin edit form
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @return void
29
+ */
30
+ public function __construct(){
31
+ $this->_objectId = 'entity_id';
32
+ $this->_blockGroup = 'megamenu2';
33
+ $this->_controller = 'adminhtml_menuitem';
34
+ $this->_mode = 'edit';
35
+ parent::__construct();
36
+ $this->setTemplate('jscriptz_megamenu2/menuitem/edit.phtml');
37
+ }
38
+ }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Form.php CHANGED
@@ -1,200 +1,200 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item edit form
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract
25
- {
26
- /**
27
- * Additional buttons on menu item page
28
- * @var array
29
- */
30
- protected $_additionalButtons = array();
31
- /**
32
- * constroctor
33
- * set template
34
- * @access public
35
- * @return void
36
- */
37
- public function __construct(){
38
- parent::__construct();
39
- $this->setTemplate('jscriptz_megamenu2/menuitem/edit/form.phtml');
40
- }
41
- /**
42
- * prepare the layout
43
- * @access protected
44
- * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
45
- */
46
- protected function _prepareLayout(){
47
- $menuitem = $this->getMenuitem();
48
- $menuitemId = (int)$menuitem->getId();
49
- $this->setChild('tabs',
50
- $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tabs', 'tabs')
51
- );
52
- $this->setChild('save_button',
53
- $this->getLayout()->createBlock('adminhtml/widget_button')
54
- ->setData(array(
55
- 'label' => Mage::helper('megamenu2')->__('Save Menu Item'),
56
- 'onclick' => "menuitemSubmit('" . $this->getSaveUrl() . "', true)",
57
- 'class' => 'save'
58
- ))
59
- );
60
- // Delete button
61
- if (!in_array($menuitemId, $this->getRootIds())) {
62
- $this->setChild('delete_button',
63
- $this->getLayout()->createBlock('adminhtml/widget_button')
64
- ->setData(array(
65
- 'label' => Mage::helper('megamenu2')->__('Delete Menu Item'),
66
- 'onclick' => "menuitemDelete('" . $this->getUrl('*/*/delete', array('_current' => true)) . "', true, {$menuitemId})",
67
- 'class' => 'delete'
68
- ))
69
- );
70
- }
71
-
72
- // Reset button
73
- $resetPath = $menuitem ? '*/*/edit' : '*/*/add';
74
- $this->setChild('reset_button',
75
- $this->getLayout()->createBlock('adminhtml/widget_button')
76
- ->setData(array(
77
- 'label' => Mage::helper('megamenu2')->__('Reset'),
78
- 'onclick' => "menuitemReset('".$this->getUrl($resetPath, array('_current'=>true))."',true)"
79
- ))
80
- );
81
- return parent::_prepareLayout();
82
- }
83
- /**
84
- * get html for delete button
85
- * @access public
86
- * @return string
87
- */
88
- public function getDeleteButtonHtml(){
89
- return $this->getChildHtml('delete_button');
90
- }
91
- /**
92
- * get html for save button
93
- * @access public
94
- * @return string
95
- */
96
- public function getSaveButtonHtml(){
97
- return $this->getChildHtml('save_button');
98
- }
99
- /**
100
- * get html for reset button
101
- * @access public
102
- * @return string
103
- */
104
- public function getResetButtonHtml(){
105
- return $this->getChildHtml('reset_button');
106
- }
107
- /**
108
- * Retrieve additional buttons html
109
- * @access public
110
- * @return string
111
- */
112
- public function getAdditionalButtonsHtml(){
113
- $html = '';
114
- foreach ($this->_additionalButtons as $childName) {
115
- $html .= $this->getChildHtml($childName);
116
- }
117
- return $html;
118
- }
119
-
120
- /**
121
- * Add additional button
122
- *
123
- * @param string $alias
124
- * @param array $config
125
- * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
126
- */
127
- public function addAdditionalButton($alias, $config){
128
- if (isset($config['name'])) {
129
- $config['element_name'] = $config['name'];
130
- }
131
- $this->setChild($alias . '_button',
132
- $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
133
- $this->_additionalButtons[$alias] = $alias . '_button';
134
- return $this;
135
- }
136
- /**
137
- * Remove additional button
138
- * @access public
139
- * @param string $alias
140
- * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
141
- */
142
- public function removeAdditionalButton($alias){
143
- if (isset($this->_additionalButtons[$alias])) {
144
- $this->unsetChild($this->_additionalButtons[$alias]);
145
- unset($this->_additionalButtons[$alias]);
146
- }
147
- return $this;
148
- }
149
- /**
150
- * get html for tabs
151
- * @access public
152
- * @return string
153
- */
154
- public function getTabsHtml(){
155
- return $this->getChildHtml('tabs');
156
- }
157
- /**
158
- * get the form header
159
- * @access public
160
- * @return string
161
- */
162
- public function getHeader(){
163
- if ($this->getMenuitemId()) {
164
- return $this->getMenuitemLinktitle();
165
- }
166
- else {
167
- return Mage::helper('megamenu2')->__('New Root Menu Item');
168
- }
169
- }
170
- /**
171
- * get the delete url
172
- * @access public
173
- * @param array $args
174
- * @return string
175
- */
176
- public function getDeleteUrl(array $args = array()){
177
- $params = array('_current'=>true);
178
- $params = array_merge($params, $args);
179
- return $this->getUrl('*/*/delete', $params);
180
- }
181
- /**
182
- * Return URL for refresh input element 'path' in form
183
- * @access public
184
- * @param array $args
185
- * @return string
186
- */
187
- public function getRefreshPathUrl(array $args = array()){
188
- $params = array('_current'=>true);
189
- $params = array_merge($params, $args);
190
- return $this->getUrl('*/*/refreshPath', $params);
191
- }
192
- /**
193
- * check if request is ajax
194
- * @access public
195
- * @return bool
196
- */
197
- public function isAjax(){
198
- return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
199
- }
200
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item edit form
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract
25
+ {
26
+ /**
27
+ * Additional buttons on menu item page
28
+ * @var array
29
+ */
30
+ protected $_additionalButtons = array();
31
+ /**
32
+ * constroctor
33
+ * set template
34
+ * @access public
35
+ * @return void
36
+ */
37
+ public function __construct(){
38
+ parent::__construct();
39
+ $this->setTemplate('jscriptz_megamenu2/menuitem/edit/form.phtml');
40
+ }
41
+ /**
42
+ * prepare the layout
43
+ * @access protected
44
+ * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
45
+ */
46
+ protected function _prepareLayout(){
47
+ $menuitem = $this->getMenuitem();
48
+ $menuitemId = (int)$menuitem->getId();
49
+ $this->setChild('tabs',
50
+ $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tabs', 'tabs')
51
+ );
52
+ $this->setChild('save_button',
53
+ $this->getLayout()->createBlock('adminhtml/widget_button')
54
+ ->setData(array(
55
+ 'label' => Mage::helper('megamenu2')->__('Save Menu Item'),
56
+ 'onclick' => "menuitemSubmit('" . $this->getSaveUrl() . "', true)",
57
+ 'class' => 'save'
58
+ ))
59
+ );
60
+ // Delete button
61
+ if (!in_array($menuitemId, $this->getRootIds())) {
62
+ $this->setChild('delete_button',
63
+ $this->getLayout()->createBlock('adminhtml/widget_button')
64
+ ->setData(array(
65
+ 'label' => Mage::helper('megamenu2')->__('Delete Menu Item'),
66
+ 'onclick' => "menuitemDelete('" . $this->getUrl('*/*/delete', array('_current' => true)) . "', true, {$menuitemId})",
67
+ 'class' => 'delete'
68
+ ))
69
+ );
70
+ }
71
+
72
+ // Reset button
73
+ $resetPath = $menuitem ? '*/*/edit' : '*/*/add';
74
+ $this->setChild('reset_button',
75
+ $this->getLayout()->createBlock('adminhtml/widget_button')
76
+ ->setData(array(
77
+ 'label' => Mage::helper('megamenu2')->__('Reset'),
78
+ 'onclick' => "menuitemReset('".$this->getUrl($resetPath, array('_current'=>true))."',true)"
79
+ ))
80
+ );
81
+ return parent::_prepareLayout();
82
+ }
83
+ /**
84
+ * get html for delete button
85
+ * @access public
86
+ * @return string
87
+ */
88
+ public function getDeleteButtonHtml(){
89
+ return $this->getChildHtml('delete_button');
90
+ }
91
+ /**
92
+ * get html for save button
93
+ * @access public
94
+ * @return string
95
+ */
96
+ public function getSaveButtonHtml(){
97
+ return $this->getChildHtml('save_button');
98
+ }
99
+ /**
100
+ * get html for reset button
101
+ * @access public
102
+ * @return string
103
+ */
104
+ public function getResetButtonHtml(){
105
+ return $this->getChildHtml('reset_button');
106
+ }
107
+ /**
108
+ * Retrieve additional buttons html
109
+ * @access public
110
+ * @return string
111
+ */
112
+ public function getAdditionalButtonsHtml(){
113
+ $html = '';
114
+ foreach ($this->_additionalButtons as $childName) {
115
+ $html .= $this->getChildHtml($childName);
116
+ }
117
+ return $html;
118
+ }
119
+
120
+ /**
121
+ * Add additional button
122
+ *
123
+ * @param string $alias
124
+ * @param array $config
125
+ * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
126
+ */
127
+ public function addAdditionalButton($alias, $config){
128
+ if (isset($config['name'])) {
129
+ $config['element_name'] = $config['name'];
130
+ }
131
+ $this->setChild($alias . '_button',
132
+ $this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
133
+ $this->_additionalButtons[$alias] = $alias . '_button';
134
+ return $this;
135
+ }
136
+ /**
137
+ * Remove additional button
138
+ * @access public
139
+ * @param string $alias
140
+ * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
141
+ */
142
+ public function removeAdditionalButton($alias){
143
+ if (isset($this->_additionalButtons[$alias])) {
144
+ $this->unsetChild($this->_additionalButtons[$alias]);
145
+ unset($this->_additionalButtons[$alias]);
146
+ }
147
+ return $this;
148
+ }
149
+ /**
150
+ * get html for tabs
151
+ * @access public
152
+ * @return string
153
+ */
154
+ public function getTabsHtml(){
155
+ return $this->getChildHtml('tabs');
156
+ }
157
+ /**
158
+ * get the form header
159
+ * @access public
160
+ * @return string
161
+ */
162
+ public function getHeader(){
163
+ if ($this->getMenuitemId()) {
164
+ return $this->getMenuitemLinktitle();
165
+ }
166
+ else {
167
+ return Mage::helper('megamenu2')->__('New Root Menu Item');
168
+ }
169
+ }
170
+ /**
171
+ * get the delete url
172
+ * @access public
173
+ * @param array $args
174
+ * @return string
175
+ */
176
+ public function getDeleteUrl(array $args = array()){
177
+ $params = array('_current'=>true);
178
+ $params = array_merge($params, $args);
179
+ return $this->getUrl('*/*/delete', $params);
180
+ }
181
+ /**
182
+ * Return URL for refresh input element 'path' in form
183
+ * @access public
184
+ * @param array $args
185
+ * @return string
186
+ */
187
+ public function getRefreshPathUrl(array $args = array()){
188
+ $params = array('_current'=>true);
189
+ $params = array_merge($params, $args);
190
+ return $this->getUrl('*/*/refreshPath', $params);
191
+ }
192
+ /**
193
+ * check if request is ajax
194
+ * @access public
195
+ * @return bool
196
+ */
197
+ public function isAjax(){
198
+ return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
199
+ }
200
  }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Form.php CHANGED
@@ -1,126 +1,126 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item edit form tab
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form{
25
- /**
26
- * prepare the form
27
- * @access protected
28
- * @return MegaMenu2_Menuitem_Block_Adminhtml_Menuitem_Edit_Tab_Form
29
- */
30
- protected function _prepareForm(){
31
- $form = new Varien_Data_Form();
32
- $form->setHtmlIdPrefix('menuitem_');
33
- $form->setFieldNameSuffix('menuitem');
34
- $this->setForm($form);
35
- $fieldset = $form->addFieldset('menuitem_form', array('legend'=>Mage::helper('megamenu2')->__('Menu Item')));
36
- $fieldset->addType('editor', Mage::getConfig()->getBlockClassName('megamenu2/adminhtml_helper_wysiwyg'));
37
- if (!$this->getMenuitem()->getId()) {
38
- $parentId = $this->getRequest()->getParam('parent');
39
- if (!$parentId) {
40
- $parentId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
41
- }
42
- $fieldset->addField('path', 'hidden', array(
43
- 'name' => 'path',
44
- 'value' => $parentId
45
- ));
46
- }
47
- else {
48
- $fieldset->addField('id', 'hidden', array(
49
- 'name' => 'id',
50
- 'value' => $this->getMenuitem()->getId()
51
- ));
52
- $fieldset->addField('path', 'hidden', array(
53
- 'name' => 'path',
54
- 'value' => $this->getMenuitem()->getPath()
55
- ));
56
- }
57
-
58
- $fieldset->addField('linktitle', 'text', array(
59
- 'label' => Mage::helper('megamenu2')->__('Link Title'),
60
- 'name' => 'linktitle',
61
  'note' => $this->__('This is the title for your menu link'),
62
  'required' => true,
63
  'class' => 'required-entry',
64
 
65
- ));
66
-
67
- $fieldset->addField('linkpath', 'text', array(
68
- 'label' => Mage::helper('megamenu2')->__('Link Path'),
69
- 'name' => 'linkpath',
70
  'note' => $this->__('This is the url your link will follow'),
71
 
72
- ));
73
-
74
- $fieldset->addField('linktarget', 'text', array(
75
- 'label' => Mage::helper('megamenu2')->__('Link Target'),
76
- 'name' => 'linktarget',
77
  'note' => $this->__('Whether the link opens in a new tab -- examples (blank, self)'),
78
 
79
- ));
80
-
81
- $fieldset->addField('menuhtml', 'editor', array(
82
- 'label' => Mage::helper('megamenu2')->__('Menu HTML'),
83
- 'name' => 'menuhtml',
84
  'note' => $this->__('Place any HTML in this block to be displayed in the Mega Nav. Tip: Disable the WYSIWYG editor to place pure HTML code'),
85
 
86
- ));
87
-
88
- /*$fieldset->addField('sortorder', 'text', array(
89
- 'label' => Mage::helper('megamenu2')->__('Link Position'),
90
- 'name' => 'sortorder',
91
  'note' => $this->__('This controls the order in which your links are displayed'),
92
 
93
- ));*/
94
- $fieldset->addField('status', 'select', array(
95
- 'label' => Mage::helper('megamenu2')->__('Status'),
96
- 'name' => 'status',
97
- 'values'=> array(
98
- array(
99
- 'value' => 1,
100
- 'label' => Mage::helper('megamenu2')->__('Enabled'),
101
- ),
102
- array(
103
- 'value' => 0,
104
- 'label' => Mage::helper('megamenu2')->__('Disabled'),
105
- ),
106
- ),
107
- ));
108
- if (Mage::app()->isSingleStoreMode()){
109
- $fieldset->addField('store_id', 'hidden', array(
110
- 'name' => 'stores[]',
111
- 'value' => Mage::app()->getStore(true)->getId()
112
- ));
113
- Mage::registry('current_menuitem')->setStoreId(Mage::app()->getStore(true)->getId());
114
- }
115
- $form->addValues($this->getMenuitem()->getData());
116
- return parent::_prepareForm();
117
- }
118
- /**
119
- * get the current menu item
120
- * @access public
121
  * @return JScriptz_MegaMenu2_Model_Menuitem
122
- */
123
- public function getMenuitem(){
124
- return Mage::registry('menuitem');
125
- }
126
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item edit form tab
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form{
25
+ /**
26
+ * prepare the form
27
+ * @access protected
28
+ * @return MegaMenu2_Menuitem_Block_Adminhtml_Menuitem_Edit_Tab_Form
29
+ */
30
+ protected function _prepareForm(){
31
+ $form = new Varien_Data_Form();
32
+ $form->setHtmlIdPrefix('menuitem_');
33
+ $form->setFieldNameSuffix('menuitem');
34
+ $this->setForm($form);
35
+ $fieldset = $form->addFieldset('menuitem_form', array('legend'=>Mage::helper('megamenu2')->__('Menu Item')));
36
+ $fieldset->addType('editor', Mage::getConfig()->getBlockClassName('megamenu2/adminhtml_helper_wysiwyg'));
37
+ if (!$this->getMenuitem()->getId()) {
38
+ $parentId = $this->getRequest()->getParam('parent');
39
+ if (!$parentId) {
40
+ $parentId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
41
+ }
42
+ $fieldset->addField('path', 'hidden', array(
43
+ 'name' => 'path',
44
+ 'value' => $parentId
45
+ ));
46
+ }
47
+ else {
48
+ $fieldset->addField('id', 'hidden', array(
49
+ 'name' => 'id',
50
+ 'value' => $this->getMenuitem()->getId()
51
+ ));
52
+ $fieldset->addField('path', 'hidden', array(
53
+ 'name' => 'path',
54
+ 'value' => $this->getMenuitem()->getPath()
55
+ ));
56
+ }
57
+
58
+ $fieldset->addField('linktitle', 'text', array(
59
+ 'label' => Mage::helper('megamenu2')->__('Link Title'),
60
+ 'name' => 'linktitle',
61
  'note' => $this->__('This is the title for your menu link'),
62
  'required' => true,
63
  'class' => 'required-entry',
64
 
65
+ ));
66
+
67
+ $fieldset->addField('linkpath', 'text', array(
68
+ 'label' => Mage::helper('megamenu2')->__('Link Path'),
69
+ 'name' => 'linkpath',
70
  'note' => $this->__('This is the url your link will follow'),
71
 
72
+ ));
73
+
74
+ $fieldset->addField('linktarget', 'text', array(
75
+ 'label' => Mage::helper('megamenu2')->__('Link Target'),
76
+ 'name' => 'linktarget',
77
  'note' => $this->__('Whether the link opens in a new tab -- examples (blank, self)'),
78
 
79
+ ));
80
+
81
+ $fieldset->addField('menuhtml', 'editor', array(
82
+ 'label' => Mage::helper('megamenu2')->__('Menu HTML'),
83
+ 'name' => 'menuhtml',
84
  'note' => $this->__('Place any HTML in this block to be displayed in the Mega Nav. Tip: Disable the WYSIWYG editor to place pure HTML code'),
85
 
86
+ ));
87
+
88
+ /*$fieldset->addField('sortorder', 'text', array(
89
+ 'label' => Mage::helper('megamenu2')->__('Link Position'),
90
+ 'name' => 'sortorder',
91
  'note' => $this->__('This controls the order in which your links are displayed'),
92
 
93
+ ));*/
94
+ $fieldset->addField('status', 'select', array(
95
+ 'label' => Mage::helper('megamenu2')->__('Status'),
96
+ 'name' => 'status',
97
+ 'values'=> array(
98
+ array(
99
+ 'value' => 1,
100
+ 'label' => Mage::helper('megamenu2')->__('Enabled'),
101
+ ),
102
+ array(
103
+ 'value' => 0,
104
+ 'label' => Mage::helper('megamenu2')->__('Disabled'),
105
+ ),
106
+ ),
107
+ ));
108
+ if (Mage::app()->isSingleStoreMode()){
109
+ $fieldset->addField('store_id', 'hidden', array(
110
+ 'name' => 'stores[]',
111
+ 'value' => Mage::app()->getStore(true)->getId()
112
+ ));
113
+ Mage::registry('current_menuitem')->setStoreId(Mage::app()->getStore(true)->getId());
114
+ }
115
+ $form->addValues($this->getMenuitem()->getData());
116
+ return parent::_prepareForm();
117
+ }
118
+ /**
119
+ * get the current menu item
120
+ * @access public
121
  * @return JScriptz_MegaMenu2_Model_Menuitem
122
+ */
123
+ public function getMenuitem(){
124
+ return Mage::registry('menuitem');
125
+ }
126
  }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Stores.php CHANGED
@@ -1,47 +1,47 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * store selection tab
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form{
25
- /**
26
- * prepare the form
27
- * @access protected
28
- * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Stores
29
- */
30
- protected function _prepareForm(){
31
- $form = new Varien_Data_Form();
32
- $form->setFieldNameSuffix('menuitem');
33
- $this->setForm($form);
34
- $fieldset = $form->addFieldset('menuitem_stores_form', array('legend'=>Mage::helper('megamenu2')->__('Store views')));
35
- $field = $fieldset->addField('store_id', 'multiselect', array(
36
- 'name' => 'stores[]',
37
- 'label' => Mage::helper('megamenu2')->__('Store Views'),
38
- 'title' => Mage::helper('megamenu2')->__('Store Views'),
39
- 'required' => true,
40
- 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
41
- ));
42
- $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
43
- $field->setRenderer($renderer);
44
- $form->addValues(Mage::registry('current_menuitem')->getData());
45
- return parent::_prepareForm();
46
- }
47
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * store selection tab
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form{
25
+ /**
26
+ * prepare the form
27
+ * @access protected
28
+ * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Stores
29
+ */
30
+ protected function _prepareForm(){
31
+ $form = new Varien_Data_Form();
32
+ $form->setFieldNameSuffix('menuitem');
33
+ $this->setForm($form);
34
+ $fieldset = $form->addFieldset('menuitem_stores_form', array('legend'=>Mage::helper('megamenu2')->__('Store views')));
35
+ $field = $fieldset->addField('store_id', 'multiselect', array(
36
+ 'name' => 'stores[]',
37
+ 'label' => Mage::helper('megamenu2')->__('Store Views'),
38
+ 'title' => Mage::helper('megamenu2')->__('Store Views'),
39
+ 'required' => true,
40
+ 'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
41
+ ));
42
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
43
+ $field->setRenderer($renderer);
44
+ $form->addValues(Mage::registry('current_menuitem')->getData());
45
+ return parent::_prepareForm();
46
+ }
47
  }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tabs.php CHANGED
@@ -1,66 +1,66 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item admin edit tabs
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
25
- /**
26
- * Initialize Tabs
27
- * @access public
28
- * @return void
29
- */
30
- public function __construct(){
31
- parent::__construct();
32
- $this->setId('menuitem_info_tabs');
33
- $this->setDestElementId('menuitem_tab_content');
34
- $this->setTitle(Mage::helper('megamenu2')->__('Menu Item'));
35
- $this->setTemplate('widget/tabshoriz.phtml');
36
- }
37
- /**
38
- * Retrieve menu item entity
39
- * @access public
40
- * @return JScriptz_MegaMenu2_Model_Menuitem
41
-
42
- */
43
- public function getMenuitem(){
44
- return Mage::registry('current_menuitem');
45
- }
46
- /**
47
- * Prepare Layout Content
48
- * @access public
49
- * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tabs
50
- */
51
- protected function _prepareLayout(){
52
- $this->addTab('form_menuitem', array(
53
- 'label' => Mage::helper('megamenu2')->__('Menu Item'),
54
- 'title' => Mage::helper('megamenu2')->__('Menu Item'),
55
- 'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_form')->toHtml(),
56
- ));
57
- if (!Mage::app()->isSingleStoreMode()){
58
- $this->addTab('form_store_menuitem', array(
59
- 'label' => Mage::helper('megamenu2')->__('Store views'),
60
- 'title' => Mage::helper('megamenu2')->__('Store views'),
61
- 'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_stores')->toHtml(),
62
- ));
63
- }
64
- return parent::_prepareLayout();
65
- }
66
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item admin edit tabs
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
25
+ /**
26
+ * Initialize Tabs
27
+ * @access public
28
+ * @return void
29
+ */
30
+ public function __construct(){
31
+ parent::__construct();
32
+ $this->setId('menuitem_info_tabs');
33
+ $this->setDestElementId('menuitem_tab_content');
34
+ $this->setTitle(Mage::helper('megamenu2')->__('Menu Item'));
35
+ $this->setTemplate('widget/tabshoriz.phtml');
36
+ }
37
+ /**
38
+ * Retrieve menu item entity
39
+ * @access public
40
+ * @return JScriptz_MegaMenu2_Model_Menuitem
41
+
42
+ */
43
+ public function getMenuitem(){
44
+ return Mage::registry('current_menuitem');
45
+ }
46
+ /**
47
+ * Prepare Layout Content
48
+ * @access public
49
+ * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tabs
50
+ */
51
+ protected function _prepareLayout(){
52
+ $this->addTab('form_menuitem', array(
53
+ 'label' => Mage::helper('megamenu2')->__('Menu Item'),
54
+ 'title' => Mage::helper('megamenu2')->__('Menu Item'),
55
+ 'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_form')->toHtml(),
56
+ ));
57
+ if (!Mage::app()->isSingleStoreMode()){
58
+ $this->addTab('form_store_menuitem', array(
59
+ 'label' => Mage::helper('megamenu2')->__('Store views'),
60
+ 'title' => Mage::helper('megamenu2')->__('Store views'),
61
+ 'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_stores')->toHtml(),
62
+ ));
63
+ }
64
+ return parent::_prepareLayout();
65
+ }
66
  }
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Tree.php CHANGED
@@ -1,303 +1,303 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item admin tree block
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract{
24
- /**
25
- * constructor
26
- * @access public
27
- * @return void
28
- */
29
- public function __construct(){
30
- parent::__construct();
31
- $this->setTemplate('jscriptz_megamenu2/menuitem/tree.phtml');
32
- $this->setUseAjax(true);
33
- $this->_withProductCount = true;
34
- }
35
- /**
36
- * prepare the layout
37
- * @access protected
38
- * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree
39
- */
40
- protected function _prepareLayout(){
41
- $addUrl = $this->getUrl("*/*/add", array(
42
- '_current'=>true,
43
- 'id'=>null,
44
- '_query' => false
45
- ));
46
-
47
- $this->setChild('add_sub_button',
48
- $this->getLayout()->createBlock('adminhtml/widget_button')
49
- ->setData(array(
50
- 'label' => Mage::helper('megamenu2')->__('Add Child Menu Item'),
51
- 'onclick' => "addNew('".$addUrl."', false)",
52
- 'class' => 'add',
53
- 'id'=> 'add_child_menuitem_button',
54
- 'style' => $this->canAddChild() ? '' : 'display: none;'
55
- ))
56
- );
57
-
58
- $this->setChild('add_root_button',
59
- $this->getLayout()->createBlock('adminhtml/widget_button')
60
- ->setData(array(
61
- 'label' => Mage::helper('megamenu2')->__('Add Root Menu Item'),
62
- 'onclick' => "addNew('".$addUrl."', true)",
63
- 'class' => 'add',
64
- 'id'=> 'add_root_menuitem_button'
65
- ))
66
- );
67
- return parent::_prepareLayout();
68
- }
69
- /**
70
- * get the menu item collection
71
- * @access public
72
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
73
- */
74
- public function getMenuitemCollection(){
75
- $collection = $this->getData('menuitem_collection');
76
- if (is_null($collection)) {
77
- $collection = Mage::getModel('megamenu2/menuitem')->getCollection();
78
- $this->setData('menuitem_collection', $collection);
79
- }
80
- return $collection;
81
- }
82
- /**
83
- * get html for add root button
84
- * @access public
85
- * @return string
86
- */
87
- public function getAddRootButtonHtml(){
88
- return $this->getChildHtml('add_root_button');
89
- }
90
- /**
91
- * get html for add child button
92
- * @access public
93
- * @return string
94
- */
95
- public function getAddSubButtonHtml(){
96
- return $this->getChildHtml('add_sub_button');
97
- }
98
- /**
99
- * get html for expand button
100
- * @access public
101
- * @return string
102
- */
103
- public function getExpandButtonHtml(){
104
- return $this->getChildHtml('expand_button');
105
- }
106
- /**
107
- * get html for add collapse button
108
- * @access public
109
- * @return string
110
- */
111
- public function getCollapseButtonHtml(){
112
- return $this->getChildHtml('collapse_button');
113
- }
114
- /**
115
- * get url for tree load
116
- * @access public
117
- * @param mxed $expanded
118
- * @return string
119
- */
120
- public function getLoadTreeUrl($expanded=null){
121
- $params = array('_current'=>true, 'id'=>null,'store'=>null);
122
- if ((is_null($expanded) && Mage::getSingleton('admin/session')->getMenuitemIsTreeWasExpanded())|| $expanded == true) {
123
- $params['expand_all'] = true;
124
- }
125
- return $this->getUrl('*/*/menuitemsJson', $params);
126
- }
127
- /**
128
- * get url for loading nodes
129
- * @access public
130
- * @return string
131
- */
132
- public function getNodesUrl(){
133
- return $this->getUrl('*/megamenu2_menuitems/jsonTree');
134
- }
135
- /**
136
- * check if tree is expanded
137
- * @access public
138
- * @return string
139
- */
140
- public function getIsWasExpanded(){
141
- return Mage::getSingleton('admin/session')->getMenuitemIsTreeWasExpanded();
142
- }
143
- /**
144
- * get url for moving menu item
145
- * @access public
146
- * @return string
147
- */
148
- public function getMoveUrl(){
149
- return $this->getUrl('*/megamenu2_menuitem/move');
150
- }
151
- /**
152
- * get the tree as json
153
- * @access public
154
- * @param mixed $parentNodeMenuitem
155
- * @return string
156
- */
157
- public function getTree($parentNodeMenuitem = null){
158
- $rootArray = $this->_getNodeJson($this->getRoot($parentNodeMenuitem));
159
- $tree = isset($rootArray['children']) ? $rootArray['children'] : array();
160
- return $tree;
161
- }
162
- /**
163
- * get the tree as json
164
- * @access public
165
- * @param mixed $parentNodeMenuitem
166
- * @return string
167
- */
168
- public function getTreeJson($parentNodeMenuitem = null){
169
- $rootArray = $this->_getNodeJson($this->getRoot($parentNodeMenuitem));
170
- $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
171
- return $json;
172
- }
173
-
174
- /**
175
- * Get JSON of array of menu items, that are breadcrumbs for specified menu item path
176
- * @access public
177
- * @param string $path
178
- * @param string $javascriptVarName
179
- * @return string
180
- */
181
- public function getBreadcrumbsJavascript($path, $javascriptVarName){
182
- if (empty($path)) {
183
- return '';
184
- }
185
-
186
- $menuitems = Mage::getResourceSingleton('megamenu2/menuitem_tree')->loadBreadcrumbsArray($path);
187
- if (empty($menuitems)) {
188
- return '';
189
- }
190
- foreach ($menuitems as $key => $menuitem) {
191
- $menuitems[$key] = $this->_getNodeJson($menuitem);
192
- }
193
- return
194
- '<script type="text/javascript">'
195
- . $javascriptVarName . ' = ' . Mage::helper('core')->jsonEncode($menuitems) . ';'
196
- . ($this->canAddChild() ? '$("add_child_menuitem_button").show();' : '$("add_child_menuitem_button").hide();')
197
- . '</script>';
198
- }
199
-
200
- /**
201
- * Get JSON of a tree node or an associative array
202
- * @access protected
203
- * @param Varien_Data_Tree_Node|array $node
204
- * @param int $level
205
- * @return string
206
- */
207
- protected function _getNodeJson($node, $level = 0){
208
- // create a node from data array
209
- if (is_array($node)) {
210
- $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
211
- }
212
- $item = array();
213
- $item['text'] = $this->buildNodeName($node);
214
- $rootForStores = in_array($node->getEntityId(), $this->getRootIds());
215
- $item['id'] = $node->getId();
216
- $item['path'] = $node->getData('path');
217
- $item['cls'] = 'folder';
218
- if ($node->getStatus()){
219
- $item['cls'] .= ' active-category';
220
- }
221
- else{
222
- $item['cls'] .= ' no-active-category';
223
- }
224
- $item['allowDrop'] = true;
225
- $item['allowDrag'] = true;
226
- if ((int)$node->getChildrenCount()>0) {
227
- $item['children'] = array();
228
- }
229
- $isParent = $this->_isParentSelectedMenuitem($node);
230
- if ($node->hasChildren()) {
231
- $item['children'] = array();
232
- if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
233
- foreach ($node->getChildren() as $child) {
234
- $item['children'][] = $this->_getNodeJson($child, $level+1);
235
- }
236
- }
237
- }
238
- if ($isParent || $node->getLevel() < 1) {
239
- $item['expanded'] = true;
240
- }
241
- return $item;
242
- }
243
- /**
244
- * Get node label
245
- * @access public
246
- * @param Varien_Object $node
247
- * @return string
248
- */
249
- public function buildNodeName($node){
250
- $result = $this->htmlEscape($node->getLinktitle());
251
- return $result;
252
- }
253
- /**
254
- * check if entity is movable
255
- * @access protected
256
- * @param Varien_Object $node
257
- * @return bool
258
- */
259
- protected function _isMenuitemMoveable($node){
260
- return true;
261
- }
262
- /**
263
- * check if parent is selected
264
- * @access protected
265
- * @param Varien_Object $node
266
- * @return bool
267
 
268
- */
269
- protected function _isParentSelectedMenuitem($node){
270
- if ($node && $this->getMenuitem()) {
271
- $pathIds = $this->getMenuitem()->getPathIds();
272
- if (in_array($node->getId(), $pathIds)) {
273
- return true;
274
- }
275
- }
276
- return false;
277
- }
278
-
279
- /**
280
- * Check if page loaded by outside link to menu item edit
281
- * @access public
282
- * @return boolean
283
- */
284
- public function isClearEdit(){
285
- return (bool) $this->getRequest()->getParam('clear');
286
- }
287
- /**
288
- * Check availability of adding root menu item
289
- * @access public
290
- * @return boolean
291
- */
292
- public function canAddRootMenuitem(){
293
- return true;
294
- }
295
- /**
296
- * Check availability of adding child menu item
297
- * @access public
298
- * @return boolean
299
- */
300
- public function canAddChild(){
301
- return true;
302
- }
303
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item admin tree block
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract{
24
+ /**
25
+ * constructor
26
+ * @access public
27
+ * @return void
28
+ */
29
+ public function __construct(){
30
+ parent::__construct();
31
+ $this->setTemplate('jscriptz_megamenu2/menuitem/tree.phtml');
32
+ $this->setUseAjax(true);
33
+ $this->_withProductCount = true;
34
+ }
35
+ /**
36
+ * prepare the layout
37
+ * @access protected
38
+ * @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree
39
+ */
40
+ protected function _prepareLayout(){
41
+ $addUrl = $this->getUrl("*/*/add", array(
42
+ '_current'=>true,
43
+ 'id'=>null,
44
+ '_query' => false
45
+ ));
46
+
47
+ $this->setChild('add_sub_button',
48
+ $this->getLayout()->createBlock('adminhtml/widget_button')
49
+ ->setData(array(
50
+ 'label' => Mage::helper('megamenu2')->__('Add Child Menu Item'),
51
+ 'onclick' => "addNew('".$addUrl."', false)",
52
+ 'class' => 'add',
53
+ 'id'=> 'add_child_menuitem_button',
54
+ 'style' => $this->canAddChild() ? '' : 'display: none;'
55
+ ))
56
+ );
57
+
58
+ $this->setChild('add_root_button',
59
+ $this->getLayout()->createBlock('adminhtml/widget_button')
60
+ ->setData(array(
61
+ 'label' => Mage::helper('megamenu2')->__('Add Root Menu Item'),
62
+ 'onclick' => "addNew('".$addUrl."', true)",
63
+ 'class' => 'add',
64
+ 'id'=> 'add_root_menuitem_button'
65
+ ))
66
+ );
67
+ return parent::_prepareLayout();
68
+ }
69
+ /**
70
+ * get the menu item collection
71
+ * @access public
72
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
73
+ */
74
+ public function getMenuitemCollection(){
75
+ $collection = $this->getData('menuitem_collection');
76
+ if (is_null($collection)) {
77
+ $collection = Mage::getModel('megamenu2/menuitem')->getCollection();
78
+ $this->setData('menuitem_collection', $collection);
79
+ }
80
+ return $collection;
81
+ }
82
+ /**
83
+ * get html for add root button
84
+ * @access public
85
+ * @return string
86
+ */
87
+ public function getAddRootButtonHtml(){
88
+ return $this->getChildHtml('add_root_button');
89
+ }
90
+ /**
91
+ * get html for add child button
92
+ * @access public
93
+ * @return string
94
+ */
95
+ public function getAddSubButtonHtml(){
96
+ return $this->getChildHtml('add_sub_button');
97
+ }
98
+ /**
99
+ * get html for expand button
100
+ * @access public
101
+ * @return string
102
+ */
103
+ public function getExpandButtonHtml(){
104
+ return $this->getChildHtml('expand_button');
105
+ }
106
+ /**
107
+ * get html for add collapse button
108
+ * @access public
109
+ * @return string
110
+ */
111
+ public function getCollapseButtonHtml(){
112
+ return $this->getChildHtml('collapse_button');
113
+ }
114
+ /**
115
+ * get url for tree load
116
+ * @access public
117
+ * @param mxed $expanded
118
+ * @return string
119
+ */
120
+ public function getLoadTreeUrl($expanded=null){
121
+ $params = array('_current'=>true, 'id'=>null,'store'=>null);
122
+ if ((is_null($expanded) && Mage::getSingleton('admin/session')->getMenuitemIsTreeWasExpanded())|| $expanded == true) {
123
+ $params['expand_all'] = true;
124
+ }
125
+ return $this->getUrl('*/*/menuitemsJson', $params);
126
+ }
127
+ /**
128
+ * get url for loading nodes
129
+ * @access public
130
+ * @return string
131
+ */
132
+ public function getNodesUrl(){
133
+ return $this->getUrl('*/megamenu2_menuitems/jsonTree');
134
+ }
135
+ /**
136
+ * check if tree is expanded
137
+ * @access public
138
+ * @return string
139
+ */
140
+ public function getIsWasExpanded(){
141
+ return Mage::getSingleton('admin/session')->getMenuitemIsTreeWasExpanded();
142
+ }
143
+ /**
144
+ * get url for moving menu item
145
+ * @access public
146
+ * @return string
147
+ */
148
+ public function getMoveUrl(){
149
+ return $this->getUrl('*/megamenu2_menuitem/move');
150
+ }
151
+ /**
152
+ * get the tree as json
153
+ * @access public
154
+ * @param mixed $parentNodeMenuitem
155
+ * @return string
156
+ */
157
+ public function getTree($parentNodeMenuitem = null){
158
+ $rootArray = $this->_getNodeJson($this->getRoot($parentNodeMenuitem));
159
+ $tree = isset($rootArray['children']) ? $rootArray['children'] : array();
160
+ return $tree;
161
+ }
162
+ /**
163
+ * get the tree as json
164
+ * @access public
165
+ * @param mixed $parentNodeMenuitem
166
+ * @return string
167
+ */
168
+ public function getTreeJson($parentNodeMenuitem = null){
169
+ $rootArray = $this->_getNodeJson($this->getRoot($parentNodeMenuitem));
170
+ $json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
171
+ return $json;
172
+ }
173
+
174
+ /**
175
+ * Get JSON of array of menu items, that are breadcrumbs for specified menu item path
176
+ * @access public
177
+ * @param string $path
178
+ * @param string $javascriptVarName
179
+ * @return string
180
+ */
181
+ public function getBreadcrumbsJavascript($path, $javascriptVarName){
182
+ if (empty($path)) {
183
+ return '';
184
+ }
185
+
186
+ $menuitems = Mage::getResourceSingleton('megamenu2/menuitem_tree')->loadBreadcrumbsArray($path);
187
+ if (empty($menuitems)) {
188
+ return '';
189
+ }
190
+ foreach ($menuitems as $key => $menuitem) {
191
+ $menuitems[$key] = $this->_getNodeJson($menuitem);
192
+ }
193
+ return
194
+ '<script type="text/javascript">'
195
+ . $javascriptVarName . ' = ' . Mage::helper('core')->jsonEncode($menuitems) . ';'
196
+ . ($this->canAddChild() ? '$("add_child_menuitem_button").show();' : '$("add_child_menuitem_button").hide();')
197
+ . '</script>';
198
+ }
199
+
200
+ /**
201
+ * Get JSON of a tree node or an associative array
202
+ * @access protected
203
+ * @param Varien_Data_Tree_Node|array $node
204
+ * @param int $level
205
+ * @return string
206
+ */
207
+ protected function _getNodeJson($node, $level = 0){
208
+ // create a node from data array
209
+ if (is_array($node)) {
210
+ $node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
211
+ }
212
+ $item = array();
213
+ $item['text'] = $this->buildNodeName($node);
214
+ $rootForStores = in_array($node->getEntityId(), $this->getRootIds());
215
+ $item['id'] = $node->getId();
216
+ $item['path'] = $node->getData('path');
217
+ $item['cls'] = 'folder';
218
+ if ($node->getStatus()){
219
+ $item['cls'] .= ' active-category';
220
+ }
221
+ else{
222
+ $item['cls'] .= ' no-active-category';
223
+ }
224
+ $item['allowDrop'] = true;
225
+ $item['allowDrag'] = true;
226
+ if ((int)$node->getChildrenCount()>0) {
227
+ $item['children'] = array();
228
+ }
229
+ $isParent = $this->_isParentSelectedMenuitem($node);
230
+ if ($node->hasChildren()) {
231
+ $item['children'] = array();
232
+ if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
233
+ foreach ($node->getChildren() as $child) {
234
+ $item['children'][] = $this->_getNodeJson($child, $level+1);
235
+ }
236
+ }
237
+ }
238
+ if ($isParent || $node->getLevel() < 1) {
239
+ $item['expanded'] = true;
240
+ }
241
+ return $item;
242
+ }
243
+ /**
244
+ * Get node label
245
+ * @access public
246
+ * @param Varien_Object $node
247
+ * @return string
248
+ */
249
+ public function buildNodeName($node){
250
+ $result = $this->htmlEscape($node->getLinktitle());
251
+ return $result;
252
+ }
253
+ /**
254
+ * check if entity is movable
255
+ * @access protected
256
+ * @param Varien_Object $node
257
+ * @return bool
258
+ */
259
+ protected function _isMenuitemMoveable($node){
260
+ return true;
261
+ }
262
+ /**
263
+ * check if parent is selected
264
+ * @access protected
265
+ * @param Varien_Object $node
266
+ * @return bool
267
 
268
+ */
269
+ protected function _isParentSelectedMenuitem($node){
270
+ if ($node && $this->getMenuitem()) {
271
+ $pathIds = $this->getMenuitem()->getPathIds();
272
+ if (in_array($node->getId(), $pathIds)) {
273
+ return true;
274
+ }
275
+ }
276
+ return false;
277
+ }
278
+
279
+ /**
280
+ * Check if page loaded by outside link to menu item edit
281
+ * @access public
282
+ * @return boolean
283
+ */
284
+ public function isClearEdit(){
285
+ return (bool) $this->getRequest()->getParam('clear');
286
+ }
287
+ /**
288
+ * Check availability of adding root menu item
289
+ * @access public
290
+ * @return boolean
291
+ */
292
+ public function canAddRootMenuitem(){
293
+ return true;
294
+ }
295
+ /**
296
+ * Check availability of adding child menu item
297
+ * @access public
298
+ * @return boolean
299
+ */
300
+ public function canAddChild(){
301
+ return true;
302
+ }
303
  }
app/code/community/JScriptz/MegaMenu2/Controller/Adminhtml/MegaMenu2.php CHANGED
@@ -1,59 +1,59 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * module base admin controller
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Controller_Adminhtml_MegaMenu2 extends Mage_Adminhtml_Controller_Action{
25
- /**
26
- * upload file and get the uploaded name
27
- * @access public
28
- * @param string $input
29
- * @param string $destinationFolder
30
- * @param array $data
31
- * @return string
32
- */
33
- protected function _uploadAndGetName($input, $destinationFolder, $data){
34
- try{
35
- if (isset($data[$input]['delete'])){
36
- return '';
37
- }
38
- else{
39
- $uploader = new Varien_File_Uploader($input);
40
- $uploader->setAllowRenameFiles(true);
41
- $uploader->setFilesDispersion(true);
42
- $uploader->setAllowCreateFolders(true);
43
- $result = $uploader->save($destinationFolder);
44
- return $result['file'];
45
- }
46
- }
47
- catch (Exception $e){
48
- if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY){
49
- throw $e;
50
- }
51
- else{
52
- if (isset($data[$input]['value'])){
53
- return $data[$input]['value'];
54
- }
55
- }
56
- }
57
- return '';
58
- }
59
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * module base admin controller
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Controller_Adminhtml_MegaMenu2 extends Mage_Adminhtml_Controller_Action{
25
+ /**
26
+ * upload file and get the uploaded name
27
+ * @access public
28
+ * @param string $input
29
+ * @param string $destinationFolder
30
+ * @param array $data
31
+ * @return string
32
+ */
33
+ protected function _uploadAndGetName($input, $destinationFolder, $data){
34
+ try{
35
+ if (isset($data[$input]['delete'])){
36
+ return '';
37
+ }
38
+ else{
39
+ $uploader = new Varien_File_Uploader($input);
40
+ $uploader->setAllowRenameFiles(true);
41
+ $uploader->setFilesDispersion(true);
42
+ $uploader->setAllowCreateFolders(true);
43
+ $result = $uploader->save($destinationFolder);
44
+ return $result['file'];
45
+ }
46
+ }
47
+ catch (Exception $e){
48
+ if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY){
49
+ throw $e;
50
+ }
51
+ else{
52
+ if (isset($data[$input]['value'])){
53
+ return $data[$input]['value'];
54
+ }
55
+ }
56
+ }
57
+ return '';
58
+ }
59
  }
app/code/community/JScriptz/MegaMenu2/Helper/Data.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * MegaMenu2 default helper
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Helper_Data extends Mage_Core_Helper_Abstract{
24
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MegaMenu2 default helper
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Helper_Data extends Mage_Core_Helper_Abstract{
24
  }
app/code/community/JScriptz/MegaMenu2/Helper/Menuitem.php CHANGED
@@ -1,41 +1,41 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item helper
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Helper_Menuitem extends Mage_Core_Helper_Abstract{
24
- const MENUITEM_ROOT_ID = 1;
25
- /**
26
- * get the root id
27
- * @access public
28
  * @return int
29
- */
30
- public function getRootMenuitemId(){
31
- return self::MENUITEM_ROOT_ID;
32
- }
33
- /**
34
- * check if breadcrumbs can be used
35
- * @access public
36
- * @return bool
37
- */
38
- public function getUseBreadcrumbs(){
39
- return Mage::getStoreConfigFlag('megamenu2/menuitem/breadcrumbs');
40
- }
41
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item helper
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Helper_Menuitem extends Mage_Core_Helper_Abstract{
24
+ const MENUITEM_ROOT_ID = 1;
25
+ /**
26
+ * get the root id
27
+ * @access public
28
  * @return int
29
+ */
30
+ public function getRootMenuitemId(){
31
+ return self::MENUITEM_ROOT_ID;
32
+ }
33
+ /**
34
+ * check if breadcrumbs can be used
35
+ * @access public
36
+ * @return bool
37
+ */
38
+ public function getUseBreadcrumbs(){
39
+ return Mage::getStoreConfigFlag('megamenu2/menuitem/breadcrumbs');
40
+ }
41
  }
app/code/community/JScriptz/MegaMenu2/Model/Menuitem.php CHANGED
@@ -1,307 +1,307 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item model
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Model_Menuitem extends Mage_Core_Model_Abstract{
24
- /**
25
- * Entity code.
26
- * Can be used as part of method name for entity processing
27
- */
28
- const ENTITY= 'megamenu2_menuitem';
29
- const CACHE_TAG = 'megamenu2_menuitem';
30
- /**
31
- * Prefix of model events names
32
- * @var string
33
- */
34
- protected $_eventPrefix = 'megamenu2_menuitem';
35
-
36
- /**
37
- * Parameter name in event
38
- * @var string
39
- */
40
- protected $_eventObject = 'menuitem';
41
- /**
42
- * constructor
43
- * @access public
44
- * @return void
45
- */
46
- public function _construct(){
47
- parent::_construct();
48
- $this->_init('megamenu2/menuitem');
49
- }
50
- /**
51
- * before save menu item
52
- * @access protected
53
- * @return JScriptz_MegaMenu2_Model_Menuitem
54
- */
55
- protected function _beforeSave(){
56
- parent::_beforeSave();
57
- $now = Mage::getSingleton('core/date')->gmtDate();
58
- if ($this->isObjectNew()){
59
- $this->setCreatedAt($now);
60
- }
61
- $this->setUpdatedAt($now);
62
- return $this;
63
- }
64
- /**
65
- * get the menuitem Menu HTML
66
- * @access public
67
- * @return string
68
- */
69
- public function getMenuhtml(){
70
- $menuhtml = $this->getData('menuhtml');
71
- $helper = Mage::helper('cms');
72
- $processor = $helper->getBlockTemplateProcessor();
73
- $html = $processor->filter($menuhtml);
74
- return $html;
75
- }
76
- /**
77
- * save menuitem relation
78
- * @access public
79
- * @return JScriptz_MegaMenu2_Model_Menuitem
80
- */
81
- protected function _afterSave() {
82
- return parent::_afterSave();
83
- }
84
- /**
85
- * get the tree model
86
- * @access public
87
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
88
 
89
- */
90
- public function getTreeModel(){
91
- return Mage::getResourceModel('megamenu2/menuitem_tree');
92
- }
93
- /**
94
- * get tree model instance
95
- * @access public
96
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
97
- */
98
- public function getTreeModelInstance(){
99
- if (is_null($this->_treeModel)) {
100
- $this->_treeModel = Mage::getResourceSingleton('megamenu2/menuitem_tree');
101
- }
102
- return $this->_treeModel;
103
- }
104
- /**
105
- * Move menu item
106
- * @access public
107
- * @param int $parentId new parent menu item id
108
- * @param int $afterMenuitemId menu item id after which we have put current menu item
109
- * @return JScriptz_MegaMenu2_Model_Menuitem
110
- */
111
- public function move($parentId, $afterMenuitemId){
112
- $parent = Mage::getModel('megamenu2/menuitem')->load($parentId);
113
- if (!$parent->getId()) {
114
- Mage::throwException(
115
- Mage::helper('megamenu2')->__('Menu Item move operation is not possible: the new parent menu item was not found.')
116
- );
117
- }
118
- if (!$this->getId()) {
119
- Mage::throwException(
120
- Mage::helper('megamenu2')->__('Menu Item move operation is not possible: the current menu item was not found.')
121
- );
122
- }
123
- elseif ($parent->getId() == $this->getId()) {
124
- Mage::throwException(
125
- Mage::helper('megamenu2')->__('Menu Item move operation is not possible: parent menu item is equal to child menu item.')
126
- );
127
- }
128
- $this->setMovedMenuitemId($this->getId());
129
- $eventParams = array(
130
- $this->_eventObject => $this,
131
- 'parent' => $parent,
132
- 'menuitem_id' => $this->getId(),
133
- 'prev_parent_id' => $this->getParentId(),
134
- 'parent_id' => $parentId
135
- );
136
- $moveComplete = false;
137
- $this->_getResource()->beginTransaction();
138
- try {
139
- $this->getResource()->changeParent($this, $parent, $afterMenuitemId);
140
- $this->_getResource()->commit();
141
- $this->setAffectedMenuitemIds(array($this->getId(), $this->getParentId(), $parentId));
142
- $moveComplete = true;
143
- }
144
- catch (Exception $e) {
145
- $this->_getResource()->rollBack();
146
- throw $e;
147
- }
148
- if ($moveComplete) {
149
- Mage::app()->cleanCache(array(self::CACHE_TAG));
150
- }
151
- return $this;
152
- }
153
- /**
154
- * Get the parent menu item
155
- * @access public
156
- * @return JScriptz_MegaMenu2_Model_Menuitem
157
- */
158
- public function getParentMenuitem(){
159
- if (!$this->hasData('parent_menuitem')) {
160
- $this->setData('parent_menuitem', Mage::getModel('megamenu2/menuitem')->load($this->getParentId()));
161
- }
162
- return $this->_getData('parent_menuitem');
163
- }
164
- /**
165
- * Get the parent id
166
- * @access public
167
- * @return int
168
- */
169
- public function getParentId(){
170
- $parentIds = $this->getParentIds();
171
- return intval(array_pop($parentIds));
172
- }
173
- /**
174
- * Get all parent menu items ids
175
- * @access public
176
- * @return array
177
- */
178
- public function getParentIds(){
179
- return array_diff($this->getPathIds(), array($this->getId()));
180
- }
181
- /**
182
- * Get all menu items children
183
- * @access public
184
- * @param bool $asArray
185
- * @return mixed (array|string)
186
- */
187
- public function getAllChildren($asArray = false){
188
- $children = $this->getResource()->getAllChildren($this);
189
- if ($asArray) {
190
- return $children;
191
- }
192
- else {
193
- return implode(',', $children);
194
- }
195
- }
196
- /**
197
- * Get all menu items children
198
- * @access public
199
- * @return string
200
- */
201
- public function getChildren(){
202
- return implode(',', $this->getResource()->getChildren($this, false));
203
- }
204
- /**
205
- * check the id
206
- * @access public
207
- * @return bool
208
- */
209
- public function checkId($id){
210
- return $this->_getResource()->checkId($id);
211
- }
212
- /**
213
- * Get array menu items ids which are part of menu item path
214
- * @access public
215
- * @return array
216
- */
217
- public function getPathIds(){
218
- $ids = $this->getData('path_ids');
219
- if (is_null($ids)) {
220
- $ids = explode('/', $this->getPath());
221
- $this->setData('path_ids', $ids);
222
- }
223
- return $ids;
224
- }
225
- /**
226
- * Retrieve level
227
- * @access public
228
- * @return int
229
- */
230
- public function getLevel(){
231
- if (!$this->hasLevel()) {
232
- return count(explode('/', $this->getPath())) - 1;
233
- }
234
- return $this->getData('level');
235
- }
236
- /**
237
- * Verify menu item ids
238
- * @access public
239
- * @param array $ids
240
- * @return bool
241
- */
242
- public function verifyIds(array $ids){
243
- return $this->getResource()->verifyIds($ids);
244
- }
245
- /**
246
- * check if menu item has children
247
- * @access public
248
- * @return bool
249
- */
250
- public function hasChildren(){
251
- return $this->_getResource()->getChildrenAmount($this) > 0;
252
- }
253
- /**
254
- * check if menu item can be deleted
255
- * @access protected
256
- * @return JScriptz_MegaMenu2_Model_Menuitem
257
- */
258
- protected function _beforeDelete(){
259
- if ($this->getResource()->isForbiddenToDelete($this->getId())) {
260
- Mage::throwException(Mage::helper('megamenu2')->__("Can't delete root menu item."));
261
- }
262
- return parent::_beforeDelete();
263
- }
264
- /**
265
- * get the menu items
266
- * @access public
267
- * @param JScriptz_MegaMenu2_Model_Menuitem $parent
268
- * @param int $recursionLevel
269
- * @param bool $sorted
270
- * @param bool $asCollection
271
- * @param bool $toLoad
272
 
273
- */
274
- public function getMenuitems($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true){
275
- return $this->getResource()->getMenuitems($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
276
- }
277
- /**
278
- * Return parent menu items of current menu item
279
- * @access public
280
- * @return array
281
- */
282
- public function getParentMenuitems(){
283
- return $this->getResource()->getParentMenuitems($this);
284
- }
285
- /**
286
- * Retuen children menu items of current menu item
287
- * @access public
288
- * @return array
289
- */
290
- public function getChildrenMenuitems(){
291
- return $this->getResource()->getChildrenMenuitems($this);
292
- }
293
- /**
294
- * check if parents are enabled
295
- * @access public
296
  * @return bool
297
- */
298
- public function getStatusPath(){
299
- $parents = $this->getParentMenuitems();
300
- foreach ($parents as $parent){
301
- if (!$parent->getStatus()){
302
- return false;
303
- }
304
- }
305
- return $this->getStatus();
306
- }
307
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item model
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Model_Menuitem extends Mage_Core_Model_Abstract{
24
+ /**
25
+ * Entity code.
26
+ * Can be used as part of method name for entity processing
27
+ */
28
+ const ENTITY= 'megamenu2_menuitem';
29
+ const CACHE_TAG = 'megamenu2_menuitem';
30
+ /**
31
+ * Prefix of model events names
32
+ * @var string
33
+ */
34
+ protected $_eventPrefix = 'megamenu2_menuitem';
35
+
36
+ /**
37
+ * Parameter name in event
38
+ * @var string
39
+ */
40
+ protected $_eventObject = 'menuitem';
41
+ /**
42
+ * constructor
43
+ * @access public
44
+ * @return void
45
+ */
46
+ public function _construct(){
47
+ parent::_construct();
48
+ $this->_init('megamenu2/menuitem');
49
+ }
50
+ /**
51
+ * before save menu item
52
+ * @access protected
53
+ * @return JScriptz_MegaMenu2_Model_Menuitem
54
+ */
55
+ protected function _beforeSave(){
56
+ parent::_beforeSave();
57
+ $now = Mage::getSingleton('core/date')->gmtDate();
58
+ if ($this->isObjectNew()){
59
+ $this->setCreatedAt($now);
60
+ }
61
+ $this->setUpdatedAt($now);
62
+ return $this;
63
+ }
64
+ /**
65
+ * get the menuitem Menu HTML
66
+ * @access public
67
+ * @return string
68
+ */
69
+ public function getMenuhtml(){
70
+ $menuhtml = $this->getData('menuhtml');
71
+ $helper = Mage::helper('cms');
72
+ $processor = $helper->getBlockTemplateProcessor();
73
+ $html = $processor->filter($menuhtml);
74
+ return $html;
75
+ }
76
+ /**
77
+ * save menuitem relation
78
+ * @access public
79
+ * @return JScriptz_MegaMenu2_Model_Menuitem
80
+ */
81
+ protected function _afterSave() {
82
+ return parent::_afterSave();
83
+ }
84
+ /**
85
+ * get the tree model
86
+ * @access public
87
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
88
 
89
+ */
90
+ public function getTreeModel(){
91
+ return Mage::getResourceModel('megamenu2/menuitem_tree');
92
+ }
93
+ /**
94
+ * get tree model instance
95
+ * @access public
96
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
97
+ */
98
+ public function getTreeModelInstance(){
99
+ if (is_null($this->_treeModel)) {
100
+ $this->_treeModel = Mage::getResourceSingleton('megamenu2/menuitem_tree');
101
+ }
102
+ return $this->_treeModel;
103
+ }
104
+ /**
105
+ * Move menu item
106
+ * @access public
107
+ * @param int $parentId new parent menu item id
108
+ * @param int $afterMenuitemId menu item id after which we have put current menu item
109
+ * @return JScriptz_MegaMenu2_Model_Menuitem
110
+ */
111
+ public function move($parentId, $afterMenuitemId){
112
+ $parent = Mage::getModel('megamenu2/menuitem')->load($parentId);
113
+ if (!$parent->getId()) {
114
+ Mage::throwException(
115
+ Mage::helper('megamenu2')->__('Menu Item move operation is not possible: the new parent menu item was not found.')
116
+ );
117
+ }
118
+ if (!$this->getId()) {
119
+ Mage::throwException(
120
+ Mage::helper('megamenu2')->__('Menu Item move operation is not possible: the current menu item was not found.')
121
+ );
122
+ }
123
+ elseif ($parent->getId() == $this->getId()) {
124
+ Mage::throwException(
125
+ Mage::helper('megamenu2')->__('Menu Item move operation is not possible: parent menu item is equal to child menu item.')
126
+ );
127
+ }
128
+ $this->setMovedMenuitemId($this->getId());
129
+ $eventParams = array(
130
+ $this->_eventObject => $this,
131
+ 'parent' => $parent,
132
+ 'menuitem_id' => $this->getId(),
133
+ 'prev_parent_id' => $this->getParentId(),
134
+ 'parent_id' => $parentId
135
+ );
136
+ $moveComplete = false;
137
+ $this->_getResource()->beginTransaction();
138
+ try {
139
+ $this->getResource()->changeParent($this, $parent, $afterMenuitemId);
140
+ $this->_getResource()->commit();
141
+ $this->setAffectedMenuitemIds(array($this->getId(), $this->getParentId(), $parentId));
142
+ $moveComplete = true;
143
+ }
144
+ catch (Exception $e) {
145
+ $this->_getResource()->rollBack();
146
+ throw $e;
147
+ }
148
+ if ($moveComplete) {
149
+ Mage::app()->cleanCache(array(self::CACHE_TAG));
150
+ }
151
+ return $this;
152
+ }
153
+ /**
154
+ * Get the parent menu item
155
+ * @access public
156
+ * @return JScriptz_MegaMenu2_Model_Menuitem
157
+ */
158
+ public function getParentMenuitem(){
159
+ if (!$this->hasData('parent_menuitem')) {
160
+ $this->setData('parent_menuitem', Mage::getModel('megamenu2/menuitem')->load($this->getParentId()));
161
+ }
162
+ return $this->_getData('parent_menuitem');
163
+ }
164
+ /**
165
+ * Get the parent id
166
+ * @access public
167
+ * @return int
168
+ */
169
+ public function getParentId(){
170
+ $parentIds = $this->getParentIds();
171
+ return intval(array_pop($parentIds));
172
+ }
173
+ /**
174
+ * Get all parent menu items ids
175
+ * @access public
176
+ * @return array
177
+ */
178
+ public function getParentIds(){
179
+ return array_diff($this->getPathIds(), array($this->getId()));
180
+ }
181
+ /**
182
+ * Get all menu items children
183
+ * @access public
184
+ * @param bool $asArray
185
+ * @return mixed (array|string)
186
+ */
187
+ public function getAllChildren($asArray = false){
188
+ $children = $this->getResource()->getAllChildren($this);
189
+ if ($asArray) {
190
+ return $children;
191
+ }
192
+ else {
193
+ return implode(',', $children);
194
+ }
195
+ }
196
+ /**
197
+ * Get all menu items children
198
+ * @access public
199
+ * @return string
200
+ */
201
+ public function getChildren(){
202
+ return implode(',', $this->getResource()->getChildren($this, false));
203
+ }
204
+ /**
205
+ * check the id
206
+ * @access public
207
+ * @return bool
208
+ */
209
+ public function checkId($id){
210
+ return $this->_getResource()->checkId($id);
211
+ }
212
+ /**
213
+ * Get array menu items ids which are part of menu item path
214
+ * @access public
215
+ * @return array
216
+ */
217
+ public function getPathIds(){
218
+ $ids = $this->getData('path_ids');
219
+ if (is_null($ids)) {
220
+ $ids = explode('/', $this->getPath());
221
+ $this->setData('path_ids', $ids);
222
+ }
223
+ return $ids;
224
+ }
225
+ /**
226
+ * Retrieve level
227
+ * @access public
228
+ * @return int
229
+ */
230
+ public function getLevel(){
231
+ if (!$this->hasLevel()) {
232
+ return count(explode('/', $this->getPath())) - 1;
233
+ }
234
+ return $this->getData('level');
235
+ }
236
+ /**
237
+ * Verify menu item ids
238
+ * @access public
239
+ * @param array $ids
240
+ * @return bool
241
+ */
242
+ public function verifyIds(array $ids){
243
+ return $this->getResource()->verifyIds($ids);
244
+ }
245
+ /**
246
+ * check if menu item has children
247
+ * @access public
248
+ * @return bool
249
+ */
250
+ public function hasChildren(){
251
+ return $this->_getResource()->getChildrenAmount($this) > 0;
252
+ }
253
+ /**
254
+ * check if menu item can be deleted
255
+ * @access protected
256
+ * @return JScriptz_MegaMenu2_Model_Menuitem
257
+ */
258
+ protected function _beforeDelete(){
259
+ if ($this->getResource()->isForbiddenToDelete($this->getId())) {
260
+ Mage::throwException(Mage::helper('megamenu2')->__("Can't delete root menu item."));
261
+ }
262
+ return parent::_beforeDelete();
263
+ }
264
+ /**
265
+ * get the menu items
266
+ * @access public
267
+ * @param JScriptz_MegaMenu2_Model_Menuitem $parent
268
+ * @param int $recursionLevel
269
+ * @param bool $sorted
270
+ * @param bool $asCollection
271
+ * @param bool $toLoad
272
 
273
+ */
274
+ public function getMenuitems($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true){
275
+ return $this->getResource()->getMenuitems($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
276
+ }
277
+ /**
278
+ * Return parent menu items of current menu item
279
+ * @access public
280
+ * @return array
281
+ */
282
+ public function getParentMenuitems(){
283
+ return $this->getResource()->getParentMenuitems($this);
284
+ }
285
+ /**
286
+ * Retuen children menu items of current menu item
287
+ * @access public
288
+ * @return array
289
+ */
290
+ public function getChildrenMenuitems(){
291
+ return $this->getResource()->getChildrenMenuitems($this);
292
+ }
293
+ /**
294
+ * check if parents are enabled
295
+ * @access public
296
  * @return bool
297
+ */
298
+ public function getStatusPath(){
299
+ $parents = $this->getParentMenuitems();
300
+ foreach ($parents as $parent){
301
+ if (!$parent->getStatus()){
302
+ return false;
303
+ }
304
+ }
305
+ return $this->getStatus();
306
+ }
307
  }
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem.php CHANGED
@@ -1,552 +1,552 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item resource model
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Model_Resource_Menuitem extends Mage_Core_Model_Resource_Db_Abstract{
24
- /**
25
- * Menu Item tree object
26
- * @var Varien_Data_Tree_Db */
27
- protected $_tree;
28
- /**
29
- * constructor
30
- * @access public
31
- * @return void
32
- */
33
- public function _construct(){
34
- $this->_init('megamenu2/menuitem', 'entity_id');
35
- }
36
-
37
- /**
38
- * Get store ids to which specified item is assigned
39
- * @access public
40
- * @param int $menuitemId
41
- * @return array
42
- */
43
- public function lookupStoreIds($menuitemId){
44
- $adapter = $this->_getReadAdapter();
45
- $select = $adapter->select()
46
- ->from($this->getTable('megamenu2/menuitem_store'), 'store_id')
47
- ->where('menuitem_id = ?',(int)$menuitemId);
48
- return $adapter->fetchCol($select);
49
- }
50
- /**
51
- * Perform operations after object load
52
- * @access public
53
- * @param Mage_Core_Model_Abstract $object
54
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
55
- */
56
- protected function _afterLoad(Mage_Core_Model_Abstract $object){
57
- if ($object->getId()) {
58
- $stores = $this->lookupStoreIds($object->getId());
59
- $object->setData('store_id', $stores);
60
- }
61
- return parent::_afterLoad($object);
62
- }
63
-
64
- /**
65
- * Retrieve select object for load object data
66
- *
67
- * @param string $field
68
- * @param mixed $value
69
- * @param JScriptz_MegaMenu2_Model_Menuitem $object
70
- * @return Zend_Db_Select */
71
- protected function _getLoadSelect($field, $value, $object){
72
- $select = parent::_getLoadSelect($field, $value, $object);
73
- if ($object->getStoreId()) {
74
- $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
75
- $select->join(
76
- array('megamenu2_menuitem_store' => $this->getTable('megamenu2/menuitem_store')),
77
- $this->getMainTable() . '.entity_id = megamenu2_menuitem_store.menuitem_id',
78
- array()
79
- )
80
- ->where('megamenu2_menuitem_store.store_id IN (?)', $storeIds)
81
- ->order('megamenu2_menuitem_store.store_id DESC')
82
- ->limit(1);
83
- }
84
- return $select;
85
- }
86
- /**
87
- * Retrieve menu item tree object
88
- * @access protected
89
- * @return Varien_Data_Tree_Db
90
- */
91
- protected function _getTree(){
92
- if (!$this->_tree) {
93
- $this->_tree = Mage::getResourceModel('megamenu2/menuitem_tree')->load();
94
- }
95
- return $this->_tree;
96
- }
97
- /**
98
- * Process menu item data before delete
99
- * update children count for parent menu item
100
- * delete child menu items
101
- * @access protected
102
- * @param Varien_Object $object
103
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
104
- */
105
- protected function _beforeDelete(Mage_Core_Model_Abstract $object){
106
- parent::_beforeDelete($object);
107
- /**
108
- * Update children count for all parent menu items
109
- */
110
- $parentIds = $object->getParentIds();
111
- if ($parentIds) {
112
- $childDecrease = $object->getChildrenCount() + 1; // +1 is itself
113
- $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease));
114
- $where = array('entity_id IN(?)' => $parentIds);
115
- $this->_getWriteAdapter()->update( $this->getMainTable(), $data, $where);
116
- }
117
- $this->deleteChildren($object);
118
- return $this;
119
- }
120
- /**
121
- * Delete children menu items of specific menu item
122
- * @access public
123
- * @param Varien_Object $object
124
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
125
- */
126
- public function deleteChildren(Varien_Object $object){
127
- $adapter = $this->_getWriteAdapter();
128
- $pathField = $adapter->quoteIdentifier('path');
129
- $select = $adapter->select()
130
- ->from($this->getMainTable(), array('entity_id'))
131
- ->where($pathField . ' LIKE :c_path');
132
- $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%'));
133
- if (!empty($childrenIds)) {
134
- $adapter->delete(
135
- $this->getMainTable(),
136
- array('entity_id IN (?)' => $childrenIds)
137
- );
138
- }
139
- /**
140
- * Add deleted children ids to object
141
- * This data can be used in after delete event
142
- */
143
- $object->setDeletedChildrenIds($childrenIds);
144
- return $this;
145
- }
146
- /**
147
- * Process menu item data after save menu item object
148
- * @access protected
149
- * @param Varien_Object $object
150
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
151
- */
152
- protected function _afterSave(Mage_Core_Model_Abstract $object){
153
- if (substr($object->getPath(), -1) == '/') {
154
- $object->setPath($object->getPath() . $object->getId());
155
- $this->_savePath($object);
156
- }
157
- $oldStores = $this->lookupStoreIds($object->getId());
158
- $newStores = (array)$object->getStores();
159
- if (empty($newStores)) {
160
- $newStores = (array)$object->getStoreId();
161
- }
162
- $table = $this->getTable('megamenu2/menuitem_store');
163
- $insert = array_diff($newStores, $oldStores);
164
- $delete = array_diff($oldStores, $newStores);
165
- if ($delete) {
166
- $where = array(
167
- 'menuitem_id = ?' => (int) $object->getId(),
168
- 'store_id IN (?)' => $delete
169
- );
170
- $this->_getWriteAdapter()->delete($table, $where);
171
- }
172
- if ($insert) {
173
- $data = array();
174
- foreach ($insert as $storeId) {
175
- $data[] = array(
176
- 'menuitem_id' => (int) $object->getId(),
177
- 'store_id' => (int) $storeId
178
- );
179
- }
180
- $this->_getWriteAdapter()->insertMultiple($table, $data);
181
- }
182
- return parent::_afterSave($object);
183
- }
184
-
185
- /**
186
- * Update path field
187
- * @access protected
188
- * @param JScriptz_MegaMenu2_Model_Menuitem $object
189
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
190
- */
191
- protected function _savePath($object){
192
- if ($object->getId()) {
193
- $this->_getWriteAdapter()->update(
194
- $this->getMainTable(),
195
- array('path' => $object->getPath()),
196
- array('entity_id = ?' => $object->getId())
197
- );
198
- }
199
- return $this;
200
- }
201
-
202
- /**
203
- * Get maximum position of child menu items by specific tree path
204
- * @access protected
205
- * @param string $path
206
- * @return int
207
- */
208
- protected function _getMaxPosition($path){
209
- $adapter = $this->getReadConnection();
210
- $positionField = $adapter->quoteIdentifier('position');
211
- $level = count(explode('/', $path));
212
- $bind = array(
213
- 'c_level' => $level,
214
- 'c_path' => $path . '/%'
215
- );
216
- $select = $adapter->select()
217
- ->from($this->getMainTable(), 'MAX(' . $positionField . ')')
218
- ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path')
219
- ->where($adapter->quoteIdentifier('level') . ' = :c_level');
220
-
221
- $position = $adapter->fetchOne($select, $bind);
222
- if (!$position) {
223
- $position = 0;
224
- }
225
- return $position;
226
- }
227
- /**
228
- * Get children menu items count
229
- * @access public
230
- * @param int $menuitemId
231
- * @return int
232
- */
233
- public function getChildrenCount($menuitemId){
234
- $select = $this->_getReadAdapter()->select()
235
- ->from($this->getMainTable(), 'children_count')
236
- ->where('entity_id = :entity_id');
237
- $bind = array('entity_id' => $menuitemId);
238
- return $this->_getReadAdapter()->fetchOne($select, $bind);
239
- }
240
- /**
241
- * Check if menu item id exist
242
- * @access public
243
- * @param int $entityId
244
- * @return bool
245
- */
246
- public function checkId($entityId){
247
- $select = $this->_getReadAdapter()->select()
248
- ->from($this->getMainTable(), 'entity_id')
249
- ->where('entity_id = :entity_id');
250
- $bind = array('entity_id' => $entityId);
251
- return $this->_getReadAdapter()->fetchOne($select, $bind);
252
- }
253
-
254
- /**
255
- * Check array of menu items identifiers
256
- * @access public
257
- * @param array $ids
258
- * @return array
259
- */
260
- public function verifyIds(array $ids){
261
- if (empty($ids)) {
262
- return array();
263
- }
264
- $select = $this->_getReadAdapter()->select()
265
- ->from($this->getMainTable(), 'entity_id')
266
- ->where('entity_id IN(?)', $ids);
267
-
268
- return $this->_getReadAdapter()->fetchCol($select);
269
- }
270
- /**
271
- * Process menu item data before saving
272
- * prepare path and increment children count for parent menu items
273
- * @access protected
274
- * @param Varien_Object $object
275
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
276
- */
277
- protected function _beforeSave(Mage_Core_Model_Abstract $object){
278
- parent::_beforeSave($object);
279
- if (!$object->getChildrenCount()) {
280
- $object->setChildrenCount(0);
281
- }
282
- if ($object->getLevel() === null) {
283
- $object->setLevel(1);
284
- }
285
- if (!$object->getId() && !$object->getInitialSetupFlag()) {
286
- $object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
287
- $path = explode('/', $object->getPath());
288
- $level = count($path);
289
- $object->setLevel($level);
290
- if ($level) {
291
- $object->setParentId($path[$level - 1]);
292
- }
293
- $object->setPath($object->getPath() . '/');
294
- $toUpdateChild = explode('/',$object->getPath());
295
- $this->_getWriteAdapter()->update(
296
- $this->getMainTable(),
297
- array('children_count' => new Zend_Db_Expr('children_count+1')),
298
- array('entity_id IN(?)' => $toUpdateChild)
299
- );
300
- }
301
- return $this;
302
- }
303
- /**
304
- * Get count of active/not active children menu items
305
- *
306
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
307
- * @param bool $isActiveFlag
308
- * @return int
309
- */
310
- public function getChildrenAmount($menuitem, $isActiveFlag = true){
311
- $bind = array(
312
- 'active_flag' => $isActiveFlag,
313
- 'c_path' => $menuitem->getPath() . '/%'
314
- );
315
- $select = $adapter->select()
316
- ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)'))
317
- ->where('m.path LIKE :c_path')
318
- ->where('status' . ' = :active_flag');
319
- return $this->_getReadAdapter()->fetchOne($select, $bind);
320
- }
321
- /**
322
- * Return parent menu items of menu item
323
- * @access public
324
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
325
- * @return array
326
- */
327
- public function getParentMenuitems($menuitem){
328
- $pathIds = array_reverse(explode('/', $menuitem->getPath()));
329
- $menuitems = Mage::getResourceModel('megamenu2/menuitem_collection')
330
- ->addFieldToFilter('entity_id', array('in' => $pathIds))
331
- ->addFieldToFilter('status', 1)
332
- ->load()
333
- ->getItems();
334
- return $menuitems;
335
- }
336
- /**
337
- * Return child menu items
338
- * @access public
339
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
340
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
341
- */
342
- public function getChildrenMenuitems($menuitem){
343
- $collection = $menuitem->getCollection();
344
- $collection
345
- ->addFilter('status', 1)
346
- ->addIdFilter($menuitem->getChildren())
347
- ->setOrder('position', Varien_Db_Select::SQL_ASC)
348
- ->load();
349
- return $collection;
350
- }
351
- /**
352
- * Return children ids of menu item
353
- * @access public
354
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
355
- * @param boolean $recursive
356
- * @return array
357
- */
358
- public function getChildren($menuitem, $recursive = true){
359
- $bind = array(
360
- 'c_path' => $menuitem->getPath() . '/%'
361
- );
362
- $select = $this->_getReadAdapter()->select()
363
- ->from(array('m' => $this->getMainTable()), 'entity_id')
364
- ->where('status = ?', 1)
365
- ->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path');
366
- if (!$recursive) {
367
- $select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level');
368
- $bind['c_level'] = $menuitem->getLevel() + 1;
369
- }
370
- return $this->_getReadAdapter()->fetchCol($select, $bind);
371
- }
372
- /**
373
- * Retrieve menu items
374
- * @access public
375
- * @param integer $parent
376
- * @param integer $recursionLevel
377
- * @param boolean|string $sorted
378
- * @param boolean $asCollection
379
- * @param boolean $toLoad
380
- * @return Varien_Data_Tree_Node_Collection|JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
381
- */
382
- public function getMenuitems($parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true){
383
- $tree = Mage::getResourceModel('megamenu2/menuitem_tree');
384
- $nodes = $tree->loadNode($parent)
385
- ->loadChildren($recursionLevel)
386
- ->getChildren();
387
- $tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
388
- if ($asCollection) {
389
- return $tree->getCollection();
390
- }
391
- return $nodes;
392
- }
393
- /**
394
- * Return all children ids of menuitem (with menuitem id)
395
- * @access public
396
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
397
- * @return array
398
- */
399
- public function getAllChildren($menuitem){
400
- $children = $this->getChildren($menuitem);
401
- $myId = array($menuitem->getId());
402
- $children = array_merge($myId, $children);
403
- return $children;
404
- }
405
- /**
406
- * Check menu item is forbidden to delete.
407
- * @access public
408
- * @param integer $menuitemId
409
- * @return boolean
410
- */
411
- public function isForbiddenToDelete($menuitemId){
412
- return ($menuitemId == Mage::helper('megamenu2/menuitem')->getRootMenuitemId());
413
- }
414
- /**
415
- * Get menu item path value by its id
416
- * @access public
417
- * @param int $menuitemId
418
- * @return string
419
- */
420
- public function getMenuitemPathById($menuitemId){
421
- $select = $this->getReadConnection()->select()
422
- ->from($this->getMainTable(), array('path'))
423
- ->where('entity_id = :entity_id');
424
- $bind = array('entity_id' => (int)$menuitemId);
425
- return $this->getReadConnection()->fetchOne($select, $bind);
426
- }
427
- /**
428
- * Move menu item to another parent node
429
- * @access public
430
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
431
- * @param JScriptz_MegaMenu2_Model_Menuitem $newParent
432
- * @param null|int $afterMenuitemId
433
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
434
- */
435
- public function changeParent(JScriptz_MegaMenu2_Model_Menuitem $menuitem, JScriptz_MegaMenu2_Model_Menuitem $newParent, $afterMenuitemId = null){
436
- $childrenCount = $this->getChildrenCount($menuitem->getId()) + 1;
437
- $table = $this->getMainTable();
438
- $adapter = $this->_getWriteAdapter();
439
- $levelFiled = $adapter->quoteIdentifier('level');
440
- $pathField = $adapter->quoteIdentifier('path');
441
-
442
- /**
443
- * Decrease children count for all old menu item parent menu items
444
- */
445
- $adapter->update(
446
- $table,
447
- array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)),
448
- array('entity_id IN(?)' => $menuitem->getParentIds())
449
- );
450
- /**
451
- * Increase children count for new menu item parents
452
- */
453
- $adapter->update(
454
- $table,
455
- array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)),
456
- array('entity_id IN(?)' => $newParent->getPathIds())
457
- );
458
-
459
- $position = $this->_processPositions($menuitem, $newParent, $afterMenuitemId);
460
-
461
- $newPath = sprintf('%s/%s', $newParent->getPath(), $menuitem->getId());
462
- $newLevel = $newParent->getLevel() + 1;
463
- $levelDisposition = $newLevel - $menuitem->getLevel();
464
-
465
- /**
466
- * Update children nodes path
467
- */
468
- $adapter->update(
469
- $table,
470
- array(
471
- 'path' => new Zend_Db_Expr('REPLACE(' . $pathField . ','.
472
- $adapter->quote($menuitem->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')'
473
- ),
474
- 'level' => new Zend_Db_Expr( $levelFiled . ' + ' . $levelDisposition)
475
- ),
476
- array($pathField . ' LIKE ?' => $menuitem->getPath() . '/%')
477
- );
478
- /**
479
- * Update moved menu item data
480
- */
481
- $data = array(
482
- 'path' => $newPath,
483
- 'level' => $newLevel,
484
- 'position' =>$position,
485
- 'parent_id' =>$newParent->getId()
486
- );
487
- $adapter->update($table, $data, array('entity_id = ?' => $menuitem->getId()));
488
- // Update menu item object to new data
489
- $menuitem->addData($data);
490
- return $this;
491
- }
492
- /**
493
- * Process positions of old parent menu item children and new parent menu item children.
494
- * Get position for moved menu item
495
- * @access protected
496
- * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
497
- * @param JScriptz_MegaMenu2_Model_Menuitem $newParent
498
- * @param null|int $afterMenuitemId
499
- * @return int
500
- */
501
- protected function _processPositions($menuitem, $newParent, $afterMenuitemId){
502
- $table = $this->getMainTable();
503
- $adapter= $this->_getWriteAdapter();
504
- $positionField = $adapter->quoteIdentifier('position');
505
-
506
- $bind = array(
507
- 'position' => new Zend_Db_Expr($positionField . ' - 1')
508
- );
509
- $where = array(
510
- 'parent_id = ?' => $menuitem->getParentId(),
511
- $positionField . ' > ?' => $menuitem->getPosition()
512
- );
513
- $adapter->update($table, $bind, $where);
514
-
515
- /**
516
- * Prepare position value
517
- */
518
- if ($afterMenuitemId) {
519
- $select = $adapter->select()
520
- ->from($table,'position')
521
- ->where('entity_id = :entity_id');
522
- $position = $adapter->fetchOne($select, array('entity_id' => $afterMenuitemId));
523
- $bind = array(
524
- 'position' => new Zend_Db_Expr($positionField . ' + 1')
525
- );
526
- $where = array(
527
- 'parent_id = ?' => $newParent->getId(),
528
- $positionField . ' > ?' => $position
529
- );
530
- $adapter->update($table, $bind, $where);
531
- }
532
- elseif ($afterMenuitemId !== null) {
533
- $position = 0;
534
- $bind = array(
535
- 'position' => new Zend_Db_Expr($positionField . ' + 1')
536
- );
537
- $where = array(
538
- 'parent_id = ?' => $newParent->getId(),
539
- $positionField . ' > ?' => $position
540
- );
541
- $adapter->update($table, $bind, $where);
542
- }
543
- else {
544
- $select = $adapter->select()
545
- ->from($table,array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')')))
546
- ->where('parent_id = :parent_id');
547
- $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId()));
548
- }
549
- $position += 1;
550
- return $position;
551
- }
552
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item resource model
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Model_Resource_Menuitem extends Mage_Core_Model_Resource_Db_Abstract{
24
+ /**
25
+ * Menu Item tree object
26
+ * @var Varien_Data_Tree_Db */
27
+ protected $_tree;
28
+ /**
29
+ * constructor
30
+ * @access public
31
+ * @return void
32
+ */
33
+ public function _construct(){
34
+ $this->_init('megamenu2/menuitem', 'entity_id');
35
+ }
36
+
37
+ /**
38
+ * Get store ids to which specified item is assigned
39
+ * @access public
40
+ * @param int $menuitemId
41
+ * @return array
42
+ */
43
+ public function lookupStoreIds($menuitemId){
44
+ $adapter = $this->_getReadAdapter();
45
+ $select = $adapter->select()
46
+ ->from($this->getTable('megamenu2/menuitem_store'), 'store_id')
47
+ ->where('menuitem_id = ?',(int)$menuitemId);
48
+ return $adapter->fetchCol($select);
49
+ }
50
+ /**
51
+ * Perform operations after object load
52
+ * @access public
53
+ * @param Mage_Core_Model_Abstract $object
54
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
55
+ */
56
+ protected function _afterLoad(Mage_Core_Model_Abstract $object){
57
+ if ($object->getId()) {
58
+ $stores = $this->lookupStoreIds($object->getId());
59
+ $object->setData('store_id', $stores);
60
+ }
61
+ return parent::_afterLoad($object);
62
+ }
63
+
64
+ /**
65
+ * Retrieve select object for load object data
66
+ *
67
+ * @param string $field
68
+ * @param mixed $value
69
+ * @param JScriptz_MegaMenu2_Model_Menuitem $object
70
+ * @return Zend_Db_Select */
71
+ protected function _getLoadSelect($field, $value, $object){
72
+ $select = parent::_getLoadSelect($field, $value, $object);
73
+ if ($object->getStoreId()) {
74
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
75
+ $select->join(
76
+ array('megamenu2_menuitem_store' => $this->getTable('megamenu2/menuitem_store')),
77
+ $this->getMainTable() . '.entity_id = megamenu2_menuitem_store.menuitem_id',
78
+ array()
79
+ )
80
+ ->where('megamenu2_menuitem_store.store_id IN (?)', $storeIds)
81
+ ->order('megamenu2_menuitem_store.store_id DESC')
82
+ ->limit(1);
83
+ }
84
+ return $select;
85
+ }
86
+ /**
87
+ * Retrieve menu item tree object
88
+ * @access protected
89
+ * @return Varien_Data_Tree_Db
90
+ */
91
+ protected function _getTree(){
92
+ if (!$this->_tree) {
93
+ $this->_tree = Mage::getResourceModel('megamenu2/menuitem_tree')->load();
94
+ }
95
+ return $this->_tree;
96
+ }
97
+ /**
98
+ * Process menu item data before delete
99
+ * update children count for parent menu item
100
+ * delete child menu items
101
+ * @access protected
102
+ * @param Varien_Object $object
103
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
104
+ */
105
+ protected function _beforeDelete(Mage_Core_Model_Abstract $object){
106
+ parent::_beforeDelete($object);
107
+ /**
108
+ * Update children count for all parent menu items
109
+ */
110
+ $parentIds = $object->getParentIds();
111
+ if ($parentIds) {
112
+ $childDecrease = $object->getChildrenCount() + 1; // +1 is itself
113
+ $data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease));
114
+ $where = array('entity_id IN(?)' => $parentIds);
115
+ $this->_getWriteAdapter()->update( $this->getMainTable(), $data, $where);
116
+ }
117
+ $this->deleteChildren($object);
118
+ return $this;
119
+ }
120
+ /**
121
+ * Delete children menu items of specific menu item
122
+ * @access public
123
+ * @param Varien_Object $object
124
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
125
+ */
126
+ public function deleteChildren(Varien_Object $object){
127
+ $adapter = $this->_getWriteAdapter();
128
+ $pathField = $adapter->quoteIdentifier('path');
129
+ $select = $adapter->select()
130
+ ->from($this->getMainTable(), array('entity_id'))
131
+ ->where($pathField . ' LIKE :c_path');
132
+ $childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%'));
133
+ if (!empty($childrenIds)) {
134
+ $adapter->delete(
135
+ $this->getMainTable(),
136
+ array('entity_id IN (?)' => $childrenIds)
137
+ );
138
+ }
139
+ /**
140
+ * Add deleted children ids to object
141
+ * This data can be used in after delete event
142
+ */
143
+ $object->setDeletedChildrenIds($childrenIds);
144
+ return $this;
145
+ }
146
+ /**
147
+ * Process menu item data after save menu item object
148
+ * @access protected
149
+ * @param Varien_Object $object
150
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
151
+ */
152
+ protected function _afterSave(Mage_Core_Model_Abstract $object){
153
+ if (substr($object->getPath(), -1) == '/') {
154
+ $object->setPath($object->getPath() . $object->getId());
155
+ $this->_savePath($object);
156
+ }
157
+ $oldStores = $this->lookupStoreIds($object->getId());
158
+ $newStores = (array)$object->getStores();
159
+ if (empty($newStores)) {
160
+ $newStores = (array)$object->getStoreId();
161
+ }
162
+ $table = $this->getTable('megamenu2/menuitem_store');
163
+ $insert = array_diff($newStores, $oldStores);
164
+ $delete = array_diff($oldStores, $newStores);
165
+ if ($delete) {
166
+ $where = array(
167
+ 'menuitem_id = ?' => (int) $object->getId(),
168
+ 'store_id IN (?)' => $delete
169
+ );
170
+ $this->_getWriteAdapter()->delete($table, $where);
171
+ }
172
+ if ($insert) {
173
+ $data = array();
174
+ foreach ($insert as $storeId) {
175
+ $data[] = array(
176
+ 'menuitem_id' => (int) $object->getId(),
177
+ 'store_id' => (int) $storeId
178
+ );
179
+ }
180
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
181
+ }
182
+ return parent::_afterSave($object);
183
+ }
184
+
185
+ /**
186
+ * Update path field
187
+ * @access protected
188
+ * @param JScriptz_MegaMenu2_Model_Menuitem $object
189
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
190
+ */
191
+ protected function _savePath($object){
192
+ if ($object->getId()) {
193
+ $this->_getWriteAdapter()->update(
194
+ $this->getMainTable(),
195
+ array('path' => $object->getPath()),
196
+ array('entity_id = ?' => $object->getId())
197
+ );
198
+ }
199
+ return $this;
200
+ }
201
+
202
+ /**
203
+ * Get maximum position of child menu items by specific tree path
204
+ * @access protected
205
+ * @param string $path
206
+ * @return int
207
+ */
208
+ protected function _getMaxPosition($path){
209
+ $adapter = $this->getReadConnection();
210
+ $positionField = $adapter->quoteIdentifier('position');
211
+ $level = count(explode('/', $path));
212
+ $bind = array(
213
+ 'c_level' => $level,
214
+ 'c_path' => $path . '/%'
215
+ );
216
+ $select = $adapter->select()
217
+ ->from($this->getMainTable(), 'MAX(' . $positionField . ')')
218
+ ->where($adapter->quoteIdentifier('path') . ' LIKE :c_path')
219
+ ->where($adapter->quoteIdentifier('level') . ' = :c_level');
220
+
221
+ $position = $adapter->fetchOne($select, $bind);
222
+ if (!$position) {
223
+ $position = 0;
224
+ }
225
+ return $position;
226
+ }
227
+ /**
228
+ * Get children menu items count
229
+ * @access public
230
+ * @param int $menuitemId
231
+ * @return int
232
+ */
233
+ public function getChildrenCount($menuitemId){
234
+ $select = $this->_getReadAdapter()->select()
235
+ ->from($this->getMainTable(), 'children_count')
236
+ ->where('entity_id = :entity_id');
237
+ $bind = array('entity_id' => $menuitemId);
238
+ return $this->_getReadAdapter()->fetchOne($select, $bind);
239
+ }
240
+ /**
241
+ * Check if menu item id exist
242
+ * @access public
243
+ * @param int $entityId
244
+ * @return bool
245
+ */
246
+ public function checkId($entityId){
247
+ $select = $this->_getReadAdapter()->select()
248
+ ->from($this->getMainTable(), 'entity_id')
249
+ ->where('entity_id = :entity_id');
250
+ $bind = array('entity_id' => $entityId);
251
+ return $this->_getReadAdapter()->fetchOne($select, $bind);
252
+ }
253
+
254
+ /**
255
+ * Check array of menu items identifiers
256
+ * @access public
257
+ * @param array $ids
258
+ * @return array
259
+ */
260
+ public function verifyIds(array $ids){
261
+ if (empty($ids)) {
262
+ return array();
263
+ }
264
+ $select = $this->_getReadAdapter()->select()
265
+ ->from($this->getMainTable(), 'entity_id')
266
+ ->where('entity_id IN(?)', $ids);
267
+
268
+ return $this->_getReadAdapter()->fetchCol($select);
269
+ }
270
+ /**
271
+ * Process menu item data before saving
272
+ * prepare path and increment children count for parent menu items
273
+ * @access protected
274
+ * @param Varien_Object $object
275
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
276
+ */
277
+ protected function _beforeSave(Mage_Core_Model_Abstract $object){
278
+ parent::_beforeSave($object);
279
+ if (!$object->getChildrenCount()) {
280
+ $object->setChildrenCount(0);
281
+ }
282
+ if ($object->getLevel() === null) {
283
+ $object->setLevel(1);
284
+ }
285
+ if (!$object->getId() && !$object->getInitialSetupFlag()) {
286
+ $object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
287
+ $path = explode('/', $object->getPath());
288
+ $level = count($path);
289
+ $object->setLevel($level);
290
+ if ($level) {
291
+ $object->setParentId($path[$level - 1]);
292
+ }
293
+ $object->setPath($object->getPath() . '/');
294
+ $toUpdateChild = explode('/',$object->getPath());
295
+ $this->_getWriteAdapter()->update(
296
+ $this->getMainTable(),
297
+ array('children_count' => new Zend_Db_Expr('children_count+1')),
298
+ array('entity_id IN(?)' => $toUpdateChild)
299
+ );
300
+ }
301
+ return $this;
302
+ }
303
+ /**
304
+ * Get count of active/not active children menu items
305
+ *
306
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
307
+ * @param bool $isActiveFlag
308
+ * @return int
309
+ */
310
+ public function getChildrenAmount($menuitem, $isActiveFlag = true){
311
+ $bind = array(
312
+ 'active_flag' => $isActiveFlag,
313
+ 'c_path' => $menuitem->getPath() . '/%'
314
+ );
315
+ $select = $adapter->select()
316
+ ->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)'))
317
+ ->where('m.path LIKE :c_path')
318
+ ->where('status' . ' = :active_flag');
319
+ return $this->_getReadAdapter()->fetchOne($select, $bind);
320
+ }
321
+ /**
322
+ * Return parent menu items of menu item
323
+ * @access public
324
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
325
+ * @return array
326
+ */
327
+ public function getParentMenuitems($menuitem){
328
+ $pathIds = array_reverse(explode('/', $menuitem->getPath()));
329
+ $menuitems = Mage::getResourceModel('megamenu2/menuitem_collection')
330
+ ->addFieldToFilter('entity_id', array('in' => $pathIds))
331
+ ->addFieldToFilter('status', 1)
332
+ ->load()
333
+ ->getItems();
334
+ return $menuitems;
335
+ }
336
+ /**
337
+ * Return child menu items
338
+ * @access public
339
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
340
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
341
+ */
342
+ public function getChildrenMenuitems($menuitem){
343
+ $collection = $menuitem->getCollection();
344
+ $collection
345
+ ->addFilter('status', 1)
346
+ ->addIdFilter($menuitem->getChildren())
347
+ ->setOrder('position', Varien_Db_Select::SQL_ASC)
348
+ ->load();
349
+ return $collection;
350
+ }
351
+ /**
352
+ * Return children ids of menu item
353
+ * @access public
354
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
355
+ * @param boolean $recursive
356
+ * @return array
357
+ */
358
+ public function getChildren($menuitem, $recursive = true){
359
+ $bind = array(
360
+ 'c_path' => $menuitem->getPath() . '/%'
361
+ );
362
+ $select = $this->_getReadAdapter()->select()
363
+ ->from(array('m' => $this->getMainTable()), 'entity_id')
364
+ ->where('status = ?', 1)
365
+ ->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path');
366
+ if (!$recursive) {
367
+ $select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level');
368
+ $bind['c_level'] = $menuitem->getLevel() + 1;
369
+ }
370
+ return $this->_getReadAdapter()->fetchCol($select, $bind);
371
+ }
372
+ /**
373
+ * Retrieve menu items
374
+ * @access public
375
+ * @param integer $parent
376
+ * @param integer $recursionLevel
377
+ * @param boolean|string $sorted
378
+ * @param boolean $asCollection
379
+ * @param boolean $toLoad
380
+ * @return Varien_Data_Tree_Node_Collection|JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
381
+ */
382
+ public function getMenuitems($parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true){
383
+ $tree = Mage::getResourceModel('megamenu2/menuitem_tree');
384
+ $nodes = $tree->loadNode($parent)
385
+ ->loadChildren($recursionLevel)
386
+ ->getChildren();
387
+ $tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
388
+ if ($asCollection) {
389
+ return $tree->getCollection();
390
+ }
391
+ return $nodes;
392
+ }
393
+ /**
394
+ * Return all children ids of menuitem (with menuitem id)
395
+ * @access public
396
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
397
+ * @return array
398
+ */
399
+ public function getAllChildren($menuitem){
400
+ $children = $this->getChildren($menuitem);
401
+ $myId = array($menuitem->getId());
402
+ $children = array_merge($myId, $children);
403
+ return $children;
404
+ }
405
+ /**
406
+ * Check menu item is forbidden to delete.
407
+ * @access public
408
+ * @param integer $menuitemId
409
+ * @return boolean
410
+ */
411
+ public function isForbiddenToDelete($menuitemId){
412
+ return ($menuitemId == Mage::helper('megamenu2/menuitem')->getRootMenuitemId());
413
+ }
414
+ /**
415
+ * Get menu item path value by its id
416
+ * @access public
417
+ * @param int $menuitemId
418
+ * @return string
419
+ */
420
+ public function getMenuitemPathById($menuitemId){
421
+ $select = $this->getReadConnection()->select()
422
+ ->from($this->getMainTable(), array('path'))
423
+ ->where('entity_id = :entity_id');
424
+ $bind = array('entity_id' => (int)$menuitemId);
425
+ return $this->getReadConnection()->fetchOne($select, $bind);
426
+ }
427
+ /**
428
+ * Move menu item to another parent node
429
+ * @access public
430
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
431
+ * @param JScriptz_MegaMenu2_Model_Menuitem $newParent
432
+ * @param null|int $afterMenuitemId
433
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem
434
+ */
435
+ public function changeParent(JScriptz_MegaMenu2_Model_Menuitem $menuitem, JScriptz_MegaMenu2_Model_Menuitem $newParent, $afterMenuitemId = null){
436
+ $childrenCount = $this->getChildrenCount($menuitem->getId()) + 1;
437
+ $table = $this->getMainTable();
438
+ $adapter = $this->_getWriteAdapter();
439
+ $levelFiled = $adapter->quoteIdentifier('level');
440
+ $pathField = $adapter->quoteIdentifier('path');
441
+
442
+ /**
443
+ * Decrease children count for all old menu item parent menu items
444
+ */
445
+ $adapter->update(
446
+ $table,
447
+ array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)),
448
+ array('entity_id IN(?)' => $menuitem->getParentIds())
449
+ );
450
+ /**
451
+ * Increase children count for new menu item parents
452
+ */
453
+ $adapter->update(
454
+ $table,
455
+ array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)),
456
+ array('entity_id IN(?)' => $newParent->getPathIds())
457
+ );
458
+
459
+ $position = $this->_processPositions($menuitem, $newParent, $afterMenuitemId);
460
+
461
+ $newPath = sprintf('%s/%s', $newParent->getPath(), $menuitem->getId());
462
+ $newLevel = $newParent->getLevel() + 1;
463
+ $levelDisposition = $newLevel - $menuitem->getLevel();
464
+
465
+ /**
466
+ * Update children nodes path
467
+ */
468
+ $adapter->update(
469
+ $table,
470
+ array(
471
+ 'path' => new Zend_Db_Expr('REPLACE(' . $pathField . ','.
472
+ $adapter->quote($menuitem->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')'
473
+ ),
474
+ 'level' => new Zend_Db_Expr( $levelFiled . ' + ' . $levelDisposition)
475
+ ),
476
+ array($pathField . ' LIKE ?' => $menuitem->getPath() . '/%')
477
+ );
478
+ /**
479
+ * Update moved menu item data
480
+ */
481
+ $data = array(
482
+ 'path' => $newPath,
483
+ 'level' => $newLevel,
484
+ 'position' =>$position,
485
+ 'parent_id' =>$newParent->getId()
486
+ );
487
+ $adapter->update($table, $data, array('entity_id = ?' => $menuitem->getId()));
488
+ // Update menu item object to new data
489
+ $menuitem->addData($data);
490
+ return $this;
491
+ }
492
+ /**
493
+ * Process positions of old parent menu item children and new parent menu item children.
494
+ * Get position for moved menu item
495
+ * @access protected
496
+ * @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
497
+ * @param JScriptz_MegaMenu2_Model_Menuitem $newParent
498
+ * @param null|int $afterMenuitemId
499
+ * @return int
500
+ */
501
+ protected function _processPositions($menuitem, $newParent, $afterMenuitemId){
502
+ $table = $this->getMainTable();
503
+ $adapter= $this->_getWriteAdapter();
504
+ $positionField = $adapter->quoteIdentifier('position');
505
+
506
+ $bind = array(
507
+ 'position' => new Zend_Db_Expr($positionField . ' - 1')
508
+ );
509
+ $where = array(
510
+ 'parent_id = ?' => $menuitem->getParentId(),
511
+ $positionField . ' > ?' => $menuitem->getPosition()
512
+ );
513
+ $adapter->update($table, $bind, $where);
514
+
515
+ /**
516
+ * Prepare position value
517
+ */
518
+ if ($afterMenuitemId) {
519
+ $select = $adapter->select()
520
+ ->from($table,'position')
521
+ ->where('entity_id = :entity_id');
522
+ $position = $adapter->fetchOne($select, array('entity_id' => $afterMenuitemId));
523
+ $bind = array(
524
+ 'position' => new Zend_Db_Expr($positionField . ' + 1')
525
+ );
526
+ $where = array(
527
+ 'parent_id = ?' => $newParent->getId(),
528
+ $positionField . ' > ?' => $position
529
+ );
530
+ $adapter->update($table, $bind, $where);
531
+ }
532
+ elseif ($afterMenuitemId !== null) {
533
+ $position = 0;
534
+ $bind = array(
535
+ 'position' => new Zend_Db_Expr($positionField . ' + 1')
536
+ );
537
+ $where = array(
538
+ 'parent_id = ?' => $newParent->getId(),
539
+ $positionField . ' > ?' => $position
540
+ );
541
+ $adapter->update($table, $bind, $where);
542
+ }
543
+ else {
544
+ $select = $adapter->select()
545
+ ->from($table,array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')')))
546
+ ->where('parent_id = :parent_id');
547
+ $position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId()));
548
+ }
549
+ $position += 1;
550
+ return $position;
551
+ }
552
  }
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Collection.php CHANGED
@@ -1,206 +1,206 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item collection resource model
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
24
- protected $_joinedFields = array();
25
- /**
26
- * constructor
27
- * @access public
28
- * @return void
29
- */
30
- public function _construct(){
31
- parent::_construct();
32
- $this->_init('megamenu2/menuitem');
33
- $this->_map['fields']['store'] = 'store_table.store_id';
34
- }
35
- /**
36
- * get menuitems as array
37
- * @access protected
38
- * @param string $valueField
39
- * @param string $labelField
40
- * @param array $additional
41
- * @return array
42
- */
43
- protected function _toOptionArray($valueField='entity_id', $labelField='linktitle', $additional=array()){
44
- return parent::_toOptionArray($valueField, $labelField, $additional);
45
- }
46
- /**
47
- * get options hash
48
- * @access protected
49
- * @param string $valueField
50
- * @param string $labelField
51
- * @return array
52
- */
53
- protected function _toOptionHash($valueField='entity_id', $labelField='linktitle'){
54
- return parent::_toOptionHash($valueField, $labelField);
55
- }
56
- /**
57
- * Add filter by store
58
- * @access public
59
- * @param int|Mage_Core_Model_Store $store
60
- * @param bool $withAdmin
61
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
62
- */
63
- public function addStoreFilter($store, $withAdmin = true){
64
- if (!isset($this->_joinedFields['store'])){
65
- if ($store instanceof Mage_Core_Model_Store) {
66
- $store = array($store->getId());
67
- }
68
- if (!is_array($store)) {
69
- $store = array($store);
70
- }
71
- if ($withAdmin) {
72
- $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
73
- }
74
- $this->addFilter('store', array('in' => $store), 'public');
75
- $this->_joinedFields['store'] = true;
76
- }
77
- return $this;
78
- }
79
- /**
80
- * Join store relation table if there is store filter
81
- * @access protected
82
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
83
- */
84
- protected function _renderFiltersBefore(){
85
- if ($this->getFilter('store')) {
86
- $this->getSelect()->join(
87
- array('store_table' => $this->getTable('megamenu2/menuitem_store')),
88
- 'main_table.entity_id = store_table.menuitem_id',
89
- array()
90
- )->group('main_table.entity_id');
91
- /*
92
- * Allow analytic functions usage because of one field grouping
93
- */
94
- $this->_useAnalyticFunction = true;
95
- }
96
- return parent::_renderFiltersBefore();
97
- }
98
- /**
99
- * Get SQL for get record count.
100
- * Extra GROUP BY strip added.
101
- * @access public
102
- * @return Varien_Db_Select
103
- */
104
- public function getSelectCountSql(){
105
- $countSelect = parent::getSelectCountSql();
106
- $countSelect->reset(Zend_Db_Select::GROUP);
107
- return $countSelect;
108
- }
109
- /**
110
- * Add Id filter
111
- * @access public
112
- * @param array $menuitemIds
113
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
114
- */
115
- public function addIdFilter($menuitemIds){
116
- if (is_array($menuitemIds)) {
117
- if (empty($menuitemIds)) {
118
- $condition = '';
119
- }
120
- else {
121
- $condition = array('in' => $menuitemIds);
122
- }
123
- }
124
- elseif (is_numeric($menuitemIds)) {
125
- $condition = $menuitemIds;
126
- }
127
- elseif (is_string($menuitemIds)) {
128
- $ids = explode(',', $menuitemIds);
129
- if (empty($ids)) {
130
- $condition = $menuitemIds;
131
- }
132
- else {
133
- $condition = array('in' => $ids);
134
- }
135
- }
136
- $this->addFieldToFilter('entity_id', $condition);
137
- return $this;
138
- }
139
- /**
140
- * Add menu item path filter
141
- * @access public
142
- * @param string $regexp
143
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
144
- */
145
- public function addPathFilter($regexp){
146
- $this->addFieldToFilter('path', array('regexp' => $regexp));
147
- return $this;
148
- }
149
-
150
- /**
151
- * Add menu item path filter
152
- * @access public
153
- * @param array|string $paths
154
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
155
- */
156
- public function addPathsFilter($paths){
157
- if (!is_array($paths)) {
158
- $paths = array($paths);
159
- }
160
- $write = $this->getResource()->getWriteConnection();
161
- $cond = array();
162
- foreach ($paths as $path) {
163
- $cond[] = $write->quoteInto('e.path LIKE ?', "$path%");
164
- }
165
- if ($cond) {
166
- $this->getSelect()->where(join(' OR ', $cond));
167
- }
168
- return $this;
169
- }
170
- /**
171
- * Add menu item level filter
172
- * @access public
173
- * @param int|string $level
174
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
175
- */
176
- public function addLevelFilter($level){
177
- $this->addFieldToFilter('level', array('lteq' => $level));
178
- return $this;
179
- }
180
- /**
181
- * Add root menu item filter
182
- * @access public
183
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
184
- public function addRootLevelFilter(){
185
- $this->addFieldToFilter('path', array('neq' => '1'));
186
- $this->addLevelFilter(1);
187
- return $this;
188
- }
189
- /**
190
- * Add order field
191
- * @access public
192
- * @param string $field
193
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
194
- public function addOrderField($field){
195
- $this->setOrder($field, self::SORT_ORDER_ASC);
196
- return $this;
197
- }
198
- /**
199
- * Add active menu item filter
200
- * @access public
201
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
202
- public function addStatusFilter(){
203
- $this->addFieldToFilter('status', 1);
204
- return $this;
205
- }
206
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item collection resource model
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
24
+ protected $_joinedFields = array();
25
+ /**
26
+ * constructor
27
+ * @access public
28
+ * @return void
29
+ */
30
+ public function _construct(){
31
+ parent::_construct();
32
+ $this->_init('megamenu2/menuitem');
33
+ $this->_map['fields']['store'] = 'store_table.store_id';
34
+ }
35
+ /**
36
+ * get menuitems as array
37
+ * @access protected
38
+ * @param string $valueField
39
+ * @param string $labelField
40
+ * @param array $additional
41
+ * @return array
42
+ */
43
+ protected function _toOptionArray($valueField='entity_id', $labelField='linktitle', $additional=array()){
44
+ return parent::_toOptionArray($valueField, $labelField, $additional);
45
+ }
46
+ /**
47
+ * get options hash
48
+ * @access protected
49
+ * @param string $valueField
50
+ * @param string $labelField
51
+ * @return array
52
+ */
53
+ protected function _toOptionHash($valueField='entity_id', $labelField='linktitle'){
54
+ return parent::_toOptionHash($valueField, $labelField);
55
+ }
56
+ /**
57
+ * Add filter by store
58
+ * @access public
59
+ * @param int|Mage_Core_Model_Store $store
60
+ * @param bool $withAdmin
61
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
62
+ */
63
+ public function addStoreFilter($store, $withAdmin = true){
64
+ if (!isset($this->_joinedFields['store'])){
65
+ if ($store instanceof Mage_Core_Model_Store) {
66
+ $store = array($store->getId());
67
+ }
68
+ if (!is_array($store)) {
69
+ $store = array($store);
70
+ }
71
+ if ($withAdmin) {
72
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
73
+ }
74
+ $this->addFilter('store', array('in' => $store), 'public');
75
+ $this->_joinedFields['store'] = true;
76
+ }
77
+ return $this;
78
+ }
79
+ /**
80
+ * Join store relation table if there is store filter
81
+ * @access protected
82
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
83
+ */
84
+ protected function _renderFiltersBefore(){
85
+ if ($this->getFilter('store')) {
86
+ $this->getSelect()->join(
87
+ array('store_table' => $this->getTable('megamenu2/menuitem_store')),
88
+ 'main_table.entity_id = store_table.menuitem_id',
89
+ array()
90
+ )->group('main_table.entity_id');
91
+ /*
92
+ * Allow analytic functions usage because of one field grouping
93
+ */
94
+ $this->_useAnalyticFunction = true;
95
+ }
96
+ return parent::_renderFiltersBefore();
97
+ }
98
+ /**
99
+ * Get SQL for get record count.
100
+ * Extra GROUP BY strip added.
101
+ * @access public
102
+ * @return Varien_Db_Select
103
+ */
104
+ public function getSelectCountSql(){
105
+ $countSelect = parent::getSelectCountSql();
106
+ $countSelect->reset(Zend_Db_Select::GROUP);
107
+ return $countSelect;
108
+ }
109
+ /**
110
+ * Add Id filter
111
+ * @access public
112
+ * @param array $menuitemIds
113
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
114
+ */
115
+ public function addIdFilter($menuitemIds){
116
+ if (is_array($menuitemIds)) {
117
+ if (empty($menuitemIds)) {
118
+ $condition = '';
119
+ }
120
+ else {
121
+ $condition = array('in' => $menuitemIds);
122
+ }
123
+ }
124
+ elseif (is_numeric($menuitemIds)) {
125
+ $condition = $menuitemIds;
126
+ }
127
+ elseif (is_string($menuitemIds)) {
128
+ $ids = explode(',', $menuitemIds);
129
+ if (empty($ids)) {
130
+ $condition = $menuitemIds;
131
+ }
132
+ else {
133
+ $condition = array('in' => $ids);
134
+ }
135
+ }
136
+ $this->addFieldToFilter('entity_id', $condition);
137
+ return $this;
138
+ }
139
+ /**
140
+ * Add menu item path filter
141
+ * @access public
142
+ * @param string $regexp
143
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
144
+ */
145
+ public function addPathFilter($regexp){
146
+ $this->addFieldToFilter('path', array('regexp' => $regexp));
147
+ return $this;
148
+ }
149
+
150
+ /**
151
+ * Add menu item path filter
152
+ * @access public
153
+ * @param array|string $paths
154
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
155
+ */
156
+ public function addPathsFilter($paths){
157
+ if (!is_array($paths)) {
158
+ $paths = array($paths);
159
+ }
160
+ $write = $this->getResource()->getWriteConnection();
161
+ $cond = array();
162
+ foreach ($paths as $path) {
163
+ $cond[] = $write->quoteInto('e.path LIKE ?', "$path%");
164
+ }
165
+ if ($cond) {
166
+ $this->getSelect()->where(join(' OR ', $cond));
167
+ }
168
+ return $this;
169
+ }
170
+ /**
171
+ * Add menu item level filter
172
+ * @access public
173
+ * @param int|string $level
174
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
175
+ */
176
+ public function addLevelFilter($level){
177
+ $this->addFieldToFilter('level', array('lteq' => $level));
178
+ return $this;
179
+ }
180
+ /**
181
+ * Add root menu item filter
182
+ * @access public
183
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
184
+ public function addRootLevelFilter(){
185
+ $this->addFieldToFilter('path', array('neq' => '1'));
186
+ $this->addLevelFilter(1);
187
+ return $this;
188
+ }
189
+ /**
190
+ * Add order field
191
+ * @access public
192
+ * @param string $field
193
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
194
+ public function addOrderField($field){
195
+ $this->setOrder($field, self::SORT_ORDER_ASC);
196
+ return $this;
197
+ }
198
+ /**
199
+ * Add active menu item filter
200
+ * @access public
201
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
202
+ public function addStatusFilter(){
203
+ $this->addFieldToFilter('status', 1);
204
+ return $this;
205
+ }
206
  }
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Tree.php CHANGED
@@ -1,389 +1,389 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item tree resource model
19
- * @category JScriptz
20
- * @package JScriptz_MegaMenu2
21
-
22
- */
23
- class JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree extends Varien_Data_Tree_Dbp{
24
- const ID_FIELD = 'entity_id';
25
- const PATH_FIELD = 'path';
26
- const ORDER_FIELD = 'order';
27
- const LEVEL_FIELD = 'level';
28
- /**
29
- * Menu Items resource collection
30
- * @var JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
31
- protected $_collection;
32
- /**
33
- * Inactive menu items ids
34
- * @var array */
35
- protected $_inactiveMenuitemIds = null;
36
- /**
37
- * Initialize tree
38
- * @access public
39
- * @return void
40
- */
41
- public function __construct(){
42
- $resource = Mage::getSingleton('core/resource');
43
- parent::__construct(
44
- $resource->getConnection('megamenu2_write'),
45
- $resource->getTableName('megamenu2/menuitem'),
46
- array(
47
- Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id',
48
- Varien_Data_Tree_Dbp::PATH_FIELD => 'path',
49
- Varien_Data_Tree_Dbp::ORDER_FIELD=> 'position',
50
- Varien_Data_Tree_Dbp::LEVEL_FIELD=> 'level',
51
- )
52
- );
53
- }
54
-
55
- /**
56
- * Get menu items collection
57
- * @access public
58
- * @param boolean $sorted
59
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
60
- */
61
- public function getCollection($sorted = false){
62
- if (is_null($this->_collection)) {
63
- $this->_collection = $this->_getDefaultCollection($sorted);
64
- }
65
- return $this->_collection;
66
- }
67
- /**
68
- * set the collection
69
- * @access public
70
- * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
71
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree */
72
- public function setCollection($collection){
73
- if (!is_null($this->_collection)) {
74
- destruct($this->_collection);
75
- }
76
- $this->_collection = $collection;
77
- return $this;
78
- }
79
- /**
80
- * get the default collection
81
- * @access protected
82
- * @param boolean $sorted
83
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
84
- protected function _getDefaultCollection($sorted = false){
85
- $collection = Mage::getModel('megamenu2/menuitem')->getCollection();
86
- if ($sorted) {
87
- if (is_string($sorted)) {
88
- $collection->setOrder($sorted);
89
- }
90
- else {
91
- $collection->setOrder('name');
92
- }
93
- }
94
- return $collection;
95
- }
96
- /**
97
- * Executing parents move method and cleaning cache after it
98
- * @access public
99
- * @param unknown_type $menuitem
100
- * @param unknown_type $newParent
101
- * @param unknown_type $prevNode
102
- */
103
- public function move($menuitem, $newParent, $prevNode = null){
104
- Mage::getResourceSingleton('megamenu2/menuitem')->move($menuitem->getId(), $newParent->getId());
105
- parent::move($menuitem, $newParent, $prevNode);
106
- $this->_afterMove($menuitem, $newParent, $prevNode);
107
- }
108
-
109
- /**
110
- * Move tree after
111
- * @access protected
112
- * @param unknown_type $menuitem
113
- * @param Varien_Data_Tree_Node $newParent
114
- * @param Varien_Data_Tree_Node $prevNode
115
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree */
116
- protected function _afterMove($menuitem, $newParent, $prevNode){
117
- Mage::app()->cleanCache(array(JScriptz_MegaMenu2_Model_Menuitem::CACHE_TAG));
118
- return $this;
119
- }
120
- /**
121
- * Load whole menu item tree, that will include specified menu items ids.
122
- * @access public
123
- * @param array $ids
124
- * @param bool $addCollectionData
125
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
126
- */
127
- public function loadByIds($ids, $addCollectionData = true){
128
- $levelField = $this->_conn->quoteIdentifier('level');
129
- $pathField = $this->_conn->quoteIdentifier('path');
130
- // load first two levels, if no ids specified
131
- if (empty($ids)) {
132
- $select = $this->_conn->select()
133
- ->from($this->_table, 'entity_id')
134
- ->where($levelField . ' <= 2');
135
- $ids = $this->_conn->fetchCol($select);
136
- }
137
- if (!is_array($ids)) {
138
- $ids = array($ids);
139
- }
140
- foreach ($ids as $key => $id) {
141
- $ids[$key] = (int)$id;
142
- }
143
- // collect paths of specified IDs and prepare to collect all their parents and neighbours
144
- $select = $this->_conn->select()
145
- ->from($this->_table, array('path', 'level'))
146
- ->where('entity_id IN (?)', $ids);
147
- $where = array($levelField . '=0' => true);
148
-
149
- foreach ($this->_conn->fetchAll($select) as $item) {
150
- $pathIds = explode('/', $item['path']);
151
- $level = (int)$item['level'];
152
- while ($level > 0) {
153
- $pathIds[count($pathIds) - 1] = '%';
154
- $path = implode('/', $pathIds);
155
- $where["$levelField=$level AND $pathField LIKE '$path'"] = true;
156
- array_pop($pathIds);
157
- $level--;
158
- }
159
- }
160
- $where = array_keys($where);
161
-
162
- // get all required records
163
- if ($addCollectionData) {
164
- $select = $this->_createCollectionDataSelect();
165
- }
166
- else {
167
- $select = clone $this->_select;
168
- $select->order($this->_orderField . ' ' . Varien_Db_Select::SQL_ASC);
169
- }
170
- $select->where(implode(' OR ', $where));
171
-
172
- // get array of records and add them as nodes to the tree
173
- $arrNodes = $this->_conn->fetchAll($select);
174
- if (!$arrNodes) {
175
- return false;
176
- }
177
- $childrenItems = array();
178
- foreach ($arrNodes as $key => $nodeInfo) {
179
- $pathToParent = explode('/', $nodeInfo[$this->_pathField]);
180
- array_pop($pathToParent);
181
- $pathToParent = implode('/', $pathToParent);
182
- $childrenItems[$pathToParent][] = $nodeInfo;
183
- }
184
- $this->addChildNodes($childrenItems, '', null);
185
- return $this;
186
- }
187
- /**
188
- * Load array of menu item parents
189
- * @access public
190
- * @param string $path
191
- * @param bool $addCollectionData
192
- * @param bool $withRootNode
193
- * @return array
194
- */
195
- public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRootNode = false){
196
- $pathIds = explode('/', $path);
197
- if (!$withRootNode) {
198
- array_shift($pathIds);
199
- }
200
- $result = array();
201
- if (!empty($pathIds)) {
202
- if ($addCollectionData) {
203
- $select = $this->_createCollectionDataSelect(false);
204
- }
205
- else {
206
- $select = clone $this->_select;
207
- }
208
- $select
209
- ->where('main_table.entity_id IN(?)', $pathIds)
210
- ->order($this->_conn->getLengthSql('main_table.path') . ' ' . Varien_Db_Select::SQL_ASC);
211
- $result = $this->_conn->fetchAll($select);
212
- }
213
- return $result;
214
- }
215
- /**
216
- * Obtain select for menu items
217
- * By default everything from entity table is selected
218
- * + name
219
- * @access public
220
- * @param bool $sorted
221
- * @param array $optionalAttributes
222
- * @return Zend_Db_Select
223
- */
224
- protected function _createCollectionDataSelect($sorted = true){
225
- $select = $this->_getDefaultCollection($sorted ? $this->_orderField : false)->getSelect();
226
- $menuitemsTable = Mage::getSingleton('core/resource')->getTableName('megamenu2/menuitem');
227
- $subConcat = $this->_conn->getConcatSql(array('main_table.path', $this->_conn->quote('/%')));
228
- $subSelect = $this->_conn->select()
229
- ->from(array('see' => $menuitemsTable), null)
230
- ->where('see.entity_id = main_table.entity_id')
231
- ->orWhere('see.path LIKE ?', $subConcat);
232
- return $select;
233
- }
234
- /**
235
- * Get real existing menu item ids by specified ids
236
- * @access public
237
- * @param array $ids
238
- * @return array
239
- */
240
- public function getExistingMenuitemIdsBySpecifiedIds($ids){
241
- if (empty($ids)) {
242
- return array();
243
- }
244
- if (!is_array($ids)) {
245
- $ids = array($ids);
246
- }
247
- $select = $this->_conn->select()
248
- ->from($this->_table, array('entity_id'))
249
- ->where('entity_id IN (?)', $ids);
250
- return $this->_conn->fetchCol($select);
251
- }
252
- /**
253
- * add collection data
254
- * @access public
255
- * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
256
- * @param boolean $sorted
257
- * @param array $exclude
258
- * @param boolean $toLoad
259
- * @param boolean $onlyActive
260
- * @return JScriptz_MegaMenu2_Model_Resource_Category_Tree
261
- */
262
- public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true, $onlyActive = false){
263
- if (is_null($collection)) {
264
- $collection = $this->getCollection($sorted);
265
- } else {
266
- $this->setCollection($collection);
267
- }
268
- if (!is_array($exclude)) {
269
- $exclude = array($exclude);
270
- }
271
- $nodeIds = array();
272
- foreach ($this->getNodes() as $node) {
273
- if (!in_array($node->getId(), $exclude)) {
274
- $nodeIds[] = $node->getId();
275
- }
276
- }
277
- $collection->addIdFilter($nodeIds);
278
- if ($onlyActive) {
279
- $disabledIds = $this->_getDisabledIds($collection);
280
- if ($disabledIds) {
281
- $collection->addFieldToFilter('entity_id', array('nin' => $disabledIds));
282
- }
283
- $collection->addFieldToFilter('status', 1);
284
- }
285
- if ($toLoad) {
286
- $collection->load();
287
- foreach ($collection as $menuitem) {
288
- if ($this->getNodeById($menuitem->getId())) {
289
- $this->getNodeById($menuitem->getId())->addData($menuitem->getData());
290
- }
291
- }
292
- foreach ($this->getNodes() as $node) {
293
- if (!$collection->getItemById($node->getId()) && $node->getParent()) {
294
- $this->removeNode($node);
295
- }
296
- }
297
- }
298
- return $this;
299
- }
300
- /**
301
- * Add inactive menu items ids
302
- * @access public
303
- * @param unknown_type $ids
304
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
305
- */
306
- public function addInactiveMenuitemIds($ids){
307
- if (!is_array($this->_inactiveMenuitemIds)) {
308
- $this->_initInactiveMenuitemIds();
309
- }
310
- $this->_inactiveMenuitemIds = array_merge($ids, $this->_inactiveMenuitemIds);
311
- return $this;
312
- }
313
- /**
314
- * Retrieve inactive menu items ids
315
- * @access protected
316
- * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
317
- */
318
- protected function _initInactiveMenuitemIds(){
319
- $this->_inactiveMenuitemIds = array();
320
- return $this;
321
- }
322
- /**
323
- * Retrieve inactive menu items ids
324
- * @access public
325
- * @return array
326
- */
327
- public function getInactiveMenuitemIds(){
328
- if (!is_array($this->_inactiveMenuitemIds)) {
329
- $this->_initInactiveMenuitemIds();
330
- }
331
- return $this->_inactiveMenuitemIds;
332
- }
333
- /**
334
- * Return disable menu item ids
335
- * @access protected
336
- * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
337
- * @return array
338
- */
339
- protected function _getDisabledIds($collection){
340
- $this->_inactiveItems = $this->getInactiveMenuitemIds();
341
- $this->_inactiveItems = array_merge(
342
- $this->_getInactiveItemIds($collection),
343
- $this->_inactiveItems
344
- );
345
- $allIds = $collection->getAllIds();
346
- $disabledIds = array();
347
-
348
- foreach ($allIds as $id) {
349
- $parents = $this->getNodeById($id)->getPath();
350
- foreach ($parents as $parent) {
351
- if (!$this->_getItemIsActive($parent->getId())){
352
- $disabledIds[] = $id;
353
- continue;
354
- }
355
- }
356
- }
357
- return $disabledIds;
358
- }
359
- /**
360
- * Retrieve inactive menu item item ids
361
- * @access protecte
362
- * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
363
- * @return array
364
- */
365
- protected function _getInactiveItemIds($collection){
366
- $filter = $collection->getAllIdsSql();
367
- $table = Mage::getSingleton('core/resource')->getTable('megamenu2/menuitem');
368
- $bind = array(
369
- 'cond' => 0,
370
- );
371
- $select = $this->_conn->select()
372
- ->from(array('d'=>$table), array('d.entity_id'))
373
- ->where('d.entity_id IN (?)', new Zend_Db_Expr($filter))
374
- ->where('status = :cond');
375
- return $this->_conn->fetchCol($select, $bind);
376
- }
377
- /**
378
- * Check is menu item items active
379
- * @access protecte
380
- * @param int $id
381
- * @return boolean
382
- */
383
- protected function _getItemIsActive($id){
384
- if (!in_array($id, $this->_inactiveItems)) {
385
- return true;
386
- }
387
- return false;
388
- }
389
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item tree resource model
19
+ * @category JScriptz
20
+ * @package JScriptz_MegaMenu2
21
+
22
+ */
23
+ class JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree extends Varien_Data_Tree_Dbp{
24
+ const ID_FIELD = 'entity_id';
25
+ const PATH_FIELD = 'path';
26
+ const ORDER_FIELD = 'order';
27
+ const LEVEL_FIELD = 'level';
28
+ /**
29
+ * Menu Items resource collection
30
+ * @var JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
31
+ protected $_collection;
32
+ /**
33
+ * Inactive menu items ids
34
+ * @var array */
35
+ protected $_inactiveMenuitemIds = null;
36
+ /**
37
+ * Initialize tree
38
+ * @access public
39
+ * @return void
40
+ */
41
+ public function __construct(){
42
+ $resource = Mage::getSingleton('core/resource');
43
+ parent::__construct(
44
+ $resource->getConnection('megamenu2_write'),
45
+ $resource->getTableName('megamenu2/menuitem'),
46
+ array(
47
+ Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id',
48
+ Varien_Data_Tree_Dbp::PATH_FIELD => 'path',
49
+ Varien_Data_Tree_Dbp::ORDER_FIELD=> 'position',
50
+ Varien_Data_Tree_Dbp::LEVEL_FIELD=> 'level',
51
+ )
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Get menu items collection
57
+ * @access public
58
+ * @param boolean $sorted
59
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
60
+ */
61
+ public function getCollection($sorted = false){
62
+ if (is_null($this->_collection)) {
63
+ $this->_collection = $this->_getDefaultCollection($sorted);
64
+ }
65
+ return $this->_collection;
66
+ }
67
+ /**
68
+ * set the collection
69
+ * @access public
70
+ * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
71
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree */
72
+ public function setCollection($collection){
73
+ if (!is_null($this->_collection)) {
74
+ destruct($this->_collection);
75
+ }
76
+ $this->_collection = $collection;
77
+ return $this;
78
+ }
79
+ /**
80
+ * get the default collection
81
+ * @access protected
82
+ * @param boolean $sorted
83
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection */
84
+ protected function _getDefaultCollection($sorted = false){
85
+ $collection = Mage::getModel('megamenu2/menuitem')->getCollection();
86
+ if ($sorted) {
87
+ if (is_string($sorted)) {
88
+ $collection->setOrder($sorted);
89
+ }
90
+ else {
91
+ $collection->setOrder('name');
92
+ }
93
+ }
94
+ return $collection;
95
+ }
96
+ /**
97
+ * Executing parents move method and cleaning cache after it
98
+ * @access public
99
+ * @param unknown_type $menuitem
100
+ * @param unknown_type $newParent
101
+ * @param unknown_type $prevNode
102
+ */
103
+ public function move($menuitem, $newParent, $prevNode = null){
104
+ Mage::getResourceSingleton('megamenu2/menuitem')->move($menuitem->getId(), $newParent->getId());
105
+ parent::move($menuitem, $newParent, $prevNode);
106
+ $this->_afterMove($menuitem, $newParent, $prevNode);
107
+ }
108
+
109
+ /**
110
+ * Move tree after
111
+ * @access protected
112
+ * @param unknown_type $menuitem
113
+ * @param Varien_Data_Tree_Node $newParent
114
+ * @param Varien_Data_Tree_Node $prevNode
115
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree */
116
+ protected function _afterMove($menuitem, $newParent, $prevNode){
117
+ Mage::app()->cleanCache(array(JScriptz_MegaMenu2_Model_Menuitem::CACHE_TAG));
118
+ return $this;
119
+ }
120
+ /**
121
+ * Load whole menu item tree, that will include specified menu items ids.
122
+ * @access public
123
+ * @param array $ids
124
+ * @param bool $addCollectionData
125
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
126
+ */
127
+ public function loadByIds($ids, $addCollectionData = true){
128
+ $levelField = $this->_conn->quoteIdentifier('level');
129
+ $pathField = $this->_conn->quoteIdentifier('path');
130
+ // load first two levels, if no ids specified
131
+ if (empty($ids)) {
132
+ $select = $this->_conn->select()
133
+ ->from($this->_table, 'entity_id')
134
+ ->where($levelField . ' <= 2');
135
+ $ids = $this->_conn->fetchCol($select);
136
+ }
137
+ if (!is_array($ids)) {
138
+ $ids = array($ids);
139
+ }
140
+ foreach ($ids as $key => $id) {
141
+ $ids[$key] = (int)$id;
142
+ }
143
+ // collect paths of specified IDs and prepare to collect all their parents and neighbours
144
+ $select = $this->_conn->select()
145
+ ->from($this->_table, array('path', 'level'))
146
+ ->where('entity_id IN (?)', $ids);
147
+ $where = array($levelField . '=0' => true);
148
+
149
+ foreach ($this->_conn->fetchAll($select) as $item) {
150
+ $pathIds = explode('/', $item['path']);
151
+ $level = (int)$item['level'];
152
+ while ($level > 0) {
153
+ $pathIds[count($pathIds) - 1] = '%';
154
+ $path = implode('/', $pathIds);
155
+ $where["$levelField=$level AND $pathField LIKE '$path'"] = true;
156
+ array_pop($pathIds);
157
+ $level--;
158
+ }
159
+ }
160
+ $where = array_keys($where);
161
+
162
+ // get all required records
163
+ if ($addCollectionData) {
164
+ $select = $this->_createCollectionDataSelect();
165
+ }
166
+ else {
167
+ $select = clone $this->_select;
168
+ $select->order($this->_orderField . ' ' . Varien_Db_Select::SQL_ASC);
169
+ }
170
+ $select->where(implode(' OR ', $where));
171
+
172
+ // get array of records and add them as nodes to the tree
173
+ $arrNodes = $this->_conn->fetchAll($select);
174
+ if (!$arrNodes) {
175
+ return false;
176
+ }
177
+ $childrenItems = array();
178
+ foreach ($arrNodes as $key => $nodeInfo) {
179
+ $pathToParent = explode('/', $nodeInfo[$this->_pathField]);
180
+ array_pop($pathToParent);
181
+ $pathToParent = implode('/', $pathToParent);
182
+ $childrenItems[$pathToParent][] = $nodeInfo;
183
+ }
184
+ $this->addChildNodes($childrenItems, '', null);
185
+ return $this;
186
+ }
187
+ /**
188
+ * Load array of menu item parents
189
+ * @access public
190
+ * @param string $path
191
+ * @param bool $addCollectionData
192
+ * @param bool $withRootNode
193
+ * @return array
194
+ */
195
+ public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRootNode = false){
196
+ $pathIds = explode('/', $path);
197
+ if (!$withRootNode) {
198
+ array_shift($pathIds);
199
+ }
200
+ $result = array();
201
+ if (!empty($pathIds)) {
202
+ if ($addCollectionData) {
203
+ $select = $this->_createCollectionDataSelect(false);
204
+ }
205
+ else {
206
+ $select = clone $this->_select;
207
+ }
208
+ $select
209
+ ->where('main_table.entity_id IN(?)', $pathIds)
210
+ ->order($this->_conn->getLengthSql('main_table.path') . ' ' . Varien_Db_Select::SQL_ASC);
211
+ $result = $this->_conn->fetchAll($select);
212
+ }
213
+ return $result;
214
+ }
215
+ /**
216
+ * Obtain select for menu items
217
+ * By default everything from entity table is selected
218
+ * + name
219
+ * @access public
220
+ * @param bool $sorted
221
+ * @param array $optionalAttributes
222
+ * @return Zend_Db_Select
223
+ */
224
+ protected function _createCollectionDataSelect($sorted = true){
225
+ $select = $this->_getDefaultCollection($sorted ? $this->_orderField : false)->getSelect();
226
+ $menuitemsTable = Mage::getSingleton('core/resource')->getTableName('megamenu2/menuitem');
227
+ $subConcat = $this->_conn->getConcatSql(array('main_table.path', $this->_conn->quote('/%')));
228
+ $subSelect = $this->_conn->select()
229
+ ->from(array('see' => $menuitemsTable), null)
230
+ ->where('see.entity_id = main_table.entity_id')
231
+ ->orWhere('see.path LIKE ?', $subConcat);
232
+ return $select;
233
+ }
234
+ /**
235
+ * Get real existing menu item ids by specified ids
236
+ * @access public
237
+ * @param array $ids
238
+ * @return array
239
+ */
240
+ public function getExistingMenuitemIdsBySpecifiedIds($ids){
241
+ if (empty($ids)) {
242
+ return array();
243
+ }
244
+ if (!is_array($ids)) {
245
+ $ids = array($ids);
246
+ }
247
+ $select = $this->_conn->select()
248
+ ->from($this->_table, array('entity_id'))
249
+ ->where('entity_id IN (?)', $ids);
250
+ return $this->_conn->fetchCol($select);
251
+ }
252
+ /**
253
+ * add collection data
254
+ * @access public
255
+ * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
256
+ * @param boolean $sorted
257
+ * @param array $exclude
258
+ * @param boolean $toLoad
259
+ * @param boolean $onlyActive
260
+ * @return JScriptz_MegaMenu2_Model_Resource_Category_Tree
261
+ */
262
+ public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true, $onlyActive = false){
263
+ if (is_null($collection)) {
264
+ $collection = $this->getCollection($sorted);
265
+ } else {
266
+ $this->setCollection($collection);
267
+ }
268
+ if (!is_array($exclude)) {
269
+ $exclude = array($exclude);
270
+ }
271
+ $nodeIds = array();
272
+ foreach ($this->getNodes() as $node) {
273
+ if (!in_array($node->getId(), $exclude)) {
274
+ $nodeIds[] = $node->getId();
275
+ }
276
+ }
277
+ $collection->addIdFilter($nodeIds);
278
+ if ($onlyActive) {
279
+ $disabledIds = $this->_getDisabledIds($collection);
280
+ if ($disabledIds) {
281
+ $collection->addFieldToFilter('entity_id', array('nin' => $disabledIds));
282
+ }
283
+ $collection->addFieldToFilter('status', 1);
284
+ }
285
+ if ($toLoad) {
286
+ $collection->load();
287
+ foreach ($collection as $menuitem) {
288
+ if ($this->getNodeById($menuitem->getId())) {
289
+ $this->getNodeById($menuitem->getId())->addData($menuitem->getData());
290
+ }
291
+ }
292
+ foreach ($this->getNodes() as $node) {
293
+ if (!$collection->getItemById($node->getId()) && $node->getParent()) {
294
+ $this->removeNode($node);
295
+ }
296
+ }
297
+ }
298
+ return $this;
299
+ }
300
+ /**
301
+ * Add inactive menu items ids
302
+ * @access public
303
+ * @param unknown_type $ids
304
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
305
+ */
306
+ public function addInactiveMenuitemIds($ids){
307
+ if (!is_array($this->_inactiveMenuitemIds)) {
308
+ $this->_initInactiveMenuitemIds();
309
+ }
310
+ $this->_inactiveMenuitemIds = array_merge($ids, $this->_inactiveMenuitemIds);
311
+ return $this;
312
+ }
313
+ /**
314
+ * Retrieve inactive menu items ids
315
+ * @access protected
316
+ * @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
317
+ */
318
+ protected function _initInactiveMenuitemIds(){
319
+ $this->_inactiveMenuitemIds = array();
320
+ return $this;
321
+ }
322
+ /**
323
+ * Retrieve inactive menu items ids
324
+ * @access public
325
+ * @return array
326
+ */
327
+ public function getInactiveMenuitemIds(){
328
+ if (!is_array($this->_inactiveMenuitemIds)) {
329
+ $this->_initInactiveMenuitemIds();
330
+ }
331
+ return $this->_inactiveMenuitemIds;
332
+ }
333
+ /**
334
+ * Return disable menu item ids
335
+ * @access protected
336
+ * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
337
+ * @return array
338
+ */
339
+ protected function _getDisabledIds($collection){
340
+ $this->_inactiveItems = $this->getInactiveMenuitemIds();
341
+ $this->_inactiveItems = array_merge(
342
+ $this->_getInactiveItemIds($collection),
343
+ $this->_inactiveItems
344
+ );
345
+ $allIds = $collection->getAllIds();
346
+ $disabledIds = array();
347
+
348
+ foreach ($allIds as $id) {
349
+ $parents = $this->getNodeById($id)->getPath();
350
+ foreach ($parents as $parent) {
351
+ if (!$this->_getItemIsActive($parent->getId())){
352
+ $disabledIds[] = $id;
353
+ continue;
354
+ }
355
+ }
356
+ }
357
+ return $disabledIds;
358
+ }
359
+ /**
360
+ * Retrieve inactive menu item item ids
361
+ * @access protecte
362
+ * @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
363
+ * @return array
364
+ */
365
+ protected function _getInactiveItemIds($collection){
366
+ $filter = $collection->getAllIdsSql();
367
+ $table = Mage::getSingleton('core/resource')->getTable('megamenu2/menuitem');
368
+ $bind = array(
369
+ 'cond' => 0,
370
+ );
371
+ $select = $this->_conn->select()
372
+ ->from(array('d'=>$table), array('d.entity_id'))
373
+ ->where('d.entity_id IN (?)', new Zend_Db_Expr($filter))
374
+ ->where('status = :cond');
375
+ return $this->_conn->fetchCol($select, $bind);
376
+ }
377
+ /**
378
+ * Check is menu item items active
379
+ * @access protecte
380
+ * @param int $id
381
+ * @return boolean
382
+ */
383
+ protected function _getItemIsActive($id){
384
+ if (!in_array($id, $this->_inactiveItems)) {
385
+ return true;
386
+ }
387
+ return false;
388
+ }
389
  }
app/code/community/JScriptz/MegaMenu2/Model/Resource/Setup.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * MegaMenu2 setup
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- class JScriptz_MegaMenu2_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
24
-
25
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MegaMenu2 setup
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ class JScriptz_MegaMenu2_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
24
+
25
  }
app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/MenuitemController.php CHANGED
@@ -1,311 +1,311 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * Menu Item admin controller
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
-
23
- */
24
- class JScriptz_MegaMenu2_Adminhtml_MegaMenu2_MenuitemController extends JScriptz_MegaMenu2_Controller_Adminhtml_MegaMenu2{
25
- /**
26
- * init menu item
27
- * @access protected
28
- * @return JScriptz_MegaMenu2_Model_Menuitem
29
- */
30
- protected function _initMenuitem(){
31
- $menuitemId = (int) $this->getRequest()->getParam('id',false);
32
- $menuitem = Mage::getModel('megamenu2/menuitem');
33
- if ($menuitemId) {
34
- $menuitem->load($menuitemId);
35
- }
36
- if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) {
37
- Mage::getSingleton('admin/session')->setActiveTabId($activeTabId);
38
- }
39
- Mage::register('menuitem', $menuitem);
40
- Mage::register('current_menuitem', $menuitem);
41
- return $menuitem;
42
- }
43
- /**
44
- * default action
45
- * @access public
46
- * @return void
47
-
48
- */
49
- public function indexAction(){
50
- $this->_forward('edit');
51
- }
52
-
53
- /**
54
- * Add new menu item form
55
- * @access public
56
- * @return void
57
-
58
- */
59
- public function addAction(){
60
- Mage::getSingleton('admin/session')->unsActiveTabId();
61
- $this->_forward('edit');
62
- }
63
- /**
64
- * Edit menu item page
65
- * @access public
66
- * @return void
67
-
68
- */
69
- public function editAction(){
70
- $params['_current'] = true;
71
- $redirect = false;
72
- $parentId = (int) $this->getRequest()->getParam('parent');
73
- $menuitemId = (int) $this->getRequest()->getParam('id');
74
- $_prevMenuitemId = Mage::getSingleton('admin/session')->getLastEditedMenuitem(true);
75
- if ($_prevMenuitemId && !$this->getRequest()->getQuery('isAjax') && !$this->getRequest()->getParam('clear')) {
76
- $this->getRequest()->setParam('id',$_prevMenuitemId);
77
- }
78
- if ($redirect) {
79
- $this->_redirect('*/*/edit', $params);
80
- return;
81
- }
82
- if (!($menuitem = $this->_initMenuitem())) {
83
- return;
84
- }
85
- $this->_title($menuitemId ? $menuitem->getLinktitle() : $this->__('New Menu Item'));
86
- $data = Mage::getSingleton('adminhtml/session')->getMenuitemData(true);
87
- if (isset($data['menuitem'])) {
88
- $menuitem->addData($data['menuitem']);
89
- }
90
- if ($this->getRequest()->getQuery('isAjax')) {
91
- $breadcrumbsPath = $menuitem->getPath();
92
- if (empty($breadcrumbsPath)) {
93
- $breadcrumbsPath = Mage::getSingleton('admin/session')->getDeletedPath(true);
94
- if (!empty($breadcrumbsPath)) {
95
- $breadcrumbsPath = explode('/', $breadcrumbsPath);
96
- if (count($breadcrumbsPath) <= 1) {
97
- $breadcrumbsPath = '';
98
- }
99
- else {
100
- array_pop($breadcrumbsPath);
101
- $breadcrumbsPath = implode('/', $breadcrumbsPath);
102
- }
103
- }
104
- }
105
- Mage::getSingleton('admin/session')->setLastEditedMenuitem($menuitem->getId());
106
- $this->loadLayout();
107
- $eventResponse = new Varien_Object(array(
108
- 'content' => $this->getLayout()->getBlock('menuitem.edit')->getFormHtml(). $this->getLayout()->getBlock('menuitem.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingMenuitemBreadcrumbs'),
109
- 'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(),
110
- ));
111
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($eventResponse->getData()));
112
- return;
113
- }
114
- $this->loadLayout();
115
- $this->_title(Mage::helper('megamenu2')->__('MegaMenu2'))
116
- ->_title(Mage::helper('megamenu2')->__('Menu Items'));
117
- $this->_setActiveMenu('megamenu2/menuitem');
118
- $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
119
- ->setContainerCssClass('menuitem');
120
-
121
- $this->_addBreadcrumb(
122
- Mage::helper('megamenu2')->__('Manage Menu Items'),
123
- Mage::helper('megamenu2')->__('Manage Menu Items')
124
- );
125
- if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
126
- $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
127
- }
128
- $this->renderLayout();
129
- }
130
- /**
131
- * Get tree node (Ajax version)
132
- * @access public
133
- * @return void
134
-
135
- */
136
- public function menuitemsJsonAction(){
137
- if ($this->getRequest()->getParam('expand_all')) {
138
- Mage::getSingleton('admin/session')->setMenuitemIsTreeWasExpanded(true);
139
- }
140
- else {
141
- Mage::getSingleton('admin/session')->setMenuitemIsTreeWasExpanded(false);
142
- }
143
- if ($menuitemId = (int) $this->getRequest()->getPost('id')) {
144
- $this->getRequest()->setParam('id', $menuitemId);
145
- if (!$menuitem = $this->_initMenuitem()) {
146
- return;
147
- }
148
- $this->getResponse()->setBody(
149
- $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_tree')->getTreeJson($menuitem)
150
- );
151
- }
152
- }
153
- /**
154
- * Move menu item action
155
- */
156
- public function moveAction(){
157
- $menuitem = $this->_initMenuitem();
158
- if (!$menuitem) {
159
- $this->getResponse()->setBody(Mage::helper('megamenu2')->__('Menu Item move error'));
160
- return;
161
- }
162
- $parentNodeId = $this->getRequest()->getPost('pid', false);
163
- $prevNodeId = $this->getRequest()->getPost('aid', false);
164
- try {
165
- $menuitem->move($parentNodeId, $prevNodeId);
166
- $this->getResponse()->setBody("SUCCESS");
167
- }
168
- catch (Mage_Core_Exception $e) {
169
- $this->getResponse()->setBody($e->getMessage());
170
- }
171
- catch (Exception $e){
172
- $this->getResponse()->setBody(Mage::helper('megamenu2')->__('Menu Item move error'));
173
- Mage::logException($e);
174
- }
175
- }
176
- /**
177
- * Tree Action
178
- * Retrieve menu item tree
179
- * @access public
180
- * @return void
181
-
182
- */
183
- public function treeAction(){
184
- $menuitemId = (int) $this->getRequest()->getParam('id');
185
- $menuitem = $this->_initMenuitem();
186
- $block = $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_tree');
187
- $root = $block->getRoot();
188
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(
189
- array(
190
- 'data' => $block->getTree(),
191
- 'parameters' => array(
192
- 'text'=> $block->buildNodeName($root),
193
- 'draggable' => false,
194
- 'allowDrop' => ($root->getIsVisible()) ? true : false,
195
- 'id' => (int) $root->getId(),
196
- 'expanded'=> (int) $block->getIsWasExpanded(),
197
- 'menuitem_id' => (int) $menuitem->getId(),
198
- 'root_visible'=> (int) $root->getIsVisible()
199
- )
200
- )
201
- ));
202
- }
203
- /**
204
- * Build response for refresh input element 'path' in form
205
- * @access public
206
- * @return void
207
-
208
- */
209
- public function refreshPathAction(){
210
- if ($id = (int) $this->getRequest()->getParam('id')) {
211
- $menuitem = Mage::getModel('megamenu2/menuitem')->load($id);
212
- $this->getResponse()->setBody(
213
- Mage::helper('core')->jsonEncode(array(
214
- 'id' => $id,
215
- 'path' => $menuitem->getPath(),
216
- ))
217
- );
218
- }
219
- }
220
- /**
221
- * Delete menu item action
222
- * @access public
223
- * @return void
224
-
225
- */
226
- public function deleteAction(){
227
- if ($id = (int) $this->getRequest()->getParam('id')) {
228
- try {
229
- $menuitem = Mage::getModel('megamenu2/menuitem')->load($id);
230
- Mage::getSingleton('admin/session')->setDeletedPath($menuitem->getPath());
231
-
232
- $menuitem->delete();
233
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('The menu item has been deleted.'));
234
- }
235
- catch (Mage_Core_Exception $e){
236
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
237
- $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
238
- return;
239
- }
240
- catch (Exception $e){
241
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('An error occurred while trying to delete the menu item.'));
242
- $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
243
- Mage::logException($e);
244
- return;
245
- }
246
- }
247
- $this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current'=>true, 'id'=>null)));
248
- }
249
- /**
250
- * Check if admin has permissions to visit related pages
251
- * @access protected
252
- * @return boolean
253
-
254
- */
255
- protected function _isAllowed(){
256
- return Mage::getSingleton('admin/session')->isAllowed('megamenu2/menuitem');
257
- } /**
258
- * wyisiwyg action
259
- * @access public
260
- * @return void
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
- */
263
- public function wysiwygAction(){
264
- $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
265
- $storeMediaUrl = Mage::app()->getStore(0)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
266
-
267
- $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
268
- 'editor_element_id' => $elementId,
269
- 'store_id' => 0,
270
- 'store_media_url' => $storeMediaUrl,
271
- ));
272
- $this->getResponse()->setBody($content->toHtml());
273
- }
274
- /**
275
- * Menu Item save action
276
- * @access public
277
- * @return void
278
-
279
- */
280
- public function saveAction(){
281
- if (!$menuitem = $this->_initMenuitem()) {
282
- return;
283
- }
284
- $refreshTree = 'false';
285
- if ($data = $this->getRequest()->getPost('menuitem')) {
286
- $menuitem->addData($data);
287
- if (!$menuitem->getId()) {
288
- $parentId = $this->getRequest()->getParam('parent');
289
- if (!$parentId) {
290
- $parentId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
291
- }
292
- $parentMenuitem = Mage::getModel('megamenu2/menuitem')->load($parentId);
293
- $menuitem->setPath($parentMenuitem->getPath());
294
- }
295
- try {
296
- $menuitem->save();
297
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('The menu item has been saved.'));
298
- $refreshTree = 'true';
299
- }
300
- catch (Exception $e){
301
- $this->_getSession()->addError($e->getMessage())->setMenuitemData($data);
302
- Mage::logException($e);
303
- $refreshTree = 'false';
304
- }
305
- }
306
- $url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => $menuitem->getId()));
307
- $this->getResponse()->setBody(
308
- '<script type="text/javascript">parent.updateContent("' . $url . '", {}, '.$refreshTree.');</script>'
309
- );
310
- }
311
  }
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Menu Item admin controller
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+
23
+ */
24
+ class JScriptz_MegaMenu2_Adminhtml_MegaMenu2_MenuitemController extends JScriptz_MegaMenu2_Controller_Adminhtml_MegaMenu2{
25
+ /**
26
+ * init menu item
27
+ * @access protected
28
+ * @return JScriptz_MegaMenu2_Model_Menuitem
29
+ */
30
+ protected function _initMenuitem(){
31
+ $menuitemId = (int) $this->getRequest()->getParam('id',false);
32
+ $menuitem = Mage::getModel('megamenu2/menuitem');
33
+ if ($menuitemId) {
34
+ $menuitem->load($menuitemId);
35
+ }
36
+ if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) {
37
+ Mage::getSingleton('admin/session')->setActiveTabId($activeTabId);
38
+ }
39
+ Mage::register('menuitem', $menuitem);
40
+ Mage::register('current_menuitem', $menuitem);
41
+ return $menuitem;
42
+ }
43
+ /**
44
+ * default action
45
+ * @access public
46
+ * @return void
47
+
48
+ */
49
+ public function indexAction(){
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ /**
54
+ * Add new menu item form
55
+ * @access public
56
+ * @return void
57
+
58
+ */
59
+ public function addAction(){
60
+ Mage::getSingleton('admin/session')->unsActiveTabId();
61
+ $this->_forward('edit');
62
+ }
63
+ /**
64
+ * Edit menu item page
65
+ * @access public
66
+ * @return void
67
+
68
+ */
69
+ public function editAction(){
70
+ $params['_current'] = true;
71
+ $redirect = false;
72
+ $parentId = (int) $this->getRequest()->getParam('parent');
73
+ $menuitemId = (int) $this->getRequest()->getParam('id');
74
+ $_prevMenuitemId = Mage::getSingleton('admin/session')->getLastEditedMenuitem(true);
75
+ if ($_prevMenuitemId && !$this->getRequest()->getQuery('isAjax') && !$this->getRequest()->getParam('clear')) {
76
+ $this->getRequest()->setParam('id',$_prevMenuitemId);
77
+ }
78
+ if ($redirect) {
79
+ $this->_redirect('*/*/edit', $params);
80
+ return;
81
+ }
82
+ if (!($menuitem = $this->_initMenuitem())) {
83
+ return;
84
+ }
85
+ $this->_title($menuitemId ? $menuitem->getLinktitle() : $this->__('New Menu Item'));
86
+ $data = Mage::getSingleton('adminhtml/session')->getMenuitemData(true);
87
+ if (isset($data['menuitem'])) {
88
+ $menuitem->addData($data['menuitem']);
89
+ }
90
+ if ($this->getRequest()->getQuery('isAjax')) {
91
+ $breadcrumbsPath = $menuitem->getPath();
92
+ if (empty($breadcrumbsPath)) {
93
+ $breadcrumbsPath = Mage::getSingleton('admin/session')->getDeletedPath(true);
94
+ if (!empty($breadcrumbsPath)) {
95
+ $breadcrumbsPath = explode('/', $breadcrumbsPath);
96
+ if (count($breadcrumbsPath) <= 1) {
97
+ $breadcrumbsPath = '';
98
+ }
99
+ else {
100
+ array_pop($breadcrumbsPath);
101
+ $breadcrumbsPath = implode('/', $breadcrumbsPath);
102
+ }
103
+ }
104
+ }
105
+ Mage::getSingleton('admin/session')->setLastEditedMenuitem($menuitem->getId());
106
+ $this->loadLayout();
107
+ $eventResponse = new Varien_Object(array(
108
+ 'content' => $this->getLayout()->getBlock('menuitem.edit')->getFormHtml(). $this->getLayout()->getBlock('menuitem.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingMenuitemBreadcrumbs'),
109
+ 'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(),
110
+ ));
111
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($eventResponse->getData()));
112
+ return;
113
+ }
114
+ $this->loadLayout();
115
+ $this->_title(Mage::helper('megamenu2')->__('MegaMenu2'))
116
+ ->_title(Mage::helper('megamenu2')->__('Menu Items'));
117
+ $this->_setActiveMenu('megamenu2/menuitem');
118
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
119
+ ->setContainerCssClass('menuitem');
120
+
121
+ $this->_addBreadcrumb(
122
+ Mage::helper('megamenu2')->__('Manage Menu Items'),
123
+ Mage::helper('megamenu2')->__('Manage Menu Items')
124
+ );
125
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
126
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
127
+ }
128
+ $this->renderLayout();
129
+ }
130
+ /**
131
+ * Get tree node (Ajax version)
132
+ * @access public
133
+ * @return void
134
+
135
+ */
136
+ public function menuitemsJsonAction(){
137
+ if ($this->getRequest()->getParam('expand_all')) {
138
+ Mage::getSingleton('admin/session')->setMenuitemIsTreeWasExpanded(true);
139
+ }
140
+ else {
141
+ Mage::getSingleton('admin/session')->setMenuitemIsTreeWasExpanded(false);
142
+ }
143
+ if ($menuitemId = (int) $this->getRequest()->getPost('id')) {
144
+ $this->getRequest()->setParam('id', $menuitemId);
145
+ if (!$menuitem = $this->_initMenuitem()) {
146
+ return;
147
+ }
148
+ $this->getResponse()->setBody(
149
+ $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_tree')->getTreeJson($menuitem)
150
+ );
151
+ }
152
+ }
153
+ /**
154
+ * Move menu item action
155
+ */
156
+ public function moveAction(){
157
+ $menuitem = $this->_initMenuitem();
158
+ if (!$menuitem) {
159
+ $this->getResponse()->setBody(Mage::helper('megamenu2')->__('Menu Item move error'));
160
+ return;
161
+ }
162
+ $parentNodeId = $this->getRequest()->getPost('pid', false);
163
+ $prevNodeId = $this->getRequest()->getPost('aid', false);
164
+ try {
165
+ $menuitem->move($parentNodeId, $prevNodeId);
166
+ $this->getResponse()->setBody("SUCCESS");
167
+ }
168
+ catch (Mage_Core_Exception $e) {
169
+ $this->getResponse()->setBody($e->getMessage());
170
+ }
171
+ catch (Exception $e){
172
+ $this->getResponse()->setBody(Mage::helper('megamenu2')->__('Menu Item move error'));
173
+ Mage::logException($e);
174
+ }
175
+ }
176
+ /**
177
+ * Tree Action
178
+ * Retrieve menu item tree
179
+ * @access public
180
+ * @return void
181
+
182
+ */
183
+ public function treeAction(){
184
+ $menuitemId = (int) $this->getRequest()->getParam('id');
185
+ $menuitem = $this->_initMenuitem();
186
+ $block = $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_tree');
187
+ $root = $block->getRoot();
188
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(
189
+ array(
190
+ 'data' => $block->getTree(),
191
+ 'parameters' => array(
192
+ 'text'=> $block->buildNodeName($root),
193
+ 'draggable' => false,
194
+ 'allowDrop' => ($root->getIsVisible()) ? true : false,
195
+ 'id' => (int) $root->getId(),
196
+ 'expanded'=> (int) $block->getIsWasExpanded(),
197
+ 'menuitem_id' => (int) $menuitem->getId(),
198
+ 'root_visible'=> (int) $root->getIsVisible()
199
+ )
200
+ )
201
+ ));
202
+ }
203
+ /**
204
+ * Build response for refresh input element 'path' in form
205
+ * @access public
206
+ * @return void
207
+
208
+ */
209
+ public function refreshPathAction(){
210
+ if ($id = (int) $this->getRequest()->getParam('id')) {
211
+ $menuitem = Mage::getModel('megamenu2/menuitem')->load($id);
212
+ $this->getResponse()->setBody(
213
+ Mage::helper('core')->jsonEncode(array(
214
+ 'id' => $id,
215
+ 'path' => $menuitem->getPath(),
216
+ ))
217
+ );
218
+ }
219
+ }
220
+ /**
221
+ * Delete menu item action
222
+ * @access public
223
+ * @return void
224
+
225
+ */
226
+ public function deleteAction(){
227
+ if ($id = (int) $this->getRequest()->getParam('id')) {
228
+ try {
229
+ $menuitem = Mage::getModel('megamenu2/menuitem')->load($id);
230
+ Mage::getSingleton('admin/session')->setDeletedPath($menuitem->getPath());
231
+
232
+ $menuitem->delete();
233
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('The menu item has been deleted.'));
234
+ }
235
+ catch (Mage_Core_Exception $e){
236
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
237
+ $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
238
+ return;
239
+ }
240
+ catch (Exception $e){
241
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('An error occurred while trying to delete the menu item.'));
242
+ $this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
243
+ Mage::logException($e);
244
+ return;
245
+ }
246
+ }
247
+ $this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current'=>true, 'id'=>null)));
248
+ }
249
+ /**
250
+ * Check if admin has permissions to visit related pages
251
+ * @access protected
252
+ * @return boolean
253
+
254
+ */
255
+ protected function _isAllowed(){
256
+ return Mage::getSingleton('admin/session')->isAllowed('megamenu2/menuitem');
257
+ } /**
258
+ * wyisiwyg action
259
+ * @access public
260
+ * @return void
261
+
262
+ */
263
+ public function wysiwygAction(){
264
+ $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
265
+ $storeMediaUrl = Mage::app()->getStore(0)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
266
+
267
+ $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
268
+ 'editor_element_id' => $elementId,
269
+ 'store_id' => 0,
270
+ 'store_media_url' => $storeMediaUrl,
271
+ ));
272
+ $this->getResponse()->setBody($content->toHtml());
273
+ }
274
+ /**
275
+ * Menu Item save action
276
+ * @access public
277
+ * @return void
278
 
279
+ */
280
+ public function saveAction(){
281
+ if (!$menuitem = $this->_initMenuitem()) {
282
+ return;
283
+ }
284
+ $refreshTree = 'false';
285
+ if ($data = $this->getRequest()->getPost('menuitem')) {
286
+ $menuitem->addData($data);
287
+ if (!$menuitem->getId()) {
288
+ $parentId = $this->getRequest()->getParam('parent');
289
+ if (!$parentId) {
290
+ $parentId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
291
+ }
292
+ $parentMenuitem = Mage::getModel('megamenu2/menuitem')->load($parentId);
293
+ $menuitem->setPath($parentMenuitem->getPath());
294
+ }
295
+ try {
296
+ $menuitem->save();
297
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('The menu item has been saved.'));
298
+ $refreshTree = 'true';
299
+ }
300
+ catch (Exception $e){
301
+ $this->_getSession()->addError($e->getMessage())->setMenuitemData($data);
302
+ Mage::logException($e);
303
+ $refreshTree = 'false';
304
+ }
305
+ }
306
+ $url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => $menuitem->getId()));
307
+ $this->getResponse()->setBody(
308
+ '<script type="text/javascript">parent.updateContent("' . $url . '", {}, '.$refreshTree.');</script>'
309
+ );
310
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  }
app/code/community/JScriptz/MegaMenu2/data/jscriptz_megamenu2_setup/data-install-0.0.1.php CHANGED
@@ -1,235 +1,235 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /*
18
- * @category JScriptz
19
- * @package JScriptz_MegaMenu2
20
- */
21
- Mage::getModel('megamenu2/menuitem')
22
- ->load(1)
23
- ->setParentId(0)
24
- ->setPath(1)
25
- ->setLevel(0)
26
- ->setPosition(0)
27
- ->setChildrenCount(0)
28
- ->setLinktitle('ROOT')
29
- ->setInitialSetupFlag(true)
30
- ->save();
31
- Mage::getModel('megamenu2/menuitem')->load(2)->setLinktitle('Products')->setParentId(1)->setPath(1)->setLevel(0)->setPosition(1)->setChildrenCount(0)->setStatus(1)->save();
32
- Mage::getModel('megamenu2/menuitem')->load(3)->setLinktitle('jQuery Tabs')->setParentId(1)->setPath(1)->setLevel(0)->setPosition(2)->setChildrenCount(0)->setStatus(1)->setMenuhtml("<div class='dropdown_fullwidth mgmenu_tabs' style='display: none;'><!-- Begin Item Container -->
33
-
34
-
35
- <ul class='mgmenu_tabs_nav'>
36
-
37
- <li><a class='current' href='#section1'>Columns Grid</a></li>
38
- <li><a href='#section2'>Gallery</a></li>
39
- <li><a href='#section3'>About Us</a></li>
40
- <li><a href='#section4'>Informations</a></li>
41
-
42
- </ul>
43
-
44
- <div class='mgmenu_tabs_panels'><!-- Begin Panels Container -->
45
-
46
- <div id='section1'><!-- Begin Section 1 -->
47
-
48
- <div class='col_12'>
49
- <h4>This is a full width container</h4>
50
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris venenatis bibendum nunc dapibus posuere. Sed quis laoreet justo. Mauris eu massa turpis, at blandit elit. Mauris rutrum placerat libero, ut rhoncus leo euismod non. Aliquam urna felis, rutrum eu rhoncus at, elementum id est.</p>
51
- </div>
52
-
53
- <div class='col_10'>
54
- <h4>This is a five sixths container</h4>
55
- <p>Phasellus bibendum malesuada augue et adipiscing. Ut pretium vulputate elit quis iaculis. Nulla nisi justo, rhoncus in consectetur et, posuere sed urna. Aliquam urna felis, rutrum eu rhoncus at, elementum id est.</p>
56
- </div>
57
-
58
- <div class='col_2'>
59
- <h4>1/6</h4>
60
- <p>Fusce adipiscing consequat porta.</p>
61
- </div>
62
-
63
- <div class='col_8'>
64
- <h4>This is a two thirds container</h4>
65
- <p>Nunc scelerisque nisl id purus pretium cursus. Integer sed auctor elit. Pellentesque malesuada suscipit vehicula. Pellentesque malesuada suscipit vehicula.</p>
66
- </div>
67
-
68
- <div class='col_4'>
69
- <h4>1/3 container</h4>
70
- <p>Integer sed auctor elit. Pellentesque malesuada suscipit vehicula urna felis.</p>
71
- </div>
72
-
73
- <div class='col_6'>
74
- <h4>This is a half width container</h4>
75
- <p>Donec vel egestas lorem. Cras at purus turpis. Fusce a imperdiet mauris. Nunc lobortis neque magna, nec iaculis nisl.</p>
76
- </div>
77
-
78
- <div class='col_6'>
79
- <h4>This is a half width container</h4>
80
- <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras pharetra tincidunt.</p>
81
- </div>
82
-
83
- <div class='col_4'>
84
- <h4>1/3 container</h4>
85
- <p>Nunc in lectus nec erat adipiscing ultrices. Donec ac scelerisque neque.</p>
86
- </div>
87
-
88
- <div class='col_4'>
89
- <h4>1/3 container</h4>
90
- <p>Fusce sapien ante, convallis eu sodales malesuada, porttitor in nisi.</p>
91
- </div>
92
-
93
- <div class='col_4'>
94
- <h4>1/3 container</h4>
95
- <p>Mauris faucibus lectus accumsan, placerat tortor nec, volutpat mi.</p>
96
- </div>
97
-
98
- <div class='col_3'>
99
- <h4>1/4 container</h4>
100
- <p>Phasellus eleifend, eros at pharetra consequat.</p>
101
- </div>
102
-
103
- <div class='col_3'>
104
- <h4>1/4 container</h4>
105
- <p>Vestibulum sit amet est turpis convallis eu sodales.</p>
106
- </div>
107
-
108
- <div class='col_3'>
109
- <h4>1/4 container</h4>
110
- <p>Ut id fermentum nunc, non adipiscing diam.</p>
111
- </div>
112
-
113
- <div class='col_3'>
114
- <h4>1/4 container</h4>
115
- <p>Suspendisse eros faucibus, in luctus ante porta.</p>
116
- </div>
117
-
118
- </div><!-- End Section 1 -->
119
-
120
- <div class='mgmenu_tabs_hide' id='section2'><!-- Begin Section 2 -->
121
-
122
- <div class='col_3'>
123
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product01@2x.jpg'></a>
124
- <p class='img_description'>Image Description</p>
125
- </div>
126
-
127
- <div class='col_3'>
128
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product02@2x.jpg'></a>
129
- <p class='img_description'>Image Description</p>
130
- </div>
131
-
132
- <div class='col_3'>
133
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product03@2x.jpg'></a>
134
- <p class='img_description'>Image Description</p>
135
- </div>
136
-
137
- <div class='col_3'>
138
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product04@2x.jpg'></a>
139
- <p class='img_description'>Image Description</p>
140
- </div>
141
-
142
- <div class='col_3'>
143
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product05@2x.jpg'></a>
144
- <p class='img_description'>Image Description</p>
145
- </div>
146
-
147
- <div class='col_3'>
148
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product06@2x.jpg'></a>
149
- <p class='img_description'>Image Description</p>
150
- </div>
151
-
152
- <div class='col_3'>
153
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product07@2x.jpg'></a>
154
- <p class='img_description'>Image Description</p>
155
- </div>
156
-
157
- <div class='col_3'>
158
- <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product08@2x.jpg'></a>
159
- <p class='img_description'>Image Description</p>
160
- </div>
161
-
162
- </div><!-- End Section 2 -->
163
-
164
- <div class='mgmenu_tabs_hide' id='section3'><!-- Begin Section 3 -->
165
-
166
- <div class='col_12'>
167
-
168
- <h3>About Us</h3>
169
-
170
- <p>Fusce adipiscing consequat porta. Proin porta molestie mauris in imperdiet. Aliquam erat volutpat. Phasellus elementum accumsan bibendum. Nulla metus massa, sagittis non aliquam quis, mollis ac arcu. Praesent adipiscing mauris ultricies nisl egestas congue molestie nunc aliquet. In faucibus euismod sapien vitae consectetur. Integer nec ligula nisi, et pretium mi. In non porttitor tortor. Donec vel egestas lorem.</p>
171
-
172
- <blockquote>'This is a testimonial from a customer. Donec vel egestas lorem. Cras at purus turpis. Fusce a imperdiet mauris faucibus euismod sapien vitae consectetur.'</blockquote>
173
-
174
- <p>Nunc scelerisque nisl id purus pretium cursus. Integer sed auctor elit. Pellentesque malesuada suscipit vehicula. Nunc dapibus, eros nec posuere rhoncus, elit lorem elementum libero, nec tempor purus neque nec ipsum. Mauris bibendum lectus nec orci pharetra dignissim egestas interdum nibh. Nunc adipiscing felis quis nunc malesuada ac ultrices mi luctus. Maecenas a porta libero. In ut rhoncus quam. Sed nec vestibulum mauris.</p>
175
-
176
- <blockquote>'Phasellus elementum accumsan bibendum. Nulla metus massa, sagittis non aliquam quis, mollis ac arcu.'</blockquote>
177
-
178
- <p>Cras at purus turpis. Fusce a imperdiet mauris. Nunc lobortis neque magna, nec iaculis nisl. Quisque at leo erat, a pretium ante. Nunc vel pretium diam. Aliquam erat volutpat.</p>
179
-
180
- </div>
181
-
182
- </div><!-- End Section 3 -->
183
-
184
- <div class='mgmenu_tabs_hide' id='section4'><!-- Begin Section 4 -->
185
-
186
- <div class='col_12'>
187
-
188
- <h3>Additional Informations</h3>
189
-
190
- </div>
191
-
192
- <div class='col_6'>
193
-
194
- <p>Phasellus bibendum malesuada augue et adipiscing. Ut pretium vulputate elit quis iaculis. Nulla nisi justo, rhoncus in consectetur et, posuere sed urna. Aliquam urna felis, rutrum eu rhoncus at, elementum id est. Ut cursus elementum nisi eu elementum. Sed lacus purus.</p>
195
-
196
- <p>Integer nisl nunc, venenatis sagittis condimentum vel, tincidunt in est. Aenean felis sem, suscipit in posuere ultrices, placerat vel ipsum. Donec quis dolor turpis, non accumsan nisl. Ut lorem turpis, consequat eget condimentum quis, consectetur vitae enim. Proin ultricies ornare nibh eget tincidunt. Nulla id lectus est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras pharetra tincidunt erat sit amet sodales.</p>
197
-
198
- </div>
199
-
200
- <div class='col_6 col_border'>
201
-
202
- <p>Fusce adipiscing consequat porta. Proin porta molestie mauris in imperdiet. Aliquam erat volutpat. Phasellus elementum accumsan bibendum. Nulla metus massa, sagittis non aliquam quis, mollis ac arcu. Praesent adipiscing mauris ultricies nisl egestas congue molestie nunc aliquet. In faucibus euismod sapien vitae consectetur. Integer nec ligula nisi, et pretium mi. In non porttitor tortor. Donec vel egestas lorem. Cras at purus turpis. Fusce a imperdiet mauris.</p>
203
-
204
- <p>Nunc lobortis neque magna, nec iaculis nisl. Quisque at leo erat, a pretium ante. Ullamcorper ut aliquet ut, dictum nec odio. Donec sed odio ac lectus fermentum accumsan quis ut magna. Sed consectetur ipsum dolor, non laoreet lectus. Phasellus malesuada varius molestie.</p>
205
-
206
- </div>
207
-
208
- </div><!-- End Section 4 -->
209
-
210
- </div><!-- End Panels Container -->
211
-
212
-
213
- </div><!-- End Item Container -->
214
-
215
-
216
- </li><!-- End Item -->")->save();
217
-
218
-
219
- Mage::getModel('megamenu2/menuitem')->load(4)->setParentId(1)->setLinktitle('Video Example')->setPath(1)->setLevel(0)->setPosition(3)->setChildrenCount(0)->setStatus(1)->setMenuhtml("<div class='dropdown_container dropdown_5columns' style='display: none;'><!-- Begin Item Container -->
220
-
221
-
222
- <div class='col_12'>
223
-
224
- <h4>Awesome Video !</h4>
225
- <p>Ut ligula nibh, tincidunt et dolor vitae, bibendum lectus, et tempus lorem lobortis consectetur neque.</p>
226
- <div class='video_container'>
227
- <iframe src='http://player.vimeo.com/video/32001208?portrait=0&amp;badge=0'></iframe>
228
- </div>
229
-
230
- </div>
231
-
232
-
233
- </div><!-- End Item Container -->")->save();
234
-
235
- Mage::getModel('megamenu2/menuitem')->load(5)->setParentId(1)->setLinktitle('Link Example')->setLinkpath('http://www.gobingya.com')->setLinktarget('blank')->setPath(1)->setLevel(0)->setPosition(4)->setChildrenCount(0)->setStatus(1)->save();
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /*
18
+ * @category JScriptz
19
+ * @package JScriptz_MegaMenu2
20
+ */
21
+ Mage::getModel('megamenu2/menuitem')
22
+ ->load(1)
23
+ ->setParentId(0)
24
+ ->setPath(1)
25
+ ->setLevel(0)
26
+ ->setPosition(0)
27
+ ->setChildrenCount(0)
28
+ ->setLinktitle('ROOT')
29
+ ->setInitialSetupFlag(true)
30
+ ->save();
31
+ Mage::getModel('megamenu2/menuitem')->load(2)->setLinktitle('Products')->setParentId(1)->setPath(1)->setLevel(0)->setPosition(1)->setChildrenCount(0)->setStatus(1)->save();
32
+ Mage::getModel('megamenu2/menuitem')->load(3)->setLinktitle('jQuery Tabs')->setParentId(1)->setPath(1)->setLevel(0)->setPosition(2)->setChildrenCount(0)->setStatus(1)->setMenuhtml("<div class='dropdown_fullwidth mgmenu_tabs' style='display: none;'><!-- Begin Item Container -->
33
+
34
+
35
+ <ul class='mgmenu_tabs_nav'>
36
+
37
+ <li><a class='current' href='#section1'>Columns Grid</a></li>
38
+ <li><a href='#section2'>Gallery</a></li>
39
+ <li><a href='#section3'>About Us</a></li>
40
+ <li><a href='#section4'>Informations</a></li>
41
+
42
+ </ul>
43
+
44
+ <div class='mgmenu_tabs_panels'><!-- Begin Panels Container -->
45
+
46
+ <div id='section1'><!-- Begin Section 1 -->
47
+
48
+ <div class='col_12'>
49
+ <h4>This is a full width container</h4>
50
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris venenatis bibendum nunc dapibus posuere. Sed quis laoreet justo. Mauris eu massa turpis, at blandit elit. Mauris rutrum placerat libero, ut rhoncus leo euismod non. Aliquam urna felis, rutrum eu rhoncus at, elementum id est.</p>
51
+ </div>
52
+
53
+ <div class='col_10'>
54
+ <h4>This is a five sixths container</h4>
55
+ <p>Phasellus bibendum malesuada augue et adipiscing. Ut pretium vulputate elit quis iaculis. Nulla nisi justo, rhoncus in consectetur et, posuere sed urna. Aliquam urna felis, rutrum eu rhoncus at, elementum id est.</p>
56
+ </div>
57
+
58
+ <div class='col_2'>
59
+ <h4>1/6</h4>
60
+ <p>Fusce adipiscing consequat porta.</p>
61
+ </div>
62
+
63
+ <div class='col_8'>
64
+ <h4>This is a two thirds container</h4>
65
+ <p>Nunc scelerisque nisl id purus pretium cursus. Integer sed auctor elit. Pellentesque malesuada suscipit vehicula. Pellentesque malesuada suscipit vehicula.</p>
66
+ </div>
67
+
68
+ <div class='col_4'>
69
+ <h4>1/3 container</h4>
70
+ <p>Integer sed auctor elit. Pellentesque malesuada suscipit vehicula urna felis.</p>
71
+ </div>
72
+
73
+ <div class='col_6'>
74
+ <h4>This is a half width container</h4>
75
+ <p>Donec vel egestas lorem. Cras at purus turpis. Fusce a imperdiet mauris. Nunc lobortis neque magna, nec iaculis nisl.</p>
76
+ </div>
77
+
78
+ <div class='col_6'>
79
+ <h4>This is a half width container</h4>
80
+ <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras pharetra tincidunt.</p>
81
+ </div>
82
+ <div style='clear:both'></div>
83
+ <div class='col_4'>
84
+ <h4>1/3 container</h4>
85
+ <p>Nunc in lectus nec erat adipiscing ultrices. Donec ac scelerisque neque.</p>
86
+ </div>
87
+
88
+ <div class='col_4'>
89
+ <h4>1/3 container</h4>
90
+ <p>Fusce sapien ante, convallis eu sodales malesuada, porttitor in nisi.</p>
91
+ </div>
92
+
93
+ <div class='col_4'>
94
+ <h4>1/3 container</h4>
95
+ <p>Mauris faucibus lectus accumsan, placerat tortor nec, volutpat mi.</p>
96
+ </div>
97
+
98
+ <div class='col_3'>
99
+ <h4>1/4 container</h4>
100
+ <p>Phasellus eleifend, eros at pharetra consequat.</p>
101
+ </div>
102
+
103
+ <div class='col_3'>
104
+ <h4>1/4 container</h4>
105
+ <p>Vestibulum sit amet est turpis convallis eu sodales.</p>
106
+ </div>
107
+
108
+ <div class='col_3'>
109
+ <h4>1/4 container</h4>
110
+ <p>Ut id fermentum nunc, non adipiscing diam.</p>
111
+ </div>
112
+
113
+ <div class='col_3'>
114
+ <h4>1/4 container</h4>
115
+ <p>Suspendisse eros faucibus, in luctus ante porta.</p>
116
+ </div>
117
+
118
+ </div><!-- End Section 1 -->
119
+
120
+ <div class='mgmenu_tabs_hide' id='section2'><!-- Begin Section 2 -->
121
+
122
+ <div class='col_3'>
123
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product01@2x.jpg'></a>
124
+ <p class='img_description'>Image Description</p>
125
+ </div>
126
+
127
+ <div class='col_3'>
128
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product02@2x.jpg'></a>
129
+ <p class='img_description'>Image Description</p>
130
+ </div>
131
+
132
+ <div class='col_3'>
133
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product03@2x.jpg'></a>
134
+ <p class='img_description'>Image Description</p>
135
+ </div>
136
+
137
+ <div class='col_3'>
138
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product04@2x.jpg'></a>
139
+ <p class='img_description'>Image Description</p>
140
+ </div>
141
+
142
+ <div class='col_3'>
143
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product05@2x.jpg'></a>
144
+ <p class='img_description'>Image Description</p>
145
+ </div>
146
+
147
+ <div class='col_3'>
148
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product06@2x.jpg'></a>
149
+ <p class='img_description'>Image Description</p>
150
+ </div>
151
+
152
+ <div class='col_3'>
153
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product07@2x.jpg'></a>
154
+ <p class='img_description'>Image Description</p>
155
+ </div>
156
+
157
+ <div class='col_3'>
158
+ <a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product08@2x.jpg'></a>
159
+ <p class='img_description'>Image Description</p>
160
+ </div>
161
+
162
+ </div><!-- End Section 2 -->
163
+
164
+ <div class='mgmenu_tabs_hide' id='section3'><!-- Begin Section 3 -->
165
+
166
+ <div class='col_12'>
167
+
168
+ <h3>About Us</h3>
169
+
170
+ <p>Fusce adipiscing consequat porta. Proin porta molestie mauris in imperdiet. Aliquam erat volutpat. Phasellus elementum accumsan bibendum. Nulla metus massa, sagittis non aliquam quis, mollis ac arcu. Praesent adipiscing mauris ultricies nisl egestas congue molestie nunc aliquet. In faucibus euismod sapien vitae consectetur. Integer nec ligula nisi, et pretium mi. In non porttitor tortor. Donec vel egestas lorem.</p>
171
+
172
+ <blockquote>'This is a testimonial from a customer. Donec vel egestas lorem. Cras at purus turpis. Fusce a imperdiet mauris faucibus euismod sapien vitae consectetur.'</blockquote>
173
+
174
+ <p>Nunc scelerisque nisl id purus pretium cursus. Integer sed auctor elit. Pellentesque malesuada suscipit vehicula. Nunc dapibus, eros nec posuere rhoncus, elit lorem elementum libero, nec tempor purus neque nec ipsum. Mauris bibendum lectus nec orci pharetra dignissim egestas interdum nibh. Nunc adipiscing felis quis nunc malesuada ac ultrices mi luctus. Maecenas a porta libero. In ut rhoncus quam. Sed nec vestibulum mauris.</p>
175
+
176
+ <blockquote>'Phasellus elementum accumsan bibendum. Nulla metus massa, sagittis non aliquam quis, mollis ac arcu.'</blockquote>
177
+
178
+ <p>Cras at purus turpis. Fusce a imperdiet mauris. Nunc lobortis neque magna, nec iaculis nisl. Quisque at leo erat, a pretium ante. Nunc vel pretium diam. Aliquam erat volutpat.</p>
179
+
180
+ </div>
181
+
182
+ </div><!-- End Section 3 -->
183
+
184
+ <div class='mgmenu_tabs_hide' id='section4'><!-- Begin Section 4 -->
185
+
186
+ <div class='col_12'>
187
+
188
+ <h3>Additional Informations</h3>
189
+
190
+ </div>
191
+
192
+ <div class='col_6'>
193
+
194
+ <p>Phasellus bibendum malesuada augue et adipiscing. Ut pretium vulputate elit quis iaculis. Nulla nisi justo, rhoncus in consectetur et, posuere sed urna. Aliquam urna felis, rutrum eu rhoncus at, elementum id est. Ut cursus elementum nisi eu elementum. Sed lacus purus.</p>
195
+
196
+ <p>Integer nisl nunc, venenatis sagittis condimentum vel, tincidunt in est. Aenean felis sem, suscipit in posuere ultrices, placerat vel ipsum. Donec quis dolor turpis, non accumsan nisl. Ut lorem turpis, consequat eget condimentum quis, consectetur vitae enim. Proin ultricies ornare nibh eget tincidunt. Nulla id lectus est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras pharetra tincidunt erat sit amet sodales.</p>
197
+
198
+ </div>
199
+
200
+ <div class='col_6 col_border'>
201
+
202
+ <p>Fusce adipiscing consequat porta. Proin porta molestie mauris in imperdiet. Aliquam erat volutpat. Phasellus elementum accumsan bibendum. Nulla metus massa, sagittis non aliquam quis, mollis ac arcu. Praesent adipiscing mauris ultricies nisl egestas congue molestie nunc aliquet. In faucibus euismod sapien vitae consectetur. Integer nec ligula nisi, et pretium mi. In non porttitor tortor. Donec vel egestas lorem. Cras at purus turpis. Fusce a imperdiet mauris.</p>
203
+
204
+ <p>Nunc lobortis neque magna, nec iaculis nisl. Quisque at leo erat, a pretium ante. Ullamcorper ut aliquet ut, dictum nec odio. Donec sed odio ac lectus fermentum accumsan quis ut magna. Sed consectetur ipsum dolor, non laoreet lectus. Phasellus malesuada varius molestie.</p>
205
+
206
+ </div>
207
+
208
+ </div><!-- End Section 4 -->
209
+
210
+ </div><!-- End Panels Container -->
211
+
212
+
213
+ </div><!-- End Item Container -->
214
+
215
+
216
+ </li><!-- End Item -->")->save();
217
+
218
+
219
+ Mage::getModel('megamenu2/menuitem')->load(4)->setParentId(1)->setLinktitle('Video Example')->setPath(1)->setLevel(0)->setPosition(3)->setChildrenCount(0)->setStatus(1)->setMenuhtml("<div class='dropdown_container dropdown_5columns' style='display: none;'><!-- Begin Item Container -->
220
+
221
+
222
+ <div class='col_12'>
223
+
224
+ <h4>Awesome Video !</h4>
225
+ <p>Ut ligula nibh, tincidunt et dolor vitae, bibendum lectus, et tempus lorem lobortis consectetur neque.</p>
226
+ <div class='video_container'>
227
+ <iframe src='http://player.vimeo.com/video/32001208?portrait=0&amp;badge=0'></iframe>
228
+ </div>
229
+
230
+ </div>
231
+
232
+
233
+ </div><!-- End Item Container -->")->save();
234
+
235
+ Mage::getModel('megamenu2/menuitem')->load(5)->setParentId(1)->setLinktitle('Link Example')->setLinkpath('http://www.gobingya.com')->setLinktarget('blank')->setPath(1)->setLevel(0)->setPosition(4)->setChildrenCount(0)->setStatus(1)->save();
app/code/community/JScriptz/MegaMenu2/etc/adminhtml.xml CHANGED
@@ -1,63 +1,63 @@
1
- <?xml version="1.0"?>
2
  <!--
3
  /**
4
- * JScriptz_MegaMenu2 extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the MIT License
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/mit-license.php
12
- *
13
- * @category JScriptz
14
- * @package JScriptz_MegaMenu2
15
- * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
- -->
19
- <config>
20
- <acl>
21
- <resources>
22
- <admin>
23
- <children>
24
- <system>
25
- <children>
26
- <config>
27
- <children>
28
- <megamenu2 translate="title" module="megamenu2">
29
- <title>MegaMenu2</title>
30
- </megamenu2>
31
- </children>
32
- </config>
33
- </children>
34
- </system>
35
- <megamenu2 translate="title" module="megamenu2">
36
- <title>MegaMenu2</title>
37
- <children>
38
- <menuitem translate="title" module="megamenu2">
39
- <title>Menu Items</title>
40
- </menuitem>
41
- </children>
42
- </megamenu2>
43
- </children>
44
- </admin>
45
- </resources>
46
- </acl>
47
- <menu>
48
- <megamenu2 translate="title" module="megamenu2">
49
- <title>MegaMenu2</title>
50
- <sort_order>81</sort_order>
51
- <depends>
52
- <module>JScriptz_MegaMenu2</module>
53
- </depends>
54
- <children>
55
- <menuitem translate="title" module="megamenu2">
56
- <title>Menu Items</title>
57
- <action>adminhtml/MegaMenu2_menuitem</action>
58
- <sort_order>0</sort_order>
59
- </menuitem>
60
- </children>
61
- </megamenu2>
62
- </menu>
63
  </config>
1
+ <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * JScriptz_MegaMenu2 extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category JScriptz
14
+ * @package JScriptz_MegaMenu2
15
+ * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <megamenu2 translate="title" module="megamenu2">
29
+ <title>MegaMenu2</title>
30
+ </megamenu2>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <megamenu2 translate="title" module="megamenu2">
36
+ <title>MegaMenu2</title>
37
+ <children>
38
+ <menuitem translate="title" module="megamenu2">
39
+ <title>Menu Items</title>
40
+ </menuitem>
41
+ </children>
42
+ </megamenu2>
43
+ </children>
44
+ </admin>
45
+ </resources>
46
+ </acl>
47
+ <menu>
48
+ <megamenu2 translate="title" module="megamenu2">
49
+ <title>MegaMenu2</title>
50
+ <sort_order>81</sort_order>
51
+ <depends>
52
+ <module>JScriptz_MegaMenu2</module>
53
+ </depends>
54
+ <children>
55
+ <menuitem translate="title" module="megamenu2">
56
+ <title>Menu Items</title>
57
+ <action>adminhtml/MegaMenu2_menuitem</action>
58
+ <sort_order>0</sort_order>
59
+ </menuitem>
60
+ </children>
61
+ </megamenu2>
62
+ </menu>
63
  </config>
app/code/community/JScriptz/MegaMenu2/etc/config.xml CHANGED
@@ -1,110 +1,110 @@
1
- <?xml version="1.0"?>
2
  <!--
3
  /**
4
- * JScriptz_MegaMenu2 extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the MIT License
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/mit-license.php
12
- *
13
- * @category JScriptz
14
- * @package JScriptz_MegaMenu2
15
- * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
- -->
19
- <config>
20
- <modules>
21
- <JScriptz_MegaMenu2>
22
- <version>1.8.0.0</version>
23
- </JScriptz_MegaMenu2>
24
- </modules>
25
- <global>
26
- <resources>
27
- <jscriptz_megamenu2_setup>
28
- <setup>
29
- <module>JScriptz_MegaMenu2</module>
30
- <class>JScriptz_MegaMenu2_Model_Resource_Setup</class>
31
- </setup>
32
- </jscriptz_megamenu2_setup>
33
- </resources>
34
- <blocks>
35
- <megamenu2>
36
- <class>JScriptz_MegaMenu2_Block</class>
37
- </megamenu2>
38
- <page>
39
- <rewrite>
40
- <html_topmenu>JScriptz_MegaMenu2_Block_Html_Topmenu</html_topmenu>
41
- </rewrite>
42
- </page>
43
- </blocks>
44
- <helpers>
45
- <megamenu2>
46
- <class>JScriptz_MegaMenu2_Helper</class>
47
- </megamenu2>
48
- </helpers>
49
- <models>
50
- <megamenu2>
51
- <class>JScriptz_MegaMenu2_Model</class>
52
- <resourceModel>megamenu2_resource</resourceModel>
53
- </megamenu2>
54
- <megamenu2_resource>
55
- <class>JScriptz_MegaMenu2_Model_Resource</class>
56
- <entities>
57
- <menuitem>
58
- <table>megamenu2_menuitem</table>
59
- </menuitem>
60
- <menuitem_store>
61
- <table>megamenu2_menuitem_store</table>
62
- </menuitem_store>
63
- </entities>
64
- </megamenu2_resource>
65
- </models>
66
-
67
- </global>
68
- <frontend>
69
- <layout>
70
- <updates>
71
- <jscriptz_megamenu2>
72
- <file>jscriptz_megamenu2.xml</file>
73
- </jscriptz_megamenu2>
74
- </updates>
75
- </layout>
76
- </frontend>
77
- <adminhtml>
78
- <layout>
79
- <updates>
80
- <jscriptz_megamenu2>
81
- <file>jscriptz_megamenu2.xml</file>
82
- </jscriptz_megamenu2>
83
- </updates>
84
- </layout>
85
- <translate>
86
- <modules>
87
- <JScriptz_MegaMenu2>
88
- <files>
89
- <default>JScriptz_MegaMenu2.csv</default>
90
- </files>
91
- </JScriptz_MegaMenu2>
92
- </modules>
93
- </translate>
94
- </adminhtml>
95
- <admin>
96
- <routers>
97
- <adminhtml>
98
- <args>
99
- <modules>
100
- <JScriptz_MegaMenu2 before="Mage_Adminhtml">JScriptz_MegaMenu2_Adminhtml</JScriptz_MegaMenu2>
101
- </modules>
102
- </args>
103
- </adminhtml>
104
- </routers>
105
- </admin>
106
- <default>
107
- <megamenu2>
108
- </megamenu2>
109
- </default>
110
  </config>
1
+ <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * JScriptz_MegaMenu2 extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category JScriptz
14
+ * @package JScriptz_MegaMenu2
15
+ * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <JScriptz_MegaMenu2>
22
+ <version>1.8.0.0</version>
23
+ </JScriptz_MegaMenu2>
24
+ </modules>
25
+ <global>
26
+ <resources>
27
+ <jscriptz_megamenu2_setup>
28
+ <setup>
29
+ <module>JScriptz_MegaMenu2</module>
30
+ <class>JScriptz_MegaMenu2_Model_Resource_Setup</class>
31
+ </setup>
32
+ </jscriptz_megamenu2_setup>
33
+ </resources>
34
+ <blocks>
35
+ <megamenu2>
36
+ <class>JScriptz_MegaMenu2_Block</class>
37
+ </megamenu2>
38
+ <page>
39
+ <rewrite>
40
+ <html_topmenu>JScriptz_MegaMenu2_Block_Html_Topmenu</html_topmenu>
41
+ </rewrite>
42
+ </page>
43
+ </blocks>
44
+ <helpers>
45
+ <megamenu2>
46
+ <class>JScriptz_MegaMenu2_Helper</class>
47
+ </megamenu2>
48
+ </helpers>
49
+ <models>
50
+ <megamenu2>
51
+ <class>JScriptz_MegaMenu2_Model</class>
52
+ <resourceModel>megamenu2_resource</resourceModel>
53
+ </megamenu2>
54
+ <megamenu2_resource>
55
+ <class>JScriptz_MegaMenu2_Model_Resource</class>
56
+ <entities>
57
+ <menuitem>
58
+ <table>megamenu2_menuitem</table>
59
+ </menuitem>
60
+ <menuitem_store>
61
+ <table>megamenu2_menuitem_store</table>
62
+ </menuitem_store>
63
+ </entities>
64
+ </megamenu2_resource>
65
+ </models>
66
+
67
+ </global>
68
+ <frontend>
69
+ <layout>
70
+ <updates>
71
+ <jscriptz_megamenu2>
72
+ <file>jscriptz_megamenu2.xml</file>
73
+ </jscriptz_megamenu2>
74
+ </updates>
75
+ </layout>
76
+ </frontend>
77
+ <adminhtml>
78
+ <layout>
79
+ <updates>
80
+ <jscriptz_megamenu2>
81
+ <file>jscriptz_megamenu2.xml</file>
82
+ </jscriptz_megamenu2>
83
+ </updates>
84
+ </layout>
85
+ <translate>
86
+ <modules>
87
+ <JScriptz_MegaMenu2>
88
+ <files>
89
+ <default>JScriptz_MegaMenu2.csv</default>
90
+ </files>
91
+ </JScriptz_MegaMenu2>
92
+ </modules>
93
+ </translate>
94
+ </adminhtml>
95
+ <admin>
96
+ <routers>
97
+ <adminhtml>
98
+ <args>
99
+ <modules>
100
+ <JScriptz_MegaMenu2 before="Mage_Adminhtml">JScriptz_MegaMenu2_Adminhtml</JScriptz_MegaMenu2>
101
+ </modules>
102
+ </args>
103
+ </adminhtml>
104
+ </routers>
105
+ </admin>
106
+ <default>
107
+ <megamenu2>
108
+ </megamenu2>
109
+ </default>
110
  </config>
app/code/community/JScriptz/MegaMenu2/sql/jscriptz_megamenu2_setup/install-0.0.1.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- /**
18
- * MegaMenu2 module install script
19
- *
20
- * @category JScriptz
21
- * @package JScriptz_MegaMenu2
22
- */
23
- $this->startSetup();
24
- $table = $this->getConnection()
25
- ->newTable($this->getTable('megamenu2/menuitem'))
26
- ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
27
- 'identity' => true,
28
- 'nullable' => false,
29
- 'primary' => true,
30
- ), 'Menu Item ID')
31
  ->addColumn('linktitle', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
32
  'nullable' => false,
33
  ), 'Link Title')
@@ -66,28 +66,28 @@ $table = $this->getConnection()
66
  ->addColumn('children_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
67
  'unsigned' => true,
68
  ), 'Children count')
69
-
70
- ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
71
- ), 'Menu Item Creation Time')
72
- ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
73
- ), 'Menu Item Modification Time')
74
- ->setComment('Menu Item Table');
75
- $this->getConnection()->createTable($table);
76
-
77
- $table = $this->getConnection()
78
- ->newTable($this->getTable('megamenu2/menuitem_store'))
79
- ->addColumn('menuitem_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
80
- 'nullable' => false,
81
- 'primary' => true,
82
- ), 'Menu Item ID')
83
- ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
84
- 'unsigned' => true,
85
- 'nullable' => false,
86
- 'primary' => true,
87
- ), 'Store ID')
88
- ->addIndex($this->getIdxName('megamenu2/menuitem_store', array('store_id')), array('store_id'))
89
- ->addForeignKey($this->getFkName('megamenu2/menuitem_store', 'menuitem_id', 'megamenu2/menuitem', 'entity_id'), 'menuitem_id', $this->getTable('megamenu2/menuitem'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
90
- ->addForeignKey($this->getFkName('megamenu2/menuitem_store', 'store_id', 'core/store', 'store_id'), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
91
- ->setComment('Menu Items To Store Linkage Table');
92
- $this->getConnection()->createTable($table);
93
  $this->endSetup();
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * MegaMenu2 module install script
19
+ *
20
+ * @category JScriptz
21
+ * @package JScriptz_MegaMenu2
22
+ */
23
+ $this->startSetup();
24
+ $table = $this->getConnection()
25
+ ->newTable($this->getTable('megamenu2/menuitem'))
26
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
27
+ 'identity' => true,
28
+ 'nullable' => false,
29
+ 'primary' => true,
30
+ ), 'Menu Item ID')
31
  ->addColumn('linktitle', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
32
  'nullable' => false,
33
  ), 'Link Title')
66
  ->addColumn('children_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
67
  'unsigned' => true,
68
  ), 'Children count')
69
+
70
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
71
+ ), 'Menu Item Creation Time')
72
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
73
+ ), 'Menu Item Modification Time')
74
+ ->setComment('Menu Item Table');
75
+ $this->getConnection()->createTable($table);
76
+
77
+ $table = $this->getConnection()
78
+ ->newTable($this->getTable('megamenu2/menuitem_store'))
79
+ ->addColumn('menuitem_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
80
+ 'nullable' => false,
81
+ 'primary' => true,
82
+ ), 'Menu Item ID')
83
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
84
+ 'unsigned' => true,
85
+ 'nullable' => false,
86
+ 'primary' => true,
87
+ ), 'Store ID')
88
+ ->addIndex($this->getIdxName('megamenu2/menuitem_store', array('store_id')), array('store_id'))
89
+ ->addForeignKey($this->getFkName('megamenu2/menuitem_store', 'menuitem_id', 'megamenu2/menuitem', 'entity_id'), 'menuitem_id', $this->getTable('megamenu2/menuitem'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
90
+ ->addForeignKey($this->getFkName('megamenu2/menuitem_store', 'store_id', 'core/store', 'store_id'), 'store_id', $this->getTable('core/store'), 'store_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
91
+ ->setComment('Menu Items To Store Linkage Table');
92
+ $this->getConnection()->createTable($table);
93
  $this->endSetup();
app/design/adminhtml/default/default/layout/jscriptz_megamenu2.xml CHANGED
@@ -1,32 +1,32 @@
1
- <?xml version="1.0"?>
2
  <!--
3
  /**
4
- * JScriptz_MegaMenu2 extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the MIT License
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/mit-license.php
12
- *
13
- * @category JScriptz
14
- * @package JScriptz_MegaMenu2
15
- * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
- -->
19
- <layout>
20
- <adminhtml_megamenu2_menuitem_edit>
21
- <update handle="editor"/>
22
- <reference name="left">
23
- <block name="menuitem.tree" type="megamenu2/adminhtml_menuitem_tree" />
24
- </reference>
25
- <reference name="content">
26
- <block name="menuitem.edit" type="megamenu2/adminhtml_menuitem_edit" template="jscriptz_megamenu2/menuitem/edit.phtml" />
27
- </reference>
28
- <reference name="js">
29
- <block type="core/template" template="catalog/wysiwyg/js.phtml" name="catalog.wysiwyg.js" />
30
- </reference>
31
- </adminhtml_megamenu2_menuitem_edit>
32
  </layout>
1
+ <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * JScriptz_MegaMenu2 extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category JScriptz
14
+ * @package JScriptz_MegaMenu2
15
+ * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
+ -->
19
+ <layout>
20
+ <adminhtml_megamenu2_menuitem_edit>
21
+ <update handle="editor"/>
22
+ <reference name="left">
23
+ <block name="menuitem.tree" type="megamenu2/adminhtml_menuitem_tree" />
24
+ </reference>
25
+ <reference name="content">
26
+ <block name="menuitem.edit" type="megamenu2/adminhtml_menuitem_edit" template="jscriptz_megamenu2/menuitem/edit.phtml" />
27
+ </reference>
28
+ <reference name="js">
29
+ <block type="core/template" template="catalog/wysiwyg/js.phtml" name="catalog.wysiwyg.js" />
30
+ </reference>
31
+ </adminhtml_megamenu2_menuitem_edit>
32
  </layout>
app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/edit.phtml CHANGED
@@ -1,151 +1,151 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- ?>
18
- <div id="menuitem-edit-container" class="category-content">
19
- <?php echo $this->getChildHtml('form') ?>
20
- </div>
21
- <script type="text/javascript">
22
- //<![CDATA[
23
- function menuitemReset(url,useAjax){
24
- if(useAjax){
25
- var params = {active_tab_id:false};
26
- updateContent(url, params);
27
- }
28
- else{
29
- location.href = url;
30
- }
31
- }
32
- function menuitemDelete(url, useAjax, menuitemId) {
33
- if (confirm('<?php echo Mage::helper('megamenu2')->__('Are you sure?') ?>')){
34
- if (useAjax){
35
- tree.nodeForDelete = menuitemId;
36
- updateContent(url, {}, true);
37
- }
38
- else {
39
- location.href = url;
40
- }
41
- }
42
- }
43
- function updateContent(url, params, refreshTree) {
44
- if (!params) {
45
- params = {};
46
- }
47
- if (!params.form_key) {
48
- params.form_key = FORM_KEY;
49
- }
50
- toolbarToggle.stop();
51
- var menuitemContainer = $('menuitem-edit-container');
52
- var messagesContainer = $('messages');
53
- var thisObj = this;
54
- new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
55
- parameters: params,
56
- evalScripts: true,
57
- onComplete: function () {
58
- setTimeout(function() {
59
- try {
60
- if (refreshTree) {
61
- thisObj.refreshTreeArea();
62
- }
63
- toolbarToggle.start();
64
- }
65
- catch (e) {
66
- alert(e.message);
67
- };
68
- }, 25);
69
- },
70
- onSuccess: function(transport) {
71
- try {
72
- if (transport.responseText.isJSON()) {
73
- var response = transport.responseText.evalJSON();
74
- var needUpdate = true;
75
- if (response.error) {
76
- alert(response.message);
77
- needUpdate = false;
78
- }
79
- if(response.ajaxExpired && response.ajaxRedirect) {
80
- setLocation(response.ajaxRedirect);
81
- needUpdate = false;
82
- }
83
- if (needUpdate){
84
- if (response.content){
85
- $(menuitemContainer).update(response.content);
86
- }
87
- if (response.messages){
88
- $(messagesContainer).update(response.messages);
89
- }
90
- }
91
- }
92
- else {
93
- $(menuitemContainer).update(transport.responseText);
94
- }
95
- }
96
- catch (e) {
97
- $(menuitemContainer).update(transport.responseText);
98
- }
99
- }
100
- });
101
- }
102
- function refreshTreeArea(transport){
103
- if (tree && window.editingMenuitemBreadcrumbs) {
104
- if (tree.nodeForDelete) {
105
- var node = tree.getNodeById(tree.nodeForDelete);
106
- tree.nodeForDelete = false;
107
- if (node) {
108
- node.parentNode.removeChild(node);
109
- tree.currentNodeId = false;
110
- }
111
- }
112
- else if (tree.addNodeTo) {
113
- var parent = tree.getNodeById(tree.addNodeTo);
114
- tree.addNodeTo = false;
115
- if (parent) {
116
- var node = new Ext.tree.AsyncTreeNode(editingMenuitemBreadcrumbs[editingMenuitemBreadcrumbs.length - 1]);
117
- node.loaded = true;
118
- tree.currentNodeId = node.id;
119
- parent.appendChild(node);
120
- if (parent.expanded) {
121
- tree.selectCurrentNode();
122
- }
123
- else {
124
- var timer;
125
- parent.expand();
126
- var f = function(){
127
- if(parent.expanded){
128
- clearInterval(timer);
129
- tree.selectCurrentNode();
130
- }
131
- };
132
- timer = setInterval(f, 200);
133
- }
134
- }
135
- }
136
- for (var i = 0; i < editingMenuitemBreadcrumbs.length; i++) {
137
- var node = tree.getNodeById(editingMenuitemBreadcrumbs[i].id);
138
- if (node) {
139
- node.setText(editingMenuitemBreadcrumbs[i].text);
140
- }
141
- }
142
- }
143
- }
144
- function displayLoadingMask(){
145
- var loaderArea = $$('#html-body .wrapper')[0];
146
- Position.clone($(loaderArea), $('loading-mask'), {offsetLeft:-2});
147
- toggleSelectsUnderBlock($('loading-mask'), false);
148
- Element.show('loading-mask');
149
- }
150
- //]]>
151
  </script>
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div id="menuitem-edit-container" class="category-content">
19
+ <?php echo $this->getChildHtml('form') ?>
20
+ </div>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ function menuitemReset(url,useAjax){
24
+ if(useAjax){
25
+ var params = {active_tab_id:false};
26
+ updateContent(url, params);
27
+ }
28
+ else{
29
+ location.href = url;
30
+ }
31
+ }
32
+ function menuitemDelete(url, useAjax, menuitemId) {
33
+ if (confirm('<?php echo Mage::helper('megamenu2')->__('Are you sure?') ?>')){
34
+ if (useAjax){
35
+ tree.nodeForDelete = menuitemId;
36
+ updateContent(url, {}, true);
37
+ }
38
+ else {
39
+ location.href = url;
40
+ }
41
+ }
42
+ }
43
+ function updateContent(url, params, refreshTree) {
44
+ if (!params) {
45
+ params = {};
46
+ }
47
+ if (!params.form_key) {
48
+ params.form_key = FORM_KEY;
49
+ }
50
+ toolbarToggle.stop();
51
+ var menuitemContainer = $('menuitem-edit-container');
52
+ var messagesContainer = $('messages');
53
+ var thisObj = this;
54
+ new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
55
+ parameters: params,
56
+ evalScripts: true,
57
+ onComplete: function () {
58
+ setTimeout(function() {
59
+ try {
60
+ if (refreshTree) {
61
+ thisObj.refreshTreeArea();
62
+ }
63
+ toolbarToggle.start();
64
+ }
65
+ catch (e) {
66
+ alert(e.message);
67
+ };
68
+ }, 25);
69
+ },
70
+ onSuccess: function(transport) {
71
+ try {
72
+ if (transport.responseText.isJSON()) {
73
+ var response = transport.responseText.evalJSON();
74
+ var needUpdate = true;
75
+ if (response.error) {
76
+ alert(response.message);
77
+ needUpdate = false;
78
+ }
79
+ if(response.ajaxExpired && response.ajaxRedirect) {
80
+ setLocation(response.ajaxRedirect);
81
+ needUpdate = false;
82
+ }
83
+ if (needUpdate){
84
+ if (response.content){
85
+ $(menuitemContainer).update(response.content);
86
+ }
87
+ if (response.messages){
88
+ $(messagesContainer).update(response.messages);
89
+ }
90
+ }
91
+ }
92
+ else {
93
+ $(menuitemContainer).update(transport.responseText);
94
+ }
95
+ }
96
+ catch (e) {
97
+ $(menuitemContainer).update(transport.responseText);
98
+ }
99
+ }
100
+ });
101
+ }
102
+ function refreshTreeArea(transport){
103
+ if (tree && window.editingMenuitemBreadcrumbs) {
104
+ if (tree.nodeForDelete) {
105
+ var node = tree.getNodeById(tree.nodeForDelete);
106
+ tree.nodeForDelete = false;
107
+ if (node) {
108
+ node.parentNode.removeChild(node);
109
+ tree.currentNodeId = false;
110
+ }
111
+ }
112
+ else if (tree.addNodeTo) {
113
+ var parent = tree.getNodeById(tree.addNodeTo);
114
+ tree.addNodeTo = false;
115
+ if (parent) {
116
+ var node = new Ext.tree.AsyncTreeNode(editingMenuitemBreadcrumbs[editingMenuitemBreadcrumbs.length - 1]);
117
+ node.loaded = true;
118
+ tree.currentNodeId = node.id;
119
+ parent.appendChild(node);
120
+ if (parent.expanded) {
121
+ tree.selectCurrentNode();
122
+ }
123
+ else {
124
+ var timer;
125
+ parent.expand();
126
+ var f = function(){
127
+ if(parent.expanded){
128
+ clearInterval(timer);
129
+ tree.selectCurrentNode();
130
+ }
131
+ };
132
+ timer = setInterval(f, 200);
133
+ }
134
+ }
135
+ }
136
+ for (var i = 0; i < editingMenuitemBreadcrumbs.length; i++) {
137
+ var node = tree.getNodeById(editingMenuitemBreadcrumbs[i].id);
138
+ if (node) {
139
+ node.setText(editingMenuitemBreadcrumbs[i].text);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ function displayLoadingMask(){
145
+ var loaderArea = $$('#html-body .wrapper')[0];
146
+ Position.clone($(loaderArea), $('loading-mask'), {offsetLeft:-2});
147
+ toggleSelectsUnderBlock($('loading-mask'), false);
148
+ Element.show('loading-mask');
149
+ }
150
+ //]]>
151
  </script>
app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/edit/form.phtml CHANGED
@@ -1,160 +1,160 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- ?>
18
- <div class="content-header">
19
- <h3 class="icon-head head-categories">
20
- <?php echo $this->htmlEscape($this->getHeader()) . ($this->getMenuitemId() ? ' (' . Mage::helper('megamenu2')->__('ID: %s', $this->getMenuitemId()) . ')' : '') ?>
21
- </h3>
22
- <p class="content-buttons form-buttons">
23
- <?php echo $this->getResetButtonHtml() ?>
24
- <?php if($this->getMenuitemId()): ?>
25
- <?php echo $this->getDeleteButtonHtml() ?>
26
- <?php endif; ?>
27
- <?php echo $this->getAdditionalButtonsHtml(); ?>
28
- <?php echo $this->getSaveButtonHtml() ?>
29
- </p>
30
- </div>
31
- <?php echo $this->getTabsHtml() ?>
32
- <iframe name="iframeSave" style="display:none; width:100%;" src="<?php echo $this->getJsUrl() ?>blank.html"></iframe>
33
- <form target="iframeSave" id="menuitem_edit_form" action="<?php echo $this->getSaveUrl() ?>" method="post" enctype="multipart/form-data">
34
- <div class="no-display">
35
- <input type="hidden" name="isIframe" value="1" />
36
- <input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>" />
37
- <input type="hidden" name="active_tab_id" id="active_tab_id" value="" />
38
- </div>
39
- <div id="menuitem_tab_content"></div>
40
- </form>
41
- <script type="text/javascript">
42
- //<![CDATA[
43
- menuitemForm = new varienForm('menuitem_edit_form');
44
- menuitemForm.submit= function (url) {
45
- this.errorSections = $H({});
46
- this.canShowError = true;
47
- this.submitUrl = url;
48
- if (this.validator && this.validator.validate()) {
49
- if(this.validationUrl){
50
- this._validate();
51
- }
52
- else{
53
- if (this.isSubmitted) {
54
- return false;
55
- }
56
- this.isSubmitted = true;
57
- this._submit();
58
- }
59
- displayLoadingMask();
60
- return true;
61
- }
62
- return false;
63
- };
64
- menuitemForm.refreshPath = function () {
65
- menuitemId = this.getMenuitemId();
66
- if (!menuitemId) {
67
- return false;
68
- }
69
- var refreshPathSuccess = function(transport) {
70
- if (transport.responseText.isJSON()) {
71
- response = transport.responseText.evalJSON()
72
- if (response.error) {
73
- alert(response.message);
74
- }
75
- else {
76
- if (menuitemForm.getMenuitemId() == response['id']) {
77
- menuitemForm.setMenuitemPath(response['path']);
78
- }
79
- }
80
- }
81
- };
82
- new Ajax.Request(
83
- '<?php echo $this->getRefreshPathUrl() ?>',
84
- {
85
- method: 'POST',
86
- evalScripts: true,
87
- onSuccess: refreshPathSuccess
88
- }
89
- );
90
- };
91
-
92
- menuitemForm.getMenuitemId = function () {
93
- collection = $(this.formId).getInputs('hidden','menuitem[id]');
94
- if (collection.size() > 0) {
95
- return collection.first().value;
96
- }
97
- return false;
98
- };
99
- menuitemForm.setMenuitemPath = function (path) {
100
- collection = $(this.formId).getInputs('hidden','menuitem[path]');
101
- if (collection.size() > 0) {
102
- return collection.first().value = path;
103
- }
104
- };
105
- function menuitemSubmit(url, useAjax) {
106
- var activeTab = $('active_tab_id');
107
- if (activeTab) {
108
- if (activeTab.tabsJsObject && activeTab.tabsJsObject.activeTab) {
109
- activeTab.value = activeTab.tabsJsObject.activeTab.id;
110
- }
111
- }
112
- var params = {};
113
- var fields = $('menuitem_edit_form').getElementsBySelector('input', 'select');
114
- for(var i=0;i<fields.length;i++){
115
- if (!fields[i].name) {
116
- continue;
117
- }
118
- params[fields[i].name] = fields[i].getValue();
119
- }
120
- var menuitemId = params['menuitem[id]'] ? params['menuitem[id]'] : 0;
121
- var isCreating = menuitemId == 0;
122
- var path = params['menuitem[path]'].split('/');
123
- var parentId = path.pop();
124
- if (parentId == menuitemId) {
125
- parentId = path.pop();
126
- }
127
- if (isCreating) {
128
- if (!tree.currentNodeId) {
129
- tree.currentNodeId = parentId;
130
- }
131
- tree.addNodeTo = parentId;
132
- }
133
- else {
134
- var currentNode = tree.getNodeById(menuitemId);
135
- var oldClass = 'active-category';
136
- var newClass = 'active-category';
137
- if (currentNode) {
138
- if (parseInt(params['menuitem[status]'])) {
139
- var oldClass = 'no-active-category';
140
- var newClass = 'active-category';
141
- }
142
- else {
143
- var oldClass = 'active-category';
144
- var newClass = 'no-active-category';
145
- }
146
- Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
147
- Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
148
- }
149
- }
150
- menuitemForm.submit();
151
- }
152
- <?php if($this->isAjax() && ($block = $this->getLayout()->getBlock('tabs')) && ($_tabsJsObject=$block->getJsObjectName())): ?>
153
- <?php echo $_tabsJsObject ?>.moveTabContentInDest();
154
- if (<?php echo $_tabsJsObject ?>.activeTab) {
155
- $('active_tab_id').value = <?php echo $_tabsJsObject ?>.activeTab.id;
156
- }
157
- $('active_tab_id').tabsJsObject = <?php echo $_tabsJsObject ?>;
158
- <?php endif; ?>
159
- //]]>
160
  </script>
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div class="content-header">
19
+ <h3 class="icon-head head-categories">
20
+ <?php echo $this->htmlEscape($this->getHeader()) . ($this->getMenuitemId() ? ' (' . Mage::helper('megamenu2')->__('ID: %s', $this->getMenuitemId()) . ')' : '') ?>
21
+ </h3>
22
+ <p class="content-buttons form-buttons">
23
+ <?php echo $this->getResetButtonHtml() ?>
24
+ <?php if($this->getMenuitemId()): ?>
25
+ <?php echo $this->getDeleteButtonHtml() ?>
26
+ <?php endif; ?>
27
+ <?php echo $this->getAdditionalButtonsHtml(); ?>
28
+ <?php echo $this->getSaveButtonHtml() ?>
29
+ </p>
30
+ </div>
31
+ <?php echo $this->getTabsHtml() ?>
32
+ <iframe name="iframeSave" style="display:none; width:100%;" src="<?php echo $this->getJsUrl() ?>blank.html"></iframe>
33
+ <form target="iframeSave" id="menuitem_edit_form" action="<?php echo $this->getSaveUrl() ?>" method="post" enctype="multipart/form-data">
34
+ <div class="no-display">
35
+ <input type="hidden" name="isIframe" value="1" />
36
+ <input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>" />
37
+ <input type="hidden" name="active_tab_id" id="active_tab_id" value="" />
38
+ </div>
39
+ <div id="menuitem_tab_content"></div>
40
+ </form>
41
+ <script type="text/javascript">
42
+ //<![CDATA[
43
+ menuitemForm = new varienForm('menuitem_edit_form');
44
+ menuitemForm.submit= function (url) {
45
+ this.errorSections = $H({});
46
+ this.canShowError = true;
47
+ this.submitUrl = url;
48
+ if (this.validator && this.validator.validate()) {
49
+ if(this.validationUrl){
50
+ this._validate();
51
+ }
52
+ else{
53
+ if (this.isSubmitted) {
54
+ return false;
55
+ }
56
+ this.isSubmitted = true;
57
+ this._submit();
58
+ }
59
+ displayLoadingMask();
60
+ return true;
61
+ }
62
+ return false;
63
+ };
64
+ menuitemForm.refreshPath = function () {
65
+ menuitemId = this.getMenuitemId();
66
+ if (!menuitemId) {
67
+ return false;
68
+ }
69
+ var refreshPathSuccess = function(transport) {
70
+ if (transport.responseText.isJSON()) {
71
+ response = transport.responseText.evalJSON()
72
+ if (response.error) {
73
+ alert(response.message);
74
+ }
75
+ else {
76
+ if (menuitemForm.getMenuitemId() == response['id']) {
77
+ menuitemForm.setMenuitemPath(response['path']);
78
+ }
79
+ }
80
+ }
81
+ };
82
+ new Ajax.Request(
83
+ '<?php echo $this->getRefreshPathUrl() ?>',
84
+ {
85
+ method: 'POST',
86
+ evalScripts: true,
87
+ onSuccess: refreshPathSuccess
88
+ }
89
+ );
90
+ };
91
+
92
+ menuitemForm.getMenuitemId = function () {
93
+ collection = $(this.formId).getInputs('hidden','menuitem[id]');
94
+ if (collection.size() > 0) {
95
+ return collection.first().value;
96
+ }
97
+ return false;
98
+ };
99
+ menuitemForm.setMenuitemPath = function (path) {
100
+ collection = $(this.formId).getInputs('hidden','menuitem[path]');
101
+ if (collection.size() > 0) {
102
+ return collection.first().value = path;
103
+ }
104
+ };
105
+ function menuitemSubmit(url, useAjax) {
106
+ var activeTab = $('active_tab_id');
107
+ if (activeTab) {
108
+ if (activeTab.tabsJsObject && activeTab.tabsJsObject.activeTab) {
109
+ activeTab.value = activeTab.tabsJsObject.activeTab.id;
110
+ }
111
+ }
112
+ var params = {};
113
+ var fields = $('menuitem_edit_form').getElementsBySelector('input', 'select');
114
+ for(var i=0;i<fields.length;i++){
115
+ if (!fields[i].name) {
116
+ continue;
117
+ }
118
+ params[fields[i].name] = fields[i].getValue();
119
+ }
120
+ var menuitemId = params['menuitem[id]'] ? params['menuitem[id]'] : 0;
121
+ var isCreating = menuitemId == 0;
122
+ var path = params['menuitem[path]'].split('/');
123
+ var parentId = path.pop();
124
+ if (parentId == menuitemId) {
125
+ parentId = path.pop();
126
+ }
127
+ if (isCreating) {
128
+ if (!tree.currentNodeId) {
129
+ tree.currentNodeId = parentId;
130
+ }
131
+ tree.addNodeTo = parentId;
132
+ }
133
+ else {
134
+ var currentNode = tree.getNodeById(menuitemId);
135
+ var oldClass = 'active-category';
136
+ var newClass = 'active-category';
137
+ if (currentNode) {
138
+ if (parseInt(params['menuitem[status]'])) {
139
+ var oldClass = 'no-active-category';
140
+ var newClass = 'active-category';
141
+ }
142
+ else {
143
+ var oldClass = 'active-category';
144
+ var newClass = 'no-active-category';
145
+ }
146
+ Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
147
+ Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
148
+ }
149
+ }
150
+ menuitemForm.submit();
151
+ }
152
+ <?php if($this->isAjax() && ($block = $this->getLayout()->getBlock('tabs')) && ($_tabsJsObject=$block->getJsObjectName())): ?>
153
+ <?php echo $_tabsJsObject ?>.moveTabContentInDest();
154
+ if (<?php echo $_tabsJsObject ?>.activeTab) {
155
+ $('active_tab_id').value = <?php echo $_tabsJsObject ?>.activeTab.id;
156
+ }
157
+ $('active_tab_id').tabsJsObject = <?php echo $_tabsJsObject ?>;
158
+ <?php endif; ?>
159
+ //]]>
160
  </script>
app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/tree.phtml CHANGED
@@ -1,376 +1,376 @@
1
- <?php
2
  /**
3
- * JScriptz_MegaMenu2 extension
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the MIT License
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/mit-license.php
11
- *
12
- * @category JScriptz
13
- * @package JScriptz_MegaMenu2
14
- * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
- */
17
- ?>
18
- <div class="categories-side-col">
19
- <div class="content-header">
20
- <h3 class="icon-head head-menuitems">
21
- <?php echo Mage::helper('megamenu2')->__('Menu Items') ?>
22
- </h3>
23
- <?php if ($this->getRoot()): ?>
24
- <?php echo $this->getAddRootButtonHtml() ?><br />
25
- <?php echo $this->getAddSubButtonHtml() ?>
26
- <?php endif; ?>
27
- </div>
28
- <div class="tree-actions">
29
- <?php if($this->getRoot()): ?>
30
- <a href="#" onclick="tree.collapseTree(); return false;">
31
- <?php echo Mage::helper('megamenu2')->__('Collapse All'); ?>
32
- </a>
33
- <span class="separator">|</span>
34
- <a href="#" onclick="tree.expandTree(); return false;">
35
- <?php echo Mage::helper('megamenu2')->__('Expand All'); ?>
36
- </a>
37
- <?php endif; ?>
38
- </div>
39
- <?php if ($this->getRoot()): ?>
40
- <div class="tree-holder">
41
- <div id="tree-div" style="width:100%; overflow:auto;"></div>
42
- </div>
43
- </div>
44
- <script type="text/javascript">
45
- //<![CDATA[
46
- var tree;
47
- /**
48
- * Fix ext compatibility with prototype 1.6
49
- */
50
- Ext.lib.Event.getTarget = function(e) {
51
- var ee = e.browserEvent || e;
52
- return ee.target ? Event.element(ee) : null;
53
- };
54
- Ext.tree.TreePanel.Enhanced = function(el, config){
55
- Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
56
- };
57
- Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
58
- loadTree : function(config, firstLoad){
59
- var parameters = config['parameters'];
60
- var data = config['data'];
61
- if ((typeof parameters['root_visible']) != 'undefined') {
62
- this.rootVisible = parameters['root_visible']*1;
63
- }
64
- var root = new Ext.tree.TreeNode(parameters);
65
- this.nodeHash = {};
66
- this.setRootNode(root);
67
- if (firstLoad) {
68
- this.addListener('click', this.menuitemClick);
69
- this.addListener('beforenodedrop', menuitemMove.createDelegate(this));
70
- }
71
- this.loader.buildMenuitemTree(root, data);
72
- this.el.dom.innerHTML = '';
73
- // render the tree
74
- this.render();
75
- if (parameters['expanded']) {
76
- this.expandAll();
77
- }
78
- else {
79
- root.expand();
80
- }
81
- var selectedNode = this.getNodeById(parameters['menuitem_id']);
82
- if (selectedNode) {
83
- this.currentNodeId = parameters['menuitem_id'];
84
- }
85
- this.selectCurrentNode();
86
- },
87
- request : function(url, params){
88
- if (!params) {
89
- if (menuitem_info_tabsJsTabs.activeTab) {
90
- var params = {active_tab_id:menuitem_info_tabsJsTabs.activeTab.id};
91
- }
92
- else {
93
- var params = {};
94
- }
95
- }
96
- if (!params.form_key) {
97
- params.form_key = FORM_KEY;
98
- }
99
- var result = new Ajax.Request(
100
- url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
101
- {
102
- parameters: params,
103
- method: 'post'
104
- }
105
- );
106
- return result;
107
- },
108
- selectCurrentNode : function(){
109
- if (this.currentNodeId) {
110
- var selectedNode = this.getNodeById(this.currentNodeId);
111
- if ((typeof selectedNode.attributes.path)!='undefined') {
112
- var path = selectedNode.attributes.path;
113
- path = '0/'+path;
114
- this.selectPath(path);
115
- }
116
- else {
117
- this.getSelectionModel().select(selectedNode);
118
- }
119
- }
120
- },
121
- collapseTree : function(){
122
- this.collapseAll();
123
- this.selectCurrentNode();
124
- if (!this.collapsed) {
125
- this.collapsed = true;
126
- this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(false) ?>';
127
- this.request(this.loader.dataUrl, false);
128
- }
129
- },
130
- expandTree : function(){
131
- this.expandAll();
132
- if (this.collapsed) {
133
- this.collapsed = false;
134
- this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(true) ?>';
135
- this.request(this.loader.dataUrl, false);
136
- }
137
- },
138
- menuitemClick : function(node, e){
139
- var baseUrl = '<?php echo $this->getEditUrl() ?>';
140
- var urlExt = 'id/'+node.id+'/';
141
- var url = parseSidUrl(baseUrl, urlExt);
142
- this.currentNodeId = node.id;
143
- if (!this.useAjax) {
144
- setLocation(url);
145
- return;
146
- }
147
- if (menuitem_info_tabsJsTabs.activeTab) {
148
- var params = {active_tab_id:menuitem_info_tabsJsTabs.activeTab.id};
149
- }
150
- updateContent(url, params);
151
- }
152
- });
153
- function reRenderTree(event){
154
- if (tree && event) {
155
- var obj = event.target;
156
- if ($('add_root_menuitem_button')) {
157
- $('add_root_menuitem_button').show();
158
- }
159
- // retain current selected menu item id
160
- var url = tree.switchTreeUrl;
161
- // load from cache
162
- // load from ajax
163
- new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
164
- parameters : {form_key: FORM_KEY},
165
- method : 'post',
166
- onComplete : function(transport) {
167
- var response = eval('(' + transport.responseText + ')');
168
- if (!response['parameters']) {
169
- return false;
170
- }
171
- _renderNewTree(response);
172
- }
173
- });
174
- }
175
- // render default tree
176
- else {
177
- _renderNewTree();
178
- }
179
- }
180
- function _renderNewTree(config){
181
- if (!config) {
182
- var config = defaultLoadTreeParams;
183
- }
184
- if (tree) {
185
- tree.purgeListeners();
186
- tree.el.dom.innerHTML = '';
187
- }
188
- tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams);
189
- tree.loadTree(config, true);
190
- // try to select current menu item
191
- var selectedNode = tree.getNodeById(config.parameters.menuitem_id);
192
- if (selectedNode) {
193
- tree.currentNodeId = config.parameters.menuitem_id;
194
- }
195
- tree.selectCurrentNode();
196
- // update content area
197
- var url = tree.editUrl;
198
- <?php if ($this->isClearEdit()):?>
199
- if (selectedNode) {
200
- url = url + 'id/' + config.parameters.menuitem_id;
201
- }
202
- <?php endif;?>
203
- updateContent(url);
204
- }
205
- Ext.onReady(function(){
206
- menuitemLoader = new Ext.tree.TreeLoader({
207
- dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
208
- });
209
- menuitemLoader.createNode = function(config) {
210
- var node;
211
- var _node = Object.clone(config);
212
- if (config.children && !config.children.length) {
213
- delete(config.children);
214
- node = new Ext.tree.AsyncTreeNode(config);
215
- }
216
- else {
217
- node = new Ext.tree.TreeNode(config);
218
- }
219
- return node;
220
- };
221
- menuitemLoader.buildMenuitemTree = function(parent, config){
222
- if (!config) {
223
- return null;
224
- }
225
- if (parent && config && config.length){
226
- for (var i = 0; i < config.length; i++) {
227
- var node;
228
- var _node = Object.clone(config[i]);
229
- if (_node.children && !_node.children.length) {
230
- delete(_node.children);
231
- node = new Ext.tree.AsyncTreeNode(_node);
232
- }
233
- else {
234
- node = new Ext.tree.TreeNode(config[i]);
235
- }
236
- parent.appendChild(node);
237
- node.loader = node.getOwnerTree().loader;
238
- if (_node.children) {
239
- this.buildMenuitemTree(node, _node.children);
240
- }
241
- }
242
- }
243
- };
244
- menuitemLoader.buildHash = function(node){
245
- var hash = {};
246
- hash = this.toArray(node.attributes);
247
- if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
248
- hash['children'] = new Array;
249
- for (var i = 0, len = node.childNodes.length; i < len; i++) {
250
- if (!hash['children']) {
251
- hash['children'] = new Array;
252
- }
253
- hash['children'].push(this.buildHash(node.childNodes[i]));
254
- }
255
- }
256
- return hash;
257
- };
258
- menuitemLoader.toArray = function(attributes) {
259
- var data = {form_key: FORM_KEY};
260
- for (var key in attributes) {
261
- var value = attributes[key];
262
- data[key] = value;
263
- }
264
- return data;
265
- };
266
- menuitemLoader.on("beforeload", function(treeLoader, node) {
267
- treeLoader.baseParams.id = node.attributes.id;
268
- treeLoader.baseParams.form_key = FORM_KEY;
269
- });
270
- menuitemLoader.on("load", function(treeLoader, node, config) {
271
- varienWindowOnload();
272
- });
273
- newTreeParams = {
274
- animate : false,
275
- loader : menuitemLoader,
276
- enableDD: true,
277
- containerScroll : true,
278
- selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
279
- rootVisible : false,
280
- useAjax : <?php echo $this->getUseAjax() ?>,
281
- switchTreeUrl : '<?php echo $this->getSwitchTreeUrl() ?>',
282
- editUrl : '<?php echo $this->getEditUrl() ?>',
283
- currentNodeId : <?php echo (int) $this->getMenuitemId() ?>
284
- };
285
- defaultLoadTreeParams = {
286
- parameters : {
287
- text: '<?php echo htmlentities($this->getRoot()->getLinktitle()) ?>',
288
- draggable : false,
289
- allowDrop : true,
290
- id : <?php echo (int) $this->getRoot()->getId() ?>,
291
- expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
292
- menuitem_id : <?php echo (int) $this->getMenuitemId() ?>
293
- },
294
- data : <?php echo $this->getTreeJson() ?>
295
- };
296
- reRenderTree();
297
- });
298
-
299
- function addNew(url, isRoot){
300
- if (isRoot) {
301
- tree.currentNodeId = tree.root.id;
302
- }
303
- url+= 'parent/'+tree.currentNodeId;
304
- updateContent(url);
305
- }
306
- function menuitemMove(obj){
307
- var data = {id: obj.dropNode.id, form_key: FORM_KEY};
308
- data.point = obj.point;
309
- switch (obj.point) {
310
- case 'above' :
311
- data.pid = obj.target.parentNode.id;
312
- data.paid = obj.dropNode.parentNode.id;
313
- if (obj.target.previousSibling) {
314
- data.aid = obj.target.previousSibling.id;
315
- }
316
- else {
317
- data.aid = 0;
318
- }
319
- break;
320
- case 'below' :
321
- data.pid = obj.target.parentNode.id;
322
- data.aid = obj.target.id;
323
- break;
324
- case 'append' :
325
- data.pid = obj.target.id;
326
- data.paid = obj.dropNode.parentNode.id;
327
- if (obj.target.lastChild) {
328
- data.aid = obj.target.lastChild.id;
329
- } else {
330
- data.aid = 0;
331
- }
332
- break;
333
- default :
334
- obj.cancel = true;
335
- return obj;
336
- }
337
- var success = function(o) {
338
- try {
339
- if(o.responseText){
340
- if(o.responseText==='SUCCESS'){
341
- menuitemForm.refreshPath();
342
- }
343
- else {
344
- alert(o.responseText);
345
- location.reload();
346
- }
347
- }
348
- }
349
- catch(e) {}
350
- };
351
- var failure = function(o) {
352
- try {
353
- console.log(o.statusText);
354
- } catch (e2) {
355
- alert(o.statusText);
356
- }
357
- location.reload();
358
- };
359
- var pd = [];
360
- for(var key in data) {
361
- pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&");
362
- }
363
- pd.splice(pd.length-1,1);
364
- new Ajax.Request(
365
- '<?php echo $this->getMoveUrl() ?>',
366
- {
367
- method: 'POST',
368
- parameters: pd.join(""),
369
- onSuccess : success,
370
- onFailure : failure
371
- }
372
- );
373
- }
374
- //]]>
375
- </script>
376
- <?php endif; ?>
1
+ <?php
2
  /**
3
+ * JScriptz_MegaMenu2 extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
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/mit-license.php
11
+ *
12
+ * @category JScriptz
13
+ * @package JScriptz_MegaMenu2
14
+ * @copyright Copyright (c) 2013
15
  * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ ?>
18
+ <div class="categories-side-col">
19
+ <div class="content-header">
20
+ <h3 class="icon-head head-menuitems">
21
+ <?php echo Mage::helper('megamenu2')->__('Menu Items') ?>
22
+ </h3>
23
+ <?php if ($this->getRoot()): ?>
24
+ <?php echo $this->getAddRootButtonHtml() ?><br />
25
+ <?php echo $this->getAddSubButtonHtml() ?>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div class="tree-actions">
29
+ <?php if($this->getRoot()): ?>
30
+ <a href="#" onclick="tree.collapseTree(); return false;">
31
+ <?php echo Mage::helper('megamenu2')->__('Collapse All'); ?>
32
+ </a>
33
+ <span class="separator">|</span>
34
+ <a href="#" onclick="tree.expandTree(); return false;">
35
+ <?php echo Mage::helper('megamenu2')->__('Expand All'); ?>
36
+ </a>
37
+ <?php endif; ?>
38
+ </div>
39
+ <?php if ($this->getRoot()): ?>
40
+ <div class="tree-holder">
41
+ <div id="tree-div" style="width:100%; overflow:auto;"></div>
42
+ </div>
43
+ </div>
44
+ <script type="text/javascript">
45
+ //<![CDATA[
46
+ var tree;
47
+ /**
48
+ * Fix ext compatibility with prototype 1.6
49
+ */
50
+ Ext.lib.Event.getTarget = function(e) {
51
+ var ee = e.browserEvent || e;
52
+ return ee.target ? Event.element(ee) : null;
53
+ };
54
+ Ext.tree.TreePanel.Enhanced = function(el, config){
55
+ Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
56
+ };
57
+ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
58
+ loadTree : function(config, firstLoad){
59
+ var parameters = config['parameters'];
60
+ var data = config['data'];
61
+ if ((typeof parameters['root_visible']) != 'undefined') {
62
+ this.rootVisible = parameters['root_visible']*1;
63
+ }
64
+ var root = new Ext.tree.TreeNode(parameters);
65
+ this.nodeHash = {};
66
+ this.setRootNode(root);
67
+ if (firstLoad) {
68
+ this.addListener('click', this.menuitemClick);
69
+ this.addListener('beforenodedrop', menuitemMove.createDelegate(this));
70
+ }
71
+ this.loader.buildMenuitemTree(root, data);
72
+ this.el.dom.innerHTML = '';
73
+ // render the tree
74
+ this.render();
75
+ if (parameters['expanded']) {
76
+ this.expandAll();
77
+ }
78
+ else {
79
+ root.expand();
80
+ }
81
+ var selectedNode = this.getNodeById(parameters['menuitem_id']);
82
+ if (selectedNode) {
83
+ this.currentNodeId = parameters['menuitem_id'];
84
+ }
85
+ this.selectCurrentNode();
86
+ },
87
+ request : function(url, params){
88
+ if (!params) {
89
+ if (menuitem_info_tabsJsTabs.activeTab) {
90
+ var params = {active_tab_id:menuitem_info_tabsJsTabs.activeTab.id};
91
+ }
92
+ else {
93
+ var params = {};
94
+ }
95
+ }
96
+ if (!params.form_key) {
97
+ params.form_key = FORM_KEY;
98
+ }
99
+ var result = new Ajax.Request(
100
+ url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
101
+ {
102
+ parameters: params,
103
+ method: 'post'
104
+ }
105
+ );
106
+ return result;
107
+ },
108
+ selectCurrentNode : function(){
109
+ if (this.currentNodeId) {
110
+ var selectedNode = this.getNodeById(this.currentNodeId);
111
+ if ((typeof selectedNode.attributes.path)!='undefined') {
112
+ var path = selectedNode.attributes.path;
113
+ path = '0/'+path;
114
+ this.selectPath(path);
115
+ }
116
+ else {
117
+ this.getSelectionModel().select(selectedNode);
118
+ }
119
+ }
120
+ },
121
+ collapseTree : function(){
122
+ this.collapseAll();
123
+ this.selectCurrentNode();
124
+ if (!this.collapsed) {
125
+ this.collapsed = true;
126
+ this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(false) ?>';
127
+ this.request(this.loader.dataUrl, false);
128
+ }
129
+ },
130
+ expandTree : function(){
131
+ this.expandAll();
132
+ if (this.collapsed) {
133
+ this.collapsed = false;
134
+ this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(true) ?>';
135
+ this.request(this.loader.dataUrl, false);
136
+ }
137
+ },
138
+ menuitemClick : function(node, e){
139
+ var baseUrl = '<?php echo $this->getEditUrl() ?>';
140
+ var urlExt = 'id/'+node.id+'/';
141
+ var url = parseSidUrl(baseUrl, urlExt);
142
+ this.currentNodeId = node.id;
143
+ if (!this.useAjax) {
144
+ setLocation(url);
145
+ return;
146
+ }
147
+ if (menuitem_info_tabsJsTabs.activeTab) {
148
+ var params = {active_tab_id:menuitem_info_tabsJsTabs.activeTab.id};
149
+ }
150
+ updateContent(url, params);
151
+ }
152
+ });
153
+ function reRenderTree(event){
154
+ if (tree && event) {
155
+ var obj = event.target;
156
+ if ($('add_root_menuitem_button')) {
157
+ $('add_root_menuitem_button').show();
158
+ }
159
+ // retain current selected menu item id
160
+ var url = tree.switchTreeUrl;
161
+ // load from cache
162
+ // load from ajax
163
+ new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
164
+ parameters : {form_key: FORM_KEY},
165
+ method : 'post',
166
+ onComplete : function(transport) {
167
+ var response = eval('(' + transport.responseText + ')');
168
+ if (!response['parameters']) {
169
+ return false;
170
+ }
171
+ _renderNewTree(response);
172
+ }
173
+ });
174
+ }
175
+ // render default tree
176
+ else {
177
+ _renderNewTree();
178
+ }
179
+ }
180
+ function _renderNewTree(config){
181
+ if (!config) {
182
+ var config = defaultLoadTreeParams;
183
+ }
184
+ if (tree) {
185
+ tree.purgeListeners();
186
+ tree.el.dom.innerHTML = '';
187
+ }
188
+ tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams);
189
+ tree.loadTree(config, true);
190
+ // try to select current menu item
191
+ var selectedNode = tree.getNodeById(config.parameters.menuitem_id);
192
+ if (selectedNode) {
193
+ tree.currentNodeId = config.parameters.menuitem_id;
194
+ }
195
+ tree.selectCurrentNode();
196
+ // update content area
197
+ var url = tree.editUrl;
198
+ <?php if ($this->isClearEdit()):?>
199
+ if (selectedNode) {
200
+ url = url + 'id/' + config.parameters.menuitem_id;
201
+ }
202
+ <?php endif;?>
203
+ updateContent(url);
204
+ }
205
+ Ext.onReady(function(){
206
+ menuitemLoader = new Ext.tree.TreeLoader({
207
+ dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
208
+ });
209
+ menuitemLoader.createNode = function(config) {
210
+ var node;
211
+ var _node = Object.clone(config);
212
+ if (config.children && !config.children.length) {
213
+ delete(config.children);
214
+ node = new Ext.tree.AsyncTreeNode(config);
215
+ }
216
+ else {
217
+ node = new Ext.tree.TreeNode(config);
218
+ }
219
+ return node;
220
+ };
221
+ menuitemLoader.buildMenuitemTree = function(parent, config){
222
+ if (!config) {
223
+ return null;
224
+ }
225
+ if (parent && config && config.length){
226
+ for (var i = 0; i < config.length; i++) {
227
+ var node;
228
+ var _node = Object.clone(config[i]);
229
+ if (_node.children && !_node.children.length) {
230
+ delete(_node.children);
231
+ node = new Ext.tree.AsyncTreeNode(_node);
232
+ }
233
+ else {
234
+ node = new Ext.tree.TreeNode(config[i]);
235
+ }
236
+ parent.appendChild(node);
237
+ node.loader = node.getOwnerTree().loader;
238
+ if (_node.children) {
239
+ this.buildMenuitemTree(node, _node.children);
240
+ }
241
+ }
242
+ }
243
+ };
244
+ menuitemLoader.buildHash = function(node){
245
+ var hash = {};
246
+ hash = this.toArray(node.attributes);
247
+ if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
248
+ hash['children'] = new Array;
249
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
250
+ if (!hash['children']) {
251
+ hash['children'] = new Array;
252
+ }
253
+ hash['children'].push(this.buildHash(node.childNodes[i]));
254
+ }
255
+ }
256
+ return hash;
257
+ };
258
+ menuitemLoader.toArray = function(attributes) {
259
+ var data = {form_key: FORM_KEY};
260
+ for (var key in attributes) {
261
+ var value = attributes[key];
262
+ data[key] = value;
263
+ }
264
+ return data;
265
+ };
266
+ menuitemLoader.on("beforeload", function(treeLoader, node) {
267
+ treeLoader.baseParams.id = node.attributes.id;
268
+ treeLoader.baseParams.form_key = FORM_KEY;
269
+ });
270
+ menuitemLoader.on("load", function(treeLoader, node, config) {
271
+ varienWindowOnload();
272
+ });
273
+ newTreeParams = {
274
+ animate : false,
275
+ loader : menuitemLoader,
276
+ enableDD: true,
277
+ containerScroll : true,
278
+ selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
279
+ rootVisible : false,
280
+ useAjax : <?php echo $this->getUseAjax() ?>,
281
+ switchTreeUrl : '<?php echo $this->getSwitchTreeUrl() ?>',
282
+ editUrl : '<?php echo $this->getEditUrl() ?>',
283
+ currentNodeId : <?php echo (int) $this->getMenuitemId() ?>
284
+ };
285
+ defaultLoadTreeParams = {
286
+ parameters : {
287
+ text: '<?php echo htmlentities($this->getRoot()->getLinktitle()) ?>',
288
+ draggable : false,
289
+ allowDrop : true,
290
+ id : <?php echo (int) $this->getRoot()->getId() ?>,
291
+ expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
292
+ menuitem_id : <?php echo (int) $this->getMenuitemId() ?>
293
+ },
294
+ data : <?php echo $this->getTreeJson() ?>
295
+ };
296
+ reRenderTree();
297
+ });
298
+
299
+ function addNew(url, isRoot){
300
+ if (isRoot) {
301
+ tree.currentNodeId = tree.root.id;
302
+ }
303
+ url+= 'parent/'+tree.currentNodeId;
304
+ updateContent(url);
305
+ }
306
+ function menuitemMove(obj){
307
+ var data = {id: obj.dropNode.id, form_key: FORM_KEY};
308
+ data.point = obj.point;
309
+ switch (obj.point) {
310
+ case 'above' :
311
+ data.pid = obj.target.parentNode.id;
312
+ data.paid = obj.dropNode.parentNode.id;
313
+ if (obj.target.previousSibling) {
314
+ data.aid = obj.target.previousSibling.id;
315
+ }
316
+ else {
317
+ data.aid = 0;
318
+ }
319
+ break;
320
+ case 'below' :
321
+ data.pid = obj.target.parentNode.id;
322
+ data.aid = obj.target.id;
323
+ break;
324
+ case 'append' :
325
+ data.pid = obj.target.id;
326
+ data.paid = obj.dropNode.parentNode.id;
327
+ if (obj.target.lastChild) {
328
+ data.aid = obj.target.lastChild.id;
329
+ } else {
330
+ data.aid = 0;
331
+ }
332
+ break;
333
+ default :
334
+ obj.cancel = true;
335
+ return obj;
336
+ }
337
+ var success = function(o) {
338
+ try {
339
+ if(o.responseText){
340
+ if(o.responseText==='SUCCESS'){
341
+ menuitemForm.refreshPath();
342
+ }
343
+ else {
344
+ alert(o.responseText);
345
+ location.reload();
346
+ }
347
+ }
348
+ }
349
+ catch(e) {}
350
+ };
351
+ var failure = function(o) {
352
+ try {
353
+ console.log(o.statusText);
354
+ } catch (e2) {
355
+ alert(o.statusText);
356
+ }
357
+ location.reload();
358
+ };
359
+ var pd = [];
360
+ for(var key in data) {
361
+ pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&");
362
+ }
363
+ pd.splice(pd.length-1,1);
364
+ new Ajax.Request(
365
+ '<?php echo $this->getMoveUrl() ?>',
366
+ {
367
+ method: 'POST',
368
+ parameters: pd.join(""),
369
+ onSuccess : success,
370
+ onFailure : failure
371
+ }
372
+ );
373
+ }
374
+ //]]>
375
+ </script>
376
+ <?php endif; ?>
app/design/frontend/base/default/layout/jscriptz_megamenu2.xml CHANGED
@@ -1,32 +1,32 @@
1
- <?xml version="1.0"?>
2
  <!--
3
  /**
4
- * JScriptz_MegaMenu2 extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the MIT License
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/mit-license.php
12
- *
13
- * @category JScriptz
14
- * @package JScriptz_MegaMenu2
15
- * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
- -->
19
- <layout version="0.1.0">
20
- <default translate="label" module="page">
21
- <reference name="head">
22
- <action method="addItem"><type>skin_js</type><name>js/JScriptz/mgmenu.js</name></action>
23
- <action method="addItem"><type>skin_css</type><name>css/JScriptz/mgmenu.css</name><params>media="screen"</params></action>
24
- </reference>
25
- <reference name="catalog.topnav">
26
- <action method="setTemplate"><template>jscriptz/html/topmenu.phtml</template></action>
27
- </reference>
28
- <reference name="top.menu">
29
- <action method="setTemplate"><template>jscriptz/html/topmenu.phtml</template></action>
30
- </reference>
31
- </default>
32
  </layout>
1
+ <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * JScriptz_MegaMenu2 extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category JScriptz
14
+ * @package JScriptz_MegaMenu2
15
+ * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
+ -->
19
+ <layout version="0.1.0">
20
+ <default translate="label" module="page">
21
+ <reference name="head">
22
+ <action method="addItem"><type>skin_js</type><name>js/JScriptz/mgmenu.js</name></action>
23
+ <action method="addItem"><type>skin_css</type><name>css/JScriptz/mgmenu.css</name><params>media="screen"</params></action>
24
+ </reference>
25
+ <reference name="catalog.topnav">
26
+ <action method="setTemplate"><template>jscriptz/html/topmenu.phtml</template></action>
27
+ </reference>
28
+ <reference name="top.menu">
29
+ <action method="setTemplate"><template>jscriptz/html/topmenu.phtml</template></action>
30
+ </reference>
31
+ </default>
32
  </layout>
app/design/frontend/base/default/template/jscriptz/html/topmenu.phtml CHANGED
@@ -62,7 +62,7 @@ jQuery( document ).ready(function( $ ) {
62
  <?php foreach($_menuItem as $sort){
63
  $sortArray[] = $sort;
64
  }
65
- usort ($sortArray, function($a, $b) {return strcmp($a['position'], $b['position']);});
66
  ?>
67
 
68
  <?php foreach($sortArray as $item): ?>
62
  <?php foreach($_menuItem as $sort){
63
  $sortArray[] = $sort;
64
  }
65
+ usort ($sortArray, strcmp($a['position'], $b['position']));
66
  ?>
67
 
68
  <?php foreach($sortArray as $item): ?>
app/etc/modules/JScriptz_MegaMenu2.xml CHANGED
@@ -1,29 +1,29 @@
1
- <?xml version="1.0"?>
2
  <!--
3
  /**
4
- * JScriptz_MegaMenu2 extension
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the MIT License
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/mit-license.php
12
- *
13
- * @category JScriptz
14
- * @package JScriptz_MegaMenu2
15
- * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
- -->
19
- <config>
20
- <modules>
21
- <JScriptz_MegaMenu2>
22
- <active>true</active>
23
- <codePool>community</codePool>
24
- <depends>
25
- <Mage_Core />
26
- </depends>
27
- </JScriptz_MegaMenu2>
28
- </modules>
29
- </config>
1
+ <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * JScriptz_MegaMenu2 extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category JScriptz
14
+ * @package JScriptz_MegaMenu2
15
+ * @copyright Copyright (c) 2013
16
  * @license http://opensource.org/licenses/mit-license.php MIT License
17
  */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <JScriptz_MegaMenu2>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ <depends>
25
+ <Mage_Core />
26
+ </depends>
27
+ </JScriptz_MegaMenu2>
28
+ </modules>
29
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>JScriptz_MegaMenu2</name>
4
- <version>1.8.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>This is a mega nav extension that allows you to control your top menu links and the content below them through the admin interface. It supports HTML, Video, Tabbed Jquery, and even has a nifty contact us form. </description>
11
  <notes>This is a mega nav extension that allows you to control your top menu links and the content below them through the admin interface. It supports HTML, Video, Tabbed Jquery, and even has a nifty contact us form. </notes>
12
  <authors><author><name>Jason Lotzer</name><user>jlotty22</user><email>jasonlotzer@gmail.com</email></author></authors>
13
- <date>2013-10-07</date>
14
- <time>16:48:32</time>
15
- <contents><target name="magecommunity"><dir name="JScriptz"><dir name="MegaMenu2"><dir name="Block"><dir name="Adminhtml"><dir name="Helper"><file name="Wysiwyg.php" hash="b466f038662d9e42a807ae3c0dc5fcca"/></dir><dir name="Menuitem"><file name="Abstract.php" hash="edc0bae932697b8aacabbaca86fdd2fe"/><dir name="Edit"><file name="Form.php" hash="db5ce8ad95a7bcd8de8bb7f1be243265"/><dir name="Tab"><file name="Form.php" hash="18d752d8318a3574ac792b9386c38a91"/><file name="Stores.php" hash="842c7c109505f22421c5430a34726933"/></dir><file name="Tabs.php" hash="5dba4a3d0765d68749e23270be8d2933"/></dir><file name="Edit.php" hash="7d59bf88e284a468ea01f5f9e5eb0905"/><file name="Tree.php" hash="4fc390bb4d595fd7227d829c6777036e"/></dir><file name="Menuitem.php" hash="5a856d8abc0928304fbbfb3505f75d6f"/></dir><dir name="Html"><file name="Topmenu.php" hash="3c848884aaf9762a85066e7cc603ade7"/></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="MegaMenu2.php" hash="04675e81391803b2425eaf29e5f376db"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ce9cce0ccb9b7355ed5f325df135b340"/><file name="Menuitem.php" hash="68688f460db50999892742bbb561346f"/></dir><dir name="Model"><file name="Menuitem.php" hash="2d570202c2373c70d1e41b2a27f1c477"/><dir name="Resource"><dir name="Menuitem"><file name="Collection.php" hash="3fd8613ce5ad89da1fabef4b07d9f4db"/><file name="Tree.php" hash="1c9ba48e1f29e929f28df8e831f4f20e"/></dir><file name="Menuitem.php" hash="beb8dc781bee28f5152fd8771d9c9f2b"/><file name="Setup.php" hash="bfc93f99f7db72c16a0500dd504f908e"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="MegaMenu2"><file name="MenuitemController.php" hash="7bd76497a989e6e00436bffc87f0287e"/></dir></dir></dir><dir name="data"><dir name="jscriptz_megamenu2_setup"><file name="data-install-0.0.1.php" hash="af94ebdf8fd07615ad5a07fc56cd85d1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ccd9ab48ea64870214061ce78d43f005"/><file name="config.xml" hash="74b313a62cde04ea63f040b11fb2a016"/></dir><dir name="sql"><dir name="jscriptz_megamenu2_setup"><file name="install-0.0.1.php" hash="61d6edab17f53224b02f045b42cd24c8"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="JScriptz_MegaMenu2.xml" hash="35ebf14afac4c63cafb1531bd00ebdc1"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="jscriptz_megamenu2.xml" hash="347eb35e0b0f9721c6758fa1e2a1ef8f"/></dir><dir name="template"><dir name="jscriptz_megamenu2"><dir name="menuitem"><dir name="edit"><file name="form.phtml" hash="b9b8c45cc98084d33f052c104daede62"/></dir><file name="edit.phtml" hash="3de3bc7531d06fc87f1b270180bd7294"/><file name="tree.phtml" hash="61eb0c277f2e641f6fd7922a6d54c643"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="jscriptz_megamenu2.xml" hash="1015ba50190b651b7d5e3a4aca9237d8"/></dir><dir name="template"><dir name="jscriptz"><dir name="html"><file name="topmenu.phtml" hash="ab84092a5d063768966ff17bd2f4c7d7"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="JScriptz"><file name="mgmenu.css" hash="4297600d34500976c09ebe3d4cf25843"/></dir></dir><dir name="js"><dir name="JScriptz"><file name="mgmenu.js" hash="b808a4e75addeeb519f24b1349ed7824"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="JScriptz_MegaMenu2.csv" hash="ab83e9d97293163a6136649945146a5a"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>JScriptz_MegaMenu2</name>
4
+ <version>1.8.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
10
  <description>This is a mega nav extension that allows you to control your top menu links and the content below them through the admin interface. It supports HTML, Video, Tabbed Jquery, and even has a nifty contact us form. </description>
11
  <notes>This is a mega nav extension that allows you to control your top menu links and the content below them through the admin interface. It supports HTML, Video, Tabbed Jquery, and even has a nifty contact us form. </notes>
12
  <authors><author><name>Jason Lotzer</name><user>jlotty22</user><email>jasonlotzer@gmail.com</email></author></authors>
13
+ <date>2013-10-17</date>
14
+ <time>03:33:03</time>
15
+ <contents><target name="magecommunity"><dir name="JScriptz"><dir name="MegaMenu2"><dir name="Block"><dir name="Adminhtml"><dir name="Helper"><file name="Wysiwyg.php" hash="f7368e9c76b954583897cf3f401f015a"/></dir><dir name="Menuitem"><file name="Abstract.php" hash="d17bdf2465fbb78d2aa05b37c42de9e7"/><dir name="Edit"><file name="Form.php" hash="13cf3368335d58e3c858460fbe13c3e6"/><dir name="Tab"><file name="Form.php" hash="5158b4336c830a826772e309af8488c1"/><file name="Stores.php" hash="4eab2faa0eedfa90d947f15eb05cd1f6"/></dir><file name="Tabs.php" hash="e6f5633e4078353171ab326e6c7592f0"/></dir><file name="Edit.php" hash="33e9326f9503d89c852538d0351728b4"/><file name="Tree.php" hash="7b60b4d71444634465c097fb940e865b"/></dir><file name="Menuitem.php" hash="72b704c68d9b563ae7f3ed5e4be20486"/></dir><dir name="Html"><file name="Topmenu.php" hash="3c848884aaf9762a85066e7cc603ade7"/></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="MegaMenu2.php" hash="50e9bf0319bd0fcf36ee85050d9f0748"/></dir></dir><dir name="Helper"><file name="Data.php" hash="793da00313f3043b7d170a6f20c55ed3"/><file name="Menuitem.php" hash="821b0f442cc80c6374fd66fe4844f57d"/></dir><dir name="Model"><file name="Menuitem.php" hash="94ac648be483266f65e9955fa9c17462"/><dir name="Resource"><dir name="Menuitem"><file name="Collection.php" hash="1e2d5ab615f4edfc827c3b8501aeedd7"/><file name="Tree.php" hash="b609f76d755dc48a20f41ac49249b945"/></dir><file name="Menuitem.php" hash="a1427dff099525e6c0c156f47918397d"/><file name="Setup.php" hash="16f720ce4f44620237341d137577d805"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="MegaMenu2"><file name="MenuitemController.php" hash="1fae234277039cff74f98fe1da62a873"/></dir></dir></dir><dir name="data"><dir name="jscriptz_megamenu2_setup"><file name="data-install-0.0.1.php" hash="237e8a0c54f78d254519a160a583bc07"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7e22334c3a04566765daa1509d53d379"/><file name="config.xml" hash="fdb836797a7750b79eb9c83eba6be9e6"/></dir><dir name="sql"><dir name="jscriptz_megamenu2_setup"><file name="install-0.0.1.php" hash="68aad3a33f5e885789e41d6980290a63"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="JScriptz_MegaMenu2.xml" hash="5642dae28d8d56debef1fbe860eb641b"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="jscriptz_megamenu2.xml" hash="dfa5b15afe6f9a37e239e1d63d275999"/></dir><dir name="template"><dir name="jscriptz_megamenu2"><dir name="menuitem"><dir name="edit"><file name="form.phtml" hash="d7cb90032e436fc734e3144887eefae0"/></dir><file name="edit.phtml" hash="269c833231f69ad9179b001c5c68be3f"/><file name="tree.phtml" hash="3759f6f8d7a5c1742ba299b4d7a347a9"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="jscriptz_megamenu2.xml" hash="7348d3ee83f9a838926cd73078ccbdbc"/></dir><dir name="template"><dir name="jscriptz"><dir name="html"><file name="topmenu.phtml" hash="86046c1fb2b00e9d20010c28816fb901"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="JScriptz"><file name="mgmenu.css" hash="4297600d34500976c09ebe3d4cf25843"/></dir></dir><dir name="js"><dir name="JScriptz"><file name="mgmenu.js" hash="b808a4e75addeeb519f24b1349ed7824"/></dir></dir><dir name="images"><dir name="jscriptz_megamenu2"><file name="Thumbs.db" hash="9bab36cc58b18e803ae6101ef6e34a31"/><file name="add-cart-mini.png" hash="a9f33fd5e6be5695a09ca4afb4d4b47b"/><file name="bg-checkout.png" hash="2a6f733742c6e47c37d7bc2305801930"/><file name="bg-product-tab.png" hash="678ed7222bb8840acb3b67ed4328c9ca"/><file name="bg-search.png" hash="432730c25de66b2651326272b99d2c4c"/><file name="bg-select.png" hash="4db99b517bdf913c4f6fa02328b49673"/><file name="bg-slider.png" hash="cf3f315a748073a991f8f4bb4b88b124"/><file name="cart.png" hash="ad3c077c0ede126538754d863ee6f52b"/><file name="checkbox.png" hash="92c5f3dd56746f7dad9a4e8ed632fa94"/><file name="collapsed.gif" hash="ef74c08289e94b7aae81766fb00d4195"/><file name="collapsed.png" hash="0613450d25c762b6a40c51768b02462d"/><file name="comments-link.png" hash="8ad80cb8806e2d072660831b1cd52122"/><file name="dotted.png" hash="0508c81a969e2b93b24936e14751d3d0"/><file name="expanded.gif" hash="3f5512a54f359343273caf7b3787ee8a"/><file name="expanded.png" hash="f7f28ae897708c78b28ead22c3692bb8"/><file name="glyphicons-halflings-white.png" hash="9bbc6e9602998a385c2ea13df56470fd"/><file name="glyphicons-halflings.png" hash="2516339970d710819585f90773aebe0a"/><file name="home-icon.png" hash="2b7a2e01a66b31ab10a749af8d0ff593"/><dir name="icons"><file name="Thumbs.db" hash="0fa02b97fb79bc05a901c4ca94e963d7"/><file name="mini-icons-white.png" hash="e83d93e748b6eff7e75d8b76fa570159"/></dir><file name="leftArrow.png" hash="109ca46ae5697e64b3a36a91fcdcbf8b"/><file name="line1.gif" hash="65b0c812c8d57ea72b84fc69a077a40a"/><file name="line1.png" hash="4e01064a2c78b8885f65ff7a40f78c02"/><file name="line2.gif" hash="95fc5c58069ece5eb44e198ee53b3fe1"/><file name="line2.png" hash="4e01064a2c78b8885f65ff7a40f78c02"/><file name="loading.gif" hash="e38c1a034a0c8577705e493aa95d6937"/><file name="menu-sidebar-active.png" hash="3033d40078a4b66378b7191f152a7654"/><file name="menu-sidebar.png" hash="c4305a06ab8ffaf0200fd791089e7525"/><file name="mini-icons-white.png" hash="e83d93e748b6eff7e75d8b76fa570159"/><file name="moogaloop.swf" hash="9791b5365fb156913005c3354add9bac"/><file name="page_bg.png" hash="ea2316224d45899c59bc285ba09dd920"/><file name="product01@2x.jpg" hash="707a8ebb46061e668d7e6b5cdcf9a233"/><file name="product02@2x.jpg" hash="b05b4c27c327a98db5bc116e26214948"/><file name="product03@2x.jpg" hash="bf853d2a7f37a421ad023323e339b12b"/><file name="product04@2x.jpg" hash="6a65fe14cc889d4f8effdb436fb3c946"/><file name="product05@2x.jpg" hash="a89c4fb832e7ae1c5f01e615026931b8"/><file name="product06@2x.jpg" hash="269cbd6ee56b42c962aac918905d4f4e"/><file name="product07@2x.jpg" hash="12e0afee056f22209cf58440d7233434"/><file name="product08@2x.jpg" hash="0f9a079770c7f18eeb3e5a34cc716660"/><file name="product09@2x.jpg" hash="7ef8a6b71be1ee7ce29a94983be0d1d5"/><file name="product10@2x.jpg" hash="5aa4dab244dfd6a0af36edf5769b778c"/><file name="product11@2x.jpg" hash="3bd6e862edf08870a8998f10ccc4f52a"/><file name="radio.png" hash="16cc8bc843e38e5ce17653d744c480a7"/><file name="rating-box.png" hash="6ebb6c46b545d8b97c013b2750a98ef5"/><file name="rating.png" hash="7eabd5b17ecec1a4dd9b9ffeb2f2094c"/><file name="rightArrow.png" hash="4b49ad18782e91b345d0298104d86bfc"/><file name="select.png" hash="d905661b016949f1a377491fb4cfd56a"/><file name="separator.png" hash="b0964148cb3bbd9e22ecccbfcc6f0899"/><file name="shadow.png" hash="dbfa3bd02e813a59ea34ef1ac1553932"/><file name="slider-sep.png" hash="ec2f6209e6cf8bd2af3802accd4b0754"/><file name="sort-down.png" hash="0e8844880f3e3c8dfc57ef9891220cae"/><file name="sort-up.png" hash="4828cb352ac273ea730476760bd290b6"/><file name="tab.jpg" hash="b24b12ac429c450a3d93c39def33eab7"/><file name="tab.png" hash="809e564f8c32c53a0f0e74f85b3e7934"/><file name="tab_key.jpg" hash="b24b12ac429c450a3d93c39def33eab7"/><file name="tick.png" hash="1bc3837af70694b07569f005df42e61b"/><file name="toggle.png" hash="a6c443b70fdc9d9cf3576e0f9927a97c"/><file name="up.png" hash="83dd8253ab279bfacfe7eeb05c7ebc9b"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="JScriptz_MegaMenu2.csv" hash="ab83e9d97293163a6136649945146a5a"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
skin/frontend/base/default/images/jscriptz_megamenu2/Thumbs.db ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/add-cart-mini.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/bg-checkout.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/bg-product-tab.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/bg-search.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/bg-select.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/bg-slider.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/cart.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/checkbox.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/collapsed.gif ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/collapsed.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/comments-link.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/dotted.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/expanded.gif ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/expanded.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/glyphicons-halflings-white.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/glyphicons-halflings.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/home-icon.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/icons/Thumbs.db ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/icons/mini-icons-white.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/leftArrow.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/line1.gif ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/line1.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/line2.gif ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/line2.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/loading.gif ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/menu-sidebar-active.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/menu-sidebar.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/mini-icons-white.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/moogaloop.swf ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/page_bg.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product01@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product02@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product03@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product04@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product05@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product06@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product07@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product08@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product09@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product10@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/product11@2x.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/radio.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/rating-box.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/rating.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/rightArrow.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/select.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/separator.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/shadow.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/slider-sep.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/sort-down.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/sort-up.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/tab.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/tab.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/tab_key.jpg ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/tick.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/toggle.png ADDED
Binary file
skin/frontend/base/default/images/jscriptz_megamenu2/up.png ADDED
Binary file