my_exension - Version 1.1.20123

Version Notes

hello every bodyhello every bodyhello every bodyhello every body

Download this release

Release Info

Developer Magento Core Team
Extension my_exension
Version 1.1.20123
Comparing to
See all releases


Version 1.1.20123

app/code/local/chimps/Theme/Block/Adminhtml/Theme.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chimps_Theme_Block_Adminhtml_Theme extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_theme';
7
+ $this->_blockGroup = 'theme';
8
+ $this->_headerText = Mage::helper('theme')->__('Theme Manager');
9
+ $this->_addButtonLabel = Mage::helper('theme')->__('Add Theme');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/chimps/Theme/Block/Adminhtml/Theme/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Block_Adminhtml_Theme_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'theme';
11
+ $this->_controller = 'adminhtml_theme';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('theme')->__('Save Theme'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('theme')->__('Delete Theme'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('theme_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'theme_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'theme_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('theme_data') && Mage::registry('theme_data')->getId() ) {
40
+ return Mage::helper('theme')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('theme_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('theme')->__('Add Theme');
43
+ }
44
+ }
45
+ }
app/code/local/chimps/Theme/Block/Adminhtml/Theme/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Block_Adminhtml_Theme_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/chimps/Theme/Block/Adminhtml/Theme/Edit/Tab/Form.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Adminhtml
24
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+ class Chimps_Theme_Block_Adminhtml_Theme_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
28
+ {
29
+ protected function _prepareForm()
30
+ {
31
+ $form = new Varien_Data_Form();
32
+ $this->setForm($form);
33
+ $fieldset = $form->addFieldset('theme_form', array('legend'=>Mage::helper('theme')->__('Theme information')));
34
+
35
+ /* $fieldset->addField('title', 'text', array(
36
+ 'label' => Mage::helper('theme')->__('Title'),
37
+ 'class' => 'required-entry',
38
+ 'required' => true,
39
+ 'name' => 'title',
40
+ ));
41
+
42
+ $fieldset->addField('filename', 'file', array(
43
+ 'label' => Mage::helper('theme')->__('File'),
44
+ 'required' => false,
45
+ 'name' => 'filename',
46
+ ));*/
47
+ $fieldset->addField('Theme', 'select', array(
48
+ 'label' => Mage::helper('theme')->__('Theme'),
49
+ 'name' => 'theme',
50
+ 'values' => array(
51
+ array(
52
+ 'value' => Mage::getModel('core/design_source_design')->getAllOptions(),
53
+
54
+ 'label' => Mage::helper('theme')->__('Enabled'),
55
+ ),
56
+ ),
57
+ ));
58
+
59
+ if ( Mage::getSingleton('adminhtml/session')->getThemeData() )
60
+ {
61
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getThemeData());
62
+ Mage::getSingleton('adminhtml/session')->setThemeData(null);
63
+ } elseif ( Mage::registry('theme_data') ) {
64
+ $form->setValues(Mage::registry('theme_data')->getData());
65
+ }
66
+ return parent::_prepareForm();
67
+ }
68
+ }
69
+ /*$fieldset->addField('Theme', 'select', array(
70
+ 'label' => Mage::helper('theme')->__('Theme'),
71
+ 'name' => 'theme',
72
+ 'values' => array(
73
+ array(
74
+ 'value' => Mage::getModel('core/design_source_design')->getAllOptions(),
75
+
76
+ 'label' => Mage::helper('theme')->__('Enabled'),
77
+ ),
78
+ ),
79
+ ));*/
80
+
81
+
82
+
83
+ ?>
app/code/local/chimps/Theme/Block/Adminhtml/Theme/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Block_Adminhtml_Theme_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('theme_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('theme')->__('Theme Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('theme')->__('Theme Information'),
18
+ 'title' => Mage::helper('theme')->__('Theme Information'),
19
+ 'content' => $this->getLayout()->createBlock('theme/adminhtml_theme_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/chimps/Theme/Block/Adminhtml/Theme/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Block_Adminhtml_Theme_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('themeGrid');
9
+ $this->setDefaultSort('theme_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('theme/theme')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('theme_id', array(
24
+ 'header' => Mage::helper('theme')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'theme_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('theme')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('theme')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('theme')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('theme')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('theme')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('theme')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('theme')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('theme_id');
84
+ $this->getMassactionBlock()->setFormFieldName('theme');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('theme')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('theme')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('theme/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('theme')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('theme')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/local/chimps/Theme/Block/Theme.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chimps_Theme_Block_Theme extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getTheme()
10
+ {
11
+ if (!$this->hasData('theme')) {
12
+ $this->setData('theme', Mage::registry('theme'));
13
+ }
14
+ return $this->getData('theme');
15
+
16
+ }
17
+ }
app/code/local/chimps/Theme/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/chimps/Theme/Model/Mysql4/Theme.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Model_Mysql4_Theme extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the theme_id refers to the key field in your database table.
8
+ $this->_init('theme/theme', 'theme_id');
9
+ }
10
+ }
app/code/local/chimps/Theme/Model/Mysql4/Theme/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Model_Mysql4_Theme_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('theme/theme');
9
+ }
10
+ }
app/code/local/chimps/Theme/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('theme')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('theme')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/chimps/Theme/Model/Theme.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Model_Theme extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('theme/theme');
9
+ }
10
+ }
app/code/local/chimps/Theme/controllers/Adminhtml/ThemeController.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Chimps_Theme_Adminhtml_ThemeController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('theme/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Theme Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+ public function editAction() {
19
+ $id = $this->getRequest()->getParam('id');
20
+ $model = Mage::getModel('theme/theme')->load($id);
21
+
22
+ if ($model->getId() || $id == 0) {
23
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
24
+ if (!empty($data)) {
25
+ $model->setData($data);
26
+ }
27
+ Mage::register('theme_data', $model);
28
+
29
+ $this->loadLayout();
30
+ $this->_setActiveMenu('theme/items');
31
+
32
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Theme Manager'), Mage::helper('adminhtml')->__('Theme Manager'));
33
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Theme News'), Mage::helper('adminhtml')->__('Theme News'));
34
+
35
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
36
+
37
+ $this->_addContent($this->getLayout()->createBlock('theme/adminhtml_theme_edit'))
38
+ ->_addLeft($this->getLayout()->createBlock('theme/adminhtml_theme_edit_tabs'));
39
+
40
+ $this->renderLayout();
41
+ } else {
42
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('theme')->__('Theme does not exist'));
43
+ $this->_redirect('*/*/');
44
+ }
45
+ }
46
+
47
+ public function newAction() {
48
+ $this->_forward('edit');
49
+ }
50
+
51
+ public function saveAction() {
52
+ if ($data = $this->getRequest()->getPost()) {
53
+
54
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
55
+ try {
56
+ /* Starting upload */
57
+ $uploader = new Varien_File_Uploader('filename');
58
+
59
+ // Any extention would work
60
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
61
+ $uploader->setAllowRenameFiles(false);
62
+
63
+ // Set the file upload mode
64
+ // false -> get the file directly in the specified folder
65
+ // true -> get the file in the product like folders
66
+ // (file.jpg will go in something like /media/f/i/file.jpg)
67
+ $uploader->setFilesDispersion(false);
68
+
69
+ // We set media as the upload dir
70
+ $path = Mage::getBaseDir('media') . DS ;
71
+ $uploader->save($path, $_FILES['filename']['name'] );
72
+
73
+ } catch (Exception $e) {
74
+
75
+ }
76
+
77
+ //this way the name is saved in DB
78
+ $data['filename'] = $_FILES['filename']['name'];
79
+ }
80
+
81
+
82
+ $model = Mage::getModel('theme/theme');
83
+ $model->setData($data)
84
+ ->setId($this->getRequest()->getParam('id'));
85
+
86
+ try {
87
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
88
+ $model->setCreatedTime(now())
89
+ ->setUpdateTime(now());
90
+ } else {
91
+ $model->setUpdateTime(now());
92
+ }
93
+
94
+ $model->save();
95
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('theme')->__('Theme was successfully saved'));
96
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
97
+
98
+ if ($this->getRequest()->getParam('back')) {
99
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
100
+ return;
101
+ }
102
+ $this->_redirect('*/*/');
103
+ return;
104
+ } catch (Exception $e) {
105
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
106
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
107
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
108
+ return;
109
+ }
110
+ }
111
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('theme')->__('Unable to find Theme to save'));
112
+ $this->_redirect('*/*/');
113
+ }
114
+
115
+ public function deleteAction() {
116
+ if( $this->getRequest()->getParam('id') > 0 ) {
117
+ try {
118
+ $model = Mage::getModel('theme/theme');
119
+
120
+ $model->setId($this->getRequest()->getParam('id'))
121
+ ->delete();
122
+
123
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Theme was successfully deleted'));
124
+ $this->_redirect('*/*/');
125
+ } catch (Exception $e) {
126
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
127
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
128
+ }
129
+ }
130
+ $this->_redirect('*/*/');
131
+ }
132
+
133
+ public function massDeleteAction() {
134
+ $themeIds = $this->getRequest()->getParam('theme');
135
+ if(!is_array($themeIds)) {
136
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Theme(s)'));
137
+ } else {
138
+ try {
139
+ foreach ($themeIds as $themeId) {
140
+ $theme = Mage::getModel('theme/theme')->load($themeId);
141
+ $theme->delete();
142
+ }
143
+ Mage::getSingleton('adminhtml/session')->addSuccess(
144
+ Mage::helper('adminhtml')->__(
145
+ 'Total of %d record(s) were successfully deleted', count($themeIds)
146
+ )
147
+ );
148
+ } catch (Exception $e) {
149
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
150
+ }
151
+ }
152
+ $this->_redirect('*/*/index');
153
+ }
154
+
155
+ public function massStatusAction()
156
+ {
157
+ $themeIds = $this->getRequest()->getParam('theme');
158
+ if(!is_array($themeIds)) {
159
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Theme(s)'));
160
+ } else {
161
+ try {
162
+ foreach ($themeIds as $themeId) {
163
+ $theme = Mage::getSingleton('theme/theme')
164
+ ->load($themeId)
165
+ ->setStatus($this->getRequest()->getParam('status'))
166
+ ->setIsMassupdate(true)
167
+ ->save();
168
+ }
169
+ $this->_getSession()->addSuccess(
170
+ $this->__('Total of %d record(s) were successfully updated', count($themeIds))
171
+ );
172
+ } catch (Exception $e) {
173
+ $this->_getSession()->addError($e->getMessage());
174
+ }
175
+ }
176
+ $this->_redirect('*/*/index');
177
+ }
178
+
179
+ public function exportCsvAction()
180
+ {
181
+ $fileName = 'theme.csv';
182
+ $content = $this->getLayout()->createBlock('theme/adminhtml_theme_grid')
183
+ ->getCsv();
184
+
185
+ $this->_sendUploadResponse($fileName, $content);
186
+ }
187
+
188
+ public function exportXmlAction()
189
+ {
190
+ $fileName = 'theme.xml';
191
+ $content = $this->getLayout()->createBlock('theme/adminhtml_theme_grid')
192
+ ->getXml();
193
+
194
+ $this->_sendUploadResponse($fileName, $content);
195
+ }
196
+
197
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
198
+ {
199
+ $response = $this->getResponse();
200
+ $response->setHeader('HTTP/1.1 200 OK','');
201
+ $response->setHeader('Pragma', 'public', true);
202
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
203
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
204
+ $response->setHeader('Last-Modified', date('r'));
205
+ $response->setHeader('Accept-Ranges', 'bytes');
206
+ $response->setHeader('Content-Length', strlen($content));
207
+ $response->setHeader('Content-type', $contentType);
208
+ $response->setBody($content);
209
+ $response->sendResponse();
210
+ die;
211
+ }
212
+ }
app/code/local/chimps/Theme/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Chimps_Theme_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/theme?id=15
11
+ * or
12
+ * http://site.com/theme/id/15
13
+ */
14
+ /*
15
+ $theme_id = $this->getRequest()->getParam('id');
16
+
17
+ if($theme_id != null && $theme_id != '') {
18
+ $theme = Mage::getModel('theme/theme')->load($theme_id)->getData();
19
+ } else {
20
+ $theme = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($theme == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $themeTable = $resource->getTableName('theme');
32
+
33
+ $select = $read->select()
34
+ ->from($themeTable,array('theme_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $theme = $read->fetchRow($select);
39
+ }
40
+ Mage::register('theme', $theme);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/chimps/Theme/etc/config.xml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Chimps
5
+ * @package Chimps_Theme
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Chimps_Theme>
13
+ <version>0.1.0</version>
14
+ </Chimps_Theme>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <theme>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Chimps_Theme</module>
22
+ <frontName>theme</frontName>
23
+ </args>
24
+ </theme>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <theme>
29
+ <file>theme.xml</file>
30
+ </theme>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <theme>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Chimps_Theme</module>
40
+ <frontName>theme</frontName>
41
+ </args>
42
+ </theme>
43
+ </routers>
44
+ </admin>
45
+ <adminhtml>
46
+ <menu>
47
+ <theme module="theme">
48
+ <title>Theme</title>
49
+ <sort_order>71</sort_order>
50
+ <children>
51
+ <items module="theme">
52
+ <title>Manage Theme</title>
53
+ <sort_order>0</sort_order>
54
+ <action>theme/adminhtml_theme</action>
55
+ </items>
56
+ </children>
57
+ </theme>
58
+ </menu>
59
+ <acl>
60
+ <resources>
61
+ <all>
62
+ <title>Allow Everything</title>
63
+ </all>
64
+ <admin>
65
+ <children>
66
+ <Chimps_Theme>
67
+ <title>Theme Module</title>
68
+ <sort_order>10</sort_order>
69
+ </Chimps_Theme>
70
+ </children>
71
+ </admin>
72
+ </resources>
73
+ </acl>
74
+ <layout>
75
+ <updates>
76
+ <theme>
77
+ <file>theme.xml</file>
78
+ </theme>
79
+ </updates>
80
+ </layout>
81
+ </adminhtml>
82
+ <global>
83
+ <models>
84
+ <theme>
85
+ <class>Chimps_Theme_Model</class>
86
+ <resourceModel>theme_mysql4</resourceModel>
87
+ </theme>
88
+ <theme_mysql4>
89
+ <class>Chimps_Theme_Model_Mysql4</class>
90
+ <entities>
91
+ <theme>
92
+ <table>theme</table>
93
+ </theme>
94
+ </entities>
95
+ </theme_mysql4>
96
+ </models>
97
+ <resources>
98
+ <theme_setup>
99
+ <setup>
100
+ <module>Chimps_Theme</module>
101
+ </setup>
102
+ <connection>
103
+ <use>core_setup</use>
104
+ </connection>
105
+ </theme_setup>
106
+ <theme_write>
107
+ <connection>
108
+ <use>core_write</use>
109
+ </connection>
110
+ </theme_write>
111
+ <theme_read>
112
+ <connection>
113
+ <use>core_read</use>
114
+ </connection>
115
+ </theme_read>
116
+ </resources>
117
+ <blocks>
118
+ <theme>
119
+ <class>Chimps_Theme_Block</class>
120
+ </theme>
121
+ </blocks>
122
+ <helpers>
123
+ <theme>
124
+ <class>Chimps_Theme_Helper</class>
125
+ </theme>
126
+ </helpers>
127
+ </global>
128
+ </config>
app/code/local/chimps/Theme/sql/theme_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('theme')};
10
+ CREATE TABLE {$this->getTable('theme')} (
11
+ `theme_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`theme_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>my_exension</name>
4
+ <version>1.1.20123</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>hello every body</summary>
10
+ <description>&gt;Magento Absolute Template based on 2 column home page layout with products slider and image slider on welcome page. JavaScript slider on front page is easy to use and SEO friendly.</description>
11
+ <notes>hello every bodyhello every bodyhello every bodyhello every body</notes>
12
+ <authors><author><name>shakil</name><user>auto-converted</user><email>shakilbzu@yahoo.com</email></author></authors>
13
+ <date>2011-04-06</date>
14
+ <time>15:38:58</time>
15
+ <contents><target name="magelocal"><dir name="chimps"><dir name="Theme"><dir name="Block"><file name="Theme.php" hash="1ef6fa77e45ec61c094995242894abe1"/><dir name="Adminhtml"><file name="Theme.php" hash="296af7478f553612a52b76dabef320c8"/><dir name="Theme"><file name="Edit.php" hash="09c4cafdacb3c4fdcc85133fb01b835d"/><file name="Grid.php" hash="2983f1b1d2ce6aca838b6a9a989207b4"/><dir name="Edit"><file name="Form.php" hash="eedb15542b39aef3a41ea484b7ddd271"/><file name="Tabs.php" hash="31f901d70f236813689cc18a1b26de51"/><dir name="Tab"><file name="Form.php" hash="680651f33946f3e5a39f33ae0cddc6df"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="7f16703c7f2c04d237e20c8b824369a5"/><dir name="Adminhtml"><file name="ThemeController.php" hash="a374d8e0606778c404b28fc306556599"/></dir></dir><dir name="etc"><file name="config.xml" hash="006ef9622c9b84eba4d3be9429adcaf7"/></dir><dir name="Helper"><file name="Data.php" hash="c1f61f8e788752357dc9288de2763568"/></dir><dir name="Model"><file name="Status.php" hash="ff0c464b35d606df205d29e9365b43b4"/><file name="Theme.php" hash="62d984808722f3069abf3968a0f14372"/><dir name="Mysql4"><file name="Theme.php" hash="d0430412ecea3fcd8f8c68a9fe7715fa"/><dir name="Theme"><file name="Collection.php" hash="e39428b8c093684ae6c3bb75ee95897b"/></dir></dir></dir><dir name="sql"><dir name="theme_setup"><file name="mysql4-install-0.1.0.php" hash="89b4ca67296721377378d632cf47ba1d"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>