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.2 |
Comparing to | |
See all releases |
Code changes from version 1.8.1.1 to 1.8.1.2
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Catalog/Product/Edit/Tab/Menuitem.php +243 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Catalog/Product/Edit/Tab/Menusetting.php +190 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Helper/Wysiwyg.php +44 -43
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem.php +38 -36
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Abstract.php +193 -182
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit.php +39 -38
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Form.php +247 -200
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Form.php +173 -126
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Menusetting.php +189 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Product.php +206 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Stores.php +48 -47
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tabs.php +75 -66
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Helper/File.php +101 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Tree.php +323 -303
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting.php +38 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit.php +62 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Form.php +43 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Form.php +79 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Menuitem.php +238 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Product.php +206 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Stores.php +48 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tabs.php +68 -0
- app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Grid.php +187 -0
- app/code/community/JScriptz/MegaMenu2/Block/Html/Topmenu.php +342 -265
- app/code/community/JScriptz/MegaMenu2/Block/Menuitem/Catalog/Product/List.php +49 -0
- app/code/community/JScriptz/MegaMenu2/Controller/Adminhtml/MegaMenu2.php +60 -59
- app/code/community/JScriptz/MegaMenu2/Helper/Data.php +25 -24
- app/code/community/JScriptz/MegaMenu2/Helper/Menuitem.php +62 -41
- app/code/community/JScriptz/MegaMenu2/Helper/Menusetting.php +34 -0
- app/code/community/JScriptz/MegaMenu2/Helper/Product.php +81 -0
- app/code/community/JScriptz/MegaMenu2/Model/Adminhtml/Observer.php +117 -0
- app/code/community/JScriptz/MegaMenu2/Model/Menuitem.php +408 -307
- app/code/community/JScriptz/MegaMenu2/Model/Menuitem/Menusetting.php +60 -0
- app/code/community/JScriptz/MegaMenu2/Model/Menuitem/Product.php +65 -0
- app/code/community/JScriptz/MegaMenu2/Model/Menusetting.php +156 -0
- app/code/community/JScriptz/MegaMenu2/Model/Menusetting/Menuitem.php +60 -0
- app/code/community/JScriptz/MegaMenu2/Model/Menusetting/Product.php +60 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem.php +578 -552
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Collection.php +264 -206
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Menusetting.php +59 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Menusetting/Collection.php +64 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Product.php +106 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Product/Collection.php +64 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Tree.php +408 -389
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting.php +121 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Collection.php +160 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Menuitem.php +82 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Menuitem/Collection.php +64 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Product.php +83 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Product/Collection.php +64 -0
- app/code/community/JScriptz/MegaMenu2/Model/Resource/Setup.php +26 -25
- app/code/community/JScriptz/MegaMenu2/Model/SystemSettings.php +14 -0
- app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/Menuitem/Catalog/ProductController.php +49 -0
- app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/MenuitemController.php +357 -311
- app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/Menusetting/Catalog/ProductController.php +62 -0
- app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/MenusettingController.php +322 -0
- app/code/community/JScriptz/MegaMenu2/data/jscriptz_megamenu2_setup/data-install-0.0.1.php +273 -235
- app/code/community/JScriptz/MegaMenu2/etc/adminhtml.xml +74 -63
- app/code/community/JScriptz/MegaMenu2/etc/config.xml +171 -110
- app/code/community/JScriptz/MegaMenu2/etc/system.xml +58 -0
- app/code/community/JScriptz/MegaMenu2/sql/jscriptz_megamenu2_setup/install-0.0.1.php +216 -93
- app/design/adminhtml/default/default/layout/jscriptz_megamenu2.xml +233 -32
- app/design/adminhtml/default/default/template/jscriptz_megamenu2/catalog/product/edit/tab/menuitem.phtml +132 -0
- app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/edit.phtml +151 -151
- app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/edit/form.phtml +275 -160
- app/design/adminhtml/default/default/template/jscriptz_megamenu2/menuitem/tree.phtml +376 -376
- app/design/adminhtml/default/default/template/jscriptz_megamenu2/menusetting/edit/tab/menuitem.phtml +130 -0
- app/design/frontend/base/default/layout/jscriptz_megamenu2.xml +32 -31
- app/design/frontend/base/default/template/jscriptz/html/topmenu.phtml +157 -47
- app/etc/modules/JScriptz_MegaMenu2.xml +25 -25
- app/locale/en_US/JScriptz_MegaMenu2.csv +32 -6
- media/menuitem/file/p/r/prod_icon.png +0 -0
- package.xml +4 -4
- skin/frontend/base/default/css/JScriptz/mgmenu.css +2 -0
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Catalog/Product/Edit/Tab/Menuitem.php
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 tab on product edit form
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Catalog_Product_Edit_Tab_Menuitem extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree{
|
25 |
+
protected $_menuitemIds = null;
|
26 |
+
protected $_selectedNodes = null;
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
* Specify template to use
|
30 |
+
* @access public
|
31 |
+
* @return void
|
32 |
+
* @author Jason Lotzer
|
33 |
+
*/
|
34 |
+
public function __construct(){
|
35 |
+
parent::__construct();
|
36 |
+
$this->setTemplate('jscriptz_megamenu2/catalog/product/edit/tab/menuitem.phtml');
|
37 |
+
}
|
38 |
+
/**
|
39 |
+
* Retrieve currently edited product
|
40 |
+
* @access public
|
41 |
+
* @return Mage_Catalog_Model_Product
|
42 |
+
* @author Jason Lotzer
|
43 |
+
*/
|
44 |
+
public function getProduct(){
|
45 |
+
return Mage::registry('current_product');
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* Return array with menu item IDs which the product is assigned to
|
49 |
+
* @access public
|
50 |
+
* @return array
|
51 |
+
* @author Jason Lotzer
|
52 |
+
*/
|
53 |
+
public function getMenuitemIds(){
|
54 |
+
if (is_null($this->_menuitemIds)){
|
55 |
+
$selectedMenuitems = Mage::helper('megamenu2/product')->getSelectedMenuitems($this->getProduct());
|
56 |
+
$ids = array();
|
57 |
+
foreach ($selectedMenuitems as $menuitem){
|
58 |
+
$ids[] = $menuitem->getId();
|
59 |
+
}
|
60 |
+
$this->_menuitemIds = $ids;
|
61 |
+
}
|
62 |
+
return $this->_menuitemIds;
|
63 |
+
}
|
64 |
+
/**
|
65 |
+
* Forms string out of getMenuitemIds()
|
66 |
+
* @access public
|
67 |
+
* @return string
|
68 |
+
* @author Jason Lotzer
|
69 |
+
*/
|
70 |
+
public function getIdsString(){
|
71 |
+
return implode(',', $this->getMenuitemIds());
|
72 |
+
}
|
73 |
+
/**
|
74 |
+
* Returns root node and sets 'checked' flag (if necessary)
|
75 |
+
* @access public
|
76 |
+
* @return Varien_Data_Tree_Node
|
77 |
+
* @author Jason Lotzer
|
78 |
+
*/
|
79 |
+
public function getRootNode(){
|
80 |
+
$root = $this->getRoot();
|
81 |
+
if ($root && in_array($root->getId(), $this->getMenuitemIds())) {
|
82 |
+
$root->setChecked(true);
|
83 |
+
}
|
84 |
+
return $root;
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* Returns root node
|
88 |
+
*
|
89 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem|null $parentNodeMenuitem
|
90 |
+
* @param int $recursionLevel
|
91 |
+
* @return Varien_Data_Tree_Node
|
92 |
+
* @author Jason Lotzer
|
93 |
+
*/
|
94 |
+
public function getRoot($parentNodeMenuitem = null, $recursionLevel = 3){
|
95 |
+
if (!is_null($parentNodeMenuitem) && $parentNodeMenuitem->getId()) {
|
96 |
+
return $this->getNode($parentNodeMenuitem, $recursionLevel);
|
97 |
+
}
|
98 |
+
$root = Mage::registry('menuitem_root');
|
99 |
+
if (is_null($root)) {
|
100 |
+
$rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
101 |
+
|
102 |
+
$ids = $this->getSelectedFMenuitemPathIds($rootId);
|
103 |
+
$tree = Mage::getResourceSingleton('megamenu2/menuitem_tree')
|
104 |
+
->loadByIds($ids, false, false);
|
105 |
+
if ($this->getMenuitem()) {
|
106 |
+
$tree->loadEnsuredNodes($this->getMenuitem(), $tree->getNodeById($rootId));
|
107 |
+
}
|
108 |
+
$tree->addCollectionData($this->getMenuitemCollection());
|
109 |
+
$root = $tree->getNodeById($rootId);
|
110 |
+
Mage::register('menuitem_root', $root);
|
111 |
+
}
|
112 |
+
return $root;
|
113 |
+
}
|
114 |
+
/**
|
115 |
+
* Returns array with configuration of current node
|
116 |
+
* @access protected
|
117 |
+
* @param Varien_Data_Tree_Node $node
|
118 |
+
* @param int $level How deep is the node in the tree
|
119 |
+
* @return array
|
120 |
+
* @author Jason Lotzer
|
121 |
+
*/
|
122 |
+
protected function _getNodeJson($node, $level = 1){
|
123 |
+
$item = parent::_getNodeJson($node, $level);
|
124 |
+
if ($this->_isParentSelectedMenuitem($node)) {
|
125 |
+
$item['expanded'] = true;
|
126 |
+
}
|
127 |
+
if (in_array($node->getId(), $this->getMenuitemIds())) {
|
128 |
+
$item['checked'] = true;
|
129 |
+
}
|
130 |
+
return $item;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Returns whether $node is a parent (not exactly direct) of a selected node
|
135 |
+
* @access protected
|
136 |
+
* @param Varien_Data_Tree_Node $node
|
137 |
+
* @return bool
|
138 |
+
* @author Jason Lotzer
|
139 |
+
*/
|
140 |
+
protected function _isParentSelectedMenuitem($node){
|
141 |
+
$result = false;
|
142 |
+
// Contains string with all menu item IDs of children (not exactly direct) of the node
|
143 |
+
$allChildren = $node->getAllChildren();
|
144 |
+
if ($allChildren) {
|
145 |
+
$selectedMenuitemIds = $this->getMenuitemIds();
|
146 |
+
$allChildrenArr = explode(',', $allChildren);
|
147 |
+
for ($i = 0, $cnt = count($selectedMenuitemIds); $i < $cnt; $i++) {
|
148 |
+
$isSelf = $node->getId() == $selectedMenuitemIds[$i];
|
149 |
+
if (!$isSelf && in_array($selectedMenuitemIds[$i], $allChildrenArr)) {
|
150 |
+
$result = true;
|
151 |
+
break;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
return $result;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Returns array with nodes those are selected (contain current product)
|
160 |
+
* @access protected
|
161 |
+
* @return array
|
162 |
+
* @author Jason Lotzer
|
163 |
+
*/
|
164 |
+
protected function _getSelectedNodes(){
|
165 |
+
if ($this->_selectedNodes === null) {
|
166 |
+
$this->_selectedNodes = array();
|
167 |
+
$root = $this->getRoot();
|
168 |
+
foreach ($this->getMenuitemIds() as $menuitemId) {
|
169 |
+
if ($root) {
|
170 |
+
$this->_selectedNodes[] = $root->getTree()->getNodeById($menuitemId);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
return $this->_selectedNodes;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Returns JSON-encoded array of menu item children
|
179 |
+
* @access public
|
180 |
+
* @param int $menuitemId
|
181 |
+
* @return string
|
182 |
+
* @author Jason Lotzer
|
183 |
+
*/
|
184 |
+
public function getMenuitemChildrenJson($menuitemId){
|
185 |
+
$menuitem = Mage::getModel('megamenu2/menuitem')->load($menuitemId);
|
186 |
+
$node = $this->getRoot($menuitem, 1)->getTree()->getNodeById($menuitemId);
|
187 |
+
if (!$node || !$node->hasChildren()) {
|
188 |
+
return '[]';
|
189 |
+
}
|
190 |
+
|
191 |
+
$children = array();
|
192 |
+
foreach ($node->getChildren() as $child) {
|
193 |
+
$children[] = $this->_getNodeJson($child);
|
194 |
+
}
|
195 |
+
return Mage::helper('core')->jsonEncode($children);
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Returns URL for loading tree
|
200 |
+
* @access public
|
201 |
+
* @param null $expanded
|
202 |
+
* @return string
|
203 |
+
* @author Jason Lotzer
|
204 |
+
*/
|
205 |
+
public function getLoadTreeUrl($expanded = null){
|
206 |
+
return $this->getUrl('*/*/menuitemsJson', array('_current' => true));
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Return distinct path ids of selected menu items
|
211 |
+
* @access public
|
212 |
+
* @param mixed $rootId Root menu item Id for context
|
213 |
+
* @return array
|
214 |
+
* @author Jason Lotzer
|
215 |
+
*/
|
216 |
+
public function getSelectedMenuitemPathIds($rootId = false){
|
217 |
+
$ids = array();
|
218 |
+
$menuitemIds = $this->getMenuitemIds();
|
219 |
+
if (empty($menuitemIds)) {
|
220 |
+
return array();
|
221 |
+
}
|
222 |
+
$collection = Mage::getResourceModel('megamenu2/menuitem_collection');
|
223 |
+
|
224 |
+
if ($rootId) {
|
225 |
+
$collection->addFieldToFilter('parent_id', $rootId);
|
226 |
+
}
|
227 |
+
else {
|
228 |
+
$collection->addFieldToFilter('entity_id', array('in'=>$menuitemIds));
|
229 |
+
}
|
230 |
+
|
231 |
+
foreach ($collection as $item) {
|
232 |
+
if ($rootId && !in_array($rootId, $item->getPathIds())) {
|
233 |
+
continue;
|
234 |
+
}
|
235 |
+
foreach ($item->getPathIds() as $id) {
|
236 |
+
if (!in_array($id, $ids)) {
|
237 |
+
$ids[] = $id;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
return $ids;
|
242 |
+
}
|
243 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Catalog/Product/Edit/Tab/Menusetting.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting tab on product edit form
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Catalog_Product_Edit_Tab_Menusetting extends Mage_Adminhtml_Block_Widget_Grid{
|
25 |
+
/**
|
26 |
+
* Set grid params
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('menusetting_grid');
|
34 |
+
$this->setDefaultSort('position');
|
35 |
+
$this->setDefaultDir('ASC');
|
36 |
+
$this->setUseAjax(true);
|
37 |
+
if ($this->getProduct()->getId()) {
|
38 |
+
$this->setDefaultFilter(array('in_menusettings'=>1));
|
39 |
+
}
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* prepare the menusetting collection
|
43 |
+
* @access protected
|
44 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Catalog_Product_Edit_Tab_Menusetting
|
45 |
+
* @author Jason Lotzer
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection() {
|
48 |
+
$collection = Mage::getResourceModel('megamenu2/menusetting_collection');
|
49 |
+
if ($this->getProduct()->getId()){
|
50 |
+
$constraint = 'related.product_id='.$this->getProduct()->getId();
|
51 |
+
}
|
52 |
+
else{
|
53 |
+
$constraint = 'related.product_id=0';
|
54 |
+
}
|
55 |
+
$collection->getSelect()->joinLeft(
|
56 |
+
array('related'=>$collection->getTable('megamenu2/menusetting_product')),
|
57 |
+
'related.menusetting_id=main_table.entity_id AND '.$constraint,
|
58 |
+
array('position')
|
59 |
+
);
|
60 |
+
$this->setCollection($collection);
|
61 |
+
parent::_prepareCollection();
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
/**
|
65 |
+
* prepare mass action grid
|
66 |
+
* @access protected
|
67 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Catalog_Product_Edit_Tab_Menusetting
|
68 |
+
* @author Jason Lotzer
|
69 |
+
*/
|
70 |
+
protected function _prepareMassaction(){
|
71 |
+
return $this;
|
72 |
+
}
|
73 |
+
/**
|
74 |
+
* prepare the grid columns
|
75 |
+
* @access protected
|
76 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Catalog_Product_Edit_Tab_Menusetting
|
77 |
+
* @author Jason Lotzer
|
78 |
+
*/
|
79 |
+
protected function _prepareColumns(){
|
80 |
+
$this->addColumn('in_menusettings', array(
|
81 |
+
'header_css_class' => 'a-center',
|
82 |
+
'type' => 'checkbox',
|
83 |
+
'name' => 'in_menusettings',
|
84 |
+
'values'=> $this->_getSelectedMenusettings(),
|
85 |
+
'align' => 'center',
|
86 |
+
'index' => 'entity_id'
|
87 |
+
));
|
88 |
+
$this->addColumn('menutitle', array(
|
89 |
+
'header'=> Mage::helper('megamenu2')->__('Menu Title'),
|
90 |
+
'align' => 'left',
|
91 |
+
'index' => 'menutitle',
|
92 |
+
));
|
93 |
+
$this->addColumn('position', array(
|
94 |
+
'header' => Mage::helper('megamenu2')->__('Position'),
|
95 |
+
'name' => 'position',
|
96 |
+
'width' => 60,
|
97 |
+
'type' => 'number',
|
98 |
+
'validate_class'=> 'validate-number',
|
99 |
+
'index' => 'position',
|
100 |
+
'editable' => true,
|
101 |
+
));
|
102 |
+
}
|
103 |
+
/**
|
104 |
+
* Retrieve selected menusettings
|
105 |
+
* @access protected
|
106 |
+
* @return array
|
107 |
+
* @author Jason Lotzer
|
108 |
+
*/
|
109 |
+
protected function _getSelectedMenusettings(){
|
110 |
+
$menusettings = $this->getProductMenusettings();
|
111 |
+
if (!is_array($menusettings)) {
|
112 |
+
$menusettings = array_keys($this->getSelectedMenusettings());
|
113 |
+
}
|
114 |
+
return $menusettings;
|
115 |
+
}
|
116 |
+
/**
|
117 |
+
* Retrieve selected menusettings
|
118 |
+
* @access protected
|
119 |
+
* @return array
|
120 |
+
* @author Jason Lotzer
|
121 |
+
*/
|
122 |
+
public function getSelectedMenusettings() {
|
123 |
+
$menusettings = array();
|
124 |
+
//used helper here in order not to override the product model
|
125 |
+
$selected = Mage::helper('megamenu2/product')->getSelectedMenusettings(Mage::registry('current_product'));
|
126 |
+
if (!is_array($selected)){
|
127 |
+
$selected = array();
|
128 |
+
}
|
129 |
+
foreach ($selected as $menusetting) {
|
130 |
+
$menusettings[$menusetting->getId()] = array('position' => $menusetting->getPosition());
|
131 |
+
}
|
132 |
+
return $menusettings;
|
133 |
+
}
|
134 |
+
/**
|
135 |
+
* get row url
|
136 |
+
* @access public
|
137 |
+
* @return string
|
138 |
+
* @author Jason Lotzer
|
139 |
+
*/
|
140 |
+
public function getRowUrl($item){
|
141 |
+
return '#';
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* get grid url
|
145 |
+
* @access public
|
146 |
+
* @return string
|
147 |
+
* @author Jason Lotzer
|
148 |
+
*/
|
149 |
+
public function getGridUrl(){
|
150 |
+
return $this->getUrl('*/*/menusettingsGrid', array(
|
151 |
+
'id'=>$this->getProduct()->getId()
|
152 |
+
));
|
153 |
+
}
|
154 |
+
/**
|
155 |
+
* get the current product
|
156 |
+
* @access public
|
157 |
+
* @return Mage_Catalog_Model_Product
|
158 |
+
* @author Jason Lotzer
|
159 |
+
*/
|
160 |
+
public function getProduct(){
|
161 |
+
return Mage::registry('current_product');
|
162 |
+
}
|
163 |
+
/**
|
164 |
+
* Add filter
|
165 |
+
* @access protected
|
166 |
+
* @param object $column
|
167 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Catalog_Product_Edit_Tab_Menusetting
|
168 |
+
* @author Jason Lotzer
|
169 |
+
*/
|
170 |
+
protected function _addColumnFilterToCollection($column){
|
171 |
+
if ($column->getId() == 'in_menusettings') {
|
172 |
+
$menusettingIds = $this->_getSelectedMenusettings();
|
173 |
+
if (empty($menusettingIds)) {
|
174 |
+
$menusettingIds = 0;
|
175 |
+
}
|
176 |
+
if ($column->getFilter()->getValue()) {
|
177 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$menusettingIds));
|
178 |
+
}
|
179 |
+
else {
|
180 |
+
if($menusettingIds) {
|
181 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$menusettingIds));
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
else {
|
186 |
+
parent::_addColumnFilterToCollection($column);
|
187 |
+
}
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Helper/Wysiwyg.php
CHANGED
@@ -1,43 +1,44 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @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 |
-
|
31 |
-
|
32 |
-
$
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
'
|
40 |
-
|
41 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function getAfterElementHtml(){
|
32 |
+
$html = parent::getAfterElementHtml();
|
33 |
+
$disabled = ($this->getDisabled() || $this->getReadonly());
|
34 |
+
$html .= Mage::getSingleton('core/layout')
|
35 |
+
->createBlock('adminhtml/widget_button', '', array(
|
36 |
+
'label' => Mage::helper('catalog')->__('WYSIWYG Editor'),
|
37 |
+
'type'=> 'button',
|
38 |
+
'disabled' => $disabled,
|
39 |
+
'class' => ($disabled) ? 'disabled btn-wysiwyg' : 'btn-wysiwyg',
|
40 |
+
'onclick' => 'catalogWysiwygEditor.open(\''.Mage::helper('adminhtml')->getUrl('*/*/wysiwyg').'\', \''.$this->getHtmlId().'\')'
|
41 |
+
))->toHtml();
|
42 |
+
return $html;
|
43 |
+
}
|
44 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem.php
CHANGED
@@ -1,36 +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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item admin block
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
* @
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
$this->
|
33 |
-
$this->
|
34 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
$this->_controller = 'adminhtml_menuitem';
|
33 |
+
$this->_blockGroup = 'megamenu2';
|
34 |
+
$this->_headerText = Mage::helper('megamenu2')->__('Menu Item');
|
35 |
+
$this->_addButtonLabel = Mage::helper('megamenu2')->__('Add Menu Item');
|
36 |
+
parent::__construct();
|
37 |
+
}
|
38 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Abstract.php
CHANGED
@@ -1,182 +1,193 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item admin block abstract
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
*
|
36 |
-
* @
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
*
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
$
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
Mage::
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$tree->
|
128 |
-
Mage::
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$tree->
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
*
|
167 |
-
* @
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
return $this->getUrl(
|
173 |
-
}
|
174 |
-
/**
|
175 |
-
*
|
176 |
-
* @access public
|
177 |
-
* @
|
178 |
-
|
179 |
-
|
180 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function getMenuitem(){
|
32 |
+
return Mage::registry('menuitem');
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* get current menu item id
|
36 |
+
* @access public
|
37 |
+
* @return int
|
38 |
+
* @author Jason Lotzer
|
39 |
+
*/
|
40 |
+
public function getMenuitemId(){
|
41 |
+
if ($this->getMenuitem()) {
|
42 |
+
return $this->getMenuitem()->getId();
|
43 |
+
}
|
44 |
+
return null;
|
45 |
+
}
|
46 |
+
/**
|
47 |
+
* get current menu item Link Title
|
48 |
+
* @access public
|
49 |
+
* @return string
|
50 |
+
* @author Jason Lotzer
|
51 |
+
*/
|
52 |
+
public function getMenuitemLinktitle(){
|
53 |
+
return $this->getMenuitem()->getLinktitle();
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* get current menu item path
|
57 |
+
* @access public
|
58 |
+
* @return string
|
59 |
+
* @author Jason Lotzer
|
60 |
+
*/
|
61 |
+
public function getMenuitemPath(){
|
62 |
+
if ($this->getMenuitem()) {
|
63 |
+
return $this->getMenuitem()->getPath();
|
64 |
+
}
|
65 |
+
return Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
66 |
+
}
|
67 |
+
/**
|
68 |
+
* check if there is a root menu item
|
69 |
+
* @access public
|
70 |
+
* @return bool
|
71 |
+
* @author Jason Lotzer
|
72 |
+
*/
|
73 |
+
public function hasRootMenuitem(){
|
74 |
+
$root = $this->getRoot();
|
75 |
+
if ($root && $root->getId()) {
|
76 |
+
return true;
|
77 |
+
}
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
/**
|
81 |
+
* get the root
|
82 |
+
* @access publoc
|
83 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem|null $parentNodeMenuitem
|
84 |
+
* @param int $recursionLevel
|
85 |
+
* @return Varien_Data_Tree_Node
|
86 |
+
* @author Jason Lotzer
|
87 |
+
*/
|
88 |
+
public function getRoot($parentNodeMenuitem = null, $recursionLevel = 3){
|
89 |
+
if (!is_null($parentNodeMenuitem) && $parentNodeMenuitem->getId()) {
|
90 |
+
return $this->getNode($parentNodeMenuitem, $recursionLevel);
|
91 |
+
}
|
92 |
+
$root = Mage::registry('root');
|
93 |
+
if (is_null($root)) {
|
94 |
+
$rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
95 |
+
$tree = Mage::getResourceSingleton('megamenu2/menuitem_tree')
|
96 |
+
->load(null, $recursionLevel);
|
97 |
+
if ($this->getMenuitem()) {
|
98 |
+
$tree->loadEnsuredNodes($this->getMenuitem(), $tree->getNodeById($rootId));
|
99 |
+
}
|
100 |
+
$tree->addCollectionData($this->getMenuitemCollection());
|
101 |
+
$root = $tree->getNodeById($rootId);
|
102 |
+
if ($root && $rootId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
|
103 |
+
$root->setIsVisible(true);
|
104 |
+
}
|
105 |
+
elseif($root && $root->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
|
106 |
+
$root->setLinktitle(Mage::helper('megamenu2')->__('Root'));
|
107 |
+
}
|
108 |
+
Mage::register('root', $root);
|
109 |
+
}
|
110 |
+
return $root;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get and register menu items root by specified menu items IDs
|
115 |
+
* @accsess public
|
116 |
+
* @param array $ids
|
117 |
+
* @return Varien_Data_Tree_Node
|
118 |
+
* @author Jason Lotzer
|
119 |
+
*/
|
120 |
+
public function getRootByIds($ids){
|
121 |
+
$root = Mage::registry('root');
|
122 |
+
if (null === $root) {
|
123 |
+
$menuitemTreeResource = Mage::getResourceSingleton('megamenu2/menuitem_tree');
|
124 |
+
$ids = $menuitemTreeResource->getExistingMenuitemIdsBySpecifiedIds($ids);
|
125 |
+
$tree = $menuitemTreeResource->loadByIds($ids);
|
126 |
+
$rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
127 |
+
$root = $tree->getNodeById($rootId);
|
128 |
+
if ($root && $rootId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
|
129 |
+
$root->setIsVisible(true);
|
130 |
+
}
|
131 |
+
else if($root && $root->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
|
132 |
+
$root->setName(Mage::helper('megamenu2')->__('Root'));
|
133 |
+
}
|
134 |
+
$tree->addCollectionData($this->getMenuitemCollection());
|
135 |
+
Mage::register('root', $root);
|
136 |
+
}
|
137 |
+
return $root;
|
138 |
+
}
|
139 |
+
/**
|
140 |
+
* get specific node
|
141 |
+
* @access public
|
142 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $parentNodeMenuitem
|
143 |
+
* @param $int $recursionLevel
|
144 |
+
* @return Varien_Data_Tree_Node
|
145 |
+
* @author Jason Lotzer
|
146 |
+
*/
|
147 |
+
public function getNode($parentNodeMenuitem, $recursionLevel = 2){
|
148 |
+
$tree = Mage::getResourceModel('megamenu2/menuitem_tree');
|
149 |
+
$nodeId = $parentNodeMenuitem->getId();
|
150 |
+
$parentId = $parentNodeMenuitem->getParentId();
|
151 |
+
$node = $tree->loadNode($nodeId);
|
152 |
+
$node->loadChildren($recursionLevel);
|
153 |
+
if ($node && $nodeId != Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
|
154 |
+
$node->setIsVisible(true);
|
155 |
+
}
|
156 |
+
elseif($node && $node->getId() == Mage::helper('megamenu2/menuitem')->getRootMenuitemId()) {
|
157 |
+
$node->setLinktitle(Mage::helper('megamenu2')->__('Root'));
|
158 |
+
}
|
159 |
+
$tree->addCollectionData($this->getMenuitemCollection());
|
160 |
+
return $node;
|
161 |
+
}
|
162 |
+
/**
|
163 |
+
* get url for saving data
|
164 |
+
* @access public
|
165 |
+
* @param array $args
|
166 |
+
* @return string
|
167 |
+
* @author Jason Lotzer
|
168 |
+
*/
|
169 |
+
public function getSaveUrl(array $args = array()){
|
170 |
+
$params = array('_current'=>true);
|
171 |
+
$params = array_merge($params, $args);
|
172 |
+
return $this->getUrl('*/*/save', $params);
|
173 |
+
}
|
174 |
+
/**
|
175 |
+
* get url for edit
|
176 |
+
* @access public
|
177 |
+
* @param array $args
|
178 |
+
* @return string
|
179 |
+
* @author Jason Lotzer
|
180 |
+
*/
|
181 |
+
public function getEditUrl(){
|
182 |
+
return $this->getUrl("*/MegaMenu2_menuitem/edit", array('_current'=>true, '_query'=>false, 'id'=>null, 'parent'=>null));
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* Return root ids
|
186 |
+
* @access public
|
187 |
+
* @return array
|
188 |
+
* @author Jason Lotzer
|
189 |
+
*/
|
190 |
+
public function getRootIds(){
|
191 |
+
return array(Mage::helper('megamenu2/menuitem')->getRootMenuitemId());
|
192 |
+
}
|
193 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit.php
CHANGED
@@ -1,38 +1,39 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item admin edit form
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
31 |
-
|
32 |
-
$this->
|
33 |
-
$this->
|
34 |
-
$this->
|
35 |
-
|
36 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
$this->_objectId = 'entity_id';
|
33 |
+
$this->_blockGroup = 'megamenu2';
|
34 |
+
$this->_controller = 'adminhtml_menuitem';
|
35 |
+
$this->_mode = 'edit';
|
36 |
+
parent::__construct();
|
37 |
+
$this->setTemplate('jscriptz_megamenu2/menuitem/edit.phtml');
|
38 |
+
}
|
39 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Form.php
CHANGED
@@ -1,200 +1,247 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item edit form
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
*
|
44 |
-
* @
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$this->
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
'
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
return $this
|
156 |
-
}
|
157 |
-
/**
|
158 |
-
* get
|
159 |
-
* @access public
|
160 |
-
* @return string
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
*
|
183 |
-
* @
|
184 |
-
* @
|
185 |
-
* @
|
186 |
-
*/
|
187 |
-
public function
|
188 |
-
$params = array('_current'=>true);
|
189 |
-
$params = array_merge($params, $args);
|
190 |
-
return $this->getUrl('*/*/
|
191 |
-
}
|
192 |
-
/**
|
193 |
-
*
|
194 |
-
* @access public
|
195 |
-
* @
|
196 |
-
|
197 |
-
|
198 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
37 |
+
*/
|
38 |
+
public function __construct(){
|
39 |
+
parent::__construct();
|
40 |
+
$this->setTemplate('jscriptz_megamenu2/menuitem/edit/form.phtml');
|
41 |
+
}
|
42 |
+
/**
|
43 |
+
* prepare the layout
|
44 |
+
* @access protected
|
45 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
|
46 |
+
* @author Jason Lotzer
|
47 |
+
*/
|
48 |
+
protected function _prepareLayout(){
|
49 |
+
$menuitem = $this->getMenuitem();
|
50 |
+
$menuitemId = (int)$menuitem->getId();
|
51 |
+
$this->setChild('tabs',
|
52 |
+
$this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tabs', 'tabs')
|
53 |
+
);
|
54 |
+
$this->setChild('save_button',
|
55 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
56 |
+
->setData(array(
|
57 |
+
'label' => Mage::helper('megamenu2')->__('Save Menu Item'),
|
58 |
+
'onclick' => "menuitemSubmit('" . $this->getSaveUrl() . "', true)",
|
59 |
+
'class' => 'save'
|
60 |
+
))
|
61 |
+
);
|
62 |
+
// Delete button
|
63 |
+
if (!in_array($menuitemId, $this->getRootIds())) {
|
64 |
+
$this->setChild('delete_button',
|
65 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
66 |
+
->setData(array(
|
67 |
+
'label' => Mage::helper('megamenu2')->__('Delete Menu Item'),
|
68 |
+
'onclick' => "menuitemDelete('" . $this->getUrl('*/*/delete', array('_current' => true)) . "', true, {$menuitemId})",
|
69 |
+
'class' => 'delete'
|
70 |
+
))
|
71 |
+
);
|
72 |
+
}
|
73 |
+
|
74 |
+
// Reset button
|
75 |
+
$resetPath = $menuitem ? '*/*/edit' : '*/*/add';
|
76 |
+
$this->setChild('reset_button',
|
77 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
78 |
+
->setData(array(
|
79 |
+
'label' => Mage::helper('megamenu2')->__('Reset'),
|
80 |
+
'onclick' => "menuitemReset('".$this->getUrl($resetPath, array('_current'=>true))."',true)"
|
81 |
+
))
|
82 |
+
);
|
83 |
+
return parent::_prepareLayout();
|
84 |
+
}
|
85 |
+
/**
|
86 |
+
* get html for delete button
|
87 |
+
* @access public
|
88 |
+
* @return string
|
89 |
+
* @author Jason Lotzer
|
90 |
+
*/
|
91 |
+
public function getDeleteButtonHtml(){
|
92 |
+
return $this->getChildHtml('delete_button');
|
93 |
+
}
|
94 |
+
/**
|
95 |
+
* get html for save button
|
96 |
+
* @access public
|
97 |
+
* @return string
|
98 |
+
* @author Jason Lotzer
|
99 |
+
*/
|
100 |
+
public function getSaveButtonHtml(){
|
101 |
+
return $this->getChildHtml('save_button');
|
102 |
+
}
|
103 |
+
/**
|
104 |
+
* get html for reset button
|
105 |
+
* @access public
|
106 |
+
* @return string
|
107 |
+
* @author Jason Lotzer
|
108 |
+
*/
|
109 |
+
public function getResetButtonHtml(){
|
110 |
+
return $this->getChildHtml('reset_button');
|
111 |
+
}
|
112 |
+
/**
|
113 |
+
* Retrieve additional buttons html
|
114 |
+
* @access public
|
115 |
+
* @return string
|
116 |
+
* @author Jason Lotzer
|
117 |
+
*/
|
118 |
+
public function getAdditionalButtonsHtml(){
|
119 |
+
$html = '';
|
120 |
+
foreach ($this->_additionalButtons as $childName) {
|
121 |
+
$html .= $this->getChildHtml($childName);
|
122 |
+
}
|
123 |
+
return $html;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Add additional button
|
128 |
+
*
|
129 |
+
* @param string $alias
|
130 |
+
* @param array $config
|
131 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
|
132 |
+
* @author Jason Lotzer
|
133 |
+
*/
|
134 |
+
public function addAdditionalButton($alias, $config){
|
135 |
+
if (isset($config['name'])) {
|
136 |
+
$config['element_name'] = $config['name'];
|
137 |
+
}
|
138 |
+
$this->setChild($alias . '_button',
|
139 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')->addData($config));
|
140 |
+
$this->_additionalButtons[$alias] = $alias . '_button';
|
141 |
+
return $this;
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* Remove additional button
|
145 |
+
* @access public
|
146 |
+
* @param string $alias
|
147 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Form
|
148 |
+
* @author Jason Lotzer
|
149 |
+
*/
|
150 |
+
public function removeAdditionalButton($alias){
|
151 |
+
if (isset($this->_additionalButtons[$alias])) {
|
152 |
+
$this->unsetChild($this->_additionalButtons[$alias]);
|
153 |
+
unset($this->_additionalButtons[$alias]);
|
154 |
+
}
|
155 |
+
return $this;
|
156 |
+
}
|
157 |
+
/**
|
158 |
+
* get html for tabs
|
159 |
+
* @access public
|
160 |
+
* @return string
|
161 |
+
* @author Jason Lotzer
|
162 |
+
*/
|
163 |
+
public function getTabsHtml(){
|
164 |
+
return $this->getChildHtml('tabs');
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* get the form header
|
168 |
+
* @access public
|
169 |
+
* @return string
|
170 |
+
* @author Jason Lotzer
|
171 |
+
*/
|
172 |
+
public function getHeader(){
|
173 |
+
if ($this->getMenuitemId()) {
|
174 |
+
return $this->getMenuitemLinktitle();
|
175 |
+
}
|
176 |
+
else {
|
177 |
+
return Mage::helper('megamenu2')->__('New Root Menu Item');
|
178 |
+
}
|
179 |
+
}
|
180 |
+
/**
|
181 |
+
* get the delete url
|
182 |
+
* @access public
|
183 |
+
* @param array $args
|
184 |
+
* @return string
|
185 |
+
* @author Jason Lotzer
|
186 |
+
*/
|
187 |
+
public function getDeleteUrl(array $args = array()){
|
188 |
+
$params = array('_current'=>true);
|
189 |
+
$params = array_merge($params, $args);
|
190 |
+
return $this->getUrl('*/*/delete', $params);
|
191 |
+
}
|
192 |
+
/**
|
193 |
+
* Return URL for refresh input element 'path' in form
|
194 |
+
* @access public
|
195 |
+
* @param array $args
|
196 |
+
* @return string
|
197 |
+
* @author Jason Lotzer
|
198 |
+
*/
|
199 |
+
public function getRefreshPathUrl(array $args = array()){
|
200 |
+
$params = array('_current'=>true);
|
201 |
+
$params = array_merge($params, $args);
|
202 |
+
return $this->getUrl('*/*/refreshPath', $params);
|
203 |
+
}
|
204 |
+
/**
|
205 |
+
* check if request is ajax
|
206 |
+
* @access public
|
207 |
+
* @return bool
|
208 |
+
* @author Jason Lotzer
|
209 |
+
*/
|
210 |
+
public function isAjax(){
|
211 |
+
return Mage::app()->getRequest()->isXmlHttpRequest() || Mage::app()->getRequest()->getParam('isAjax');
|
212 |
+
}
|
213 |
+
/**
|
214 |
+
* get products json
|
215 |
+
* @access public
|
216 |
+
* @return string
|
217 |
+
* @author Jason Lotzer
|
218 |
+
*/
|
219 |
+
public function getProductsJson(){
|
220 |
+
$products = $this->getMenuitem()->getSelectedProducts();
|
221 |
+
if (!empty($products)) {
|
222 |
+
$positions = array();
|
223 |
+
foreach ($products as $product){
|
224 |
+
$positions[$product->getId()] = $product->getPosition();
|
225 |
+
}
|
226 |
+
return Mage::helper('core')->jsonEncode($positions);
|
227 |
+
}
|
228 |
+
return '{}';
|
229 |
+
}
|
230 |
+
/**
|
231 |
+
* get menu settings in json format
|
232 |
+
* @access public
|
233 |
+
* @return string
|
234 |
+
* @author Jason Lotzer
|
235 |
+
*/
|
236 |
+
public function getMenusettingsJson(){
|
237 |
+
$menusettings = $this->getMenuitem()->getSelectedMenusettings();
|
238 |
+
if (!empty($menusettings)) {
|
239 |
+
$positions = array();
|
240 |
+
foreach ($menusettings as $menusetting){
|
241 |
+
$positions[$menusetting->getId()] = $menusetting->getPosition();
|
242 |
+
}
|
243 |
+
return Mage::helper('core')->jsonEncode($positions);
|
244 |
+
}
|
245 |
+
return '{}';
|
246 |
+
}
|
247 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Form.php
CHANGED
@@ -1,126 +1,173 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item edit form tab
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
31 |
-
|
32 |
-
$form
|
33 |
-
$form->
|
34 |
-
$
|
35 |
-
$
|
36 |
-
$fieldset->
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
'label' => Mage::helper('megamenu2')->__('Link
|
90 |
-
'name' => '
|
91 |
-
'
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
'
|
97 |
-
'
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _prepareForm(){
|
32 |
+
$form = new Varien_Data_Form();
|
33 |
+
$form->setHtmlIdPrefix('menuitem_');
|
34 |
+
$form->setFieldNameSuffix('menuitem');
|
35 |
+
$this->setForm($form);
|
36 |
+
$fieldset = $form->addFieldset('menuitem_form', array('legend'=>Mage::helper('megamenu2')->__('Menu Item')));
|
37 |
+
$fieldset->addType('file', Mage::getConfig()->getBlockClassName('megamenu2/adminhtml_menuitem_helper_file'));
|
38 |
+
$fieldset->addType('editor', Mage::getConfig()->getBlockClassName('megamenu2/adminhtml_helper_wysiwyg'));
|
39 |
+
if (!$this->getMenuitem()->getId()) {
|
40 |
+
$parentId = $this->getRequest()->getParam('parent');
|
41 |
+
if (!$parentId) {
|
42 |
+
$parentId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
43 |
+
}
|
44 |
+
$fieldset->addField('path', 'hidden', array(
|
45 |
+
'name' => 'path',
|
46 |
+
'value' => $parentId
|
47 |
+
));
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
$fieldset->addField('id', 'hidden', array(
|
51 |
+
'name' => 'id',
|
52 |
+
'value' => $this->getMenuitem()->getId()
|
53 |
+
));
|
54 |
+
$fieldset->addField('path', 'hidden', array(
|
55 |
+
'name' => 'path',
|
56 |
+
'value' => $this->getMenuitem()->getPath()
|
57 |
+
));
|
58 |
+
}
|
59 |
+
|
60 |
+
$fieldset->addField('linktype', 'select', array(
|
61 |
+
'label' => 'Link Type',
|
62 |
+
'name' => 'linktype',
|
63 |
+
'note' => 'Select from the list of link type options',
|
64 |
+
'values' => array(
|
65 |
+
array(
|
66 |
+
'value' => 0,
|
67 |
+
'label' => 'Standard Link',
|
68 |
+
),
|
69 |
+
|
70 |
+
array(
|
71 |
+
'value' => 1,
|
72 |
+
'label' => 'Dropdown with Categories',
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'value' => 2,
|
76 |
+
'label' => 'Dropdown with HTML',
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'value' => 3,
|
80 |
+
'label' => 'Contact Us',
|
81 |
+
),
|
82 |
+
array(
|
83 |
+
'value' => 4,
|
84 |
+
'label' => 'Dropdown with Custom Featured Products',
|
85 |
+
),
|
86 |
+
),
|
87 |
+
));
|
88 |
+
$fieldset->addField('linktitle', 'text', array(
|
89 |
+
'label' => Mage::helper('megamenu2')->__('Link Title'),
|
90 |
+
'name' => 'linktitle',
|
91 |
+
'required' => true,
|
92 |
+
'class' => 'required-entry',
|
93 |
+
|
94 |
+
));
|
95 |
+
$fieldset->addField('linkpath', 'text', array(
|
96 |
+
'label' => Mage::helper('megamenu2')->__('Link Path'),
|
97 |
+
'note' => 'The URL you want the link to point to',
|
98 |
+
'name' => 'linkpath',
|
99 |
+
|
100 |
+
));
|
101 |
+
$fieldset->addField('linkclass', 'text', array(
|
102 |
+
'label' => Mage::helper('megamenu2')->__('Link Class'),
|
103 |
+
'note' => 'CSS class to style your link',
|
104 |
+
'name' => 'linkclass',
|
105 |
+
));
|
106 |
+
$fieldset->addField('titletag', 'text', array(
|
107 |
+
'label' => Mage::helper('megamenu2')->__('Title Tag'),
|
108 |
+
'note' => 'Title Tag that shows a tooltip on hover, also good for seo purposes',
|
109 |
+
'name' => 'titletag',
|
110 |
+
));
|
111 |
+
$fieldset->addField('linktarget', 'select', array(
|
112 |
+
'label' => 'Target',
|
113 |
+
'name' => 'linktarget',
|
114 |
+
'note' => 'Sets whether the link opens in same window or different tab',
|
115 |
+
'values' => array(
|
116 |
+
array(
|
117 |
+
'value' => 0,
|
118 |
+
'label' => 'Same Window',
|
119 |
+
),
|
120 |
+
|
121 |
+
array(
|
122 |
+
'value' => 1,
|
123 |
+
'label' => 'New Tab',
|
124 |
+
),
|
125 |
+
),
|
126 |
+
));
|
127 |
+
//if($this->getMenuItem()->getData('linktype') == 2){
|
128 |
+
$fieldset->addField('menuhtml', 'editor', array(
|
129 |
+
'label' => Mage::helper('megamenu2')->__('Menu HTML'),
|
130 |
+
'name' => 'menuhtml',
|
131 |
+
|
132 |
+
));
|
133 |
+
//}
|
134 |
+
$fieldset->addField('linkimage', 'file', array(
|
135 |
+
'label' => Mage::helper('megamenu2')->__('Link Image'),
|
136 |
+
'name' => 'linkimage',
|
137 |
+
'note' => $this->__('Upload an image to include next to your menu link'),
|
138 |
+
|
139 |
+
));
|
140 |
+
$fieldset->addField('status', 'select', array(
|
141 |
+
'label' => Mage::helper('megamenu2')->__('Status'),
|
142 |
+
'name' => 'status',
|
143 |
+
'values'=> array(
|
144 |
+
array(
|
145 |
+
'value' => 1,
|
146 |
+
'label' => Mage::helper('megamenu2')->__('Enabled'),
|
147 |
+
),
|
148 |
+
array(
|
149 |
+
'value' => 0,
|
150 |
+
'label' => Mage::helper('megamenu2')->__('Disabled'),
|
151 |
+
),
|
152 |
+
),
|
153 |
+
));
|
154 |
+
if (Mage::app()->isSingleStoreMode()){
|
155 |
+
$fieldset->addField('store_id', 'hidden', array(
|
156 |
+
'name' => 'stores[]',
|
157 |
+
'value' => Mage::app()->getStore(true)->getId()
|
158 |
+
));
|
159 |
+
Mage::registry('current_menuitem')->setStoreId(Mage::app()->getStore(true)->getId());
|
160 |
+
}
|
161 |
+
$form->addValues($this->getMenuitem()->getData());
|
162 |
+
return parent::_prepareForm();
|
163 |
+
|
164 |
+
}
|
165 |
+
/**
|
166 |
+
* get the current menu item
|
167 |
+
* @access public
|
168 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
169 |
+
*/
|
170 |
+
public function getMenuitem(){
|
171 |
+
return Mage::registry('menuitem');
|
172 |
+
}
|
173 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Menusetting.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* menuitem - menusetting relation edit block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Menusetting extends Mage_Adminhtml_Block_Widget_Grid{
|
25 |
+
/**
|
26 |
+
* Set grid params
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('menusetting_grid');
|
34 |
+
$this->setDefaultSort('position');
|
35 |
+
$this->setDefaultDir('ASC');
|
36 |
+
$this->setUseAjax(true);
|
37 |
+
if ($this->getMenuitem()->getId()) {
|
38 |
+
$this->setDefaultFilter(array('in_menusettings'=>1));
|
39 |
+
}
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* prepare the menusetting collection
|
43 |
+
* @access protected
|
44 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Menusetting
|
45 |
+
* @author Jason Lotzer
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection() {
|
48 |
+
$collection = Mage::getResourceModel('megamenu2/menusetting_collection');
|
49 |
+
if ($this->getMenuitem()->getId()){
|
50 |
+
$constraint = 'related.menuitem_id='.$this->getMenuitem()->getId();
|
51 |
+
}
|
52 |
+
else{
|
53 |
+
$constraint = 'related.menuitem_id=0';
|
54 |
+
}
|
55 |
+
$collection->getSelect()->joinLeft(
|
56 |
+
array('related'=>$collection->getTable('megamenu2/menuitem_menusetting')),
|
57 |
+
'related.menusetting_id=main_table.entity_id AND '.$constraint,
|
58 |
+
array('position'));
|
59 |
+
$this->setCollection($collection);
|
60 |
+
parent::_prepareCollection();
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
/**
|
64 |
+
* prepare mass action grid
|
65 |
+
* @access protected
|
66 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Menusetting
|
67 |
+
* @author Jason Lotzer
|
68 |
+
*/
|
69 |
+
protected function _prepareMassaction(){
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
/**
|
73 |
+
* prepare the grid columns
|
74 |
+
* @access protected
|
75 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Menusetting
|
76 |
+
* @author Jason Lotzer
|
77 |
+
*/
|
78 |
+
protected function _prepareColumns(){
|
79 |
+
$this->addColumn('in_menusettings', array(
|
80 |
+
'header_css_class' => 'a-center',
|
81 |
+
'type' => 'checkbox',
|
82 |
+
'name' => 'in_menusettings',
|
83 |
+
'values'=> $this->_getSelectedMenusettings(),
|
84 |
+
'align' => 'center',
|
85 |
+
'index' => 'entity_id'
|
86 |
+
));
|
87 |
+
$this->addColumn('menutitle', array(
|
88 |
+
'header'=> Mage::helper('megamenu2')->__('Menu Title'),
|
89 |
+
'align' => 'left',
|
90 |
+
'index' => 'menutitle',
|
91 |
+
));
|
92 |
+
$this->addColumn('position', array(
|
93 |
+
'header'=> Mage::helper('megamenu2')->__('Position'),
|
94 |
+
'name' => 'position',
|
95 |
+
'width' => 60,
|
96 |
+
'type' => 'number',
|
97 |
+
'validate_class'=> 'validate-number',
|
98 |
+
'index' => 'position',
|
99 |
+
'editable' => true,
|
100 |
+
));
|
101 |
+
}
|
102 |
+
/**
|
103 |
+
* Retrieve selected menusettings
|
104 |
+
* @access protected
|
105 |
+
* @return array
|
106 |
+
* @author Jason Lotzer
|
107 |
+
*/
|
108 |
+
protected function _getSelectedMenusettings(){
|
109 |
+
$menusettings = $this->getMenuitemMenusettings();
|
110 |
+
if (!is_array($menusettings)) {
|
111 |
+
$menusettings = array_keys($this->getSelectedMenusettings());
|
112 |
+
}
|
113 |
+
return $menusettings;
|
114 |
+
}
|
115 |
+
/**
|
116 |
+
* Retrieve selected menusettings
|
117 |
+
* @access protected
|
118 |
+
* @return array
|
119 |
+
* @author Jason Lotzer
|
120 |
+
*/
|
121 |
+
public function getSelectedMenusettings() {
|
122 |
+
$menusettings = array();
|
123 |
+
$selected = Mage::registry('current_menuitem')->getSelectedMenusettings();
|
124 |
+
if (!is_array($selected)){
|
125 |
+
$selected = array();
|
126 |
+
}
|
127 |
+
foreach ($selected as $menusetting) {
|
128 |
+
$menusettings[$menusetting->getId()] = array('position' => $menusetting->getPosition());
|
129 |
+
}
|
130 |
+
return $menusettings;
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* get row url
|
134 |
+
* @access public
|
135 |
+
* @return string
|
136 |
+
* @author Jason Lotzer
|
137 |
+
*/
|
138 |
+
public function getRowUrl($item){
|
139 |
+
return '#';
|
140 |
+
}
|
141 |
+
/**
|
142 |
+
* get grid url
|
143 |
+
* @access public
|
144 |
+
* @return string
|
145 |
+
* @author Jason Lotzer
|
146 |
+
*/
|
147 |
+
public function getGridUrl(){
|
148 |
+
return $this->getUrl('*/*/menusettingsGrid', array(
|
149 |
+
'id'=>$this->getMenuitem()->getId()
|
150 |
+
));
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
* get the current menuitem
|
154 |
+
* @access public
|
155 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
156 |
+
* @author Jason Lotzer
|
157 |
+
*/
|
158 |
+
public function getMenuitem(){
|
159 |
+
return Mage::registry('current_menuitem');
|
160 |
+
}
|
161 |
+
/**
|
162 |
+
* Add filter
|
163 |
+
* @access protected
|
164 |
+
* @param object $column
|
165 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Menusetting
|
166 |
+
* @author Jason Lotzer
|
167 |
+
*/
|
168 |
+
protected function _addColumnFilterToCollection($column){
|
169 |
+
// Set custom filter for in product flag
|
170 |
+
if ($column->getId() == 'in_menusettings') {
|
171 |
+
$menusettingIds = $this->_getSelectedMenusettings();
|
172 |
+
if (empty($menusettingIds)) {
|
173 |
+
$menusettingIds = 0;
|
174 |
+
}
|
175 |
+
if ($column->getFilter()->getValue()) {
|
176 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$menusettingIds));
|
177 |
+
}
|
178 |
+
else {
|
179 |
+
if($menusettingIds) {
|
180 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$menusettingIds));
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
else {
|
185 |
+
parent::_addColumnFilterToCollection($column);
|
186 |
+
}
|
187 |
+
return $this;
|
188 |
+
}
|
189 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Product.php
ADDED
@@ -0,0 +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 - product relation edit block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid{
|
25 |
+
/**
|
26 |
+
* Set grid params
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('product_grid');
|
34 |
+
$this->setDefaultSort('position');
|
35 |
+
$this->setDefaultDir('ASC');
|
36 |
+
$this->setUseAjax(true);
|
37 |
+
if ($this->getMenuitem()->getId()) {
|
38 |
+
$this->setDefaultFilter(array('in_products'=>1));
|
39 |
+
}
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* prepare the product collection
|
43 |
+
* @access protected
|
44 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Product
|
45 |
+
* @author Jason Lotzer
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection() {
|
48 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
49 |
+
$collection->addAttributeToSelect('price');
|
50 |
+
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
51 |
+
$collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore);
|
52 |
+
if ($this->getMenuitem()->getId()){
|
53 |
+
$constraint = '{{table}}.menuitem_id='.$this->getMenuitem()->getId();
|
54 |
+
}
|
55 |
+
else{
|
56 |
+
$constraint = '{{table}}.menuitem_id=0';
|
57 |
+
}
|
58 |
+
$collection->joinField('position',
|
59 |
+
'megamenu2/menuitem_product',
|
60 |
+
'position',
|
61 |
+
'product_id=entity_id',
|
62 |
+
$constraint,
|
63 |
+
'left');
|
64 |
+
$this->setCollection($collection);
|
65 |
+
parent::_prepareCollection();
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* prepare mass action grid
|
70 |
+
* @access protected
|
71 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Product
|
72 |
+
* @author Jason Lotzer
|
73 |
+
*/
|
74 |
+
protected function _prepareMassaction(){
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* prepare the grid columns
|
79 |
+
* @access protected
|
80 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Product
|
81 |
+
* @author Jason Lotzer
|
82 |
+
*/
|
83 |
+
protected function _prepareColumns(){
|
84 |
+
$this->addColumn('in_products', array(
|
85 |
+
'header_css_class' => 'a-center',
|
86 |
+
'type' => 'checkbox',
|
87 |
+
'name' => 'in_products',
|
88 |
+
'values'=> $this->_getSelectedProducts(),
|
89 |
+
'align' => 'center',
|
90 |
+
'index' => 'entity_id'
|
91 |
+
));
|
92 |
+
$this->addColumn('product_name', array(
|
93 |
+
'header'=> Mage::helper('catalog')->__('Name'),
|
94 |
+
'align' => 'left',
|
95 |
+
'index' => 'product_name',
|
96 |
+
));
|
97 |
+
$this->addColumn('sku', array(
|
98 |
+
'header'=> Mage::helper('catalog')->__('SKU'),
|
99 |
+
'align' => 'left',
|
100 |
+
'index' => 'sku',
|
101 |
+
));
|
102 |
+
$this->addColumn('price', array(
|
103 |
+
'header'=> Mage::helper('catalog')->__('Price'),
|
104 |
+
'type' => 'currency',
|
105 |
+
'width' => '1',
|
106 |
+
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
|
107 |
+
'index' => 'price'
|
108 |
+
));
|
109 |
+
$this->addColumn('position', array(
|
110 |
+
'header'=> Mage::helper('catalog')->__('Position'),
|
111 |
+
'name' => 'position',
|
112 |
+
'width' => 60,
|
113 |
+
'type' => 'number',
|
114 |
+
'validate_class'=> 'validate-number',
|
115 |
+
'index' => 'position',
|
116 |
+
'editable' => true,
|
117 |
+
));
|
118 |
+
}
|
119 |
+
/**
|
120 |
+
* Retrieve selected products
|
121 |
+
* @access protected
|
122 |
+
* @return array
|
123 |
+
* @author Jason Lotzer
|
124 |
+
*/
|
125 |
+
protected function _getSelectedProducts(){
|
126 |
+
$products = $this->getMenuitemProducts();
|
127 |
+
if (!is_array($products)) {
|
128 |
+
$products = array_keys($this->getSelectedProducts());
|
129 |
+
}
|
130 |
+
return $products;
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* Retrieve selected products
|
134 |
+
* @access protected
|
135 |
+
* @return array
|
136 |
+
* @author Jason Lotzer
|
137 |
+
*/
|
138 |
+
public function getSelectedProducts() {
|
139 |
+
$products = array();
|
140 |
+
$selected = Mage::registry('current_menuitem')->getSelectedProducts();
|
141 |
+
if (!is_array($selected)){
|
142 |
+
$selected = array();
|
143 |
+
}
|
144 |
+
foreach ($selected as $product) {
|
145 |
+
$products[$product->getId()] = array('position' => $product->getPosition());
|
146 |
+
}
|
147 |
+
return $products;
|
148 |
+
}
|
149 |
+
/**
|
150 |
+
* get row url
|
151 |
+
* @access public
|
152 |
+
* @return string
|
153 |
+
* @author Jason Lotzer
|
154 |
+
*/
|
155 |
+
public function getRowUrl($item){
|
156 |
+
return '#';
|
157 |
+
}
|
158 |
+
/**
|
159 |
+
* get grid url
|
160 |
+
* @access public
|
161 |
+
* @return string
|
162 |
+
* @author Jason Lotzer
|
163 |
+
*/
|
164 |
+
public function getGridUrl(){
|
165 |
+
return $this->getUrl('*/*/productsGrid', array(
|
166 |
+
'id'=>$this->getMenuitem()->getId()
|
167 |
+
));
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* get the current menuitem
|
171 |
+
* @access public
|
172 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
173 |
+
* @author Jason Lotzer
|
174 |
+
*/
|
175 |
+
public function getMenuitem(){
|
176 |
+
return Mage::registry('current_menuitem');
|
177 |
+
}
|
178 |
+
/**
|
179 |
+
* Add filter
|
180 |
+
* @access protected
|
181 |
+
* @param object $column
|
182 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tab_Product
|
183 |
+
* @author Jason Lotzer
|
184 |
+
*/
|
185 |
+
protected function _addColumnFilterToCollection($column){
|
186 |
+
// Set custom filter for in product flag
|
187 |
+
if ($column->getId() == 'in_products') {
|
188 |
+
$productIds = $this->_getSelectedProducts();
|
189 |
+
if (empty($productIds)) {
|
190 |
+
$productIds = 0;
|
191 |
+
}
|
192 |
+
if ($column->getFilter()->getValue()) {
|
193 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
|
194 |
+
}
|
195 |
+
else {
|
196 |
+
if($productIds) {
|
197 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
else {
|
202 |
+
parent::_addColumnFilterToCollection($column);
|
203 |
+
}
|
204 |
+
return $this;
|
205 |
+
}
|
206 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tab/Stores.php
CHANGED
@@ -1,47 +1,48 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* store selection tab
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
31 |
-
|
32 |
-
$form
|
33 |
-
$
|
34 |
-
$
|
35 |
-
$
|
36 |
-
|
37 |
-
'
|
38 |
-
'
|
39 |
-
'
|
40 |
-
'
|
41 |
-
|
42 |
-
|
43 |
-
$
|
44 |
-
|
45 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _prepareForm(){
|
32 |
+
$form = new Varien_Data_Form();
|
33 |
+
$form->setFieldNameSuffix('menuitem');
|
34 |
+
$this->setForm($form);
|
35 |
+
$fieldset = $form->addFieldset('menuitem_stores_form', array('legend'=>Mage::helper('megamenu2')->__('Store views')));
|
36 |
+
$field = $fieldset->addField('store_id', 'multiselect', array(
|
37 |
+
'name' => 'stores[]',
|
38 |
+
'label' => Mage::helper('megamenu2')->__('Store Views'),
|
39 |
+
'title' => Mage::helper('megamenu2')->__('Store Views'),
|
40 |
+
'required' => true,
|
41 |
+
'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
42 |
+
));
|
43 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
44 |
+
$field->setRenderer($renderer);
|
45 |
+
$form->addValues(Mage::registry('current_menuitem')->getData());
|
46 |
+
return parent::_prepareForm();
|
47 |
+
}
|
48 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Edit/Tabs.php
CHANGED
@@ -1,66 +1,75 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item admin edit tabs
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this->
|
34 |
-
$this->
|
35 |
-
$this->
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
*
|
40 |
-
* @
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
* @
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
'
|
55 |
-
'
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
'
|
61 |
-
'
|
62 |
-
|
63 |
-
|
64 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('menuitem_info_tabs');
|
34 |
+
$this->setDestElementId('menuitem_tab_content');
|
35 |
+
$this->setTitle(Mage::helper('megamenu2')->__('Menu Item'));
|
36 |
+
$this->setTemplate('widget/tabshoriz.phtml');
|
37 |
+
}
|
38 |
+
/**
|
39 |
+
* Retrieve menu item entity
|
40 |
+
* @access public
|
41 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
42 |
+
* @author Jason Lotzer
|
43 |
+
*/
|
44 |
+
public function getMenuitem(){
|
45 |
+
return Mage::registry('current_menuitem');
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* Prepare Layout Content
|
49 |
+
* @access public
|
50 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Edit_Tabs
|
51 |
+
*/
|
52 |
+
protected function _prepareLayout(){
|
53 |
+
$this->addTab('form_menuitem', array(
|
54 |
+
'label' => Mage::helper('megamenu2')->__('Menu Item'),
|
55 |
+
'title' => Mage::helper('megamenu2')->__('Menu Item'),
|
56 |
+
'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_form')->toHtml(),
|
57 |
+
));
|
58 |
+
if (!Mage::app()->isSingleStoreMode()){
|
59 |
+
$this->addTab('form_store_menuitem', array(
|
60 |
+
'label' => Mage::helper('megamenu2')->__('Store views'),
|
61 |
+
'title' => Mage::helper('megamenu2')->__('Store views'),
|
62 |
+
'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_stores')->toHtml(),
|
63 |
+
));
|
64 |
+
}
|
65 |
+
$this->addTab('menusettings', array(
|
66 |
+
'label' => Mage::helper('megamenu2')->__('Menu Settings'),
|
67 |
+
'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_menusetting','menuitem.menusetting.grid')->toHtml(),
|
68 |
+
));
|
69 |
+
$this->addTab('products', array(
|
70 |
+
'label' => Mage::helper('megamenu2')->__('Associated Products'),
|
71 |
+
'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_product','menuitem.product.grid')->toHtml(),
|
72 |
+
));
|
73 |
+
return parent::_prepareLayout();
|
74 |
+
}
|
75 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Helper/File.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 file field renderer helper
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Helper_File extends Varien_Data_Form_Element_Abstract{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @param array $data
|
29 |
+
* @return void
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
public function __construct($data){
|
33 |
+
parent::__construct($data);
|
34 |
+
$this->setType('file');
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* get element html
|
38 |
+
* @access public
|
39 |
+
* @return string
|
40 |
+
* @author Jason Lotzer
|
41 |
+
*/
|
42 |
+
public function getElementHtml(){
|
43 |
+
$html = '';
|
44 |
+
$this->addClass('input-file');
|
45 |
+
$html.= parent::getElementHtml();
|
46 |
+
if ($this->getValue()) {
|
47 |
+
$url = $this->_getUrl();
|
48 |
+
if( !preg_match("/^http\:\/\/|https\:\/\//", $url) ) {
|
49 |
+
$url = Mage::helper('megamenu2/menuitem')->getFileBaseUrl() . $url;
|
50 |
+
}
|
51 |
+
$html .= '<br /><a href="'.$url.'">'.$this->_getUrl().'</a> ';
|
52 |
+
}
|
53 |
+
$html.= $this->_getDeleteCheckbox();
|
54 |
+
return $html;
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* get the delete checkbox HTML
|
58 |
+
* @access protected
|
59 |
+
* @return string
|
60 |
+
* @author Jason Lotzer
|
61 |
+
*/
|
62 |
+
protected function _getDeleteCheckbox(){
|
63 |
+
$html = '';
|
64 |
+
if ($this->getValue()) {
|
65 |
+
$label = Mage::helper('megamenu2')->__('Delete File');
|
66 |
+
$html .= '<span class="delete-image">';
|
67 |
+
$html .= '<input type="checkbox" name="'.parent::getName().'[delete]" value="1" class="checkbox" id="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' disabled="disabled"': '').'/>';
|
68 |
+
$html .= '<label for="'.$this->getHtmlId().'_delete"'.($this->getDisabled() ? ' class="disabled"' : '').'> '.$label.'</label>';
|
69 |
+
$html .= $this->_getHiddenInput();
|
70 |
+
$html .= '</span>';
|
71 |
+
}
|
72 |
+
return $html;
|
73 |
+
}
|
74 |
+
/**
|
75 |
+
* get the hidden input
|
76 |
+
* @access protected
|
77 |
+
* @return string
|
78 |
+
* @author Jason Lotzer
|
79 |
+
*/
|
80 |
+
protected function _getHiddenInput(){
|
81 |
+
return '<input type="hidden" name="'.parent::getName().'[value]" value="'.$this->getValue().'" />';
|
82 |
+
}
|
83 |
+
/**
|
84 |
+
* get the file url
|
85 |
+
* @access protected
|
86 |
+
* @return string
|
87 |
+
* @author Jason Lotzer
|
88 |
+
*/
|
89 |
+
protected function _getUrl(){
|
90 |
+
return $this->getValue();
|
91 |
+
}
|
92 |
+
/**
|
93 |
+
* get the name
|
94 |
+
* @access public
|
95 |
+
* @return string
|
96 |
+
* @author Jason Lotzer
|
97 |
+
*/
|
98 |
+
public function getName(){
|
99 |
+
return $this->getData('name');
|
100 |
+
}
|
101 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menuitem/Tree.php
CHANGED
@@ -1,303 +1,323 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item admin tree block
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
* @
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this->
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
*
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'
|
54 |
-
'
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
'
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
*
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
*
|
108 |
-
* @
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
*
|
116 |
-
* @
|
117 |
-
* @
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
*
|
138 |
-
* @
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
*
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
*
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
*
|
165 |
-
* @
|
166 |
-
* @
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
*
|
177 |
-
* @
|
178 |
-
* @param
|
179 |
-
* @return string
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
$
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
$
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
$
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
*
|
264 |
-
* @
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
*
|
282 |
-
* @
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
*
|
299 |
-
|
300 |
-
|
301 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Abstract{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setTemplate('jscriptz_megamenu2/menuitem/tree.phtml');
|
34 |
+
$this->setUseAjax(true);
|
35 |
+
$this->_withProductCount = true;
|
36 |
+
}
|
37 |
+
/**
|
38 |
+
* prepare the layout
|
39 |
+
* @access protected
|
40 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree
|
41 |
+
* @author Jason Lotzer
|
42 |
+
*/
|
43 |
+
protected function _prepareLayout(){
|
44 |
+
$addUrl = $this->getUrl("*/*/add", array(
|
45 |
+
'_current'=>true,
|
46 |
+
'id'=>null,
|
47 |
+
'_query' => false
|
48 |
+
));
|
49 |
+
|
50 |
+
/*$this->setChild('add_sub_button',
|
51 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
52 |
+
->setData(array(
|
53 |
+
'label' => Mage::helper('megamenu2')->__('Add Child Menu Item'),
|
54 |
+
'onclick' => "addNew('".$addUrl."', false)",
|
55 |
+
'class' => 'add',
|
56 |
+
'id'=> 'add_child_menuitem_button',
|
57 |
+
'style' => $this->canAddChild() ? '' : 'display: none;'
|
58 |
+
))
|
59 |
+
);
|
60 |
+
*/
|
61 |
+
$this->setChild('add_root_button',
|
62 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
63 |
+
->setData(array(
|
64 |
+
'label' => Mage::helper('megamenu2')->__('Add Menu Item'),
|
65 |
+
'onclick' => "addNew('".$addUrl."', true)",
|
66 |
+
'class' => 'add',
|
67 |
+
'id'=> 'add_root_menuitem_button'
|
68 |
+
))
|
69 |
+
);
|
70 |
+
return parent::_prepareLayout();
|
71 |
+
}
|
72 |
+
/**
|
73 |
+
* get the menu item collection
|
74 |
+
* @access public
|
75 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
76 |
+
* @author Jason Lotzer
|
77 |
+
*/
|
78 |
+
public function getMenuitemCollection(){
|
79 |
+
$collection = $this->getData('menuitem_collection');
|
80 |
+
if (is_null($collection)) {
|
81 |
+
$collection = Mage::getModel('megamenu2/menuitem')->getCollection();
|
82 |
+
$this->setData('menuitem_collection', $collection);
|
83 |
+
}
|
84 |
+
return $collection;
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* get html for add root button
|
88 |
+
* @access public
|
89 |
+
* @return string
|
90 |
+
* @author Jason Lotzer
|
91 |
+
*/
|
92 |
+
public function getAddRootButtonHtml(){
|
93 |
+
return $this->getChildHtml('add_root_button');
|
94 |
+
}
|
95 |
+
/**
|
96 |
+
* get html for add child button
|
97 |
+
* @access public
|
98 |
+
* @return string
|
99 |
+
* @author Jason Lotzer
|
100 |
+
*/
|
101 |
+
public function getAddSubButtonHtml(){
|
102 |
+
return $this->getChildHtml('add_sub_button');
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* get html for expand button
|
106 |
+
* @access public
|
107 |
+
* @return string
|
108 |
+
* @author Jason Lotzer
|
109 |
+
*/
|
110 |
+
public function getExpandButtonHtml(){
|
111 |
+
return $this->getChildHtml('expand_button');
|
112 |
+
}
|
113 |
+
/**
|
114 |
+
* get html for add collapse button
|
115 |
+
* @access public
|
116 |
+
* @return string
|
117 |
+
* @author Jason Lotzer
|
118 |
+
*/
|
119 |
+
public function getCollapseButtonHtml(){
|
120 |
+
return $this->getChildHtml('collapse_button');
|
121 |
+
}
|
122 |
+
/**
|
123 |
+
* get url for tree load
|
124 |
+
* @access public
|
125 |
+
* @param mxed $expanded
|
126 |
+
* @return string
|
127 |
+
* @author Jason Lotzer
|
128 |
+
*/
|
129 |
+
public function getLoadTreeUrl($expanded=null){
|
130 |
+
$params = array('_current'=>true, 'id'=>null,'store'=>null);
|
131 |
+
if ((is_null($expanded) && Mage::getSingleton('admin/session')->getMenuitemIsTreeWasExpanded())|| $expanded == true) {
|
132 |
+
$params['expand_all'] = true;
|
133 |
+
}
|
134 |
+
return $this->getUrl('*/*/menuitemsJson', $params);
|
135 |
+
}
|
136 |
+
/**
|
137 |
+
* get url for loading nodes
|
138 |
+
* @access public
|
139 |
+
* @return string
|
140 |
+
* @author Jason Lotzer
|
141 |
+
*/
|
142 |
+
public function getNodesUrl(){
|
143 |
+
return $this->getUrl('*/MegaMenu2_menuitems/jsonTree');
|
144 |
+
}
|
145 |
+
/**
|
146 |
+
* check if tree is expanded
|
147 |
+
* @access public
|
148 |
+
* @return string
|
149 |
+
* @author Jason Lotzer
|
150 |
+
*/
|
151 |
+
public function getIsWasExpanded(){
|
152 |
+
return Mage::getSingleton('admin/session')->getMenuitemIsTreeWasExpanded();
|
153 |
+
}
|
154 |
+
/**
|
155 |
+
* get url for moving menu item
|
156 |
+
* @access public
|
157 |
+
* @return string
|
158 |
+
* @author Jason Lotzer
|
159 |
+
*/
|
160 |
+
public function getMoveUrl(){
|
161 |
+
return $this->getUrl('*/MegaMenu2_menuitem/move');
|
162 |
+
}
|
163 |
+
/**
|
164 |
+
* get the tree as json
|
165 |
+
* @access public
|
166 |
+
* @param mixed $parentNodeMenuitem
|
167 |
+
* @return string
|
168 |
+
* @author Jason Lotzer
|
169 |
+
*/
|
170 |
+
public function getTree($parentNodeMenuitem = null){
|
171 |
+
$rootArray = $this->_getNodeJson($this->getRoot($parentNodeMenuitem));
|
172 |
+
$tree = isset($rootArray['children']) ? $rootArray['children'] : array();
|
173 |
+
return $tree;
|
174 |
+
}
|
175 |
+
/**
|
176 |
+
* get the tree as json
|
177 |
+
* @access public
|
178 |
+
* @param mixed $parentNodeMenuitem
|
179 |
+
* @return string
|
180 |
+
* @author Jason Lotzer
|
181 |
+
*/
|
182 |
+
public function getTreeJson($parentNodeMenuitem = null){
|
183 |
+
$rootArray = $this->_getNodeJson($this->getRoot($parentNodeMenuitem));
|
184 |
+
$json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
|
185 |
+
return $json;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Get JSON of array of menu items, that are breadcrumbs for specified menu item path
|
190 |
+
* @access public
|
191 |
+
* @param string $path
|
192 |
+
* @param string $javascriptVarName
|
193 |
+
* @return string
|
194 |
+
* @author Jason Lotzer
|
195 |
+
*/
|
196 |
+
public function getBreadcrumbsJavascript($path, $javascriptVarName){
|
197 |
+
if (empty($path)) {
|
198 |
+
return '';
|
199 |
+
}
|
200 |
+
|
201 |
+
$menuitems = Mage::getResourceSingleton('megamenu2/menuitem_tree')->loadBreadcrumbsArray($path);
|
202 |
+
if (empty($menuitems)) {
|
203 |
+
return '';
|
204 |
+
}
|
205 |
+
foreach ($menuitems as $key => $menuitem) {
|
206 |
+
$menuitems[$key] = $this->_getNodeJson($menuitem);
|
207 |
+
}
|
208 |
+
return
|
209 |
+
'<script type="text/javascript">'
|
210 |
+
. $javascriptVarName . ' = ' . Mage::helper('core')->jsonEncode($menuitems) . ';'
|
211 |
+
. ($this->canAddChild() ? '$("add_child_menuitem_button").show();' : '$("add_child_menuitem_button").hide();')
|
212 |
+
. '</script>';
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Get JSON of a tree node or an associative array
|
217 |
+
* @access protected
|
218 |
+
* @param Varien_Data_Tree_Node|array $node
|
219 |
+
* @param int $level
|
220 |
+
* @return string
|
221 |
+
* @author Jason Lotzer
|
222 |
+
*/
|
223 |
+
protected function _getNodeJson($node, $level = 0){
|
224 |
+
// create a node from data array
|
225 |
+
if (is_array($node)) {
|
226 |
+
$node = new Varien_Data_Tree_Node($node, 'entity_id', new Varien_Data_Tree);
|
227 |
+
}
|
228 |
+
$item = array();
|
229 |
+
$item['text'] = $this->buildNodeName($node);
|
230 |
+
$rootForStores = in_array($node->getEntityId(), $this->getRootIds());
|
231 |
+
$item['id'] = $node->getId();
|
232 |
+
$item['path'] = $node->getData('path');
|
233 |
+
$item['cls'] = 'folder';
|
234 |
+
if ($node->getStatus()){
|
235 |
+
$item['cls'] .= ' active-category';
|
236 |
+
}
|
237 |
+
else{
|
238 |
+
$item['cls'] .= ' no-active-category';
|
239 |
+
}
|
240 |
+
$item['allowDrop'] = true;
|
241 |
+
$item['allowDrag'] = true;
|
242 |
+
if ((int)$node->getChildrenCount()>0) {
|
243 |
+
$item['children'] = array();
|
244 |
+
}
|
245 |
+
$isParent = $this->_isParentSelectedMenuitem($node);
|
246 |
+
if ($node->hasChildren()) {
|
247 |
+
$item['children'] = array();
|
248 |
+
if (!($this->getUseAjax() && $node->getLevel() > 1 && !$isParent)) {
|
249 |
+
foreach ($node->getChildren() as $child) {
|
250 |
+
$item['children'][] = $this->_getNodeJson($child, $level+1);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
}
|
254 |
+
if ($isParent || $node->getLevel() < 1) {
|
255 |
+
$item['expanded'] = true;
|
256 |
+
}
|
257 |
+
return $item;
|
258 |
+
}
|
259 |
+
/**
|
260 |
+
* Get node label
|
261 |
+
* @access public
|
262 |
+
* @param Varien_Object $node
|
263 |
+
* @return string
|
264 |
+
* @author Jason Lotzer
|
265 |
+
*/
|
266 |
+
public function buildNodeName($node){
|
267 |
+
$result = $this->htmlEscape($node->getLinktitle());
|
268 |
+
return $result;
|
269 |
+
}
|
270 |
+
/**
|
271 |
+
* check if entity is movable
|
272 |
+
* @access protected
|
273 |
+
* @param Varien_Object $node
|
274 |
+
* @return bool
|
275 |
+
* @author Jason Lotzer
|
276 |
+
*/
|
277 |
+
protected function _isMenuitemMoveable($node){
|
278 |
+
return true;
|
279 |
+
}
|
280 |
+
/**
|
281 |
+
* check if parent is selected
|
282 |
+
* @access protected
|
283 |
+
* @param Varien_Object $node
|
284 |
+
* @return bool
|
285 |
+
* @author Jason Lotzer
|
286 |
+
*/
|
287 |
+
protected function _isParentSelectedMenuitem($node){
|
288 |
+
if ($node && $this->getMenuitem()) {
|
289 |
+
$pathIds = $this->getMenuitem()->getPathIds();
|
290 |
+
if (in_array($node->getId(), $pathIds)) {
|
291 |
+
return true;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
return false;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Check if page loaded by outside link to menu item edit
|
299 |
+
* @access public
|
300 |
+
* @return boolean
|
301 |
+
* @author Jason Lotzer
|
302 |
+
*/
|
303 |
+
public function isClearEdit(){
|
304 |
+
return (bool) $this->getRequest()->getParam('clear');
|
305 |
+
}
|
306 |
+
/**
|
307 |
+
* Check availability of adding root menu item
|
308 |
+
* @access public
|
309 |
+
* @return boolean
|
310 |
+
* @author Jason Lotzer
|
311 |
+
*/
|
312 |
+
public function canAddRootMenuitem(){
|
313 |
+
return true;
|
314 |
+
}
|
315 |
+
/**
|
316 |
+
* Check availability of adding child menu item
|
317 |
+
* @access public
|
318 |
+
* @return boolean
|
319 |
+
*/
|
320 |
+
public function canAddChild(){
|
321 |
+
return true;
|
322 |
+
}
|
323 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting.php
ADDED
@@ -0,0 +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 Setting admin block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
$this->_controller = 'adminhtml_menusetting';
|
33 |
+
$this->_blockGroup = 'megamenu2';
|
34 |
+
$this->_headerText = Mage::helper('megamenu2')->__('Menu Setting');
|
35 |
+
$this->_addButtonLabel = Mage::helper('megamenu2')->__('Add Menu Setting');
|
36 |
+
parent::__construct();
|
37 |
+
}
|
38 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting admin edit block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
|
25 |
+
/**
|
26 |
+
* constuctor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->_blockGroup = 'megamenu2';
|
34 |
+
$this->_controller = 'adminhtml_menusetting';
|
35 |
+
$this->_updateButton('save', 'label', Mage::helper('megamenu2')->__('Save Menu Setting'));
|
36 |
+
$this->_updateButton('delete', 'label', Mage::helper('megamenu2')->__('Delete Menu Setting'));
|
37 |
+
$this->_addButton('saveandcontinue', array(
|
38 |
+
'label' => Mage::helper('megamenu2')->__('Save And Continue Edit'),
|
39 |
+
'onclick' => 'saveAndContinueEdit()',
|
40 |
+
'class' => 'save',
|
41 |
+
), -100);
|
42 |
+
$this->_formScripts[] = "
|
43 |
+
function saveAndContinueEdit(){
|
44 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
45 |
+
}
|
46 |
+
";
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* get the edit form header
|
50 |
+
* @access public
|
51 |
+
* @return string
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function getHeaderText(){
|
55 |
+
if( Mage::registry('menusetting_data') && Mage::registry('menusetting_data')->getId() ) {
|
56 |
+
return Mage::helper('megamenu2')->__("Edit Menu Setting '%s'", $this->htmlEscape(Mage::registry('menusetting_data')->getMenutitle()));
|
57 |
+
}
|
58 |
+
else {
|
59 |
+
return Mage::helper('megamenu2')->__('Add Menu Setting');
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Form.php
ADDED
@@ -0,0 +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 |
+
* Menu Setting edit form
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
|
25 |
+
/**
|
26 |
+
* prepare form
|
27 |
+
* @access protected
|
28 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Form
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _prepareForm(){
|
32 |
+
$form = new Varien_Data_Form(array(
|
33 |
+
'id' => 'edit_form',
|
34 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
35 |
+
'method' => 'post',
|
36 |
+
'enctype' => 'multipart/form-data'
|
37 |
+
)
|
38 |
+
);
|
39 |
+
$form->setUseContainer(true);
|
40 |
+
$this->setForm($form);
|
41 |
+
return parent::_prepareForm();
|
42 |
+
}
|
43 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting edit form tab
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form{
|
25 |
+
/**
|
26 |
+
* prepare the form
|
27 |
+
* @access protected
|
28 |
+
* @return MegaMenu2_Menusetting_Block_Adminhtml_Menusetting_Edit_Tab_Form
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _prepareForm(){
|
32 |
+
$form = new Varien_Data_Form();
|
33 |
+
$form->setHtmlIdPrefix('menusetting_');
|
34 |
+
$form->setFieldNameSuffix('menusetting');
|
35 |
+
$this->setForm($form);
|
36 |
+
$fieldset = $form->addFieldset('menusetting_form', array('legend'=>Mage::helper('megamenu2')->__('Menu Setting')));
|
37 |
+
|
38 |
+
$fieldset->addField('menutitle', 'text', array(
|
39 |
+
'label' => Mage::helper('megamenu2')->__('Menu Title'),
|
40 |
+
'name' => 'menutitle',
|
41 |
+
'note' => $this->__('Title for your menu'),
|
42 |
+
'required' => true,
|
43 |
+
'class' => 'required-entry',
|
44 |
+
|
45 |
+
));
|
46 |
+
|
47 |
+
$fieldset->addField('disablemenu', 'select', array(
|
48 |
+
'label' => Mage::helper('megamenu2')->__('Disable Menu'),
|
49 |
+
'name' => 'disablemenu',
|
50 |
+
'note' => $this->__('Disables Menu for Debugging'),
|
51 |
+
|
52 |
+
'values'=> array(
|
53 |
+
array(
|
54 |
+
'value' => 1,
|
55 |
+
'label' => Mage::helper('megamenu2')->__('Yes'),
|
56 |
+
),
|
57 |
+
array(
|
58 |
+
'value' => 0,
|
59 |
+
'label' => Mage::helper('megamenu2')->__('No'),
|
60 |
+
),
|
61 |
+
),
|
62 |
+
));
|
63 |
+
if (Mage::app()->isSingleStoreMode()){
|
64 |
+
$fieldset->addField('store_id', 'hidden', array(
|
65 |
+
'name' => 'stores[]',
|
66 |
+
'value' => Mage::app()->getStore(true)->getId()
|
67 |
+
));
|
68 |
+
Mage::registry('current_menusetting')->setStoreId(Mage::app()->getStore(true)->getId());
|
69 |
+
}
|
70 |
+
if (Mage::getSingleton('adminhtml/session')->getMenusettingData()){
|
71 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getMenusettingData());
|
72 |
+
Mage::getSingleton('adminhtml/session')->setMenusettingData(null);
|
73 |
+
}
|
74 |
+
elseif (Mage::registry('current_menusetting')){
|
75 |
+
$form->setValues(Mage::registry('current_menusetting')->getData());
|
76 |
+
}
|
77 |
+
return parent::_prepareForm();
|
78 |
+
}
|
79 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Menuitem.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* menusetting - menuitem relation edit block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Menuitem extends JScriptz_MegaMenu2_Block_Adminhtml_Menuitem_Tree{
|
25 |
+
protected $_menuitemIds = null;
|
26 |
+
protected $_selectedNodes = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
* Specify template to use
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
* @author Jason Lotzer
|
34 |
+
*/
|
35 |
+
public function __construct(){
|
36 |
+
parent::__construct();
|
37 |
+
$this->setTemplate('jscriptz_megamenu2/menusetting/edit/tab/menuitem.phtml');
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* Retrieve currently edited menu setting
|
41 |
+
* @access public
|
42 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting
|
43 |
+
* @author Jason Lotzer
|
44 |
+
*/
|
45 |
+
public function getMenusetting(){
|
46 |
+
return Mage::registry('current_menusetting');
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* Return array with menu items IDs which the menu setting is linked to
|
50 |
+
* @access public
|
51 |
+
* @return array
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function getMenuitemIds(){
|
55 |
+
if (is_null($this->_menuitemIds)){
|
56 |
+
$menuitems = $this->getMenusetting()->getSelectedMenuitems();
|
57 |
+
$ids = array();
|
58 |
+
foreach ($menuitems as $menuitem){
|
59 |
+
$ids[] = $menuitem->getId();
|
60 |
+
}
|
61 |
+
$this->_menuitemIds = $ids;
|
62 |
+
}
|
63 |
+
return $this->_menuitemIds;
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* Forms string out of getMenuitemIds()
|
67 |
+
* @access public
|
68 |
+
* @return string
|
69 |
+
* @author Jason Lotzer
|
70 |
+
*/
|
71 |
+
public function getIdsString(){
|
72 |
+
return implode(',', $this->getMenuitemIds());
|
73 |
+
}
|
74 |
+
/**
|
75 |
+
* Returns root node and sets 'checked' flag (if necessary)
|
76 |
+
* @access public
|
77 |
+
* @return Varien_Data_Tree_Node
|
78 |
+
* @author Jason Lotzer
|
79 |
+
*/
|
80 |
+
public function getRootNode(){
|
81 |
+
$root = $this->getRoot();
|
82 |
+
if ($root && in_array($root->getId(), $this->getMenuitemIds())) {
|
83 |
+
$root->setChecked(true);
|
84 |
+
}
|
85 |
+
return $root;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns root node
|
90 |
+
*
|
91 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem|null $parentNodeMenuitem
|
92 |
+
* @param int $recursionLevel
|
93 |
+
* @return Varien_Data_Tree_Node
|
94 |
+
* @author Jason Lotzer
|
95 |
+
*/
|
96 |
+
public function getRoot($parentNodeMenuitem = null, $recursionLevel = 3){
|
97 |
+
if (!is_null($parentNodeMenuitem) && $parentNodeMenuitem->getId()) {
|
98 |
+
return $this->getNode($parentNodeMenuitem, $recursionLevel);
|
99 |
+
}
|
100 |
+
$root = Mage::registry('menuitem_root');
|
101 |
+
if (is_null($root)) {
|
102 |
+
$rootId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
103 |
+
$ids = $this->getSelectedMenuitemPathIds($rootId);
|
104 |
+
$tree = Mage::getResourceSingleton('megamenu2/menuitem_tree')
|
105 |
+
->loadByIds($ids, false, false);
|
106 |
+
if ($this->getMenuitem()) {
|
107 |
+
$tree->loadEnsuredNodes($this->getMenuitem(), $tree->getNodeById($rootId));
|
108 |
+
}
|
109 |
+
$tree->addCollectionData($this->getMenuitemCollection());
|
110 |
+
$root = $tree->getNodeById($rootId);
|
111 |
+
Mage::register('menuitem_root', $root);
|
112 |
+
}
|
113 |
+
return $root;
|
114 |
+
}
|
115 |
+
/**
|
116 |
+
* Returns array with configuration of current node
|
117 |
+
* @access public
|
118 |
+
* @param Varien_Data_Tree_Node $node
|
119 |
+
* @param int $level How deep is the node in the tree
|
120 |
+
* @return array
|
121 |
+
* @author Jason Lotzer
|
122 |
+
*/
|
123 |
+
protected function _getNodeJson($node, $level = 1){
|
124 |
+
$item = parent::_getNodeJson($node, $level);
|
125 |
+
if ($this->_isParentSelectedMenuitem($node)) {
|
126 |
+
$item['expanded'] = true;
|
127 |
+
}
|
128 |
+
if (in_array($node->getId(), $this->getMenuitemIds())) {
|
129 |
+
$item['checked'] = true;
|
130 |
+
}
|
131 |
+
return $item;
|
132 |
+
}
|
133 |
+
/**
|
134 |
+
* Returns whether $node is a parent (not exactly direct) of a selected node
|
135 |
+
* @access public
|
136 |
+
* @param Varien_Data_Tree_Node $node
|
137 |
+
* @return bool
|
138 |
+
* @author Jason Lotzer
|
139 |
+
*/
|
140 |
+
protected function _isParentSelectedMenuitem($node){
|
141 |
+
$result = false;
|
142 |
+
// Contains string with all menu item IDs of children (not exactly direct) of the node
|
143 |
+
$allChildren = $node->getAllChildren();
|
144 |
+
if ($allChildren) {
|
145 |
+
$selectedMenuitemIds = $this->getMenuitemIds();
|
146 |
+
$allChildrenArr = explode(',', $allChildren);
|
147 |
+
for ($i = 0, $cnt = count($selectedMenuitemIds); $i < $cnt; $i++) {
|
148 |
+
$isSelf = $node->getId() == $selectedMenuitemIds[$i];
|
149 |
+
if (!$isSelf && in_array($selectedMenuitemIds[$i], $allChildrenArr)) {
|
150 |
+
$result = true;
|
151 |
+
break;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
return $result;
|
156 |
+
}
|
157 |
+
/**
|
158 |
+
* Returns array with nodes those are selected (contain current menu setting)
|
159 |
+
*
|
160 |
+
* @return array
|
161 |
+
*/
|
162 |
+
protected function _getSelectedNodes(){
|
163 |
+
if ($this->_selectedNodes === null) {
|
164 |
+
$this->_selectedNodes = array();
|
165 |
+
$root = $this->getRoot();
|
166 |
+
foreach ($this->getMenuitemIds() as $menuitemId) {
|
167 |
+
if ($root) {
|
168 |
+
$this->_selectedNodes[] = $root->getTree()->getNodeById($menuitemId);
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
+
return $this->_selectedNodes;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Returns JSON-encoded array of menu items children
|
177 |
+
* @access public
|
178 |
+
* @param int $menuitemId
|
179 |
+
* @return string
|
180 |
+
* @author Jason Lotzer
|
181 |
+
*/
|
182 |
+
public function getMenuitemChildrenJson($menuitemId){
|
183 |
+
$menuitem = Mage::getModel('megamenu2/menuitem')->load($menuitemId);
|
184 |
+
$node = $this->getRoot($menuitem, 1)->getTree()->getNodeById($menuitemId);
|
185 |
+
if (!$node || !$node->hasChildren()) {
|
186 |
+
return '[]';
|
187 |
+
}
|
188 |
+
$children = array();
|
189 |
+
foreach ($node->getChildren() as $child) {
|
190 |
+
$children[] = $this->_getNodeJson($child);
|
191 |
+
}
|
192 |
+
return Mage::helper('core')->jsonEncode($children);
|
193 |
+
}
|
194 |
+
/**
|
195 |
+
* Returns URL for loading tree
|
196 |
+
* @access public
|
197 |
+
* @param null $expanded
|
198 |
+
* @return string
|
199 |
+
* @author Jason Lotzer
|
200 |
+
*/
|
201 |
+
public function getLoadTreeUrl($expanded = null){
|
202 |
+
return $this->getUrl('*/*/menuitemsJson', array('_current' => true));
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Return distinct path ids of selected menu items
|
207 |
+
* @access public
|
208 |
+
* @param mixed $rootId Root menu item Id for context
|
209 |
+
* @return array
|
210 |
+
* @author Jason Lotzer
|
211 |
+
*/
|
212 |
+
public function getSelectedMenuitemPathIds($rootId = false){
|
213 |
+
$ids = array();
|
214 |
+
$menuitemIds = $this->getMenuitemIds();
|
215 |
+
if (empty($menuitemIds)) {
|
216 |
+
return array();
|
217 |
+
}
|
218 |
+
$collection = Mage::getResourceModel('megamenu2/menuitem_collection');
|
219 |
+
if ($rootId) {
|
220 |
+
$collection->addFieldToFilter('parent_id', $rootId);
|
221 |
+
}
|
222 |
+
else {
|
223 |
+
$collection->addFieldToFilter('entity_id', array('in'=>$menuitemIds));
|
224 |
+
}
|
225 |
+
|
226 |
+
foreach ($collection as $item) {
|
227 |
+
if ($rootId && !in_array($rootId, $item->getPathIds())) {
|
228 |
+
continue;
|
229 |
+
}
|
230 |
+
foreach ($item->getPathIds() as $id) {
|
231 |
+
if (!in_array($id, $ids)) {
|
232 |
+
$ids[] = $id;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
return $ids;
|
237 |
+
}
|
238 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Product.php
ADDED
@@ -0,0 +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 Setting - product relation edit block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid{
|
25 |
+
/**
|
26 |
+
* Set grid params
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('product_grid');
|
34 |
+
$this->setDefaultSort('position');
|
35 |
+
$this->setDefaultDir('ASC');
|
36 |
+
$this->setUseAjax(true);
|
37 |
+
if ($this->getMenusetting()->getId()) {
|
38 |
+
$this->setDefaultFilter(array('in_products'=>1));
|
39 |
+
}
|
40 |
+
}
|
41 |
+
/**
|
42 |
+
* prepare the product collection
|
43 |
+
* @access protected
|
44 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Product
|
45 |
+
* @author Jason Lotzer
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection() {
|
48 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
49 |
+
$collection->addAttributeToSelect('price');
|
50 |
+
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
51 |
+
$collection->joinAttribute('product_name', 'catalog_product/name', 'entity_id', null, 'left', $adminStore);
|
52 |
+
if ($this->getMenusetting()->getId()){
|
53 |
+
$constraint = '{{table}}.menusetting_id='.$this->getMenusetting()->getId();
|
54 |
+
}
|
55 |
+
else{
|
56 |
+
$constraint = '{{table}}.menusetting_id=0';
|
57 |
+
}
|
58 |
+
$collection->joinField('position',
|
59 |
+
'megamenu2/menusetting_product',
|
60 |
+
'position',
|
61 |
+
'product_id=entity_id',
|
62 |
+
$constraint,
|
63 |
+
'left');
|
64 |
+
$this->setCollection($collection);
|
65 |
+
parent::_prepareCollection();
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* prepare mass action grid
|
70 |
+
* @access protected
|
71 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Product
|
72 |
+
* @author Jason Lotzer
|
73 |
+
*/
|
74 |
+
protected function _prepareMassaction(){
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
/**
|
78 |
+
* prepare the grid columns
|
79 |
+
* @access protected
|
80 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Product
|
81 |
+
* @author Jason Lotzer
|
82 |
+
*/
|
83 |
+
protected function _prepareColumns(){
|
84 |
+
$this->addColumn('in_products', array(
|
85 |
+
'header_css_class' => 'a-center',
|
86 |
+
'type' => 'checkbox',
|
87 |
+
'name' => 'in_products',
|
88 |
+
'values'=> $this->_getSelectedProducts(),
|
89 |
+
'align' => 'center',
|
90 |
+
'index' => 'entity_id'
|
91 |
+
));
|
92 |
+
$this->addColumn('product_name', array(
|
93 |
+
'header'=> Mage::helper('catalog')->__('Name'),
|
94 |
+
'align' => 'left',
|
95 |
+
'index' => 'product_name',
|
96 |
+
));
|
97 |
+
$this->addColumn('sku', array(
|
98 |
+
'header'=> Mage::helper('catalog')->__('SKU'),
|
99 |
+
'align' => 'left',
|
100 |
+
'index' => 'sku',
|
101 |
+
));
|
102 |
+
$this->addColumn('price', array(
|
103 |
+
'header'=> Mage::helper('catalog')->__('Price'),
|
104 |
+
'type' => 'currency',
|
105 |
+
'width' => '1',
|
106 |
+
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
|
107 |
+
'index' => 'price'
|
108 |
+
));
|
109 |
+
$this->addColumn('position', array(
|
110 |
+
'header'=> Mage::helper('catalog')->__('Position'),
|
111 |
+
'name' => 'position',
|
112 |
+
'width' => 60,
|
113 |
+
'type' => 'number',
|
114 |
+
'validate_class'=> 'validate-number',
|
115 |
+
'index' => 'position',
|
116 |
+
'editable' => true,
|
117 |
+
));
|
118 |
+
}
|
119 |
+
/**
|
120 |
+
* Retrieve selected products
|
121 |
+
* @access protected
|
122 |
+
* @return array
|
123 |
+
* @author Jason Lotzer
|
124 |
+
*/
|
125 |
+
protected function _getSelectedProducts(){
|
126 |
+
$products = $this->getMenusettingProducts();
|
127 |
+
if (!is_array($products)) {
|
128 |
+
$products = array_keys($this->getSelectedProducts());
|
129 |
+
}
|
130 |
+
return $products;
|
131 |
+
}
|
132 |
+
/**
|
133 |
+
* Retrieve selected products
|
134 |
+
* @access protected
|
135 |
+
* @return array
|
136 |
+
* @author Jason Lotzer
|
137 |
+
*/
|
138 |
+
public function getSelectedProducts() {
|
139 |
+
$products = array();
|
140 |
+
$selected = Mage::registry('current_menusetting')->getSelectedProducts();
|
141 |
+
if (!is_array($selected)){
|
142 |
+
$selected = array();
|
143 |
+
}
|
144 |
+
foreach ($selected as $product) {
|
145 |
+
$products[$product->getId()] = array('position' => $product->getPosition());
|
146 |
+
}
|
147 |
+
return $products;
|
148 |
+
}
|
149 |
+
/**
|
150 |
+
* get row url
|
151 |
+
* @access public
|
152 |
+
* @return string
|
153 |
+
* @author Jason Lotzer
|
154 |
+
*/
|
155 |
+
public function getRowUrl($item){
|
156 |
+
return '#';
|
157 |
+
}
|
158 |
+
/**
|
159 |
+
* get grid url
|
160 |
+
* @access public
|
161 |
+
* @return string
|
162 |
+
* @author Jason Lotzer
|
163 |
+
*/
|
164 |
+
public function getGridUrl(){
|
165 |
+
return $this->getUrl('*/*/productsGrid', array(
|
166 |
+
'id'=>$this->getMenusetting()->getId()
|
167 |
+
));
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* get the current menusetting
|
171 |
+
* @access public
|
172 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting
|
173 |
+
* @author Jason Lotzer
|
174 |
+
*/
|
175 |
+
public function getMenusetting(){
|
176 |
+
return Mage::registry('current_menusetting');
|
177 |
+
}
|
178 |
+
/**
|
179 |
+
* Add filter
|
180 |
+
* @access protected
|
181 |
+
* @param object $column
|
182 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Product
|
183 |
+
* @author Jason Lotzer
|
184 |
+
*/
|
185 |
+
protected function _addColumnFilterToCollection($column){
|
186 |
+
// Set custom filter for in product flag
|
187 |
+
if ($column->getId() == 'in_products') {
|
188 |
+
$productIds = $this->_getSelectedProducts();
|
189 |
+
if (empty($productIds)) {
|
190 |
+
$productIds = 0;
|
191 |
+
}
|
192 |
+
if ($column->getFilter()->getValue()) {
|
193 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
|
194 |
+
}
|
195 |
+
else {
|
196 |
+
if($productIds) {
|
197 |
+
$this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
else {
|
202 |
+
parent::_addColumnFilterToCollection($column);
|
203 |
+
}
|
204 |
+
return $this;
|
205 |
+
}
|
206 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tab/Stores.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form{
|
25 |
+
/**
|
26 |
+
* prepare the form
|
27 |
+
* @access protected
|
28 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tab_Stores
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _prepareForm(){
|
32 |
+
$form = new Varien_Data_Form();
|
33 |
+
$form->setFieldNameSuffix('menusetting');
|
34 |
+
$this->setForm($form);
|
35 |
+
$fieldset = $form->addFieldset('menusetting_stores_form', array('legend'=>Mage::helper('megamenu2')->__('Store views')));
|
36 |
+
$field = $fieldset->addField('store_id', 'multiselect', array(
|
37 |
+
'name' => 'stores[]',
|
38 |
+
'label' => Mage::helper('megamenu2')->__('Store Views'),
|
39 |
+
'title' => Mage::helper('megamenu2')->__('Store Views'),
|
40 |
+
'required' => true,
|
41 |
+
'values'=> Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
42 |
+
));
|
43 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
44 |
+
$field->setRenderer($renderer);
|
45 |
+
$form->addValues(Mage::registry('current_menusetting')->getData());
|
46 |
+
return parent::_prepareForm();
|
47 |
+
}
|
48 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Edit/Tabs.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting admin edit tabs
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('menusetting_tabs');
|
34 |
+
$this->setDestElementId('edit_form');
|
35 |
+
$this->setTitle(Mage::helper('megamenu2')->__('Menu Setting'));
|
36 |
+
}
|
37 |
+
/**
|
38 |
+
* before render html
|
39 |
+
* @access protected
|
40 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Edit_Tabs
|
41 |
+
* @author Jason Lotzer
|
42 |
+
*/
|
43 |
+
protected function _beforeToHtml(){
|
44 |
+
$this->addTab('form_menusetting', array(
|
45 |
+
'label' => Mage::helper('megamenu2')->__('Menu Setting'),
|
46 |
+
'title' => Mage::helper('megamenu2')->__('Menu Setting'),
|
47 |
+
'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menusetting_edit_tab_form')->toHtml(),
|
48 |
+
));
|
49 |
+
if (!Mage::app()->isSingleStoreMode()){
|
50 |
+
$this->addTab('form_store_menusetting', array(
|
51 |
+
'label' => Mage::helper('megamenu2')->__('Store views'),
|
52 |
+
'title' => Mage::helper('megamenu2')->__('Store views'),
|
53 |
+
'content' => $this->getLayout()->createBlock('megamenu2/adminhtml_menusetting_edit_tab_stores')->toHtml(),
|
54 |
+
));
|
55 |
+
}
|
56 |
+
$this->addTab('menuitems', array(
|
57 |
+
'label' => Mage::helper('megamenu2')->__('Menu Items'),
|
58 |
+
'url' => $this->getUrl('*/*/menuitems', array('_current' => true)),
|
59 |
+
'class' => 'ajax'
|
60 |
+
));
|
61 |
+
$this->addTab('products', array(
|
62 |
+
'label' => Mage::helper('megamenu2')->__('Associated products'),
|
63 |
+
'url' => $this->getUrl('*/*/products', array('_current' => true)),
|
64 |
+
'class' => 'ajax'
|
65 |
+
));
|
66 |
+
return parent::_beforeToHtml();
|
67 |
+
}
|
68 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Adminhtml/Menusetting/Grid.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting admin grid block
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Grid extends Mage_Adminhtml_Block_Widget_Grid{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function __construct(){
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('menusettingGrid');
|
34 |
+
$this->setDefaultSort('entity_id');
|
35 |
+
$this->setDefaultDir('ASC');
|
36 |
+
$this->setSaveParametersInSession(true);
|
37 |
+
$this->setUseAjax(true);
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* prepare collection
|
41 |
+
* @access protected
|
42 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Grid
|
43 |
+
* @author Jason Lotzer
|
44 |
+
*/
|
45 |
+
protected function _prepareCollection(){
|
46 |
+
$collection = Mage::getModel('megamenu2/menusetting')->getCollection();
|
47 |
+
$this->setCollection($collection);
|
48 |
+
return parent::_prepareCollection();
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* prepare grid collection
|
52 |
+
* @access protected
|
53 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Grid
|
54 |
+
* @author Jason Lotzer
|
55 |
+
*/
|
56 |
+
protected function _prepareColumns(){
|
57 |
+
$this->addColumn('entity_id', array(
|
58 |
+
'header' => Mage::helper('megamenu2')->__('Id'),
|
59 |
+
'index' => 'entity_id',
|
60 |
+
'type' => 'number'
|
61 |
+
));
|
62 |
+
$this->addColumn('menutitle', array(
|
63 |
+
'header'=> Mage::helper('megamenu2')->__('Menu Title'),
|
64 |
+
'index' => 'menutitle',
|
65 |
+
'type' => 'text',
|
66 |
+
|
67 |
+
));
|
68 |
+
$this->addColumn('disablemenu', array(
|
69 |
+
'header'=> Mage::helper('megamenu2')->__('Disable Menu'),
|
70 |
+
'index' => 'disablemenu',
|
71 |
+
'type' => 'options',
|
72 |
+
'options' => array(
|
73 |
+
'1' => Mage::helper('megamenu2')->__('Yes'),
|
74 |
+
'0' => Mage::helper('megamenu2')->__('No'),
|
75 |
+
)
|
76 |
+
|
77 |
+
));
|
78 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
79 |
+
$this->addColumn('store_id', array(
|
80 |
+
'header'=> Mage::helper('megamenu2')->__('Store Views'),
|
81 |
+
'index' => 'store_id',
|
82 |
+
'type' => 'store',
|
83 |
+
'store_all' => true,
|
84 |
+
'store_view'=> true,
|
85 |
+
'sortable' => false,
|
86 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
87 |
+
));
|
88 |
+
}
|
89 |
+
$this->addColumn('action',
|
90 |
+
array(
|
91 |
+
'header'=> Mage::helper('megamenu2')->__('Action'),
|
92 |
+
'width' => '100',
|
93 |
+
'type' => 'action',
|
94 |
+
'getter'=> 'getId',
|
95 |
+
'actions' => array(
|
96 |
+
array(
|
97 |
+
'caption' => Mage::helper('megamenu2')->__('Edit'),
|
98 |
+
'url' => array('base'=> '*/*/edit'),
|
99 |
+
'field' => 'id'
|
100 |
+
)
|
101 |
+
),
|
102 |
+
'filter'=> false,
|
103 |
+
'is_system' => true,
|
104 |
+
'sortable' => false,
|
105 |
+
));
|
106 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('megamenu2')->__('CSV'));
|
107 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('megamenu2')->__('Excel'));
|
108 |
+
$this->addExportType('*/*/exportXml', Mage::helper('megamenu2')->__('XML'));
|
109 |
+
return parent::_prepareColumns();
|
110 |
+
}
|
111 |
+
/**
|
112 |
+
* prepare mass action
|
113 |
+
* @access protected
|
114 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Grid
|
115 |
+
* @author Jason Lotzer
|
116 |
+
*/
|
117 |
+
protected function _prepareMassaction(){
|
118 |
+
$this->setMassactionIdField('entity_id');
|
119 |
+
$this->getMassactionBlock()->setFormFieldName('menusetting');
|
120 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
121 |
+
'label'=> Mage::helper('megamenu2')->__('Delete'),
|
122 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
123 |
+
'confirm' => Mage::helper('megamenu2')->__('Are you sure?')
|
124 |
+
));
|
125 |
+
$this->getMassactionBlock()->addItem('disablemenu', array(
|
126 |
+
'label'=> Mage::helper('megamenu2')->__('Change Disable Menu'),
|
127 |
+
'url' => $this->getUrl('*/*/massDisablemenu', array('_current'=>true)),
|
128 |
+
'additional' => array(
|
129 |
+
'flag_disablemenu' => array(
|
130 |
+
'name' => 'flag_disablemenu',
|
131 |
+
'type' => 'select',
|
132 |
+
'class' => 'required-entry',
|
133 |
+
'label' => Mage::helper('megamenu2')->__('Disable Menu'),
|
134 |
+
'values' => array(
|
135 |
+
'1' => Mage::helper('megamenu2')->__('Yes'),
|
136 |
+
'0' => Mage::helper('megamenu2')->__('No'),
|
137 |
+
)
|
138 |
+
)
|
139 |
+
)
|
140 |
+
));
|
141 |
+
return $this;
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* get the row url
|
145 |
+
* @access public
|
146 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting
|
147 |
+
* @return string
|
148 |
+
* @author Jason Lotzer
|
149 |
+
*/
|
150 |
+
public function getRowUrl($row){
|
151 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* get the grid url
|
155 |
+
* @access public
|
156 |
+
* @return string
|
157 |
+
* @author Jason Lotzer
|
158 |
+
*/
|
159 |
+
public function getGridUrl(){
|
160 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
161 |
+
}
|
162 |
+
/**
|
163 |
+
* after collection load
|
164 |
+
* @access protected
|
165 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Grid
|
166 |
+
* @author Jason Lotzer
|
167 |
+
*/
|
168 |
+
protected function _afterLoadCollection(){
|
169 |
+
$this->getCollection()->walk('afterLoad');
|
170 |
+
parent::_afterLoadCollection();
|
171 |
+
}
|
172 |
+
/**
|
173 |
+
* filter store column
|
174 |
+
* @access protected
|
175 |
+
* @param JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection $collection
|
176 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
177 |
+
* @return JScriptz_MegaMenu2_Block_Adminhtml_Menusetting_Grid
|
178 |
+
* @author Jason Lotzer
|
179 |
+
*/
|
180 |
+
protected function _filterStoreCondition($collection, $column){
|
181 |
+
if (!$value = $column->getFilter()->getValue()) {
|
182 |
+
return;
|
183 |
+
}
|
184 |
+
$collection->addStoreFilter($value);
|
185 |
+
return $this;
|
186 |
+
}
|
187 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Html/Topmenu.php
CHANGED
@@ -1,265 +1,342 @@
|
|
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 Html Block Topmenu
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package JScriptz_MegaMenu2
|
22 |
-
*/
|
23 |
-
class JScriptz_MegaMenu2_Block_Html_Topmenu extends Mage_Core_Block_Template
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Top menu data tree
|
27 |
-
*
|
28 |
-
* @var Varien_Data_Tree_Node
|
29 |
-
*/
|
30 |
-
protected $_menu;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Current entity key
|
34 |
-
*
|
35 |
-
* @var string|int
|
36 |
-
*/
|
37 |
-
protected $_currentEntityKey;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Init top menu tree structure
|
41 |
-
*/
|
42 |
-
public function _construct()
|
43 |
-
{
|
44 |
-
$this->_menu = new Varien_Data_Tree_Node(array(), 'root', new Varien_Data_Tree());
|
45 |
-
|
46 |
-
$this->addData(array(
|
47 |
-
'cache_lifetime' => false,
|
48 |
-
));
|
49 |
-
}
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
$
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
$
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
$
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
$html .= ' ' . $
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
$
|
180 |
-
$
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
);
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Html Block Topmenu
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
*/
|
23 |
+
class JScriptz_MegaMenu2_Block_Html_Topmenu extends Mage_Core_Block_Template
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* Top menu data tree
|
27 |
+
*
|
28 |
+
* @var Varien_Data_Tree_Node
|
29 |
+
*/
|
30 |
+
protected $_menu;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Current entity key
|
34 |
+
*
|
35 |
+
* @var string|int
|
36 |
+
*/
|
37 |
+
protected $_currentEntityKey;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Init top menu tree structure
|
41 |
+
*/
|
42 |
+
public function _construct()
|
43 |
+
{
|
44 |
+
$this->_menu = new Varien_Data_Tree_Node(array(), 'root', new Varien_Data_Tree());
|
45 |
+
|
46 |
+
$this->addData(array(
|
47 |
+
'cache_lifetime' => false,
|
48 |
+
));
|
49 |
+
}
|
50 |
+
|
51 |
+
public function isMenuDisabled($entityID = 1){
|
52 |
+
|
53 |
+
$menusettings = Mage::getModel('megamenu2/menusetting');
|
54 |
+
$menusettings->load($entityID);
|
55 |
+
return $menusettings->getData('disablemenu');
|
56 |
+
|
57 |
+
}
|
58 |
+
public function mySort($a,$b){
|
59 |
+
if ($a->position == $b->position) {
|
60 |
+
return 0;
|
61 |
+
}
|
62 |
+
return ($a->position < $b->position) ? -1 : 1;
|
63 |
+
}
|
64 |
+
public function getSorted($sortArray){
|
65 |
+
usort($sortArray, "mySort");
|
66 |
+
return $sortArray;
|
67 |
+
}
|
68 |
+
public function getMenuItem($entityID){
|
69 |
+
|
70 |
+
$mytable = Mage::getModel('megamenu2/menuitem')->getCollection()->getData();
|
71 |
+
return $mytable;
|
72 |
+
|
73 |
+
}
|
74 |
+
public function getMenuItemSettings($entityID = 1){
|
75 |
+
|
76 |
+
$mytable = Mage::getModel('megamenu2/menuitem_menusetting')->getCollection();
|
77 |
+
$mytable->getData('menuitem_id');
|
78 |
+
return $mytable;
|
79 |
+
|
80 |
+
}
|
81 |
+
/**
|
82 |
+
* Get top menu html
|
83 |
+
*
|
84 |
+
* @param string $outermostClass
|
85 |
+
* @param string $childrenWrapClass
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
public function getHtml($outermostClass = '', $childrenWrapClass = '')
|
89 |
+
{
|
90 |
+
Mage::dispatchEvent('page_block_html_topmenu_gethtml_before', array(
|
91 |
+
'menu' => $this->_menu,
|
92 |
+
'block' => $this
|
93 |
+
));
|
94 |
+
|
95 |
+
$this->_menu->setOutermostClass($outermostClass);
|
96 |
+
$this->_menu->setChildrenWrapClass($childrenWrapClass);
|
97 |
+
|
98 |
+
$html = $this->_getHtml($this->_menu, $childrenWrapClass);
|
99 |
+
|
100 |
+
Mage::dispatchEvent('page_block_html_topmenu_gethtml_after', array(
|
101 |
+
'menu' => $this->_menu,
|
102 |
+
'html' => $html
|
103 |
+
));
|
104 |
+
|
105 |
+
return $html;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Recursively generates top menu html from data that is specified in $menuTree
|
110 |
+
*
|
111 |
+
* @param Varien_Data_Tree_Node $menuTree
|
112 |
+
* @param string $childrenWrapClass
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
|
116 |
+
{
|
117 |
+
if(Mage::getStoreConfig('megamenu2_options/options/megamenu2')){
|
118 |
+
$html = '';
|
119 |
+
|
120 |
+
$children = $menuTree->getChildren();
|
121 |
+
$parentLevel = $menuTree->getLevel();
|
122 |
+
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
|
123 |
+
|
124 |
+
$counter = 1;
|
125 |
+
$childrenCount = $children->count();
|
126 |
+
|
127 |
+
$parentPositionClass = $menuTree->getPositionClass();
|
128 |
+
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
|
129 |
+
|
130 |
+
foreach ($children as $child) {
|
131 |
+
|
132 |
+
$child->setLevel($childLevel);
|
133 |
+
$child->setIsFirst($counter == 1);
|
134 |
+
$child->setIsLast($counter == $childrenCount);
|
135 |
+
$child->setPositionClass($itemPositionClassPrefix . $counter);
|
136 |
+
|
137 |
+
$outermostClassCode = '';
|
138 |
+
$outermostClass = $menuTree->getOutermostClass();
|
139 |
+
|
140 |
+
if ($childLevel == 0 && $outermostClass) {
|
141 |
+
$outermostClassCode = 'dropdown_flyout_parent';
|
142 |
+
$outermostClassCode = " class='dropdown_flyout_parent'";
|
143 |
+
$child->setClass($outermostClass);
|
144 |
+
}
|
145 |
+
|
146 |
+
|
147 |
+
|
148 |
+
if ($child->hasChildren()) {
|
149 |
+
$html .= "<li class='dropdown_parent'>";
|
150 |
+
$html .= '<a href="' . $child->getUrl() .'" title="'.$this->escapeHtml($child->getName()). '" ' . $outermostClassCode . '><span>'
|
151 |
+
. $this->escapeHtml($child->getName()) . '</span></a>';
|
152 |
+
/*if (!empty($childrenWrapClass)) {
|
153 |
+
$html .= '<div class="' . $childrenWrapClass . '">';
|
154 |
+
}*/
|
155 |
+
$html .= "<ul class='dropdown_flyout_level' style='display:none'>";
|
156 |
+
$html .= $this->_getHtml($child, $childrenWrapClass);
|
157 |
+
$html .= '</ul>';
|
158 |
+
|
159 |
+
/*if (!empty($childrenWrapClass)) {
|
160 |
+
$html .= '</div>';
|
161 |
+
}*/
|
162 |
+
}
|
163 |
+
else{
|
164 |
+
$html .= "<li>";
|
165 |
+
$html .= '<a href="' . $child->getUrl() . '" title="'.$this->escapeHtml($child->getName()).'" ' . $outermostClassCode . '><span>'
|
166 |
+
. $this->escapeHtml($child->getName()) . '</span></a></li>';
|
167 |
+
}
|
168 |
+
$html .= '</li>';
|
169 |
+
|
170 |
+
$counter++;
|
171 |
+
}
|
172 |
+
|
173 |
+
return $html;
|
174 |
+
}
|
175 |
+
else{
|
176 |
+
$html = '';
|
177 |
+
|
178 |
+
$children = $menuTree->getChildren();
|
179 |
+
$parentLevel = $menuTree->getLevel();
|
180 |
+
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
|
181 |
+
|
182 |
+
$counter = 1;
|
183 |
+
$childrenCount = $children->count();
|
184 |
+
|
185 |
+
$parentPositionClass = $menuTree->getPositionClass();
|
186 |
+
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
|
187 |
+
|
188 |
+
foreach ($children as $child) {
|
189 |
+
|
190 |
+
$child->setLevel($childLevel);
|
191 |
+
$child->setIsFirst($counter == 1);
|
192 |
+
$child->setIsLast($counter == $childrenCount);
|
193 |
+
$child->setPositionClass($itemPositionClassPrefix . $counter);
|
194 |
+
|
195 |
+
$outermostClassCode = '';
|
196 |
+
$outermostClass = $menuTree->getOutermostClass();
|
197 |
+
|
198 |
+
if ($childLevel == 0 && $outermostClass) {
|
199 |
+
$outermostClassCode = ' class="' . $outermostClass . '" ';
|
200 |
+
$child->setClass($outermostClass);
|
201 |
+
}
|
202 |
+
|
203 |
+
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
|
204 |
+
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
|
205 |
+
. $this->escapeHtml($child->getName()) . '</span></a>';
|
206 |
+
|
207 |
+
if ($child->hasChildren()) {
|
208 |
+
if (!empty($childrenWrapClass)) {
|
209 |
+
$html .= '<div class="' . $childrenWrapClass . '">';
|
210 |
+
}
|
211 |
+
$html .= '<ul class="level' . $childLevel . '">';
|
212 |
+
$html .= $this->_getHtml($child, $childrenWrapClass);
|
213 |
+
$html .= '</ul>';
|
214 |
+
|
215 |
+
if (!empty($childrenWrapClass)) {
|
216 |
+
$html .= '</div>';
|
217 |
+
}
|
218 |
+
}
|
219 |
+
$html .= '</li>';
|
220 |
+
|
221 |
+
$counter++;
|
222 |
+
}
|
223 |
+
|
224 |
+
return $html;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Generates string with all attributes that should be present in menu item element
|
232 |
+
*
|
233 |
+
* @param Varien_Data_Tree_Node $item
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
+
protected function _getRenderedMenuItemAttributes(Varien_Data_Tree_Node $item)
|
237 |
+
{
|
238 |
+
$html = '';
|
239 |
+
$attributes = $this->_getMenuItemAttributes($item);
|
240 |
+
|
241 |
+
foreach ($attributes as $attributeName => $attributeValue) {
|
242 |
+
$html .= ' ' . $attributeName . '="' . str_replace('"', '\"', $attributeValue) . '"';
|
243 |
+
}
|
244 |
+
|
245 |
+
return $html;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Returns array of menu item's attributes
|
250 |
+
*
|
251 |
+
* @param Varien_Data_Tree_Node $item
|
252 |
+
* @return array
|
253 |
+
*/
|
254 |
+
protected function _getMenuItemAttributes(Varien_Data_Tree_Node $item)
|
255 |
+
{
|
256 |
+
$menuItemClasses = $this->_getMenuItemClasses($item);
|
257 |
+
$attributes = array(
|
258 |
+
'class' => implode(' ', $menuItemClasses)
|
259 |
+
);
|
260 |
+
|
261 |
+
return $attributes;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Returns array of menu item's classes
|
266 |
+
*
|
267 |
+
* @param Varien_Data_Tree_Node $item
|
268 |
+
* @return array
|
269 |
+
*/
|
270 |
+
protected function _getMenuItemClasses(Varien_Data_Tree_Node $item)
|
271 |
+
{
|
272 |
+
$classes = array();
|
273 |
+
|
274 |
+
$classes[] = 'level' . $item->getLevel();
|
275 |
+
$classes[] = $item->getPositionClass();
|
276 |
+
|
277 |
+
if ($item->getIsFirst()) {
|
278 |
+
$classes[] = 'first';
|
279 |
+
}
|
280 |
+
|
281 |
+
if ($item->getIsActive()) {
|
282 |
+
$classes[] = 'active';
|
283 |
+
}
|
284 |
+
|
285 |
+
if ($item->getIsLast()) {
|
286 |
+
$classes[] = 'last';
|
287 |
+
}
|
288 |
+
|
289 |
+
if ($item->getClass()) {
|
290 |
+
$classes[] = $item->getClass();
|
291 |
+
}
|
292 |
+
|
293 |
+
if ($item->hasChildren()) {
|
294 |
+
$classes[] = 'parent';
|
295 |
+
}
|
296 |
+
|
297 |
+
return $classes;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Retrieve cache key data
|
302 |
+
*
|
303 |
+
* @return array
|
304 |
+
*/
|
305 |
+
public function getCacheKeyInfo()
|
306 |
+
{
|
307 |
+
$shortCacheId = array(
|
308 |
+
'TOPMENU',
|
309 |
+
Mage::app()->getStore()->getId(),
|
310 |
+
Mage::getDesign()->getPackageName(),
|
311 |
+
Mage::getDesign()->getTheme('template'),
|
312 |
+
Mage::getSingleton('customer/session')->getCustomerGroupId(),
|
313 |
+
'template' => $this->getTemplate(),
|
314 |
+
'name' => $this->getNameInLayout(),
|
315 |
+
$this->getCurrentEntityKey()
|
316 |
+
);
|
317 |
+
$cacheId = $shortCacheId;
|
318 |
+
|
319 |
+
$shortCacheId = array_values($shortCacheId);
|
320 |
+
$shortCacheId = implode('|', $shortCacheId);
|
321 |
+
$shortCacheId = md5($shortCacheId);
|
322 |
+
|
323 |
+
$cacheId['entity_key'] = $this->getCurrentEntityKey();
|
324 |
+
$cacheId['short_cache_id'] = $shortCacheId;
|
325 |
+
|
326 |
+
return $cacheId;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Retrieve current entity key
|
331 |
+
*
|
332 |
+
* @return int|string
|
333 |
+
*/
|
334 |
+
public function getCurrentEntityKey()
|
335 |
+
{
|
336 |
+
if (null === $this->_currentEntityKey) {
|
337 |
+
$this->_currentEntityKey = Mage::registry('current_entity_key')
|
338 |
+
? Mage::registry('current_entity_key') : Mage::app()->getStore()->getRootCategoryId();
|
339 |
+
}
|
340 |
+
return $this->_currentEntityKey;
|
341 |
+
}
|
342 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Block/Menuitem/Catalog/Product/List.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 product list
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Block_Menuitem_Catalog_Product_List extends Mage_Core_Block_Template{
|
25 |
+
/**
|
26 |
+
* get the list of products
|
27 |
+
* @access public
|
28 |
+
* @return Mage_Catalog_Model_Resource_Product_Collection
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function getProductCollection(){
|
32 |
+
$collection = $this->getMenuitem()->getSelectedProductsCollection();
|
33 |
+
$collection->addAttributeToSelect('name');
|
34 |
+
$collection->addUrlRewrite();
|
35 |
+
$collection->getSelect()->order('related.position');
|
36 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
37 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
38 |
+
return $collection;
|
39 |
+
}
|
40 |
+
/**
|
41 |
+
* get current menuitem
|
42 |
+
* @access public
|
43 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
44 |
+
* @author Jason Lotzer
|
45 |
+
*/
|
46 |
+
public function getMenuitem(){
|
47 |
+
return Mage::registry('current_megamenu2_menuitem');
|
48 |
+
}
|
49 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Controller/Adminhtml/MegaMenu2.php
CHANGED
@@ -1,59 +1,60 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* module base admin controller
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$uploader
|
41 |
-
$uploader->
|
42 |
-
$uploader->
|
43 |
-
$
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
33 |
+
*/
|
34 |
+
protected function _uploadAndGetName($input, $destinationFolder, $data){
|
35 |
+
try{
|
36 |
+
if (isset($data[$input]['delete'])){
|
37 |
+
return '';
|
38 |
+
}
|
39 |
+
else{
|
40 |
+
$uploader = new Varien_File_Uploader($input);
|
41 |
+
$uploader->setAllowRenameFiles(true);
|
42 |
+
$uploader->setFilesDispersion(true);
|
43 |
+
$uploader->setAllowCreateFolders(true);
|
44 |
+
$result = $uploader->save($destinationFolder);
|
45 |
+
return $result['file'];
|
46 |
+
}
|
47 |
+
}
|
48 |
+
catch (Exception $e){
|
49 |
+
if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY){
|
50 |
+
throw $e;
|
51 |
+
}
|
52 |
+
else{
|
53 |
+
if (isset($data[$input]['value'])){
|
54 |
+
return $data[$input]['value'];
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
return '';
|
59 |
+
}
|
60 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Helper/Data.php
CHANGED
@@ -1,24 +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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* MegaMenu2 default helper
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Helper_Data extends Mage_Core_Helper_Abstract{
|
25 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Helper/Menuitem.php
CHANGED
@@ -1,41 +1,62 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item helper
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
*
|
28 |
-
* @
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
|
38 |
-
|
39 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Helper_Menuitem extends Mage_Core_Helper_Abstract{
|
25 |
+
const MENUITEM_ROOT_ID = 1;
|
26 |
+
/**
|
27 |
+
* get the root id
|
28 |
+
* @access public
|
29 |
+
* @return int
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
public function getRootMenuitemId(){
|
33 |
+
return self::MENUITEM_ROOT_ID;
|
34 |
+
}
|
35 |
+
/**
|
36 |
+
* get base files dir
|
37 |
+
* @access public
|
38 |
+
* @return string
|
39 |
+
* @author Jason Lotzer
|
40 |
+
*/
|
41 |
+
public function getFileBaseDir(){
|
42 |
+
return Mage::getBaseDir('media').DS.'menuitem'.DS.'file';
|
43 |
+
}
|
44 |
+
/**
|
45 |
+
* get base file url
|
46 |
+
* @access public
|
47 |
+
* @return string
|
48 |
+
* @author Jason Lotzer
|
49 |
+
*/
|
50 |
+
public function getFileBaseUrl(){
|
51 |
+
return Mage::getBaseUrl('media').'menuitem'.'/'.'file';
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* check if breadcrumbs can be used
|
55 |
+
* @access public
|
56 |
+
* @return bool
|
57 |
+
* @author Jason Lotzer
|
58 |
+
*/
|
59 |
+
public function getUseBreadcrumbs(){
|
60 |
+
return Mage::getStoreConfigFlag('megamenu2/menuitem/breadcrumbs');
|
61 |
+
}
|
62 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Helper/Menusetting.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting helper
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Helper_Menusetting extends Mage_Core_Helper_Abstract{
|
25 |
+
/**
|
26 |
+
* check if breadcrumbs can be used
|
27 |
+
* @access public
|
28 |
+
* @return bool
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function getUseBreadcrumbs(){
|
32 |
+
return Mage::getStoreConfigFlag('megamenu2/menusetting/breadcrumbs');
|
33 |
+
}
|
34 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Helper/Product.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Product helper
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Helper_Product extends JScriptz_MegaMenu2_Helper_Data{
|
25 |
+
/**
|
26 |
+
* get the selected menuitems for a product
|
27 |
+
* @access public
|
28 |
+
* @param Mage_Catalog_Model_Product $product
|
29 |
+
* @return array()
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
public function getSelectedMenuitems(Mage_Catalog_Model_Product $product){
|
33 |
+
if (!$product->hasSelectedMenuitems()) {
|
34 |
+
$menuitems = array();
|
35 |
+
foreach ($this->getSelectedMenuitemsCollection($product) as $menuitem) {
|
36 |
+
$menuitems[] = $menuitem;
|
37 |
+
}
|
38 |
+
$product->setSelectedMenuitems($menuitems);
|
39 |
+
}
|
40 |
+
return $product->getData('selected_menuitems');
|
41 |
+
}
|
42 |
+
/**
|
43 |
+
* get menuitem collection for a product
|
44 |
+
* @access public
|
45 |
+
* @param Mage_Catalog_Model_Product $product
|
46 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
47 |
+
*/
|
48 |
+
public function getSelectedMenuitemsCollection(Mage_Catalog_Model_Product $product){
|
49 |
+
$collection = Mage::getResourceSingleton('megamenu2/menuitem_collection')
|
50 |
+
->addProductFilter($product);
|
51 |
+
return $collection;
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* get the selected menusettings for a product
|
55 |
+
* @access public
|
56 |
+
* @param Mage_Catalog_Model_Product $product
|
57 |
+
* @return array()
|
58 |
+
* @author Jason Lotzer
|
59 |
+
*/
|
60 |
+
public function getSelectedMenusettings(Mage_Catalog_Model_Product $product){
|
61 |
+
if (!$product->hasSelectedMenusettings()) {
|
62 |
+
$menusettings = array();
|
63 |
+
foreach ($this->getSelectedMenusettingsCollection($product) as $menusetting) {
|
64 |
+
$menusettings[] = $menusetting;
|
65 |
+
}
|
66 |
+
$product->setSelectedMenusettings($menusettings);
|
67 |
+
}
|
68 |
+
return $product->getData('selected_menusettings');
|
69 |
+
}
|
70 |
+
/**
|
71 |
+
* get menusetting collection for a product
|
72 |
+
* @access public
|
73 |
+
* @param Mage_Catalog_Model_Product $product
|
74 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection
|
75 |
+
*/
|
76 |
+
public function getSelectedMenusettingsCollection(Mage_Catalog_Model_Product $product){
|
77 |
+
$collection = Mage::getResourceSingleton('megamenu2/menusetting_collection')
|
78 |
+
->addProductFilter($product);
|
79 |
+
return $collection;
|
80 |
+
}
|
81 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Adminhtml/Observer.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Adminhtml observer
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Adminhtml_Observer{
|
25 |
+
/**
|
26 |
+
* check if tab can be added
|
27 |
+
* @access protected
|
28 |
+
* @param Mage_Catalog_Model_Product $product
|
29 |
+
* @return bool
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
protected function _canAddTab($product){
|
33 |
+
if ($product->getId()){
|
34 |
+
return true;
|
35 |
+
}
|
36 |
+
if (!$product->getAttributeSetId()){
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
$request = Mage::app()->getRequest();
|
40 |
+
if ($request->getParam('type') == 'configurable'){
|
41 |
+
if ($request->getParam('attribtues')){
|
42 |
+
return true;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* add the menuitem tab to products
|
49 |
+
* @access public
|
50 |
+
* @param Varien_Event_Observer $observer
|
51 |
+
* @return JScriptz_MegaMenu2_Model_Adminhtml_Observer
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function addMenuitemBlock($observer){
|
55 |
+
$block = $observer->getEvent()->getBlock();
|
56 |
+
$product = Mage::registry('product');
|
57 |
+
if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)){
|
58 |
+
$block->addTab('menuitems', array(
|
59 |
+
'label' => Mage::helper('megamenu2')->__('Menuitems'),
|
60 |
+
'url' => Mage::helper('adminhtml')->getUrl('adminhtml/megamenu2_menuitem_catalog_product/menuitems', array('_current' => true)),
|
61 |
+
'class' => 'ajax',
|
62 |
+
));
|
63 |
+
}
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
/**
|
67 |
+
* add the menusetting tab to products
|
68 |
+
* @access public
|
69 |
+
* @param Varien_Event_Observer $observer
|
70 |
+
* @return JScriptz_MegaMenu2_Model_Adminhtml_Observer
|
71 |
+
* @author Jason Lotzer
|
72 |
+
*/
|
73 |
+
public function addMenusettingBlock($observer){
|
74 |
+
$block = $observer->getEvent()->getBlock();
|
75 |
+
$product = Mage::registry('product');
|
76 |
+
if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)){
|
77 |
+
$block->addTab('menusettings', array(
|
78 |
+
'label' => Mage::helper('megamenu2')->__('Menusettings'),
|
79 |
+
'url' => Mage::helper('adminhtml')->getUrl('adminhtml/megamenu2_menusetting_catalog_product/menusettings', array('_current' => true)),
|
80 |
+
'class' => 'ajax',
|
81 |
+
));
|
82 |
+
}
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
/**
|
86 |
+
* save menusetting - product relation
|
87 |
+
* @access public
|
88 |
+
* @param Varien_Event_Observer $observer
|
89 |
+
* @return JScriptz_MegaMenu2_Model_Adminhtml_Observer
|
90 |
+
* @author Jason Lotzer
|
91 |
+
*/
|
92 |
+
public function saveMenusettingData($observer){
|
93 |
+
$post = Mage::app()->getRequest()->getPost('menusettings', -1);
|
94 |
+
if ($post != '-1') {
|
95 |
+
$post = Mage::helper('adminhtml/js')->decodeGridSerializedInput($post);
|
96 |
+
$product = Mage::registry('product');
|
97 |
+
$menusettingProduct = Mage::getResourceSingleton('megamenu2/menusetting_product')->saveProductRelation($product, $post);
|
98 |
+
}
|
99 |
+
return $this;
|
100 |
+
} /**
|
101 |
+
* save menuitem - product relation
|
102 |
+
* @access public
|
103 |
+
* @param Varien_Event_Observer $observer
|
104 |
+
* @return JScriptz_MegaMenu2_Model_Adminhtml_Observer
|
105 |
+
* @author Jason Lotzer
|
106 |
+
*/
|
107 |
+
public function saveMenuitemData($observer){
|
108 |
+
$post = Mage::app()->getRequest()->getPost('menuitem_ids', -1);
|
109 |
+
if ($post != '-1') {
|
110 |
+
$post = explode(',', $post);
|
111 |
+
$post = array_unique($post);
|
112 |
+
$product = $observer->getEvent()->getProduct();
|
113 |
+
Mage::getResourceSingleton('megamenu2/menuitem_product')->saveProductRelation($product, $post);
|
114 |
+
}
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Menuitem.php
CHANGED
@@ -1,307 +1,408 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item model
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
|
28 |
-
|
29 |
-
const
|
30 |
-
|
31 |
-
|
32 |
-
*
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
*
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
* @
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
return
|
92 |
-
}
|
93 |
-
/**
|
94 |
-
* get
|
95 |
-
* @access public
|
96 |
-
* @return
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
*
|
107 |
-
* @
|
108 |
-
* @
|
109 |
-
* @
|
110 |
-
*/
|
111 |
-
public function
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$this->
|
129 |
-
$
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
$this->
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
*
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
*
|
255 |
-
* @
|
256 |
-
* @
|
257 |
-
*/
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
*
|
266 |
-
* @
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
*
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Menuitem extends Mage_Core_Model_Abstract{
|
25 |
+
/**
|
26 |
+
* Entity code.
|
27 |
+
* Can be used as part of method name for entity processing
|
28 |
+
*/
|
29 |
+
const ENTITY= 'megamenu2_menuitem';
|
30 |
+
const CACHE_TAG = 'megamenu2_menuitem';
|
31 |
+
/**
|
32 |
+
* Prefix of model events names
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
protected $_eventPrefix = 'megamenu2_menuitem';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Parameter name in event
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
protected $_eventObject = 'menuitem';
|
42 |
+
protected $_menusettingInstance = null;
|
43 |
+
protected $_productInstance = null;
|
44 |
+
/**
|
45 |
+
* constructor
|
46 |
+
* @access public
|
47 |
+
* @return void
|
48 |
+
* @author Jason Lotzer
|
49 |
+
*/
|
50 |
+
public function _construct(){
|
51 |
+
parent::_construct();
|
52 |
+
$this->_init('megamenu2/menuitem');
|
53 |
+
}
|
54 |
+
/**
|
55 |
+
* before save menu item
|
56 |
+
* @access protected
|
57 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
58 |
+
* @author Jason Lotzer
|
59 |
+
*/
|
60 |
+
protected function _beforeSave(){
|
61 |
+
parent::_beforeSave();
|
62 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
63 |
+
if ($this->isObjectNew()){
|
64 |
+
$this->setCreatedAt($now);
|
65 |
+
}
|
66 |
+
$this->setUpdatedAt($now);
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
/**
|
70 |
+
* get the menuitem Menu HTML
|
71 |
+
* @access public
|
72 |
+
* @return string
|
73 |
+
* @author Jason Lotzer
|
74 |
+
*/
|
75 |
+
public function getMenuhtml(){
|
76 |
+
$menuhtml = $this->getData('menuhtml');
|
77 |
+
$helper = Mage::helper('cms');
|
78 |
+
$processor = $helper->getBlockTemplateProcessor();
|
79 |
+
$html = $processor->filter($menuhtml);
|
80 |
+
return $html;
|
81 |
+
}
|
82 |
+
/**
|
83 |
+
* save menuitem relation
|
84 |
+
* @access public
|
85 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
86 |
+
* @author Jason Lotzer
|
87 |
+
*/
|
88 |
+
protected function _afterSave() {
|
89 |
+
$this->getProductInstance()->saveMenuitemRelation($this);
|
90 |
+
$this->getMenusettingInstance()->saveMenuitemRelation($this);
|
91 |
+
return parent::_afterSave();
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* get product relation model
|
95 |
+
* @access public
|
96 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem_Product
|
97 |
+
* @author Jason Lotzer
|
98 |
+
*/
|
99 |
+
public function getProductInstance(){
|
100 |
+
if (!$this->_productInstance) {
|
101 |
+
$this->_productInstance = Mage::getSingleton('megamenu2/menuitem_product');
|
102 |
+
}
|
103 |
+
return $this->_productInstance;
|
104 |
+
}
|
105 |
+
/**
|
106 |
+
* get selected products array
|
107 |
+
* @access public
|
108 |
+
* @return array
|
109 |
+
* @author Jason Lotzer
|
110 |
+
*/
|
111 |
+
public function getSelectedProducts(){
|
112 |
+
if (!$this->hasSelectedProducts()) {
|
113 |
+
$products = array();
|
114 |
+
foreach ($this->getSelectedProductsCollection() as $product) {
|
115 |
+
$products[] = $product;
|
116 |
+
}
|
117 |
+
$this->setSelectedProducts($products);
|
118 |
+
}
|
119 |
+
return $this->getData('selected_products');
|
120 |
+
}
|
121 |
+
/**
|
122 |
+
* Retrieve collection selected products
|
123 |
+
* @access public
|
124 |
+
* @return JScriptz_MegaMenu2_Resource_Menuitem_Product_Collection
|
125 |
+
* @author Jason Lotzer
|
126 |
+
*/
|
127 |
+
public function getSelectedProductsCollection(){
|
128 |
+
$collection = $this->getProductInstance()->getProductCollection($this);
|
129 |
+
return $collection;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* get menusetting relation model
|
133 |
+
* @access public
|
134 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem_Menusetting
|
135 |
+
* @author Jason Lotzer
|
136 |
+
*/
|
137 |
+
public function getMenusettingInstance(){
|
138 |
+
if (!$this->_menusettingInstance) {
|
139 |
+
$this->_menusettingInstance = Mage::getSingleton('megamenu2/menuitem_menusetting');
|
140 |
+
}
|
141 |
+
return $this->_menusettingInstance;
|
142 |
+
}
|
143 |
+
/**
|
144 |
+
* get selected menusettings array
|
145 |
+
* @access public
|
146 |
+
* @return array
|
147 |
+
* @author Jason Lotzer
|
148 |
+
*/
|
149 |
+
public function getSelectedMenusettings(){
|
150 |
+
if (!$this->hasSelectedMenusettings()) {
|
151 |
+
$menusettings = array();
|
152 |
+
foreach ($this->getSelectedMenusettingsCollection() as $menusetting) {
|
153 |
+
$menusettings[] = $menusetting;
|
154 |
+
}
|
155 |
+
$this->setSelectedMenusettings($menusettings);
|
156 |
+
}
|
157 |
+
return $this->getData('selected_menusettings');
|
158 |
+
}
|
159 |
+
/**
|
160 |
+
* Retrieve collection selected menusettings
|
161 |
+
* @access public
|
162 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem_Menusetting_Collection
|
163 |
+
* @author Jason Lotzer
|
164 |
+
*/
|
165 |
+
public function getSelectedMenusettingsCollection(){
|
166 |
+
$collection = $this->getMenusettingInstance()->getMenusettingsCollection($this);
|
167 |
+
return $collection;
|
168 |
+
}
|
169 |
+
/**
|
170 |
+
* get the tree model
|
171 |
+
* @access public
|
172 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
173 |
+
* @author Jason Lotzer
|
174 |
+
*/
|
175 |
+
public function getTreeModel(){
|
176 |
+
return Mage::getResourceModel('megamenu2/menuitem_tree');
|
177 |
+
}
|
178 |
+
/**
|
179 |
+
* get tree model instance
|
180 |
+
* @access public
|
181 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
182 |
+
* @author Jason Lotzer
|
183 |
+
*/
|
184 |
+
public function getTreeModelInstance(){
|
185 |
+
if (is_null($this->_treeModel)) {
|
186 |
+
$this->_treeModel = Mage::getResourceSingleton('megamenu2/menuitem_tree');
|
187 |
+
}
|
188 |
+
return $this->_treeModel;
|
189 |
+
}
|
190 |
+
/**
|
191 |
+
* Move menu item
|
192 |
+
* @access public
|
193 |
+
* @param int $parentId new parent menu item id
|
194 |
+
* @param int $afterMenuitemId menu item id after which we have put current menu item
|
195 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
196 |
+
* @author Jason Lotzer
|
197 |
+
*/
|
198 |
+
public function move($parentId, $afterMenuitemId){
|
199 |
+
$parent = Mage::getModel('megamenu2/menuitem')->load($parentId);
|
200 |
+
if (!$parent->getId()) {
|
201 |
+
Mage::throwException(
|
202 |
+
Mage::helper('megamenu2')->__('Menu Item move operation is not possible: the new parent menu item was not found.')
|
203 |
+
);
|
204 |
+
}
|
205 |
+
if (!$this->getId()) {
|
206 |
+
Mage::throwException(
|
207 |
+
Mage::helper('megamenu2')->__('Menu Item move operation is not possible: the current menu item was not found.')
|
208 |
+
);
|
209 |
+
}
|
210 |
+
elseif ($parent->getId() == $this->getId()) {
|
211 |
+
Mage::throwException(
|
212 |
+
Mage::helper('megamenu2')->__('Menu Item move operation is not possible: parent menu item is equal to child menu item.')
|
213 |
+
);
|
214 |
+
}
|
215 |
+
$this->setMovedMenuitemId($this->getId());
|
216 |
+
$eventParams = array(
|
217 |
+
$this->_eventObject => $this,
|
218 |
+
'parent' => $parent,
|
219 |
+
'menuitem_id' => $this->getId(),
|
220 |
+
'prev_parent_id' => $this->getParentId(),
|
221 |
+
'parent_id' => $parentId
|
222 |
+
);
|
223 |
+
$moveComplete = false;
|
224 |
+
$this->_getResource()->beginTransaction();
|
225 |
+
try {
|
226 |
+
$this->getResource()->changeParent($this, $parent, $afterMenuitemId);
|
227 |
+
$this->_getResource()->commit();
|
228 |
+
$this->setAffectedMenuitemIds(array($this->getId(), $this->getParentId(), $parentId));
|
229 |
+
$moveComplete = true;
|
230 |
+
}
|
231 |
+
catch (Exception $e) {
|
232 |
+
$this->_getResource()->rollBack();
|
233 |
+
throw $e;
|
234 |
+
}
|
235 |
+
if ($moveComplete) {
|
236 |
+
Mage::app()->cleanCache(array(self::CACHE_TAG));
|
237 |
+
}
|
238 |
+
return $this;
|
239 |
+
}
|
240 |
+
/**
|
241 |
+
* Get the parent menu item
|
242 |
+
* @access public
|
243 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
244 |
+
* @author Jason Lotzer
|
245 |
+
*/
|
246 |
+
public function getParentMenuitem(){
|
247 |
+
if (!$this->hasData('parent_menuitem')) {
|
248 |
+
$this->setData('parent_menuitem', Mage::getModel('megamenu2/menuitem')->load($this->getParentId()));
|
249 |
+
}
|
250 |
+
return $this->_getData('parent_menuitem');
|
251 |
+
}
|
252 |
+
/**
|
253 |
+
* Get the parent id
|
254 |
+
* @access public
|
255 |
+
* @return int
|
256 |
+
* @author Jason Lotzer
|
257 |
+
*/
|
258 |
+
public function getParentId(){
|
259 |
+
$parentIds = $this->getParentIds();
|
260 |
+
return intval(array_pop($parentIds));
|
261 |
+
}
|
262 |
+
/**
|
263 |
+
* Get all parent menu items ids
|
264 |
+
* @access public
|
265 |
+
* @return array
|
266 |
+
* @author Jason Lotzer
|
267 |
+
*/
|
268 |
+
public function getParentIds(){
|
269 |
+
return array_diff($this->getPathIds(), array($this->getId()));
|
270 |
+
}
|
271 |
+
/**
|
272 |
+
* Get all menu items children
|
273 |
+
* @access public
|
274 |
+
* @param bool $asArray
|
275 |
+
* @return mixed (array|string)
|
276 |
+
* @author Jason Lotzer
|
277 |
+
*/
|
278 |
+
public function getAllChildren($asArray = false){
|
279 |
+
$children = $this->getResource()->getAllChildren($this);
|
280 |
+
if ($asArray) {
|
281 |
+
return $children;
|
282 |
+
}
|
283 |
+
else {
|
284 |
+
return implode(',', $children);
|
285 |
+
}
|
286 |
+
}
|
287 |
+
/**
|
288 |
+
* Get all menu items children
|
289 |
+
* @access public
|
290 |
+
* @return string
|
291 |
+
* @author Jason Lotzer
|
292 |
+
*/
|
293 |
+
public function getChildren(){
|
294 |
+
return implode(',', $this->getResource()->getChildren($this, false));
|
295 |
+
}
|
296 |
+
/**
|
297 |
+
* check the id
|
298 |
+
* @access public
|
299 |
+
* @return bool
|
300 |
+
* @author Jason Lotzer
|
301 |
+
*/
|
302 |
+
public function checkId($id){
|
303 |
+
return $this->_getResource()->checkId($id);
|
304 |
+
}
|
305 |
+
/**
|
306 |
+
* Get array menu items ids which are part of menu item path
|
307 |
+
* @access public
|
308 |
+
* @return array
|
309 |
+
* @author Jason Lotzer
|
310 |
+
*/
|
311 |
+
public function getPathIds(){
|
312 |
+
$ids = $this->getData('path_ids');
|
313 |
+
if (is_null($ids)) {
|
314 |
+
$ids = explode('/', $this->getPath());
|
315 |
+
$this->setData('path_ids', $ids);
|
316 |
+
}
|
317 |
+
return $ids;
|
318 |
+
}
|
319 |
+
/**
|
320 |
+
* Retrieve level
|
321 |
+
* @access public
|
322 |
+
* @return int
|
323 |
+
* @author Jason Lotzer
|
324 |
+
*/
|
325 |
+
public function getLevel(){
|
326 |
+
if (!$this->hasLevel()) {
|
327 |
+
return count(explode('/', $this->getPath())) - 1;
|
328 |
+
}
|
329 |
+
return $this->getData('level');
|
330 |
+
}
|
331 |
+
/**
|
332 |
+
* Verify menu item ids
|
333 |
+
* @access public
|
334 |
+
* @param array $ids
|
335 |
+
* @return bool
|
336 |
+
* @author Jason Lotzer
|
337 |
+
*/
|
338 |
+
public function verifyIds(array $ids){
|
339 |
+
return $this->getResource()->verifyIds($ids);
|
340 |
+
}
|
341 |
+
/**
|
342 |
+
* check if menu item has children
|
343 |
+
* @access public
|
344 |
+
* @return bool
|
345 |
+
* @author Jason Lotzer
|
346 |
+
*/
|
347 |
+
public function hasChildren(){
|
348 |
+
return $this->_getResource()->getChildrenAmount($this) > 0;
|
349 |
+
}
|
350 |
+
/**
|
351 |
+
* check if menu item can be deleted
|
352 |
+
* @access protected
|
353 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem
|
354 |
+
* @author Jason Lotzer
|
355 |
+
*/
|
356 |
+
protected function _beforeDelete(){
|
357 |
+
if ($this->getResource()->isForbiddenToDelete($this->getId())) {
|
358 |
+
Mage::throwException(Mage::helper('megamenu2')->__("Can't delete root menu item."));
|
359 |
+
}
|
360 |
+
return parent::_beforeDelete();
|
361 |
+
}
|
362 |
+
/**
|
363 |
+
* get the menu items
|
364 |
+
* @access public
|
365 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $parent
|
366 |
+
* @param int $recursionLevel
|
367 |
+
* @param bool $sorted
|
368 |
+
* @param bool $asCollection
|
369 |
+
* @param bool $toLoad
|
370 |
+
* @author Jason Lotzer
|
371 |
+
*/
|
372 |
+
public function getMenuitems($parent, $recursionLevel = 0, $sorted=false, $asCollection=false, $toLoad=true){
|
373 |
+
return $this->getResource()->getMenuitems($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
|
374 |
+
}
|
375 |
+
/**
|
376 |
+
* Return parent menu items of current menu item
|
377 |
+
* @access public
|
378 |
+
* @return array
|
379 |
+
* @author Jason Lotzer
|
380 |
+
*/
|
381 |
+
public function getParentMenuitems(){
|
382 |
+
return $this->getResource()->getParentMenuitems($this);
|
383 |
+
}
|
384 |
+
/**
|
385 |
+
* Retuen children menu items of current menu item
|
386 |
+
* @access public
|
387 |
+
* @return array
|
388 |
+
* @author Jason Lotzer
|
389 |
+
*/
|
390 |
+
public function getChildrenMenuitems(){
|
391 |
+
return $this->getResource()->getChildrenMenuitems($this);
|
392 |
+
}
|
393 |
+
/**
|
394 |
+
* check if parents are enabled
|
395 |
+
* @access public
|
396 |
+
* @return bool
|
397 |
+
* @author Jason Lotzer
|
398 |
+
*/
|
399 |
+
public function getStatusPath(){
|
400 |
+
$parents = $this->getParentMenuitems();
|
401 |
+
foreach ($parents as $parent){
|
402 |
+
if (!$parent->getStatus()){
|
403 |
+
return false;
|
404 |
+
}
|
405 |
+
}
|
406 |
+
return $this->getStatus();
|
407 |
+
}
|
408 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Menuitem/Menusetting.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 menu setting model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Menuitem_Menusetting extends Mage_Core_Model_Abstract{
|
25 |
+
/**
|
26 |
+
* Initialize resource
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _construct(){
|
32 |
+
$this->_init('megamenu2/menuitem_menusetting');
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Save data for menuitem - menusetting relation
|
36 |
+
* @access public
|
37 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
38 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem_Menusetting
|
39 |
+
* @author Jason Lotzer
|
40 |
+
*/
|
41 |
+
public function saveMenuitemRelation($menuitem){
|
42 |
+
$data = $menuitem->getMenusettingsData();
|
43 |
+
if (!is_null($data)) {
|
44 |
+
$this->_getResource()->saveMenuitemRelation($menuitem, $data);
|
45 |
+
}
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* get menusettings for menuitem
|
50 |
+
* @access public
|
51 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
52 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Menusetting_Collection
|
53 |
+
* @author Jason Lotzer
|
54 |
+
*/
|
55 |
+
public function getMenusettingsCollection($menuitem){
|
56 |
+
$collection = Mage::getResourceModel('megamenu2/menuitem_menusetting_collection')
|
57 |
+
->addMenuitemFilter($menuitem);
|
58 |
+
return $collection;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Menuitem/Product.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 product model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Menuitem_Product extends Mage_Core_Model_Abstract{
|
25 |
+
/**
|
26 |
+
* Initialize resource
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _construct(){
|
32 |
+
$this->_init('megamenu2/menuitem_product');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getMyData(){
|
36 |
+
$data = $menuitem->getProductsData();
|
37 |
+
return $this->data;
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* Save data for menuitem-product relation
|
41 |
+
* @access public
|
42 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
43 |
+
* @return JScriptz_MegaMenu2_Model_Menuitem_Product
|
44 |
+
* @author Jason Lotzer
|
45 |
+
*/
|
46 |
+
public function saveMenuitemRelation($menuitem){
|
47 |
+
$data = $menuitem->getProductsData();
|
48 |
+
if (!is_null($data)) {
|
49 |
+
$this->_getResource()->saveMenuitemRelation($menuitem, $data);
|
50 |
+
}
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* get products for menuitem
|
55 |
+
* @access public
|
56 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
57 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Product_Collection
|
58 |
+
* @author Jason Lotzer
|
59 |
+
*/
|
60 |
+
public function getProductCollection($menuitem){
|
61 |
+
$collection = Mage::getResourceModel('megamenu2/menuitem_product_collection')
|
62 |
+
->addMenuitemFilter($menuitem);
|
63 |
+
return $collection;
|
64 |
+
}
|
65 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Menusetting.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Menusetting extends Mage_Core_Model_Abstract{
|
25 |
+
/**
|
26 |
+
* Entity code.
|
27 |
+
* Can be used as part of method name for entity processing
|
28 |
+
*/
|
29 |
+
const ENTITY= 'megamenu2_menusetting';
|
30 |
+
const CACHE_TAG = 'megamenu2_menusetting';
|
31 |
+
/**
|
32 |
+
* Prefix of model events names
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
protected $_eventPrefix = 'megamenu2_menusetting';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Parameter name in event
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
protected $_eventObject = 'menusetting';
|
42 |
+
protected $_menuitemInstance = null;
|
43 |
+
protected $_productInstance = null;
|
44 |
+
/**
|
45 |
+
* constructor
|
46 |
+
* @access public
|
47 |
+
* @return void
|
48 |
+
* @author Jason Lotzer
|
49 |
+
*/
|
50 |
+
public function _construct(){
|
51 |
+
parent::_construct();
|
52 |
+
$this->_init('megamenu2/menusetting');
|
53 |
+
}
|
54 |
+
/**
|
55 |
+
* before save menu setting
|
56 |
+
* @access protected
|
57 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting
|
58 |
+
* @author Jason Lotzer
|
59 |
+
*/
|
60 |
+
protected function _beforeSave(){
|
61 |
+
parent::_beforeSave();
|
62 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
63 |
+
if ($this->isObjectNew()){
|
64 |
+
$this->setCreatedAt($now);
|
65 |
+
}
|
66 |
+
$this->setUpdatedAt($now);
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
/**
|
70 |
+
* save menusetting relation
|
71 |
+
* @access public
|
72 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting
|
73 |
+
* @author Jason Lotzer
|
74 |
+
*/
|
75 |
+
protected function _afterSave() {
|
76 |
+
$this->getProductInstance()->saveMenusettingRelation($this);
|
77 |
+
$this->getMenuitemInstance()->saveMenusettingRelation($this);
|
78 |
+
return parent::_afterSave();
|
79 |
+
}
|
80 |
+
/**
|
81 |
+
* get product relation model
|
82 |
+
* @access public
|
83 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting_Product
|
84 |
+
* @author Jason Lotzer
|
85 |
+
*/
|
86 |
+
public function getProductInstance(){
|
87 |
+
if (!$this->_productInstance) {
|
88 |
+
$this->_productInstance = Mage::getSingleton('megamenu2/menusetting_product');
|
89 |
+
}
|
90 |
+
return $this->_productInstance;
|
91 |
+
}
|
92 |
+
/**
|
93 |
+
* get selected products array
|
94 |
+
* @access public
|
95 |
+
* @return array
|
96 |
+
* @author Jason Lotzer
|
97 |
+
*/
|
98 |
+
public function getSelectedProducts(){
|
99 |
+
if (!$this->hasSelectedProducts()) {
|
100 |
+
$products = array();
|
101 |
+
foreach ($this->getSelectedProductsCollection() as $product) {
|
102 |
+
$products[] = $product;
|
103 |
+
}
|
104 |
+
$this->setSelectedProducts($products);
|
105 |
+
}
|
106 |
+
return $this->getData('selected_products');
|
107 |
+
}
|
108 |
+
/**
|
109 |
+
* Retrieve collection selected products
|
110 |
+
* @access public
|
111 |
+
* @return JScriptz_MegaMenu2_Resource_Menusetting_Product_Collection
|
112 |
+
* @author Jason Lotzer
|
113 |
+
*/
|
114 |
+
public function getSelectedProductsCollection(){
|
115 |
+
$collection = $this->getProductInstance()->getProductCollection($this);
|
116 |
+
return $collection;
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* get menuitem relation model
|
120 |
+
* @access public
|
121 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting_Menuitem
|
122 |
+
* @author Jason Lotzer
|
123 |
+
*/
|
124 |
+
public function getMenuitemInstance(){
|
125 |
+
if (!$this->_menuitemInstance) {
|
126 |
+
$this->_menuitemInstance = Mage::getSingleton('megamenu2/menusetting_menuitem');
|
127 |
+
}
|
128 |
+
return $this->_menuitemInstance;
|
129 |
+
}
|
130 |
+
/**
|
131 |
+
* get selected menuitems array
|
132 |
+
* @access public
|
133 |
+
* @return array
|
134 |
+
* @author Jason Lotzer
|
135 |
+
*/
|
136 |
+
public function getSelectedMenuitems(){
|
137 |
+
if (!$this->hasSelectedMenuitems()) {
|
138 |
+
$menuitems = array();
|
139 |
+
foreach ($this->getSelectedMenuitemsCollection() as $menuitem) {
|
140 |
+
$menuitems[] = $menuitem;
|
141 |
+
}
|
142 |
+
$this->setSelectedMenuitems($menuitems);
|
143 |
+
}
|
144 |
+
return $this->getData('selected_menuitems');
|
145 |
+
}
|
146 |
+
/**
|
147 |
+
* Retrieve collection selected menuitems
|
148 |
+
* @access public
|
149 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting_Menuitem_Collection
|
150 |
+
* @author Jason Lotzer
|
151 |
+
*/
|
152 |
+
public function getSelectedMenuitemsCollection(){
|
153 |
+
$collection = $this->getMenuitemInstance()->getMenuitemsCollection($this);
|
154 |
+
return $collection;
|
155 |
+
}
|
156 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Menusetting/Menuitem.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting menu item model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Menusetting_Menuitem extends Mage_Core_Model_Abstract{
|
25 |
+
/**
|
26 |
+
* Initialize resource
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _construct(){
|
32 |
+
$this->_init('megamenu2/menusetting_menuitem');
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Save data for menusetting - menuitem relation
|
36 |
+
* @access public
|
37 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting $menusetting
|
38 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting_Menuitem
|
39 |
+
* @author Jason Lotzer
|
40 |
+
*/
|
41 |
+
public function saveMenusettingRelation($menusetting){
|
42 |
+
$data = $menusetting->getMenuitemsData();
|
43 |
+
if (!is_null($data)) {
|
44 |
+
$this->_getResource()->saveMenusettingRelation($menusetting, $data);
|
45 |
+
}
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* get menuitems for menusetting
|
50 |
+
* @access public
|
51 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting $menusetting
|
52 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Menuitem_Collection
|
53 |
+
* @author Jason Lotzer
|
54 |
+
*/
|
55 |
+
public function getMenuitemsCollection($menusetting){
|
56 |
+
$collection = Mage::getResourceModel('megamenu2/menusetting_menuitem_collection')
|
57 |
+
->addMenusettingFilter($menusetting);
|
58 |
+
return $collection;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Menusetting/Product.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting product model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Menusetting_Product extends Mage_Core_Model_Abstract{
|
25 |
+
/**
|
26 |
+
* Initialize resource
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _construct(){
|
32 |
+
$this->_init('megamenu2/menusetting_product');
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Save data for menusetting-product relation
|
36 |
+
* @access public
|
37 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting $menusetting
|
38 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting_Product
|
39 |
+
* @author Jason Lotzer
|
40 |
+
*/
|
41 |
+
public function saveMenusettingRelation($menusetting){
|
42 |
+
$data = $menusetting->getProductsData();
|
43 |
+
if (!is_null($data)) {
|
44 |
+
$this->_getResource()->saveMenusettingRelation($menusetting, $data);
|
45 |
+
}
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
/**
|
49 |
+
* get products for menusetting
|
50 |
+
* @access public
|
51 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting $menusetting
|
52 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Product_Collection
|
53 |
+
* @author Jason Lotzer
|
54 |
+
*/
|
55 |
+
public function getProductCollection($menusetting){
|
56 |
+
$collection = Mage::getResourceModel('megamenu2/menusetting_product_collection')
|
57 |
+
->addMenusettingFilter($menusetting);
|
58 |
+
return $collection;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem.php
CHANGED
@@ -1,552 +1,578 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item resource model
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
*
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
*
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
*
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
*
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
->
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
)
|
179 |
-
|
180 |
-
$this->_getWriteAdapter()->
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
*
|
242 |
-
* @
|
243 |
-
* @
|
244 |
-
* @
|
245 |
-
*/
|
246 |
-
public function
|
247 |
-
$select = $this->_getReadAdapter()->select()
|
248 |
-
->from($this->getMainTable(), '
|
249 |
-
->where('entity_id = :entity_id');
|
250 |
-
$bind =
|
251 |
-
return $this->_getReadAdapter()->fetchOne($select, $bind);
|
252 |
-
}
|
253 |
-
|
254 |
-
|
255 |
-
*
|
256 |
-
* @
|
257 |
-
* @
|
258 |
-
* @
|
259 |
-
*/
|
260 |
-
public function
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
$
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
*
|
272 |
-
*
|
273 |
-
* @
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
$
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
);
|
300 |
-
}
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
*
|
323 |
-
* @
|
324 |
-
* @
|
325 |
-
* @
|
326 |
-
*/
|
327 |
-
public function
|
328 |
-
$
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
->
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
*
|
340 |
-
* @
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
->
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
*
|
356 |
-
* @
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
$
|
363 |
-
|
364 |
-
->
|
365 |
-
->
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
*
|
374 |
-
* @
|
375 |
-
* @
|
376 |
-
* @
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
->
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
*
|
395 |
-
* @
|
396 |
-
* @param
|
397 |
-
* @
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
return
|
413 |
-
}
|
414 |
-
/**
|
415 |
-
*
|
416 |
-
* @access public
|
417 |
-
* @param
|
418 |
-
* @return
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
$
|
425 |
-
return $
|
426 |
-
}
|
427 |
-
/**
|
428 |
-
*
|
429 |
-
* @access public
|
430 |
-
* @param
|
431 |
-
* @
|
432 |
-
* @
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
$
|
446 |
-
$
|
447 |
-
|
448 |
-
|
449 |
-
);
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
$
|
462 |
-
$
|
463 |
-
$
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
);
|
487 |
-
$
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
$
|
507 |
-
'
|
508 |
-
|
509 |
-
|
510 |
-
'parent_id
|
511 |
-
|
512 |
-
);
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
)
|
537 |
-
$
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
->
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menuitem extends Mage_Core_Model_Resource_Db_Abstract{
|
25 |
+
/**
|
26 |
+
* Menu Item tree object
|
27 |
+
* @var Varien_Data_Tree_Db
|
28 |
+
*/
|
29 |
+
protected $_tree;
|
30 |
+
/**
|
31 |
+
* constructor
|
32 |
+
* @access public
|
33 |
+
* @return void
|
34 |
+
* @author Jason Lotzer
|
35 |
+
*/
|
36 |
+
public function _construct(){
|
37 |
+
$this->_init('megamenu2/menuitem', 'entity_id');
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get store ids to which specified item is assigned
|
42 |
+
* @access public
|
43 |
+
* @param int $menuitemId
|
44 |
+
* @return array
|
45 |
+
* @author Jason Lotzer
|
46 |
+
*/
|
47 |
+
public function lookupStoreIds($menuitemId){
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('megamenu2/menuitem_store'), 'store_id')
|
51 |
+
->where('menuitem_id = ?',(int)$menuitemId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
/**
|
55 |
+
* Perform operations after object load
|
56 |
+
* @access public
|
57 |
+
* @param Mage_Core_Model_Abstract $object
|
58 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
59 |
+
* @author Jason Lotzer
|
60 |
+
*/
|
61 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object){
|
62 |
+
if ($object->getId()) {
|
63 |
+
$stores = $this->lookupStoreIds($object->getId());
|
64 |
+
$object->setData('store_id', $stores);
|
65 |
+
}
|
66 |
+
return parent::_afterLoad($object);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Retrieve select object for load object data
|
71 |
+
*
|
72 |
+
* @param string $field
|
73 |
+
* @param mixed $value
|
74 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $object
|
75 |
+
* @return Zend_Db_Select
|
76 |
+
*/
|
77 |
+
protected function _getLoadSelect($field, $value, $object){
|
78 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
79 |
+
if ($object->getStoreId()) {
|
80 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
81 |
+
$select->join(
|
82 |
+
array('megamenu2_menuitem_store' => $this->getTable('megamenu2/menuitem_store')),
|
83 |
+
$this->getMainTable() . '.entity_id = megamenu2_menuitem_store.menuitem_id',
|
84 |
+
array()
|
85 |
+
)
|
86 |
+
->where('megamenu2_menuitem_store.store_id IN (?)', $storeIds)
|
87 |
+
->order('megamenu2_menuitem_store.store_id DESC')
|
88 |
+
->limit(1);
|
89 |
+
}
|
90 |
+
return $select;
|
91 |
+
}
|
92 |
+
/**
|
93 |
+
* Retrieve menu item tree object
|
94 |
+
* @access protected
|
95 |
+
* @return Varien_Data_Tree_Db
|
96 |
+
* @author Jason Lotzer
|
97 |
+
*/
|
98 |
+
protected function _getTree(){
|
99 |
+
if (!$this->_tree) {
|
100 |
+
$this->_tree = Mage::getResourceModel('megamenu2/menuitem_tree')->load();
|
101 |
+
}
|
102 |
+
return $this->_tree;
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* Process menu item data before delete
|
106 |
+
* update children count for parent menu item
|
107 |
+
* delete child menu items
|
108 |
+
* @access protected
|
109 |
+
* @param Varien_Object $object
|
110 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
111 |
+
* @author Jason Lotzer
|
112 |
+
*/
|
113 |
+
protected function _beforeDelete(Mage_Core_Model_Abstract $object){
|
114 |
+
parent::_beforeDelete($object);
|
115 |
+
/**
|
116 |
+
* Update children count for all parent menu items
|
117 |
+
*/
|
118 |
+
$parentIds = $object->getParentIds();
|
119 |
+
if ($parentIds) {
|
120 |
+
$childDecrease = $object->getChildrenCount() + 1; // +1 is itself
|
121 |
+
$data = array('children_count' => new Zend_Db_Expr('children_count - ' . $childDecrease));
|
122 |
+
$where = array('entity_id IN(?)' => $parentIds);
|
123 |
+
$this->_getWriteAdapter()->update( $this->getMainTable(), $data, $where);
|
124 |
+
}
|
125 |
+
$this->deleteChildren($object);
|
126 |
+
return $this;
|
127 |
+
}
|
128 |
+
/**
|
129 |
+
* Delete children menu items of specific menu item
|
130 |
+
* @access public
|
131 |
+
* @param Varien_Object $object
|
132 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
133 |
+
* @author Jason Lotzer
|
134 |
+
*/
|
135 |
+
public function deleteChildren(Varien_Object $object){
|
136 |
+
$adapter = $this->_getWriteAdapter();
|
137 |
+
$pathField = $adapter->quoteIdentifier('path');
|
138 |
+
$select = $adapter->select()
|
139 |
+
->from($this->getMainTable(), array('entity_id'))
|
140 |
+
->where($pathField . ' LIKE :c_path');
|
141 |
+
$childrenIds = $adapter->fetchCol($select, array('c_path' => $object->getPath() . '/%'));
|
142 |
+
if (!empty($childrenIds)) {
|
143 |
+
$adapter->delete(
|
144 |
+
$this->getMainTable(),
|
145 |
+
array('entity_id IN (?)' => $childrenIds)
|
146 |
+
);
|
147 |
+
}
|
148 |
+
/**
|
149 |
+
* Add deleted children ids to object
|
150 |
+
* This data can be used in after delete event
|
151 |
+
*/
|
152 |
+
$object->setDeletedChildrenIds($childrenIds);
|
153 |
+
return $this;
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* Process menu item data after save menu item object
|
157 |
+
* @access protected
|
158 |
+
* @param Varien_Object $object
|
159 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
160 |
+
* @author Jason Lotzer
|
161 |
+
*/
|
162 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object){
|
163 |
+
if (substr($object->getPath(), -1) == '/') {
|
164 |
+
$object->setPath($object->getPath() . $object->getId());
|
165 |
+
$this->_savePath($object);
|
166 |
+
}
|
167 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
168 |
+
$newStores = (array)$object->getStores();
|
169 |
+
if (empty($newStores)) {
|
170 |
+
$newStores = (array)$object->getStoreId();
|
171 |
+
}
|
172 |
+
$table = $this->getTable('megamenu2/menuitem_store');
|
173 |
+
$insert = array_diff($newStores, $oldStores);
|
174 |
+
$delete = array_diff($oldStores, $newStores);
|
175 |
+
if ($delete) {
|
176 |
+
$where = array(
|
177 |
+
'menuitem_id = ?' => (int) $object->getId(),
|
178 |
+
'store_id IN (?)' => $delete
|
179 |
+
);
|
180 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
181 |
+
}
|
182 |
+
if ($insert) {
|
183 |
+
$data = array();
|
184 |
+
foreach ($insert as $storeId) {
|
185 |
+
$data[] = array(
|
186 |
+
'menuitem_id' => (int) $object->getId(),
|
187 |
+
'store_id' => (int) $storeId
|
188 |
+
);
|
189 |
+
}
|
190 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
191 |
+
}
|
192 |
+
return parent::_afterSave($object);
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Update path field
|
197 |
+
* @access protected
|
198 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $object
|
199 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
200 |
+
* @author Jason Lotzer
|
201 |
+
*/
|
202 |
+
protected function _savePath($object){
|
203 |
+
if ($object->getId()) {
|
204 |
+
$this->_getWriteAdapter()->update(
|
205 |
+
$this->getMainTable(),
|
206 |
+
array('path' => $object->getPath()),
|
207 |
+
array('entity_id = ?' => $object->getId())
|
208 |
+
);
|
209 |
+
}
|
210 |
+
return $this;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Get maximum position of child menu items by specific tree path
|
215 |
+
* @access protected
|
216 |
+
* @param string $path
|
217 |
+
* @return int
|
218 |
+
* @author Jason Lotzer
|
219 |
+
*/
|
220 |
+
protected function _getMaxPosition($path){
|
221 |
+
$adapter = $this->getReadConnection();
|
222 |
+
$positionField = $adapter->quoteIdentifier('position');
|
223 |
+
$level = count(explode('/', $path));
|
224 |
+
$bind = array(
|
225 |
+
'c_level' => $level,
|
226 |
+
'c_path' => $path . '/%'
|
227 |
+
);
|
228 |
+
$select = $adapter->select()
|
229 |
+
->from($this->getMainTable(), 'MAX(' . $positionField . ')')
|
230 |
+
->where($adapter->quoteIdentifier('path') . ' LIKE :c_path')
|
231 |
+
->where($adapter->quoteIdentifier('level') . ' = :c_level');
|
232 |
+
|
233 |
+
$position = $adapter->fetchOne($select, $bind);
|
234 |
+
if (!$position) {
|
235 |
+
$position = 0;
|
236 |
+
}
|
237 |
+
return $position;
|
238 |
+
}
|
239 |
+
/**
|
240 |
+
* Get children menu items count
|
241 |
+
* @access public
|
242 |
+
* @param int $menuitemId
|
243 |
+
* @return int
|
244 |
+
* @author Jason Lotzer
|
245 |
+
*/
|
246 |
+
public function getChildrenCount($menuitemId){
|
247 |
+
$select = $this->_getReadAdapter()->select()
|
248 |
+
->from($this->getMainTable(), 'children_count')
|
249 |
+
->where('entity_id = :entity_id');
|
250 |
+
$bind = array('entity_id' => $menuitemId);
|
251 |
+
return $this->_getReadAdapter()->fetchOne($select, $bind);
|
252 |
+
}
|
253 |
+
/**
|
254 |
+
* Check if menu item id exist
|
255 |
+
* @access public
|
256 |
+
* @param int $entityId
|
257 |
+
* @return bool
|
258 |
+
* @author Jason Lotzer
|
259 |
+
*/
|
260 |
+
public function checkId($entityId){
|
261 |
+
$select = $this->_getReadAdapter()->select()
|
262 |
+
->from($this->getMainTable(), 'entity_id')
|
263 |
+
->where('entity_id = :entity_id');
|
264 |
+
$bind = array('entity_id' => $entityId);
|
265 |
+
return $this->_getReadAdapter()->fetchOne($select, $bind);
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Check array of menu items identifiers
|
270 |
+
* @access public
|
271 |
+
* @param array $ids
|
272 |
+
* @return array
|
273 |
+
* @author Jason Lotzer
|
274 |
+
*/
|
275 |
+
public function verifyIds(array $ids){
|
276 |
+
if (empty($ids)) {
|
277 |
+
return array();
|
278 |
+
}
|
279 |
+
$select = $this->_getReadAdapter()->select()
|
280 |
+
->from($this->getMainTable(), 'entity_id')
|
281 |
+
->where('entity_id IN(?)', $ids);
|
282 |
+
|
283 |
+
return $this->_getReadAdapter()->fetchCol($select);
|
284 |
+
}
|
285 |
+
/**
|
286 |
+
* Process menu item data before saving
|
287 |
+
* prepare path and increment children count for parent menu items
|
288 |
+
* @access protected
|
289 |
+
* @param Varien_Object $object
|
290 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
291 |
+
* @author Jason Lotzer
|
292 |
+
*/
|
293 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object){
|
294 |
+
parent::_beforeSave($object);
|
295 |
+
if (!$object->getChildrenCount()) {
|
296 |
+
$object->setChildrenCount(0);
|
297 |
+
}
|
298 |
+
if ($object->getLevel() === null) {
|
299 |
+
$object->setLevel(1);
|
300 |
+
}
|
301 |
+
if (!$object->getId() && !$object->getInitialSetupFlag()) {
|
302 |
+
$object->setPosition($this->_getMaxPosition($object->getPath()) + 1);
|
303 |
+
$path = explode('/', $object->getPath());
|
304 |
+
$level = count($path);
|
305 |
+
$object->setLevel($level);
|
306 |
+
if ($level) {
|
307 |
+
$object->setParentId($path[$level - 1]);
|
308 |
+
}
|
309 |
+
$object->setPath($object->getPath() . '/');
|
310 |
+
$toUpdateChild = explode('/',$object->getPath());
|
311 |
+
$this->_getWriteAdapter()->update(
|
312 |
+
$this->getMainTable(),
|
313 |
+
array('children_count' => new Zend_Db_Expr('children_count+1')),
|
314 |
+
array('entity_id IN(?)' => $toUpdateChild)
|
315 |
+
);
|
316 |
+
}
|
317 |
+
return $this;
|
318 |
+
}
|
319 |
+
/**
|
320 |
+
* Get count of active/not active children menu items
|
321 |
+
*
|
322 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
323 |
+
* @param bool $isActiveFlag
|
324 |
+
* @return int
|
325 |
+
* @author Jason Lotzer
|
326 |
+
*/
|
327 |
+
public function getChildrenAmount($menuitem, $isActiveFlag = true){
|
328 |
+
$bind = array(
|
329 |
+
'active_flag' => $isActiveFlag,
|
330 |
+
'c_path' => $menuitem->getPath() . '/%'
|
331 |
+
);
|
332 |
+
$select = $adapter->select()
|
333 |
+
->from(array('m' => $this->getMainTable()), array('COUNT(m.entity_id)'))
|
334 |
+
->where('m.path LIKE :c_path')
|
335 |
+
->where('status' . ' = :active_flag');
|
336 |
+
return $this->_getReadAdapter()->fetchOne($select, $bind);
|
337 |
+
}
|
338 |
+
/**
|
339 |
+
* Return parent menu items of menu item
|
340 |
+
* @access public
|
341 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
342 |
+
* @return array
|
343 |
+
* @author Jason Lotzer
|
344 |
+
*/
|
345 |
+
public function getParentMenuitems($menuitem){
|
346 |
+
$pathIds = array_reverse(explode('/', $menuitem->getPath()));
|
347 |
+
$menuitems = Mage::getResourceModel('megamenu2/menuitem_collection')
|
348 |
+
->addFieldToFilter('entity_id', array('in' => $pathIds))
|
349 |
+
->addFieldToFilter('status', 1)
|
350 |
+
->load()
|
351 |
+
->getItems();
|
352 |
+
return $menuitems;
|
353 |
+
}
|
354 |
+
/**
|
355 |
+
* Return child menu items
|
356 |
+
* @access public
|
357 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
358 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
359 |
+
* @author Jason Lotzer
|
360 |
+
*/
|
361 |
+
public function getChildrenMenuitems($menuitem){
|
362 |
+
$collection = $menuitem->getCollection();
|
363 |
+
$collection
|
364 |
+
->addFilter('status', 1)
|
365 |
+
->addIdFilter($menuitem->getChildren())
|
366 |
+
->setOrder('position', Varien_Db_Select::SQL_ASC)
|
367 |
+
->load();
|
368 |
+
return $collection;
|
369 |
+
}
|
370 |
+
/**
|
371 |
+
* Return children ids of menu item
|
372 |
+
* @access public
|
373 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
374 |
+
* @param boolean $recursive
|
375 |
+
* @return array
|
376 |
+
* @author Jason Lotzer
|
377 |
+
*/
|
378 |
+
public function getChildren($menuitem, $recursive = true){
|
379 |
+
$bind = array(
|
380 |
+
'c_path' => $menuitem->getPath() . '/%'
|
381 |
+
);
|
382 |
+
$select = $this->_getReadAdapter()->select()
|
383 |
+
->from(array('m' => $this->getMainTable()), 'entity_id')
|
384 |
+
->where('status = ?', 1)
|
385 |
+
->where($this->_getReadAdapter()->quoteIdentifier('path') . ' LIKE :c_path');
|
386 |
+
if (!$recursive) {
|
387 |
+
$select->where($this->_getReadAdapter()->quoteIdentifier('level') . ' <= :c_level');
|
388 |
+
$bind['c_level'] = $menuitem->getLevel() + 1;
|
389 |
+
}
|
390 |
+
return $this->_getReadAdapter()->fetchCol($select, $bind);
|
391 |
+
}
|
392 |
+
/**
|
393 |
+
* Retrieve menu items
|
394 |
+
* @access public
|
395 |
+
* @param integer $parent
|
396 |
+
* @param integer $recursionLevel
|
397 |
+
* @param boolean|string $sorted
|
398 |
+
* @param boolean $asCollection
|
399 |
+
* @param boolean $toLoad
|
400 |
+
* @return Varien_Data_Tree_Node_Collection|JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
401 |
+
* @author Jason Lotzer
|
402 |
+
*/
|
403 |
+
public function getMenuitems($parent, $recursionLevel = 0, $sorted = false, $asCollection = false, $toLoad = true){
|
404 |
+
$tree = Mage::getResourceModel('megamenu2/menuitem_tree');
|
405 |
+
$nodes = $tree->loadNode($parent)
|
406 |
+
->loadChildren($recursionLevel)
|
407 |
+
->getChildren();
|
408 |
+
$tree->addCollectionData(null, $sorted, $parent, $toLoad, true);
|
409 |
+
if ($asCollection) {
|
410 |
+
return $tree->getCollection();
|
411 |
+
}
|
412 |
+
return $nodes;
|
413 |
+
}
|
414 |
+
/**
|
415 |
+
* Return all children ids of menuitem (with menuitem id)
|
416 |
+
* @access public
|
417 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
418 |
+
* @return array
|
419 |
+
* @author Jason Lotzer
|
420 |
+
*/
|
421 |
+
public function getAllChildren($menuitem){
|
422 |
+
$children = $this->getChildren($menuitem);
|
423 |
+
$myId = array($menuitem->getId());
|
424 |
+
$children = array_merge($myId, $children);
|
425 |
+
return $children;
|
426 |
+
}
|
427 |
+
/**
|
428 |
+
* Check menu item is forbidden to delete.
|
429 |
+
* @access public
|
430 |
+
* @param integer $menuitemId
|
431 |
+
* @return boolean
|
432 |
+
* @author Jason Lotzer
|
433 |
+
*/
|
434 |
+
public function isForbiddenToDelete($menuitemId){
|
435 |
+
return ($menuitemId == Mage::helper('megamenu2/menuitem')->getRootMenuitemId());
|
436 |
+
}
|
437 |
+
/**
|
438 |
+
* Get menu item path value by its id
|
439 |
+
* @access public
|
440 |
+
* @param int $menuitemId
|
441 |
+
* @return string
|
442 |
+
* @author Jason Lotzer
|
443 |
+
*/
|
444 |
+
public function getMenuitemPathById($menuitemId){
|
445 |
+
$select = $this->getReadConnection()->select()
|
446 |
+
->from($this->getMainTable(), array('path'))
|
447 |
+
->where('entity_id = :entity_id');
|
448 |
+
$bind = array('entity_id' => (int)$menuitemId);
|
449 |
+
return $this->getReadConnection()->fetchOne($select, $bind);
|
450 |
+
}
|
451 |
+
/**
|
452 |
+
* Move menu item to another parent node
|
453 |
+
* @access public
|
454 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
455 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $newParent
|
456 |
+
* @param null|int $afterMenuitemId
|
457 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem
|
458 |
+
* @author Jason Lotzer
|
459 |
+
*/
|
460 |
+
public function changeParent(JScriptz_MegaMenu2_Model_Menuitem $menuitem, JScriptz_MegaMenu2_Model_Menuitem $newParent, $afterMenuitemId = null){
|
461 |
+
$childrenCount = $this->getChildrenCount($menuitem->getId()) + 1;
|
462 |
+
$table = $this->getMainTable();
|
463 |
+
$adapter = $this->_getWriteAdapter();
|
464 |
+
$levelFiled = $adapter->quoteIdentifier('level');
|
465 |
+
$pathField = $adapter->quoteIdentifier('path');
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Decrease children count for all old menu item parent menu items
|
469 |
+
*/
|
470 |
+
$adapter->update(
|
471 |
+
$table,
|
472 |
+
array('children_count' => new Zend_Db_Expr('children_count - ' . $childrenCount)),
|
473 |
+
array('entity_id IN(?)' => $menuitem->getParentIds())
|
474 |
+
);
|
475 |
+
/**
|
476 |
+
* Increase children count for new menu item parents
|
477 |
+
*/
|
478 |
+
$adapter->update(
|
479 |
+
$table,
|
480 |
+
array('children_count' => new Zend_Db_Expr('children_count + ' . $childrenCount)),
|
481 |
+
array('entity_id IN(?)' => $newParent->getPathIds())
|
482 |
+
);
|
483 |
+
|
484 |
+
$position = $this->_processPositions($menuitem, $newParent, $afterMenuitemId);
|
485 |
+
|
486 |
+
$newPath = sprintf('%s/%s', $newParent->getPath(), $menuitem->getId());
|
487 |
+
$newLevel = $newParent->getLevel() + 1;
|
488 |
+
$levelDisposition = $newLevel - $menuitem->getLevel();
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Update children nodes path
|
492 |
+
*/
|
493 |
+
$adapter->update(
|
494 |
+
$table,
|
495 |
+
array(
|
496 |
+
'path' => new Zend_Db_Expr('REPLACE(' . $pathField . ','.
|
497 |
+
$adapter->quote($menuitem->getPath() . '/'). ', '.$adapter->quote($newPath . '/').')'
|
498 |
+
),
|
499 |
+
'level' => new Zend_Db_Expr( $levelFiled . ' + ' . $levelDisposition)
|
500 |
+
),
|
501 |
+
array($pathField . ' LIKE ?' => $menuitem->getPath() . '/%')
|
502 |
+
);
|
503 |
+
/**
|
504 |
+
* Update moved menu item data
|
505 |
+
*/
|
506 |
+
$data = array(
|
507 |
+
'path' => $newPath,
|
508 |
+
'level' => $newLevel,
|
509 |
+
'position' =>$position,
|
510 |
+
'parent_id' =>$newParent->getId()
|
511 |
+
);
|
512 |
+
$adapter->update($table, $data, array('entity_id = ?' => $menuitem->getId()));
|
513 |
+
// Update menu item object to new data
|
514 |
+
$menuitem->addData($data);
|
515 |
+
return $this;
|
516 |
+
}
|
517 |
+
/**
|
518 |
+
* Process positions of old parent menu item children and new parent menu item children.
|
519 |
+
* Get position for moved menu item
|
520 |
+
* @access protected
|
521 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
522 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $newParent
|
523 |
+
* @param null|int $afterMenuitemId
|
524 |
+
* @return int
|
525 |
+
* @author Jason Lotzer
|
526 |
+
*/
|
527 |
+
protected function _processPositions($menuitem, $newParent, $afterMenuitemId){
|
528 |
+
$table = $this->getMainTable();
|
529 |
+
$adapter= $this->_getWriteAdapter();
|
530 |
+
$positionField = $adapter->quoteIdentifier('position');
|
531 |
+
|
532 |
+
$bind = array(
|
533 |
+
'position' => new Zend_Db_Expr($positionField . ' - 1')
|
534 |
+
);
|
535 |
+
$where = array(
|
536 |
+
'parent_id = ?' => $menuitem->getParentId(),
|
537 |
+
$positionField . ' > ?' => $menuitem->getPosition()
|
538 |
+
);
|
539 |
+
$adapter->update($table, $bind, $where);
|
540 |
+
|
541 |
+
/**
|
542 |
+
* Prepare position value
|
543 |
+
*/
|
544 |
+
if ($afterMenuitemId) {
|
545 |
+
$select = $adapter->select()
|
546 |
+
->from($table,'position')
|
547 |
+
->where('entity_id = :entity_id');
|
548 |
+
$position = $adapter->fetchOne($select, array('entity_id' => $afterMenuitemId));
|
549 |
+
$bind = array(
|
550 |
+
'position' => new Zend_Db_Expr($positionField . ' + 1')
|
551 |
+
);
|
552 |
+
$where = array(
|
553 |
+
'parent_id = ?' => $newParent->getId(),
|
554 |
+
$positionField . ' > ?' => $position
|
555 |
+
);
|
556 |
+
$adapter->update($table, $bind, $where);
|
557 |
+
}
|
558 |
+
elseif ($afterMenuitemId !== null) {
|
559 |
+
$position = 0;
|
560 |
+
$bind = array(
|
561 |
+
'position' => new Zend_Db_Expr($positionField . ' + 1')
|
562 |
+
);
|
563 |
+
$where = array(
|
564 |
+
'parent_id = ?' => $newParent->getId(),
|
565 |
+
$positionField . ' > ?' => $position
|
566 |
+
);
|
567 |
+
$adapter->update($table, $bind, $where);
|
568 |
+
}
|
569 |
+
else {
|
570 |
+
$select = $adapter->select()
|
571 |
+
->from($table,array('position' => new Zend_Db_Expr('MIN(' . $positionField. ')')))
|
572 |
+
->where('parent_id = :parent_id');
|
573 |
+
$position = $adapter->fetchOne($select, array('parent_id' => $newParent->getId()));
|
574 |
+
}
|
575 |
+
$position += 1;
|
576 |
+
return $position;
|
577 |
+
}
|
578 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Collection.php
CHANGED
@@ -1,206 +1,264 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item collection resource model
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
*
|
28 |
-
* @
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
*
|
39 |
-
* @
|
40 |
-
* @param
|
41 |
-
* @
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
*
|
51 |
-
* @
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
*
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
*
|
152 |
-
* @
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
return $this;
|
179 |
-
}
|
180 |
-
/**
|
181 |
-
* Add
|
182 |
-
* @access public
|
183 |
-
* @
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
*
|
193 |
-
* @
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
|
25 |
+
protected $_joinedFields = array();
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
* @access public
|
29 |
+
* @return void
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
public function _construct(){
|
33 |
+
parent::_construct();
|
34 |
+
$this->_init('megamenu2/menuitem');
|
35 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
36 |
+
}
|
37 |
+
/**
|
38 |
+
* get menuitems as array
|
39 |
+
* @access protected
|
40 |
+
* @param string $valueField
|
41 |
+
* @param string $labelField
|
42 |
+
* @param array $additional
|
43 |
+
* @return array
|
44 |
+
* @author Jason Lotzer
|
45 |
+
*/
|
46 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='linktitle', $additional=array()){
|
47 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* get options hash
|
51 |
+
* @access protected
|
52 |
+
* @param string $valueField
|
53 |
+
* @param string $labelField
|
54 |
+
* @return array
|
55 |
+
* @author Jason Lotzer
|
56 |
+
*/
|
57 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='linktitle'){
|
58 |
+
return parent::_toOptionHash($valueField, $labelField);
|
59 |
+
}
|
60 |
+
/**
|
61 |
+
* Add filter by store
|
62 |
+
* @access public
|
63 |
+
* @param int|Mage_Core_Model_Store $store
|
64 |
+
* @param bool $withAdmin
|
65 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
66 |
+
* @author Jason Lotzer
|
67 |
+
*/
|
68 |
+
public function addStoreFilter($store, $withAdmin = true){
|
69 |
+
if (!isset($this->_joinedFields['store'])){
|
70 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
71 |
+
$store = array($store->getId());
|
72 |
+
}
|
73 |
+
if (!is_array($store)) {
|
74 |
+
$store = array($store);
|
75 |
+
}
|
76 |
+
if ($withAdmin) {
|
77 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
78 |
+
}
|
79 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
80 |
+
$this->_joinedFields['store'] = true;
|
81 |
+
}
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* Join store relation table if there is store filter
|
86 |
+
* @access protected
|
87 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
88 |
+
* @author Jason Lotzer
|
89 |
+
*/
|
90 |
+
protected function _renderFiltersBefore(){
|
91 |
+
if ($this->getFilter('store')) {
|
92 |
+
$this->getSelect()->join(
|
93 |
+
array('store_table' => $this->getTable('megamenu2/menuitem_store')),
|
94 |
+
'main_table.entity_id = store_table.menuitem_id',
|
95 |
+
array()
|
96 |
+
)->group('main_table.entity_id');
|
97 |
+
/*
|
98 |
+
* Allow analytic functions usage because of one field grouping
|
99 |
+
*/
|
100 |
+
$this->_useAnalyticFunction = true;
|
101 |
+
}
|
102 |
+
return parent::_renderFiltersBefore();
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* Get SQL for get record count.
|
106 |
+
* Extra GROUP BY strip added.
|
107 |
+
* @access public
|
108 |
+
* @return Varien_Db_Select
|
109 |
+
* @author Jason Lotzer
|
110 |
+
*/
|
111 |
+
public function getSelectCountSql(){
|
112 |
+
$countSelect = parent::getSelectCountSql();
|
113 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
114 |
+
return $countSelect;
|
115 |
+
}
|
116 |
+
/**
|
117 |
+
* Add Id filter
|
118 |
+
* @access public
|
119 |
+
* @param array $menuitemIds
|
120 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
121 |
+
* @author Jason Lotzer
|
122 |
+
*/
|
123 |
+
public function addIdFilter($menuitemIds){
|
124 |
+
if (is_array($menuitemIds)) {
|
125 |
+
if (empty($menuitemIds)) {
|
126 |
+
$condition = '';
|
127 |
+
}
|
128 |
+
else {
|
129 |
+
$condition = array('in' => $menuitemIds);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
elseif (is_numeric($menuitemIds)) {
|
133 |
+
$condition = $menuitemIds;
|
134 |
+
}
|
135 |
+
elseif (is_string($menuitemIds)) {
|
136 |
+
$ids = explode(',', $menuitemIds);
|
137 |
+
if (empty($ids)) {
|
138 |
+
$condition = $menuitemIds;
|
139 |
+
}
|
140 |
+
else {
|
141 |
+
$condition = array('in' => $ids);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
$this->addFieldToFilter('entity_id', $condition);
|
145 |
+
return $this;
|
146 |
+
}
|
147 |
+
/**
|
148 |
+
* Add menu item path filter
|
149 |
+
* @access public
|
150 |
+
* @param string $regexp
|
151 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
152 |
+
* @author Jason Lotzer
|
153 |
+
*/
|
154 |
+
public function addPathFilter($regexp){
|
155 |
+
$this->addFieldToFilter('path', array('regexp' => $regexp));
|
156 |
+
return $this;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Add menu item path filter
|
161 |
+
* @access public
|
162 |
+
* @param array|string $paths
|
163 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
164 |
+
* @author Jason Lotzer
|
165 |
+
*/
|
166 |
+
public function addPathsFilter($paths){
|
167 |
+
if (!is_array($paths)) {
|
168 |
+
$paths = array($paths);
|
169 |
+
}
|
170 |
+
$write = $this->getResource()->getWriteConnection();
|
171 |
+
$cond = array();
|
172 |
+
foreach ($paths as $path) {
|
173 |
+
$cond[] = $write->quoteInto('e.path LIKE ?', "$path%");
|
174 |
+
}
|
175 |
+
if ($cond) {
|
176 |
+
$this->getSelect()->where(join(' OR ', $cond));
|
177 |
+
}
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
/**
|
181 |
+
* Add menu item level filter
|
182 |
+
* @access public
|
183 |
+
* @param int|string $level
|
184 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
185 |
+
* @author Jason Lotzer
|
186 |
+
*/
|
187 |
+
public function addLevelFilter($level){
|
188 |
+
$this->addFieldToFilter('level', array('lteq' => $level));
|
189 |
+
return $this;
|
190 |
+
}
|
191 |
+
/**
|
192 |
+
* Add root menu item filter
|
193 |
+
* @access public
|
194 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
195 |
+
*/
|
196 |
+
public function addRootLevelFilter(){
|
197 |
+
$this->addFieldToFilter('path', array('neq' => '1'));
|
198 |
+
$this->addLevelFilter(1);
|
199 |
+
return $this;
|
200 |
+
}
|
201 |
+
/**
|
202 |
+
* Add order field
|
203 |
+
* @access public
|
204 |
+
* @param string $field
|
205 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
206 |
+
*/
|
207 |
+
public function addOrderField($field){
|
208 |
+
$this->setOrder($field, self::SORT_ORDER_ASC);
|
209 |
+
return $this;
|
210 |
+
}
|
211 |
+
/**
|
212 |
+
* Add active menu item filter
|
213 |
+
* @access public
|
214 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
215 |
+
*/
|
216 |
+
public function addStatusFilter(){
|
217 |
+
$this->addFieldToFilter('status', 1);
|
218 |
+
return $this;
|
219 |
+
}
|
220 |
+
/**
|
221 |
+
* add the product filter to collection
|
222 |
+
* @access public
|
223 |
+
* @param mixed (Mage_Catalog_Model_Product|int) $product
|
224 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
225 |
+
* @author Jason Lotzer
|
226 |
+
*/
|
227 |
+
public function addProductFilter($product){
|
228 |
+
if ($product instanceof Mage_Catalog_Model_Product){
|
229 |
+
$product = $product->getId();
|
230 |
+
}
|
231 |
+
if (!isset($this->_joinedFields['product'])){
|
232 |
+
$this->getSelect()->join(
|
233 |
+
array('related_product' => $this->getTable('megamenu2/menuitem_product')),
|
234 |
+
'related_product.menuitem_id = main_table.entity_id',
|
235 |
+
array('position')
|
236 |
+
);
|
237 |
+
$this->getSelect()->where('related_product.product_id = ?', $product);
|
238 |
+
$this->_joinedFields['product'] = true;
|
239 |
+
}
|
240 |
+
return $this;
|
241 |
+
}
|
242 |
+
/**
|
243 |
+
* add the menusetting filter to collection
|
244 |
+
* @access public
|
245 |
+
* @param mixed (JScriptz_MegaMenu2_Model_Menusetting|int) $menusetting
|
246 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
247 |
+
* @author Jason Lotzer
|
248 |
+
*/
|
249 |
+
public function addMenusettingFilter($menusetting){
|
250 |
+
if ($menusetting instanceof JScriptz_MegaMenu2_Model_Menusetting){
|
251 |
+
$menusetting = $menusetting->getId();
|
252 |
+
}
|
253 |
+
if (!isset($this->_joinedFields['menusetting'])){
|
254 |
+
$this->getSelect()->join(
|
255 |
+
array('related_menusetting' => $this->getTable('megamenu2/menuitem_menusetting')),
|
256 |
+
'related_menusetting.menuitem_id = main_table.entity_id',
|
257 |
+
array('position')
|
258 |
+
);
|
259 |
+
$this->getSelect()->where('related_menusetting.menusetting_id = ?', $menusetting);
|
260 |
+
$this->_joinedFields['menusetting'] = true;
|
261 |
+
}
|
262 |
+
return $this;
|
263 |
+
}
|
264 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Menusetting.php
ADDED
@@ -0,0 +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 |
+
* Menu Item - Menu Setting relation model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menuitem_Menusetting extends Mage_Core_Model_Resource_Db_Abstract{
|
25 |
+
/**
|
26 |
+
* initialize resource model
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @see Mage_Core_Model_Resource_Abstract::_construct()
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
protected function _construct(){
|
33 |
+
$this->_init('megamenu2/menuitem_menusetting', 'rel_id');
|
34 |
+
}
|
35 |
+
/**
|
36 |
+
* Save menuitem - menusetting relations
|
37 |
+
* @access public
|
38 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
39 |
+
* @param array $data
|
40 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Menusetting
|
41 |
+
* @author Jason Lotzer
|
42 |
+
*/
|
43 |
+
public function saveMenuitemRelation($menuitem, $data){
|
44 |
+
if (!is_array($data)) {
|
45 |
+
$data = array();
|
46 |
+
}
|
47 |
+
$deleteCondition = $this->_getWriteAdapter()->quoteInto('menuitem_id=?', $menuitem->getId());
|
48 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
|
49 |
+
|
50 |
+
foreach ($data as $menusettingId => $info) {
|
51 |
+
$this->_getWriteAdapter()->insert($this->getMainTable(), array(
|
52 |
+
'menuitem_id' => $menuitem->getId(),
|
53 |
+
'menusetting_id' => $menusettingId,
|
54 |
+
'position' => @$info['position']
|
55 |
+
));
|
56 |
+
}
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Menusetting/Collection.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - Menu Setting relation resource model collection
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menuitem_Menusetting_Collection extends JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection{
|
25 |
+
/**
|
26 |
+
* remember if fields have been joined
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
protected $_joinedFields = false;
|
30 |
+
/**
|
31 |
+
* join the link table
|
32 |
+
* @access public
|
33 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Menusetting_Collection
|
34 |
+
* @author Jason Lotzer
|
35 |
+
*/
|
36 |
+
public function joinFields(){
|
37 |
+
if (!$this->_joinedFields){
|
38 |
+
$this->getSelect()->join(
|
39 |
+
array('related' => $this->getTable('megamenu2/menuitem_menusetting')),
|
40 |
+
'related.menusetting_id = main_table.entity_id',
|
41 |
+
array('position')
|
42 |
+
);
|
43 |
+
$this->_joinedFields = true;
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* add menuitem filter
|
49 |
+
* @access public
|
50 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem | int $menuitem
|
51 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Menusetting_Collection
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function addMenuitemFilter($menuitem){
|
55 |
+
if ($menuitem instanceof JScriptz_MegaMenu2_Model_Menuitem){
|
56 |
+
$menuitem = $menuitem->getId();
|
57 |
+
}
|
58 |
+
if (!$this->_joinedFields){
|
59 |
+
$this->joinFields();
|
60 |
+
}
|
61 |
+
$this->getSelect()->where('related.menuitem_id = ?', $menuitem);
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Product.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - product relation model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
|
25 |
+
class JScriptz_MegaMenu2_Model_Resource_Menuitem_Product extends Mage_Core_Model_Resource_Db_Abstract{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* initialize resource model
|
29 |
+
* @access protected
|
30 |
+
* @return void
|
31 |
+
* @see Mage_Core_Model_Resource_Abstract::_construct()
|
32 |
+
* @author Jason Lotzer
|
33 |
+
*/
|
34 |
+
protected function _construct(){
|
35 |
+
$this->_init('megamenu2/menuitem_product', 'rel_id');
|
36 |
+
}
|
37 |
+
/**
|
38 |
+
* Save menu item - product relations
|
39 |
+
* @access public
|
40 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem $menuitem
|
41 |
+
* @param array $data
|
42 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Product
|
43 |
+
* @author Jason Lotzer
|
44 |
+
*/
|
45 |
+
public function saveMenuitemRelation($menuitem, $data){
|
46 |
+
if (!is_array($data)) {
|
47 |
+
$data = array();
|
48 |
+
}
|
49 |
+
$deleteCondition = $this->_getWriteAdapter()->quoteInto('menuitem_id=?', $menuitem->getId());
|
50 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
|
51 |
+
|
52 |
+
foreach ($data as $productId => $info) {
|
53 |
+
$this->_getWriteAdapter()->insert($this->getMainTable(), array(
|
54 |
+
'menuitem_id' => $menuitem->getId(),
|
55 |
+
'product_id' => $productId,
|
56 |
+
'position' => @$info['position']
|
57 |
+
));
|
58 |
+
}
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
/**
|
62 |
+
* Save product - menu item relations
|
63 |
+
* @access public
|
64 |
+
* @param Mage_Catalog_Model_Product $prooduct
|
65 |
+
* @param array $data
|
66 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Product
|
67 |
+
* @author Jason Lotzer
|
68 |
+
*/
|
69 |
+
public function saveProductRelation($product, $menuitemIds){
|
70 |
+
|
71 |
+
$oldMenuitems = Mage::helper('megamenu2/product')->getSelectedMenuitems($product);
|
72 |
+
$oldMenuitemIds = array();
|
73 |
+
foreach ($oldMenuitems as $menuitem){
|
74 |
+
$oldMenuitemIds[] = $menuitem->getId();
|
75 |
+
}
|
76 |
+
$insert = array_diff($menuitemIds, $oldMenuitemIds);
|
77 |
+
$delete = array_diff($oldMenuitemIds, $menuitemIds);
|
78 |
+
$write = $this->_getWriteAdapter();
|
79 |
+
if (!empty($insert)) {
|
80 |
+
$data = array();
|
81 |
+
foreach ($insert as $menuitemId) {
|
82 |
+
if (empty($menuitemId)) {
|
83 |
+
continue;
|
84 |
+
}
|
85 |
+
$data[] = array(
|
86 |
+
'menuitem_id' => (int)$menuitemId,
|
87 |
+
'product_id' => (int)$product->getId(),
|
88 |
+
'position'=> 1
|
89 |
+
);
|
90 |
+
}
|
91 |
+
if ($data) {
|
92 |
+
$write->insertMultiple($this->getMainTable(), $data);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
if (!empty($delete)) {
|
96 |
+
foreach ($delete as $menuitemId) {
|
97 |
+
$where = array(
|
98 |
+
'product_id = ?' => (int)$product->getId(),
|
99 |
+
'menuitem_id = ?' => (int)$menuitemId,
|
100 |
+
);
|
101 |
+
$write->delete($this->getMainTable(), $where);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
return $this;
|
105 |
+
}
|
106 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Product/Collection.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - product relation resource model collection
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menuitem_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection{
|
25 |
+
/**
|
26 |
+
* remember if fields have been joined
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
protected $_joinedFields = false;
|
30 |
+
/**
|
31 |
+
* join the link table
|
32 |
+
* @access public
|
33 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Product_Collection
|
34 |
+
* @author Jason Lotzer
|
35 |
+
*/
|
36 |
+
public function joinFields(){
|
37 |
+
if (!$this->_joinedFields){
|
38 |
+
$this->getSelect()->join(
|
39 |
+
array('related' => $this->getTable('megamenu2/menuitem_product')),
|
40 |
+
'related.product_id = e.entity_id',
|
41 |
+
array('position')
|
42 |
+
);
|
43 |
+
$this->_joinedFields = true;
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* add menuitem filter
|
49 |
+
* @access public
|
50 |
+
* @param JScriptz_MegaMenu2_Model_Menuitem | int $menuitem
|
51 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Product_Collection
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function addMenuitemFilter($menuitem){
|
55 |
+
if ($menuitem instanceof JScriptz_MegaMenu2_Model_Menuitem){
|
56 |
+
$menuitem = $menuitem->getId();
|
57 |
+
}
|
58 |
+
if (!$this->_joinedFields){
|
59 |
+
$this->joinFields();
|
60 |
+
}
|
61 |
+
$this->getSelect()->where('related.menuitem_id = ?', $menuitem);
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menuitem/Tree.php
CHANGED
@@ -1,389 +1,408 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item tree resource model
|
19 |
-
* @category JScriptz
|
20 |
-
* @package
|
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 |
-
|
32 |
-
|
33 |
-
|
34 |
-
*
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
*
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
Varien_Data_Tree_Dbp::
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
*
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
*
|
122 |
-
* @
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
$
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
foreach ($
|
150 |
-
$
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
$
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
$
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
$
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
return $this;
|
312 |
-
}
|
313 |
-
/**
|
314 |
-
|
315 |
-
* @access
|
316 |
-
* @
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
)
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
*
|
379 |
-
* @
|
380 |
-
* @
|
381 |
-
* @
|
382 |
-
*/
|
383 |
-
protected function
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
*/
|
32 |
+
protected $_collection;
|
33 |
+
/**
|
34 |
+
* Inactive menu items ids
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
protected $_inactiveMenuitemIds = null;
|
38 |
+
/**
|
39 |
+
* Initialize tree
|
40 |
+
* @access public
|
41 |
+
* @return void
|
42 |
+
* @author Jason Lotzer
|
43 |
+
*/
|
44 |
+
public function __construct(){
|
45 |
+
$resource = Mage::getSingleton('core/resource');
|
46 |
+
parent::__construct(
|
47 |
+
$resource->getConnection('megamenu2_write'),
|
48 |
+
$resource->getTableName('megamenu2/menuitem'),
|
49 |
+
array(
|
50 |
+
Varien_Data_Tree_Dbp::ID_FIELD => 'entity_id',
|
51 |
+
Varien_Data_Tree_Dbp::PATH_FIELD => 'path',
|
52 |
+
Varien_Data_Tree_Dbp::ORDER_FIELD=> 'position',
|
53 |
+
Varien_Data_Tree_Dbp::LEVEL_FIELD=> 'level',
|
54 |
+
)
|
55 |
+
);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Get menu items collection
|
60 |
+
* @access public
|
61 |
+
* @param boolean $sorted
|
62 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
63 |
+
* @author Jason Lotzer
|
64 |
+
*/
|
65 |
+
public function getCollection($sorted = false){
|
66 |
+
if (is_null($this->_collection)) {
|
67 |
+
$this->_collection = $this->_getDefaultCollection($sorted);
|
68 |
+
}
|
69 |
+
return $this->_collection;
|
70 |
+
}
|
71 |
+
/**
|
72 |
+
* set the collection
|
73 |
+
* @access public
|
74 |
+
* @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
|
75 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
76 |
+
*/
|
77 |
+
public function setCollection($collection){
|
78 |
+
if (!is_null($this->_collection)) {
|
79 |
+
destruct($this->_collection);
|
80 |
+
}
|
81 |
+
$this->_collection = $collection;
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* get the default collection
|
86 |
+
* @access protected
|
87 |
+
* @param boolean $sorted
|
88 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection
|
89 |
+
*/
|
90 |
+
protected function _getDefaultCollection($sorted = false){
|
91 |
+
$collection = Mage::getModel('megamenu2/menuitem')->getCollection();
|
92 |
+
if ($sorted) {
|
93 |
+
if (is_string($sorted)) {
|
94 |
+
$collection->setOrder($sorted);
|
95 |
+
}
|
96 |
+
else {
|
97 |
+
$collection->setOrder('name');
|
98 |
+
}
|
99 |
+
}
|
100 |
+
return $collection;
|
101 |
+
}
|
102 |
+
/**
|
103 |
+
* Executing parents move method and cleaning cache after it
|
104 |
+
* @access public
|
105 |
+
* @param unknown_type $menuitem
|
106 |
+
* @param unknown_type $newParent
|
107 |
+
* @param unknown_type $prevNode
|
108 |
+
* @author Jason Lotzer
|
109 |
+
*/
|
110 |
+
public function move($menuitem, $newParent, $prevNode = null){
|
111 |
+
Mage::getResourceSingleton('megamenu2/menuitem')->move($menuitem->getId(), $newParent->getId());
|
112 |
+
parent::move($menuitem, $newParent, $prevNode);
|
113 |
+
$this->_afterMove($menuitem, $newParent, $prevNode);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Move tree after
|
118 |
+
* @access protected
|
119 |
+
* @param unknown_type $menuitem
|
120 |
+
* @param Varien_Data_Tree_Node $newParent
|
121 |
+
* @param Varien_Data_Tree_Node $prevNode
|
122 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
123 |
+
*/
|
124 |
+
protected function _afterMove($menuitem, $newParent, $prevNode){
|
125 |
+
Mage::app()->cleanCache(array(JScriptz_MegaMenu2_Model_Menuitem::CACHE_TAG));
|
126 |
+
return $this;
|
127 |
+
}
|
128 |
+
/**
|
129 |
+
* Load whole menu item tree, that will include specified menu items ids.
|
130 |
+
* @access public
|
131 |
+
* @param array $ids
|
132 |
+
* @param bool $addCollectionData
|
133 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
134 |
+
* @author Jason Lotzer
|
135 |
+
*/
|
136 |
+
public function loadByIds($ids, $addCollectionData = true){
|
137 |
+
$levelField = $this->_conn->quoteIdentifier('level');
|
138 |
+
$pathField = $this->_conn->quoteIdentifier('path');
|
139 |
+
// load first two levels, if no ids specified
|
140 |
+
if (empty($ids)) {
|
141 |
+
$select = $this->_conn->select()
|
142 |
+
->from($this->_table, 'entity_id')
|
143 |
+
->where($levelField . ' <= 2');
|
144 |
+
$ids = $this->_conn->fetchCol($select);
|
145 |
+
}
|
146 |
+
if (!is_array($ids)) {
|
147 |
+
$ids = array($ids);
|
148 |
+
}
|
149 |
+
foreach ($ids as $key => $id) {
|
150 |
+
$ids[$key] = (int)$id;
|
151 |
+
}
|
152 |
+
// collect paths of specified IDs and prepare to collect all their parents and neighbours
|
153 |
+
$select = $this->_conn->select()
|
154 |
+
->from($this->_table, array('path', 'level'))
|
155 |
+
->where('entity_id IN (?)', $ids);
|
156 |
+
$where = array($levelField . '=0' => true);
|
157 |
+
|
158 |
+
foreach ($this->_conn->fetchAll($select) as $item) {
|
159 |
+
$pathIds = explode('/', $item['path']);
|
160 |
+
$level = (int)$item['level'];
|
161 |
+
while ($level > 0) {
|
162 |
+
$pathIds[count($pathIds) - 1] = '%';
|
163 |
+
$path = implode('/', $pathIds);
|
164 |
+
$where["$levelField=$level AND $pathField LIKE '$path'"] = true;
|
165 |
+
array_pop($pathIds);
|
166 |
+
$level--;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
$where = array_keys($where);
|
170 |
+
|
171 |
+
// get all required records
|
172 |
+
if ($addCollectionData) {
|
173 |
+
$select = $this->_createCollectionDataSelect();
|
174 |
+
}
|
175 |
+
else {
|
176 |
+
$select = clone $this->_select;
|
177 |
+
$select->order($this->_orderField . ' ' . Varien_Db_Select::SQL_ASC);
|
178 |
+
}
|
179 |
+
$select->where(implode(' OR ', $where));
|
180 |
+
|
181 |
+
// get array of records and add them as nodes to the tree
|
182 |
+
$arrNodes = $this->_conn->fetchAll($select);
|
183 |
+
if (!$arrNodes) {
|
184 |
+
return false;
|
185 |
+
}
|
186 |
+
$childrenItems = array();
|
187 |
+
foreach ($arrNodes as $key => $nodeInfo) {
|
188 |
+
$pathToParent = explode('/', $nodeInfo[$this->_pathField]);
|
189 |
+
array_pop($pathToParent);
|
190 |
+
$pathToParent = implode('/', $pathToParent);
|
191 |
+
$childrenItems[$pathToParent][] = $nodeInfo;
|
192 |
+
}
|
193 |
+
$this->addChildNodes($childrenItems, '', null);
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
/**
|
197 |
+
* Load array of menu item parents
|
198 |
+
* @access public
|
199 |
+
* @param string $path
|
200 |
+
* @param bool $addCollectionData
|
201 |
+
* @param bool $withRootNode
|
202 |
+
* @return array
|
203 |
+
* @author Jason Lotzer
|
204 |
+
*/
|
205 |
+
public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRootNode = false){
|
206 |
+
$pathIds = explode('/', $path);
|
207 |
+
if (!$withRootNode) {
|
208 |
+
array_shift($pathIds);
|
209 |
+
}
|
210 |
+
$result = array();
|
211 |
+
if (!empty($pathIds)) {
|
212 |
+
if ($addCollectionData) {
|
213 |
+
$select = $this->_createCollectionDataSelect(false);
|
214 |
+
}
|
215 |
+
else {
|
216 |
+
$select = clone $this->_select;
|
217 |
+
}
|
218 |
+
$select
|
219 |
+
->where('main_table.entity_id IN(?)', $pathIds)
|
220 |
+
->order($this->_conn->getLengthSql('main_table.path') . ' ' . Varien_Db_Select::SQL_ASC);
|
221 |
+
$result = $this->_conn->fetchAll($select);
|
222 |
+
}
|
223 |
+
return $result;
|
224 |
+
}
|
225 |
+
/**
|
226 |
+
* Obtain select for menu items
|
227 |
+
* By default everything from entity table is selected
|
228 |
+
* + name
|
229 |
+
* @access public
|
230 |
+
* @param bool $sorted
|
231 |
+
* @param array $optionalAttributes
|
232 |
+
* @return Zend_Db_Select
|
233 |
+
* @author Jason Lotzer
|
234 |
+
*/
|
235 |
+
protected function _createCollectionDataSelect($sorted = true){
|
236 |
+
$select = $this->_getDefaultCollection($sorted ? $this->_orderField : false)->getSelect();
|
237 |
+
$menuitemsTable = Mage::getSingleton('core/resource')->getTableName('megamenu2/menuitem');
|
238 |
+
$subConcat = $this->_conn->getConcatSql(array('main_table.path', $this->_conn->quote('/%')));
|
239 |
+
$subSelect = $this->_conn->select()
|
240 |
+
->from(array('see' => $menuitemsTable), null)
|
241 |
+
->where('see.entity_id = main_table.entity_id')
|
242 |
+
->orWhere('see.path LIKE ?', $subConcat);
|
243 |
+
return $select;
|
244 |
+
}
|
245 |
+
/**
|
246 |
+
* Get real existing menu item ids by specified ids
|
247 |
+
* @access public
|
248 |
+
* @param array $ids
|
249 |
+
* @return array
|
250 |
+
* @author Jason Lotzer
|
251 |
+
*/
|
252 |
+
public function getExistingMenuitemIdsBySpecifiedIds($ids){
|
253 |
+
if (empty($ids)) {
|
254 |
+
return array();
|
255 |
+
}
|
256 |
+
if (!is_array($ids)) {
|
257 |
+
$ids = array($ids);
|
258 |
+
}
|
259 |
+
$select = $this->_conn->select()
|
260 |
+
->from($this->_table, array('entity_id'))
|
261 |
+
->where('entity_id IN (?)', $ids);
|
262 |
+
return $this->_conn->fetchCol($select);
|
263 |
+
}
|
264 |
+
/**
|
265 |
+
* add collection data
|
266 |
+
* @access public
|
267 |
+
* @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
|
268 |
+
* @param boolean $sorted
|
269 |
+
* @param array $exclude
|
270 |
+
* @param boolean $toLoad
|
271 |
+
* @param boolean $onlyActive
|
272 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Category_Tree
|
273 |
+
* @author Jason Lotzer
|
274 |
+
*/
|
275 |
+
public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true, $onlyActive = false){
|
276 |
+
if (is_null($collection)) {
|
277 |
+
$collection = $this->getCollection($sorted);
|
278 |
+
} else {
|
279 |
+
$this->setCollection($collection);
|
280 |
+
}
|
281 |
+
if (!is_array($exclude)) {
|
282 |
+
$exclude = array($exclude);
|
283 |
+
}
|
284 |
+
$nodeIds = array();
|
285 |
+
foreach ($this->getNodes() as $node) {
|
286 |
+
if (!in_array($node->getId(), $exclude)) {
|
287 |
+
$nodeIds[] = $node->getId();
|
288 |
+
}
|
289 |
+
}
|
290 |
+
$collection->addIdFilter($nodeIds);
|
291 |
+
if ($onlyActive) {
|
292 |
+
$disabledIds = $this->_getDisabledIds($collection);
|
293 |
+
if ($disabledIds) {
|
294 |
+
$collection->addFieldToFilter('entity_id', array('nin' => $disabledIds));
|
295 |
+
}
|
296 |
+
$collection->addFieldToFilter('status', 1);
|
297 |
+
}
|
298 |
+
if ($toLoad) {
|
299 |
+
$collection->load();
|
300 |
+
foreach ($collection as $menuitem) {
|
301 |
+
if ($this->getNodeById($menuitem->getId())) {
|
302 |
+
$this->getNodeById($menuitem->getId())->addData($menuitem->getData());
|
303 |
+
}
|
304 |
+
}
|
305 |
+
foreach ($this->getNodes() as $node) {
|
306 |
+
if (!$collection->getItemById($node->getId()) && $node->getParent()) {
|
307 |
+
$this->removeNode($node);
|
308 |
+
}
|
309 |
+
}
|
310 |
+
}
|
311 |
+
return $this;
|
312 |
+
}
|
313 |
+
/**
|
314 |
+
* Add inactive menu items ids
|
315 |
+
* @access public
|
316 |
+
* @param unknown_type $ids
|
317 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
318 |
+
* @author Jason Lotzer
|
319 |
+
*/
|
320 |
+
public function addInactiveMenuitemIds($ids){
|
321 |
+
if (!is_array($this->_inactiveMenuitemIds)) {
|
322 |
+
$this->_initInactiveMenuitemIds();
|
323 |
+
}
|
324 |
+
$this->_inactiveMenuitemIds = array_merge($ids, $this->_inactiveMenuitemIds);
|
325 |
+
return $this;
|
326 |
+
}
|
327 |
+
/**
|
328 |
+
* Retrieve inactive menu items ids
|
329 |
+
* @access protected
|
330 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menuitem_Tree
|
331 |
+
* @author Jason Lotzer
|
332 |
+
*/
|
333 |
+
protected function _initInactiveMenuitemIds(){
|
334 |
+
$this->_inactiveMenuitemIds = array();
|
335 |
+
return $this;
|
336 |
+
}
|
337 |
+
/**
|
338 |
+
* Retrieve inactive menu items ids
|
339 |
+
* @access public
|
340 |
+
* @return array
|
341 |
+
* @author Jason Lotzer
|
342 |
+
*/
|
343 |
+
public function getInactiveMenuitemIds(){
|
344 |
+
if (!is_array($this->_inactiveMenuitemIds)) {
|
345 |
+
$this->_initInactiveMenuitemIds();
|
346 |
+
}
|
347 |
+
return $this->_inactiveMenuitemIds;
|
348 |
+
}
|
349 |
+
/**
|
350 |
+
* Return disable menu item ids
|
351 |
+
* @access protected
|
352 |
+
* @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
|
353 |
+
* @return array
|
354 |
+
* @author Jason Lotzer
|
355 |
+
*/
|
356 |
+
protected function _getDisabledIds($collection){
|
357 |
+
$this->_inactiveItems = $this->getInactiveMenuitemIds();
|
358 |
+
$this->_inactiveItems = array_merge(
|
359 |
+
$this->_getInactiveItemIds($collection),
|
360 |
+
$this->_inactiveItems
|
361 |
+
);
|
362 |
+
$allIds = $collection->getAllIds();
|
363 |
+
$disabledIds = array();
|
364 |
+
|
365 |
+
foreach ($allIds as $id) {
|
366 |
+
$parents = $this->getNodeById($id)->getPath();
|
367 |
+
foreach ($parents as $parent) {
|
368 |
+
if (!$this->_getItemIsActive($parent->getId())){
|
369 |
+
$disabledIds[] = $id;
|
370 |
+
continue;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}
|
374 |
+
return $disabledIds;
|
375 |
+
}
|
376 |
+
/**
|
377 |
+
* Retrieve inactive menu item item ids
|
378 |
+
* @access protecte
|
379 |
+
* @param JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection $collection
|
380 |
+
* @return array
|
381 |
+
* @author Jason Lotzer
|
382 |
+
*/
|
383 |
+
protected function _getInactiveItemIds($collection){
|
384 |
+
$filter = $collection->getAllIdsSql();
|
385 |
+
$table = Mage::getSingleton('core/resource')->getTable('megamenu2/menuitem');
|
386 |
+
$bind = array(
|
387 |
+
'cond' => 0,
|
388 |
+
);
|
389 |
+
$select = $this->_conn->select()
|
390 |
+
->from(array('d'=>$table), array('d.entity_id'))
|
391 |
+
->where('d.entity_id IN (?)', new Zend_Db_Expr($filter))
|
392 |
+
->where('status = :cond');
|
393 |
+
return $this->_conn->fetchCol($select, $bind);
|
394 |
+
}
|
395 |
+
/**
|
396 |
+
* Check is menu item items active
|
397 |
+
* @access protecte
|
398 |
+
* @param int $id
|
399 |
+
* @return boolean
|
400 |
+
* @author Jason Lotzer
|
401 |
+
*/
|
402 |
+
protected function _getItemIsActive($id){
|
403 |
+
if (!in_array($id, $this->_inactiveItems)) {
|
404 |
+
return true;
|
405 |
+
}
|
406 |
+
return false;
|
407 |
+
}
|
408 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting resource model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menusetting extends Mage_Core_Model_Resource_Db_Abstract{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function _construct(){
|
32 |
+
$this->_init('megamenu2/menusetting', 'entity_id');
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get store ids to which specified item is assigned
|
37 |
+
* @access public
|
38 |
+
* @param int $menusettingId
|
39 |
+
* @return array
|
40 |
+
* @author Jason Lotzer
|
41 |
+
*/
|
42 |
+
public function lookupStoreIds($menusettingId){
|
43 |
+
$adapter = $this->_getReadAdapter();
|
44 |
+
$select = $adapter->select()
|
45 |
+
->from($this->getTable('megamenu2/menusetting_store'), 'store_id')
|
46 |
+
->where('menusetting_id = ?',(int)$menusettingId);
|
47 |
+
return $adapter->fetchCol($select);
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* Perform operations after object load
|
51 |
+
* @access public
|
52 |
+
* @param Mage_Core_Model_Abstract $object
|
53 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting
|
54 |
+
* @author Jason Lotzer
|
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_Menusetting $object
|
70 |
+
* @return Zend_Db_Select
|
71 |
+
*/
|
72 |
+
protected function _getLoadSelect($field, $value, $object){
|
73 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
74 |
+
if ($object->getStoreId()) {
|
75 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
76 |
+
$select->join(
|
77 |
+
array('megamenu2_menusetting_store' => $this->getTable('megamenu2/menusetting_store')),
|
78 |
+
$this->getMainTable() . '.entity_id = megamenu2_menusetting_store.menusetting_id',
|
79 |
+
array()
|
80 |
+
)
|
81 |
+
->where('megamenu2_menusetting_store.store_id IN (?)', $storeIds)
|
82 |
+
->order('megamenu2_menusetting_store.store_id DESC')
|
83 |
+
->limit(1);
|
84 |
+
}
|
85 |
+
return $select;
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* Assign menu setting to store views
|
89 |
+
* @access protected
|
90 |
+
* @param Mage_Core_Model_Abstract $object
|
91 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting
|
92 |
+
* @author Jason Lotzer
|
93 |
+
*/
|
94 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object){
|
95 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
96 |
+
$newStores = (array)$object->getStores();
|
97 |
+
if (empty($newStores)) {
|
98 |
+
$newStores = (array)$object->getStoreId();
|
99 |
+
}
|
100 |
+
$table = $this->getTable('megamenu2/menusetting_store');
|
101 |
+
$insert = array_diff($newStores, $oldStores);
|
102 |
+
$delete = array_diff($oldStores, $newStores);
|
103 |
+
if ($delete) {
|
104 |
+
$where = array(
|
105 |
+
'menusetting_id = ?' => (int) $object->getId(),
|
106 |
+
'store_id IN (?)' => $delete
|
107 |
+
);
|
108 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
109 |
+
}
|
110 |
+
if ($insert) {
|
111 |
+
$data = array();
|
112 |
+
foreach ($insert as $storeId) {
|
113 |
+
$data[] = array(
|
114 |
+
'menusetting_id' => (int) $object->getId(),
|
115 |
+
'store_id' => (int) $storeId
|
116 |
+
);
|
117 |
+
}
|
118 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
119 |
+
}
|
120 |
+
return parent::_afterSave($object);
|
121 |
+
}}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Collection.php
ADDED
@@ -0,0 +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 |
+
* Menu Setting collection resource model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
|
25 |
+
protected $_joinedFields = array();
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
* @access public
|
29 |
+
* @return void
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
public function _construct(){
|
33 |
+
parent::_construct();
|
34 |
+
$this->_init('megamenu2/menusetting');
|
35 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
36 |
+
}
|
37 |
+
/**
|
38 |
+
* get menusettings as array
|
39 |
+
* @access protected
|
40 |
+
* @param string $valueField
|
41 |
+
* @param string $labelField
|
42 |
+
* @param array $additional
|
43 |
+
* @return array
|
44 |
+
* @author Jason Lotzer
|
45 |
+
*/
|
46 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='menutitle', $additional=array()){
|
47 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* get options hash
|
51 |
+
* @access protected
|
52 |
+
* @param string $valueField
|
53 |
+
* @param string $labelField
|
54 |
+
* @return array
|
55 |
+
* @author Jason Lotzer
|
56 |
+
*/
|
57 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='menutitle'){
|
58 |
+
return parent::_toOptionHash($valueField, $labelField);
|
59 |
+
}
|
60 |
+
/**
|
61 |
+
* Add filter by store
|
62 |
+
* @access public
|
63 |
+
* @param int|Mage_Core_Model_Store $store
|
64 |
+
* @param bool $withAdmin
|
65 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection
|
66 |
+
* @author Jason Lotzer
|
67 |
+
*/
|
68 |
+
public function addStoreFilter($store, $withAdmin = true){
|
69 |
+
if (!isset($this->_joinedFields['store'])){
|
70 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
71 |
+
$store = array($store->getId());
|
72 |
+
}
|
73 |
+
if (!is_array($store)) {
|
74 |
+
$store = array($store);
|
75 |
+
}
|
76 |
+
if ($withAdmin) {
|
77 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
78 |
+
}
|
79 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
80 |
+
$this->_joinedFields['store'] = true;
|
81 |
+
}
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* Join store relation table if there is store filter
|
86 |
+
* @access protected
|
87 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection
|
88 |
+
* @author Jason Lotzer
|
89 |
+
*/
|
90 |
+
protected function _renderFiltersBefore(){
|
91 |
+
if ($this->getFilter('store')) {
|
92 |
+
$this->getSelect()->join(
|
93 |
+
array('store_table' => $this->getTable('megamenu2/menusetting_store')),
|
94 |
+
'main_table.entity_id = store_table.menusetting_id',
|
95 |
+
array()
|
96 |
+
)->group('main_table.entity_id');
|
97 |
+
/*
|
98 |
+
* Allow analytic functions usage because of one field grouping
|
99 |
+
*/
|
100 |
+
$this->_useAnalyticFunction = true;
|
101 |
+
}
|
102 |
+
return parent::_renderFiltersBefore();
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* Get SQL for get record count.
|
106 |
+
* Extra GROUP BY strip added.
|
107 |
+
* @access public
|
108 |
+
* @return Varien_Db_Select
|
109 |
+
* @author Jason Lotzer
|
110 |
+
*/
|
111 |
+
public function getSelectCountSql(){
|
112 |
+
$countSelect = parent::getSelectCountSql();
|
113 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
114 |
+
return $countSelect;
|
115 |
+
}
|
116 |
+
/**
|
117 |
+
* add the product filter to collection
|
118 |
+
* @access public
|
119 |
+
* @param mixed (Mage_Catalog_Model_Product|int) $product
|
120 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection
|
121 |
+
* @author Jason Lotzer
|
122 |
+
*/
|
123 |
+
public function addProductFilter($product){
|
124 |
+
if ($product instanceof Mage_Catalog_Model_Product){
|
125 |
+
$product = $product->getId();
|
126 |
+
}
|
127 |
+
if (!isset($this->_joinedFields['product'])){
|
128 |
+
$this->getSelect()->join(
|
129 |
+
array('related_product' => $this->getTable('megamenu2/menusetting_product')),
|
130 |
+
'related_product.menusetting_id = main_table.entity_id',
|
131 |
+
array('position')
|
132 |
+
);
|
133 |
+
$this->getSelect()->where('related_product.product_id = ?', $product);
|
134 |
+
$this->_joinedFields['product'] = true;
|
135 |
+
}
|
136 |
+
return $this;
|
137 |
+
}
|
138 |
+
/**
|
139 |
+
* add the menuitem filter to collection
|
140 |
+
* @access public
|
141 |
+
* @param mixed (JScriptz_MegaMenu2_Model_Menuitem|int) $menuitem
|
142 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Collection
|
143 |
+
* @author Jason Lotzer
|
144 |
+
*/
|
145 |
+
public function addMenuitemFilter($menuitem){
|
146 |
+
if ($menuitem instanceof JScriptz_MegaMenu2_Model_Menuitem){
|
147 |
+
$menuitem = $menuitem->getId();
|
148 |
+
}
|
149 |
+
if (!isset($this->_joinedFields['menuitem'])){
|
150 |
+
$this->getSelect()->join(
|
151 |
+
array('related_menuitem' => $this->getTable('megamenu2/menusetting_menuitem')),
|
152 |
+
'related_menuitem.menusetting_id = main_table.entity_id',
|
153 |
+
array('position')
|
154 |
+
);
|
155 |
+
$this->getSelect()->where('related_menuitem.menuitem_id = ?', $menuitem);
|
156 |
+
$this->_joinedFields['menuitem'] = true;
|
157 |
+
}
|
158 |
+
return $this;
|
159 |
+
}
|
160 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Menuitem.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting - Menu Item relation model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menusetting_Menuitem extends Mage_Core_Model_Resource_Db_Abstract{
|
25 |
+
/**
|
26 |
+
* initialize resource model
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @see Mage_Core_Model_Resource_Abstract::_construct()
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
protected function _construct(){
|
33 |
+
$this->_init('megamenu2/menusetting_menuitem', 'rel_id');
|
34 |
+
}
|
35 |
+
/**
|
36 |
+
* Save menusetting - menuitem relations
|
37 |
+
* @access public
|
38 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting $menusetting
|
39 |
+
* @param array $data
|
40 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Menuitem
|
41 |
+
* @author Jason Lotzer
|
42 |
+
*/
|
43 |
+
public function saveMenusettingRelation($menusetting, $menuitemIds){
|
44 |
+
if (is_null($menuitemIds)){
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
$oldMenuitems = $menusetting->getSelectedMenuitems();
|
48 |
+
$oldMenuitemIds = array();
|
49 |
+
foreach ($oldMenuitems as $menuitem){
|
50 |
+
$oldMenuitemIds[] = $menuitem->getId();
|
51 |
+
}
|
52 |
+
$insert = array_diff($menuitemIds, $oldMenuitemIds);
|
53 |
+
$delete = array_diff($oldMenuitemIds, $menuitemIds);
|
54 |
+
$write = $this->_getWriteAdapter();
|
55 |
+
if (!empty($insert)) {
|
56 |
+
$data = array();
|
57 |
+
foreach ($insert as $menuitemId) {
|
58 |
+
if (empty($menuitemId)) {
|
59 |
+
continue;
|
60 |
+
}
|
61 |
+
$data[] = array(
|
62 |
+
'menuitem_id' => (int)$menuitemId,
|
63 |
+
'menusetting_id' => (int)$menusetting->getId(),
|
64 |
+
'position'=> 1
|
65 |
+
);
|
66 |
+
}
|
67 |
+
if ($data) {
|
68 |
+
$write->insertMultiple($this->getMainTable(), $data);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
if (!empty($delete)) {
|
72 |
+
foreach ($delete as $menuitemId) {
|
73 |
+
$where = array(
|
74 |
+
'menusetting_id = ?' => (int)$menusetting->getId(),
|
75 |
+
'menuitem_id = ?' => (int)$menuitemId,
|
76 |
+
);
|
77 |
+
$write->delete($this->getMainTable(), $where);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Menuitem/Collection.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting - Menu Item relation resource model collection
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menusetting_Menuitem_Collection extends JScriptz_MegaMenu2_Model_Resource_Menuitem_Collection{
|
25 |
+
/**
|
26 |
+
* remember if fields have been joined
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
protected $_joinedFields = false;
|
30 |
+
/**
|
31 |
+
* join the link table
|
32 |
+
* @access public
|
33 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Menuitem_Collection
|
34 |
+
* @author Jason Lotzer
|
35 |
+
*/
|
36 |
+
public function joinFields(){
|
37 |
+
if (!$this->_joinedFields){
|
38 |
+
$this->getSelect()->join(
|
39 |
+
array('related' => $this->getTable('megamenu2/menusetting_menuitem')),
|
40 |
+
'related.menuitem_id = main_table.entity_id',
|
41 |
+
array('position')
|
42 |
+
);
|
43 |
+
$this->_joinedFields = true;
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* add menusetting filter
|
49 |
+
* @access public
|
50 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting | int $menusetting
|
51 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Menuitem_Collection
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function addMenusettingFilter($menusetting){
|
55 |
+
if ($menusetting instanceof JScriptz_MegaMenu2_Model_Menusetting){
|
56 |
+
$menusetting = $menusetting->getId();
|
57 |
+
}
|
58 |
+
if (!$this->_joinedFields){
|
59 |
+
$this->joinFields();
|
60 |
+
}
|
61 |
+
$this->getSelect()->where('related.menusetting_id = ?', $menusetting);
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Product.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting - product relation model
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menusetting_Product extends Mage_Core_Model_Resource_Db_Abstract{
|
25 |
+
/**
|
26 |
+
* initialize resource model
|
27 |
+
* @access protected
|
28 |
+
* @return void
|
29 |
+
* @see Mage_Core_Model_Resource_Abstract::_construct()
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
protected function _construct(){
|
33 |
+
$this->_init('megamenu2/menusetting_product', 'rel_id');
|
34 |
+
}
|
35 |
+
/**
|
36 |
+
* Save menusetting - product relations
|
37 |
+
* @access public
|
38 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting $menusetting
|
39 |
+
* @param array $data
|
40 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Product
|
41 |
+
* @author Jason Lotzer
|
42 |
+
*/
|
43 |
+
public function saveMenusettingRelation($menusetting, $data){
|
44 |
+
if (!is_array($data)) {
|
45 |
+
$data = array();
|
46 |
+
}
|
47 |
+
$deleteCondition = $this->_getWriteAdapter()->quoteInto('menusetting_id=?', $menusetting->getId());
|
48 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
|
49 |
+
|
50 |
+
foreach ($data as $productId => $info) {
|
51 |
+
$this->_getWriteAdapter()->insert($this->getMainTable(), array(
|
52 |
+
'menusetting_id' => $menusetting->getId(),
|
53 |
+
'product_id' => $productId,
|
54 |
+
'position' => @$info['position']
|
55 |
+
));
|
56 |
+
}
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
/**
|
60 |
+
* Save product - menusetting relations
|
61 |
+
* @access public
|
62 |
+
* @param Mage_Catalog_Model_Product $prooduct
|
63 |
+
* @param array $data
|
64 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Product
|
65 |
+
* @@author Jason Lotzer
|
66 |
+
*/
|
67 |
+
public function saveProductRelation($product, $data){
|
68 |
+
if (!is_array($data)) {
|
69 |
+
$data = array();
|
70 |
+
}
|
71 |
+
$deleteCondition = $this->_getWriteAdapter()->quoteInto('product_id=?', $product->getId());
|
72 |
+
$this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition);
|
73 |
+
|
74 |
+
foreach ($data as $menusettingId => $info) {
|
75 |
+
$this->_getWriteAdapter()->insert($this->getMainTable(), array(
|
76 |
+
'menusetting_id' => $menusettingId,
|
77 |
+
'product_id' => $product->getId(),
|
78 |
+
'position' => @$info['position']
|
79 |
+
));
|
80 |
+
}
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Menusetting/Product/Collection.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting - product relation resource model collection
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Menusetting_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection{
|
25 |
+
/**
|
26 |
+
* remember if fields have been joined
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
protected $_joinedFields = false;
|
30 |
+
/**
|
31 |
+
* join the link table
|
32 |
+
* @access public
|
33 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Product_Collection
|
34 |
+
* @author Jason Lotzer
|
35 |
+
*/
|
36 |
+
public function joinFields(){
|
37 |
+
if (!$this->_joinedFields){
|
38 |
+
$this->getSelect()->join(
|
39 |
+
array('related' => $this->getTable('megamenu2/menusetting_product')),
|
40 |
+
'related.product_id = e.entity_id',
|
41 |
+
array('position')
|
42 |
+
);
|
43 |
+
$this->_joinedFields = true;
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
/**
|
48 |
+
* add menusetting filter
|
49 |
+
* @access public
|
50 |
+
* @param JScriptz_MegaMenu2_Model_Menusetting | int $menusetting
|
51 |
+
* @return JScriptz_MegaMenu2_Model_Resource_Menusetting_Product_Collection
|
52 |
+
* @author Jason Lotzer
|
53 |
+
*/
|
54 |
+
public function addMenusettingFilter($menusetting){
|
55 |
+
if ($menusetting instanceof JScriptz_MegaMenu2_Model_Menusetting){
|
56 |
+
$menusetting = $menusetting->getId();
|
57 |
+
}
|
58 |
+
if (!$this->_joinedFields){
|
59 |
+
$this->joinFields();
|
60 |
+
}
|
61 |
+
$this->getSelect()->where('related.menusetting_id = ?', $menusetting);
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/Resource/Setup.php
CHANGED
@@ -1,25 +1,26 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* MegaMenu2 setup
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
22 |
-
|
23 |
-
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup{
|
25 |
+
|
26 |
+
}
|
app/code/community/JScriptz/MegaMenu2/Model/SystemSettings.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class JScriptz_MegaMenu2_Model_SystemSettings
|
3 |
+
{
|
4 |
+
public function toOptionArray()
|
5 |
+
{
|
6 |
+
return array(
|
7 |
+
array('value'=>1, 'label'=>Mage::helper('megamenu2')->__('Enabled')),
|
8 |
+
array('value'=>0, 'label'=>Mage::helper('megamenu2')->__('Disabled')),
|
9 |
+
|
10 |
+
);
|
11 |
+
}
|
12 |
+
|
13 |
+
}
|
14 |
+
?>
|
app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/Menuitem/Catalog/ProductController.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 - product controller
|
19 |
+
* @category JScriptz
|
20 |
+
* @package JScriptz_MegaMenu2
|
21 |
+
* @author Jason Lotzer
|
22 |
+
*/
|
23 |
+
require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
|
24 |
+
class JScriptz_MegaMenu2_Adminhtml_MegaMenu2_Menuitem_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController{
|
25 |
+
/**
|
26 |
+
* menu items action
|
27 |
+
* @access public
|
28 |
+
* @return void
|
29 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
public function menuitemsAction(){
|
32 |
+
$this->_initProduct();
|
33 |
+
$this->loadLayout();
|
34 |
+
$this->renderLayout();
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* menu items json action
|
38 |
+
* @access public
|
39 |
+
* @return void
|
40 |
+
* @author Jason Lotzer
|
41 |
+
*/
|
42 |
+
public function menuitemsJsonAction(){
|
43 |
+
$product = $this->_initProduct();
|
44 |
+
$this->getResponse()->setBody(
|
45 |
+
$this->getLayout()->createBlock('megamenu2/adminhtml_catalog_product_edit_tab_menuitem')
|
46 |
+
->getMenuitemChildrenJson($this->getRequest()->getParam('menuitem'))
|
47 |
+
);
|
48 |
+
}
|
49 |
+
}
|
app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/MenuitemController.php
CHANGED
@@ -1,311 +1,357 @@
|
|
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
|
14 |
-
* @copyright Copyright (c) 2013
|
15 |
-
* @license
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Menu Item admin controller
|
19 |
-
*
|
20 |
-
* @category JScriptz
|
21 |
-
* @package
|
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 |
-
|
31 |
-
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
Mage::register('
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
*
|
46 |
-
* @
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
*
|
56 |
-
* @
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
*
|
66 |
-
* @
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
$
|
72 |
-
$
|
73 |
-
$
|
74 |
-
$
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
$
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
$
|
107 |
-
$
|
108 |
-
|
109 |
-
'
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$this->
|
116 |
-
|
117 |
-
|
118 |
-
$this->
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
Mage::helper('megamenu2')->__('Manage Menu Items')
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
*
|
133 |
-
* @
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
$
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
Mage::
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
*
|
179 |
-
*
|
180 |
-
* @
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
$
|
186 |
-
$
|
187 |
-
$
|
188 |
-
$
|
189 |
-
|
190 |
-
|
191 |
-
'
|
192 |
-
|
193 |
-
'
|
194 |
-
'
|
195 |
-
'
|
196 |
-
'
|
197 |
-
'
|
198 |
-
'
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
*
|
206 |
-
* @
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
'
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
*
|
223 |
-
* @
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
Mage::
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
*
|
252 |
-
* @
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
*
|
260 |
-
* @
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
$
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
'
|
270 |
-
'
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
*
|
277 |
-
* @
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
$
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
$menuitem->
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
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 |
+
* @author Jason Lotzer
|
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 |
+
* @author Jason Lotzer
|
30 |
+
*/
|
31 |
+
protected function _initMenuitem(){
|
32 |
+
$menuitemId = (int) $this->getRequest()->getParam('id',false);
|
33 |
+
$menuitem = Mage::getModel('megamenu2/menuitem');
|
34 |
+
if ($menuitemId) {
|
35 |
+
$menuitem->load($menuitemId);
|
36 |
+
}
|
37 |
+
if ($activeTabId = (string) $this->getRequest()->getParam('active_tab_id')) {
|
38 |
+
Mage::getSingleton('admin/session')->setActiveTabId($activeTabId);
|
39 |
+
}
|
40 |
+
Mage::register('menuitem', $menuitem);
|
41 |
+
Mage::register('current_menuitem', $menuitem);
|
42 |
+
return $menuitem;
|
43 |
+
}
|
44 |
+
/**
|
45 |
+
* default action
|
46 |
+
* @access public
|
47 |
+
* @return void
|
48 |
+
* @author Jason Lotzer
|
49 |
+
*/
|
50 |
+
public function indexAction(){
|
51 |
+
$this->_forward('edit');
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Add new menu item form
|
56 |
+
* @access public
|
57 |
+
* @return void
|
58 |
+
* @author Jason Lotzer
|
59 |
+
*/
|
60 |
+
public function addAction(){
|
61 |
+
Mage::getSingleton('admin/session')->unsActiveTabId();
|
62 |
+
$this->_forward('edit');
|
63 |
+
}
|
64 |
+
/**
|
65 |
+
* Edit menu item page
|
66 |
+
* @access public
|
67 |
+
* @return void
|
68 |
+
* @author Jason Lotzer
|
69 |
+
*/
|
70 |
+
public function editAction(){
|
71 |
+
$params['_current'] = true;
|
72 |
+
$redirect = false;
|
73 |
+
$parentId = (int) $this->getRequest()->getParam('parent');
|
74 |
+
$menuitemId = (int) $this->getRequest()->getParam('id');
|
75 |
+
$_prevMenuitemId = Mage::getSingleton('admin/session')->getLastEditedMenuitem(true);
|
76 |
+
if ($_prevMenuitemId && !$this->getRequest()->getQuery('isAjax') && !$this->getRequest()->getParam('clear')) {
|
77 |
+
$this->getRequest()->setParam('id',$_prevMenuitemId);
|
78 |
+
}
|
79 |
+
if ($redirect) {
|
80 |
+
$this->_redirect('*/*/edit', $params);
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
if (!($menuitem = $this->_initMenuitem())) {
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
$this->_title($menuitemId ? $menuitem->getLinktitle() : $this->__('New Menu Item'));
|
87 |
+
$data = Mage::getSingleton('adminhtml/session')->getMenuitemData(true);
|
88 |
+
if (isset($data['menuitem'])) {
|
89 |
+
$menuitem->addData($data['menuitem']);
|
90 |
+
}
|
91 |
+
if ($this->getRequest()->getQuery('isAjax')) {
|
92 |
+
$breadcrumbsPath = $menuitem->getPath();
|
93 |
+
if (empty($breadcrumbsPath)) {
|
94 |
+
$breadcrumbsPath = Mage::getSingleton('admin/session')->getDeletedPath(true);
|
95 |
+
if (!empty($breadcrumbsPath)) {
|
96 |
+
$breadcrumbsPath = explode('/', $breadcrumbsPath);
|
97 |
+
if (count($breadcrumbsPath) <= 1) {
|
98 |
+
$breadcrumbsPath = '';
|
99 |
+
}
|
100 |
+
else {
|
101 |
+
array_pop($breadcrumbsPath);
|
102 |
+
$breadcrumbsPath = implode('/', $breadcrumbsPath);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
Mage::getSingleton('admin/session')->setLastEditedMenuitem($menuitem->getId());
|
107 |
+
$this->loadLayout();
|
108 |
+
$eventResponse = new Varien_Object(array(
|
109 |
+
'content' => $this->getLayout()->getBlock('menuitem.edit')->getFormHtml(). $this->getLayout()->getBlock('menuitem.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingMenuitemBreadcrumbs'),
|
110 |
+
'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(),
|
111 |
+
));
|
112 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($eventResponse->getData()));
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
$this->loadLayout();
|
116 |
+
$this->_title(Mage::helper('megamenu2')->__('MegaMenu2'))
|
117 |
+
->_title(Mage::helper('megamenu2')->__('Menu Items'));
|
118 |
+
$this->_setActiveMenu('megamenu2/menuitem');
|
119 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
|
120 |
+
->setContainerCssClass('menuitem');
|
121 |
+
|
122 |
+
$this->_addBreadcrumb(
|
123 |
+
Mage::helper('megamenu2')->__('Manage Menu Items'),
|
124 |
+
Mage::helper('megamenu2')->__('Manage Menu Items')
|
125 |
+
);
|
126 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
127 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
128 |
+
}
|
129 |
+
$this->renderLayout();
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* Get tree node (Ajax version)
|
133 |
+
* @access public
|
134 |
+
* @return void
|
135 |
+
* @author Jason Lotzer
|
136 |
+
*/
|
137 |
+
public function menuitemsJsonAction(){
|
138 |
+
if ($this->getRequest()->getParam('expand_all')) {
|
139 |
+
Mage::getSingleton('admin/session')->setMenuitemIsTreeWasExpanded(true);
|
140 |
+
}
|
141 |
+
else {
|
142 |
+
Mage::getSingleton('admin/session')->setMenuitemIsTreeWasExpanded(false);
|
143 |
+
}
|
144 |
+
if ($menuitemId = (int) $this->getRequest()->getPost('id')) {
|
145 |
+
$this->getRequest()->setParam('id', $menuitemId);
|
146 |
+
if (!$menuitem = $this->_initMenuitem()) {
|
147 |
+
return;
|
148 |
+
}
|
149 |
+
$this->getResponse()->setBody(
|
150 |
+
$this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_tree')->getTreeJson($menuitem)
|
151 |
+
);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
/**
|
155 |
+
* Move menu item action
|
156 |
+
*/
|
157 |
+
public function moveAction(){
|
158 |
+
$menuitem = $this->_initMenuitem();
|
159 |
+
if (!$menuitem) {
|
160 |
+
$this->getResponse()->setBody(Mage::helper('megamenu2')->__('Menu Item move error'));
|
161 |
+
return;
|
162 |
+
}
|
163 |
+
$parentNodeId = $this->getRequest()->getPost('pid', false);
|
164 |
+
$prevNodeId = $this->getRequest()->getPost('aid', false);
|
165 |
+
try {
|
166 |
+
$menuitem->move($parentNodeId, $prevNodeId);
|
167 |
+
$this->getResponse()->setBody("SUCCESS");
|
168 |
+
}
|
169 |
+
catch (Mage_Core_Exception $e) {
|
170 |
+
$this->getResponse()->setBody($e->getMessage());
|
171 |
+
}
|
172 |
+
catch (Exception $e){
|
173 |
+
$this->getResponse()->setBody(Mage::helper('megamenu2')->__('Menu Item move error'));
|
174 |
+
Mage::logException($e);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
/**
|
178 |
+
* Tree Action
|
179 |
+
* Retrieve menu item tree
|
180 |
+
* @access public
|
181 |
+
* @return void
|
182 |
+
* @author Jason Lotzer
|
183 |
+
*/
|
184 |
+
public function treeAction(){
|
185 |
+
$menuitemId = (int) $this->getRequest()->getParam('id');
|
186 |
+
$menuitem = $this->_initMenuitem();
|
187 |
+
$block = $this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_tree');
|
188 |
+
$root = $block->getRoot();
|
189 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(
|
190 |
+
array(
|
191 |
+
'data' => $block->getTree(),
|
192 |
+
'parameters' => array(
|
193 |
+
'text'=> $block->buildNodeName($root),
|
194 |
+
'draggable' => false,
|
195 |
+
'allowDrop' => ($root->getIsVisible()) ? true : false,
|
196 |
+
'id' => (int) $root->getId(),
|
197 |
+
'expanded'=> (int) $block->getIsWasExpanded(),
|
198 |
+
'menuitem_id' => (int) $menuitem->getId(),
|
199 |
+
'root_visible'=> (int) $root->getIsVisible()
|
200 |
+
)
|
201 |
+
)
|
202 |
+
));
|
203 |
+
}
|
204 |
+
/**
|
205 |
+
* Build response for refresh input element 'path' in form
|
206 |
+
* @access public
|
207 |
+
* @return void
|
208 |
+
* @author Jason Lotzer
|
209 |
+
*/
|
210 |
+
public function refreshPathAction(){
|
211 |
+
if ($id = (int) $this->getRequest()->getParam('id')) {
|
212 |
+
$menuitem = Mage::getModel('megamenu2/menuitem')->load($id);
|
213 |
+
$this->getResponse()->setBody(
|
214 |
+
Mage::helper('core')->jsonEncode(array(
|
215 |
+
'id' => $id,
|
216 |
+
'path' => $menuitem->getPath(),
|
217 |
+
))
|
218 |
+
);
|
219 |
+
}
|
220 |
+
}
|
221 |
+
/**
|
222 |
+
* Delete menu item action
|
223 |
+
* @access public
|
224 |
+
* @return void
|
225 |
+
* @author Jason Lotzer
|
226 |
+
*/
|
227 |
+
public function deleteAction(){
|
228 |
+
if ($id = (int) $this->getRequest()->getParam('id')) {
|
229 |
+
try {
|
230 |
+
$menuitem = Mage::getModel('megamenu2/menuitem')->load($id);
|
231 |
+
Mage::getSingleton('admin/session')->setDeletedPath($menuitem->getPath());
|
232 |
+
|
233 |
+
$menuitem->delete();
|
234 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('The menu item has been deleted.'));
|
235 |
+
}
|
236 |
+
catch (Mage_Core_Exception $e){
|
237 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
238 |
+
$this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
|
239 |
+
return;
|
240 |
+
}
|
241 |
+
catch (Exception $e){
|
242 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('An error occurred while trying to delete the menu item.'));
|
243 |
+
$this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('_current'=>true)));
|
244 |
+
Mage::logException($e);
|
245 |
+
return;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
$this->getResponse()->setRedirect($this->getUrl('*/*/', array('_current'=>true, 'id'=>null)));
|
249 |
+
}
|
250 |
+
/**
|
251 |
+
* Check if admin has permissions to visit related pages
|
252 |
+
* @access protected
|
253 |
+
* @return boolean
|
254 |
+
* @author Jason Lotzer
|
255 |
+
*/
|
256 |
+
protected function _isAllowed(){
|
257 |
+
return Mage::getSingleton('admin/session')->isAllowed('megamenu2/menuitem');
|
258 |
+
} /**
|
259 |
+
* wyisiwyg action
|
260 |
+
* @access public
|
261 |
+
* @return void
|
262 |
+
* @author Jason Lotzer
|
263 |
+
*/
|
264 |
+
public function wysiwygAction(){
|
265 |
+
$elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
|
266 |
+
$storeMediaUrl = Mage::app()->getStore(0)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
267 |
+
|
268 |
+
$content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
|
269 |
+
'editor_element_id' => $elementId,
|
270 |
+
'store_id' => 0,
|
271 |
+
'store_media_url' => $storeMediaUrl,
|
272 |
+
));
|
273 |
+
$this->getResponse()->setBody($content->toHtml());
|
274 |
+
}
|
275 |
+
/**
|
276 |
+
* Menu Item save action
|
277 |
+
* @access public
|
278 |
+
* @return void
|
279 |
+
* @author Jason Lotzer
|
280 |
+
*/
|
281 |
+
public function saveAction(){
|
282 |
+
if (!$menuitem = $this->_initMenuitem()) {
|
283 |
+
return;
|
284 |
+
}
|
285 |
+
$refreshTree = 'false';
|
286 |
+
if ($data = $this->getRequest()->getPost('menuitem')) {
|
287 |
+
$menuitem->addData($data);
|
288 |
+
$linkimageName = $this->_uploadAndGetName('linkimage', Mage::helper('megamenu2/menuitem')->getFileBaseDir(), $data);
|
289 |
+
$menuitem->setData('linkimage', $linkimageName);
|
290 |
+
if (!$menuitem->getId()) {
|
291 |
+
$parentId = $this->getRequest()->getParam('parent');
|
292 |
+
if (!$parentId) {
|
293 |
+
$parentId = Mage::helper('megamenu2/menuitem')->getRootMenuitemId();
|
294 |
+
}
|
295 |
+
$parentMenuitem = Mage::getModel('megamenu2/menuitem')->load($parentId);
|
296 |
+
$menuitem->setPath($parentMenuitem->getPath());
|
297 |
+
}
|
298 |
+
try {
|
299 |
+
$products = $this->getRequest()->getPost('menuitem_products', -1);
|
300 |
+
if ($products != -1) {
|
301 |
+
$productData = array();
|
302 |
+
parse_str($products, $productData);
|
303 |
+
$products = array();
|
304 |
+
foreach ($productData as $id=>$position){
|
305 |
+
$products[$id]['position'] = $position;
|
306 |
+
}
|
307 |
+
$menuitem->setProductsData($productData);
|
308 |
+
}
|
309 |
+
|
310 |
+
$menusettings = $this->getRequest()->getPost('menuitem_menusettings', -1);
|
311 |
+
if ($menusettings != -1) {
|
312 |
+
$menusettingData = array();
|
313 |
+
parse_str($menusettings, $menusettingData);
|
314 |
+
$menusettings = array();
|
315 |
+
foreach ($menusettingData as $id=>$position){
|
316 |
+
$menusetting[$id]['position'] = $position;
|
317 |
+
}
|
318 |
+
$menuitem->setMenusettingsData($menusettingData);
|
319 |
+
}
|
320 |
+
$menuitem->save();
|
321 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('The menu item has been saved.'));
|
322 |
+
$refreshTree = 'true';
|
323 |
+
}
|
324 |
+
catch (Exception $e){
|
325 |
+
$this->_getSession()->addError($e->getMessage())->setMenuitemData($data);
|
326 |
+
Mage::logException($e);
|
327 |
+
$refreshTree = 'false';
|
328 |
+
}
|
329 |
+
}
|
330 |
+
$url = $this->getUrl('*/*/edit', array('_current' => true, 'id' => $menuitem->getId()));
|
331 |
+
$this->getResponse()->setBody(
|
332 |
+
'<script type="text/javascript">parent.updateContent("' . $url . '", {}, '.$refreshTree.');</script>'
|
333 |
+
);
|
334 |
+
}
|
335 |
+
/**
|
336 |
+
* get the products grid
|
337 |
+
* @access public
|
338 |
+
* @return void
|
339 |
+
* @author Jason Lotzer
|
340 |
+
*/
|
341 |
+
public function productsgridAction(){
|
342 |
+
if (!$menuitem = $this->_initMenuitem()) {
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
$this->getResponse()->setBody(
|
346 |
+
$this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_product', 'menuitem.product.grid')->toHtml()
|
347 |
+
);
|
348 |
+
}
|
349 |
+
public function menusettingsgridAction(){
|
350 |
+
if (!$menuitem = $this->_initMenuitem()) {
|
351 |
+
return;
|
352 |
+
}
|
353 |
+
$this->getResponse()->setBody(
|
354 |
+
$this->getLayout()->createBlock('megamenu2/adminhtml_menuitem_edit_tab_menusetting', 'menuitem.menusetting.grid')->toHtml()
|
355 |
+
);
|
356 |
+
}
|
357 |
+
}
|
app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/Menusetting/Catalog/ProductController.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Menusetting product admin controller
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
require_once ("Mage/Adminhtml/controllers/Catalog/ProductController.php");
|
25 |
+
class JScriptz_MegaMenu2_Adminhtml_MegaMenu2_Menusetting_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController{
|
26 |
+
/**
|
27 |
+
* construct
|
28 |
+
* @access protected
|
29 |
+
* @return void
|
30 |
+
* @author Jason Lotzer
|
31 |
+
*/
|
32 |
+
protected function _construct(){
|
33 |
+
// Define module dependent translate
|
34 |
+
$this->setUsedModuleName('JScriptz_MegaMenu2');
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* menusettings in the catalog page
|
38 |
+
* @access public
|
39 |
+
* @return void
|
40 |
+
* @author Jason Lotzer
|
41 |
+
*/
|
42 |
+
public function menusettingsAction(){
|
43 |
+
$this->_initProduct();
|
44 |
+
$this->loadLayout();
|
45 |
+
$this->getLayout()->getBlock('product.edit.tab.menusetting')
|
46 |
+
->setProductMenusettings($this->getRequest()->getPost('product_menusettings', null));
|
47 |
+
$this->renderLayout();
|
48 |
+
}
|
49 |
+
/**
|
50 |
+
* menusettings grid in the catalog page
|
51 |
+
* @access public
|
52 |
+
* @return void
|
53 |
+
* @author Jason Lotzer
|
54 |
+
*/
|
55 |
+
public function menusettingsGridAction(){
|
56 |
+
$this->_initProduct();
|
57 |
+
$this->loadLayout();
|
58 |
+
$this->getLayout()->getBlock('product.edit.tab.menusetting')
|
59 |
+
->setProductMenusettings($this->getRequest()->getPost('product_menusettings', null));
|
60 |
+
$this->renderLayout();
|
61 |
+
}
|
62 |
+
}
|
app/code/community/JScriptz/MegaMenu2/controllers/Adminhtml/MegaMenu2/MenusettingController.php
ADDED
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Setting admin controller
|
19 |
+
*
|
20 |
+
* @category JScriptz
|
21 |
+
* @package JScriptz_MegaMenu2
|
22 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
class JScriptz_MegaMenu2_Adminhtml_MegaMenu2_MenusettingController extends JScriptz_MegaMenu2_Controller_Adminhtml_MegaMenu2{
|
25 |
+
/**
|
26 |
+
* init the menusetting
|
27 |
+
* @access protected
|
28 |
+
* @return JScriptz_MegaMenu2_Model_Menusetting
|
29 |
+
*/
|
30 |
+
protected function _initMenusetting(){
|
31 |
+
$menusettingId = (int) $this->getRequest()->getParam('id');
|
32 |
+
$menusetting = Mage::getModel('megamenu2/menusetting');
|
33 |
+
if ($menusettingId) {
|
34 |
+
$menusetting->load($menusettingId);
|
35 |
+
}
|
36 |
+
Mage::register('current_menusetting', $menusetting);
|
37 |
+
return $menusetting;
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* default action
|
41 |
+
* @access public
|
42 |
+
* @return void
|
43 |
+
* @author Jason Lotzer
|
44 |
+
*/
|
45 |
+
public function indexAction() {
|
46 |
+
$this->loadLayout();
|
47 |
+
$this->_title(Mage::helper('megamenu2')->__('MegaMenu2'))
|
48 |
+
->_title(Mage::helper('megamenu2')->__('Menu Settings'));
|
49 |
+
$this->renderLayout();
|
50 |
+
}
|
51 |
+
/**
|
52 |
+
* grid action
|
53 |
+
* @access public
|
54 |
+
* @return void
|
55 |
+
* @author Jason Lotzer
|
56 |
+
*/
|
57 |
+
public function gridAction() {
|
58 |
+
$this->loadLayout()->renderLayout();
|
59 |
+
}
|
60 |
+
/**
|
61 |
+
* edit menu setting - action
|
62 |
+
* @access public
|
63 |
+
* @return void
|
64 |
+
* @author Jason Lotzer
|
65 |
+
*/
|
66 |
+
public function editAction() {
|
67 |
+
$menusettingId = $this->getRequest()->getParam('id');
|
68 |
+
$menusetting = $this->_initMenusetting();
|
69 |
+
if ($menusettingId && !$menusetting->getId()) {
|
70 |
+
$this->_getSession()->addError(Mage::helper('megamenu2')->__('This menu setting no longer exists.'));
|
71 |
+
$this->_redirect('*/*/');
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
75 |
+
if (!empty($data)) {
|
76 |
+
$menusetting->setData($data);
|
77 |
+
}
|
78 |
+
Mage::register('menusetting_data', $menusetting);
|
79 |
+
$this->loadLayout();
|
80 |
+
$this->_title(Mage::helper('megamenu2')->__('MegaMenu2'))
|
81 |
+
->_title(Mage::helper('megamenu2')->__('Menu Settings'));
|
82 |
+
if ($menusetting->getId()){
|
83 |
+
$this->_title($menusetting->getMenutitle());
|
84 |
+
}
|
85 |
+
else{
|
86 |
+
$this->_title(Mage::helper('megamenu2')->__('Add menu setting'));
|
87 |
+
}
|
88 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
89 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
90 |
+
}
|
91 |
+
$this->renderLayout();
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* new menu setting action
|
95 |
+
* @access public
|
96 |
+
* @return void
|
97 |
+
* @author Jason Lotzer
|
98 |
+
*/
|
99 |
+
public function newAction() {
|
100 |
+
$this->_forward('edit');
|
101 |
+
}
|
102 |
+
/**
|
103 |
+
* save menu setting - action
|
104 |
+
* @access public
|
105 |
+
* @return void
|
106 |
+
* @author Jason Lotzer
|
107 |
+
*/
|
108 |
+
public function saveAction() {
|
109 |
+
if ($data = $this->getRequest()->getPost('menusetting')) {
|
110 |
+
try {
|
111 |
+
$menusetting = $this->_initMenusetting();
|
112 |
+
$menusetting->addData($data);
|
113 |
+
$products = $this->getRequest()->getPost('products', -1);
|
114 |
+
if ($products != -1) {
|
115 |
+
$menusetting->setProductsData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($products));
|
116 |
+
}
|
117 |
+
$menuitems = $this->getRequest()->getPost('menuitem_ids', -1);
|
118 |
+
if ($menuitems != -1) {
|
119 |
+
$menuitems = explode(',', $menuitems);
|
120 |
+
$menuitems = array_unique($menuitems);
|
121 |
+
$menusetting->setMenuitemsData($menuitems);
|
122 |
+
}
|
123 |
+
$menusetting->save();
|
124 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('Menu Setting was successfully saved'));
|
125 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
126 |
+
if ($this->getRequest()->getParam('back')) {
|
127 |
+
$this->_redirect('*/*/edit', array('id' => $menusetting->getId()));
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
$this->_redirect('*/*/');
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
catch (Mage_Core_Exception $e){
|
134 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
135 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
136 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
catch (Exception $e) {
|
140 |
+
Mage::logException($e);
|
141 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('There was a problem saving the menu setting.'));
|
142 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
143 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
144 |
+
return;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('Unable to find menu setting to save.'));
|
148 |
+
$this->_redirect('*/*/');
|
149 |
+
}
|
150 |
+
/**
|
151 |
+
* delete menu setting - action
|
152 |
+
* @access public
|
153 |
+
* @return void
|
154 |
+
* @author Jason Lotzer
|
155 |
+
*/
|
156 |
+
public function deleteAction() {
|
157 |
+
if( $this->getRequest()->getParam('id') > 0) {
|
158 |
+
try {
|
159 |
+
$menusetting = Mage::getModel('megamenu2/menusetting');
|
160 |
+
$menusetting->setId($this->getRequest()->getParam('id'))->delete();
|
161 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('Menu Setting was successfully deleted.'));
|
162 |
+
$this->_redirect('*/*/');
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
catch (Mage_Core_Exception $e){
|
166 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
167 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
168 |
+
}
|
169 |
+
catch (Exception $e) {
|
170 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('There was an error deleteing menu setting.'));
|
171 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
172 |
+
Mage::logException($e);
|
173 |
+
return;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('Could not find menu setting to delete.'));
|
177 |
+
$this->_redirect('*/*/');
|
178 |
+
}
|
179 |
+
/**
|
180 |
+
* mass delete menu setting - action
|
181 |
+
* @access public
|
182 |
+
* @return void
|
183 |
+
* @author Jason Lotzer
|
184 |
+
*/
|
185 |
+
public function massDeleteAction() {
|
186 |
+
$menusettingIds = $this->getRequest()->getParam('menusetting');
|
187 |
+
if(!is_array($menusettingIds)) {
|
188 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('Please select menu settings to delete.'));
|
189 |
+
}
|
190 |
+
else {
|
191 |
+
try {
|
192 |
+
foreach ($menusettingIds as $menusettingId) {
|
193 |
+
$menusetting = Mage::getModel('megamenu2/menusetting');
|
194 |
+
$menusetting->setId($menusettingId)->delete();
|
195 |
+
}
|
196 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('megamenu2')->__('Total of %d menu settings were successfully deleted.', count($menusettingIds)));
|
197 |
+
}
|
198 |
+
catch (Mage_Core_Exception $e){
|
199 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
200 |
+
}
|
201 |
+
catch (Exception $e) {
|
202 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('There was an error deleteing menu settings.'));
|
203 |
+
Mage::logException($e);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
$this->_redirect('*/*/index');
|
207 |
+
}
|
208 |
+
/**
|
209 |
+
* mass Disable Menu change - action
|
210 |
+
* @access public
|
211 |
+
* @return void
|
212 |
+
* @author Jason Lotzer
|
213 |
+
*/
|
214 |
+
public function massDisablemenuAction(){
|
215 |
+
$menusettingIds = $this->getRequest()->getParam('menusetting');
|
216 |
+
if(!is_array($menusettingIds)) {
|
217 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('Please select menu settings.'));
|
218 |
+
}
|
219 |
+
else {
|
220 |
+
try {
|
221 |
+
foreach ($menusettingIds as $menusettingId) {
|
222 |
+
$menusetting = Mage::getSingleton('megamenu2/menusetting')->load($menusettingId)
|
223 |
+
->setDisablemenu($this->getRequest()->getParam('flag_disablemenu'))
|
224 |
+
->setIsMassupdate(true)
|
225 |
+
->save();
|
226 |
+
}
|
227 |
+
$this->_getSession()->addSuccess($this->__('Total of %d menu settings were successfully updated.', count($menusettingIds)));
|
228 |
+
}
|
229 |
+
catch (Mage_Core_Exception $e){
|
230 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
231 |
+
}
|
232 |
+
catch (Exception $e) {
|
233 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('megamenu2')->__('There was an error updating menu settings.'));
|
234 |
+
Mage::logException($e);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
$this->_redirect('*/*/index');
|
238 |
+
}
|
239 |
+
/**
|
240 |
+
* get grid of products action
|
241 |
+
* @access public
|
242 |
+
* @return void
|
243 |
+
* @author Jason Lotzer
|
244 |
+
*/
|
245 |
+
public function productsAction(){
|
246 |
+
$this->_initMenusetting();
|
247 |
+
$this->loadLayout();
|
248 |
+
$this->getLayout()->getBlock('menusetting.edit.tab.product')
|
249 |
+
->setMenusettingProducts($this->getRequest()->getPost('menusetting_products', null));
|
250 |
+
$this->renderLayout();
|
251 |
+
}
|
252 |
+
/**
|
253 |
+
* get grid of products action
|
254 |
+
* @access public
|
255 |
+
* @return void
|
256 |
+
* @author Jason Lotzer
|
257 |
+
*/
|
258 |
+
public function productsgridAction(){
|
259 |
+
$this->_initMenusetting();
|
260 |
+
$this->loadLayout();
|
261 |
+
$this->getLayout()->getBlock('menusetting.edit.tab.product')
|
262 |
+
->setMenusettingProducts($this->getRequest()->getPost('menusetting_products', null));
|
263 |
+
$this->renderLayout();
|
264 |
+
}
|
265 |
+
/**
|
266 |
+
* get menuitems action
|
267 |
+
* @access public
|
268 |
+
* @return void
|
269 |
+
* @author Jason Lotzer
|
270 |
+
*/
|
271 |
+
public function menuitemsAction(){
|
272 |
+
$this->_initMenusetting();
|
273 |
+
$this->loadLayout();
|
274 |
+
$this->renderLayout();
|
275 |
+
}
|
276 |
+
/**
|
277 |
+
* get child menuitems action
|
278 |
+
* @access public
|
279 |
+
* @return void
|
280 |
+
* @author Jason Lotzer
|
281 |
+
*/
|
282 |
+
public function menuitemsJsonAction(){
|
283 |
+
$this->_initMenusetting();
|
284 |
+
$this->getResponse()->setBody(
|
285 |
+
$this->getLayout()->createBlock('megamenu2/adminhtml_menusetting_edit_tab_menuitem')
|
286 |
+
->getMenuitemChildrenJson($this->getRequest()->getParam('menuitem'))
|
287 |
+
);
|
288 |
+
}
|
289 |
+
/**
|
290 |
+
* export as csv - action
|
291 |
+
* @access public
|
292 |
+
* @return void
|
293 |
+
* @author Jason Lotzer
|
294 |
+
*/
|
295 |
+
public function exportCsvAction(){
|
296 |
+
$fileName = 'menusetting.csv';
|
297 |
+
$content = $this->getLayout()->createBlock('megamenu2/adminhtml_menusetting_grid')->getCsv();
|
298 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
299 |
+
}
|
300 |
+
/**
|
301 |
+
* export as MsExcel - action
|
302 |
+
* @access public
|
303 |
+
* @return void
|
304 |
+
* @author Jason Lotzer
|
305 |
+
*/
|
306 |
+
public function exportExcelAction(){
|
307 |
+
$fileName = 'menusetting.xls';
|
308 |
+
$content = $this->getLayout()->createBlock('megamenu2/adminhtml_menusetting_grid')->getExcelFile();
|
309 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
310 |
+
}
|
311 |
+
/**
|
312 |
+
* export as xml - action
|
313 |
+
* @access public
|
314 |
+
* @return void
|
315 |
+
* @author Jason Lotzer
|
316 |
+
*/
|
317 |
+
public function exportXmlAction(){
|
318 |
+
$fileName = 'menusetting.xml';
|
319 |
+
$content = $this->getLayout()->createBlock('megamenu2/adminhtml_menusetting_grid')->getXml();
|
320 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
321 |
+
}
|
322 |
+
}
|
app/code/community/JScriptz/MegaMenu2/data/jscriptz_megamenu2_setup/data-install-0.0.1.php
CHANGED
@@ -1,235 +1,273 @@
|
|
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(
|
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(
|
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&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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)->setLinktype(1)->setPath(1)->setLinkimage('/p/r/prod_icon.png')->setLevel(0)->setLinkclass('topnav-link')->setPosition(1)->setChildrenCount(0)->setStatus(1)->save();
|
32 |
+
Mage::getModel('megamenu2/menuitem')->load(3)->setLinktitle('jQuery Tabs')->setParentId(1)->setLinktype(2)->setPath(1)->setLevel(0)->setPosition(3)->setChildrenCount(0)->setStatus(1)->setLinkclass('topnav-link')->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)->setLinktype(2)->setLinktitle('Video Example')->setPath(1)->setLevel(0)->setPosition(4)->setChildrenCount(0)->setStatus(1)->setLinkclass('topnav-link')->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&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)->setLinktype(0)->setLinktitle('Link Example')->setLinkpath('http://www.gobingya.com')->setLinkclass('topnav-link')->setLinktarget('blank')->setPath(1)->setLevel(0)->setPosition(5)->setChildrenCount(0)->setStatus(1)->save();
|
236 |
+
Mage::getModel('megamenu2/menuitem')->load(6)->setParentId(1)->setLinktype(4)->setLinktitle('Featured')->setLinkpath('')->setLinkclass('topnav-link')->setLinktarget('self')->setPath(1)->setLevel(0)->setPosition(2)->setChildrenCount(0)->setStatus(1)->save();
|
237 |
+
Mage::getModel('megamenu2/menuitem')->load(7)->setParentId(1)->setLinktype(3)->setLinktitle('Contact Us')->setPath(1)->setLevel(0)->setPosition(6)->setChildrenCount(0)->setStatus(1)->save();
|
238 |
+
|
239 |
+
Mage::getModel('megamenu2/menusetting')->load(7)
|
240 |
+
->setMenutitle('Main Menu')
|
241 |
+
->setdisablemenu(0)
|
242 |
+
->save();
|
243 |
+
|
244 |
+
Mage::getModel('megamenu2/menuitem_menusetting')->load(8)
|
245 |
+
->setMenuitemId(2)
|
246 |
+
->setMenusettingId(1)
|
247 |
+
->setPosition(0)
|
248 |
+
->save();
|
249 |
+
Mage::getModel('megamenu2/menuitem_menusetting')->load(9)
|
250 |
+
->setMenuitemId(3)
|
251 |
+
->setMenusettingId(1)
|
252 |
+
->setPosition(1)
|
253 |
+
->save();
|
254 |
+
Mage::getModel('megamenu2/menuitem_menusetting')->load(10)
|
255 |
+
->setMenuitemId(4)
|
256 |
+
->setMenusettingId(1)
|
257 |
+
->setPosition(3)
|
258 |
+
->save();
|
259 |
+
Mage::getModel('megamenu2/menuitem_menusetting')->load(11)
|
260 |
+
->setMenuitemId(5)
|
261 |
+
->setMenusettingId(1)
|
262 |
+
->setPosition(4)
|
263 |
+
->save();
|
264 |
+
Mage::getModel('megamenu2/menuitem_menusetting')->load(12)
|
265 |
+
->setMenuitemId(6)
|
266 |
+
->setMenusettingId(1)
|
267 |
+
->setPosition(5)
|
268 |
+
->save();
|
269 |
+
Mage::getModel('megamenu2/menuitem_menusetting')->load(13)
|
270 |
+
->setMenuitemId(7)
|
271 |
+
->setMenusettingId(1)
|
272 |
+
->setPosition(2)
|
273 |
+
->save();
|
app/code/community/JScriptz/MegaMenu2/etc/adminhtml.xml
CHANGED
@@ -1,63 +1,74 @@
|
|
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 |
-
*
|
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 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
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 |
+
<megamenu2_options>
|
32 |
+
<title>Store MegaMenu2 System Settings Section</title>
|
33 |
+
</megamenu2_options>
|
34 |
+
</children>
|
35 |
+
</config>
|
36 |
+
</children>
|
37 |
+
</system>
|
38 |
+
<megamenu2 translate="title" module="megamenu2">
|
39 |
+
<title>MegaMenu2</title>
|
40 |
+
<children>
|
41 |
+
<menuitem translate="title" module="megamenu2">
|
42 |
+
<title>Menu Items</title>
|
43 |
+
</menuitem>
|
44 |
+
<!--<menusetting translate="title" module="megamenu2">
|
45 |
+
<title>Menu Settings</title>
|
46 |
+
</menusetting>-->
|
47 |
+
</children>
|
48 |
+
</megamenu2>
|
49 |
+
</children>
|
50 |
+
</admin>
|
51 |
+
</resources>
|
52 |
+
</acl>
|
53 |
+
<menu>
|
54 |
+
<megamenu2 translate="title" module="megamenu2">
|
55 |
+
<title>MegaMenu2</title>
|
56 |
+
<sort_order>85</sort_order>
|
57 |
+
<depends>
|
58 |
+
<module>JScriptz_MegaMenu2</module>
|
59 |
+
</depends>
|
60 |
+
<children>
|
61 |
+
<menuitem translate="title" module="megamenu2">
|
62 |
+
<title>Menu Items</title>
|
63 |
+
<action>adminhtml/MegaMenu2_menuitem</action>
|
64 |
+
<sort_order>0</sort_order>
|
65 |
+
</menuitem>
|
66 |
+
<!--<menusetting translate="title" module="megamenu2">
|
67 |
+
<title>Menu Settings</title>
|
68 |
+
<action>adminhtml/MegaMenu2_menusetting</action>
|
69 |
+
<sort_order>10</sort_order>
|
70 |
+
</menusetting>-->
|
71 |
+
</children>
|
72 |
+
</megamenu2>
|
73 |
+
</menu>
|
74 |
+
</config>
|
app/code/community/JScriptz/MegaMenu2/etc/config.xml
CHANGED
@@ -1,110 +1,171 @@
|
|
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 |
-
*
|
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.
|
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 |
-
<
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
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 |
-
<
|
55 |
-
<class>
|
56 |
-
<
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
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.1.2</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 |
+
<page>
|
36 |
+
<rewrite>
|
37 |
+
<html_topmenu>JScriptz_MegaMenu2_Block_Html_Topmenu</html_topmenu>
|
38 |
+
</rewrite>
|
39 |
+
</page>
|
40 |
+
<megamenu2>
|
41 |
+
<class>JScriptz_MegaMenu2_Block</class>
|
42 |
+
</megamenu2>
|
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_options>
|
55 |
+
<class>JScriptz_MegaMenu2_Model_SystemSettings</class>
|
56 |
+
<resourceModel>megamenu2_resource</resourceModel>
|
57 |
+
</megamenu2_options>
|
58 |
+
<megamenu2_resource>
|
59 |
+
<class>JScriptz_MegaMenu2_Model_Resource</class>
|
60 |
+
<entities>
|
61 |
+
<menuitem>
|
62 |
+
<table>megamenu2_menuitem</table>
|
63 |
+
</menuitem>
|
64 |
+
<menuitem_store>
|
65 |
+
<table>megamenu2_menuitem_store</table>
|
66 |
+
</menuitem_store>
|
67 |
+
<menusetting>
|
68 |
+
<table>megamenu2_menusetting</table>
|
69 |
+
</menusetting>
|
70 |
+
<menusetting_store>
|
71 |
+
<table>megamenu2_menusetting_store</table>
|
72 |
+
</menusetting_store>
|
73 |
+
<menuitem_menusetting>
|
74 |
+
<table>megamenu2_menuitem_menusetting</table>
|
75 |
+
</menuitem_menusetting>
|
76 |
+
<menusetting_menuitem>
|
77 |
+
<table>megamenu2_menuitem_menusetting</table>
|
78 |
+
</menusetting_menuitem>
|
79 |
+
<menuitem_product>
|
80 |
+
<table>megamenu2_menuitem_product</table>
|
81 |
+
</menuitem_product>
|
82 |
+
<menusetting_product>
|
83 |
+
<table>megamenu2_menusetting_product</table>
|
84 |
+
</menusetting_product>
|
85 |
+
</entities>
|
86 |
+
</megamenu2_resource>
|
87 |
+
</models>
|
88 |
+
</global>
|
89 |
+
<frontend>
|
90 |
+
<layout>
|
91 |
+
<updates>
|
92 |
+
<jscriptz_megamenu2>
|
93 |
+
<file>jscriptz_megamenu2.xml</file>
|
94 |
+
</jscriptz_megamenu2>
|
95 |
+
</updates>
|
96 |
+
</layout>
|
97 |
+
</frontend>
|
98 |
+
<adminhtml>
|
99 |
+
<layout>
|
100 |
+
<updates>
|
101 |
+
<jscriptz_megamenu2>
|
102 |
+
<file>jscriptz_megamenu2.xml</file>
|
103 |
+
</jscriptz_megamenu2>
|
104 |
+
</updates>
|
105 |
+
</layout>
|
106 |
+
<translate>
|
107 |
+
<modules>
|
108 |
+
<JScriptz_MegaMenu2>
|
109 |
+
<files>
|
110 |
+
<default>JScriptz_MegaMenu2.csv</default>
|
111 |
+
</files>
|
112 |
+
</JScriptz_MegaMenu2>
|
113 |
+
</modules>
|
114 |
+
</translate>
|
115 |
+
<events>
|
116 |
+
<core_block_abstract_prepare_layout_after>
|
117 |
+
<observers>
|
118 |
+
<menuitem>
|
119 |
+
<type>singleton</type>
|
120 |
+
<class>megamenu2/adminhtml_observer</class>
|
121 |
+
<method>addMenuitemBlock</method>
|
122 |
+
</menuitem>
|
123 |
+
</observers>
|
124 |
+
</core_block_abstract_prepare_layout_after>
|
125 |
+
<catalog_product_save_after>
|
126 |
+
<observers>
|
127 |
+
<menuitem>
|
128 |
+
<type>singleton</type>
|
129 |
+
<class>megamenu2/adminhtml_observer</class>
|
130 |
+
<method>saveMenuitemData</method>
|
131 |
+
</menuitem>
|
132 |
+
</observers>
|
133 |
+
</catalog_product_save_after>
|
134 |
+
</events>
|
135 |
+
<events>
|
136 |
+
<core_block_abstract_prepare_layout_after>
|
137 |
+
<observers>
|
138 |
+
<menusetting>
|
139 |
+
<type>singleton</type>
|
140 |
+
<class>megamenu2/adminhtml_observer</class>
|
141 |
+
<method>addMenusettingBlock</method>
|
142 |
+
</menusetting>
|
143 |
+
</observers>
|
144 |
+
</core_block_abstract_prepare_layout_after>
|
145 |
+
<catalog_product_save_after>
|
146 |
+
<observers>
|
147 |
+
<menusetting>
|
148 |
+
<type>singleton</type>
|
149 |
+
<class>megamenu2/adminhtml_observer</class>
|
150 |
+
<method>saveMenusettingData</method>
|
151 |
+
</menusetting>
|
152 |
+
</observers>
|
153 |
+
</catalog_product_save_after>
|
154 |
+
</events>
|
155 |
+
</adminhtml>
|
156 |
+
<admin>
|
157 |
+
<routers>
|
158 |
+
<adminhtml>
|
159 |
+
<args>
|
160 |
+
<modules>
|
161 |
+
<JScriptz_MegaMenu2 before="Mage_Adminhtml">JScriptz_MegaMenu2_Adminhtml</JScriptz_MegaMenu2>
|
162 |
+
</modules>
|
163 |
+
</args>
|
164 |
+
</adminhtml>
|
165 |
+
</routers>
|
166 |
+
</admin>
|
167 |
+
<default>
|
168 |
+
<megamenu2>
|
169 |
+
</megamenu2>
|
170 |
+
</default>
|
171 |
+
</config>
|
app/code/community/JScriptz/MegaMenu2/etc/system.xml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<tabs>
|
21 |
+
<megamenu2config translate="label" module="megamenu2">
|
22 |
+
<label>MegaMenu2 Config</label>
|
23 |
+
<sort_order>9999</sort_order>
|
24 |
+
</megamenu2config>
|
25 |
+
</tabs>
|
26 |
+
<sections>
|
27 |
+
<megamenu2_options translate="label" module="megamenu2">
|
28 |
+
<label>MegaMenu2 Config Options</label>
|
29 |
+
<tab>megamenu2config</tab>
|
30 |
+
<frontend_type>select</frontend_type>
|
31 |
+
<sort_order>1000</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<groups>
|
36 |
+
<options translate="label">
|
37 |
+
<label>Is Enabled</label>
|
38 |
+
<frontend_type>select</frontend_type>
|
39 |
+
<sort_order>1</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
<fields>
|
44 |
+
<megamenu2>
|
45 |
+
<label>Is Enabled</label>
|
46 |
+
<frontend_type>select</frontend_type>
|
47 |
+
<source_model>megamenu2/SystemSettings</source_model>
|
48 |
+
<sort_order>1</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
</megamenu2>
|
53 |
+
</fields>
|
54 |
+
</options>
|
55 |
+
</groups>
|
56 |
+
</megamenu2_options>
|
57 |
+
</sections>
|
58 |
+
</config>
|
app/code/community/JScriptz/MegaMenu2/sql/jscriptz_megamenu2_setup/install-0.0.1.php
CHANGED
@@ -1,93 +1,216 @@
|
|
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
|
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
|
22 |
-
|
23 |
-
|
24 |
-
$
|
25 |
-
|
26 |
-
->
|
27 |
-
|
28 |
-
'
|
29 |
-
'
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
->addColumn('
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
->addColumn('
|
42 |
-
), '
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
), 'Link
|
47 |
-
|
48 |
-
->addColumn('
|
49 |
-
), '
|
50 |
-
|
51 |
-
->addColumn('
|
52 |
-
'
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
'
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
->addColumn('
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
->
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
'
|
87 |
-
|
88 |
-
|
89 |
-
->
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @author Jason Lotzer
|
23 |
+
*/
|
24 |
+
$this->startSetup();
|
25 |
+
$table = $this->getConnection()
|
26 |
+
->newTable($this->getTable('megamenu2/menuitem'))
|
27 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
28 |
+
'identity' => true,
|
29 |
+
'nullable' => false,
|
30 |
+
'primary' => true,
|
31 |
+
), 'Menu Item ID')
|
32 |
+
->addColumn('linktype', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
33 |
+
'nullable' => false,
|
34 |
+
), 'Link Type')
|
35 |
+
->addColumn('linktitle', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
36 |
+
'nullable' => false,
|
37 |
+
), 'Link Title')
|
38 |
+
|
39 |
+
->addColumn('linkpath', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
40 |
+
), 'Link Path')
|
41 |
+
->addColumn('linkclass', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
42 |
+
), 'Link Class')
|
43 |
+
->addColumn('titletag', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
44 |
+
), 'Title Tag')
|
45 |
+
->addColumn('linktarget', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
46 |
+
), 'Link Target')
|
47 |
+
|
48 |
+
->addColumn('menuhtml', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
|
49 |
+
), 'Menu HTML')
|
50 |
+
|
51 |
+
->addColumn('linkimage', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
52 |
+
), 'Link Image')
|
53 |
+
|
54 |
+
->addColumn('status', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
55 |
+
), 'Status')
|
56 |
+
|
57 |
+
->addColumn('parent_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
58 |
+
'unsigned' => true,
|
59 |
+
), 'Parent id')
|
60 |
+
|
61 |
+
->addColumn('path', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
62 |
+
), 'Path')
|
63 |
+
|
64 |
+
->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
65 |
+
'unsigned' => true,
|
66 |
+
), 'Position')
|
67 |
+
|
68 |
+
->addColumn('level', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
69 |
+
'unsigned' => true,
|
70 |
+
), 'Level')
|
71 |
+
|
72 |
+
->addColumn('children_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
73 |
+
'unsigned' => true,
|
74 |
+
), 'Children count')
|
75 |
+
|
76 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
77 |
+
), 'Menu Item Creation Time')
|
78 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
79 |
+
), 'Menu Item Modification Time')
|
80 |
+
->setComment('Menu Item Table');
|
81 |
+
$this->getConnection()->createTable($table);
|
82 |
+
|
83 |
+
$table = $this->getConnection()
|
84 |
+
->newTable($this->getTable('megamenu2/menuitem_store'))
|
85 |
+
->addColumn('menuitem_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
86 |
+
'nullable' => false,
|
87 |
+
'primary' => true,
|
88 |
+
), 'Menu Item ID')
|
89 |
+
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
90 |
+
'unsigned' => true,
|
91 |
+
'nullable' => false,
|
92 |
+
'primary' => true,
|
93 |
+
), 'Store ID')
|
94 |
+
->addIndex($this->getIdxName('megamenu2/menuitem_store', array('store_id')), array('store_id'))
|
95 |
+
->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)
|
96 |
+
->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)
|
97 |
+
->setComment('Menu Items To Store Linkage Table');
|
98 |
+
$this->getConnection()->createTable($table);
|
99 |
+
$table = $this->getConnection()
|
100 |
+
->newTable($this->getTable('megamenu2/menusetting'))
|
101 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
102 |
+
'identity' => true,
|
103 |
+
'nullable' => false,
|
104 |
+
'primary' => true,
|
105 |
+
), 'Menu Setting ID')
|
106 |
+
->addColumn('menutitle', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
107 |
+
'nullable' => false,
|
108 |
+
), 'Menu Title')
|
109 |
+
|
110 |
+
->addColumn('disablemenu', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
111 |
+
), 'Disable Menu')
|
112 |
+
|
113 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
114 |
+
), 'Menu Setting Creation Time')
|
115 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
116 |
+
), 'Menu Setting Modification Time')
|
117 |
+
->setComment('Menu Setting Table');
|
118 |
+
$this->getConnection()->createTable($table);
|
119 |
+
|
120 |
+
$table = $this->getConnection()
|
121 |
+
->newTable($this->getTable('megamenu2/menusetting_store'))
|
122 |
+
->addColumn('menusetting_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
123 |
+
'nullable' => false,
|
124 |
+
'primary' => true,
|
125 |
+
), 'Menu Setting ID')
|
126 |
+
->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
127 |
+
'unsigned' => true,
|
128 |
+
'nullable' => false,
|
129 |
+
'primary' => true,
|
130 |
+
), 'Store ID')
|
131 |
+
->addIndex($this->getIdxName('megamenu2/menusetting_store', array('store_id')), array('store_id'))
|
132 |
+
->addForeignKey($this->getFkName('megamenu2/menusetting_store', 'menusetting_id', 'megamenu2/menusetting', 'entity_id'), 'menusetting_id', $this->getTable('megamenu2/menusetting'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
133 |
+
->addForeignKey($this->getFkName('megamenu2/menusetting_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)
|
134 |
+
->setComment('Menu Settings To Store Linkage Table');
|
135 |
+
$this->getConnection()->createTable($table);
|
136 |
+
$table = $this->getConnection()
|
137 |
+
->newTable($this->getTable('megamenu2/menuitem_product'))
|
138 |
+
->addColumn('rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
139 |
+
'unsigned' => true,
|
140 |
+
'identity' => true,
|
141 |
+
'nullable' => false,
|
142 |
+
'primary' => true,
|
143 |
+
), 'Category ID')
|
144 |
+
->addColumn('menuitem_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
145 |
+
'unsigned' => true,
|
146 |
+
'nullable' => false,
|
147 |
+
'default' => '0',
|
148 |
+
), 'Menu Item ID')
|
149 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
150 |
+
'unsigned' => true,
|
151 |
+
'nullable' => false,
|
152 |
+
'default' => '0',
|
153 |
+
), 'Product ID')
|
154 |
+
->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
155 |
+
'nullable' => false,
|
156 |
+
'default' => '0',
|
157 |
+
), 'Position')
|
158 |
+
->addIndex($this->getIdxName('megamenu2/menuitem_product', array('product_id')), array('product_id'))
|
159 |
+
->addForeignKey($this->getFkName('megamenu2/menuitem_product', '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)
|
160 |
+
->addForeignKey($this->getFkName('megamenu2/menuitem_product', 'product_id', 'catalog/product', 'entity_id'), 'product_id', $this->getTable('catalog/product'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
161 |
+
->setComment('Menu Item to Product Linkage Table');
|
162 |
+
$this->getConnection()->createTable($table);
|
163 |
+
$table = $this->getConnection()
|
164 |
+
->newTable($this->getTable('megamenu2/menusetting_product'))
|
165 |
+
->addColumn('rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
166 |
+
'unsigned' => true,
|
167 |
+
'identity' => true,
|
168 |
+
'nullable' => false,
|
169 |
+
'primary' => true,
|
170 |
+
), 'Category ID')
|
171 |
+
->addColumn('menusetting_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
172 |
+
'unsigned' => true,
|
173 |
+
'nullable' => false,
|
174 |
+
'default' => '0',
|
175 |
+
), 'Menu Setting ID')
|
176 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
177 |
+
'unsigned' => true,
|
178 |
+
'nullable' => false,
|
179 |
+
'default' => '0',
|
180 |
+
), 'Product ID')
|
181 |
+
->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
182 |
+
'nullable' => false,
|
183 |
+
'default' => '0',
|
184 |
+
), 'Position')
|
185 |
+
->addIndex($this->getIdxName('megamenu2/menusetting_product', array('product_id')), array('product_id'))
|
186 |
+
->addForeignKey($this->getFkName('megamenu2/menusetting_product', 'menusetting_id', 'megamenu2/menusetting', 'entity_id'), 'menusetting_id', $this->getTable('megamenu2/menusetting'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
187 |
+
->addForeignKey($this->getFkName('megamenu2/menusetting_product', 'product_id', 'catalog/product', 'entity_id'), 'product_id', $this->getTable('catalog/product'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
188 |
+
->setComment('Menu Setting to Product Linkage Table');
|
189 |
+
$this->getConnection()->createTable($table);
|
190 |
+
$table = $this->getConnection()
|
191 |
+
->newTable($this->getTable('megamenu2/menuitem_menusetting'))
|
192 |
+
->addColumn('rel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
193 |
+
'unsigned' => true,
|
194 |
+
'identity' => true,
|
195 |
+
'nullable' => false,
|
196 |
+
'primary' => true,
|
197 |
+
), 'Relation ID')
|
198 |
+
->addColumn('menuitem_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
199 |
+
'unsigned' => true,
|
200 |
+
'nullable' => false,
|
201 |
+
'default' => '0',
|
202 |
+
), 'Menu Item ID')
|
203 |
+
->addColumn('menusetting_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
204 |
+
'unsigned' => true,
|
205 |
+
'nullable' => false,
|
206 |
+
'default' => '0',
|
207 |
+
), 'Menu Setting ID')
|
208 |
+
->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
209 |
+
'nullable' => false,
|
210 |
+
'default' => '0',
|
211 |
+
), 'Position')
|
212 |
+
->addForeignKey($this->getFkName('megamenu2/menuitem_menusetting', '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)
|
213 |
+
->addForeignKey($this->getFkName('megamenu2/menuitem_menusetting', 'menusetting_id', 'megamenu2/menuitem', 'entity_id'), 'menusetting_id', $this->getTable('megamenu2/menusetting'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
214 |
+
->setComment('Menu Item to Menu Setting Linkage Table');
|
215 |
+
$this->getConnection()->createTable($table);
|
216 |
+
$this->endSetup();
|
app/design/adminhtml/default/default/layout/jscriptz_megamenu2.xml
CHANGED
@@ -1,32 +1,233 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
*
|
6 |
-
|
7 |
-
*
|
8 |
-
|
9 |
-
*
|
10 |
-
|
11 |
-
*
|
12 |
-
|
13 |
-
*
|
14 |
-
|
15 |
-
*
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<!--
|
4 |
+
/**
|
5 |
+
* JScriptz_MegaMenu2 extension
|
6 |
+
|
7 |
+
*
|
8 |
+
|
9 |
+
* NOTICE OF LICENSE
|
10 |
+
|
11 |
+
*
|
12 |
+
|
13 |
+
* This source file is subject to the MIT License
|
14 |
+
|
15 |
+
* that is bundled with this package in the file LICENSE.txt.
|
16 |
+
|
17 |
+
* It is also available through the world-wide-web at this URL:
|
18 |
+
|
19 |
+
* http://opensource.org/licenses/mit-license.php
|
20 |
+
|
21 |
+
*
|
22 |
+
|
23 |
+
* @category JScriptz
|
24 |
+
|
25 |
+
* @package JScriptz_MegaMenu2
|
26 |
+
|
27 |
+
* @copyright Copyright (c) 2013
|
28 |
+
|
29 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
30 |
+
*/
|
31 |
+
-->
|
32 |
+
|
33 |
+
<layout>
|
34 |
+
|
35 |
+
<!-- Menu Settings grid action -->
|
36 |
+
|
37 |
+
<adminhtml_megamenu2_menusetting_index>
|
38 |
+
|
39 |
+
<reference name="menu">
|
40 |
+
|
41 |
+
<action method="setActive">
|
42 |
+
|
43 |
+
<menupath>MegaMenu2/menusetting</menupath>
|
44 |
+
|
45 |
+
</action>
|
46 |
+
|
47 |
+
</reference>
|
48 |
+
|
49 |
+
<reference name="content">
|
50 |
+
|
51 |
+
<block type="megamenu2/adminhtml_menusetting" name="menusetting" />
|
52 |
+
|
53 |
+
</reference>
|
54 |
+
|
55 |
+
</adminhtml_megamenu2_menusetting_index>
|
56 |
+
|
57 |
+
<adminhtml_megamenu2_menusetting_grid>
|
58 |
+
|
59 |
+
<block type="core/text_list" name="root" output="toHtml">
|
60 |
+
|
61 |
+
<block type="megamenu2/adminhtml_menusetting_grid" name="menusetting_grid"/>
|
62 |
+
|
63 |
+
</block>
|
64 |
+
|
65 |
+
</adminhtml_megamenu2_menusetting_grid>
|
66 |
+
|
67 |
+
<!-- Menusetting add/edit action -->
|
68 |
+
|
69 |
+
<adminhtml_megamenu2_menusetting_edit>
|
70 |
+
|
71 |
+
<update handle="editor"/>
|
72 |
+
|
73 |
+
<reference name="menu">
|
74 |
+
|
75 |
+
<action method="setActive">
|
76 |
+
|
77 |
+
<menupath>MegaMenu2/menusetting</menupath>
|
78 |
+
|
79 |
+
</action>
|
80 |
+
|
81 |
+
</reference>
|
82 |
+
|
83 |
+
<reference name="content">
|
84 |
+
|
85 |
+
<block type="megamenu2/adminhtml_menusetting_edit" name="menusetting_edit"></block>
|
86 |
+
|
87 |
+
</reference>
|
88 |
+
|
89 |
+
<reference name="left">
|
90 |
+
|
91 |
+
<block type="megamenu2/adminhtml_menusetting_edit_tabs" name="menusetting_tabs"></block>
|
92 |
+
|
93 |
+
</reference>
|
94 |
+
|
95 |
+
</adminhtml_megamenu2_menusetting_edit>
|
96 |
+
|
97 |
+
<adminhtml_megamenu2_menusetting_catalog_product_menusettings>
|
98 |
+
|
99 |
+
<block type="core/text_list" name="root" output="toHtml">
|
100 |
+
|
101 |
+
<block type="megamenu2/adminhtml_catalog_product_edit_tab_menusetting" name="product.edit.tab.menusetting"/>
|
102 |
+
|
103 |
+
<block type="adminhtml/widget_grid_serializer" name="menusetting_grid_serializer">
|
104 |
+
|
105 |
+
<reference name="menusetting_grid_serializer">
|
106 |
+
|
107 |
+
<action method="initSerializerBlock">
|
108 |
+
|
109 |
+
<grid_block_name>product.edit.tab.menusetting</grid_block_name>
|
110 |
+
|
111 |
+
<data_callback>getSelectedMenusettings</data_callback>
|
112 |
+
|
113 |
+
<hidden_input_name>menusettings</hidden_input_name>
|
114 |
+
|
115 |
+
<reload_param_name>product_menusettings</reload_param_name>
|
116 |
+
|
117 |
+
</action>
|
118 |
+
|
119 |
+
<action method="addColumnInputName">
|
120 |
+
|
121 |
+
<input_name>position</input_name>
|
122 |
+
|
123 |
+
</action>
|
124 |
+
|
125 |
+
</reference>
|
126 |
+
|
127 |
+
</block>
|
128 |
+
|
129 |
+
</block>
|
130 |
+
|
131 |
+
</adminhtml_megamenu2_menusetting_catalog_product_menusettings>
|
132 |
+
|
133 |
+
<adminhtml_megamenu2_menusetting_catalog_product_menusettingsgrid>
|
134 |
+
|
135 |
+
<block type="core/text_list" name="root" output="toHtml">
|
136 |
+
|
137 |
+
<block type="megamenu2/adminhtml_catalog_product_edit_tab_menusetting" name="product.edit.tab.menusetting"/>
|
138 |
+
|
139 |
+
</block>
|
140 |
+
|
141 |
+
</adminhtml_megamenu2_menusetting_catalog_product_menusettingsgrid>
|
142 |
+
|
143 |
+
<adminhtml_megamenu2_menusetting_products>
|
144 |
+
|
145 |
+
<block type="core/text_list" name="root" output="toHtml">
|
146 |
+
|
147 |
+
<block type="megamenu2/adminhtml_menusetting_edit_tab_product" name="menusetting.edit.tab.product"/>
|
148 |
+
|
149 |
+
<block type="adminhtml/widget_grid_serializer" name="product_grid_serializer">
|
150 |
+
|
151 |
+
<reference name="product_grid_serializer">
|
152 |
+
|
153 |
+
<action method="initSerializerBlock">
|
154 |
+
|
155 |
+
<grid_block_name>menusetting.edit.tab.product</grid_block_name>
|
156 |
+
|
157 |
+
<data_callback>getSelectedProducts</data_callback>
|
158 |
+
|
159 |
+
<hidden_input_name>products</hidden_input_name>
|
160 |
+
|
161 |
+
<reload_param_name>menusetting_products</reload_param_name>
|
162 |
+
|
163 |
+
</action>
|
164 |
+
|
165 |
+
<action method="addColumnInputName">
|
166 |
+
|
167 |
+
<input_name>position</input_name>
|
168 |
+
|
169 |
+
</action>
|
170 |
+
|
171 |
+
</reference>
|
172 |
+
|
173 |
+
</block>
|
174 |
+
|
175 |
+
</block>
|
176 |
+
|
177 |
+
</adminhtml_megamenu2_menusetting_products>
|
178 |
+
|
179 |
+
<adminhtml_megamenu2_menusetting_productsgrid>
|
180 |
+
|
181 |
+
<block type="core/text_list" name="root" output="toHtml">
|
182 |
+
|
183 |
+
<block type="megamenu2/adminhtml_menusetting_edit_tab_product" name="menusetting.edit.tab.product"/>
|
184 |
+
|
185 |
+
</block>
|
186 |
+
|
187 |
+
</adminhtml_megamenu2_menusetting_productsgrid>
|
188 |
+
|
189 |
+
<adminhtml_megamenu2_menuitem_edit>
|
190 |
+
|
191 |
+
<update handle="editor"/>
|
192 |
+
|
193 |
+
<reference name="left">
|
194 |
+
|
195 |
+
<block name="menuitem.tree" type="megamenu2/adminhtml_menuitem_tree" />
|
196 |
+
|
197 |
+
</reference>
|
198 |
+
|
199 |
+
<reference name="content">
|
200 |
+
|
201 |
+
<block name="menuitem.edit" type="megamenu2/adminhtml_menuitem_edit" template="jscriptz_megamenu2/menuitem/edit.phtml" />
|
202 |
+
|
203 |
+
</reference>
|
204 |
+
|
205 |
+
<reference name="js">
|
206 |
+
|
207 |
+
<block type="core/template" template="catalog/wysiwyg/js.phtml" name="catalog.wysiwyg.js" />
|
208 |
+
|
209 |
+
</reference>
|
210 |
+
|
211 |
+
</adminhtml_megamenu2_menuitem_edit>
|
212 |
+
|
213 |
+
<adminhtml_megamenu2_menuitem_catalog_product_menuitems>
|
214 |
+
|
215 |
+
<block type="core/text_list" name="root" output="toHtml">
|
216 |
+
|
217 |
+
<block type="megamenu2/adminhtml_catalog_product_edit_tab_menuitem" name="catalog.product.edit.tab.menuitems"/>
|
218 |
+
|
219 |
+
</block>
|
220 |
+
|
221 |
+
</adminhtml_megamenu2_menuitem_catalog_product_menuitems>
|
222 |
+
|
223 |
+
<adminhtml_megamenu2_menusetting_menuitems>
|
224 |
+
|
225 |
+
<block type="core/text_list" name="root" output="toHtml">
|
226 |
+
|
227 |
+
<block type="megamenu2/adminhtml_menusetting_edit_tab_menuitem" name="menusetting.edit.tab.menuitem"/>
|
228 |
+
|
229 |
+
</block>
|
230 |
+
|
231 |
+
</adminhtml_megamenu2_menusetting_menuitems>
|
232 |
+
|
233 |
+
</layout>
|
app/design/adminhtml/default/default/template/jscriptz_megamenu2/catalog/product/edit/tab/menuitem.phtml
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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="entry-edit">
|
19 |
+
<div class="entry-edit-head">
|
20 |
+
<h4 class="icon-head head-edit-form fieldset-legend">
|
21 |
+
<?php echo Mage::helper('megamenu2')->__('Menu Items') ?>
|
22 |
+
</h4>
|
23 |
+
</div>
|
24 |
+
<fieldset id="grop_fields">
|
25 |
+
<input type="hidden" name="menuitem_ids" id="product_menuitems" value="<?php echo $this->getIdsString() ?>">
|
26 |
+
<div id="product-menuitems" class="tree"></div>
|
27 |
+
</fieldset>
|
28 |
+
</div>
|
29 |
+
<?php if($this->getRootNode() && $this->getRootNode()->hasChildren()): ?>
|
30 |
+
<script type="text/javascript">
|
31 |
+
Ext.EventManager.onDocumentReady(function() {
|
32 |
+
var menuitemLoader = new Ext.tree.TreeLoader({
|
33 |
+
dataUrl: '<?php echo $this->getLoadTreeUrl()?>'
|
34 |
+
});
|
35 |
+
|
36 |
+
menuitemLoader.createNode = function(config) {
|
37 |
+
config.uiProvider = Ext.tree.CheckboxNodeUI;
|
38 |
+
var node;
|
39 |
+
if (config.children && !config.children.length) {
|
40 |
+
delete(config.children);
|
41 |
+
node = new Ext.tree.AsyncTreeNode(config);
|
42 |
+
}
|
43 |
+
else {
|
44 |
+
node = new Ext.tree.TreeNode(config);
|
45 |
+
}
|
46 |
+
return node;
|
47 |
+
};
|
48 |
+
menuitemLoader.on("beforeload", function(treeLoader, node) {
|
49 |
+
treeLoader.baseParams.menuitem = node.attributes.id;
|
50 |
+
});
|
51 |
+
menuitemLoader.on("load", function(treeLoader, node, config) {
|
52 |
+
varienWindowOnload();
|
53 |
+
});
|
54 |
+
var tree = new Ext.tree.TreePanel('product-menuitems', {
|
55 |
+
animate:true,
|
56 |
+
loader: menuitemLoader,
|
57 |
+
enableDD:false,
|
58 |
+
containerScroll: true,
|
59 |
+
rootUIProvider: Ext.tree.CheckboxNodeUI,
|
60 |
+
selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
|
61 |
+
rootVisible: '<?php echo $this->getRootNode()->getIsVisible() ?>'
|
62 |
+
});
|
63 |
+
tree.on('check', function(node) {
|
64 |
+
if(node.attributes.checked) {
|
65 |
+
menuitemAdd(node.id);
|
66 |
+
}
|
67 |
+
else {
|
68 |
+
menuitemRemove(node.id);
|
69 |
+
}
|
70 |
+
varienElementMethods.setHasChanges(node.getUI().checkbox);
|
71 |
+
}, tree);
|
72 |
+
|
73 |
+
var root = new Ext.tree.TreeNode({
|
74 |
+
text: '<?php echo $this->jsQuoteEscape($this->getRootNode()->getName()) ?>',
|
75 |
+
draggable:false,
|
76 |
+
checked:'<?php echo $this->getRootNode()->getChecked() ?>',
|
77 |
+
id:'<?php echo $this->getRootNode()->getId() ?>',
|
78 |
+
disabled: <?php echo ($this->getRootNode()->getDisabled() ? 'true' : 'false') ?>,
|
79 |
+
uiProvider: Ext.tree.CheckboxNodeUI
|
80 |
+
});
|
81 |
+
tree.setRootNode(root);
|
82 |
+
bildMenuitemTree(root, <?php echo $this->getTreeJson() ?>);
|
83 |
+
tree.addListener('click', menuitemClick.createDelegate(this));
|
84 |
+
// render the tree
|
85 |
+
tree.render();
|
86 |
+
root.expand();
|
87 |
+
});
|
88 |
+
function bildMenuitemTree(parent, config){
|
89 |
+
if (!config) {
|
90 |
+
return null;
|
91 |
+
}
|
92 |
+
if (parent && config && config.length){
|
93 |
+
for (var i = 0; i < config.length; i++){
|
94 |
+
config[i].uiProvider = Ext.tree.CheckboxNodeUI;
|
95 |
+
var node;
|
96 |
+
var _node = Object.clone(config[i]);
|
97 |
+
if (_node.children && !_node.children.length) {
|
98 |
+
delete(_node.children);
|
99 |
+
node = new Ext.tree.AsyncTreeNode(_node);
|
100 |
+
}
|
101 |
+
else {
|
102 |
+
node = new Ext.tree.TreeNode(config[i]);
|
103 |
+
}
|
104 |
+
parent.appendChild(node);
|
105 |
+
node.loader = node.getOwnerTree().loader;
|
106 |
+
if(config[i].children){
|
107 |
+
bildMenuitemTree(node, config[i].children);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
function menuitemClick(node, e){
|
113 |
+
if (node.disabled) {
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
node.getUI().check(!node.getUI().checked());
|
117 |
+
varienElementMethods.setHasChanges(Event.element(e), e);
|
118 |
+
};
|
119 |
+
function menuitemAdd(id) {
|
120 |
+
var ids = $('product_menuitems').value.split(',');
|
121 |
+
ids.push(id);
|
122 |
+
$('product_menuitems').value = ids.join(',');
|
123 |
+
}
|
124 |
+
function menuitemRemove(id) {
|
125 |
+
var ids = $('product_menuitems').value.split(',');
|
126 |
+
while (-1 != ids.indexOf(id)) {
|
127 |
+
ids.splice(ids.indexOf(id), 1);
|
128 |
+
}
|
129 |
+
$('product_menuitems').value = ids.join(',');
|
130 |
+
}
|
131 |
+
</script>
|
132 |
+
<?php endif; ?>
|
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,275 @@
|
|
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 |
-
|
39 |
-
|
40 |
-
</
|
41 |
-
<
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
this.
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
var
|
123 |
-
var
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
var
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
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 |
+
<input type="hidden" name="menuitem_products" id="in_menuitem_products" value="" />
|
39 |
+
<input type="hidden" name="menuitem_menusettings" id="in_menuitem_menusettings" value="" />
|
40 |
+
</div>
|
41 |
+
<div id="menuitem_tab_content"></div>
|
42 |
+
</form>
|
43 |
+
<script type="text/javascript">
|
44 |
+
//<![CDATA[
|
45 |
+
menuitemForm = new varienForm('menuitem_edit_form');
|
46 |
+
menuitemForm.submit= function (url) {
|
47 |
+
this.errorSections = $H({});
|
48 |
+
this.canShowError = true;
|
49 |
+
this.submitUrl = url;
|
50 |
+
if (this.validator && this.validator.validate()) {
|
51 |
+
if(this.validationUrl){
|
52 |
+
this._validate();
|
53 |
+
}
|
54 |
+
else{
|
55 |
+
if (this.isSubmitted) {
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
this.isSubmitted = true;
|
59 |
+
this._submit();
|
60 |
+
}
|
61 |
+
displayLoadingMask();
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
return false;
|
65 |
+
};
|
66 |
+
menuitemForm.refreshPath = function () {
|
67 |
+
menuitemId = this.getMenuitemId();
|
68 |
+
if (!menuitemId) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
var refreshPathSuccess = function(transport) {
|
72 |
+
if (transport.responseText.isJSON()) {
|
73 |
+
response = transport.responseText.evalJSON()
|
74 |
+
if (response.error) {
|
75 |
+
alert(response.message);
|
76 |
+
}
|
77 |
+
else {
|
78 |
+
if (menuitemForm.getMenuitemId() == response['id']) {
|
79 |
+
menuitemForm.setMenuitemPath(response['path']);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
};
|
84 |
+
new Ajax.Request(
|
85 |
+
'<?php echo $this->getRefreshPathUrl() ?>',
|
86 |
+
{
|
87 |
+
method: 'POST',
|
88 |
+
evalScripts: true,
|
89 |
+
onSuccess: refreshPathSuccess
|
90 |
+
}
|
91 |
+
);
|
92 |
+
};
|
93 |
+
|
94 |
+
menuitemForm.getMenuitemId = function () {
|
95 |
+
collection = $(this.formId).getInputs('hidden','menuitem[id]');
|
96 |
+
if (collection.size() > 0) {
|
97 |
+
return collection.first().value;
|
98 |
+
}
|
99 |
+
return false;
|
100 |
+
};
|
101 |
+
menuitemForm.setMenuitemPath = function (path) {
|
102 |
+
collection = $(this.formId).getInputs('hidden','menuitem[path]');
|
103 |
+
if (collection.size() > 0) {
|
104 |
+
return collection.first().value = path;
|
105 |
+
}
|
106 |
+
};
|
107 |
+
function menuitemSubmit(url, useAjax) {
|
108 |
+
var activeTab = $('active_tab_id');
|
109 |
+
if (activeTab) {
|
110 |
+
if (activeTab.tabsJsObject && activeTab.tabsJsObject.activeTab) {
|
111 |
+
activeTab.value = activeTab.tabsJsObject.activeTab.id;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
var params = {};
|
115 |
+
var fields = $('menuitem_edit_form').getElementsBySelector('input', 'select');
|
116 |
+
for(var i=0;i<fields.length;i++){
|
117 |
+
if (!fields[i].name) {
|
118 |
+
continue;
|
119 |
+
}
|
120 |
+
params[fields[i].name] = fields[i].getValue();
|
121 |
+
}
|
122 |
+
var menuitemId = params['menuitem[id]'] ? params['menuitem[id]'] : 0;
|
123 |
+
var isCreating = menuitemId == 0;
|
124 |
+
var path = params['menuitem[path]'].split('/');
|
125 |
+
var parentId = path.pop();
|
126 |
+
if (parentId == menuitemId) {
|
127 |
+
parentId = path.pop();
|
128 |
+
}
|
129 |
+
if (isCreating) {
|
130 |
+
if (!tree.currentNodeId) {
|
131 |
+
tree.currentNodeId = parentId;
|
132 |
+
}
|
133 |
+
tree.addNodeTo = parentId;
|
134 |
+
}
|
135 |
+
else {
|
136 |
+
var currentNode = tree.getNodeById(menuitemId);
|
137 |
+
var oldClass = 'active-category';
|
138 |
+
var newClass = 'active-category';
|
139 |
+
if (currentNode) {
|
140 |
+
if (parseInt(params['menuitem[status]'])) {
|
141 |
+
var oldClass = 'no-active-category';
|
142 |
+
var newClass = 'active-category';
|
143 |
+
}
|
144 |
+
else {
|
145 |
+
var oldClass = 'active-category';
|
146 |
+
var newClass = 'no-active-category';
|
147 |
+
}
|
148 |
+
Element.removeClassName(currentNode.ui.wrap.firstChild, oldClass);
|
149 |
+
Element.addClassName(currentNode.ui.wrap.firstChild, newClass);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
menuitemForm.submit();
|
153 |
+
}
|
154 |
+
<?php if(($block = $this->getLayout()->getBlock('menuitem.product.grid')) && ($_gridJsObject=$block->getJsObjectName())): ?>
|
155 |
+
var menuitemProducts = $H(<?php echo $this->getProductsJson() ?>);
|
156 |
+
$('in_menuitem_products').value = menuitemProducts.toQueryString();
|
157 |
+
function registerMenuitemProduct(grid, element, checked){
|
158 |
+
if(checked){
|
159 |
+
if(element.positionElement){
|
160 |
+
element.positionElement.disabled = false;
|
161 |
+
menuitemProducts.set(element.value, element.positionElement.value);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
else{
|
165 |
+
if(element.positionElement){
|
166 |
+
element.positionElement.disabled = true;
|
167 |
+
}
|
168 |
+
menuitemProducts.unset(element.value);
|
169 |
+
}
|
170 |
+
$('in_menuitem_products').value = menuitemProducts.toQueryString();
|
171 |
+
grid.reloadParams = {'selected_products[]':menuitemProducts.keys()};
|
172 |
+
}
|
173 |
+
function menuitemProductRowClick(grid, event){
|
174 |
+
var trElement = Event.findElement(event, 'tr');
|
175 |
+
var isInput = Event.element(event).tagName == 'INPUT';
|
176 |
+
if(trElement){
|
177 |
+
var checkbox = Element.getElementsBySelector(trElement, 'input');
|
178 |
+
if(checkbox[0]){
|
179 |
+
var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
|
180 |
+
<?php echo $_gridJsObject ?>.setCheckboxChecked(checkbox[0], checked);
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
function positionChange(event){
|
185 |
+
var element = Event.element(event);
|
186 |
+
if(element && element.checkboxElement && element.checkboxElement.checked){
|
187 |
+
menuitemProducts.set(element.checkboxElement.value, element.value);
|
188 |
+
$('in_menuitem_products').value = menuitemProducts.toQueryString();
|
189 |
+
}
|
190 |
+
}
|
191 |
+
var tabIndex = 1000;
|
192 |
+
function menuitemProductRowInit(grid, row){
|
193 |
+
var checkbox = $(row).getElementsByClassName('checkbox')[0];
|
194 |
+
var position = $(row).getElementsByClassName('input-text')[0];
|
195 |
+
if(checkbox && position){
|
196 |
+
checkbox.positionElement = position;
|
197 |
+
position.checkboxElement = checkbox;
|
198 |
+
position.disabled = !checkbox.checked;
|
199 |
+
position.tabIndex = tabIndex++;
|
200 |
+
Event.observe(position,'keyup',positionChange);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
<?php echo $_gridJsObject ?>.rowClickCallback = menuitemProductRowClick;
|
204 |
+
<?php echo $_gridJsObject ?>.initRowCallback = menuitemProductRowInit;
|
205 |
+
<?php echo $_gridJsObject ?>.checkboxCheckCallback = registerMenuitemProduct;
|
206 |
+
<?php echo $_gridJsObject ?>.rows.each(function(row){
|
207 |
+
menuitemProductRowInit(<?php echo $_gridJsObject ?>, row)
|
208 |
+
});
|
209 |
+
<?php endif; ?>
|
210 |
+
<?php if(($block = $this->getLayout()->getBlock('menuitem.menusetting.grid')) && ($_gridJsObject=$block->getJsObjectName())): ?>
|
211 |
+
var menuitemMenusettings = $H(<?php echo $this->getMenusettingsJson() ?>);
|
212 |
+
$('in_menuitem_menusettings').value = menuitemMenusettings.toQueryString();
|
213 |
+
function registerMenuitemMenusetting(grid, element, checked){
|
214 |
+
if(checked){
|
215 |
+
if(element.positionElement){
|
216 |
+
element.positionElement.disabled = false;
|
217 |
+
menuitemMenusettings.set(element.value, element.positionElement.value);
|
218 |
+
}
|
219 |
+
}
|
220 |
+
else{
|
221 |
+
if(element.positionElement){
|
222 |
+
element.positionElement.disabled = true;
|
223 |
+
}
|
224 |
+
menuitemMenusettings.unset(element.value);
|
225 |
+
}
|
226 |
+
$('in_menuitem_menusettings').value = menuitemMenusettings.toQueryString();
|
227 |
+
grid.reloadParams = {'selected_menusettings[]':menuitemMenusettings.keys()
|
228 |
+
};
|
229 |
+
}
|
230 |
+
function menuitemMenusettingRowClick(grid, event){
|
231 |
+
var trElement = Event.findElement(event, 'tr');
|
232 |
+
var isInput = Event.element(event).tagName == 'INPUT';
|
233 |
+
if(trElement){
|
234 |
+
var checkbox = Element.getElementsBySelector(trElement, 'input');
|
235 |
+
if(checkbox[0]){
|
236 |
+
var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
|
237 |
+
<?php echo $_gridJsObject ?>.setCheckboxChecked(checkbox[0], checked);
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
function positionMenusettingChange(event){
|
242 |
+
var element = Event.element(event);
|
243 |
+
if(element && element.checkboxElement && element.checkboxElement.checked){
|
244 |
+
menuitemMenusettings.set(element.checkboxElement.value, element.value);
|
245 |
+
$('in_menuitem_menusettings').value = menuitemMenusettings.toQueryString();
|
246 |
+
}
|
247 |
+
}
|
248 |
+
var tabIndex = 1000;
|
249 |
+
function menuitemMenusettingRowInit(grid, row){
|
250 |
+
var checkbox = $(row).getElementsByClassName('checkbox')[0];
|
251 |
+
var position = $(row).getElementsByClassName('input-text')[0];
|
252 |
+
if(checkbox && position){
|
253 |
+
checkbox.positionElement = position;
|
254 |
+
position.checkboxElement = checkbox;
|
255 |
+
position.disabled = !checkbox.checked;
|
256 |
+
position.tabIndex = tabIndex++;
|
257 |
+
Event.observe(position,'keyup',positionMenusettingChange);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
<?php echo $_gridJsObject ?>.rowClickCallback = menuitemMenusettingRowClick;
|
261 |
+
<?php echo $_gridJsObject ?>.initRowCallback = menuitemMenusettingRowInit;
|
262 |
+
<?php echo $_gridJsObject ?>.checkboxCheckCallback = registerMenuitemMenusetting;
|
263 |
+
<?php echo $_gridJsObject ?>.rows.each(function(row){
|
264 |
+
menuitemMenusettingRowInit(<?php echo $_gridJsObject ?>, row)
|
265 |
+
});
|
266 |
+
<?php endif; ?>
|
267 |
+
<?php if($this->isAjax() && ($block = $this->getLayout()->getBlock('tabs')) && ($_tabsJsObject=$block->getJsObjectName())): ?>
|
268 |
+
<?php echo $_tabsJsObject ?>.moveTabContentInDest();
|
269 |
+
if (<?php echo $_tabsJsObject ?>.activeTab) {
|
270 |
+
$('active_tab_id').value = <?php echo $_tabsJsObject ?>.activeTab.id;
|
271 |
+
}
|
272 |
+
$('active_tab_id').tabsJsObject = <?php echo $_tabsJsObject ?>;
|
273 |
+
<?php endif; ?>
|
274 |
+
//]]>
|
275 |
+
</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/adminhtml/default/default/template/jscriptz_megamenu2/menusetting/edit/tab/menuitem.phtml
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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="entry-edit">
|
19 |
+
<div class="entry-edit-head">
|
20 |
+
<h4 class="icon-head head-edit-form fieldset-legend">
|
21 |
+
<?php echo Mage::helper('megamenu2')->__('Menu Items') ?>
|
22 |
+
</h4>
|
23 |
+
</div>
|
24 |
+
<fieldset id="grop_fields">
|
25 |
+
<input type="hidden" name="menuitem_ids" id="menusetting_menuitems" value="<?php echo $this->getIdsString() ?>">
|
26 |
+
<div id="menusetting-menuitems" class="tree"></div>
|
27 |
+
</fieldset>
|
28 |
+
</div>
|
29 |
+
<?php if($this->getRootNode() && $this->getRootNode()->hasChildren()): ?>
|
30 |
+
<script type="text/javascript">
|
31 |
+
Ext.EventManager.onDocumentReady(function() {
|
32 |
+
var menuitemLoader = new Ext.tree.TreeLoader({
|
33 |
+
dataUrl: '<?php echo $this->getLoadTreeUrl()?>'
|
34 |
+
});
|
35 |
+
menuitemLoader.createNode = function(config) {
|
36 |
+
config.uiProvider = Ext.tree.CheckboxNodeUI;
|
37 |
+
var node;
|
38 |
+
if (config.children && !config.children.length) {
|
39 |
+
delete(config.children);
|
40 |
+
node = new Ext.tree.AsyncTreeNode(config);
|
41 |
+
}
|
42 |
+
else {
|
43 |
+
node = new Ext.tree.TreeNode(config);
|
44 |
+
}
|
45 |
+
return node;
|
46 |
+
};
|
47 |
+
menuitemLoader.on("beforeload", function(treeLoader, node) {
|
48 |
+
treeLoader.baseParams.menuitem = node.attributes.id;
|
49 |
+
});
|
50 |
+
|
51 |
+
menuitemLoader.on("load", function(treeLoader, node, config) {
|
52 |
+
varienWindowOnload();
|
53 |
+
});
|
54 |
+
var tree = new Ext.tree.TreePanel('menusetting-menuitems', {
|
55 |
+
animate:true,
|
56 |
+
loader: menuitemLoader,
|
57 |
+
enableDD:false,
|
58 |
+
containerScroll: true,
|
59 |
+
rootUIProvider: Ext.tree.CheckboxNodeUI,
|
60 |
+
selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
|
61 |
+
rootVisible: '<?php echo $this->getRootNode()->getIsVisible() ?>'
|
62 |
+
});
|
63 |
+
tree.on('check', function(node) {
|
64 |
+
if(node.attributes.checked) {
|
65 |
+
menuitemAdd(node.id);
|
66 |
+
} else {
|
67 |
+
menuitemRemove(node.id);
|
68 |
+
}
|
69 |
+
varienElementMethods.setHasChanges(node.getUI().checkbox);
|
70 |
+
}, tree);
|
71 |
+
var root = new Ext.tree.TreeNode({
|
72 |
+
text: '<?php echo $this->jsQuoteEscape($this->getRootNode()->getLinktitle()) ?>',
|
73 |
+
draggable:false,
|
74 |
+
checked:'<?php echo $this->getRootNode()->getChecked() ?>',
|
75 |
+
id:'<?php echo $this->getRootNode()->getId() ?>',
|
76 |
+
disabled: <?php echo ($this->getRootNode()->getDisabled() ? 'true' : 'false') ?>,
|
77 |
+
uiProvider: Ext.tree.CheckboxNodeUI
|
78 |
+
});
|
79 |
+
tree.setRootNode(root);
|
80 |
+
bildMenuitemTree(root, <?php echo $this->getTreeJson() ?>);
|
81 |
+
tree.addListener('click', menuitemClick.createDelegate(this));
|
82 |
+
tree.render();
|
83 |
+
root.expand();
|
84 |
+
});
|
85 |
+
function bildMenuitemTree(parent, config){
|
86 |
+
if (!config) {
|
87 |
+
return null;
|
88 |
+
}
|
89 |
+
if (parent && config && config.length){
|
90 |
+
for (var i = 0; i < config.length; i++){
|
91 |
+
config[i].uiProvider = Ext.tree.CheckboxNodeUI;
|
92 |
+
var node;
|
93 |
+
var _node = Object.clone(config[i]);
|
94 |
+
if (_node.children && !_node.children.length) {
|
95 |
+
delete(_node.children);
|
96 |
+
node = new Ext.tree.AsyncTreeNode(_node);
|
97 |
+
|
98 |
+
}
|
99 |
+
else {
|
100 |
+
node = new Ext.tree.TreeNode(config[i]);
|
101 |
+
}
|
102 |
+
parent.appendChild(node);
|
103 |
+
node.loader = node.getOwnerTree().loader;
|
104 |
+
if(config[i].children){
|
105 |
+
bildMenuitemTree(node, config[i].children);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
function menuitemClick(node, e){
|
111 |
+
if (node.disabled) {
|
112 |
+
return;
|
113 |
+
}
|
114 |
+
node.getUI().check(!node.getUI().checked());
|
115 |
+
varienElementMethods.setHasChanges(Event.element(e), e);
|
116 |
+
};
|
117 |
+
function menuitemAdd(id) {
|
118 |
+
var ids = $('menusetting_menuitems').value.split(',');
|
119 |
+
ids.push(id);
|
120 |
+
$('menusetting_menuitems').value = ids.join(',');
|
121 |
+
}
|
122 |
+
function menuitemRemove(id) {
|
123 |
+
var ids = $('menusetting_menuitems').value.split(',');
|
124 |
+
while (-1 != ids.indexOf(id)) {
|
125 |
+
ids.splice(ids.indexOf(id), 1);
|
126 |
+
}
|
127 |
+
$('menusetting_menuitems').value = ids.join(',');
|
128 |
+
}
|
129 |
+
</script>
|
130 |
+
<?php endif; ?>
|
app/design/frontend/base/default/layout/jscriptz_megamenu2.xml
CHANGED
@@ -1,32 +1,33 @@
|
|
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 |
-
|
29 |
-
<action method="setTemplate"><template>jscriptz/html/topmenu.phtml</template></action>
|
30 |
-
</reference>
|
31 |
-
|
|
|
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" ifconfig="megamenu2_options/options/megamenu2"><type>skin_js</type><name>js/JScriptz/mgmenu.js</name></action>
|
23 |
+
<action method="addItem" ifconfig="megamenu2_options/options/megamenu2"><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" ifconfig="megamenu2_options/options/megamenu2"><template>jscriptz/html/topmenu.phtml</template></action>
|
27 |
+
</reference>
|
28 |
+
<reference name="top.menu">
|
29 |
+
<action method="setTemplate" ifconfig="megamenu2_options/options/megamenu2"><template>jscriptz/html/topmenu.phtml</template></action>
|
30 |
+
</reference>
|
31 |
+
|
32 |
+
</default>
|
33 |
</layout>
|
app/design/frontend/base/default/template/jscriptz/html/topmenu.phtml
CHANGED
@@ -31,8 +31,23 @@
|
|
31 |
* @see JScriptz_MegaMenu2_Block_Html_Topmenu extends Mage_Page_Block_Html_Topmenu
|
32 |
*/
|
33 |
?>
|
34 |
-
<?php
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
<script>
|
37 |
$.noConflict();
|
38 |
jQuery( document ).ready(function( $ ) {
|
@@ -51,7 +66,7 @@ jQuery( document ).ready(function( $ ) {
|
|
51 |
</script>
|
52 |
|
53 |
<div class="mgmenu_container" id="mgmenu1"><!-- Begin Mega Menu Container -->
|
54 |
-
|
55 |
<ul class="mgmenu"><!-- Begin Mega Menu -->
|
56 |
|
57 |
|
@@ -59,74 +74,161 @@ jQuery( document ).ready(function( $ ) {
|
|
59 |
<!-- Begin MegaMenu Items -->
|
60 |
|
61 |
<?php if(!empty($_menuItem)): ?>
|
62 |
-
<?php foreach($
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
<div class="dropdown_2columns dropdown_container" style="display: none;"><!-- Begin Products Item Container -->
|
75 |
-
|
76 |
<ul class="dropdown_flyout">
|
77 |
-
|
78 |
-
<?php if($_menu): ?>
|
79 |
<li class="mgmenu_button" style="display: none;"><?php echo $item["linktitle"]; ?></li><!-- Button (Mobile Devices) -->
|
80 |
<?php echo $_menu; ?>
|
81 |
-
<?php endif ?>
|
82 |
</ul>
|
83 |
-
|
84 |
</div><!-- End Products Item Container -->
|
85 |
|
86 |
</li><!-- End Products Item -->
|
87 |
-
|
88 |
-
<?php
|
89 |
-
<li class="mgmenu_button" style="display: none;"><?php echo
|
90 |
|
91 |
<!-- Begin Dropdown Link -->
|
92 |
<li>
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
if(!empty($item["linktarget"])){
|
99 |
-
echo "target='_".$item['linktarget']."'>".$item["linktitle"]."</a>";
|
100 |
-
}
|
101 |
-
else{
|
102 |
-
echo ">".$item["linktitle"]."</a>";
|
103 |
-
}
|
104 |
?>
|
105 |
-
|
106 |
-
<?php else: ?>
|
107 |
-
|
108 |
-
<span><?php echo $item["linktitle"]; ?></span>
|
109 |
-
|
110 |
<?php endif; ?>
|
|
|
111 |
|
|
|
112 |
|
113 |
|
114 |
-
<?php if(!empty($item["menuhtml"])): ?>
|
115 |
-
|
116 |
<?php echo $item["menuhtml"]; ?>
|
117 |
-
|
118 |
<?php endif; ?>
|
119 |
|
|
|
120 |
</li>
|
121 |
<!-- End Dropdown Link -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
<?php endif; ?>
|
124 |
-
<?php endif; ?>
|
125 |
-
|
126 |
-
<?php endforeach; ?>
|
127 |
-
<?php endif ?>
|
128 |
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
|
132 |
<div class="dropdown_container dropdown_4columns dropdown_right" style="display: none;"><!-- Begin Item Container -->
|
@@ -170,6 +272,13 @@ jQuery( document ).ready(function( $ ) {
|
|
170 |
|
171 |
|
172 |
</li><!-- End Item -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
|
175 |
|
@@ -178,3 +287,4 @@ jQuery( document ).ready(function( $ ) {
|
|
178 |
|
179 |
|
180 |
</div>
|
|
31 |
* @see JScriptz_MegaMenu2_Block_Html_Topmenu extends Mage_Page_Block_Html_Topmenu
|
32 |
*/
|
33 |
?>
|
34 |
+
<?php
|
35 |
+
$z=0;
|
36 |
+
$_menu = $this->getHtml('level-top');
|
37 |
+
$_menuItem = $this->getMenuItem();
|
38 |
+
$menuDisabled = $this->isMenuDisabled();
|
39 |
+
$menuItemSettings = $this->getMenuItemSettings();
|
40 |
+
$store = $this->helper('core')->getStoreId();
|
41 |
+
|
42 |
+
?>
|
43 |
+
|
44 |
+
<?php if($menuDisabled == true): ?>
|
45 |
+
<div class="nav-container">
|
46 |
+
<ul id="nav">
|
47 |
+
<?php echo $_menu ?>
|
48 |
+
</ul>
|
49 |
+
</div>
|
50 |
+
<?php else: ?>
|
51 |
<script>
|
52 |
$.noConflict();
|
53 |
jQuery( document ).ready(function( $ ) {
|
66 |
</script>
|
67 |
|
68 |
<div class="mgmenu_container" id="mgmenu1"><!-- Begin Mega Menu Container -->
|
69 |
+
|
70 |
<ul class="mgmenu"><!-- Begin Mega Menu -->
|
71 |
|
72 |
|
74 |
<!-- Begin MegaMenu Items -->
|
75 |
|
76 |
<?php if(!empty($_menuItem)): ?>
|
77 |
+
<?php foreach($menuItemSettings as $setting){
|
78 |
+
$storeSetting[] = $setting;
|
79 |
+
}
|
80 |
+
?>
|
81 |
+
<?php function mySort($a,$b){
|
82 |
+
if ($a['position'] == $b['position']) {
|
83 |
+
return 0;
|
84 |
+
}
|
85 |
+
return ($a['position'] < $b['position']) ? -1 : 1;
|
86 |
+
}
|
87 |
+
|
88 |
+
usort($_menuItem, "mySort");
|
89 |
+
|
90 |
+
foreach($_menuItem as $item): ?>
|
91 |
+
<?php foreach($storeSetting as $set): ?>
|
92 |
+
<?php if($item['linktitle'] != 'ROOT' && $item['level'] == 1 && $set['menuitem_id'] == $item['entity_id']): ?>
|
93 |
+
|
94 |
+
<?php if($item['linktype'] == 1): ?>
|
95 |
+
<li style=""><span><i class="mini_icon ic_grid"></i><?php echo $item['linktitle']; ?></span><!-- Begin Products Item -->
|
96 |
|
97 |
<div class="dropdown_2columns dropdown_container" style="display: none;"><!-- Begin Products Item Container -->
|
98 |
+
<?php if($_menu): ?>
|
99 |
<ul class="dropdown_flyout">
|
|
|
|
|
100 |
<li class="mgmenu_button" style="display: none;"><?php echo $item["linktitle"]; ?></li><!-- Button (Mobile Devices) -->
|
101 |
<?php echo $_menu; ?>
|
|
|
102 |
</ul>
|
103 |
+
<?php endif ?>
|
104 |
</div><!-- End Products Item Container -->
|
105 |
|
106 |
</li><!-- End Products Item -->
|
107 |
+
<?php endif; ?>
|
108 |
+
<?php if($item['linktype'] == 0 || $item['linktype'] == 2): ?>
|
109 |
+
<li class="mgmenu_button" style="display: none;"><?php echo "<a class ='".$item["linkclass"]."' title='".$item['titletag']."'>".$item["linktitle"]."</a>"; ?></li><!-- Button (Mobile Devices) -->
|
110 |
|
111 |
<!-- Begin Dropdown Link -->
|
112 |
<li>
|
113 |
+
<?php if($item['linktype'] == 0): ?>
|
114 |
+
<?php
|
115 |
+
$target = ($item['linktarget']) ? 'blank' : 'self';
|
116 |
+
echo "<a href='".$item['linkpath']."' target='_".$target."' class='".$item["linkclass"]."' title ='".$item["titletag"]."' >".$item["linktitle"]."</a>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
?>
|
|
|
|
|
|
|
|
|
|
|
118 |
<?php endif; ?>
|
119 |
+
<?php if($item['linktype'] == 2): ?>
|
120 |
|
121 |
+
<span><?php echo "<a title='".$item['titletag']."' class='".$item['linkclass']."'>".$item["linktitle"]."</a>"; ?></span>
|
122 |
|
123 |
|
|
|
|
|
124 |
<?php echo $item["menuhtml"]; ?>
|
|
|
125 |
<?php endif; ?>
|
126 |
|
127 |
+
|
128 |
</li>
|
129 |
<!-- End Dropdown Link -->
|
130 |
+
<?php endif; ?>
|
131 |
+
|
132 |
+
<?php if($item['linktype'] == 4 && $set['menuitem_id'] == $item['entity_id']): ?>
|
133 |
+
|
134 |
+
<li style="" title="<?php echo $item['titletag']; ?>"><span><i class="mini_icon ic_grid"></i><?php echo $item['linktitle']; ?></span><!-- Begin Products Item -->
|
135 |
+
|
136 |
+
<div class='dropdown_fullwidth mgmenu_tabs' style='display: none;'><!-- Begin Item Container -->
|
137 |
+
|
138 |
+
|
139 |
+
<ul class='mgmenu_tabs_nav'>
|
140 |
+
|
141 |
+
<li><a class='current' href='#section1'>Popular Products</a></li>
|
142 |
+
<li><a href='#section2'>Related Products</a></li>
|
143 |
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
+
</ul>
|
146 |
+
|
147 |
+
<div class='mgmenu_tabs_panels'><!-- Begin Panels Container -->
|
148 |
+
|
149 |
+
<div class='mgmenu_tabs' id='section1'><!-- Begin Section 1 -->
|
150 |
+
|
151 |
+
|
152 |
+
<?php $model = Mage::getModel('megamenu2/menuitem_product')->getProductCollection($item['entity_id']);
|
153 |
+
if($model){
|
154 |
+
$ent = $model->getData();
|
155 |
+
foreach($ent as $ent2){
|
156 |
+
$prod = Mage::getModel('catalog/product')->loadByAttribute('entity_id',$ent2['entity_id']);
|
157 |
+
if($prod){
|
158 |
+
foreach($prod as $p){
|
159 |
+
|
160 |
+
if(!empty($p["name"]) && $p['name'] != 'e'){
|
161 |
+
echo "<div class='col_3'>
|
162 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/media/catalog/product".$p['image']."'></a>";
|
163 |
+
echo nl2br("<p class='img_description'>".$p["name"]." \n Price: $".$p['price']."</p><br /></div>");
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
unset($model);
|
169 |
+
}
|
170 |
+
?>
|
171 |
+
|
172 |
+
</div><!-- End Section 2 -->
|
173 |
+
|
174 |
+
<div class='mgmenu_tabs_hide' id='section2'><!-- Begin Section 2 -->
|
175 |
+
|
176 |
+
<div class='col_3'>
|
177 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product01@2x.jpg'></a>
|
178 |
+
<p class='img_description'>Image Description</p>
|
179 |
+
</div>
|
180 |
+
|
181 |
+
<div class='col_3'>
|
182 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product02@2x.jpg'></a>
|
183 |
+
<p class='img_description'>Image Description</p>
|
184 |
+
</div>
|
185 |
+
|
186 |
+
<div class='col_3'>
|
187 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product03@2x.jpg'></a>
|
188 |
+
<p class='img_description'>Image Description</p>
|
189 |
+
</div>
|
190 |
+
|
191 |
+
<div class='col_3'>
|
192 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product04@2x.jpg'></a>
|
193 |
+
<p class='img_description'>Image Description</p>
|
194 |
+
</div>
|
195 |
+
|
196 |
+
<div class='col_3'>
|
197 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product05@2x.jpg'></a>
|
198 |
+
<p class='img_description'>Image Description</p>
|
199 |
+
</div>
|
200 |
+
|
201 |
+
<div class='col_3'>
|
202 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product06@2x.jpg'></a>
|
203 |
+
<p class='img_description'>Image Description</p>
|
204 |
+
</div>
|
205 |
+
|
206 |
+
<div class='col_3'>
|
207 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product07@2x.jpg'></a>
|
208 |
+
<p class='img_description'>Image Description</p>
|
209 |
+
</div>
|
210 |
+
|
211 |
+
<div class='col_3'>
|
212 |
+
<a href='#'><img width='220' height='140' class='inline_img' alt='' src='/skin/frontend/base/default/images/jscriptz_megamenu2/product08@2x.jpg'></a>
|
213 |
+
<p class='img_description'>Image Description</p>
|
214 |
+
</div>
|
215 |
+
|
216 |
+
</div><!-- End Section 2 -->
|
217 |
+
|
218 |
+
|
219 |
+
|
220 |
+
</div><!-- End Panels Container -->
|
221 |
+
|
222 |
+
|
223 |
+
</div><!-- End Item Container -->
|
224 |
+
|
225 |
+
|
226 |
+
</li><!-- End Item -->
|
227 |
+
|
228 |
+
<?php endif; ?>
|
229 |
+
|
230 |
+
<?php if($item['linktype'] == 3 && $set['menuitem_id'] == $item['entity_id']): ?>
|
231 |
+
<li class="right_item" style=""><span><i class="mini_icon ic_chat"></i>Contact</span><!-- Begin Item -->
|
232 |
|
233 |
|
234 |
<div class="dropdown_container dropdown_4columns dropdown_right" style="display: none;"><!-- Begin Item Container -->
|
272 |
|
273 |
|
274 |
</li><!-- End Item -->
|
275 |
+
<?php endif; ?>
|
276 |
+
<?php endif; ?>
|
277 |
+
<?php endforeach; ?>
|
278 |
+
<?php endforeach; ?>
|
279 |
+
<?php endif ?>
|
280 |
+
|
281 |
+
|
282 |
|
283 |
|
284 |
|
287 |
|
288 |
|
289 |
</div>
|
290 |
+
<?php endif; ?>
|
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>
|
app/locale/en_US/JScriptz_MegaMenu2.csv
CHANGED
@@ -1,19 +1,29 @@
|
|
1 |
"Action","Action"
|
2 |
"Add Child Menu Item","Add Child Menu Item"
|
3 |
"Add Menu Item","Add Menu Item"
|
|
|
4 |
"Add Root Menu Item","Add Root Menu Item"
|
5 |
"An error occurred while trying to delete the menu item.","An error occurred while trying to delete the menu item."
|
6 |
"Are you sure?","Are you sure?"
|
|
|
|
|
7 |
"CSV","CSV"
|
8 |
"Can't delete root menu item.","Can't delete root menu item."
|
|
|
9 |
"Change status","Change status"
|
10 |
"Collapse All","Collapse All"
|
11 |
"Could not find menu item to delete.","Could not find menu item to delete."
|
|
|
|
|
12 |
"Delete Menu Item","Delete Menu Item"
|
|
|
13 |
"Delete","Delete"
|
|
|
14 |
"Disabled","Disabled"
|
|
|
15 |
"Display as tree","Display as tree"
|
16 |
"Edit Menu Item '%s'","Edit Menu Item '%s'"
|
|
|
17 |
"Edit","Edit"
|
18 |
"Enabled","Enabled"
|
19 |
"Excel","Excel"
|
@@ -22,8 +32,8 @@
|
|
22 |
"ID: %s","ID: %s"
|
23 |
"Id","Id"
|
24 |
"Levels to show (0 for all)","Levels to show (0 for all)"
|
|
|
25 |
"Link Path","Link Path"
|
26 |
-
"Link Position","Link Position"
|
27 |
"Link Target","Link Target"
|
28 |
"Link Title","Link Title"
|
29 |
"Manage Menu Items","Manage Menu Items"
|
@@ -38,32 +48,48 @@
|
|
38 |
"Menu Item was successfully saved","Menu Item was successfully saved"
|
39 |
"Menu Item","Menu Item"
|
40 |
"Menu Items","Menu Items"
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
"New Menu Item","New Menu Item"
|
42 |
"New Root Menu Item","New Root Menu Item"
|
43 |
"No","No"
|
44 |
"None","None"
|
45 |
-
"Place any HTML in this block to be displayed in the Mega Nav. Tip: Disable the WYSIWYG editor to place pure HTML code","Place any HTML in this block to be displayed in the Mega Nav. Tip: Disable the WYSIWYG editor to place pure HTML code"
|
46 |
"Please select menu items to delete.","Please select menu items to delete."
|
47 |
"Please select menu items.","Please select menu items."
|
|
|
|
|
|
|
48 |
"Recursion level","Recursion level"
|
|
|
49 |
"Root","Root"
|
50 |
"Save And Continue Edit","Save And Continue Edit"
|
51 |
"Save Menu Item","Save Menu Item"
|
|
|
52 |
"Select Menu Item","Select Menu Item"
|
53 |
"Status","Status"
|
54 |
"Store views","Store views"
|
55 |
"The menu item has been saved.","The menu item has been saved."
|
56 |
"There was a problem saving the menu item.","There was a problem saving the menu item."
|
|
|
57 |
"There was an error deleteing menu item.","There was an error deleteing menu item."
|
58 |
"There was an error deleteing menu items.","There was an error deleteing menu items."
|
|
|
|
|
59 |
"There was an error updating menu items.","There was an error updating menu items."
|
60 |
-
"
|
61 |
-
"This is the title for your menu link","This is the title for your menu link"
|
62 |
-
"This is the url your link will follow","This is the url your link will follow"
|
63 |
"This menu item no longer exists.","This menu item no longer exists."
|
|
|
|
|
64 |
"Total of %d menu items were successfully deleted.","Total of %d menu items were successfully deleted."
|
65 |
"Total of %d menu items were successfully updated.","Total of %d menu items were successfully updated."
|
|
|
|
|
66 |
"Unable to find menu item to save.","Unable to find menu item to save."
|
67 |
-
"
|
|
|
68 |
"XML","XML"
|
69 |
"Yes","Yes"
|
1 |
"Action","Action"
|
2 |
"Add Child Menu Item","Add Child Menu Item"
|
3 |
"Add Menu Item","Add Menu Item"
|
4 |
+
"Add Menu Setting","Add Menu Setting"
|
5 |
"Add Root Menu Item","Add Root Menu Item"
|
6 |
"An error occurred while trying to delete the menu item.","An error occurred while trying to delete the menu item."
|
7 |
"Are you sure?","Are you sure?"
|
8 |
+
"Assign menu setting to menu item","Assign menu setting to menu item"
|
9 |
+
"Associated products","Associated products"
|
10 |
"CSV","CSV"
|
11 |
"Can't delete root menu item.","Can't delete root menu item."
|
12 |
+
"Change Disable Menu","Change Disable Menu"
|
13 |
"Change status","Change status"
|
14 |
"Collapse All","Collapse All"
|
15 |
"Could not find menu item to delete.","Could not find menu item to delete."
|
16 |
+
"Could not find menu setting to delete.","Could not find menu setting to delete."
|
17 |
+
"Delete File","Delete File"
|
18 |
"Delete Menu Item","Delete Menu Item"
|
19 |
+
"Delete Menu Setting","Delete Menu Setting"
|
20 |
"Delete","Delete"
|
21 |
+
"Disable Menu","Disable Menu"
|
22 |
"Disabled","Disabled"
|
23 |
+
"Disables Menu for Debugging","Disables Menu for Debugging"
|
24 |
"Display as tree","Display as tree"
|
25 |
"Edit Menu Item '%s'","Edit Menu Item '%s'"
|
26 |
+
"Edit Menu Setting '%s'","Edit Menu Setting '%s'"
|
27 |
"Edit","Edit"
|
28 |
"Enabled","Enabled"
|
29 |
"Excel","Excel"
|
32 |
"ID: %s","ID: %s"
|
33 |
"Id","Id"
|
34 |
"Levels to show (0 for all)","Levels to show (0 for all)"
|
35 |
+
"Link Image","Link Image"
|
36 |
"Link Path","Link Path"
|
|
|
37 |
"Link Target","Link Target"
|
38 |
"Link Title","Link Title"
|
39 |
"Manage Menu Items","Manage Menu Items"
|
48 |
"Menu Item was successfully saved","Menu Item was successfully saved"
|
49 |
"Menu Item","Menu Item"
|
50 |
"Menu Items","Menu Items"
|
51 |
+
"Menu Setting does not exist.","Menu Setting does not exist."
|
52 |
+
"Menu Setting was successfully deleted.","Menu Setting was successfully deleted."
|
53 |
+
"Menu Setting was successfully saved","Menu Setting was successfully saved"
|
54 |
+
"Menu Setting","Menu Setting"
|
55 |
+
"Menu Settings","Menu Settings"
|
56 |
+
"Menu Title","Menu Title"
|
57 |
"New Menu Item","New Menu Item"
|
58 |
"New Root Menu Item","New Root Menu Item"
|
59 |
"No","No"
|
60 |
"None","None"
|
|
|
61 |
"Please select menu items to delete.","Please select menu items to delete."
|
62 |
"Please select menu items.","Please select menu items."
|
63 |
+
"Please select menu settings to delete.","Please select menu settings to delete."
|
64 |
+
"Please select menu settings.","Please select menu settings."
|
65 |
+
"Position","Position"
|
66 |
"Recursion level","Recursion level"
|
67 |
+
"Remove menu setting from menu item","Remove menu setting from menu item"
|
68 |
"Root","Root"
|
69 |
"Save And Continue Edit","Save And Continue Edit"
|
70 |
"Save Menu Item","Save Menu Item"
|
71 |
+
"Save Menu Setting","Save Menu Setting"
|
72 |
"Select Menu Item","Select Menu Item"
|
73 |
"Status","Status"
|
74 |
"Store views","Store views"
|
75 |
"The menu item has been saved.","The menu item has been saved."
|
76 |
"There was a problem saving the menu item.","There was a problem saving the menu item."
|
77 |
+
"There was a problem saving the menu setting.","There was a problem saving the menu setting."
|
78 |
"There was an error deleteing menu item.","There was an error deleteing menu item."
|
79 |
"There was an error deleteing menu items.","There was an error deleteing menu items."
|
80 |
+
"There was an error deleteing menu setting.","There was an error deleteing menu setting."
|
81 |
+
"There was an error deleteing menu settings.","There was an error deleteing menu settings."
|
82 |
"There was an error updating menu items.","There was an error updating menu items."
|
83 |
+
"There was an error updating menu settings.","There was an error updating menu settings."
|
|
|
|
|
84 |
"This menu item no longer exists.","This menu item no longer exists."
|
85 |
+
"This menu setting no longer exists.","This menu setting no longer exists."
|
86 |
+
"Title for your menu","Title for your menu"
|
87 |
"Total of %d menu items were successfully deleted.","Total of %d menu items were successfully deleted."
|
88 |
"Total of %d menu items were successfully updated.","Total of %d menu items were successfully updated."
|
89 |
+
"Total of %d menu settings were successfully deleted.","Total of %d menu settings were successfully deleted."
|
90 |
+
"Total of %d menu settings were successfully updated.","Total of %d menu settings were successfully updated."
|
91 |
"Unable to find menu item to save.","Unable to find menu item to save."
|
92 |
+
"Unable to find menu setting to save.","Unable to find menu setting to save."
|
93 |
+
"Upload an image to include next to your menu link","Upload an image to include next to your menu link"
|
94 |
"XML","XML"
|
95 |
"Yes","Yes"
|
media/menuitem/file/p/r/prod_icon.png
ADDED
Binary file
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>JScriptz_MegaMenu2</name>
|
4 |
-
<version>1.8.1.
|
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-
|
14 |
-
<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="22e829c46ddda7d46d1adb39b9c461c8"/></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>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>JScriptz_MegaMenu2</name>
|
4 |
+
<version>1.8.1.2</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-11-15</date>
|
14 |
+
<time>05:43:01</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="JScriptz"><dir name="MegaMenu2"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Menuitem.php" hash="e2bd922a15f9e3722e2a3c4ee25927fd"/><file name="Menusetting.php" hash="19db0dceef26855ef21bd78083f308bf"/></dir></dir></dir></dir><dir name="Helper"><file name="Wysiwyg.php" hash="f4a101bec7b37f9944eae9689370684d"/></dir><dir name="Menuitem"><file name="Abstract.php" hash="544dae0a11c8de66a7c6ffe57d0eb772"/><dir name="Edit"><file name="Form.php" hash="a7a860fcfddfb8ae2482edc592ff20fe"/><dir name="Tab"><file name="Form.php" hash="750ae3a863e072850145703f7fd65318"/><file name="Menusetting.php" hash="30aa64433e394114fe74ef3396b9236f"/><file name="Product.php" hash="b56c7e3cb152b7182ba08dea451ed8c0"/><file name="Stores.php" hash="8bff88326d87be92ae08e18ded9bb986"/></dir><file name="Tabs.php" hash="13b78e0b9687c4a93f4ee9f25664a82e"/></dir><file name="Edit.php" hash="53c4b8799fc428878c93ba3755a3f742"/><dir name="Helper"><file name="File.php" hash="5b36bea0f832e02725d0b7ecb8ed1070"/></dir><file name="Tree.php" hash="2902a61d2adcfef9bbb1b3a2fd8e87f2"/></dir><file name="Menuitem.php" hash="c79ebb1c09cd2fe0c2d3fe8144f61b06"/><dir name="Menusetting"><dir name="Edit"><file name="Form.php" hash="a69448e661f36d9ea375e98037ad7f4e"/><dir name="Tab"><file name="Form.php" hash="00f79b3660ec3dc512853d067ef02096"/><file name="Menuitem.php" hash="98b9dfbea0404e0a1e35ec44ff670290"/><file name="Product.php" hash="c2c775b987076ed41df4718160841adf"/><file name="Stores.php" hash="875b61d43a2dddee4e5ad3769ab845dc"/></dir><file name="Tabs.php" hash="a1e2561648cec96f1be4ce9fd1675b3d"/></dir><file name="Edit.php" hash="88824815a1ed7e2b085940537313878e"/><file name="Grid.php" hash="a458f730218b18518f08b126b2060e6f"/></dir><file name="Menusetting.php" hash="44b201a704f43f77ddbd2c248c9e8dca"/></dir><dir name="Html"><file name="Topmenu.php" hash="02a723f02c83dfe1e9c9373bd366ecea"/></dir><dir name="Menuitem"><dir name="Catalog"><dir name="Product"><file name="List.php" hash="cf9a03ca751aaf595be5e1d3d9d096e6"/></dir></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="MegaMenu2.php" hash="77ca9ac3d1c50c17911eba2339c035a9"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4533f8233b792a416c15633a02ef67cf"/><file name="Menuitem.php" hash="86ecb51a9403537463a04685a4835326"/><file name="Menusetting.php" hash="95692e375b8b1bb2215a9d6b56f6a935"/><file name="Product.php" hash="7a4e09d1fd17a29d4041028c33aa8d95"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="45ea1d41d594176902e025d83dc35458"/></dir><dir name="Menuitem"><file name="Menusetting.php" hash="71c8259fa2b93a5a77ef7d2712ff813c"/><file name="Product.php" hash="4566ebbe417967b8f4f5f7e7da6cdebb"/></dir><file name="Menuitem.php" hash="d1ce3f9542c78ebd852ab43379bde217"/><dir name="Menusetting"><file name="Menuitem.php" hash="3f471b1e2d12f4a927c8ab9b2d630095"/><file name="Product.php" hash="569f352e734404ec70daef6bf4ef1a7a"/></dir><file name="Menusetting.php" hash="c716e95e715cafeab96d3315c3c93ad2"/><dir name="Resource"><dir name="Menuitem"><file name="Collection.php" hash="c9e597f713791ad32aefc55a0872749f"/><dir name="Menusetting"><file name="Collection.php" hash="22c49b57bd8286638c2df2e0a26cb261"/></dir><file name="Menusetting.php" hash="23effd90a04cdfe2fcf7a101e50dd637"/><dir name="Product"><file name="Collection.php" hash="ab51ee672f2a2860a4b372aa091265d8"/></dir><file name="Product.php" hash="052426e4629d8f2b277cd7a27ad72205"/><file name="Tree.php" hash="455695c0634713489dbb60b4651e6582"/></dir><file name="Menuitem.php" hash="5034856c86dc072f0979937adda4196f"/><dir name="Menusetting"><file name="Collection.php" hash="f9c136c4a78cea82d3ecf4ad0ce84882"/><dir name="Menuitem"><file name="Collection.php" hash="ff404b85f7b3bca0bf4a26ddac125f1f"/></dir><file name="Menuitem.php" hash="ef66bee098cc58b2416bbbfbc1c42b08"/><dir name="Product"><file name="Collection.php" hash="20b37059480b89b5a3fe11336b881ef4"/></dir><file name="Product.php" hash="031090881509beb8b738595aee1ea47d"/></dir><file name="Menusetting.php" hash="668bea4882c149da910eec49aa4ccf57"/><file name="Setup.php" hash="c6a7c5f548d829f9b2fcb6586d7640a3"/></dir><file name="SystemSettings.php" hash="3471e98e9548a06aae94bc01846bff72"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="MegaMenu2"><dir name="Menuitem"><dir name="Catalog"><file name="ProductController.php" hash="b1a2aac464fe0e11106e49b5e1e019e6"/></dir></dir><file name="MenuitemController.php" hash="e77eb3251fb78ee278e5c22c6517593d"/><dir name="Menusetting"><dir name="Catalog"><file name="ProductController.php" hash="f0f852781e8b910a577bf1a7f244eba2"/></dir></dir><file name="MenusettingController.php" hash="3be2b40143cff833a2044722bc63c4e7"/></dir></dir></dir><dir name="data"><dir name="jscriptz_megamenu2_setup"><file name="data-install-0.0.1.php" hash="d12fff1665f30238edec4dd1960b09b6"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e0278dad3ceb7f0a48574f04c09de26c"/><file name="config.xml" hash="d2f890639521796c1c971eff24f0f8a0"/><file name="system.xml" hash="6f4990accf9b94b1e76141db9f744e0d"/></dir><dir name="sql"><dir name="jscriptz_megamenu2_setup"><file name="install-0.0.1.php" hash="cad9ff2f986256e1a4c5f6da31ac80bf"/></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="b53fe6b7dff9d19cac8814dbb2dcd00f"/></dir><dir name="template"><dir name="jscriptz_megamenu2"><dir name="catalog"><dir name="product"><dir name="edit"><dir name="tab"><file name="menuitem.phtml" hash="efdb8e992bf21a54c4c599f6d30097bd"/></dir></dir></dir></dir><dir name="menuitem"><dir name="edit"><file name="form.phtml" hash="30339f175fd3c2de5927d36000093a6b"/></dir><file name="edit.phtml" hash="7e33f666f86b3eecf034b45f2c6ce86a"/><file name="tree.phtml" hash="968cc1808a7be1e9a01f904f352f629b"/></dir><dir name="menusetting"><dir name="edit"><dir name="tab"><file name="menuitem.phtml" hash="c21c0e4865c68957b8b85c71a4580a23"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="jscriptz_megamenu2.xml" hash="80cd1bcd33c5e8c77d7cfa8de0daeed4"/></dir><dir name="template"><dir name="jscriptz"><dir name="html"><file name="topmenu.phtml" hash="7692d9045d2b81a6b7e8f2120d83caa5"/></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="15a93606b4ad0550b65eb98906d25514"/></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="f2c1f74b320597380fbb560a693f3893"/></dir></target><target name="magemedia"><dir name="menuitem"><dir name="file"><dir name="p"><dir name="r"><file name="prod_icon.png" hash="6d31b464f8214b7bdf0307d78d0c02da"/></dir></dir></dir></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/css/JScriptz/mgmenu.css
CHANGED
@@ -262,6 +262,8 @@ body{font-family:Arial,Helvetica,sans-serif}
|
|
262 |
.description h2{margin-bottom:48px;text-align:center;text-shadow:1px 1px 1px #fff}
|
263 |
.description p{font-size:12px;line-height:18px;margin-bottom:18px;text-shadow:1px 1px 1px #fff;clear:both}
|
264 |
.dropdown_flyout {}
|
|
|
|
|
265 |
.dropdown_parent {width:250px}
|
266 |
.mgmenu .dropdown_flyout, .mgmenu .dropdown_flyout .dropdown_flyout_level {width:250px}
|
267 |
.mgmenu .dropdown_flyout a, .mgmenu .dropdown_flyout .dropdown_flyout_level a{width:250px}
|
262 |
.description h2{margin-bottom:48px;text-align:center;text-shadow:1px 1px 1px #fff}
|
263 |
.description p{font-size:12px;line-height:18px;margin-bottom:18px;text-shadow:1px 1px 1px #fff;clear:both}
|
264 |
.dropdown_flyout {}
|
265 |
+
a.topnav-link {color:#fff}
|
266 |
+
a.topnav-link:hover {color:#eee}
|
267 |
.dropdown_parent {width:250px}
|
268 |
.mgmenu .dropdown_flyout, .mgmenu .dropdown_flyout .dropdown_flyout_level {width:250px}
|
269 |
.mgmenu .dropdown_flyout a, .mgmenu .dropdown_flyout .dropdown_flyout_level a{width:250px}
|