Version Notes
Prepared admin UI and functionality for setting up themes by custom group and dates range. Prepared for Magento Connect 2.0
Download this release
Release Info
| Developer | Lanot |
| Extension | Lanot_AdvancedTheme |
| Version | 1.0.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0.0
- app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design.php +64 -0
- app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit.php +94 -0
- app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit/Form.php +47 -0
- app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit/Tab/General.php +151 -0
- app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit/Tabs.php +49 -0
- app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Grid.php +95 -0
- app/code/community/Lanot/AdvancedTheme/Helper/Admin.php +40 -0
- app/code/community/Lanot/AdvancedTheme/Helper/Data.php +38 -0
- app/code/community/Lanot/AdvancedTheme/Model/Design.php +45 -0
- app/code/community/Lanot/AdvancedTheme/Model/Mysql4/Design.php +189 -0
- app/code/community/Lanot/AdvancedTheme/Model/Mysql4/Design/Collection.php +55 -0
- app/code/community/Lanot/AdvancedTheme/Model/Observer.php +101 -0
- app/code/community/Lanot/AdvancedTheme/controllers/Adminhtml/DesignController.php +73 -0
- app/code/community/Lanot/AdvancedTheme/etc/adminhtml.xml +74 -0
- app/code/community/Lanot/AdvancedTheme/etc/config.xml +91 -0
- app/code/community/Lanot/AdvancedTheme/etc/system.xml +42 -0
- app/code/community/Lanot/AdvancedTheme/sql/lanot_advancedtheme_setup/mysql4-install-1.0.0.0.php +45 -0
- app/code/community/Lanot/Core/Block/Adminhtml/Grid/Abstract.php +329 -0
- app/code/community/Lanot/Core/Controller/Adminhtml/AbstractController.php +334 -0
- app/code/community/Lanot/Core/Model/Item/Interface.php +37 -0
- app/design/adminhtml/default/default/layout/lanot_advancedtheme.xml +39 -0
- app/etc/modules/Lanot_AdvancedTheme.xml +13 -0
- app/etc/modules/Lanot_Core.xml +13 -0
- package.xml +18 -0
app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design.php
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Stickers List admin grid container
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
class Lanot_AdvancedTheme_Block_Adminhtml_Design
|
| 28 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 29 |
+
{
|
| 30 |
+
/**
|
| 31 |
+
* Block constructor
|
| 32 |
+
*/
|
| 33 |
+
public function __construct()
|
| 34 |
+
{
|
| 35 |
+
$this->_blockGroup = 'lanot_advancedtheme';
|
| 36 |
+
$this->_controller = 'adminhtml_design';
|
| 37 |
+
$this->_headerText = $this->_getHelper()->__('Manage Design Changes');
|
| 38 |
+
|
| 39 |
+
parent::__construct();
|
| 40 |
+
|
| 41 |
+
if ($this->_getAclHelper()->isActionAllowed('manage_sticker/save')) {
|
| 42 |
+
$this->_updateButton('add', 'label', $this->_getHelper()->__('Add Design Change'));
|
| 43 |
+
} else {
|
| 44 |
+
$this->_removeButton('add');
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 50 |
+
*/
|
| 51 |
+
protected function _getHelper()
|
| 52 |
+
{
|
| 53 |
+
return Mage::helper('lanot_advancedtheme');
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* @return Lanot_AdvancedTheme_Helper_Admin
|
| 58 |
+
*/
|
| 59 |
+
protected function _getAclHelper()
|
| 60 |
+
{
|
| 61 |
+
return Mage::helper('lanot_advancedtheme/admin');
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit.php
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Sticker Sticker admin edit form container
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_AdvancedTheme_Block_Adminhtml_Design_Edit
|
| 27 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 28 |
+
{
|
| 29 |
+
/**
|
| 30 |
+
* Initialize edit form container
|
| 31 |
+
*
|
| 32 |
+
*/
|
| 33 |
+
public function __construct()
|
| 34 |
+
{
|
| 35 |
+
$this->_objectId = 'id';
|
| 36 |
+
$this->_blockGroup = 'lanot_advancedtheme';
|
| 37 |
+
$this->_controller = 'adminhtml_design';
|
| 38 |
+
|
| 39 |
+
parent::__construct();
|
| 40 |
+
|
| 41 |
+
//check permissions
|
| 42 |
+
if ($this->_getAclHelper()->isActionAllowed('manage_sticker/save')) {
|
| 43 |
+
$this->_updateButton('save', 'label', $this->_getHelper()->__('Save Sticker Item'));
|
| 44 |
+
$this->_addButton('saveandcontinue', array(
|
| 45 |
+
'label' => $this->_getHelper()->__('Save and Continue Edit'),
|
| 46 |
+
'onclick' => 'saveAndContinueEdit()',
|
| 47 |
+
'class' => 'save',
|
| 48 |
+
), -100);
|
| 49 |
+
|
| 50 |
+
$this->_formScripts[] = "
|
| 51 |
+
function saveAndContinueEdit(){
|
| 52 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
| 53 |
+
}";
|
| 54 |
+
} else {
|
| 55 |
+
$this->_removeButton('save');
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
if ($this->_getAclHelper()->isActionAllowed('manage_sticker/delete')) {
|
| 59 |
+
$this->_updateButton('delete', 'label', $this->_getHelper()->__('Delete Design Change'));
|
| 60 |
+
} else {
|
| 61 |
+
$this->_removeButton('delete');
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* @return string
|
| 67 |
+
*/
|
| 68 |
+
public function getHeaderText()
|
| 69 |
+
{
|
| 70 |
+
$header = '';
|
| 71 |
+
if (Mage::registry('design')->getId()) {
|
| 72 |
+
$header = $this->_getHelper()->__('Edit Design Change');
|
| 73 |
+
} else {
|
| 74 |
+
$header = $this->_getHelper()->__('New Design Change');
|
| 75 |
+
}
|
| 76 |
+
return $header;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 81 |
+
*/
|
| 82 |
+
protected function _getHelper()
|
| 83 |
+
{
|
| 84 |
+
return Mage::helper('lanot_advancedtheme');
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* @return Lanot_AdvancedTheme_Helper_Admin
|
| 89 |
+
*/
|
| 90 |
+
protected function _getAclHelper()
|
| 91 |
+
{
|
| 92 |
+
return Mage::helper('lanot_advancedtheme/admin');
|
| 93 |
+
}
|
| 94 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit/Form.php
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Sticker admin edit form block
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_AdvancedTheme_Block_Adminhtml_Design_Edit_Form
|
| 27 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
| 28 |
+
{
|
| 29 |
+
/**
|
| 30 |
+
* Prepare FORM action
|
| 31 |
+
*
|
| 32 |
+
* @return Lanot_AdvancedTheme_Block_Adminhtml_Design_Edit_Form
|
| 33 |
+
*/
|
| 34 |
+
protected function _prepareForm()
|
| 35 |
+
{
|
| 36 |
+
$form = new Varien_Data_Form(array(
|
| 37 |
+
'id' => 'edit_form',
|
| 38 |
+
'action' => $this->getUrl('*/*/save'),
|
| 39 |
+
'method' => 'post',
|
| 40 |
+
'enctype' => 'multipart/form-data'
|
| 41 |
+
));
|
| 42 |
+
|
| 43 |
+
$form->setUseContainer(true);
|
| 44 |
+
$this->setForm($form);
|
| 45 |
+
return parent::_prepareForm();
|
| 46 |
+
}
|
| 47 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit/Tab/General.php
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Sticker admin edit form main tab block
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_AdvancedTheme_Block_Adminhtml_Design_Edit_Tab_General
|
| 27 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
| 28 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
| 29 |
+
{
|
| 30 |
+
protected function _prepareForm()
|
| 31 |
+
{
|
| 32 |
+
$options = $this->_getCustomerGroupCollection()->toOptionArray();
|
| 33 |
+
array_unshift($options, array('value' => '', 'label' => ''));
|
| 34 |
+
|
| 35 |
+
$form = new Varien_Data_Form();
|
| 36 |
+
|
| 37 |
+
$fieldset = $form->addFieldset('general', array('legend' => $this->_getHelper()->__('General Settings')));
|
| 38 |
+
|
| 39 |
+
if (Mage::registry('design') && Mage::registry('design')->getId()) {
|
| 40 |
+
$fieldset->addField('design_change_id', 'hidden', array(
|
| 41 |
+
'name' => 'id',
|
| 42 |
+
//'value'
|
| 43 |
+
));
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
| 47 |
+
$fieldset->addField('store_id', 'select', array(
|
| 48 |
+
'label' => $this->_getHelper()->__('Store'),
|
| 49 |
+
'title' => $this->_getHelper()->__('Store'),
|
| 50 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
|
| 51 |
+
'name' => 'store_id',
|
| 52 |
+
'required' => true,
|
| 53 |
+
));
|
| 54 |
+
} else {
|
| 55 |
+
$fieldset->addField('store_id', 'hidden', array(
|
| 56 |
+
'name' => 'store_id',
|
| 57 |
+
'value' => Mage::app()->getStore(true)->getId(),
|
| 58 |
+
));
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
$fieldset->addField('customer_group_id', 'select', array(
|
| 62 |
+
'name' => 'customer_group_id',
|
| 63 |
+
'label' => $this->_getHelper()->__('Customer Group'),
|
| 64 |
+
'title' => $this->_getHelper()->__('Customer Group'),
|
| 65 |
+
'values' => $options,
|
| 66 |
+
), 'store_id');
|
| 67 |
+
|
| 68 |
+
$fieldset->addField('design', 'select', array(
|
| 69 |
+
'label' => $this->_getHelper()->__('Custom Design'),
|
| 70 |
+
'title' => $this->_getHelper()->__('Custom Design'),
|
| 71 |
+
'values' => Mage::getSingleton('core/design_source_design')->getAllOptions(),
|
| 72 |
+
'name' => 'design',
|
| 73 |
+
'required' => true,
|
| 74 |
+
));
|
| 75 |
+
|
| 76 |
+
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
| 77 |
+
$fieldset->addField('date_from', 'date', array(
|
| 78 |
+
'label' => $this->_getHelper()->__('Date From'),
|
| 79 |
+
'title' => $this->_getHelper()->__('Date From'),
|
| 80 |
+
'name' => 'date_from',
|
| 81 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
| 82 |
+
'format' => $dateFormatIso,
|
| 83 |
+
//'required' => true,
|
| 84 |
+
));
|
| 85 |
+
$fieldset->addField('date_to', 'date', array(
|
| 86 |
+
'label' => $this->_getHelper()->__('Date To'),
|
| 87 |
+
'title' => $this->_getHelper()->__('Date To'),
|
| 88 |
+
'name' => 'date_to',
|
| 89 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
| 90 |
+
'format' => $dateFormatIso,
|
| 91 |
+
//'required' => true,
|
| 92 |
+
));
|
| 93 |
+
|
| 94 |
+
$formData = Mage::getSingleton('adminhtml/session')->getDesignData(true);
|
| 95 |
+
if (!$formData){
|
| 96 |
+
$formData = Mage::registry('design')->getData();
|
| 97 |
+
} else {
|
| 98 |
+
$formData = $formData['design'];
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
//fixes for dates
|
| 103 |
+
if (!empty($formData['date_from'])) {
|
| 104 |
+
$formData['date_from'] = Varien_Date::formatDate($formData['date_from'], false);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
if (!empty($formData['date_to'])) {
|
| 108 |
+
$formData['date_to'] = Varien_Date::formatDate($formData['date_to'], false);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
$form->addValues($formData);
|
| 112 |
+
//$form->setFieldNameSuffix('design');
|
| 113 |
+
$this->setForm($form);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
public function getTabLabel()
|
| 117 |
+
{
|
| 118 |
+
return $this->_getHelper()->__('General');
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
public function getTabTitle()
|
| 122 |
+
{
|
| 123 |
+
return $this->_getHelper()->__('General');
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
public function canShowTab()
|
| 127 |
+
{
|
| 128 |
+
return true;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
public function isHidden()
|
| 132 |
+
{
|
| 133 |
+
return false;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 138 |
+
*/
|
| 139 |
+
protected function _getHelper()
|
| 140 |
+
{
|
| 141 |
+
return Mage::helper('lanot_advancedtheme');
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* @return Mage_Customer_Model_Resource_Group_Collection
|
| 146 |
+
*/
|
| 147 |
+
protected function _getCustomerGroupCollection()
|
| 148 |
+
{
|
| 149 |
+
return Mage::getResourceModel('customer/group_collection');
|
| 150 |
+
}
|
| 151 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Edit/Tabs.php
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Sticker admin edit tabs block
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_AdvancedTheme_Block_Adminhtml_Design_Edit_Tabs
|
| 27 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
| 28 |
+
{
|
| 29 |
+
/**
|
| 30 |
+
* Initialize tabs and define tabs block settings
|
| 31 |
+
*
|
| 32 |
+
*/
|
| 33 |
+
public function __construct()
|
| 34 |
+
{
|
| 35 |
+
parent::__construct();
|
| 36 |
+
|
| 37 |
+
$this->setId('page_tabs');
|
| 38 |
+
$this->setDestElementId('edit_form');
|
| 39 |
+
$this->setTitle($this->_getHelper()->__('Design Change'));
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 44 |
+
*/
|
| 45 |
+
protected function _getHelper()
|
| 46 |
+
{
|
| 47 |
+
return Mage::helper('lanot_advancedtheme');
|
| 48 |
+
}
|
| 49 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Block/Adminhtml/Design/Grid.php
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Design admin grid
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_AdvancedTheme_Block_Adminhtml_Design_Grid
|
| 27 |
+
extends Mage_Adminhtml_Block_System_Design_Grid
|
| 28 |
+
{
|
| 29 |
+
/**
|
| 30 |
+
* Prepare grid data collection
|
| 31 |
+
*
|
| 32 |
+
* @return Lanot_AdvancedTheme_Block_Adminhtml_Design_Grid
|
| 33 |
+
*/
|
| 34 |
+
protected function _prepareCollection()
|
| 35 |
+
{
|
| 36 |
+
/** @var $collection Lanot_AdvancedTheme_Model_Mysql4_Design_Collection */
|
| 37 |
+
$collection = Mage::getModel('lanot_advancedtheme/design')->getCollection();
|
| 38 |
+
$collection->joinCustomerGroup();
|
| 39 |
+
|
| 40 |
+
$this->setCollection($collection);
|
| 41 |
+
|
| 42 |
+
Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
| 43 |
+
return $this;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* @return Lanot_AdvancedTheme_Block_Adminhtml_Design_Grid
|
| 48 |
+
*/
|
| 49 |
+
protected function _prepareColumns()
|
| 50 |
+
{
|
| 51 |
+
$this->addColumnAfter('customer_group_id', array(
|
| 52 |
+
'header' => $this->_getHelper()->__('Customer Group'),
|
| 53 |
+
'index' => 'customer_group_id',
|
| 54 |
+
'filter_index' => 'main_table.customer_group_id',
|
| 55 |
+
'type' => 'options',
|
| 56 |
+
'options' => $this->_getCustomerGroupCollection()->toOptionHash(),
|
| 57 |
+
'width' => '150px',
|
| 58 |
+
), 'package');
|
| 59 |
+
|
| 60 |
+
$this->addColumnAfter('action', array(
|
| 61 |
+
'header' => $this->_getHelper()->__('Action'),
|
| 62 |
+
'width' => '70px',
|
| 63 |
+
'align' => 'center',
|
| 64 |
+
'type' => 'action',
|
| 65 |
+
'getter' => 'getId',
|
| 66 |
+
'actions' => array(
|
| 67 |
+
array(
|
| 68 |
+
'caption' => $this->_getHelper()->__('Edit'),
|
| 69 |
+
'url' => array('base' => '*/*/edit'),
|
| 70 |
+
'field' => 'id'
|
| 71 |
+
)
|
| 72 |
+
),
|
| 73 |
+
'filter' => false,
|
| 74 |
+
'sortable' => false,
|
| 75 |
+
), 'date_to');
|
| 76 |
+
|
| 77 |
+
return parent::_prepareColumns();
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 82 |
+
*/
|
| 83 |
+
protected function _getHelper()
|
| 84 |
+
{
|
| 85 |
+
return Mage::helper('lanot_advancedtheme');
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* @return Mage_Customer_Model_Resource_Group_Collection
|
| 90 |
+
*/
|
| 91 |
+
protected function _getCustomerGroupCollection()
|
| 92 |
+
{
|
| 93 |
+
return Mage::getResourceModel('customer/group_collection');
|
| 94 |
+
}
|
| 95 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Helper/Admin.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* clever theme helper
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
class Lanot_AdvancedTheme_Helper_Admin
|
| 28 |
+
extends Mage_Core_Helper_Abstract
|
| 29 |
+
{
|
| 30 |
+
/**
|
| 31 |
+
* Check permission for passed action
|
| 32 |
+
*
|
| 33 |
+
* @param string $action
|
| 34 |
+
* @return bool
|
| 35 |
+
*/
|
| 36 |
+
public function isActionAllowed($action)
|
| 37 |
+
{
|
| 38 |
+
return Mage::getSingleton('admin/session')->isAllowed('lanot/lanot_advancedtheme/' . $action);
|
| 39 |
+
}
|
| 40 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Helper/Data.php
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* clever theme helper
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
class Lanot_AdvancedTheme_Helper_Data extends Mage_Core_Helper_Abstract
|
| 28 |
+
{
|
| 29 |
+
const XML_NODE_PATH_ENABLED = 'lanot_advancedtheme/view/enabled';
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @return bool
|
| 33 |
+
*/
|
| 34 |
+
public function isEnabled()
|
| 35 |
+
{
|
| 36 |
+
return (bool) Mage::getStoreConfig(self::XML_NODE_PATH_ENABLED);
|
| 37 |
+
}
|
| 38 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Model/Design.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Lanot_AdvancedTheme_Model_Design extends Mage_Core_Model_Design
|
| 22 |
+
{
|
| 23 |
+
protected function _construct()
|
| 24 |
+
{
|
| 25 |
+
$this->_init('lanot_advancedtheme/design');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
public function loadChange($storeId, $date = null, $customerGroupId = null)
|
| 29 |
+
{
|
| 30 |
+
$result = $this->getResource()
|
| 31 |
+
->loadChange($storeId, $date, $customerGroupId);
|
| 32 |
+
|
| 33 |
+
if (count($result)){
|
| 34 |
+
if (!empty($result['design'])) {
|
| 35 |
+
$tmp = explode('/', $result['design']);
|
| 36 |
+
$result['package'] = $tmp[0];
|
| 37 |
+
$result['theme'] = $tmp[1];
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
$this->setData($result);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return $this;
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Model/Mysql4/Design.php
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Lanot_AdvancedTheme_Model_Mysql4_Design extends Mage_Core_Model_Mysql4_Design
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* Define main table and primary key
|
| 25 |
+
*
|
| 26 |
+
*/
|
| 27 |
+
protected function _construct()
|
| 28 |
+
{
|
| 29 |
+
$this->_init('lanot_advancedtheme/design_change', 'design_change_id');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Perform actions before object save
|
| 34 |
+
*
|
| 35 |
+
* @param Mage_Core_Model_Abstract $object
|
| 36 |
+
* @return Mage_Core_Model_Resource_Db_Abstract
|
| 37 |
+
* @throws Mage_Core_Exception
|
| 38 |
+
*/
|
| 39 |
+
public function _beforeSave(Mage_Core_Model_Abstract $object)
|
| 40 |
+
{
|
| 41 |
+
if ($date = $object->getDateFrom()) {
|
| 42 |
+
$object->setDateFrom($this->formatDate($date));
|
| 43 |
+
} else {
|
| 44 |
+
$object->setDateFrom(null);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
if ($date = $object->getDateTo()) {
|
| 48 |
+
$object->setDateTo($this->formatDate($date));
|
| 49 |
+
} else {
|
| 50 |
+
$object->setDateTo(null);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo())
|
| 54 |
+
&& Varien_Date::toTimestamp($object->getDateFrom()) > Varien_Date::toTimestamp($object->getDateTo())) {
|
| 55 |
+
Mage::throwException(Mage::helper('core')->__('Start date cannot be greater than end date.'));
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
if ($object->getCustomerGroupId() === null || $object->getCustomerGroupId() === '')//@todo: added
|
| 59 |
+
$object->setCustomerGroupId(new Zend_Db_Expr('null'));
|
| 60 |
+
|
| 61 |
+
$check = $this->_checkIntersection(
|
| 62 |
+
$object->getStoreId(),
|
| 63 |
+
$object->getDateFrom(),
|
| 64 |
+
$object->getDateTo(),
|
| 65 |
+
$object->getId(),
|
| 66 |
+
$object->getCustomerGroupId()//@todo: added
|
| 67 |
+
);
|
| 68 |
+
|
| 69 |
+
if ($check) {
|
| 70 |
+
Mage::throwException( //@todo: added
|
| 71 |
+
Mage::helper('lanot_advancedtheme')->__('Your design change for the specified store and Customer Group intersects with another one, please specify another date range.')
|
| 72 |
+
);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if ($object->getDateFrom() === null)
|
| 76 |
+
$object->setDateFrom(new Zend_Db_Expr('null'));
|
| 77 |
+
if ($object->getDateTo() === null)
|
| 78 |
+
$object->setDateTo(new Zend_Db_Expr('null'));
|
| 79 |
+
|
| 80 |
+
//Mage_Core_Model_Mysql4_Abstract::_beforeSave($object);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Check intersections
|
| 85 |
+
*
|
| 86 |
+
* @param int $storeId
|
| 87 |
+
* @param date $dateFrom
|
| 88 |
+
* @param date $dateTo
|
| 89 |
+
* @param int $currentId
|
| 90 |
+
* @param $customerGroupId
|
| 91 |
+
* @return Array
|
| 92 |
+
*/
|
| 93 |
+
protected function _checkIntersection($storeId, $dateFrom, $dateTo, $currentId, $customerGroupId = null)//@todo: added
|
| 94 |
+
{
|
| 95 |
+
$adapter = $this->_getReadAdapter();
|
| 96 |
+
$select = $adapter->select()
|
| 97 |
+
->from(array('main_table'=>$this->getTable('design_change')))
|
| 98 |
+
->where('main_table.store_id = :store_id')
|
| 99 |
+
->where('main_table.customer_group_id = :customer_group_id')//@todo: added
|
| 100 |
+
->where('main_table.design_change_id <> :current_id');
|
| 101 |
+
|
| 102 |
+
$dateConditions = array('date_to IS NULL AND date_from IS NULL');
|
| 103 |
+
|
| 104 |
+
if (!is_null($dateFrom)) {
|
| 105 |
+
$dateConditions[] = ':date_from BETWEEN date_from AND date_to';
|
| 106 |
+
$dateConditions[] = ':date_from >= date_from and date_to IS NULL';
|
| 107 |
+
$dateConditions[] = ':date_from <= date_to and date_from IS NULL';
|
| 108 |
+
} else {
|
| 109 |
+
$dateConditions[] = 'date_from IS NULL';
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if (!is_null($dateTo)) {
|
| 113 |
+
$dateConditions[] = ':date_to BETWEEN date_from AND date_to';
|
| 114 |
+
$dateConditions[] = ':date_to >= date_from AND date_to IS NULL';
|
| 115 |
+
$dateConditions[] = ':date_to <= date_to AND date_from IS NULL';
|
| 116 |
+
} else {
|
| 117 |
+
$dateConditions[] = 'date_to IS NULL';
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
if (is_null($dateFrom) && !is_null($dateTo)) {
|
| 121 |
+
$dateConditions[] = 'date_to <= :date_to OR date_from <= :date_to';
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (!is_null($dateFrom) && is_null($dateTo)) {
|
| 125 |
+
$dateConditions[] = 'date_to >= :date_from OR date_from >= :date_from';
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
if (!is_null($dateFrom) && !is_null($dateTo)) {
|
| 129 |
+
$dateConditions[] = 'date_from BETWEEN :date_from AND :date_to';
|
| 130 |
+
$dateConditions[] = 'date_to BETWEEN :date_from AND :date_to';
|
| 131 |
+
} elseif (is_null($dateFrom) && is_null($dateTo)) {
|
| 132 |
+
$dateConditions = array();
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
$condition = '';
|
| 136 |
+
if (!empty($dateConditions)) {
|
| 137 |
+
$condition = '(' . implode(') OR (', $dateConditions) . ')';
|
| 138 |
+
$select->where($condition);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
$bind = array(
|
| 142 |
+
'store_id' => (int)$storeId,
|
| 143 |
+
'current_id' => (int)$currentId,
|
| 144 |
+
'customer_group_id' => $customerGroupId,//@todo: added
|
| 145 |
+
);
|
| 146 |
+
|
| 147 |
+
if (!is_null($dateTo)) {
|
| 148 |
+
$bind['date_to'] = $dateTo;
|
| 149 |
+
}
|
| 150 |
+
if (!is_null($dateFrom)) {
|
| 151 |
+
$bind['date_from'] = $dateFrom;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
$result = $adapter->fetchOne($select, $bind);
|
| 155 |
+
return $result;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* Load changes for specific store and date
|
| 160 |
+
*
|
| 161 |
+
* @param int $storeId
|
| 162 |
+
* @param string $date
|
| 163 |
+
* @param int $customerGroupId
|
| 164 |
+
* @return array
|
| 165 |
+
*/
|
| 166 |
+
public function loadChange($storeId, $date = null, $customerGroupId = null)//@todo: added
|
| 167 |
+
{
|
| 168 |
+
if (is_null($date)) {
|
| 169 |
+
$date = Varien_Date::now();
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
$select = $this->_getReadAdapter()->select()
|
| 173 |
+
->from(array('main_table' => $this->getTable('design_change')))
|
| 174 |
+
->where('store_id = :store_id')
|
| 175 |
+
->where('date_from <= :required_date or date_from IS NULL')
|
| 176 |
+
->where('date_to >= :required_date or date_to IS NULL')
|
| 177 |
+
->where('customer_group_id = :customer_group_id OR customer_group_id IS NULL')//@todo: added
|
| 178 |
+
->order('customer_group_id DESC')//@todo: added
|
| 179 |
+
->limit(1);//@todo: added
|
| 180 |
+
|
| 181 |
+
$bind = array(
|
| 182 |
+
'store_id' => (int)$storeId,
|
| 183 |
+
'required_date' => $date,
|
| 184 |
+
'customer_group_id' => (int) $customerGroupId,//@todo: added
|
| 185 |
+
);
|
| 186 |
+
|
| 187 |
+
return $this->_getReadAdapter()->fetchRow($select, $bind);
|
| 188 |
+
}
|
| 189 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Model/Mysql4/Design/Collection.php
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
class Lanot_AdvancedTheme_Model_Mysql4_Design_Collection
|
| 21 |
+
extends Mage_Core_Model_Mysql4_Design_Collection
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* Core Design resource collection
|
| 25 |
+
*
|
| 26 |
+
*/
|
| 27 |
+
protected function _construct()
|
| 28 |
+
{
|
| 29 |
+
$this->_init('lanot_advancedtheme/design');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Join customer group data to collection
|
| 34 |
+
*
|
| 35 |
+
* @return Lanot_AdvancedTheme_Model_Mysql4_Design_Collection
|
| 36 |
+
*/
|
| 37 |
+
public function joinCustomerGroup()
|
| 38 |
+
{
|
| 39 |
+
return $this->getSelect()->joinLeft(
|
| 40 |
+
array('cg' => $this->getTable('customer/customer_group')),
|
| 41 |
+
'cg.customer_group_id = main_table.customer_group_id',
|
| 42 |
+
array('cg.customer_group_code'));
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Add customer group filter to collection
|
| 47 |
+
*
|
| 48 |
+
* @param int|array $customerGroupId
|
| 49 |
+
* @return Lanot_AdvancedTheme_Model_Mysql4_Design_Collection
|
| 50 |
+
*/
|
| 51 |
+
public function addCustomerGroupFilter($customerGroupId)
|
| 52 |
+
{
|
| 53 |
+
return $this->addFieldToFilter('main_table.customer_group_id', array('in' => $customerGroupId));
|
| 54 |
+
}
|
| 55 |
+
}
|
app/code/community/Lanot/AdvancedTheme/Model/Observer.php
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* clever theme observer
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_AdvancedTheme_Model_Observer
|
| 27 |
+
{
|
| 28 |
+
protected $_themes = array('layout', 'template', 'skin', 'locale');
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @param Varien_Object $observer
|
| 32 |
+
* @return Lanot_AdvancedTheme_Model_Observer
|
| 33 |
+
*/
|
| 34 |
+
public function prepareTheme($observer)
|
| 35 |
+
{
|
| 36 |
+
if ($this->_getHelper()->isEnabled() && $this->_isFrontend()) {
|
| 37 |
+
//#1. Load advanced design change
|
| 38 |
+
/** @var $designChange Lanot_AdvancedTheme_Model_Design */
|
| 39 |
+
$designChange = $this->_getDesignModel()->loadChange(
|
| 40 |
+
Mage::app()->getStore()->getId(),
|
| 41 |
+
Varien_Date::now(),
|
| 42 |
+
$this->_getSession()->getCustomerGroupId());
|
| 43 |
+
|
| 44 |
+
//#2. Set new theme items and package
|
| 45 |
+
if ($designChange && $designChange->getId()) {
|
| 46 |
+
$theme = $designChange->getTheme();
|
| 47 |
+
$this->_getDesignPackage()->setPackageName($designChange->getPackage());
|
| 48 |
+
foreach($this->_themes as $name) {
|
| 49 |
+
$this->_getDesignPackage()->setTheme($name, $theme);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
return $this;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* @return bool
|
| 58 |
+
*/
|
| 59 |
+
protected function _isFrontend()
|
| 60 |
+
{
|
| 61 |
+
if (Mage::app()->getRequest()->isStraight()) {
|
| 62 |
+
return false;
|
| 63 |
+
}
|
| 64 |
+
if ($this->_getDesignPackage()->getArea() != Mage_Core_Model_App_Area::AREA_FRONTEND) {
|
| 65 |
+
return false;
|
| 66 |
+
}
|
| 67 |
+
return true;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 72 |
+
*/
|
| 73 |
+
protected function _getHelper()
|
| 74 |
+
{
|
| 75 |
+
return Mage::helper('lanot_advancedtheme');
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* @return Mage_Core_Model_Design_Package
|
| 80 |
+
*/
|
| 81 |
+
protected function _getDesignPackage()
|
| 82 |
+
{
|
| 83 |
+
return Mage::getSingleton('core/design_package');
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* @return Mage_Customer_Model_Session
|
| 88 |
+
*/
|
| 89 |
+
protected function _getSession()
|
| 90 |
+
{
|
| 91 |
+
return Mage::getSingleton('customer/session');
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* @return Lanot_AdvancedTheme_Model_Design
|
| 96 |
+
*/
|
| 97 |
+
protected function _getDesignModel()
|
| 98 |
+
{
|
| 99 |
+
return Mage::getSingleton('lanot_advancedtheme/design');
|
| 100 |
+
}
|
| 101 |
+
}
|
app/code/community/Lanot/AdvancedTheme/controllers/Adminhtml/DesignController.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_EasyDesign
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Lanot_AdvancedTheme_Adminhtml_DesignController
|
| 22 |
+
extends Lanot_Core_Controller_Adminhtml_AbstractController
|
| 23 |
+
{
|
| 24 |
+
protected $_msgTitle = 'Designs';
|
| 25 |
+
protected $_msgHeader = 'Manage Designs';
|
| 26 |
+
protected $_msgItemDoesNotExist = 'The Design item does not exist.';
|
| 27 |
+
protected $_msgItemNotFound = 'Unable to find the design item #%s.';
|
| 28 |
+
protected $_msgItemEdit = 'Edit Design Item';
|
| 29 |
+
protected $_msgItemNew = 'New Design Item';
|
| 30 |
+
protected $_msgItemSaved = 'The Design item has been saved.';
|
| 31 |
+
protected $_msgItemDeleted = 'The Design item has been deleted';
|
| 32 |
+
protected $_msgError = 'An error occurred while edit the Design item %s.';
|
| 33 |
+
protected $_msgErrorItems = 'An error occurred while edit the Design items %s.';
|
| 34 |
+
protected $_msgItems = 'The Design items (#%s) has been';
|
| 35 |
+
|
| 36 |
+
protected $_menuActive = 'lanot/lanot_advancedtheme';
|
| 37 |
+
protected $_aclSection = 'manage_design';
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* @return Mage_Core_Model_Abstract
|
| 42 |
+
*/
|
| 43 |
+
protected function _getItemModel()
|
| 44 |
+
{
|
| 45 |
+
return Mage::getModel('lanot_advancedtheme/design');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @param Mage_Core_Model_Abstract $model
|
| 50 |
+
* @return Lanot_AdvancedTheme_Adminhtml_DesignController
|
| 51 |
+
*/
|
| 52 |
+
protected function _registerItem(Mage_Core_Model_Abstract $model)
|
| 53 |
+
{
|
| 54 |
+
Mage::register('design', $model);
|
| 55 |
+
return $this;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @return Lanot_AdvancedTheme_Helper_Data
|
| 60 |
+
*/
|
| 61 |
+
protected function _getHelper()
|
| 62 |
+
{
|
| 63 |
+
return Mage::helper('lanot_advancedtheme');
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* @return Lanot_AdvancedTheme_Helper_Admin
|
| 68 |
+
*/
|
| 69 |
+
protected function _getAclHelper()
|
| 70 |
+
{
|
| 71 |
+
return Mage::helper('lanot_advancedtheme/admin');
|
| 72 |
+
}
|
| 73 |
+
}
|
app/code/community/Lanot/AdvancedTheme/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento admin config
|
| 5 |
+
*
|
| 6 |
+
* @author Lanot
|
| 7 |
+
*/
|
| 8 |
+
-->
|
| 9 |
+
<config>
|
| 10 |
+
|
| 11 |
+
<menu>
|
| 12 |
+
<lanot translate="title">
|
| 13 |
+
<title>Lanot</title>
|
| 14 |
+
<sort_order>65</sort_order>
|
| 15 |
+
<children>
|
| 16 |
+
<lanot_advancedtheme translate="title" module="lanot_advancedtheme">
|
| 17 |
+
<title>Advanced Theme</title>
|
| 18 |
+
<action>lanot_advancedtheme/adminhtml_design</action>
|
| 19 |
+
<sort_order>10</sort_order>
|
| 20 |
+
</lanot_advancedtheme>
|
| 21 |
+
</children>
|
| 22 |
+
</lanot>
|
| 23 |
+
</menu>
|
| 24 |
+
|
| 25 |
+
<acl>
|
| 26 |
+
<resources>
|
| 27 |
+
<admin>
|
| 28 |
+
<children>
|
| 29 |
+
|
| 30 |
+
<lanot>
|
| 31 |
+
<title>Lanot</title>
|
| 32 |
+
<sort_order>65</sort_order>
|
| 33 |
+
<children>
|
| 34 |
+
<lanot_advancedtheme translate="title" module="lanot_advancedtheme">
|
| 35 |
+
<title>Advanced Theme</title>
|
| 36 |
+
<sort_order>75</sort_order>
|
| 37 |
+
<children>
|
| 38 |
+
<manage_design translate="title">
|
| 39 |
+
<title>Manage Designs</title>
|
| 40 |
+
<sort_order>0</sort_order>
|
| 41 |
+
<children>
|
| 42 |
+
<save translate="title">
|
| 43 |
+
<title>Save Design</title>
|
| 44 |
+
<sort_order>0</sort_order>
|
| 45 |
+
</save>
|
| 46 |
+
<delete translate="title">
|
| 47 |
+
<title>Delete Design</title>
|
| 48 |
+
<sort_order>10</sort_order>
|
| 49 |
+
</delete>
|
| 50 |
+
</children>
|
| 51 |
+
</manage_design>
|
| 52 |
+
</children>
|
| 53 |
+
</lanot_advancedtheme>
|
| 54 |
+
</children>
|
| 55 |
+
</lanot>
|
| 56 |
+
|
| 57 |
+
<system>
|
| 58 |
+
<children>
|
| 59 |
+
<config>
|
| 60 |
+
<children>
|
| 61 |
+
<lanot_advancedtheme translate="title" module="lanot_advancedtheme">
|
| 62 |
+
<title>Lanot Advanced Theme Configuration</title>
|
| 63 |
+
</lanot_advancedtheme>
|
| 64 |
+
</children>
|
| 65 |
+
</config>
|
| 66 |
+
</children>
|
| 67 |
+
</system>
|
| 68 |
+
|
| 69 |
+
</children>
|
| 70 |
+
</admin>
|
| 71 |
+
</resources>
|
| 72 |
+
</acl>
|
| 73 |
+
|
| 74 |
+
</config>
|
app/code/community/Lanot/AdvancedTheme/etc/config.xml
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
|
| 4 |
+
<modules>
|
| 5 |
+
<Lanot_AdvancedTheme>
|
| 6 |
+
<version>1.0.0.0</version>
|
| 7 |
+
</Lanot_AdvancedTheme>
|
| 8 |
+
</modules>
|
| 9 |
+
|
| 10 |
+
<global>
|
| 11 |
+
<helpers>
|
| 12 |
+
<lanot_advancedtheme>
|
| 13 |
+
<class>Lanot_AdvancedTheme_Helper</class>
|
| 14 |
+
</lanot_advancedtheme>
|
| 15 |
+
</helpers>
|
| 16 |
+
|
| 17 |
+
<blocks>
|
| 18 |
+
<lanot_advancedtheme>
|
| 19 |
+
<class>Lanot_AdvancedTheme_Block</class>
|
| 20 |
+
</lanot_advancedtheme>
|
| 21 |
+
</blocks>
|
| 22 |
+
|
| 23 |
+
<models>
|
| 24 |
+
<lanot_advancedtheme>
|
| 25 |
+
<class>Lanot_AdvancedTheme_Model</class>
|
| 26 |
+
<resourceModel>lanot_advancedtheme_resource</resourceModel>
|
| 27 |
+
</lanot_advancedtheme>
|
| 28 |
+
<lanot_advancedtheme_resource>
|
| 29 |
+
<class>Lanot_AdvancedTheme_Model_Mysql4</class>
|
| 30 |
+
<entities>
|
| 31 |
+
<design_change><table>lanot_advancedtheme_design_change</table></design_change>
|
| 32 |
+
</entities>
|
| 33 |
+
</lanot_advancedtheme_resource>
|
| 34 |
+
</models>
|
| 35 |
+
|
| 36 |
+
<resources>
|
| 37 |
+
<lanot_advancedtheme_setup>
|
| 38 |
+
<setup>
|
| 39 |
+
<module>Lanot_AdvancedTheme</module>
|
| 40 |
+
</setup>
|
| 41 |
+
</lanot_advancedtheme_setup>
|
| 42 |
+
</resources>
|
| 43 |
+
</global>
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
<adminhtml>
|
| 47 |
+
<layout>
|
| 48 |
+
<updates>
|
| 49 |
+
<lanot_advancedtheme>
|
| 50 |
+
<file>lanot_advancedtheme.xml</file>
|
| 51 |
+
</lanot_advancedtheme>
|
| 52 |
+
</updates>
|
| 53 |
+
</layout>
|
| 54 |
+
</adminhtml>
|
| 55 |
+
|
| 56 |
+
<admin>
|
| 57 |
+
<routers>
|
| 58 |
+
<lanot_advancedtheme>
|
| 59 |
+
<use>admin</use>
|
| 60 |
+
<args>
|
| 61 |
+
<module>Lanot_AdvancedTheme</module>
|
| 62 |
+
<frontName>lanot_advancedtheme</frontName>
|
| 63 |
+
</args>
|
| 64 |
+
</lanot_advancedtheme>
|
| 65 |
+
</routers>
|
| 66 |
+
</admin>
|
| 67 |
+
|
| 68 |
+
<frontend>
|
| 69 |
+
<!-- OBSERVER EVENTS -->
|
| 70 |
+
<events>
|
| 71 |
+
<controller_action_predispatch>
|
| 72 |
+
<observers>
|
| 73 |
+
<lanot_advancedtheme>
|
| 74 |
+
<type>singleton</type>
|
| 75 |
+
<class>lanot_advancedtheme/observer</class>
|
| 76 |
+
<method>prepareTheme</method>
|
| 77 |
+
</lanot_advancedtheme>
|
| 78 |
+
</observers>
|
| 79 |
+
</controller_action_predispatch>
|
| 80 |
+
</events>
|
| 81 |
+
<!--/OBSERVER EVENTS -->
|
| 82 |
+
</frontend>
|
| 83 |
+
|
| 84 |
+
<default>
|
| 85 |
+
<lanot_advancedtheme>
|
| 86 |
+
<view>
|
| 87 |
+
<enabled>1</enabled>
|
| 88 |
+
</view>
|
| 89 |
+
</lanot_advancedtheme>
|
| 90 |
+
</default>
|
| 91 |
+
</config>
|
app/code/community/Lanot/AdvancedTheme/etc/system.xml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<lanot translate="label">
|
| 5 |
+
<label>Lanot Extensions</label>
|
| 6 |
+
<sort_order>200</sort_order>
|
| 7 |
+
</lanot>
|
| 8 |
+
</tabs>
|
| 9 |
+
<sections>
|
| 10 |
+
<lanot_advancedtheme>
|
| 11 |
+
<class>separator-top</class>
|
| 12 |
+
<label>Advanced Theme</label>
|
| 13 |
+
<tab>lanot</tab>
|
| 14 |
+
<frontend_type>text</frontend_type>
|
| 15 |
+
<sort_order>1000</sort_order>
|
| 16 |
+
<show_in_default>1</show_in_default>
|
| 17 |
+
<show_in_website>0</show_in_website>
|
| 18 |
+
<show_in_store>0</show_in_store>
|
| 19 |
+
<groups>
|
| 20 |
+
<view translate="label">
|
| 21 |
+
<label>Advanced Theme Settings</label>
|
| 22 |
+
<frontend_type>text</frontend_type>
|
| 23 |
+
<sort_order>10</sort_order>
|
| 24 |
+
<show_in_default>1</show_in_default>
|
| 25 |
+
<show_in_website>0</show_in_website>
|
| 26 |
+
<show_in_store>0</show_in_store>
|
| 27 |
+
<fields>
|
| 28 |
+
<enabled translate="label">
|
| 29 |
+
<label>Enabled at Frontend</label>
|
| 30 |
+
<frontend_type>select</frontend_type>
|
| 31 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 32 |
+
<sort_order>10</sort_order>
|
| 33 |
+
<show_in_default>1</show_in_default>
|
| 34 |
+
<show_in_website>0</show_in_website>
|
| 35 |
+
<show_in_store>0</show_in_store>
|
| 36 |
+
</enabled>
|
| 37 |
+
</fields>
|
| 38 |
+
</view>
|
| 39 |
+
</groups>
|
| 40 |
+
</lanot_advancedtheme>
|
| 41 |
+
</sections>
|
| 42 |
+
</config>
|
app/code/community/Lanot/AdvancedTheme/sql/lanot_advancedtheme_setup/mysql4-install-1.0.0.0.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_AdvancedTheme
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 22 |
+
$installer = $this;
|
| 23 |
+
$installer->startSetup();
|
| 24 |
+
|
| 25 |
+
$tableDesignChange = $this->getTable('lanot_advancedtheme/design_change');
|
| 26 |
+
$customerGroupTable = $this->getTable('customer/customer_group');
|
| 27 |
+
$tableStore = $this->getTable('core/store');
|
| 28 |
+
|
| 29 |
+
$this->run("
|
| 30 |
+
DROP TABLE IF EXISTS `{$tableDesignChange}`;
|
| 31 |
+
CREATE TABLE `{$tableDesignChange}` (
|
| 32 |
+
`design_change_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Design Change Id',
|
| 33 |
+
`store_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Store Id',
|
| 34 |
+
`customer_group_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Customer Group Id',
|
| 35 |
+
`design` varchar(255) DEFAULT NULL COMMENT 'Design',
|
| 36 |
+
`date_from` date DEFAULT NULL COMMENT 'First Date of Design Activity',
|
| 37 |
+
`date_to` date DEFAULT NULL COMMENT 'Last Date of Design Activity',
|
| 38 |
+
PRIMARY KEY (`design_change_id`),
|
| 39 |
+
CONSTRAINT `FK_LCT_DESIGN_CHANGE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `{$tableStore}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
| 40 |
+
CONSTRAINT `FK_LCT_DC_CUSTOMER_GROUP_ID_TO_CG_CUSTOMER_GROUP_ID` FOREIGN KEY (`customer_group_id`) REFERENCES `{$customerGroupTable}` (`customer_group_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
| 41 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Lanot Clever Theme Design Changes';
|
| 42 |
+
");
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
$installer->endSetup();
|
app/code/community/Lanot/Core/Block/Adminhtml/Grid/Abstract.php
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_Core
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* core grid abstract
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_Core_Block_Adminhtml_Grid_Abstract
|
| 27 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
| 28 |
+
{
|
| 29 |
+
protected $_gridId = 'lanot_core_list_grid';
|
| 30 |
+
protected $_entityIdField = 'entity_id';
|
| 31 |
+
protected $_itemParam = 'entity_id';
|
| 32 |
+
protected $_formFieldName = 'entity';
|
| 33 |
+
protected $_columnPrefix = '';
|
| 34 |
+
protected $_checkboxFieldName = 'in_selected';
|
| 35 |
+
protected $_isTabGrid = false;
|
| 36 |
+
|
| 37 |
+
/** @var Mage_Core_Model_Abstract */
|
| 38 |
+
protected $_item = null;
|
| 39 |
+
protected $_selectedLinks = null;
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Init Grid default properties
|
| 43 |
+
*
|
| 44 |
+
*/
|
| 45 |
+
public function __construct()
|
| 46 |
+
{
|
| 47 |
+
parent::__construct();
|
| 48 |
+
|
| 49 |
+
$this->setId($this->_gridId);
|
| 50 |
+
$this->setDefaultSort('sort_order');
|
| 51 |
+
$this->setDefaultDir('ASC');
|
| 52 |
+
$this->setSaveParametersInSession(true);
|
| 53 |
+
$this->setUseAjax(true);
|
| 54 |
+
|
| 55 |
+
if ($this->isReadonly()) {
|
| 56 |
+
$this->setFilterVisibility(false);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
| 62 |
+
*/
|
| 63 |
+
protected function _prepareCollection()
|
| 64 |
+
{
|
| 65 |
+
$collection = $this->_getItemModel()->getCollection();
|
| 66 |
+
|
| 67 |
+
//filter colelction if it show in tab
|
| 68 |
+
if ($this->_isTabGrid && $this->isReadonly()) {
|
| 69 |
+
$valueIds = $this->_getSelectedLinks();
|
| 70 |
+
if (empty($valueIds)) {
|
| 71 |
+
$valueIds = array(0);
|
| 72 |
+
}
|
| 73 |
+
$collection->addFieldToFilter($this->_entityIdField, array('in' => $valueIds));
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
Mage::dispatchEvent('lanot_grid_prepare_collection', array('grid' => $this, 'collection' => $collection));
|
| 77 |
+
|
| 78 |
+
$this->setCollection($collection);
|
| 79 |
+
|
| 80 |
+
return parent::_prepareCollection();
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* @param $row
|
| 85 |
+
* @return string
|
| 86 |
+
*/
|
| 87 |
+
public function getRowUrl($row)
|
| 88 |
+
{
|
| 89 |
+
return (!$this->_isTabGrid) ? $this->getUrl('*/*/edit', array('id' => $row->getId())) : '#';
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* @return string
|
| 94 |
+
*/
|
| 95 |
+
public function getGridUrl()
|
| 96 |
+
{
|
| 97 |
+
return (!$this->_isTabGrid) ?
|
| 98 |
+
$this->getUrl('*/*/grid', array('_current' => true)) :
|
| 99 |
+
$this->getUrl('*/*/ajaxgridonly', array('_current' => true));
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Prepare Grid columns
|
| 104 |
+
*
|
| 105 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
| 106 |
+
*/
|
| 107 |
+
protected function _prepareColumns()
|
| 108 |
+
{
|
| 109 |
+
if ($this->_isTabGrid) {
|
| 110 |
+
$this->addColumn('in_selected', array(
|
| 111 |
+
'header_css_class' => 'a-center',
|
| 112 |
+
'type' => 'checkbox',
|
| 113 |
+
'name' => 'in_selected',
|
| 114 |
+
'values' => $this->_getSelectedLinks(),
|
| 115 |
+
'align' => 'center',
|
| 116 |
+
'index' => $this->_entityIdField,
|
| 117 |
+
));
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
$this->addColumn($this->_entityIdField, array(
|
| 121 |
+
'header' => $this->_getHelper()->__('ID'),
|
| 122 |
+
'index' => $this->_entityIdField,
|
| 123 |
+
'type' => 'number',
|
| 124 |
+
'width' => '50px',
|
| 125 |
+
));
|
| 126 |
+
|
| 127 |
+
$this->addColumn('title', array(
|
| 128 |
+
'header' => $this->_getHelper()->__('Title'),
|
| 129 |
+
'index' => 'title',
|
| 130 |
+
));
|
| 131 |
+
|
| 132 |
+
$this->addColumn('is_active', array(
|
| 133 |
+
'header' => $this->_getHelper()->__('Active'),
|
| 134 |
+
'index' => 'is_active',
|
| 135 |
+
'type' => 'options',
|
| 136 |
+
'options' => $this->_getItemModel()->getAvailableStatuses(),
|
| 137 |
+
'width' => '100px',
|
| 138 |
+
));
|
| 139 |
+
|
| 140 |
+
$this->addColumn('updated_at', array(
|
| 141 |
+
'header' => $this->_getHelper()->__('Updated'),
|
| 142 |
+
'index' => 'updated_at',
|
| 143 |
+
'width' => '150px',
|
| 144 |
+
));
|
| 145 |
+
|
| 146 |
+
if (!$this->_isTabGrid) {
|
| 147 |
+
$this->addColumn('action',
|
| 148 |
+
array(
|
| 149 |
+
'header' => $this->_getHelper()->__('Action'),
|
| 150 |
+
'width' => '70px',
|
| 151 |
+
'align' => 'center',
|
| 152 |
+
'type' => 'action',
|
| 153 |
+
'getter' => 'getId',
|
| 154 |
+
'actions' => array(
|
| 155 |
+
array(
|
| 156 |
+
'caption' => $this->_getHelper()->__('Edit'),
|
| 157 |
+
'url' => array('base' => '*/*/edit'),
|
| 158 |
+
'field' => 'id'
|
| 159 |
+
)
|
| 160 |
+
),
|
| 161 |
+
'filter' => false,
|
| 162 |
+
'sortable' => false,
|
| 163 |
+
'index' => 'banner',
|
| 164 |
+
));
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
Mage::dispatchEvent('lanot_grid_prepare_columns', array('grid' => $this));
|
| 168 |
+
|
| 169 |
+
return parent::_prepareColumns();
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
| 175 |
+
*/
|
| 176 |
+
protected function _prepareMassaction()
|
| 177 |
+
{
|
| 178 |
+
if (!$this->isMassActionAllowed()) {
|
| 179 |
+
return $this;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
$this->setMassactionIdField($this->_entityIdField);
|
| 183 |
+
$this->getMassactionBlock()->setFormFieldName($this->_formFieldName);
|
| 184 |
+
|
| 185 |
+
$this->getMassactionBlock()->addItem('active_enable', array(
|
| 186 |
+
'label' => $this->_getHelper()->__('Enable'),
|
| 187 |
+
'url' => $this->getUrl('*/*/mass', array('type' => 'enable'))
|
| 188 |
+
));
|
| 189 |
+
|
| 190 |
+
$this->getMassactionBlock()->addItem('active_disable', array(
|
| 191 |
+
'label' => $this->_getHelper()->__('Disable'),
|
| 192 |
+
'url' => $this->getUrl('*/*/mass', array('type' => 'disable'))
|
| 193 |
+
));
|
| 194 |
+
|
| 195 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 196 |
+
'label' => $this->_getHelper()->__('Delete'),
|
| 197 |
+
'confirm' => $this->_getHelper()->__('Are you sure?'),
|
| 198 |
+
'url' => $this->getUrl('*/*/mass', array('type' => 'delete')),
|
| 199 |
+
));
|
| 200 |
+
|
| 201 |
+
Mage::dispatchEvent('lanot_grid_prepare_massaction', array('grid' => $this));
|
| 202 |
+
|
| 203 |
+
return $this;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Retrieve selected values
|
| 208 |
+
*
|
| 209 |
+
* @return array
|
| 210 |
+
*/
|
| 211 |
+
public function getSelectedLinks()
|
| 212 |
+
{
|
| 213 |
+
if (null === $this->_selectedLinks) {
|
| 214 |
+
$this->_selectedLinks = $this->_getItem()->getSelectedLinks();
|
| 215 |
+
}
|
| 216 |
+
return $this->_selectedLinks;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
/**
|
| 220 |
+
* Retrieve selected values
|
| 221 |
+
*
|
| 222 |
+
* @return array
|
| 223 |
+
*/
|
| 224 |
+
protected function _getSelectedLinks()
|
| 225 |
+
{
|
| 226 |
+
return $this->getSelectedLinks();
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* Add column to grid
|
| 231 |
+
*
|
| 232 |
+
* @param string $columnId
|
| 233 |
+
* @param array || Varien_Object $column
|
| 234 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
| 235 |
+
*/
|
| 236 |
+
public function addColumn($columnId, $column)
|
| 237 |
+
{
|
| 238 |
+
return parent::addColumn($this->_columnPrefix . $columnId, $column);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
| 243 |
+
*/
|
| 244 |
+
protected function _getItem()
|
| 245 |
+
{
|
| 246 |
+
if ($this->_item !== null) {
|
| 247 |
+
return $this->_item;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
$itemId = $this->getRequest()->getParam($this->_itemParam);
|
| 251 |
+
$this->_item = $this->_getItemModel();
|
| 252 |
+
if ($itemId) {
|
| 253 |
+
$this->_item->load($itemId);
|
| 254 |
+
}
|
| 255 |
+
return $this->_item;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/**
|
| 259 |
+
* @param $column
|
| 260 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
| 261 |
+
*/
|
| 262 |
+
protected function _addColumnFilterToCollection($column)
|
| 263 |
+
{
|
| 264 |
+
// Set custom filter by selected values
|
| 265 |
+
if ($this->_isTabGrid && $column->getId() == $this->_checkboxFieldName) {
|
| 266 |
+
$valueIds = $this->_getSelectedLinks();
|
| 267 |
+
if (empty($valueIds)) {
|
| 268 |
+
$valueIds = 0;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
if ($column->getFilter()->getValue()) {
|
| 272 |
+
$this->getCollection()->addFieldToFilter($this->_entityIdField, array('in' => $valueIds));
|
| 273 |
+
} else {
|
| 274 |
+
if($valueIds) {
|
| 275 |
+
$this->getCollection()->addFieldToFilter($this->_entityIdField, array('nin' => $valueIds));
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
} else {
|
| 279 |
+
parent::_addColumnFilterToCollection($column);
|
| 280 |
+
}
|
| 281 |
+
return $this;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
//--------------------------- methods must be overwritten -----------------------------//
|
| 285 |
+
/**
|
| 286 |
+
* Checks when this block is readonly
|
| 287 |
+
*
|
| 288 |
+
* @return boolean
|
| 289 |
+
*/
|
| 290 |
+
public function isReadonly()
|
| 291 |
+
{
|
| 292 |
+
return false;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* Checks when this block is not available
|
| 297 |
+
*
|
| 298 |
+
* @return boolean
|
| 299 |
+
*/
|
| 300 |
+
public function isMassActionAllowed()
|
| 301 |
+
{
|
| 302 |
+
return !$this->_isTabGrid;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* @return Mage_Core_Model_Abstract
|
| 307 |
+
*/
|
| 308 |
+
protected function _getItemModel()
|
| 309 |
+
{
|
| 310 |
+
return null;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* @return Mage_Core_Helper_Abstract
|
| 315 |
+
*/
|
| 316 |
+
protected function _getHelper()
|
| 317 |
+
{
|
| 318 |
+
return null;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
/**
|
| 322 |
+
* @return Mage_Core_Helper_Abstract
|
| 323 |
+
*/
|
| 324 |
+
protected function _getAclHelper()
|
| 325 |
+
{
|
| 326 |
+
return null;
|
| 327 |
+
}
|
| 328 |
+
//--------------------------- methods must be overwritten-----------------------------//
|
| 329 |
+
}
|
app/code/community/Lanot/Core/Controller/Adminhtml/AbstractController.php
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_Core
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* core controller abstract
|
| 23 |
+
*
|
| 24 |
+
* @author Lanot
|
| 25 |
+
*/
|
| 26 |
+
class Lanot_Core_Controller_Adminhtml_AbstractController
|
| 27 |
+
extends Mage_Adminhtml_Controller_Action
|
| 28 |
+
{
|
| 29 |
+
protected $_msgTitle = 'Items';
|
| 30 |
+
protected $_msgHeader = 'Items';
|
| 31 |
+
protected $_msgItemDoesNotExist = 'Item does not exist.';
|
| 32 |
+
protected $_msgItemNotFound = 'Unable to find an item. #%s';
|
| 33 |
+
protected $_msgItemEdit = 'Edit Item';
|
| 34 |
+
protected $_msgItemNew = 'New Item';
|
| 35 |
+
protected $_msgItemSaved = 'The item has been saved.';
|
| 36 |
+
protected $_msgItemDeleted = 'The item has been deleted.';
|
| 37 |
+
protected $_msgError = 'An error occurred while edit the item. %s';
|
| 38 |
+
protected $_msgErrorItems = 'An error occurred while edit the items. %s';
|
| 39 |
+
protected $_msgItems = 'The items %s has been';
|
| 40 |
+
|
| 41 |
+
protected $_menuActive = null;
|
| 42 |
+
protected $_aclSection = null;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Check the permission to run it
|
| 46 |
+
*
|
| 47 |
+
* @return boolean
|
| 48 |
+
*/
|
| 49 |
+
protected function _isAllowed()
|
| 50 |
+
{
|
| 51 |
+
switch ($this->getRequest()->getActionName()) {
|
| 52 |
+
case 'new':
|
| 53 |
+
case 'edit':
|
| 54 |
+
case 'save':
|
| 55 |
+
case 'mass':
|
| 56 |
+
return $this->_getAclHelper()->isActionAllowed($this->_aclSection . '/save');
|
| 57 |
+
break;
|
| 58 |
+
case 'delete':
|
| 59 |
+
return $this->_getAclHelper()->isActionAllowed($this->_aclSection . '/delete');
|
| 60 |
+
break;
|
| 61 |
+
default:
|
| 62 |
+
return $this->_getAclHelper()->isActionAllowed($this->_aclSection);
|
| 63 |
+
break;
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Init actions
|
| 69 |
+
*
|
| 70 |
+
* @return Lanot_Core_Controller_Adminhtml_AbstractController
|
| 71 |
+
*/
|
| 72 |
+
protected function _initAction()
|
| 73 |
+
{
|
| 74 |
+
// load layout, set active menu and breadcrumbs
|
| 75 |
+
$this->loadLayout()
|
| 76 |
+
->_setActiveMenu($this->_menuActive)
|
| 77 |
+
->_addBreadcrumb(
|
| 78 |
+
$this->_getHelper()->__($this->_msgTitle),
|
| 79 |
+
$this->_getHelper()->__($this->_msgTitle)
|
| 80 |
+
)
|
| 81 |
+
->_addBreadcrumb(
|
| 82 |
+
$this->_getHelper()->__($this->_msgHeader),
|
| 83 |
+
$this->_getHelper()->__($this->_msgHeader)
|
| 84 |
+
);
|
| 85 |
+
|
| 86 |
+
return $this;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Index action
|
| 91 |
+
*/
|
| 92 |
+
public function indexAction()
|
| 93 |
+
{
|
| 94 |
+
$this->_title($this->__($this->_msgTitle))
|
| 95 |
+
->_title($this->__($this->_msgHeader))
|
| 96 |
+
->_initAction()
|
| 97 |
+
->renderLayout();
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Grid action
|
| 102 |
+
*/
|
| 103 |
+
public function gridAction()
|
| 104 |
+
{
|
| 105 |
+
$this->loadLayout();
|
| 106 |
+
$this->renderLayout();
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* Create new Item
|
| 111 |
+
*/
|
| 112 |
+
public function newAction()
|
| 113 |
+
{
|
| 114 |
+
$this->_forward('edit');
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Edit item
|
| 119 |
+
*/
|
| 120 |
+
public function editAction()
|
| 121 |
+
{
|
| 122 |
+
$this->_title($this->__($this->_msgTitle))
|
| 123 |
+
->_title($this->__($this->_msgHeader));
|
| 124 |
+
|
| 125 |
+
// 1. instance model
|
| 126 |
+
$model = $this->_getItemModel();
|
| 127 |
+
|
| 128 |
+
// 2. if exists id, check it and load data
|
| 129 |
+
$itemId = $this->getRequest()->getParam('id');
|
| 130 |
+
if ($itemId) {
|
| 131 |
+
$model->load($itemId);
|
| 132 |
+
if (!$model->getId()) {
|
| 133 |
+
$this->_getSession()->addError($this->_getHelper()->__($this->_msgItemNotFound, $itemId));
|
| 134 |
+
return $this->_redirect('*/*/');
|
| 135 |
+
}
|
| 136 |
+
// prepare title
|
| 137 |
+
$this->_title($model->getTitle());
|
| 138 |
+
$breadCrumb = $this->_getHelper()->__($this->_msgItemEdit);
|
| 139 |
+
} else {
|
| 140 |
+
$this->_title($this->_getHelper()->__($this->_msgItemNew));
|
| 141 |
+
$breadCrumb = $this->_getHelper()->__($this->_msgItemNew);
|
| 142 |
+
}
|
| 143 |
+
// 3. Set entered data if was error when we do save
|
| 144 |
+
$data = $this->_getSession()->getFormData(true);
|
| 145 |
+
if (!empty($data)) {
|
| 146 |
+
$model->addData($data);
|
| 147 |
+
}
|
| 148 |
+
// 4. Register model to use later in blocks
|
| 149 |
+
$this->_registerItem($model);
|
| 150 |
+
|
| 151 |
+
// Init breadcrumbs
|
| 152 |
+
$this->_initAction()->_addBreadcrumb($breadCrumb, $breadCrumb);
|
| 153 |
+
|
| 154 |
+
// 5. render layout
|
| 155 |
+
$this->renderLayout();
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* Save action
|
| 160 |
+
*/
|
| 161 |
+
public function saveAction()
|
| 162 |
+
{
|
| 163 |
+
$redirectPath = '*/*';
|
| 164 |
+
$redirectParams = array();
|
| 165 |
+
$hasError = false;
|
| 166 |
+
// check if data sent
|
| 167 |
+
$data = $this->getRequest()->getPost();
|
| 168 |
+
if ($data) {
|
| 169 |
+
$data = $this->_preparePostData($data);
|
| 170 |
+
|
| 171 |
+
//1. instance model
|
| 172 |
+
$model = $this->_getItemModel();
|
| 173 |
+
//2. if exists id, try to load data
|
| 174 |
+
$itemId = $this->getRequest()->getParam('id');
|
| 175 |
+
if ($itemId) {
|
| 176 |
+
$model->load($itemId);
|
| 177 |
+
}
|
| 178 |
+
$model->addData($data);
|
| 179 |
+
|
| 180 |
+
try {
|
| 181 |
+
//3. save the data
|
| 182 |
+
$model->save();
|
| 183 |
+
//4. display success message
|
| 184 |
+
$msg = $this->_getHelper()->__($this->_msgItemSaved);
|
| 185 |
+
$this->_getSession()->addSuccess($msg);
|
| 186 |
+
//5. check if 'Save and Continue'
|
| 187 |
+
if ($this->getRequest()->getParam('back')) {
|
| 188 |
+
$redirectPath = '*/*/edit';
|
| 189 |
+
$redirectParams = array('id' => $model->getId());
|
| 190 |
+
}
|
| 191 |
+
} catch (Mage_Core_Exception $e) {
|
| 192 |
+
$hasError = true;
|
| 193 |
+
$this->_getSession()->addError($e->getMessage());
|
| 194 |
+
} catch (Exception $e) {
|
| 195 |
+
$hasError = true;
|
| 196 |
+
$msg = $this->_getHelper()->__($this->_msgError);
|
| 197 |
+
$this->_getSession()->addException($e, $msg);
|
| 198 |
+
}
|
| 199 |
+
//6. check if errors happened
|
| 200 |
+
if ($hasError) {
|
| 201 |
+
$this->_getSession()->setFormData($data);
|
| 202 |
+
$redirectPath = '*/*/edit';
|
| 203 |
+
$redirectParams = array('id' => $this->getRequest()->getParam('id'));
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
//7. go to grid or edit form
|
| 207 |
+
$this->_redirect($redirectPath, $redirectParams);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Delete action
|
| 212 |
+
*/
|
| 213 |
+
public function deleteAction()
|
| 214 |
+
{
|
| 215 |
+
$itemId = $this->getRequest()->getParam('id');
|
| 216 |
+
if ($itemId) {
|
| 217 |
+
try {
|
| 218 |
+
// 1. instance model
|
| 219 |
+
$model = $this->_getItemModel();
|
| 220 |
+
// 2. if exists id, load data
|
| 221 |
+
$model->load($itemId);
|
| 222 |
+
// 3. check if elements exists
|
| 223 |
+
if (!$model->getId()) {
|
| 224 |
+
$msg = $this->_getHelper()->__($this->_msgItemDoesNotExist);
|
| 225 |
+
Mage::throwException($msg);
|
| 226 |
+
}
|
| 227 |
+
// 4. delete item
|
| 228 |
+
$model->delete();
|
| 229 |
+
// display success message
|
| 230 |
+
$msg = $this->_getHelper()->__($this->_msgItemDeleted);
|
| 231 |
+
$this->_getSession()->addSuccess($msg);
|
| 232 |
+
} catch (Mage_Core_Exception $e) {
|
| 233 |
+
$this->_getSession()->addError($e->getMessage());
|
| 234 |
+
} catch (Exception $e) {
|
| 235 |
+
$msg = $this->_getHelper()->__($this->_msgError, $e->getMessage());
|
| 236 |
+
$this->_getSession()->addException($e, $msg);
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
// 5. go to grid
|
| 240 |
+
$this->_redirect('*/*/');
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/**
|
| 244 |
+
* Mass Update/Delete Action
|
| 245 |
+
*/
|
| 246 |
+
public function massAction()
|
| 247 |
+
{
|
| 248 |
+
$msg = '';
|
| 249 |
+
$key = $this->getRequest()->getParam('massaction_prepare_key');
|
| 250 |
+
$itemIds = $this->getRequest()->getParam($key);
|
| 251 |
+
$type = $this->getRequest()->getParam('type');
|
| 252 |
+
$active = $this->_getItemModel()->getStatusDisabled();
|
| 253 |
+
|
| 254 |
+
if (is_array($itemIds) && count($itemIds)) {
|
| 255 |
+
try {
|
| 256 |
+
foreach($itemIds as $itemId) {
|
| 257 |
+
// 1. instance banner model
|
| 258 |
+
$model = $this->_getItemModel();
|
| 259 |
+
// 2. if exists id, load data
|
| 260 |
+
$model->load($itemId);
|
| 261 |
+
// 3. check if elements exists
|
| 262 |
+
if (!$model->getId()) {
|
| 263 |
+
Mage::throwException($this->_getHelper()->__($this->_msgItemNotFound));
|
| 264 |
+
}
|
| 265 |
+
// 4. main logic
|
| 266 |
+
switch ($type) {
|
| 267 |
+
case 'enable':
|
| 268 |
+
$active = $this->_getItemModel()->getStatusEnabled();
|
| 269 |
+
case 'disable':
|
| 270 |
+
$model->setIsActive($active);
|
| 271 |
+
$model->save();
|
| 272 |
+
$msg = $this->_msgItems .
|
| 273 |
+
(($active == $this->_getItemModel()->getStatusDisabled()) ? ' disabled' : ' enabled') . '.';
|
| 274 |
+
break;
|
| 275 |
+
case 'delete':
|
| 276 |
+
$model->delete();
|
| 277 |
+
$msg = $this->_msgItems . ' deleted.';
|
| 278 |
+
break;
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
// display success message
|
| 282 |
+
$this->_getSession()->addSuccess($this->_getHelper()->__($msg, implode(', ', $itemIds)));
|
| 283 |
+
} catch (Mage_Core_Exception $e) {
|
| 284 |
+
$this->_getSession()->addError($e->getMessage());
|
| 285 |
+
} catch (Exception $e) {
|
| 286 |
+
$this->_getSession()->addException($e, $this->_getHelper()->__($this->_msgErrorItems,$e->getMessage()));
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
// 5. go to grid
|
| 290 |
+
$this->_redirect('*/*/');
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
/**
|
| 294 |
+
* @param array $data
|
| 295 |
+
* @return array
|
| 296 |
+
*/
|
| 297 |
+
protected function _preparePostData($data)
|
| 298 |
+
{
|
| 299 |
+
return $data;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
/**
|
| 303 |
+
* @return Mage_Core_Helper_Abstract
|
| 304 |
+
*/
|
| 305 |
+
protected function _getHelper()
|
| 306 |
+
{
|
| 307 |
+
return null;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
/**
|
| 311 |
+
* @return Mage_Core_Helper_Abstract
|
| 312 |
+
*/
|
| 313 |
+
protected function _getAclHelper()
|
| 314 |
+
{
|
| 315 |
+
return null;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
/**
|
| 319 |
+
* @return Mage_Core_Model_Abstract
|
| 320 |
+
*/
|
| 321 |
+
protected function _getItemModel()
|
| 322 |
+
{
|
| 323 |
+
return null;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
/**
|
| 327 |
+
* @param Mage_Core_Model_Abstract $model
|
| 328 |
+
* @return Lanot_Core_Controller_Adminhtml_AbstractController
|
| 329 |
+
*/
|
| 330 |
+
protected function _registerItem(Mage_Core_Model_Abstract $model)
|
| 331 |
+
{
|
| 332 |
+
return $this;
|
| 333 |
+
}
|
| 334 |
+
}
|
app/code/community/Lanot/Core/Model/Item/Interface.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category Lanot
|
| 16 |
+
* @package Lanot_Core
|
| 17 |
+
* @copyright Copyright (c) 2012 Lanot
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
interface Lanot_Core_Model_Item_Interface
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* @return array
|
| 25 |
+
*/
|
| 26 |
+
public function getAvailableStatuses();
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @return int
|
| 30 |
+
*/
|
| 31 |
+
public function getStatusDisabled();
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* @return int
|
| 35 |
+
*/
|
| 36 |
+
public function getStatusEnabled();
|
| 37 |
+
}
|
app/design/adminhtml/default/default/layout/lanot_advancedtheme.xml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento backend layout
|
| 5 |
+
*
|
| 6 |
+
* @author Lanot
|
| 7 |
+
*/
|
| 8 |
+
-->
|
| 9 |
+
<layout>
|
| 10 |
+
|
| 11 |
+
<!-- ADMIN -->
|
| 12 |
+
<lanot_advancedtheme_adminhtml_design_index>
|
| 13 |
+
<reference name="content">
|
| 14 |
+
<block type="lanot_advancedtheme/adminhtml_design" name="lanot_advancedtheme_design" />
|
| 15 |
+
</reference>
|
| 16 |
+
</lanot_advancedtheme_adminhtml_design_index>
|
| 17 |
+
|
| 18 |
+
<lanot_advancedtheme_adminhtml_design_grid>
|
| 19 |
+
<block type="lanot_advancedtheme/adminhtml_design_grid" name="root"/>
|
| 20 |
+
</lanot_advancedtheme_adminhtml_design_grid>
|
| 21 |
+
|
| 22 |
+
<lanot_advancedtheme_adminhtml_design_new>
|
| 23 |
+
<update handle="lanot_advancedtheme_adminhtml_design_edit" />
|
| 24 |
+
</lanot_advancedtheme_adminhtml_design_new>
|
| 25 |
+
|
| 26 |
+
<lanot_advancedtheme_adminhtml_design_edit>
|
| 27 |
+
<reference name="content">
|
| 28 |
+
<block type="lanot_advancedtheme/adminhtml_design_edit" name="lanot_advancedtheme_design_edit" />
|
| 29 |
+
</reference>
|
| 30 |
+
<reference name="left">
|
| 31 |
+
<block type="lanot_advancedtheme/adminhtml_design_edit_tabs" name="lanot_advancedtheme_design_edit_tabs">
|
| 32 |
+
<block type="lanot_advancedtheme/adminhtml_design_edit_tab_general" name="lanot_advancedtheme_design_edit_tab_main" />
|
| 33 |
+
<action method="addTab"><name>main_section</name><block>lanot_advancedtheme_design_edit_tab_main</block></action>
|
| 34 |
+
</block>
|
| 35 |
+
</reference>
|
| 36 |
+
</lanot_advancedtheme_adminhtml_design_edit>
|
| 37 |
+
<!--/ADMIN -->
|
| 38 |
+
|
| 39 |
+
</layout>
|
app/etc/modules/Lanot_AdvancedTheme.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Lanot_AdvancedTheme>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Core />
|
| 9 |
+
<Lanot_Core />
|
| 10 |
+
</depends>
|
| 11 |
+
</Lanot_AdvancedTheme>
|
| 12 |
+
</modules>
|
| 13 |
+
</config>
|
app/etc/modules/Lanot_Core.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Lanot_Core>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<version>1.0.0.0</version>
|
| 8 |
+
<depends>
|
| 9 |
+
<Mage_Adminhtml />
|
| 10 |
+
</depends>
|
| 11 |
+
</Lanot_Core>
|
| 12 |
+
</modules>
|
| 13 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Lanot_AdvancedTheme</name>
|
| 4 |
+
<version>1.0.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>OSL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Extension Adds Ability Administrator choose target customer group for setting up Design Theme to the users assigned to the group and for date range.</summary>
|
| 10 |
+
<description>Extension Adds Ability Administrator choose target customer group for setting up Design Theme to the users assigned to the group and for date range.</description>
|
| 11 |
+
<notes>Prepared admin UI and functionality for setting up themes by custom group and dates range. Prepared for Magento Connect 2.0</notes>
|
| 12 |
+
<authors><author><name>Lanot</name><user>Lanot</user><email>lanot.biz@gmail.com</email></author></authors>
|
| 13 |
+
<date>2013-01-09</date>
|
| 14 |
+
<time>08:50:16</time>
|
| 15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Lanot_AdvancedTheme.xml" hash="0d1b46b487ceed861707dc4bf4c5f33c"/><file name="Lanot_Core.xml" hash="4a34519b5eb68d56afd1a5b93f529e71"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lanot_advancedtheme.xml" hash="3c22f21d6a6ad16109cbfca778683f30"/></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Lanot"><dir name="AdvancedTheme"><dir name="Block"><dir name="Adminhtml"><dir name="Design"><dir name="Edit"><file name="Form.php" hash="e8c56bc5d38b43795dd7c839343b5cae"/><dir name="Tab"><file name="General.php" hash="e64372dce8baa5b2250726d1e2698761"/></dir><file name="Tabs.php" hash="2f654af2ec68cfa73a4e286e7228b51e"/></dir><file name="Edit.php" hash="d81c9fa52b72546c2481c5117f82378a"/><file name="Grid.php" hash="8e182b0085d69adf623424c6249a2fa7"/></dir><file name="Design.php" hash="89ce76733470b3a12c4d25d3ea0b8844"/></dir></dir><dir name="Helper"><file name="Admin.php" hash="def367ed39404f3c792c496fd4e09591"/><file name="Data.php" hash="fa09ae839eac992d54159156d666d963"/></dir><dir name="Model"><file name="Design.php" hash="872f851dbeada48755f14e3fb39bb06b"/><dir name="Mysql4"><dir name="Design"><file name="Collection.php" hash="299b4f7087555ece6aea9b4a602aa93a"/></dir><file name="Design.php" hash="4b6d0ae26c2dd635c08e47280e0fb726"/></dir><file name="Observer.php" hash="235a015cbf5ad69a89c527698980cc04"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DesignController.php" hash="e82322ae77b7c4e61029ebbcb0350604"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="cc85617582f26534374f6dad0adc5304"/><file name="config.xml" hash="cb27987a2829a8b2d0d96a661dd6e7b8"/><file name="system.xml" hash="d837b74b26071cdf950e5fc153d5a5bd"/></dir><dir name="sql"><dir name="lanot_advancedtheme_setup"><file name="mysql4-install-1.0.0.0.php" hash="8c8005b51e3e7de2d9d520c104dd84b0"/></dir></dir></dir><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="Grid"><file name="Abstract.php" hash="fd0a241fb2cf4f42a732ba72dc4b8d5d"/></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="AbstractController.php" hash="9ebfaeab2c78fbe828449695f34bd733"/></dir></dir><dir name="Model"><dir name="Item"><file name="Interface.php" hash="19a7bde224ad3eb288119e9f36ca43e0"/></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
