Version Notes
This is first stable version.
Release 1.0.0
- Admin page for managing menus
- Admin page for managing menu items and submenus
- Block for showing menu
- Sample layout XML to show how all working
Download this release
Release Info
Developer | Eleven Soft |
Extension | ES_Custommenu |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu.php +12 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit.php +45 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit/Form.php +19 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit/Tab/Form.php +42 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit/Tabs.php +24 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Grid.php +102 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items.php +12 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit.php +45 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit/Form.php +19 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit/Tab/Form.php +78 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit/Tabs.php +24 -0
- app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Grid.php +130 -0
- app/code/community/ES/Custommenu/Block/Custommenu.php +46 -0
- app/code/community/ES/Custommenu/Helper/Data.php +60 -0
- app/code/community/ES/Custommenu/Model/Custommenu.php +49 -0
- app/code/community/ES/Custommenu/Model/Custommenu/Items.php +120 -0
- app/code/community/ES/Custommenu/Model/Mysql4/Custommenu.php +10 -0
- app/code/community/ES/Custommenu/Model/Mysql4/Custommenu/Collection.php +10 -0
- app/code/community/ES/Custommenu/Model/Mysql4/Custommenu/Items.php +10 -0
- app/code/community/ES/Custommenu/Model/Mysql4/Custommenu/Items/Collection.php +10 -0
- app/code/community/ES/Custommenu/Model/Status.php +21 -0
- app/code/community/ES/Custommenu/controllers/Adminhtml/Custommenu/ItemsController.php +147 -0
- app/code/community/ES/Custommenu/controllers/Adminhtml/CustommenuController.php +174 -0
- app/code/community/ES/Custommenu/etc/config.xml +154 -0
- app/code/community/ES/Custommenu/sql/custommenu_setup/mysql4-install-1.0.0.php +43 -0
- app/design/adminhtml/default/default/layout/es_custommenu.xml +13 -0
- app/design/frontend/base/default/layout/es_custommenu.xml +11 -0
- app/design/frontend/base/default/template/es_custommenu/menu.phtml +23 -0
- app/design/frontend/base/default/template/es_custommenu/submenu.phtml +22 -0
- app/etc/modules/ES_Custommenu.xml +9 -0
- package.xml +28 -0
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_custommenu';
|
7 |
+
$this->_blockGroup = 'custommenu';
|
8 |
+
$this->_headerText = Mage::helper('custommenu')->__('Menu Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('custommenu')->__('Add Menu');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'custommenu';
|
11 |
+
$this->_controller = 'adminhtml_custommenu';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('custommenu')->__('Save Menu'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('custommenu')->__('Delete Menu'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('custommenu_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'custommenu_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'custommenu_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('custommenu_data') && Mage::registry('custommenu_data')->getId() ) {
|
40 |
+
return Mage::helper('custommenu')->__("Edit Menu '%s'", $this->htmlEscape(Mage::registry('custommenu_data')->getName()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('custommenu')->__('Add Menu');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
4 |
+
|
5 |
+
protected function _prepareForm() {
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
$fieldset = $form->addFieldset('custommenu_form', array('legend' => Mage::helper('custommenu')->__('Menu Information')));
|
9 |
+
|
10 |
+
$fieldset->addField('name', 'text', array(
|
11 |
+
'label' => Mage::helper('custommenu')->__('Name'),
|
12 |
+
'required' => true,
|
13 |
+
'name' => 'name',
|
14 |
+
));
|
15 |
+
|
16 |
+
$fieldset->addField('label', 'text', array(
|
17 |
+
'label' => Mage::helper('custommenu')->__('Label'),
|
18 |
+
'required' => true,
|
19 |
+
'name' => 'label',
|
20 |
+
));
|
21 |
+
|
22 |
+
$fieldset->addField('status', 'select', array(
|
23 |
+
'label' => Mage::helper('custommenu')->__('Status'),
|
24 |
+
'name' => 'status',
|
25 |
+
'values' => array(
|
26 |
+
array(
|
27 |
+
'value' => 1,
|
28 |
+
'label' => Mage::helper('custommenu')->__('Enabled'),
|
29 |
+
),
|
30 |
+
array(
|
31 |
+
'value' => 2,
|
32 |
+
'label' => Mage::helper('custommenu')->__('Disabled'),
|
33 |
+
),
|
34 |
+
),
|
35 |
+
));
|
36 |
+
|
37 |
+
$form->setValues(Mage::registry('custommenu_data')->getData());
|
38 |
+
|
39 |
+
return parent::_prepareForm();
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('custommenu_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('custommenu')->__('Menu Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('custommenu')->__('Menu Information'),
|
18 |
+
'title' => Mage::helper('custommenu')->__('Menu Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('custommenu/adminhtml_custommenu_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Grid.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('custommenuGrid');
|
8 |
+
$this->setDefaultSort('custommenu_id');
|
9 |
+
$this->setDefaultDir('ASC');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _prepareCollection() {
|
14 |
+
$collection = Mage::getModel('custommenu/custommenu')->getCollection();
|
15 |
+
$this->setCollection($collection);
|
16 |
+
return parent::_prepareCollection();
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareColumns() {
|
20 |
+
$this->addColumn('custommenu_id', array(
|
21 |
+
'header' => Mage::helper('custommenu')->__('ID'),
|
22 |
+
'align' => 'right',
|
23 |
+
'width' => '50px',
|
24 |
+
'index' => 'custommenu_id',
|
25 |
+
));
|
26 |
+
|
27 |
+
$this->addColumn('name', array(
|
28 |
+
'header' => Mage::helper('custommenu')->__('Name'),
|
29 |
+
'align' => 'left',
|
30 |
+
'index' => 'name',
|
31 |
+
));
|
32 |
+
$this->addColumn('label', array(
|
33 |
+
'header' => Mage::helper('custommenu')->__('Label'),
|
34 |
+
'align' => 'left',
|
35 |
+
'index' => 'label',
|
36 |
+
));
|
37 |
+
|
38 |
+
$this->addColumn('status', array(
|
39 |
+
'header' => Mage::helper('custommenu')->__('Status'),
|
40 |
+
'align' => 'left',
|
41 |
+
'width' => '80px',
|
42 |
+
'index' => 'status',
|
43 |
+
'type' => 'options',
|
44 |
+
'options' => array(
|
45 |
+
1 => 'Enabled',
|
46 |
+
2 => 'Disabled',
|
47 |
+
),
|
48 |
+
));
|
49 |
+
$this->addColumn('action', array(
|
50 |
+
'header' => Mage::helper('custommenu')->__('Action'),
|
51 |
+
'width' => '100',
|
52 |
+
'type' => 'action',
|
53 |
+
'getter' => 'getId',
|
54 |
+
'actions' => array(
|
55 |
+
array(
|
56 |
+
'caption' => Mage::helper('custommenu')->__('Edit'),
|
57 |
+
'url' => array('base' => '*/*/edit'),
|
58 |
+
'field' => 'id'
|
59 |
+
)
|
60 |
+
),
|
61 |
+
'filter' => false,
|
62 |
+
'sortable' => false,
|
63 |
+
'index' => 'stores',
|
64 |
+
'is_system' => true,
|
65 |
+
));
|
66 |
+
|
67 |
+
return parent::_prepareColumns();
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _prepareMassaction() {
|
71 |
+
$this->setMassactionIdField('custommenu_id');
|
72 |
+
$this->getMassactionBlock()->setFormFieldName('custommenu');
|
73 |
+
|
74 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
75 |
+
'label' => Mage::helper('custommenu')->__('Delete'),
|
76 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
77 |
+
'confirm' => Mage::helper('custommenu')->__('Are you sure?')
|
78 |
+
));
|
79 |
+
$statuses = Mage::getSingleton('custommenu/status')->getOptionArray();
|
80 |
+
|
81 |
+
array_unshift($statuses, array('label' => '', 'value' => ''));
|
82 |
+
$this->getMassactionBlock()->addItem('status', array(
|
83 |
+
'label' => Mage::helper('custommenu')->__('Change status'),
|
84 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
|
85 |
+
'additional' => array(
|
86 |
+
'visibility' => array(
|
87 |
+
'name' => 'status',
|
88 |
+
'type' => 'select',
|
89 |
+
'class' => 'required-entry',
|
90 |
+
'label' => Mage::helper('custommenu')->__('Status'),
|
91 |
+
'values' => $statuses
|
92 |
+
)
|
93 |
+
)
|
94 |
+
));
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getRowUrl($row) {
|
99 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Items extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_custommenu_items';
|
7 |
+
$this->_blockGroup = 'custommenu';
|
8 |
+
$this->_headerText = Mage::helper('custommenu')->__('Menu Items Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('custommenu')->__('Add Menu Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Items_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'custommenu_item_id';
|
10 |
+
$this->_blockGroup = 'custommenu';
|
11 |
+
$this->_controller = 'adminhtml_custommenu_items';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('custommenu')->__('Save Menu Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('custommenu')->__('Delete Menu Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('custommenu_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'custommenu_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'custommenu_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('custommenu_data') && Mage::registry('custommenu_data')->getId() ) {
|
40 |
+
return Mage::helper('custommenu')->__("Edit Menu Item '%s'", $this->htmlEscape(Mage::registry('custommenu_data')->getName()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('custommenu')->__('Add Menu Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Items_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Items_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
4 |
+
|
5 |
+
protected function _prepareForm() {
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
$fieldset = $form->addFieldset('custommenu_items_form', array('legend' => Mage::helper('custommenu')->__('Menu Item Information')));
|
9 |
+
|
10 |
+
$fieldset->addField('name', 'text', array(
|
11 |
+
'label' => Mage::helper('custommenu')->__('Name'),
|
12 |
+
'required' => true,
|
13 |
+
'name' => 'name',
|
14 |
+
));
|
15 |
+
$fieldset->addField('menu_id', 'select', array(
|
16 |
+
'label' => Mage::helper('custommenu')->__('Menu'),
|
17 |
+
'name' => 'menu_id',
|
18 |
+
'required' => true,
|
19 |
+
'values' => Mage::getModel('custommenu/custommenu')->getInputSelectMenu()
|
20 |
+
));
|
21 |
+
$fieldset->addField('parent_id', 'select', array(
|
22 |
+
'label' => Mage::helper('custommenu')->__('Parent'),
|
23 |
+
'required' => false,
|
24 |
+
'values' => Mage::getModel('custommenu/custommenu_items')->getInputSelectParentItem(),
|
25 |
+
'name' => 'parent_id',
|
26 |
+
));
|
27 |
+
$fieldset->addField('url', 'text', array(
|
28 |
+
'label' => Mage::helper('custommenu')->__('Url'),
|
29 |
+
'required' => false,
|
30 |
+
'name' => 'url',
|
31 |
+
));
|
32 |
+
$fieldset->addField('cms_id', 'select', array(
|
33 |
+
'label' => Mage::helper('custommenu')->__('Page'),
|
34 |
+
'required' => false,
|
35 |
+
'values' => Mage::getModel('custommenu/custommenu_items')->getInputSelectPages(),
|
36 |
+
'name' => 'cms_id',
|
37 |
+
));
|
38 |
+
$fieldset->addField('order', 'text', array(
|
39 |
+
'label' => Mage::helper('custommenu')->__('Order'),
|
40 |
+
'required' => true,
|
41 |
+
'name' => 'order',
|
42 |
+
));
|
43 |
+
$fieldset->addField('target', 'select', array(
|
44 |
+
'label' => Mage::helper('custommenu')->__('Target'),
|
45 |
+
'name' => 'target',
|
46 |
+
'values' => array(
|
47 |
+
array(
|
48 |
+
'value' => '',
|
49 |
+
'label' => Mage::helper('custommenu')->__('Current Window'),
|
50 |
+
),
|
51 |
+
array(
|
52 |
+
'value' => '_blank',
|
53 |
+
'label' => Mage::helper('custommenu')->__('New Window'),
|
54 |
+
)
|
55 |
+
),
|
56 |
+
));
|
57 |
+
|
58 |
+
$fieldset->addField('status', 'select', array(
|
59 |
+
'label' => Mage::helper('custommenu')->__('Status'),
|
60 |
+
'name' => 'status',
|
61 |
+
'values' => array(
|
62 |
+
array(
|
63 |
+
'value' => 1,
|
64 |
+
'label' => Mage::helper('custommenu')->__('Enabled'),
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'value' => 2,
|
68 |
+
'label' => Mage::helper('custommenu')->__('Disabled'),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
));
|
72 |
+
|
73 |
+
$form->setValues(Mage::registry('custommenu_data')->getData());
|
74 |
+
|
75 |
+
return parent::_prepareForm();
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Items_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('custommenu_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('custommenu')->__('Menu Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('custommenu')->__('Menu Item Information'),
|
18 |
+
'title' => Mage::helper('custommenu')->__('Menu Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('custommenu/adminhtml_custommenu_items_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/ES/Custommenu/Block/Adminhtml/Custommenu/Items/Grid.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Adminhtml_Custommenu_Items_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('custommenu_itemGrid');
|
8 |
+
$this->setDefaultSort('menu_id');
|
9 |
+
$this->setDefaultDir('ASC');
|
10 |
+
$this->setSaveParametersInSession(true);
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _prepareCollection() {
|
14 |
+
$collection = Mage::getModel('custommenu/custommenu_items')->getCollection();
|
15 |
+
$this->setCollection($collection);
|
16 |
+
return parent::_prepareCollection();
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareColumns() {
|
20 |
+
$this->addColumn('custommenu_item_id', array(
|
21 |
+
'header' => Mage::helper('custommenu')->__('ID'),
|
22 |
+
'align' => 'right',
|
23 |
+
'width' => '50px',
|
24 |
+
'index' => 'custommenu_item_id',
|
25 |
+
));
|
26 |
+
|
27 |
+
$this->addColumn('name', array(
|
28 |
+
'header' => Mage::helper('custommenu')->__('Name'),
|
29 |
+
'align' => 'left',
|
30 |
+
'index' => 'name',
|
31 |
+
));
|
32 |
+
$this->addColumn('menu_id', array(
|
33 |
+
'header' => Mage::helper('custommenu')->__('Menu'),
|
34 |
+
'align' => 'left',
|
35 |
+
'index' => 'menu_id',
|
36 |
+
'type' => 'options',
|
37 |
+
'options' => Mage::getModel('custommenu/custommenu')->getGridInputSelectMenu()
|
38 |
+
));
|
39 |
+
|
40 |
+
$this->addColumn('parent_id', array(
|
41 |
+
'header' => Mage::helper('custommenu')->__('Parent'),
|
42 |
+
'align' => 'left',
|
43 |
+
'index' => 'parent_id',
|
44 |
+
'type' => 'options',
|
45 |
+
'options' => Mage::getModel('custommenu/custommenu_items')->getGridInputSelectParentItem()
|
46 |
+
));
|
47 |
+
$this->addColumn('url', array(
|
48 |
+
'header' => Mage::helper('custommenu')->__('Name'),
|
49 |
+
'align' => 'left',
|
50 |
+
'index' => 'url',
|
51 |
+
));
|
52 |
+
$this->addColumn('cms_id', array(
|
53 |
+
'header' => Mage::helper('custommenu')->__('Page'),
|
54 |
+
'align' => 'left',
|
55 |
+
'index' => 'cms_id',
|
56 |
+
'type' => 'options',
|
57 |
+
'options' => Mage::getModel('custommenu/custommenu_items')->getGridInputSelectPages()
|
58 |
+
));
|
59 |
+
$this->addColumn('order', array(
|
60 |
+
'header' => Mage::helper('custommenu')->__('Order'),
|
61 |
+
'align' => 'left',
|
62 |
+
'index' => 'order',
|
63 |
+
));
|
64 |
+
|
65 |
+
$this->addColumn('status', array(
|
66 |
+
'header' => Mage::helper('custommenu')->__('Status'),
|
67 |
+
'align' => 'left',
|
68 |
+
'width' => '80px',
|
69 |
+
'index' => 'status',
|
70 |
+
'type' => 'options',
|
71 |
+
'options' => array(
|
72 |
+
1 => 'Enabled',
|
73 |
+
2 => 'Disabled',
|
74 |
+
),
|
75 |
+
));
|
76 |
+
$this->addColumn('action', array(
|
77 |
+
'header' => Mage::helper('custommenu')->__('Action'),
|
78 |
+
'width' => '100',
|
79 |
+
'type' => 'action',
|
80 |
+
'getter' => 'getId',
|
81 |
+
'actions' => array(
|
82 |
+
array(
|
83 |
+
'caption' => Mage::helper('custommenu')->__('Edit'),
|
84 |
+
'url' => array('base' => '*/*/edit'),
|
85 |
+
'field' => 'id'
|
86 |
+
)
|
87 |
+
),
|
88 |
+
'filter' => false,
|
89 |
+
'sortable' => false,
|
90 |
+
'index' => 'stores',
|
91 |
+
'is_system' => true,
|
92 |
+
));
|
93 |
+
|
94 |
+
return parent::_prepareColumns();
|
95 |
+
}
|
96 |
+
|
97 |
+
protected function _prepareMassaction() {
|
98 |
+
$this->setMassactionIdField('custommenu_item_id');
|
99 |
+
$this->getMassactionBlock()->setFormFieldName('custommenu');
|
100 |
+
|
101 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
102 |
+
'label' => Mage::helper('custommenu')->__('Delete'),
|
103 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
104 |
+
'confirm' => Mage::helper('custommenu')->__('Are you sure?')
|
105 |
+
));
|
106 |
+
|
107 |
+
$statuses = Mage::getSingleton('custommenu/status')->getOptionArray();
|
108 |
+
|
109 |
+
array_unshift($statuses, array('label' => '', 'value' => ''));
|
110 |
+
$this->getMassactionBlock()->addItem('status', array(
|
111 |
+
'label' => Mage::helper('custommenu')->__('Change status'),
|
112 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
|
113 |
+
'additional' => array(
|
114 |
+
'visibility' => array(
|
115 |
+
'name' => 'status',
|
116 |
+
'type' => 'select',
|
117 |
+
'class' => 'required-entry',
|
118 |
+
'label' => Mage::helper('custommenu')->__('Status'),
|
119 |
+
'values' => $statuses
|
120 |
+
)
|
121 |
+
)
|
122 |
+
));
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function getRowUrl($row) {
|
127 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
app/code/community/ES/Custommenu/Block/Custommenu.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Block_Custommenu extends Mage_Core_Block_Template {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Prepare layout and set general template for menus
|
7 |
+
*
|
8 |
+
* @return type
|
9 |
+
*/
|
10 |
+
public function _prepareLayout() {
|
11 |
+
$this->setTemplate('es_custommenu/menu.phtml');
|
12 |
+
return parent::_prepareLayout();
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Get menu items of menu by menu label
|
17 |
+
*
|
18 |
+
* @param type $menuLabel
|
19 |
+
* @return ES_Custommenu_Model_Mysql4_Custommenu_Items_Collection collection of menu items
|
20 |
+
*/
|
21 |
+
public function getMenuItems($menuLabel) {
|
22 |
+
return Mage::helper('custommenu')->getMenuItems($menuLabel);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Get submenu item block and html
|
27 |
+
*
|
28 |
+
* @param type ES_Custommenu_Block_Custommenu
|
29 |
+
*/
|
30 |
+
public function getSubMenuBlock($menuItem) {
|
31 |
+
$subMenuBlock = $this->getLayout()->createBlock('custommenu/custommenu')->setTemplate('es_custommenu/submenu.phtml');
|
32 |
+
$subMenuBlock->setParentMenu($menuItem);
|
33 |
+
return $subMenuBlock;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get menu items of menu by parent menu $menuItem
|
38 |
+
*
|
39 |
+
* @param type $menuLabel
|
40 |
+
* @return ES_Custommenu_Model_Mysql4_Custommenu_Items_Collection collection of menu items
|
41 |
+
*/
|
42 |
+
public function getMenuSubItems($menuItem) {
|
43 |
+
return Mage::helper('custommenu')->getMenuSubItems($menuItem);
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
app/code/community/ES/Custommenu/Helper/Data.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Remove all sub menu items for parent item
|
7 |
+
*
|
8 |
+
* @param type $parentId - parent item ID
|
9 |
+
*/
|
10 |
+
public function removeChilds($parentId) {
|
11 |
+
$collection = Mage::getModel('custommenu/custommenu_items')->getCollection()
|
12 |
+
->addFieldToFilter('parent_id', $parentId);
|
13 |
+
|
14 |
+
if (count($collection) > 0) {
|
15 |
+
foreach ($collection as $val) {
|
16 |
+
$this->removeChilds($val->getId());
|
17 |
+
$val->delete();
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get tier 1 items of menu
|
24 |
+
*
|
25 |
+
* @param type $menuLabel - Menu Label
|
26 |
+
* @return ES_Custommenu_Model_Mysql4_Custommenu_Items_Collection collection of menu items
|
27 |
+
* @throws Zend_Exception
|
28 |
+
*/
|
29 |
+
public function getMenuItems($menuLabel) {
|
30 |
+
$menu = Mage::getModel('custommenu/custommenu')->load($menuLabel, 'label');
|
31 |
+
|
32 |
+
if ($menu->getId()) {
|
33 |
+
$collection = Mage::getModel('custommenu/custommenu_items')->getCollection()
|
34 |
+
->addFieldToSelect('*')
|
35 |
+
->addFieldToFilter('menu_id', $menu->getId())
|
36 |
+
->addFieldToFilter('parent_id', 0)
|
37 |
+
->addFieldToFilter('status', ES_Custommenu_Model_Status::STATUS_ENABLED)
|
38 |
+
->setOrder("'order'", 'asc');
|
39 |
+
return $collection;
|
40 |
+
} else {
|
41 |
+
throw new Zend_Exception('Menu not exist.');
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Get menu items of menu by parent menu item
|
47 |
+
*
|
48 |
+
* @param type $menuItem
|
49 |
+
* @return ES_Custommenu_Model_Mysql4_Custommenu_Items_Collection collection of menu items
|
50 |
+
*/
|
51 |
+
public function getMenuSubItems($menuItem) {
|
52 |
+
$collection = Mage::getModel('custommenu/custommenu_items')->getCollection()
|
53 |
+
->addFieldToSelect('*')
|
54 |
+
->addFieldToFilter('parent_id', $menuItem->getId())
|
55 |
+
->addFieldToFilter('status', ES_Custommenu_Model_Status::STATUS_ENABLED)
|
56 |
+
->setOrder("'order'", 'asc');
|
57 |
+
return $collection;
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
app/code/community/ES/Custommenu/Model/Custommenu.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Custommenu extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('custommenu/custommenu');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getInputSelectMenu()
|
12 |
+
{
|
13 |
+
$output = array();
|
14 |
+
$output[] = array('value' => '', 'label' => 'Select');
|
15 |
+
|
16 |
+
$collection = $this->getCollection()
|
17 |
+
->addFieldToSelect('*')
|
18 |
+
->setOrder('name', 'asc');
|
19 |
+
|
20 |
+
if(count($collection) > 0)
|
21 |
+
{
|
22 |
+
foreach($collection as $menu)
|
23 |
+
{
|
24 |
+
$output[] = array('value' => $menu->getId(), 'label' => $menu->getName());
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $output;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getGridInputSelectMenu()
|
32 |
+
{
|
33 |
+
$output = array();
|
34 |
+
$collection = $this->getCollection()
|
35 |
+
->addFieldToSelect('*')
|
36 |
+
->setOrder('name', 'asc');
|
37 |
+
|
38 |
+
if(count($collection) > 0)
|
39 |
+
{
|
40 |
+
foreach($collection as $menu)
|
41 |
+
{
|
42 |
+
$output[$menu->getId()] = $menu->getName();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
return $output;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
?>
|
app/code/community/ES/Custommenu/Model/Custommenu/Items.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Custommenu_Items extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('custommenu/custommenu_items');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getInputSelectParentItem()
|
12 |
+
{
|
13 |
+
$output = array();
|
14 |
+
$output[] = array('value' => '', 'label' => 'Select');
|
15 |
+
|
16 |
+
$collection = $this->getCollection()
|
17 |
+
->addFieldToSelect('*')
|
18 |
+
->setOrder('name', 'asc');
|
19 |
+
|
20 |
+
if(count($collection) > 0)
|
21 |
+
{
|
22 |
+
foreach($collection as $menu)
|
23 |
+
{
|
24 |
+
$output[] = array('value' => $menu->getId(), 'label' => $menu->getName());
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $output;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getInputSelectPages()
|
32 |
+
{
|
33 |
+
$output = array();
|
34 |
+
$output[] = array('value' => '', 'label' => 'Select');
|
35 |
+
|
36 |
+
$collection = Mage::getModel('cms/page')->getCollection()
|
37 |
+
->addFieldToSelect('*')
|
38 |
+
->setOrder('title', 'asc');
|
39 |
+
|
40 |
+
if(count($collection) > 0)
|
41 |
+
{
|
42 |
+
foreach($collection as $page)
|
43 |
+
{
|
44 |
+
$output[] = array('value' => $page->getId(), 'label' => $page->getTitle());
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
return $output;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getGridInputSelectPages()
|
52 |
+
{
|
53 |
+
$output = array();
|
54 |
+
$output[''] = 'Select';
|
55 |
+
|
56 |
+
$collection = Mage::getModel('cms/page')->getCollection()
|
57 |
+
->addFieldToSelect('*')
|
58 |
+
->setOrder('title', 'asc');
|
59 |
+
|
60 |
+
if(count($collection) > 0)
|
61 |
+
{
|
62 |
+
foreach($collection as $page)
|
63 |
+
{
|
64 |
+
$output[$page->getId()] = $page->getTitle();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
return $output;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getGridInputSelectParentItem()
|
72 |
+
{
|
73 |
+
$output = array();
|
74 |
+
$output[0] = 'None';
|
75 |
+
|
76 |
+
$collection = $this->getCollection()
|
77 |
+
->addFieldToSelect('*')
|
78 |
+
->setOrder('name', 'asc');
|
79 |
+
|
80 |
+
if(count($collection) > 0)
|
81 |
+
{
|
82 |
+
foreach($collection as $menu)
|
83 |
+
{
|
84 |
+
$output[$menu->getId()] = $menu->getName();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
return $output;
|
89 |
+
}
|
90 |
+
|
91 |
+
public function getRealUrl()
|
92 |
+
{
|
93 |
+
if($this->getCmsId())
|
94 |
+
{
|
95 |
+
$pageUrl = Mage::getModel('cms/page')->load($this->getCmsId())->getIdentifier();
|
96 |
+
return Mage::getUrl() . (($pageUrl == 'home')?'':$pageUrl);
|
97 |
+
}
|
98 |
+
return $this->getUrl();
|
99 |
+
}
|
100 |
+
|
101 |
+
public function getTargetHtml()
|
102 |
+
{
|
103 |
+
if($this->getTarget() != '')
|
104 |
+
{
|
105 |
+
return ' target="' . $this->getTarget() . '"';
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
public function getLevel($level = 0)
|
110 |
+
{
|
111 |
+
if($this->getParentId() == 0){
|
112 |
+
return $level;
|
113 |
+
}
|
114 |
+
$level++;
|
115 |
+
$menu = Mage::getModel('custommenu/custommenu_items')->load($this->getParentId());
|
116 |
+
return $menu->getLevel($level);
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
120 |
+
?>
|
app/code/community/ES/Custommenu/Model/Mysql4/Custommenu.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Mysql4_Custommenu extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the bannerslider_id refers to the key field in your database table.
|
8 |
+
$this->_init('custommenu/custommenu', 'custommenu_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/ES/Custommenu/Model/Mysql4/Custommenu/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Mysql4_Custommenu_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('custommenu/custommenu');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/ES/Custommenu/Model/Mysql4/Custommenu/Items.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Mysql4_Custommenu_Items extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the bannerslider_id refers to the key field in your database table.
|
8 |
+
$this->_init('custommenu/custommenu_items', 'custommenu_item_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/ES/Custommenu/Model/Mysql4/Custommenu/Items/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Mysql4_Custommenu_Items_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('custommenu/custommenu_items');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/ES/Custommenu/Model/Status.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Model_Status extends Varien_Object {
|
4 |
+
|
5 |
+
const STATUS_ENABLED = 1; // Menu status enabled
|
6 |
+
const STATUS_DISABLED = 2; // Menu status disabled
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Get status option arrays for status drop down in admin
|
10 |
+
*
|
11 |
+
* @return option array
|
12 |
+
*/
|
13 |
+
|
14 |
+
static public function getOptionArray() {
|
15 |
+
return array(
|
16 |
+
self::STATUS_ENABLED => Mage::helper('custommenu')->__('Enabled'),
|
17 |
+
self::STATUS_DISABLED => Mage::helper('custommenu')->__('Disabled')
|
18 |
+
);
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/ES/Custommenu/controllers/Adminhtml/Custommenu/ItemsController.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Adminhtml_Custommenu_ItemsController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
protected function _initAction() {
|
6 |
+
$this->loadLayout()
|
7 |
+
->_setActiveMenu('custommenu/items')
|
8 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Menu Items Manager'), Mage::helper('adminhtml')->__('Menu Items Manager'));
|
9 |
+
|
10 |
+
return $this;
|
11 |
+
}
|
12 |
+
|
13 |
+
public function indexAction() {
|
14 |
+
$this->_initAction()
|
15 |
+
->renderLayout();
|
16 |
+
}
|
17 |
+
|
18 |
+
public function editAction() {
|
19 |
+
$id = $this->getRequest()->getParam('id');
|
20 |
+
$model = Mage::getModel('custommenu/custommenu_items')->load($id);
|
21 |
+
|
22 |
+
if ($model->getId() || $id == 0) {
|
23 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
24 |
+
if (!empty($data)) {
|
25 |
+
$model->setData($data);
|
26 |
+
}
|
27 |
+
|
28 |
+
Mage::register('custommenu_data', $model);
|
29 |
+
|
30 |
+
$this->loadLayout();
|
31 |
+
$this->_setActiveMenu('custommenu/items');
|
32 |
+
|
33 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Menu Manager'), Mage::helper('adminhtml')->__('Menu Item Manager'));
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Menu News'), Mage::helper('adminhtml')->__('Menu Item News'));
|
35 |
+
|
36 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
37 |
+
|
38 |
+
$this->_addContent($this->getLayout()->createBlock('custommenu/adminhtml_custommenu_items_edit'))
|
39 |
+
->_addLeft($this->getLayout()->createBlock('custommenu/adminhtml_custommenu_items_edit_tabs'));
|
40 |
+
|
41 |
+
$this->renderLayout();
|
42 |
+
} else {
|
43 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('custommenu')->__('Menu Item does not exist'));
|
44 |
+
$this->_redirect('*/*/');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
public function newAction() {
|
49 |
+
$this->_forward('edit');
|
50 |
+
}
|
51 |
+
|
52 |
+
public function saveAction() {
|
53 |
+
if ($data = $this->getRequest()->getPost()) {
|
54 |
+
|
55 |
+
$model = Mage::getModel('custommenu/custommenu_items');
|
56 |
+
|
57 |
+
$model->setData($data)
|
58 |
+
->setId($this->getRequest()->getParam('id'));
|
59 |
+
|
60 |
+
try {
|
61 |
+
|
62 |
+
$model->save();
|
63 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('custommenu')->__('Menu Item was successfully saved'));
|
64 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
65 |
+
|
66 |
+
if ($this->getRequest()->getParam('back')) {
|
67 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
$this->_redirect('*/*/');
|
71 |
+
return;
|
72 |
+
} catch (Exception $e) {
|
73 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
74 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
75 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('custommenu')->__('Unable to find item to save'));
|
80 |
+
$this->_redirect('*/*/');
|
81 |
+
}
|
82 |
+
|
83 |
+
public function deleteAction() {
|
84 |
+
if ($this->getRequest()->getParam('id') > 0) {
|
85 |
+
try {
|
86 |
+
$model = Mage::getModel('custommenu/custommenu_items')->load($this->getRequest()->getParam('id'));
|
87 |
+
Mage::helper('custommenu')->removeChilds($model->getId());
|
88 |
+
$model->delete();
|
89 |
+
|
90 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Menu Item was successfully deleted'));
|
91 |
+
$this->_redirect('*/*/');
|
92 |
+
} catch (Exception $e) {
|
93 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
94 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
$this->_redirect('*/*/');
|
98 |
+
}
|
99 |
+
|
100 |
+
public function massDeleteAction() {
|
101 |
+
|
102 |
+
$contactformIds = $this->getRequest()->getParam('custommenu');
|
103 |
+
if (!is_array($contactformIds)) {
|
104 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select menu(s)'));
|
105 |
+
} else {
|
106 |
+
try {
|
107 |
+
foreach ($contactformIds as $contactformId) {
|
108 |
+
$model = Mage::getModel('custommenu/custommenu_items')->load($contactformId);
|
109 |
+
Mage::helper('custommenu')->removeChilds($model->getId());
|
110 |
+
$model->delete();
|
111 |
+
}
|
112 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
113 |
+
Mage::helper('adminhtml')->__(
|
114 |
+
'Total of %d record(s) were successfully deleted', count($contactformIds)
|
115 |
+
)
|
116 |
+
);
|
117 |
+
} catch (Exception $e) {
|
118 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
119 |
+
}
|
120 |
+
}
|
121 |
+
$this->_redirect('*/*/index');
|
122 |
+
}
|
123 |
+
|
124 |
+
public function massStatusAction() {
|
125 |
+
$bannersliderIds = $this->getRequest()->getParam('custommenu');
|
126 |
+
if (!is_array($bannersliderIds)) {
|
127 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select menu(s)'));
|
128 |
+
} else {
|
129 |
+
try {
|
130 |
+
foreach ($bannersliderIds as $bannersliderId) {
|
131 |
+
$bannerslider = Mage::getSingleton('custommenu/custommenu_items')
|
132 |
+
->load($bannersliderId)
|
133 |
+
->setStatus($this->getRequest()->getParam('status'))
|
134 |
+
->setIsMassupdate(true)
|
135 |
+
->save();
|
136 |
+
}
|
137 |
+
$this->_getSession()->addSuccess(
|
138 |
+
$this->__('Total of %d record(s) were successfully updated', count($bannersliderIds))
|
139 |
+
);
|
140 |
+
} catch (Exception $e) {
|
141 |
+
$this->_getSession()->addError($e->getMessage());
|
142 |
+
}
|
143 |
+
}
|
144 |
+
$this->_redirect('*/*/index');
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
app/code/community/ES/Custommenu/controllers/Adminhtml/CustommenuController.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Custommenu_Adminhtml_CustommenuController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Controller setup action
|
7 |
+
*
|
8 |
+
* @return \ES_Custommenu_Adminhtml_CustommenuController
|
9 |
+
*/
|
10 |
+
protected function _initAction() {
|
11 |
+
$this->loadLayout()
|
12 |
+
->_setActiveMenu('custommenu/items')
|
13 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Menu Manager'), Mage::helper('adminhtml')->__('Menu Manager'));
|
14 |
+
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Custommenu index action
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function indexAction() {
|
23 |
+
$this->_initAction()->renderLayout();
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Custommenu edit action
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
public function editAction() {
|
31 |
+
$id = $this->getRequest()->getParam('id');
|
32 |
+
$model = Mage::getModel('custommenu/custommenu')->load($id);
|
33 |
+
|
34 |
+
if ($model->getId() || $id == 0) {
|
35 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
36 |
+
if (!empty($data)) {
|
37 |
+
$model->setData($data);
|
38 |
+
}
|
39 |
+
|
40 |
+
Mage::register('custommenu_data', $model);
|
41 |
+
|
42 |
+
$this->loadLayout();
|
43 |
+
$this->_setActiveMenu('custommenu/items');
|
44 |
+
|
45 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Menu Manager'), Mage::helper('adminhtml')->__('Menu Manager'));
|
46 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Menu News'), Mage::helper('adminhtml')->__('Menu News'));
|
47 |
+
|
48 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
49 |
+
|
50 |
+
$this->_addContent($this->getLayout()->createBlock('custommenu/adminhtml_custommenu_edit'))
|
51 |
+
->_addLeft($this->getLayout()->createBlock('custommenu/adminhtml_custommenu_edit_tabs'));
|
52 |
+
|
53 |
+
$this->renderLayout();
|
54 |
+
} else {
|
55 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('custommenu')->__('Menu does not exist'));
|
56 |
+
$this->_redirect('*/*/');
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Custom menu new action forwarded to edit action
|
62 |
+
*
|
63 |
+
*/
|
64 |
+
public function newAction() {
|
65 |
+
$this->_forward('edit');
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Custom menu save action
|
70 |
+
*
|
71 |
+
* @return type
|
72 |
+
*/
|
73 |
+
public function saveAction() {
|
74 |
+
if ($data = $this->getRequest()->getPost()) {
|
75 |
+
|
76 |
+
$model = Mage::getModel('custommenu/custommenu');
|
77 |
+
|
78 |
+
$model->setData($data)
|
79 |
+
->setId($this->getRequest()->getParam('id'));
|
80 |
+
|
81 |
+
try {
|
82 |
+
|
83 |
+
$model->save();
|
84 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('custommenu')->__('Menu was successfully saved'));
|
85 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
86 |
+
|
87 |
+
if ($this->getRequest()->getParam('back')) {
|
88 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
$this->_redirect('*/*/');
|
92 |
+
return;
|
93 |
+
} catch (Exception $e) {
|
94 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
95 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
96 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('custommenu')->__('Unable to find item to save'));
|
101 |
+
$this->_redirect('*/*/');
|
102 |
+
}
|
103 |
+
|
104 |
+
public function deleteAction() {
|
105 |
+
if ($this->getRequest()->getParam('id') > 0) {
|
106 |
+
try {
|
107 |
+
$model = Mage::getModel('custommenu/custommenu')->load($this->getRequest()->getParam('id'));
|
108 |
+
$menuItemModel = Mage::getModel('custommenu/custommenu_items')->getCollection()->addFieldToFilter('menu_id', $model->getId());
|
109 |
+
foreach ($menuItemModel as $val) {
|
110 |
+
$val->delete();
|
111 |
+
}
|
112 |
+
$model->delete();
|
113 |
+
|
114 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Menu was successfully deleted'));
|
115 |
+
$this->_redirect('*/*/');
|
116 |
+
} catch (Exception $e) {
|
117 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
118 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
119 |
+
}
|
120 |
+
}
|
121 |
+
$this->_redirect('*/*/');
|
122 |
+
}
|
123 |
+
|
124 |
+
public function massDeleteAction() {
|
125 |
+
|
126 |
+
$contactformIds = $this->getRequest()->getParam('custommenu');
|
127 |
+
if (!is_array($contactformIds)) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select menu(s)'));
|
129 |
+
} else {
|
130 |
+
try {
|
131 |
+
foreach ($contactformIds as $contactformId) {
|
132 |
+
$model = Mage::getModel('custommenu/custommenu')->load($contactformId);
|
133 |
+
$menuItemModel = Mage::getModel('custommenu/custommenu_items')->getCollection()->addFieldToFilter('menu_id', $model->getId());
|
134 |
+
foreach ($menuItemModel as $val) {
|
135 |
+
$val->delete();
|
136 |
+
}
|
137 |
+
$model->delete();
|
138 |
+
}
|
139 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
140 |
+
Mage::helper('adminhtml')->__(
|
141 |
+
'Total of %d record(s) were successfully deleted', count($contactformIds)
|
142 |
+
)
|
143 |
+
);
|
144 |
+
} catch (Exception $e) {
|
145 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
146 |
+
}
|
147 |
+
}
|
148 |
+
$this->_redirect('*/*/index');
|
149 |
+
}
|
150 |
+
|
151 |
+
public function massStatusAction() {
|
152 |
+
$bannersliderIds = $this->getRequest()->getParam('custommenu');
|
153 |
+
if (!is_array($bannersliderIds)) {
|
154 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select menu(s)'));
|
155 |
+
} else {
|
156 |
+
try {
|
157 |
+
foreach ($bannersliderIds as $bannersliderId) {
|
158 |
+
$bannerslider = Mage::getSingleton('custommenu/custommenu')
|
159 |
+
->load($bannersliderId)
|
160 |
+
->setStatus($this->getRequest()->getParam('status'))
|
161 |
+
->setIsMassupdate(true)
|
162 |
+
->save();
|
163 |
+
}
|
164 |
+
$this->_getSession()->addSuccess(
|
165 |
+
$this->__('Total of %d record(s) were successfully updated', count($bannersliderIds))
|
166 |
+
);
|
167 |
+
} catch (Exception $e) {
|
168 |
+
$this->_getSession()->addError($e->getMessage());
|
169 |
+
}
|
170 |
+
}
|
171 |
+
$this->_redirect('*/*/index');
|
172 |
+
}
|
173 |
+
|
174 |
+
}
|
app/code/community/ES/Custommenu/etc/config.xml
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ES_Custommenu>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</ES_Custommenu>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<custommenu>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>ES_Custommenu</module>
|
14 |
+
<frontName>custommenu</frontName>
|
15 |
+
</args>
|
16 |
+
</custommenu>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<custommenu>
|
21 |
+
<file>es_custommenu.xml</file>
|
22 |
+
</custommenu>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<custommenu>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>ES_Custommenu</module>
|
32 |
+
<frontName>custommenu</frontName>
|
33 |
+
</args>
|
34 |
+
</custommenu>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<cms>
|
40 |
+
<children>
|
41 |
+
<custommenu module="custommenu">
|
42 |
+
<title>Custom Menu</title>
|
43 |
+
<sort_order>71</sort_order>
|
44 |
+
<children>
|
45 |
+
<menu module="custommenu">
|
46 |
+
<title>Manage Menus</title>
|
47 |
+
<sort_order>1</sort_order>
|
48 |
+
<action>custommenu/adminhtml_custommenu</action>
|
49 |
+
</menu>
|
50 |
+
<items module="custommenu">
|
51 |
+
<title>Manage Menu Items</title>
|
52 |
+
<sort_order>2</sort_order>
|
53 |
+
<action>custommenu/adminhtml_custommenu_items</action>
|
54 |
+
</items>
|
55 |
+
</children>
|
56 |
+
</custommenu>
|
57 |
+
</children>
|
58 |
+
</cms>
|
59 |
+
</menu>
|
60 |
+
<acl>
|
61 |
+
<resources>
|
62 |
+
<all>
|
63 |
+
<title>Allow Everything</title>
|
64 |
+
</all>
|
65 |
+
<admin>
|
66 |
+
<children>
|
67 |
+
<ES_Custommenu>
|
68 |
+
<title>Custommenu Module</title>
|
69 |
+
<sort_order>10</sort_order>
|
70 |
+
</ES_Custommenu>
|
71 |
+
<system>
|
72 |
+
<children>
|
73 |
+
<config>
|
74 |
+
<children>
|
75 |
+
<custommenu translate="title" module="custommenu">
|
76 |
+
<title>Custommenu Settings</title>
|
77 |
+
<sort_order>50</sort_order>
|
78 |
+
</custommenu>
|
79 |
+
</children>
|
80 |
+
</config>
|
81 |
+
</children>
|
82 |
+
</system>
|
83 |
+
</children>
|
84 |
+
</admin>
|
85 |
+
</resources>
|
86 |
+
</acl>
|
87 |
+
<layout>
|
88 |
+
<updates>
|
89 |
+
<custommenu>
|
90 |
+
<file>es_custommenu.xml</file>
|
91 |
+
</custommenu>
|
92 |
+
</updates>
|
93 |
+
</layout>
|
94 |
+
</adminhtml>
|
95 |
+
<global>
|
96 |
+
<models>
|
97 |
+
<custommenu>
|
98 |
+
<class>ES_Custommenu_Model</class>
|
99 |
+
<resourceModel>custommenu_mysql4</resourceModel>
|
100 |
+
</custommenu>
|
101 |
+
<custommenu_mysql4>
|
102 |
+
<class>ES_Custommenu_Model_Mysql4</class>
|
103 |
+
<entities>
|
104 |
+
<custommenu>
|
105 |
+
<table>es_custommenu</table>
|
106 |
+
</custommenu>
|
107 |
+
<custommenu_items>
|
108 |
+
<table>es_custommenu_item</table>
|
109 |
+
</custommenu_items>
|
110 |
+
</entities>
|
111 |
+
</custommenu_mysql4>
|
112 |
+
</models>
|
113 |
+
<resources>
|
114 |
+
<custommenu_setup>
|
115 |
+
<setup>
|
116 |
+
<module>ES_Custommenu</module>
|
117 |
+
</setup>
|
118 |
+
<connection>
|
119 |
+
<use>core_setup</use>
|
120 |
+
</connection>
|
121 |
+
</custommenu_setup>
|
122 |
+
<custommenu_write>
|
123 |
+
<connection>
|
124 |
+
<use>core_write</use>
|
125 |
+
</connection>
|
126 |
+
</custommenu_write>
|
127 |
+
<custommenu_read>
|
128 |
+
<connection>
|
129 |
+
<use>core_read</use>
|
130 |
+
</connection>
|
131 |
+
</custommenu_read>
|
132 |
+
</resources>
|
133 |
+
<blocks>
|
134 |
+
<custommenu>
|
135 |
+
<class>ES_Custommenu_Block</class>
|
136 |
+
</custommenu>
|
137 |
+
</blocks>
|
138 |
+
<helpers>
|
139 |
+
<custommenu>
|
140 |
+
<class>ES_Custommenu_Helper</class>
|
141 |
+
</custommenu>
|
142 |
+
</helpers>
|
143 |
+
</global>
|
144 |
+
<default>
|
145 |
+
<custommenu>
|
146 |
+
<custommenu_setup>
|
147 |
+
<enabled>1</enabled>
|
148 |
+
<width>100</width>
|
149 |
+
<height>100</height>
|
150 |
+
<effect>random</effect>
|
151 |
+
</custommenu_setup>
|
152 |
+
</custommenu>
|
153 |
+
</default>
|
154 |
+
</config>
|
app/code/community/ES/Custommenu/sql/custommenu_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
DROP TABLE IF EXISTS {$this->getTable('es_custommenu')};
|
10 |
+
CREATE TABLE {$this->getTable('es_custommenu')} (
|
11 |
+
`custommenu_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`name` varchar(255) NOT NULL default '',
|
13 |
+
`label` varchar(255) NOT NULL default '',
|
14 |
+
`status` int(2) NOT NULL default 1,
|
15 |
+
PRIMARY KEY (`custommenu_id`)
|
16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
+
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->run("
|
21 |
+
|
22 |
+
DROP TABLE IF EXISTS {$this->getTable('es_custommenu_item')};
|
23 |
+
CREATE TABLE {$this->getTable('es_custommenu_item')} (
|
24 |
+
`custommenu_item_id` int(11) unsigned NOT NULL auto_increment,
|
25 |
+
`name` varchar(255) NOT NULL default '',
|
26 |
+
`menu_id` int(11) NOT NULL default 0,
|
27 |
+
`parent_id` int(11) NOT NULL default 0,
|
28 |
+
`url` varchar(255) default '',
|
29 |
+
`cms_id` int(11) default 0,
|
30 |
+
`target` varchar(255) default '',
|
31 |
+
`order` varchar(255) NOT NULL default '',
|
32 |
+
`status` int(2) NOT NULL default 1,
|
33 |
+
PRIMARY KEY (`custommenu_item_id`)
|
34 |
+
|
35 |
+
#INDEX par_ind (menu_id),
|
36 |
+
#FOREIGN KEY (menu_id) REFERENCES {$this->getTable('custommenu_item')}(custommenu_id)
|
37 |
+
# ON DELETE CASCADE
|
38 |
+
# ON UPDATE CASCADE
|
39 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
40 |
+
|
41 |
+
");
|
42 |
+
|
43 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/es_custommenu.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<custommenu_adminhtml_custommenu_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="custommenu/adminhtml_custommenu" name="custommenu" />
|
6 |
+
</reference>
|
7 |
+
</custommenu_adminhtml_custommenu_index>
|
8 |
+
<custommenu_adminhtml_custommenu_items_index>
|
9 |
+
<reference name="content">
|
10 |
+
<block type="custommenu/adminhtml_custommenu_items" name="custommenu_items" />
|
11 |
+
</reference>
|
12 |
+
</custommenu_adminhtml_custommenu_items_index>
|
13 |
+
</layout>
|
app/design/frontend/base/default/layout/es_custommenu.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default translate="label">
|
4 |
+
<reference name="top.menu">
|
5 |
+
<block type="custommenu/custommenu" after="-" name="custommenu.top">
|
6 |
+
<action method="setMenuLabel"><value>main_menu</value></action>
|
7 |
+
<action method="setHtmlId"><value>nav</value></action>
|
8 |
+
</block>
|
9 |
+
</reference>
|
10 |
+
</default>
|
11 |
+
</layout>
|
app/design/frontend/base/default/template/es_custommenu/menu.phtml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $menuLabel = $this->getMenuLabel(null); ?>
|
2 |
+
<?php if ($menuLabel != null) { ?>
|
3 |
+
<?php $menu = Mage::getModel('custommenu/custommenu')->load($menuLabel, 'label') ?>
|
4 |
+
<?php $menuItems = $this->getMenuItems($menuLabel); ?>
|
5 |
+
<?php if (count($menuItems) > 0) { ?>
|
6 |
+
<ul class="es_custommenu <?php echo $menuLabel ?> <?php echo $this->getHtmlClass() ?>" id="<?php echo $this->getHtmlId() ?>">
|
7 |
+
<?php $i = 0; ?>
|
8 |
+
<?php foreach ($menuItems as $_menuItem) {
|
9 |
+
$i++;
|
10 |
+
?>
|
11 |
+
<?php if ($i == count($menuItems)) { ?>
|
12 |
+
<?php $class = 'es_menu_tier0 last' ?>
|
13 |
+
<?php } else if ($i == 1) { ?>
|
14 |
+
<?php $class = 'es_menu_tier0 first' ?>
|
15 |
+
<?php } ?>
|
16 |
+
<li class="<?php echo $class ?>">
|
17 |
+
<a href="<?php echo $_menuItem->getRealUrl() ?>" <?php echo $_menuItem->getTargetHtml() ?>><span><?php echo $_menuItem->getName() ?></span></a>
|
18 |
+
<?php echo $this->getSubMenuBlock($_menuItem)->toHtml(); ?>
|
19 |
+
</li>
|
20 |
+
<?php } ?>
|
21 |
+
</ul>
|
22 |
+
<?php } ?>
|
23 |
+
<?php } ?>
|
app/design/frontend/base/default/template/es_custommenu/submenu.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $parentMenu = $this->getParentMenu() ?>
|
2 |
+
<?php if ($parentMenu) { ?>
|
3 |
+
<?php $subMenuItems = $this->getMenuSubItems($parentMenu); ?>
|
4 |
+
<?php if (count($subMenuItems) > 0) { ?>
|
5 |
+
<ul class="es_customsubmenu_tier<?php echo $parentMenu->getLevel() + 1 ?> <?php echo $parentMenu->getClass() ?>" <?php echo $parentMenu->getAttributes() ?>>
|
6 |
+
<?php $i = 0; ?>
|
7 |
+
<?php foreach ($subMenuItems as $_subMenuItem) {
|
8 |
+
$i++;
|
9 |
+
?>
|
10 |
+
<?php if($i == count($subMenuItems)){ ?>
|
11 |
+
<?php $class = 'es_menu_tier' . $_subMenuItem->getLevel() . ' last' ?>
|
12 |
+
<?php }else if($i == 1){ ?>
|
13 |
+
<?php $class = 'es_menu_tier' . $_subMenuItem->getLevel() . ' first' ?>
|
14 |
+
<?php } ?>
|
15 |
+
<li class="<?php echo $class ?>">
|
16 |
+
<a href="<?php echo $_subMenuItem->getRealUrl() ?>" <?php echo $_subMenuItem->getTargetHtml() ?>><span><?php echo $_subMenuItem->getName() ?></span></a>
|
17 |
+
<?php echo $this->getSubMenuBlock($_subMenuItem)->toHtml(); ?>
|
18 |
+
</li>
|
19 |
+
<?php } ?>
|
20 |
+
</ul>
|
21 |
+
<?php } ?>
|
22 |
+
<?php } ?>
|
app/etc/modules/ES_Custommenu.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ES_Custommenu>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</ES_Custommenu>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>ES_Custommenu</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Eleven Soft CustomMenu is very simple module for easy creation menus and add it to any area of site.</summary>
|
10 |
+
<description>Eleven Soft CustomMenu is very simple module for easy creation menus and add it to any area of site.
|
11 |
+

|
12 |
+
It support unlimited sub menus. In admin you have two sections. First one is to create menu for example main menu, footer menu, right menu etc. In second section you can create menu items assign it to menus and also you can add parent of menu to make submenus.
|
13 |
+

|
14 |
+
For url of your link you can enter URL or choose CMS page.</description>
|
15 |
+
<notes>This is first stable version.
|
16 |
+

|
17 |
+
Release 1.0.0
|
18 |
+
- Admin page for managing menus
|
19 |
+
- Admin page for managing menu items and submenus
|
20 |
+
- Block for showing menu
|
21 |
+
- Sample layout XML to show how all working</notes>
|
22 |
+
<authors><author><name>Eleven Soft</name><user>elevensoft</user><email>support@eleven-soft.com</email></author></authors>
|
23 |
+
<date>2012-09-07</date>
|
24 |
+
<time>23:31:48</time>
|
25 |
+
<contents><target name="magecommunity"><dir name="ES"><dir name="Custommenu"><dir name="Block"><dir name="Adminhtml"><dir name="Custommenu"><dir name="Edit"><file name="Form.php" hash="1d0f8838598fd79eba08b5081d6dc465"/><dir name="Tab"><file name="Form.php" hash="850d547d96ca38134391db885db8de42"/></dir><file name="Tabs.php" hash="4ead7691e23b12b594b439641d4fa8b8"/></dir><file name="Edit.php" hash="4c0daf6ed28b7f6d56076f366c6fc816"/><file name="Grid.php" hash="dfc1c4721bb2d4c3db16ead1f1994812"/><dir name="Items"><dir name="Edit"><file name="Form.php" hash="70894a455bfc71d478658066f9a03ba9"/><dir name="Tab"><file name="Form.php" hash="c7027e85f6063c49a75b67e39c931a2c"/></dir><file name="Tabs.php" hash="191f684960d2d98d701db2b325cc4243"/></dir><file name="Edit.php" hash="132fa9d73ed3507beb98fe4a8b725999"/><file name="Grid.php" hash="64c62980d720ad66c4c8ac9e4b068f00"/></dir><file name="Items.php" hash="59efdfc86ee12c908efdddf898e92d24"/></dir><file name="Custommenu.php" hash="5ce4f2e24533cfe777afca772d8bc318"/></dir><file name="Custommenu.php" hash="04bb6ab2396a5a8e3937e99710298db5"/></dir><dir name="Helper"><file name="Data.php" hash="b33b8f793555f288bc896ac7bf3dae9b"/></dir><dir name="Model"><dir name="Custommenu"><file name="Items.php" hash="e1734fb3d12e63078201b11efb6997a1"/></dir><file name="Custommenu.php" hash="4d106b3703735057e768dc559dff7620"/><dir name="Mysql4"><dir name="Custommenu"><file name="Collection.php" hash="73e6ee0afe6048c19aca869cd358ab4c"/><dir name="Items"><file name="Collection.php" hash="41cf88e7be54767529c984cc39ef0e36"/></dir><file name="Items.php" hash="0fa8fe08213d4521f4361f6ecf51bae7"/></dir><file name="Custommenu.php" hash="6167ecf64ca967a229e76010f3ceebf6"/></dir><file name="Status.php" hash="349dfeea66da3faf8720db74ff6cc00d"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Custommenu"><file name="ItemsController.php" hash="05a88f5cf78e49f2cdff4da2f7a97122"/></dir><file name="CustommenuController.php" hash="9315ccfc69debbfac31eba700186ea36"/></dir></dir><dir name="etc"><file name="config.xml" hash="f85e7d951748bc298ede0249159a3d30"/></dir><dir name="sql"><dir name="custommenu_setup"><file name="mysql4-install-1.0.0.php" hash="1a7046fadd327ed006ff789a676f790b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ES_Custommenu.xml" hash="c946fff190f507f00aac2a23e500b365"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="es_custommenu"><file name="menu.phtml" hash="84f8c24f5fccd72dabf8b2eabb4f2f03"/><file name="submenu.phtml" hash="4671bb5cfaa26e9344299b5282c2a520"/></dir></dir><dir name="layout"><file name="es_custommenu.xml" hash="19322f67018e509de839978a726a065e"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="es_custommenu.xml" hash="45fe59e4f476e5237870162f498ae591"/></dir></dir></dir></dir></target></contents>
|
26 |
+
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
28 |
+
</package>
|