BroSolutions_CustomBackground - Version 1.0.0

Version Notes

- CMS, Product, Category, Home,Cart and Checkout pages management
- Custom styles
- Custom body selector

Download this release

Release Info

Developer Alex
Extension BroSolutions_CustomBackground
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (30) hide show
  1. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background.php +42 -0
  2. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit.php +82 -0
  3. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Form.php +52 -0
  4. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Tab/Form.php +253 -0
  5. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Tab/Stores.php +58 -0
  6. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Tabs.php +87 -0
  7. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Grid.php +301 -0
  8. app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Helper/Image.php +42 -0
  9. app/code/local/BroSolutions/CustomBackground/Block/Background.php +81 -0
  10. app/code/local/BroSolutions/CustomBackground/Controller/Adminhtml/CustomBackground.php +60 -0
  11. app/code/local/BroSolutions/CustomBackground/Helper/Background.php +38 -0
  12. app/code/local/BroSolutions/CustomBackground/Helper/Background/Image.php +36 -0
  13. app/code/local/BroSolutions/CustomBackground/Helper/Data.php +129 -0
  14. app/code/local/BroSolutions/CustomBackground/Helper/Image/Abstract.php +512 -0
  15. app/code/local/BroSolutions/CustomBackground/Model/Background.php +126 -0
  16. app/code/local/BroSolutions/CustomBackground/Model/Background/Attribute/Source/Targettype.php +113 -0
  17. app/code/local/BroSolutions/CustomBackground/Model/Resource/Background.php +150 -0
  18. app/code/local/BroSolutions/CustomBackground/Model/Resource/Background/Collection.php +136 -0
  19. app/code/local/BroSolutions/CustomBackground/Model/Resource/Setup.php +26 -0
  20. app/code/local/BroSolutions/CustomBackground/controllers/Adminhtml/Custombackground/BackgroundController.php +488 -0
  21. app/code/local/BroSolutions/CustomBackground/controllers/BackgroundController.php +26 -0
  22. app/code/local/BroSolutions/CustomBackground/etc/adminhtml.xml +69 -0
  23. app/code/local/BroSolutions/CustomBackground/etc/config.xml +125 -0
  24. app/code/local/BroSolutions/CustomBackground/etc/system.xml +59 -0
  25. app/code/local/BroSolutions/CustomBackground/sql/brosolutions_custombackground_setup/install-1.0.0.php +180 -0
  26. app/design/adminhtml/default/default/layout/brosolutions_custombackground.xml +55 -0
  27. app/design/frontend/base/default/layout/brosolutions_custombackground.xml +25 -0
  28. app/design/frontend/base/default/template/brosolutions/custombackground/js.phtml +11 -0
  29. app/etc/modules/BroSolutions_CustomBackground.xml +29 -0
  30. package.xml +20 -0
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background admin block
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background extends Mage_Adminhtml_Block_Widget_Grid_Container
25
+ {
26
+ /**
27
+ * constructor
28
+ *
29
+ * @access public
30
+ * @return void
31
+ * @author Ultimate Module Creator
32
+ */
33
+ public function __construct()
34
+ {
35
+ $this->_controller = 'adminhtml_background';
36
+ $this->_blockGroup = 'brosolutions_custombackground';
37
+ parent::__construct();
38
+ $this->_headerText = Mage::helper('brosolutions_custombackground')->__('Background');
39
+ $this->_updateButton('add', 'label', Mage::helper('brosolutions_custombackground')->__('Add Background'));
40
+
41
+ }
42
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background admin edit form
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
25
+ {
26
+ /**
27
+ * constructor
28
+ *
29
+ * @access public
30
+ * @return void
31
+ * @author Ultimate Module Creator
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ $this->_blockGroup = 'brosolutions_custombackground';
37
+ $this->_controller = 'adminhtml_background';
38
+ $this->_updateButton(
39
+ 'save',
40
+ 'label',
41
+ Mage::helper('brosolutions_custombackground')->__('Save Background')
42
+ );
43
+ $this->_updateButton(
44
+ 'delete',
45
+ 'label',
46
+ Mage::helper('brosolutions_custombackground')->__('Delete Background')
47
+ );
48
+ $this->_addButton(
49
+ 'saveandcontinue',
50
+ array(
51
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Save And Continue Edit'),
52
+ 'onclick' => 'saveAndContinueEdit()',
53
+ 'class' => 'save',
54
+ ),
55
+ -100
56
+ );
57
+ $this->_formScripts[] = "
58
+ function saveAndContinueEdit() {
59
+ editForm.submit($('edit_form').action+'back/edit/');
60
+ }
61
+ ";
62
+ }
63
+
64
+ /**
65
+ * get the edit form header
66
+ *
67
+ * @access public
68
+ * @return string
69
+ * @author Ultimate Module Creator
70
+ */
71
+ public function getHeaderText()
72
+ {
73
+ if (Mage::registry('current_background') && Mage::registry('current_background')->getId()) {
74
+ return Mage::helper('brosolutions_custombackground')->__(
75
+ "Edit Background '%s'",
76
+ $this->escapeHtml(Mage::registry('current_background')->getName())
77
+ );
78
+ } else {
79
+ return Mage::helper('brosolutions_custombackground')->__('Add Background');
80
+ }
81
+ }
82
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Form.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background edit form
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
25
+ {
26
+ /**
27
+ * prepare form
28
+ *
29
+ * @access protected
30
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Form
31
+ * @author Ultimate Module Creator
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $form = new Varien_Data_Form(
36
+ array(
37
+ 'id' => 'edit_form',
38
+ 'action' => $this->getUrl(
39
+ '*/*/save',
40
+ array(
41
+ 'id' => $this->getRequest()->getParam('id')
42
+ )
43
+ ),
44
+ 'method' => 'post',
45
+ 'enctype' => 'multipart/form-data'
46
+ )
47
+ );
48
+ $form->setUseContainer(true);
49
+ $this->setForm($form);
50
+ return parent::_prepareForm();
51
+ }
52
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Tab/Form.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background edit form tab
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
25
+ {
26
+ /**
27
+ * prepare the form
28
+ *
29
+ * @access protected
30
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Tab_Form
31
+ * @author Ultimate Module Creator
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $form = new Varien_Data_Form();
36
+ $form->setHtmlIdPrefix('background_');
37
+ $form->setFieldNameSuffix('background');
38
+ $this->setForm($form);
39
+ $fieldset = $form->addFieldset(
40
+ 'background_form',
41
+ array('legend' => Mage::helper('brosolutions_custombackground')->__('Background'))
42
+ );
43
+ $fieldset->addType(
44
+ 'image',
45
+ Mage::getConfig()->getBlockClassName('brosolutions_custombackground/adminhtml_background_helper_image')
46
+ );
47
+
48
+ $fieldset->addField(
49
+ 'name',
50
+ 'text',
51
+ array(
52
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Name'),
53
+ 'name' => 'name',
54
+ 'required' => true,
55
+ 'class' => 'required-entry',
56
+ )
57
+ );
58
+
59
+ $fieldset->addField(
60
+ 'target_element',
61
+ 'select',
62
+ array(
63
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Append Background To'),
64
+ 'name' => 'target_element',
65
+ 'required' => true,
66
+ 'class' => 'required-entry',
67
+ 'values'=> array(
68
+ '.wrapper'=>'Wrapper',
69
+ 'body'=>'Body',
70
+ 'custom'=>'Custom CSS selector',
71
+ ),
72
+ )
73
+ );
74
+
75
+
76
+ $fieldset->addField(
77
+ 'target_element_custom',
78
+ 'text',
79
+ array(
80
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Custom CSS selector'),
81
+ 'name' => 'target_element_custom',
82
+ 'required' => false,
83
+ 'note'=>'Input CSS seletot, like .class or #id',
84
+ )
85
+ );
86
+
87
+ $fieldset->addField(
88
+ 'target_type',
89
+ 'select',
90
+ array(
91
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Type Of Object'),
92
+ 'name' => 'target_type',
93
+ 'required' => true,
94
+ 'class' => 'required-entry',
95
+
96
+ 'values'=> Mage::getModel('brosolutions_custombackground/background_attribute_source_targettype')->getAllOptions(true),
97
+ )
98
+ );
99
+
100
+ $options = $collection = Mage::getModel('cms/page')
101
+ ->getCollection()
102
+ ->addFieldToFilter('is_active',1)
103
+ ->toOptionArray();
104
+
105
+ $fieldset->addField(
106
+ 'target_id',
107
+ 'multiselect',
108
+ array(
109
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Object'),
110
+ 'name' => 'target_id',
111
+ 'required' => true,
112
+ 'class' => 'required-entry',
113
+ 'values' => $options,
114
+ )
115
+ );
116
+
117
+ $fieldset->addField(
118
+ 'background',
119
+ 'image',
120
+ array(
121
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Background'),
122
+ 'name' => 'background',
123
+
124
+ )
125
+ );
126
+
127
+ $fieldset->addField(
128
+ 'color',
129
+ 'text',
130
+ array(
131
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Background Color'),
132
+ 'name' => 'color',
133
+ 'class' => 'color'
134
+ )
135
+ );
136
+
137
+
138
+ $fieldset->addField(
139
+ 'repeat_x',
140
+ 'select',
141
+ array(
142
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Repeat-X'),
143
+ 'name' => 'repeat_x',
144
+
145
+ 'values'=> array(
146
+ array(
147
+ 'value' => 1,
148
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Yes'),
149
+ ),
150
+ array(
151
+ 'value' => 0,
152
+ 'label' => Mage::helper('brosolutions_custombackground')->__('No'),
153
+ ),
154
+ ),
155
+ )
156
+ );
157
+
158
+ $fieldset->addField(
159
+ 'repeat_y',
160
+ 'select',
161
+ array(
162
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Repeat-Y'),
163
+ 'name' => 'repeat_y',
164
+
165
+ 'values'=> array(
166
+ array(
167
+ 'value' => 1,
168
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Yes'),
169
+ ),
170
+ array(
171
+ 'value' => 0,
172
+ 'label' => Mage::helper('brosolutions_custombackground')->__('No'),
173
+ ),
174
+ ),
175
+ )
176
+ );
177
+
178
+ $fieldset->addField(
179
+ 'style',
180
+ 'text',
181
+ array(
182
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Additional CSS Styles'),
183
+ 'name' => 'style',
184
+
185
+ )
186
+ );
187
+ $fieldset->addField(
188
+ 'status',
189
+ 'select',
190
+ array(
191
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Status'),
192
+ 'name' => 'status',
193
+ 'values' => array(
194
+ array(
195
+ 'value' => 1,
196
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Enabled'),
197
+ ),
198
+ array(
199
+ 'value' => 0,
200
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Disabled'),
201
+ ),
202
+ ),
203
+ )
204
+ );
205
+ if (Mage::app()->isSingleStoreMode()) {
206
+ $fieldset->addField(
207
+ 'store_id',
208
+ 'hidden',
209
+ array(
210
+ 'name' => 'stores[]',
211
+ 'value' => Mage::app()->getStore(true)->getId()
212
+ )
213
+ );
214
+ Mage::registry('current_background')->setStoreId(Mage::app()->getStore(true)->getId());
215
+ }
216
+ $formValues = Mage::registry('current_background')->getDefaultValues();
217
+ if (!is_array($formValues)) {
218
+ $formValues = array();
219
+ }
220
+ if (Mage::getSingleton('adminhtml/session')->getBackgroundData()) {
221
+ $formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getBackgroundData());
222
+ Mage::getSingleton('adminhtml/session')->setBackgroundData(null);
223
+ } elseif (Mage::registry('current_background')) {
224
+ $formValues = array_merge($formValues, Mage::registry('current_background')->getData());
225
+ }
226
+ $form->setValues($formValues);
227
+
228
+ $this->setChild(
229
+ 'form_after',
230
+ $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
231
+ ->addFieldMap('background_target_element', 'target_element')
232
+ ->addFieldMap('background_target_element_custom', 'target_element_custom')
233
+ ->addFieldDependence('target_element_custom', 'target_element', 'custom')
234
+ ->addFieldMap('background_target_type','target_type')
235
+ ->addFieldMap('background_target_id','target_id')
236
+ ->addFieldDependence('target_id', 'target_type', array('1','3'))
237
+ );
238
+
239
+ return parent::_prepareForm();
240
+ }
241
+
242
+
243
+ // public function _afterToHtml($html) {
244
+ // $html .= '<script>
245
+ // Event.observe($("background_target_type"), "change", function(){
246
+ // new Ajax.Updater("background_target_id", "'.$this->getUrl('*/*/getTarget').'", {
247
+ // parameters: { type: $F("background_target_type") }
248
+ // });
249
+ // })
250
+ // </script>';
251
+ // return parent::_afterToHtml($html);
252
+ // }
253
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Tab/Stores.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * store selection tab
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
25
+ {
26
+ /**
27
+ * prepare the form
28
+ *
29
+ * @access protected
30
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Tab_Stores
31
+ * @author Ultimate Module Creator
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $form = new Varien_Data_Form();
36
+ $form->setFieldNameSuffix('background');
37
+ $this->setForm($form);
38
+ $fieldset = $form->addFieldset(
39
+ 'background_stores_form',
40
+ array('legend' => Mage::helper('brosolutions_custombackground')->__('Store views'))
41
+ );
42
+ $field = $fieldset->addField(
43
+ 'store_id',
44
+ 'multiselect',
45
+ array(
46
+ 'name' => 'stores[]',
47
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Store Views'),
48
+ 'title' => Mage::helper('brosolutions_custombackground')->__('Store Views'),
49
+ 'required' => true,
50
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
51
+ )
52
+ );
53
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
54
+ $field->setRenderer($renderer);
55
+ $form->addValues(Mage::registry('current_background')->getData());
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Edit/Tabs.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background admin edit tabs
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
25
+ {
26
+ /**
27
+ * Initialize Tabs
28
+ *
29
+ * @access public
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct()
33
+ {
34
+ parent::__construct();
35
+ $this->setId('background_tabs');
36
+ $this->setDestElementId('edit_form');
37
+ $this->setTitle(Mage::helper('brosolutions_custombackground')->__('Background'));
38
+ }
39
+
40
+ /**
41
+ * before render html
42
+ *
43
+ * @access protected
44
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Edit_Tabs
45
+ * @author Ultimate Module Creator
46
+ */
47
+ protected function _beforeToHtml()
48
+ {
49
+ $this->addTab(
50
+ 'form_background',
51
+ array(
52
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Background'),
53
+ 'title' => Mage::helper('brosolutions_custombackground')->__('Background'),
54
+ 'content' => $this->getLayout()->createBlock(
55
+ 'brosolutions_custombackground/adminhtml_background_edit_tab_form'
56
+ )
57
+ ->toHtml(),
58
+ )
59
+ );
60
+ if (!Mage::app()->isSingleStoreMode()) {
61
+ $this->addTab(
62
+ 'form_store_background',
63
+ array(
64
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Store views'),
65
+ 'title' => Mage::helper('brosolutions_custombackground')->__('Store views'),
66
+ 'content' => $this->getLayout()->createBlock(
67
+ 'brosolutions_custombackground/adminhtml_background_edit_tab_stores'
68
+ )
69
+ ->toHtml(),
70
+ )
71
+ );
72
+ }
73
+ return parent::_beforeToHtml();
74
+ }
75
+
76
+ /**
77
+ * Retrieve background entity
78
+ *
79
+ * @access public
80
+ * @return BroSolutions_CustomBackground_Model_Background
81
+ * @author Ultimate Module Creator
82
+ */
83
+ public function getBackground()
84
+ {
85
+ return Mage::registry('current_background');
86
+ }
87
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Grid.php ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background admin grid block
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Grid extends Mage_Adminhtml_Block_Widget_Grid
25
+ {
26
+ /**
27
+ * constructor
28
+ *
29
+ * @access public
30
+ * @author Ultimate Module Creator
31
+ */
32
+ public function __construct()
33
+ {
34
+ parent::__construct();
35
+ $this->setId('backgroundGrid');
36
+ $this->setDefaultSort('entity_id');
37
+ $this->setDefaultDir('ASC');
38
+ $this->setSaveParametersInSession(true);
39
+ $this->setUseAjax(true);
40
+ }
41
+
42
+ /**
43
+ * prepare collection
44
+ *
45
+ * @access protected
46
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Grid
47
+ * @author Ultimate Module Creator
48
+ */
49
+ protected function _prepareCollection()
50
+ {
51
+ $collection = Mage::getModel('brosolutions_custombackground/background')
52
+ ->getCollection();
53
+
54
+ $this->setCollection($collection);
55
+ return parent::_prepareCollection();
56
+ }
57
+
58
+ /**
59
+ * prepare grid collection
60
+ *
61
+ * @access protected
62
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Grid
63
+ * @author Ultimate Module Creator
64
+ */
65
+ protected function _prepareColumns()
66
+ {
67
+ $this->addColumn(
68
+ 'entity_id',
69
+ array(
70
+ 'header' => Mage::helper('brosolutions_custombackground')->__('Id'),
71
+ 'index' => 'entity_id',
72
+ 'type' => 'number'
73
+ )
74
+ );
75
+ $this->addColumn(
76
+ 'name',
77
+ array(
78
+ 'header' => Mage::helper('brosolutions_custombackground')->__('Name'),
79
+ 'align' => 'left',
80
+ 'index' => 'name',
81
+ )
82
+ );
83
+
84
+ $this->addColumn(
85
+ 'status',
86
+ array(
87
+ 'header' => Mage::helper('brosolutions_custombackground')->__('Status'),
88
+ 'index' => 'status',
89
+ 'type' => 'options',
90
+ 'options' => array(
91
+ '1' => Mage::helper('brosolutions_custombackground')->__('Enabled'),
92
+ '0' => Mage::helper('brosolutions_custombackground')->__('Disabled'),
93
+ )
94
+ )
95
+ );
96
+ $this->addColumn(
97
+ 'target_type',
98
+ array(
99
+ 'header' => Mage::helper('brosolutions_custombackground')->__('Type Of Object'),
100
+ 'index' => 'target_type',
101
+ 'type' => 'options',
102
+ 'options' => Mage::helper('brosolutions_custombackground')->convertOptions(
103
+ Mage::getModel('brosolutions_custombackground/background_attribute_source_targettype')->getAllOptions(false)
104
+ )
105
+
106
+ )
107
+ );
108
+ if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
109
+ $this->addColumn(
110
+ 'store_id',
111
+ array(
112
+ 'header' => Mage::helper('brosolutions_custombackground')->__('Store Views'),
113
+ 'index' => 'store_id',
114
+ 'type' => 'store',
115
+ 'store_all' => true,
116
+ 'store_view' => true,
117
+ 'sortable' => false,
118
+ 'filter_condition_callback'=> array($this, '_filterStoreCondition'),
119
+ )
120
+ );
121
+ }
122
+ $this->addColumn(
123
+ 'action',
124
+ array(
125
+ 'header' => Mage::helper('brosolutions_custombackground')->__('Action'),
126
+ 'width' => '100',
127
+ 'type' => 'action',
128
+ 'getter' => 'getId',
129
+ 'actions' => array(
130
+ array(
131
+ 'caption' => Mage::helper('brosolutions_custombackground')->__('Edit'),
132
+ 'url' => array('base'=> '*/*/edit'),
133
+ 'field' => 'id'
134
+ )
135
+ ),
136
+ 'filter' => false,
137
+ 'is_system' => true,
138
+ 'sortable' => false,
139
+ )
140
+ );
141
+ $this->addExportType('*/*/exportCsv', Mage::helper('brosolutions_custombackground')->__('CSV'));
142
+ $this->addExportType('*/*/exportExcel', Mage::helper('brosolutions_custombackground')->__('Excel'));
143
+ $this->addExportType('*/*/exportXml', Mage::helper('brosolutions_custombackground')->__('XML'));
144
+ return parent::_prepareColumns();
145
+ }
146
+
147
+ /**
148
+ * prepare mass action
149
+ *
150
+ * @access protected
151
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Grid
152
+ * @author Ultimate Module Creator
153
+ */
154
+ protected function _prepareMassaction()
155
+ {
156
+ $this->setMassactionIdField('entity_id');
157
+ $this->getMassactionBlock()->setFormFieldName('background');
158
+ $this->getMassactionBlock()->addItem(
159
+ 'delete',
160
+ array(
161
+ 'label'=> Mage::helper('brosolutions_custombackground')->__('Delete'),
162
+ 'url' => $this->getUrl('*/*/massDelete'),
163
+ 'confirm' => Mage::helper('brosolutions_custombackground')->__('Are you sure?')
164
+ )
165
+ );
166
+ $this->getMassactionBlock()->addItem(
167
+ 'status',
168
+ array(
169
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Change status'),
170
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
171
+ 'additional' => array(
172
+ 'status' => array(
173
+ 'name' => 'status',
174
+ 'type' => 'select',
175
+ 'class' => 'required-entry',
176
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Status'),
177
+ 'values' => array(
178
+ '1' => Mage::helper('brosolutions_custombackground')->__('Enabled'),
179
+ '0' => Mage::helper('brosolutions_custombackground')->__('Disabled'),
180
+ )
181
+ )
182
+ )
183
+ )
184
+ );
185
+ $this->getMassactionBlock()->addItem(
186
+ 'target_type',
187
+ array(
188
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Change Type Of Object'),
189
+ 'url' => $this->getUrl('*/*/massTargetType', array('_current'=>true)),
190
+ 'additional' => array(
191
+ 'flag_target_type' => array(
192
+ 'name' => 'flag_target_type',
193
+ 'type' => 'select',
194
+ 'class' => 'required-entry',
195
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Type Of Object'),
196
+ 'values' => Mage::getModel('brosolutions_custombackground/background_attribute_source_targettype')
197
+ ->getAllOptions(true),
198
+
199
+ )
200
+ )
201
+ )
202
+ );
203
+ $this->getMassactionBlock()->addItem(
204
+ 'repeat_x',
205
+ array(
206
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Change Repeat-X'),
207
+ 'url' => $this->getUrl('*/*/massRepeatX', array('_current'=>true)),
208
+ 'additional' => array(
209
+ 'flag_repeat_x' => array(
210
+ 'name' => 'flag_repeat_x',
211
+ 'type' => 'select',
212
+ 'class' => 'required-entry',
213
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Repeat-X'),
214
+ 'values' => array(
215
+ '1' => Mage::helper('brosolutions_custombackground')->__('Yes'),
216
+ '0' => Mage::helper('brosolutions_custombackground')->__('No'),
217
+ )
218
+
219
+ )
220
+ )
221
+ )
222
+ );
223
+ $this->getMassactionBlock()->addItem(
224
+ 'repeat_y',
225
+ array(
226
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Change Repeat-Y'),
227
+ 'url' => $this->getUrl('*/*/massRepeatY', array('_current'=>true)),
228
+ 'additional' => array(
229
+ 'flag_repeat_y' => array(
230
+ 'name' => 'flag_repeat_y',
231
+ 'type' => 'select',
232
+ 'class' => 'required-entry',
233
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Repeat-Y'),
234
+ 'values' => array(
235
+ '1' => Mage::helper('brosolutions_custombackground')->__('Yes'),
236
+ '0' => Mage::helper('brosolutions_custombackground')->__('No'),
237
+ )
238
+
239
+ )
240
+ )
241
+ )
242
+ );
243
+ return $this;
244
+ }
245
+
246
+ /**
247
+ * get the row url
248
+ *
249
+ * @access public
250
+ * @param BroSolutions_CustomBackground_Model_Background
251
+ * @return string
252
+ * @author Ultimate Module Creator
253
+ */
254
+ public function getRowUrl($row)
255
+ {
256
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
257
+ }
258
+
259
+ /**
260
+ * get the grid url
261
+ *
262
+ * @access public
263
+ * @return string
264
+ * @author Ultimate Module Creator
265
+ */
266
+ public function getGridUrl()
267
+ {
268
+ return $this->getUrl('*/*/grid', array('_current'=>true));
269
+ }
270
+
271
+ /**
272
+ * after collection load
273
+ *
274
+ * @access protected
275
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Grid
276
+ * @author Ultimate Module Creator
277
+ */
278
+ protected function _afterLoadCollection()
279
+ {
280
+ $this->getCollection()->walk('afterLoad');
281
+ parent::_afterLoadCollection();
282
+ }
283
+
284
+ /**
285
+ * filter store column
286
+ *
287
+ * @access protected
288
+ * @param BroSolutions_CustomBackground_Model_Resource_Background_Collection $collection
289
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
290
+ * @return BroSolutions_CustomBackground_Block_Adminhtml_Background_Grid
291
+ * @author Ultimate Module Creator
292
+ */
293
+ protected function _filterStoreCondition($collection, $column)
294
+ {
295
+ if (!$value = $column->getFilter()->getValue()) {
296
+ return;
297
+ }
298
+ $collection->addStoreFilter($value);
299
+ return $this;
300
+ }
301
+ }
app/code/local/BroSolutions/CustomBackground/Block/Adminhtml/Background/Helper/Image.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background image field renderer helper
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Block_Adminhtml_Background_Helper_Image extends Varien_Data_Form_Element_Image
25
+ {
26
+ /**
27
+ * get the url of the image
28
+ *
29
+ * @access protected
30
+ * @return string
31
+ * @author Ultimate Module Creator
32
+ */
33
+ protected function _getUrl()
34
+ {
35
+ $url = false;
36
+ if ($this->getValue()) {
37
+ $url = Mage::helper('brosolutions_custombackground/background_image')->getImageBaseUrl().
38
+ $this->getValue();
39
+ }
40
+ return $url;
41
+ }
42
+ }
app/code/local/BroSolutions/CustomBackground/Block/Background.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background admin block
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+
25
+ class BroSolutions_CustomBackground_Block_Background extends Mage_Core_Block_Template
26
+ {
27
+
28
+ public function getBackground()
29
+ {
30
+ if(!$this->getData('current_bro_background')){
31
+ $background = Mage::helper('brosolutions_custombackground')->getCurrentBackground();
32
+ $this->setData('current_bro_background',$background);
33
+ }
34
+ return $this->getData('current_bro_background');
35
+ }
36
+
37
+
38
+ public function isBackgroundNeeded()
39
+ {
40
+ return (bool)$this->getBackground();
41
+ }
42
+
43
+ public function getStyleOptions(){
44
+ $result = array();
45
+ $background = $this->getBackground();
46
+ if(strlen($background->getColor())){
47
+ $result['backgroundColor'] = '#'.$background->getColor();
48
+ }
49
+
50
+ if(strlen($background->getBackground())){
51
+ $result['backgroundImage'] = 'url('.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'background/image'.$background->getBackground().')';
52
+ }
53
+
54
+ if($background->getRepeatX() && $background->getRepeatY()){
55
+ $result['backgroundRepeat'] = 'repeat';
56
+ } elseif($background->getRepeatX()){
57
+ $result['backgroundRepeat'] = 'repeat-x';
58
+ } elseif($background->getRepeatY()){
59
+ $result['backgroundRepeat'] = 'repeat-y';
60
+ }
61
+
62
+ if(strlen($background->getStyle())){
63
+ foreach(explode(';',$background->getStyle()) as $pair){
64
+ if(!stristr($pair, ':'))
65
+ continue;
66
+ list($key,$value) = explode(':',$pair);
67
+ $result[$key] = $value;
68
+ }
69
+ }
70
+
71
+ return $result;
72
+ }
73
+
74
+
75
+ public function getTargetElement()
76
+ {
77
+ $background = $this->getBackground();
78
+ return $background->getTargetElement();
79
+ }
80
+ }
81
+
app/code/local/BroSolutions/CustomBackground/Controller/Adminhtml/CustomBackground.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * module base admin controller
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Controller_Adminhtml_CustomBackground extends Mage_Adminhtml_Controller_Action
25
+ {
26
+ /**
27
+ * upload file and get the uploaded name
28
+ *
29
+ * @access public
30
+ * @param string $input
31
+ * @param string $destinationFolder
32
+ * @param array $data
33
+ * @return string
34
+ * @author Ultimate Module Creator
35
+ */
36
+ protected function _uploadAndGetName($input, $destinationFolder, $data)
37
+ {
38
+ try {
39
+ if (isset($data[$input]['delete'])) {
40
+ return '';
41
+ } else {
42
+ $uploader = new Varien_File_Uploader($input);
43
+ $uploader->setAllowRenameFiles(true);
44
+ $uploader->setFilesDispersion(true);
45
+ $uploader->setAllowCreateFolders(true);
46
+ $result = $uploader->save($destinationFolder);
47
+ return $result['file'];
48
+ }
49
+ } catch (Exception $e) {
50
+ if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
51
+ throw $e;
52
+ } else {
53
+ if (isset($data[$input]['value'])) {
54
+ return $data[$input]['value'];
55
+ }
56
+ }
57
+ }
58
+ return '';
59
+ }
60
+ }
app/code/local/BroSolutions/CustomBackground/Helper/Background.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background helper
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Helper_Background extends Mage_Core_Helper_Abstract
25
+ {
26
+
27
+ /**
28
+ * check if breadcrumbs can be used
29
+ *
30
+ * @access public
31
+ * @return bool
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function getUseBreadcrumbs()
35
+ {
36
+ return Mage::getStoreConfigFlag('brosolutions_custombackground/background/breadcrumbs');
37
+ }
38
+ }
app/code/local/BroSolutions/CustomBackground/Helper/Background/Image.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background image helper
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Helper_Background_Image extends BroSolutions_CustomBackground_Helper_Image_Abstract
25
+ {
26
+ /**
27
+ * image placeholder
28
+ * @var string
29
+ */
30
+ protected $_placeholder = 'images/placeholder/background.jpg';
31
+ /**
32
+ * image subdir
33
+ * @var string
34
+ */
35
+ protected $_subdir = 'background';
36
+ }
app/code/local/BroSolutions/CustomBackground/Helper/Data.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * CustomBackground default helper
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Helper_Data extends Mage_Core_Helper_Abstract
25
+ {
26
+ /**
27
+ * convert array to options
28
+ *
29
+ * @access public
30
+ * @param $options
31
+ * @return array
32
+ * @author Ultimate Module Creator
33
+ */
34
+ public function convertOptions($options)
35
+ {
36
+ $converted = array();
37
+ foreach ($options as $option) {
38
+ if (isset($option['value']) && !is_array($option['value']) &&
39
+ isset($option['label']) && !is_array($option['label'])) {
40
+ $converted[$option['value']] = $option['label'];
41
+ }
42
+ }
43
+ return $converted;
44
+ }
45
+
46
+ public function getObjectsByType($type)
47
+ {
48
+ switch ($type){
49
+ case BroSolutions_CustomBackground_Model_Background::TARGET_CMS:
50
+ $collection = Mage::getModel('cms/page')
51
+ ->getCollection()
52
+ ->addFieldToFilter('is_active',1);
53
+ break;
54
+ default:
55
+ return false;
56
+ }
57
+
58
+ return $collection->toOptionArray();
59
+ }
60
+
61
+
62
+ public function getCurrentBackground()
63
+ {
64
+ switch(Mage::app()->getRequest()->getControllerName()){
65
+ case 'index':
66
+ $background = Mage::getModel('brosolutions_custombackground/background')
67
+ ->getCollection()
68
+ ->addStoreFilter(Mage::app()->getStore())
69
+ ->addFieldToFilter('status',1)
70
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_HOME)
71
+ ->getFirstItem();
72
+ break;
73
+ case 'page':
74
+ $background = Mage::getModel('brosolutions_custombackground/background')
75
+ ->getCollection()
76
+ ->addFieldToFilter('status',1)
77
+ ->addStoreFilter(Mage::app()->getStore())
78
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_CMS)
79
+ ->addFieldToFilter('target_id',array('regexp'=>'(^|,)'.Mage::getSingleton('cms/page')->getIdentifier().'(,|$)'))
80
+ ->getFirstItem();
81
+ break;
82
+
83
+ case 'category':
84
+ $background = Mage::getModel('brosolutions_custombackground/background')
85
+ ->getCollection()
86
+ ->addStoreFilter(Mage::app()->getStore())
87
+ ->addFieldToFilter('status',1)
88
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_CATEGORY)
89
+ ->getFirstItem();
90
+ break;
91
+ case 'product':
92
+ $background = Mage::getModel('brosolutions_custombackground/background')
93
+ ->getCollection()
94
+ ->addStoreFilter(Mage::app()->getStore())
95
+ ->addFieldToFilter('status',1)
96
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_CATEGORY)
97
+ ->getFirstItem();
98
+ break;
99
+ case 'cart':
100
+ $background = Mage::getModel('brosolutions_custombackground/background')
101
+ ->getCollection()
102
+ ->addStoreFilter(Mage::app()->getStore())
103
+ ->addFieldToFilter('status',1)
104
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_CART)
105
+ ->getFirstItem();
106
+ break;
107
+ case 'onepage':
108
+ case 'checkout':
109
+ $background = Mage::getModel('brosolutions_custombackground/background')
110
+ ->getCollection()
111
+ ->addStoreFilter(Mage::app()->getStore())
112
+ ->addFieldToFilter('status',1)
113
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_CHECKOUT)
114
+ ->getFirstItem();
115
+ break;
116
+ case 'account':
117
+ $background = Mage::getModel('brosolutions_custombackground/background')
118
+ ->getCollection()
119
+ ->addStoreFilter(Mage::app()->getStore())
120
+ ->addFieldToFilter('status',1)
121
+ ->addFieldToFilter('target_type',BroSolutions_CustomBackground_Model_Background::TARGET_CUSTOMER)
122
+ ->getFirstItem();
123
+ break;
124
+
125
+ default: Mage::getModel('brosolutions_custombackground/background');
126
+ }
127
+ return $background;
128
+ }
129
+ }
app/code/local/BroSolutions/CustomBackground/Helper/Image/Abstract.php ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * abstract image helper
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ abstract class BroSolutions_CustomBackground_Helper_Image_Abstract extends Mage_Core_Helper_Data
25
+ {
26
+ /**
27
+ * path to image placeholder
28
+ * override in child
29
+ * @var string
30
+ */
31
+ protected $_placeholder = '';
32
+
33
+ /**
34
+ * subdirectory to save imaves
35
+ * override in child
36
+ * @var string
37
+ */
38
+ protected $_subdir = '';
39
+
40
+ /**
41
+ * image processor
42
+ * @var null|Varien_Image_Adapter_Gd2
43
+ */
44
+ protected $_imageProcessor = null;
45
+
46
+ /**
47
+ * image to process
48
+ * @var unknown_type
49
+ */
50
+ protected $_image = null;
51
+
52
+ /**
53
+ * error message
54
+ * @var string
55
+ */
56
+ protected $_openError = "";
57
+
58
+ /**
59
+ * keep image frame
60
+ * @var bool
61
+ */
62
+ protected $_keepFrame = false;
63
+
64
+ /**
65
+ * keep image aspect ratio
66
+ * @var bool
67
+ */
68
+ protected $_keepAspectRatio = true;
69
+
70
+ /**
71
+ * constrain image
72
+ * @var bool
73
+ */
74
+ protected $_constrainOnly = true;
75
+
76
+ /**
77
+ * addaptive resize - crop
78
+ * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
79
+ * @var bool
80
+ */
81
+ protected $_adaptiveResize = 'center'; // false|center|top|bottom
82
+
83
+ /**
84
+ * image width
85
+ * @var mixed(null|int)
86
+ */
87
+ protected $_width = null;
88
+
89
+ /**
90
+ * image height
91
+ * @var mixed(null|int)
92
+ */
93
+ protected $_height = null;
94
+
95
+ /**
96
+ * image resize needed
97
+ * @var mixed (null|array)
98
+ */
99
+ protected $_scheduledResize = null;
100
+
101
+ /**
102
+ * image is resized
103
+ * @var bool
104
+ */
105
+ protected $_resized = false;
106
+
107
+ /**
108
+ * addaptive resize positions
109
+ * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
110
+ * @var array
111
+ */
112
+ protected $_adaptiveResizePositions = array(
113
+ 'center' => array(0.5,0.5),
114
+ 'top' => array(1,0),
115
+ 'bottom' => array(0,1)
116
+ );
117
+
118
+ /**
119
+ * resized image folder name
120
+ * @var string
121
+ */
122
+ protected $_resizeFolderName = 'cache';
123
+
124
+ /**
125
+ * get the image base dir
126
+ *
127
+ * @access public
128
+ * @return string
129
+ * @author Ultimate Module Creator
130
+ */
131
+ public function getImageBaseDir()
132
+ {
133
+ return Mage::getBaseDir('media').DS.$this->_subdir.DS.'image';
134
+ }
135
+
136
+ /**
137
+ * get the image url for object
138
+ *
139
+ * @access public
140
+ * @return string
141
+ * @author Ultimate Module Creator
142
+ */
143
+ public function getImageBaseUrl()
144
+ {
145
+ return Mage::getBaseUrl('media').$this->_subdir.'/'.'image';
146
+ }
147
+
148
+ /**
149
+ * init image
150
+ *
151
+ * @access public
152
+ * @param Varien_Object $object
153
+ * @param string $imageField
154
+ * @return BroSolutions_CustomBackground_Helper_Image_Abstract
155
+ * @author Ultimate Module Creator
156
+ */
157
+ public function init(Varien_Object $object, $imageField = 'image')
158
+ {
159
+ $this->_imageProcessor = null;
160
+ $this->_image = $object->getDataUsingMethod($imageField);
161
+ if (!$this->_image) {
162
+ $this->_image = '/'.$this->_placeholder;
163
+ }
164
+ $this->_width = null;
165
+ $this->_height = null;
166
+ $this->_scheduledResize = false;
167
+ $this->_resized = false;
168
+ $this->_adaptiveResize = 'center';
169
+
170
+ try {
171
+ $this->_getImageProcessor()->open($this->getImageBaseDir().$this->_image);
172
+ } catch (Exception $e) {
173
+ $this->_openError = $e->getMessage();
174
+ try {
175
+ $this->_getImageProcessor()->open(Mage::getDesign()->getSkinUrl($this->_placeholder));
176
+ $this->_image = '/'.$this->_placeholder;
177
+ } catch(Exception $e) {
178
+ $this->_openError .= "\n".$e->getMessage();
179
+ $this->_image = null;
180
+ }
181
+ }
182
+ return $this;
183
+ }
184
+
185
+ /**
186
+ * get the image processor
187
+ *
188
+ * @access protected
189
+ * @return Varien_Image_Adapter_Gd2
190
+ * @author Ultimate Module Creator
191
+ */
192
+ protected function _getImageProcessor()
193
+ {
194
+ if (is_null($this->_imageProcessor)) {
195
+ $this->_imageProcessor = Varien_Image_Adapter::factory('GD2');
196
+ $this->_imageProcessor->keepFrame($this->_keepFrame);
197
+ $this->_imageProcessor->keepAspectRatio($this->_keepAspectRatio);
198
+ $this->_imageProcessor->constrainOnly($this->_constrainOnly);
199
+ }
200
+ return $this->_imageProcessor;
201
+ }
202
+
203
+ /**
204
+ * Get/set keepAspectRatio
205
+ *
206
+ * @access public
207
+ * @param bool $value
208
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
209
+ * @author Ultimate Module Creator
210
+ */
211
+ public function keepAspectRatio($value = null)
212
+ {
213
+ if (null !== $value) {
214
+ $this->_getImageProcessor()->keepAspectRatio($value);
215
+ return $this;
216
+ } else {
217
+ return $this->_getImageProcessor()->keepAspectRatio();
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Get/set keepFrame
223
+ *
224
+ * @access public
225
+ * @param bool $value
226
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
227
+ * @author Ultimate Module Creator
228
+ */
229
+ public function keepFrame($value = null)
230
+ {
231
+ if (null !== $value) {
232
+ $this->_getImageProcessor()->keepFrame($value);
233
+ return $this;
234
+ } else {
235
+ return $this->_getImageProcessor()->keepFrame();
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Get/set keepTransparency
241
+ *
242
+ * @access public
243
+ * @param bool $value
244
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
245
+ * @author Ultimate Module Creator
246
+ */
247
+ public function keepTransparency($value = null)
248
+ {
249
+ if (null !== $value) {
250
+ $this->_getImageProcessor()->keepTransparency($value);
251
+ return $this;
252
+ } else {
253
+ return $this->_getImageProcessor()->keepTransparency();
254
+ }
255
+ }
256
+
257
+ /**
258
+ * Get/set adaptiveResize
259
+ *
260
+ * @access public
261
+ * @param bool|string $value
262
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
263
+ * https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
264
+ * @author Ultimate Module Creator
265
+ */
266
+ public function adaptiveResize($value = null)
267
+ {
268
+ if (null !== $value) {
269
+ $this->_adaptiveResize = $value;
270
+ if ($value) {
271
+ $this->keepFrame(false);
272
+ }
273
+ return $this;
274
+ } else {
275
+ return $this->_adaptiveResize;
276
+ }
277
+ }
278
+
279
+ /**
280
+ * Get/set constrainOnly
281
+ *
282
+ * @access public
283
+ * @param bool $value
284
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
285
+ * @author Ultimate Module Creator
286
+ */
287
+ public function constrainOnly($value = null)
288
+ {
289
+ if (null !== $value) {
290
+ $this->_getImageProcessor()->constrainOnly($value);
291
+ return $this;
292
+ } else {
293
+ return $this->_getImageProcessor()->constrainOnly();
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Get/set quality, values in percentage from 0 to 100
299
+ *
300
+ * @access public
301
+ * @param int $value
302
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
303
+ * @author Ultimate Module Creator
304
+ */
305
+ public function quality($value = null)
306
+ {
307
+ if (null !== $value) {
308
+ $this->_getImageProcessor()->quality($value);
309
+ return $this;
310
+ } else {
311
+ return $this->_getImageProcessor()->quality();
312
+ }
313
+ }
314
+
315
+ /**
316
+ * Get/set keepBackgroundColor
317
+ *
318
+ * @access public
319
+ * @param array $value
320
+ * @return mixed(bool|BroSolutions_CustomBackground_Helper_Image_Abstract)
321
+ * @author Ultimate Module Creator
322
+ */
323
+ public function backgroundColor($value = null)
324
+ {
325
+ if (null !== $value) {
326
+ $this->_getImageProcessor()-> backgroundColor($value);
327
+ return $this;
328
+ } else {
329
+ return $this->_getImageProcessor()-> backgroundColor();
330
+ }
331
+ }
332
+
333
+ /**
334
+ * resize image
335
+ *
336
+ * @access public
337
+ * @param int $width - defaults to null
338
+ * @param int $height - defaults to null
339
+ * @return BroSolutions_CustomBackground_Helper_Image_Abstract
340
+ * @author Ultimate Module Creator
341
+ */
342
+ public function resize($width = null, $height = null)
343
+ {
344
+ $this->_scheduledResize = true;
345
+ $this->_width = $width;
346
+ $this->_height = $height;
347
+ return $this;
348
+ }
349
+
350
+ /**
351
+ * get destination image prefix
352
+ *
353
+ * @access protected
354
+ * @return BroSolutions_CustomBackground_Helper_Image_Abstract
355
+ * @author Ultimate Module Creator
356
+ */
357
+ protected function _getDestinationImagePrefix()
358
+ {
359
+ if (!$this->_image) {
360
+ return $this;
361
+ }
362
+ $imageRealPath = "";
363
+ if ($this->_scheduledResize) {
364
+ $width = $this->_width;
365
+ $height = $this->_height;
366
+ $adaptive = $this->adaptiveResize();
367
+ $keepFrame = $this->keepFrame();
368
+ $keepAspectRatio= $this->keepAspectRatio();
369
+ $constrainOnly = $this->constrainOnly();
370
+ $imageRealPath = $width.'x'.$height;
371
+ $options = "";
372
+
373
+ if (!$keepAspectRatio) {
374
+ $imageRealPath .= '-exact';
375
+ } else {
376
+ if (!$keepFrame && $width && $height && ($adaptive !== false)) {
377
+ $adaptive = strtolower(trim($adaptive));
378
+ if (isset($this->_adaptiveResizePositions[$adaptive])) {
379
+ $imageRealPath .= '-'.$adaptive;
380
+ }
381
+ }
382
+ }
383
+ if ($keepFrame) {
384
+ $imageRealPath .= '-frame';
385
+ $_backgroundColor = $this->backgroundColor();
386
+ if ($_backgroundColor) {
387
+ $imageRealPath .= '-'.implode('-', $_backgroundColor);
388
+ }
389
+ }
390
+ if (!$constrainOnly) {
391
+ $imageRealPath .= '-zoom';
392
+ }
393
+ }
394
+ return $imageRealPath;
395
+ }
396
+
397
+ /**
398
+ * get image destination path
399
+ *
400
+ * @access protected
401
+ * @return string
402
+ * @author Ultimate Module Creator
403
+ */
404
+ protected function _getDestinationPath()
405
+ {
406
+ if (!$this->_image) {
407
+ return $this;
408
+ }
409
+ if ($this->_scheduledResize) {
410
+ return $this->getImageBaseDir().DS.$this->_resizeFolderName.DS.$this->_getDestinationImagePrefix().DS.$this->_image;
411
+ } else {
412
+ return $this->getImageBaseDir().DS.$this->_image;
413
+ }
414
+ }
415
+
416
+ /**
417
+ * get image url
418
+ *
419
+ * @access protected
420
+ * @return mixed (string|bool)
421
+ * @author Ultimate Module Creator
422
+ */
423
+ protected function _getImageUrl()
424
+ {
425
+ if (!$this->_image) {
426
+ return false;
427
+ }
428
+ if ($this->_scheduledResize) {
429
+ return $this->getImageBaseUrl().'/'.$this->_resizeFolderName.'/'.$this->_getDestinationImagePrefix().$this->_image;
430
+ } else {
431
+ return $this->getImageBaseUrl().$this->_image;
432
+ }
433
+ }
434
+
435
+ /**
436
+ * resize image
437
+ *
438
+ * @access protected
439
+ * @return BroSolutions_CustomBackground_Helper_Image_Abstract
440
+ * @author Ultimate Module Creator
441
+ */
442
+ protected function _doResize()
443
+ {
444
+ if (!$this->_image || !$this->_scheduledResize || $this->_resized) {
445
+ return $this;
446
+ }
447
+ $this->_resized = true; //mark as resized
448
+ $width = $this->_width;
449
+ $height = $this->_height;
450
+ $adaptive = $width && $height &&
451
+ $this->keepAspectRatio() && !$this->keepFrame() &&
452
+ ($this->adaptiveResize() !== false);
453
+ $adaptivePosition = false;
454
+ if ($adaptive) {
455
+ $adaptive = strtolower(trim($this->adaptiveResize()));
456
+ if (isset($this->_adaptiveResizePositions[$adaptive])) {
457
+ $adaptivePosition = $this->_adaptiveResizePositions[$adaptive];
458
+ }
459
+ }
460
+ $processor = $this->_getImageProcessor();
461
+
462
+ if (!$adaptivePosition) {
463
+ $processor->resize($width, $height);
464
+ return $this;
465
+ }
466
+ //make adaptive resize
467
+ //https://github.com/wearefarm/magento-adaptive-resize/blob/master/README.md
468
+ $currentRatio = $processor->getOriginalWidth() / $processor->getOriginalHeight();
469
+ $targetRatio = $width / $height;
470
+ if ($targetRatio > $currentRatio) {
471
+ $processor->resize($width, null);
472
+ } else {
473
+ $processor->resize(null, $height);
474
+ }
475
+ $diffWidth = $processor->getOriginalWidth() - $width;
476
+ $diffHeight = $processor->getOriginalHeight() - $height;
477
+ if ($diffWidth || $diffHeight) {
478
+ $processor->crop(
479
+ floor($diffHeight * $adaptivePosition[0]), //top rate
480
+ floor($diffWidth / 2),
481
+ ceil($diffWidth / 2),
482
+ ceil($diffHeight * $adaptivePosition[1]) //bottom rate
483
+ );
484
+ }
485
+ return $this;
486
+ }
487
+
488
+ /**
489
+ * to string - no need for cache expire because the image names will be different
490
+ *
491
+ * @access public
492
+ * @return string
493
+ * @author Ultimate Module Creator
494
+ */
495
+ public function __toString()
496
+ {
497
+ try {
498
+ if (!$this->_image) {
499
+ throw new Exception($this->_openError);
500
+ }
501
+ $imageRealPath = $this->_getDestinationPath();
502
+ if (!file_exists($imageRealPath)) {
503
+ $this->_doResize();
504
+ $this->_getImageProcessor()->save($imageRealPath);
505
+ }
506
+ return $this->_getImageUrl();
507
+ } catch (Exception $e) {
508
+ Mage::logException($e);
509
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFr0lEQVR42rWXaUxUZxSGZVOKpWBRCGrSijBgDG1dagaxVgNSUqhAqq1CqzVVksb+sdZU0hgbfhQ1riEoiHFns4qVEYWglEWgVaBQLXRYJKzCzCA7KCpvz7njHbgz4AXSkryZYea73/Oe5Tv3zhQABtGfGcmCZPk/yYIZEuYIuDnJgeRKcn8pj/9Q7rw3M5g1moFpJGVnVxe0Wi20Oh107e1of/wYj1kdHejo7AR/z+oS1d0tqLunx6AeVm+vifoHBsAMZo1lYKVWq0NzyyO0PGrFo9Y2tLZp0KYRDA2bMjamN6c3OGzSxGwvmWDGWAasSR9qde0EbiVwG4E10AxnQw/XQ1nDUAYZZ2QU9fX1gRnMGtMAASTwMUvBGoYyQFoClmkJ5A0QhOHSlEtTbQoeAewVRdGy+kZoYDwGCGSacmOwKVQK6+9H/yh68uSJvAGGCGBTuACur6pCXUICssPDcXfHDvy5dy8KIyLQdOkSmh8+FNI8YCwCs54+fSpvgCNkOJeiwwieHROD3KBP8CDyJ9QePYLq/fuhjoqCml7L9/yI236+yI+L40hZDJRocHBwXAZGjTztq00o+mYbKiIj8cf2cGT6rIJKqUTakiW44a1EwdYtKNm1C/lfboBq0xcMM9GzZ8/kDRDMBJ5FkWeHrkPJD7uQvsYb177egr/LyzndQhPmpqYi2c0Fv23aiPxt25AZHIi8kycnZ4CaS1rz2lpcXbEUhd9ux7VVSmSfO8d1NaSY36cGBSJzrT9uhYYia+PnyFy/Dul+K6FpbmaoQc+fP5c3wF0twtnM5d27cfPTAEFJYRskcH69vjkMBaEh1BtBuEX9kbJIgav+q5EW6Iu0PXsYatCLFy/kDfCR4j7g1PIxSwwm+PogJCo98c/9+1L41s24FxaCIh8f5K3xwdVlC3CeTkTCewqkBvjhSthnkzMgwvn9WS9PpH7kh3Pve4yE0+brURLsixJqxOIPvKHyWoicM2eEWscrZuPI3Dk4tciNoRLJGuCB0q0fMMJQOb5YgQMz7BHj5mQYJvE+3shdqkDpvHkonz8PqmUKZJ8+zQAh0ti3HbDPbAriFusNDA0NscZngKFC9C8n2sm1foh6wwqHZ9vgdnIyYlZ5QeVojd/p0r+szHHZxR5Z8fGGCCtKSxHnZI1ouuZsyMcMlkjWAEN79dELEV/4ficOzZmOE7TpPlcnpDrb4A5d9oDgv7ja42ZcrAHOgLggfyTMskbsXBukROyeeAkYKkbPHd9UX48DHjMRa0lAgmfQJXenmiPFfQauH4+RwH89fBgXXGyRTOaOLpiFlsbGic8BHi5i9GyAm+7yoYOIUdghiZbfmmqBC++8iWiaCyJcXVaG6ABfpNCaLDJ32s0OV+ga2oP3Eu+QvJ/8A8mA3oDkvLP7Q8H+OOVB9ba2QKHja8icb4vEBTNx0cMB11xex10q071pFjhPa47QWuojPs58P+H7Cov/HyLGcjkD7Fw0IElf0oH9OOjpiBvudihztEG1uRnqSGoylE3RH/N0wsWon4WHFY1Gg5aWFjQ1NaGhoRH19Q1QqVR3iPEWyVzOgJh+iQFWQ10dTuz8DvsCVuOY0gXRXvNxNMQfsfRZjVotwGtpfBcWFqKoqAjldM+oqKhguJr2X0iayjw5Axy9sYGRE01yvvk7vo4HGEeel5fHnwt1r6qqYngj7b1IbD45Ayb1Z4DUgHS48BqGcb055Tk5uUIfVVdXIyMjQ2tra7uC9p7OHHkDBB7bgGn0/Bmv5ej5QaaOSlRcXIyamhoB7uzs7Ef72jJjogaM6//K9HPH63Q6qKkPKisrkZ6e3kiRL2c4yUzWgPjDZCIGAEgM0C8qNsBwbrh3STZSoLyB5QR8Ve1HKwGv5x7gsz5E8AL+HSie9YkYsHx5Rr25FJOUF2kuyUoCkjUgNcGZsJ6kpolDZrz6F2ZUsalEFcbPAAAAAElFTkSuQmCC';
510
+ }
511
+ }
512
+ }
app/code/local/BroSolutions/CustomBackground/Model/Background.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background model
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Model_Background extends Mage_Core_Model_Abstract
25
+ {
26
+ /**
27
+ * Entity code.
28
+ * Can be used as part of method name for entity processing
29
+ */
30
+ const ENTITY = 'brosolutions_custombackground_background';
31
+ const CACHE_TAG = 'brosolutions_custombackground_background';
32
+
33
+ const TARGET_CMS = 1;
34
+ const TARGET_PRODUCT = 2;
35
+ const TARGET_CATEGORY = 3;
36
+ const TARGET_CUSTOMER = 4;
37
+ const TARGET_HOME = 5;
38
+ const TARGET_CHECKOUT = 6;
39
+ const TARGET_CART = 7;
40
+
41
+ /**
42
+ * Prefix of model events names
43
+ *
44
+ * @var string
45
+ */
46
+ protected $_eventPrefix = 'brosolutions_custombackground_background';
47
+
48
+ /**
49
+ * Parameter name in event
50
+ *
51
+ * @var string
52
+ */
53
+ protected $_eventObject = 'background';
54
+
55
+ /**
56
+ * constructor
57
+ *
58
+ * @access public
59
+ * @return void
60
+ * @author Ultimate Module Creator
61
+ */
62
+ public function _construct()
63
+ {
64
+ parent::_construct();
65
+ $this->_init('brosolutions_custombackground/background');
66
+ }
67
+
68
+ /**
69
+ * before save background
70
+ *
71
+ * @access protected
72
+ * @return BroSolutions_CustomBackground_Model_Background
73
+ * @author Ultimate Module Creator
74
+ */
75
+ protected function _beforeSave()
76
+ {
77
+ parent::_beforeSave();
78
+ $now = Mage::getSingleton('core/date')->gmtDate();
79
+ if ($this->isObjectNew()) {
80
+ $this->setCreatedAt($now);
81
+ }
82
+ $this->setUpdatedAt($now);
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * save background relation
88
+ *
89
+ * @access public
90
+ * @return BroSolutions_CustomBackground_Model_Background
91
+ * @author Ultimate Module Creator
92
+ */
93
+ protected function _afterSave()
94
+ {
95
+ return parent::_afterSave();
96
+ }
97
+
98
+ /**
99
+ * get default values
100
+ *
101
+ * @access public
102
+ * @return array
103
+ * @author Ultimate Module Creator
104
+ */
105
+ public function getDefaultValues()
106
+ {
107
+ $values = array();
108
+ $values['status'] = 1;
109
+ return $values;
110
+ }
111
+
112
+ /**
113
+ * get Object
114
+ *
115
+ * @access public
116
+ * @return array
117
+ * @author Ultimate Module Creator
118
+ */
119
+ public function getTargetId()
120
+ {
121
+ if (!$this->getData('target_id')) {
122
+ return explode(',', $this->getData('target_id'));
123
+ }
124
+ return $this->getData('target_id');
125
+ }
126
+ }
app/code/local/BroSolutions/CustomBackground/Model/Background/Attribute/Source/Targettype.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Admin source model for Type Of Object
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Model_Background_Attribute_Source_Targettype extends Mage_Eav_Model_Entity_Attribute_Source_Table
25
+ {
26
+ /**
27
+ * get possible values
28
+ *
29
+ * @access public
30
+ * @param bool $withEmpty
31
+ * @param bool $defaultValues
32
+ * @return array
33
+ * @author Ultimate Module Creator
34
+ */
35
+ public function getAllOptions($withEmpty = true, $defaultValues = false)
36
+ {
37
+ $options = array(
38
+ array(
39
+ 'label' => Mage::helper('brosolutions_custombackground')->__('CMS'),
40
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_CMS,
41
+ ),
42
+ array(
43
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Product View'),
44
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_PRODUCT,
45
+ ),
46
+ array(
47
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Category View'),
48
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_CATEGORY,
49
+ ),
50
+ array(
51
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Customer Cabinet'),
52
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_CUSTOMER,
53
+ ),
54
+ array(
55
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Home Page'),
56
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_HOME,
57
+ ),
58
+ array(
59
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Checkout'),
60
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_CHECKOUT,
61
+ ),
62
+ array(
63
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Cart'),
64
+ 'value' => BroSolutions_CustomBackground_Model_Background::TARGET_CART,
65
+ )
66
+ );
67
+ if ($withEmpty) {
68
+ array_unshift($options, array('label'=>'', 'value'=>''));
69
+ }
70
+ return $options;
71
+
72
+ }
73
+
74
+ /**
75
+ * get options as array
76
+ *
77
+ * @access public
78
+ * @param bool $withEmpty
79
+ * @return string
80
+ * @author Ultimate Module Creator
81
+ */
82
+ public function getOptionsArray($withEmpty = true)
83
+ {
84
+ $options = array();
85
+ foreach ($this->getAllOptions($withEmpty) as $option) {
86
+ $options[$option['value']] = $option['label'];
87
+ }
88
+ return $options;
89
+ }
90
+
91
+ /**
92
+ * get option text
93
+ *
94
+ * @access public
95
+ * @param mixed $value
96
+ * @return string
97
+ * @author Ultimate Module Creator
98
+ */
99
+ public function getOptionText($value)
100
+ {
101
+ $options = $this->getOptionsArray();
102
+ if (!is_array($value)) {
103
+ $value = explode(',', $value);
104
+ }
105
+ $texts = array();
106
+ foreach ($value as $v) {
107
+ if (isset($options[$v])) {
108
+ $texts[] = $options[$v];
109
+ }
110
+ }
111
+ return implode(', ', $texts);
112
+ }
113
+ }
app/code/local/BroSolutions/CustomBackground/Model/Resource/Background.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background resource model
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Model_Resource_Background extends Mage_Core_Model_Resource_Db_Abstract
25
+ {
26
+
27
+ /**
28
+ * constructor
29
+ *
30
+ * @access public
31
+ * @author Ultimate Module Creator
32
+ */
33
+ public function _construct()
34
+ {
35
+ $this->_init('brosolutions_custombackground/background', 'entity_id');
36
+ }
37
+
38
+ /**
39
+ * Get store ids to which specified item is assigned
40
+ *
41
+ * @access public
42
+ * @param int $backgroundId
43
+ * @return array
44
+ * @author Ultimate Module Creator
45
+ */
46
+ public function lookupStoreIds($backgroundId)
47
+ {
48
+ $adapter = $this->_getReadAdapter();
49
+ $select = $adapter->select()
50
+ ->from($this->getTable('brosolutions_custombackground/background_store'), 'store_id')
51
+ ->where('background_id = ?', (int)$backgroundId);
52
+ return $adapter->fetchCol($select);
53
+ }
54
+
55
+ /**
56
+ * Perform operations after object load
57
+ *
58
+ * @access public
59
+ * @param Mage_Core_Model_Abstract $object
60
+ * @return BroSolutions_CustomBackground_Model_Resource_Background
61
+ * @author Ultimate Module Creator
62
+ */
63
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
64
+ {
65
+ if ($object->getId()) {
66
+ $stores = $this->lookupStoreIds($object->getId());
67
+ $object->setData('store_id', $stores);
68
+ }
69
+ return parent::_afterLoad($object);
70
+ }
71
+
72
+ /**
73
+ * Retrieve select object for load object data
74
+ *
75
+ * @param string $field
76
+ * @param mixed $value
77
+ * @param BroSolutions_CustomBackground_Model_Background $object
78
+ * @return Zend_Db_Select
79
+ */
80
+ protected function _getLoadSelect($field, $value, $object)
81
+ {
82
+ $select = parent::_getLoadSelect($field, $value, $object);
83
+ if ($object->getStoreId()) {
84
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
85
+ $select->join(
86
+ array('custombackground_background_store' => $this->getTable('brosolutions_custombackground/background_store')),
87
+ $this->getMainTable() . '.entity_id = custombackground_background_store.background_id',
88
+ array()
89
+ )
90
+ ->where('custombackground_background_store.store_id IN (?)', $storeIds)
91
+ ->order('custombackground_background_store.store_id DESC')
92
+ ->limit(1);
93
+ }
94
+ return $select;
95
+ }
96
+
97
+ /**
98
+ * Assign background to store views
99
+ *
100
+ * @access protected
101
+ * @param Mage_Core_Model_Abstract $object
102
+ * @return BroSolutions_CustomBackground_Model_Resource_Background
103
+ * @author Ultimate Module Creator
104
+ */
105
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
106
+ {
107
+ $oldStores = $this->lookupStoreIds($object->getId());
108
+ $newStores = (array)$object->getStores();
109
+ if (empty($newStores)) {
110
+ $newStores = (array)$object->getStoreId();
111
+ }
112
+ $table = $this->getTable('brosolutions_custombackground/background_store');
113
+ $insert = array_diff($newStores, $oldStores);
114
+ $delete = array_diff($oldStores, $newStores);
115
+ if ($delete) {
116
+ $where = array(
117
+ 'background_id = ?' => (int) $object->getId(),
118
+ 'store_id IN (?)' => $delete
119
+ );
120
+ $this->_getWriteAdapter()->delete($table, $where);
121
+ }
122
+ if ($insert) {
123
+ $data = array();
124
+ foreach ($insert as $storeId) {
125
+ $data[] = array(
126
+ 'background_id' => (int) $object->getId(),
127
+ 'store_id' => (int) $storeId
128
+ );
129
+ }
130
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
131
+ }
132
+ return parent::_afterSave($object);
133
+ }
134
+ /**
135
+ * process multiple select fields
136
+ *
137
+ * @access protected
138
+ * @param Mage_Core_Model_Abstract $object
139
+ * @return BroSolutions_CustomBackground_Model_Resource_Background
140
+ * @author Ultimate Module Creator
141
+ */
142
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
143
+ {
144
+ $targetid = $object->getTargetId();
145
+ if (is_array($targetid)) {
146
+ $object->setTargetId(implode(',', $targetid));
147
+ }
148
+ return parent::_beforeSave($object);
149
+ }
150
+ }
app/code/local/BroSolutions/CustomBackground/Model/Resource/Background/Collection.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background collection resource model
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Model_Resource_Background_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
25
+ {
26
+ protected $_joinedFields = array();
27
+
28
+ /**
29
+ * constructor
30
+ *
31
+ * @access public
32
+ * @return void
33
+ * @author Ultimate Module Creator
34
+ */
35
+ protected function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('brosolutions_custombackground/background');
39
+ $this->_map['fields']['store'] = 'store_table.store_id';
40
+ }
41
+
42
+ /**
43
+ * Add filter by store
44
+ *
45
+ * @access public
46
+ * @param int|Mage_Core_Model_Store $store
47
+ * @param bool $withAdmin
48
+ * @return BroSolutions_CustomBackground_Model_Resource_Background_Collection
49
+ * @author Ultimate Module Creator
50
+ */
51
+ public function addStoreFilter($store, $withAdmin = true)
52
+ {
53
+ if (!isset($this->_joinedFields['store'])) {
54
+ if ($store instanceof Mage_Core_Model_Store) {
55
+ $store = array($store->getId());
56
+ }
57
+ if (!is_array($store)) {
58
+ $store = array($store);
59
+ }
60
+ if ($withAdmin) {
61
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
62
+ }
63
+ $this->addFilter('store', array('in' => $store), 'public');
64
+ $this->_joinedFields['store'] = true;
65
+ }
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Join store relation table if there is store filter
71
+ *
72
+ * @access protected
73
+ * @return BroSolutions_CustomBackground_Model_Resource_Background_Collection
74
+ * @author Ultimate Module Creator
75
+ */
76
+ protected function _renderFiltersBefore()
77
+ {
78
+ if ($this->getFilter('store')) {
79
+ $this->getSelect()->join(
80
+ array('store_table' => $this->getTable('brosolutions_custombackground/background_store')),
81
+ 'main_table.entity_id = store_table.background_id',
82
+ array()
83
+ )
84
+ ->group('main_table.entity_id');
85
+ /*
86
+ * Allow analytic functions usage because of one field grouping
87
+ */
88
+ $this->_useAnalyticFunction = true;
89
+ }
90
+ return parent::_renderFiltersBefore();
91
+ }
92
+
93
+ /**
94
+ * get backgrounds as array
95
+ *
96
+ * @access protected
97
+ * @param string $valueField
98
+ * @param string $labelField
99
+ * @param array $additional
100
+ * @return array
101
+ * @author Ultimate Module Creator
102
+ */
103
+ protected function _toOptionArray($valueField='entity_id', $labelField='name', $additional=array())
104
+ {
105
+ return parent::_toOptionArray($valueField, $labelField, $additional);
106
+ }
107
+
108
+ /**
109
+ * get options hash
110
+ *
111
+ * @access protected
112
+ * @param string $valueField
113
+ * @param string $labelField
114
+ * @return array
115
+ * @author Ultimate Module Creator
116
+ */
117
+ protected function _toOptionHash($valueField='entity_id', $labelField='name')
118
+ {
119
+ return parent::_toOptionHash($valueField, $labelField);
120
+ }
121
+
122
+ /**
123
+ * Get SQL for get record count.
124
+ * Extra GROUP BY strip added.
125
+ *
126
+ * @access public
127
+ * @return Varien_Db_Select
128
+ * @author Ultimate Module Creator
129
+ */
130
+ public function getSelectCountSql()
131
+ {
132
+ $countSelect = parent::getSelectCountSql();
133
+ $countSelect->reset(Zend_Db_Select::GROUP);
134
+ return $countSelect;
135
+ }
136
+ }
app/code/local/BroSolutions/CustomBackground/Model/Resource/Setup.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * CustomBackground setup
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
25
+ {
26
+ }
app/code/local/BroSolutions/CustomBackground/controllers/Adminhtml/Custombackground/BackgroundController.php ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background admin controller
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_Adminhtml_Custombackground_BackgroundController extends BroSolutions_CustomBackground_Controller_Adminhtml_CustomBackground
25
+ {
26
+ /**
27
+ * init the background
28
+ *
29
+ * @access protected
30
+ * @return BroSolutions_CustomBackground_Model_Background
31
+ */
32
+ protected function _initBackground()
33
+ {
34
+ $backgroundId = (int) $this->getRequest()->getParam('id');
35
+ $background = Mage::getModel('brosolutions_custombackground/background');
36
+ if ($backgroundId) {
37
+ $background->load($backgroundId);
38
+ }
39
+ Mage::register('current_background', $background);
40
+ return $background;
41
+ }
42
+
43
+ /**
44
+ * default action
45
+ *
46
+ * @access public
47
+ * @return void
48
+ * @author Ultimate Module Creator
49
+ */
50
+ public function indexAction()
51
+ {
52
+ $this->loadLayout();
53
+ $this->_title(Mage::helper('brosolutions_custombackground')->__('Background Management'))
54
+ ->_title(Mage::helper('brosolutions_custombackground')->__('Backgrounds'));
55
+ $this->renderLayout();
56
+ }
57
+
58
+ /**
59
+ * grid action
60
+ *
61
+ * @access public
62
+ * @return void
63
+ * @author Ultimate Module Creator
64
+ */
65
+ public function gridAction()
66
+ {
67
+ $this->loadLayout()->renderLayout();
68
+ }
69
+
70
+ /**
71
+ * edit background - action
72
+ *
73
+ * @access public
74
+ * @return void
75
+ * @author Ultimate Module Creator
76
+ */
77
+ public function editAction()
78
+ {
79
+ $backgroundId = $this->getRequest()->getParam('id');
80
+ $background = $this->_initBackground();
81
+ if ($backgroundId && !$background->getId()) {
82
+ $this->_getSession()->addError(
83
+ Mage::helper('brosolutions_custombackground')->__('This background no longer exists.')
84
+ );
85
+ $this->_redirect('*/*/');
86
+ return;
87
+ }
88
+ $data = Mage::getSingleton('adminhtml/session')->getBackgroundData(true);
89
+ if (!empty($data)) {
90
+ $background->setData($data);
91
+ }
92
+ Mage::register('background_data', $background);
93
+ $this->loadLayout();
94
+ $this->_title(Mage::helper('brosolutions_custombackground')->__('Background Management'))
95
+ ->_title(Mage::helper('brosolutions_custombackground')->__('Backgrounds'));
96
+ if ($background->getId()) {
97
+ $this->_title($background->getName());
98
+ } else {
99
+ $this->_title(Mage::helper('brosolutions_custombackground')->__('Add background'));
100
+ }
101
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
102
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
103
+ }
104
+ $this->renderLayout();
105
+ }
106
+
107
+ /**
108
+ * new background action
109
+ *
110
+ * @access public
111
+ * @return void
112
+ * @author Ultimate Module Creator
113
+ */
114
+ public function newAction()
115
+ {
116
+ $this->_forward('edit');
117
+ }
118
+
119
+ /**
120
+ * save background - action
121
+ *
122
+ * @access public
123
+ * @return void
124
+ * @author Ultimate Module Creator
125
+ */
126
+ public function saveAction()
127
+ {
128
+ if ($data = $this->getRequest()->getPost('background')) {
129
+ try {
130
+ $background = $this->_initBackground();
131
+ $background->addData($data);
132
+ $backgroundName = $this->_uploadAndGetName(
133
+ 'background',
134
+ Mage::helper('brosolutions_custombackground/background_image')->getImageBaseDir(),
135
+ $data
136
+ );
137
+ $background->setData('background', $backgroundName);
138
+ $background->save();
139
+ Mage::getSingleton('adminhtml/session')->addSuccess(
140
+ Mage::helper('brosolutions_custombackground')->__('Background was successfully saved')
141
+ );
142
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
143
+ if ($this->getRequest()->getParam('back')) {
144
+ $this->_redirect('*/*/edit', array('id' => $background->getId()));
145
+ return;
146
+ }
147
+ $this->_redirect('*/*/');
148
+ return;
149
+ } catch (Mage_Core_Exception $e) {
150
+ if (isset($data['background']['value'])) {
151
+ $data['background'] = $data['background']['value'];
152
+ }
153
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
154
+ Mage::getSingleton('adminhtml/session')->setBackgroundData($data);
155
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
156
+ return;
157
+ } catch (Exception $e) {
158
+ Mage::logException($e);
159
+ if (isset($data['background']['value'])) {
160
+ $data['background'] = $data['background']['value'];
161
+ }
162
+ Mage::getSingleton('adminhtml/session')->addError(
163
+ Mage::helper('brosolutions_custombackground')->__('There was a problem saving the background.')
164
+ );
165
+ Mage::getSingleton('adminhtml/session')->setBackgroundData($data);
166
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
167
+ return;
168
+ }
169
+ }
170
+ Mage::getSingleton('adminhtml/session')->addError(
171
+ Mage::helper('brosolutions_custombackground')->__('Unable to find background to save.')
172
+ );
173
+ $this->_redirect('*/*/');
174
+ }
175
+
176
+ /**
177
+ * delete background - action
178
+ *
179
+ * @access public
180
+ * @return void
181
+ * @author Ultimate Module Creator
182
+ */
183
+ public function deleteAction()
184
+ {
185
+ if ( $this->getRequest()->getParam('id') > 0) {
186
+ try {
187
+ $background = Mage::getModel('brosolutions_custombackground/background');
188
+ $background->setId($this->getRequest()->getParam('id'))->delete();
189
+ Mage::getSingleton('adminhtml/session')->addSuccess(
190
+ Mage::helper('brosolutions_custombackground')->__('Background was successfully deleted.')
191
+ );
192
+ $this->_redirect('*/*/');
193
+ return;
194
+ } catch (Mage_Core_Exception $e) {
195
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
196
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
197
+ } catch (Exception $e) {
198
+ Mage::getSingleton('adminhtml/session')->addError(
199
+ Mage::helper('brosolutions_custombackground')->__('There was an error deleting background.')
200
+ );
201
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
202
+ Mage::logException($e);
203
+ return;
204
+ }
205
+ }
206
+ Mage::getSingleton('adminhtml/session')->addError(
207
+ Mage::helper('brosolutions_custombackground')->__('Could not find background to delete.')
208
+ );
209
+ $this->_redirect('*/*/');
210
+ }
211
+
212
+ /**
213
+ * mass delete background - action
214
+ *
215
+ * @access public
216
+ * @return void
217
+ * @author Ultimate Module Creator
218
+ */
219
+ public function massDeleteAction()
220
+ {
221
+ $backgroundIds = $this->getRequest()->getParam('background');
222
+ if (!is_array($backgroundIds)) {
223
+ Mage::getSingleton('adminhtml/session')->addError(
224
+ Mage::helper('brosolutions_custombackground')->__('Please select backgrounds to delete.')
225
+ );
226
+ } else {
227
+ try {
228
+ foreach ($backgroundIds as $backgroundId) {
229
+ $background = Mage::getModel('brosolutions_custombackground/background');
230
+ $background->setId($backgroundId)->delete();
231
+ }
232
+ Mage::getSingleton('adminhtml/session')->addSuccess(
233
+ Mage::helper('brosolutions_custombackground')->__('Total of %d backgrounds were successfully deleted.', count($backgroundIds))
234
+ );
235
+ } catch (Mage_Core_Exception $e) {
236
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
237
+ } catch (Exception $e) {
238
+ Mage::getSingleton('adminhtml/session')->addError(
239
+ Mage::helper('brosolutions_custombackground')->__('There was an error deleting backgrounds.')
240
+ );
241
+ Mage::logException($e);
242
+ }
243
+ }
244
+ $this->_redirect('*/*/index');
245
+ }
246
+
247
+ /**
248
+ * mass status change - action
249
+ *
250
+ * @access public
251
+ * @return void
252
+ * @author Ultimate Module Creator
253
+ */
254
+ public function massStatusAction()
255
+ {
256
+ $backgroundIds = $this->getRequest()->getParam('background');
257
+ if (!is_array($backgroundIds)) {
258
+ Mage::getSingleton('adminhtml/session')->addError(
259
+ Mage::helper('brosolutions_custombackground')->__('Please select backgrounds.')
260
+ );
261
+ } else {
262
+ try {
263
+ foreach ($backgroundIds as $backgroundId) {
264
+ $background = Mage::getSingleton('brosolutions_custombackground/background')->load($backgroundId)
265
+ ->setStatus($this->getRequest()->getParam('status'))
266
+ ->setIsMassupdate(true)
267
+ ->save();
268
+ }
269
+ $this->_getSession()->addSuccess(
270
+ $this->__('Total of %d backgrounds were successfully updated.', count($backgroundIds))
271
+ );
272
+ } catch (Mage_Core_Exception $e) {
273
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
274
+ } catch (Exception $e) {
275
+ Mage::getSingleton('adminhtml/session')->addError(
276
+ Mage::helper('brosolutions_custombackground')->__('There was an error updating backgrounds.')
277
+ );
278
+ Mage::logException($e);
279
+ }
280
+ }
281
+ $this->_redirect('*/*/index');
282
+ }
283
+
284
+ /**
285
+ * mass Type Of Object change - action
286
+ *
287
+ * @access public
288
+ * @return void
289
+ * @author Ultimate Module Creator
290
+ */
291
+ public function massTargetTypeAction()
292
+ {
293
+ $backgroundIds = $this->getRequest()->getParam('background');
294
+ if (!is_array($backgroundIds)) {
295
+ Mage::getSingleton('adminhtml/session')->addError(
296
+ Mage::helper('brosolutions_custombackground')->__('Please select backgrounds.')
297
+ );
298
+ } else {
299
+ try {
300
+ foreach ($backgroundIds as $backgroundId) {
301
+ $background = Mage::getSingleton('brosolutions_custombackground/background')->load($backgroundId)
302
+ ->setTargetType($this->getRequest()->getParam('flag_target_type'))
303
+ ->setIsMassupdate(true)
304
+ ->save();
305
+ }
306
+ $this->_getSession()->addSuccess(
307
+ $this->__('Total of %d backgrounds were successfully updated.', count($backgroundIds))
308
+ );
309
+ } catch (Mage_Core_Exception $e) {
310
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
311
+ } catch (Exception $e) {
312
+ Mage::getSingleton('adminhtml/session')->addError(
313
+ Mage::helper('brosolutions_custombackground')->__('There was an error updating backgrounds.')
314
+ );
315
+ Mage::logException($e);
316
+ }
317
+ }
318
+ $this->_redirect('*/*/index');
319
+ }
320
+
321
+ /**
322
+ * mass Repeat-X change - action
323
+ *
324
+ * @access public
325
+ * @return void
326
+ * @author Ultimate Module Creator
327
+ */
328
+ public function massRepeatXAction()
329
+ {
330
+ $backgroundIds = $this->getRequest()->getParam('background');
331
+ if (!is_array($backgroundIds)) {
332
+ Mage::getSingleton('adminhtml/session')->addError(
333
+ Mage::helper('brosolutions_custombackground')->__('Please select backgrounds.')
334
+ );
335
+ } else {
336
+ try {
337
+ foreach ($backgroundIds as $backgroundId) {
338
+ $background = Mage::getSingleton('brosolutions_custombackground/background')->load($backgroundId)
339
+ ->setRepeatX($this->getRequest()->getParam('flag_repeat_x'))
340
+ ->setIsMassupdate(true)
341
+ ->save();
342
+ }
343
+ $this->_getSession()->addSuccess(
344
+ $this->__('Total of %d backgrounds were successfully updated.', count($backgroundIds))
345
+ );
346
+ } catch (Mage_Core_Exception $e) {
347
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
348
+ } catch (Exception $e) {
349
+ Mage::getSingleton('adminhtml/session')->addError(
350
+ Mage::helper('brosolutions_custombackground')->__('There was an error updating backgrounds.')
351
+ );
352
+ Mage::logException($e);
353
+ }
354
+ }
355
+ $this->_redirect('*/*/index');
356
+ }
357
+
358
+ /**
359
+ * mass Repeat-Y change - action
360
+ *
361
+ * @access public
362
+ * @return void
363
+ * @author Ultimate Module Creator
364
+ */
365
+ public function massRepeatYAction()
366
+ {
367
+ $backgroundIds = $this->getRequest()->getParam('background');
368
+ if (!is_array($backgroundIds)) {
369
+ Mage::getSingleton('adminhtml/session')->addError(
370
+ Mage::helper('brosolutions_custombackground')->__('Please select backgrounds.')
371
+ );
372
+ } else {
373
+ try {
374
+ foreach ($backgroundIds as $backgroundId) {
375
+ $background = Mage::getSingleton('brosolutions_custombackground/background')->load($backgroundId)
376
+ ->setRepeatY($this->getRequest()->getParam('flag_repeat_y'))
377
+ ->setIsMassupdate(true)
378
+ ->save();
379
+ }
380
+ $this->_getSession()->addSuccess(
381
+ $this->__('Total of %d backgrounds were successfully updated.', count($backgroundIds))
382
+ );
383
+ } catch (Mage_Core_Exception $e) {
384
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
385
+ } catch (Exception $e) {
386
+ Mage::getSingleton('adminhtml/session')->addError(
387
+ Mage::helper('brosolutions_custombackground')->__('There was an error updating backgrounds.')
388
+ );
389
+ Mage::logException($e);
390
+ }
391
+ }
392
+ $this->_redirect('*/*/index');
393
+ }
394
+
395
+ /**
396
+ * export as csv - action
397
+ *
398
+ * @access public
399
+ * @return void
400
+ * @author Ultimate Module Creator
401
+ */
402
+ public function exportCsvAction()
403
+ {
404
+ $fileName = 'background.csv';
405
+ $content = $this->getLayout()->createBlock('brosolutions_custombackground/adminhtml_background_grid')
406
+ ->getCsv();
407
+ $this->_prepareDownloadResponse($fileName, $content);
408
+ }
409
+
410
+ /**
411
+ * export as MsExcel - action
412
+ *
413
+ * @access public
414
+ * @return void
415
+ * @author Ultimate Module Creator
416
+ */
417
+ public function exportExcelAction()
418
+ {
419
+ $fileName = 'background.xls';
420
+ $content = $this->getLayout()->createBlock('brosolutions_custombackground/adminhtml_background_grid')
421
+ ->getExcelFile();
422
+ $this->_prepareDownloadResponse($fileName, $content);
423
+ }
424
+
425
+ /**
426
+ * export as xml - action
427
+ *
428
+ * @access public
429
+ * @return void
430
+ * @author Ultimate Module Creator
431
+ */
432
+ public function exportXmlAction()
433
+ {
434
+ $fileName = 'background.xml';
435
+ $content = $this->getLayout()->createBlock('brosolutions_custombackground/adminhtml_background_grid')
436
+ ->getXml();
437
+ $this->_prepareDownloadResponse($fileName, $content);
438
+ }
439
+
440
+ public function getTargetAction()
441
+ {
442
+ $type = $this->getRequest()->getParam('type');
443
+ $options = Mage::helper('brosolutions_custombackground')->getObjectsByType($type);
444
+ $form = new Varien_Data_Form();
445
+ $form->setHtmlIdPrefix('background_');
446
+ $form->setFieldNameSuffix('background');
447
+
448
+ if($options){
449
+ $config = array(
450
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Object'),
451
+ 'name' => 'target_id',
452
+ 'required' => true,
453
+ 'class' => 'required-entry',
454
+ 'values' => $options,
455
+ );
456
+ $element = new Varien_Data_Form_Element_Multiselect($config);
457
+ } else {
458
+ $config = array(
459
+ 'label' => Mage::helper('brosolutions_custombackground')->__('Object'),
460
+ 'name' => 'target_id',
461
+ 'required' => true,
462
+ 'class' => 'required-entry',
463
+ );
464
+ $element = new Varien_Data_Form_Element_Hidden($config);
465
+ }
466
+
467
+ $element->setId('target_id');
468
+ $element->setForm($form);
469
+
470
+ $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_element');
471
+ $element->setRenderer($renderer);
472
+
473
+ $this->getResponse()->setBody($element->getElementHtml());
474
+ }
475
+
476
+
477
+ /**
478
+ * Check if admin has permissions to visit related pages
479
+ *
480
+ * @access protected
481
+ * @return boolean
482
+ * @author Ultimate Module Creator
483
+ */
484
+ protected function _isAllowed()
485
+ {
486
+ return Mage::getSingleton('admin/session')->isAllowed('system/brosolutions_custombackground/background');
487
+ }
488
+ }
app/code/local/BroSolutions/CustomBackground/controllers/BackgroundController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * Background front contrller
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ class BroSolutions_CustomBackground_BackgroundController extends Mage_Core_Controller_Front_Action
25
+ {
26
+ }
app/code/local/BroSolutions/CustomBackground/etc/adminhtml.xml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BroSolutions_CustomBackground extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category BroSolutions
14
+ * @package BroSolutions_CustomBackground
15
+ * @copyright Copyright (c) 2015
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <brosolutions_custombackground translate="title" module="brosolutions_custombackground">
29
+ <title>CustomBackground</title>
30
+ </brosolutions_custombackground>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ <system>
36
+ <children>
37
+ <brosolutions_custombackground translate="title" module="brosolutions_custombackground">
38
+ <title>Background Management</title>
39
+ <children>
40
+ <background translate="title" module="brosolutions_custombackground">
41
+ <title>Background</title>
42
+ <sort_order>0</sort_order>
43
+ </background>
44
+ </children>
45
+ </brosolutions_custombackground> </children>
46
+ </system>
47
+
48
+ </children>
49
+ </admin>
50
+ </resources>
51
+ </acl>
52
+ <menu>
53
+ <system>
54
+ <children>
55
+ <brosolutions_custombackground translate="title" module="brosolutions_custombackground">
56
+ <title>Background Management</title>
57
+ <sort_order>0</sort_order>
58
+ <children>
59
+ <background translate="title" module="brosolutions_custombackground">
60
+ <title>Background</title>
61
+ <action>adminhtml/custombackground_background</action>
62
+ <sort_order>0</sort_order>
63
+ </background>
64
+ </children>
65
+ </brosolutions_custombackground> </children>
66
+ </system>
67
+
68
+ </menu>
69
+ </config>
app/code/local/BroSolutions/CustomBackground/etc/config.xml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BroSolutions_CustomBackground extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category BroSolutions
14
+ * @package BroSolutions_CustomBackground
15
+ * @copyright Copyright (c) 2015
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <BroSolutions_CustomBackground>
22
+ <version>1.0.0</version>
23
+ </BroSolutions_CustomBackground>
24
+ </modules>
25
+ <global>
26
+ <resources>
27
+ <brosolutions_custombackground_setup>
28
+ <setup>
29
+ <module>BroSolutions_CustomBackground</module>
30
+ <class>BroSolutions_CustomBackground_Model_Resource_Setup</class>
31
+ </setup>
32
+ </brosolutions_custombackground_setup>
33
+ </resources>
34
+ <blocks>
35
+ <brosolutions_custombackground>
36
+ <class>BroSolutions_CustomBackground_Block</class>
37
+ </brosolutions_custombackground>
38
+ </blocks>
39
+ <helpers>
40
+ <brosolutions_custombackground>
41
+ <class>BroSolutions_CustomBackground_Helper</class>
42
+ </brosolutions_custombackground>
43
+ </helpers>
44
+ <models>
45
+ <brosolutions_custombackground>
46
+ <class>BroSolutions_CustomBackground_Model</class>
47
+ <resourceModel>brosolutions_custombackground_resource</resourceModel>
48
+ </brosolutions_custombackground>
49
+ <brosolutions_custombackground_resource>
50
+ <class>BroSolutions_CustomBackground_Model_Resource</class>
51
+ <entities>
52
+ <background>
53
+ <table>brosolutions_custombackground_background</table>
54
+ </background>
55
+ <background_store>
56
+ <table>brosolutions_custombackground_background_store</table>
57
+ </background_store>
58
+ </entities>
59
+ </brosolutions_custombackground_resource>
60
+ </models>
61
+ </global>
62
+ <adminhtml>
63
+ <layout>
64
+ <updates>
65
+ <brosolutions_custombackground>
66
+ <file>brosolutions_custombackground.xml</file>
67
+ </brosolutions_custombackground>
68
+ </updates>
69
+ </layout>
70
+ <translate>
71
+ <modules>
72
+ <BroSolutions_CustomBackground>
73
+ <files>
74
+ <default>BroSolutions_CustomBackground.csv</default>
75
+ </files>
76
+ </BroSolutions_CustomBackground>
77
+ </modules>
78
+ </translate>
79
+ </adminhtml>
80
+ <admin>
81
+ <routers>
82
+ <adminhtml>
83
+ <args>
84
+ <modules>
85
+ <BroSolutions_CustomBackground before="Mage_Adminhtml">BroSolutions_CustomBackground_Adminhtml</BroSolutions_CustomBackground>
86
+ </modules>
87
+ </args>
88
+ </adminhtml>
89
+ </routers>
90
+ </admin>
91
+ <frontend>
92
+ <routers>
93
+ <brosolutions_custombackground>
94
+ <use>standard</use>
95
+ <args>
96
+ <module>BroSolutions_CustomBackground</module>
97
+ <frontName>brosolutions_custombackground</frontName>
98
+ </args>
99
+ </brosolutions_custombackground>
100
+ </routers>
101
+ <layout>
102
+ <updates>
103
+ <brosolutions_custombackground>
104
+ <file>brosolutions_custombackground.xml</file>
105
+ </brosolutions_custombackground>
106
+ </updates>
107
+ </layout>
108
+ <translate>
109
+ <modules>
110
+ <BroSolutions_CustomBackground>
111
+ <files>
112
+ <default>BroSolutions_CustomBackground.csv</default>
113
+ </files>
114
+ </BroSolutions_CustomBackground>
115
+ </modules>
116
+ </translate>
117
+ </frontend>
118
+ <default>
119
+ <brosolutions_custombackground>
120
+ <background>
121
+ <breadcrumbs>1</breadcrumbs>
122
+ </background>
123
+ </brosolutions_custombackground>
124
+ </default>
125
+ </config>
app/code/local/BroSolutions/CustomBackground/etc/system.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BroSolutions_CustomBackground extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category BroSolutions
14
+ * @package BroSolutions_CustomBackground
15
+ * @copyright Copyright (c) 2015
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <tabs>
21
+ <brosolutions translate="label" module="brosolutions_custombackground">
22
+ <label>BroSolutions</label>
23
+ <sort_order>2000</sort_order>
24
+ </brosolutions>
25
+ </tabs>
26
+ <sections>
27
+ <brosolutions_custombackground translate="label" module="brosolutions_custombackground">
28
+ <class>separator-top</class>
29
+ <label>Background Management</label>
30
+ <tab>brosolutions</tab>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>100</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <groups>
37
+ <background translate="label" module="brosolutions_custombackground">
38
+ <label>Background</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>0</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <fields>
45
+ <breadcrumbs translate="label">
46
+ <label>Use Breadcrumbs</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </breadcrumbs>
54
+ </fields>
55
+ </background>
56
+ </groups>
57
+ </brosolutions_custombackground>
58
+ </sections>
59
+ </config>
app/code/local/BroSolutions/CustomBackground/sql/brosolutions_custombackground_setup/install-1.0.0.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BroSolutions_CustomBackground extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the MIT License
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/mit-license.php
11
+ *
12
+ * @category BroSolutions
13
+ * @package BroSolutions_CustomBackground
14
+ * @copyright Copyright (c) 2015
15
+ * @license http://opensource.org/licenses/mit-license.php MIT License
16
+ */
17
+ /**
18
+ * CustomBackground module install script
19
+ *
20
+ * @category BroSolutions
21
+ * @package BroSolutions_CustomBackground
22
+ * @author Alex (silyadev@gmail.com)
23
+ */
24
+ $this->startSetup();
25
+ $table = $this->getConnection()
26
+ ->newTable($this->getTable('brosolutions_custombackground/background'))
27
+ ->addColumn(
28
+ 'entity_id',
29
+ Varien_Db_Ddl_Table::TYPE_INTEGER,
30
+ null,
31
+ array(
32
+ 'identity' => true,
33
+ 'nullable' => false,
34
+ 'primary' => true,
35
+ ),
36
+ 'Background ID'
37
+ )
38
+ ->addColumn(
39
+ 'target_type',
40
+ Varien_Db_Ddl_Table::TYPE_INTEGER, null,
41
+ array(
42
+ 'nullable' => false,
43
+ ),
44
+ 'Type Of Object'
45
+ )
46
+ ->addColumn(
47
+ 'target_id',
48
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
49
+ array(
50
+ 'nullable' => false,
51
+ ),
52
+ 'Object'
53
+ )
54
+ ->addColumn(
55
+ 'target_element',
56
+ Varien_Db_Ddl_Table::TYPE_TEXT, '64k',
57
+ array(
58
+ 'nullable' => false,
59
+ ),
60
+ 'Object'
61
+ )
62
+ ->addColumn(
63
+ 'background',
64
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
65
+ array(),
66
+ 'Background'
67
+ )
68
+ ->addColumn(
69
+ 'color',
70
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
71
+ array(),
72
+ 'Background Color'
73
+ )
74
+ ->addColumn(
75
+ 'name',
76
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
77
+ array(
78
+ 'nullable' => false,
79
+ ),
80
+ 'Name'
81
+ )
82
+ ->addColumn(
83
+ 'repeat_x',
84
+ Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
85
+ array(),
86
+ 'Repeat-X'
87
+ )
88
+ ->addColumn(
89
+ 'repeat_y',
90
+ Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
91
+ array(),
92
+ 'Repeat-Y'
93
+ )
94
+ ->addColumn(
95
+ 'style',
96
+ Varien_Db_Ddl_Table::TYPE_TEXT, 255,
97
+ array(),
98
+ 'Additional CSS Styles'
99
+ )
100
+ ->addColumn(
101
+ 'status',
102
+ Varien_Db_Ddl_Table::TYPE_SMALLINT, null,
103
+ array(),
104
+ 'Enabled'
105
+ )
106
+ ->addColumn(
107
+ 'updated_at',
108
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
109
+ null,
110
+ array(),
111
+ 'Background Modification Time'
112
+ )
113
+ ->addColumn(
114
+ 'created_at',
115
+ Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
116
+ null,
117
+ array(),
118
+ 'Background Creation Time'
119
+ )
120
+ ->setComment('Background Table');
121
+ $this->getConnection()->createTable($table);
122
+ $table = $this->getConnection()
123
+ ->newTable($this->getTable('brosolutions_custombackground/background_store'))
124
+ ->addColumn(
125
+ 'background_id',
126
+ Varien_Db_Ddl_Table::TYPE_SMALLINT,
127
+ null,
128
+ array(
129
+ 'nullable' => false,
130
+ 'primary' => true,
131
+ ),
132
+ 'Background ID'
133
+ )
134
+ ->addColumn(
135
+ 'store_id',
136
+ Varien_Db_Ddl_Table::TYPE_SMALLINT,
137
+ null,
138
+ array(
139
+ 'unsigned' => true,
140
+ 'nullable' => false,
141
+ 'primary' => true,
142
+ ),
143
+ 'Store ID'
144
+ )
145
+ ->addIndex(
146
+ $this->getIdxName(
147
+ 'brosolutions_custombackground/background_store',
148
+ array('store_id')
149
+ ),
150
+ array('store_id')
151
+ )
152
+ ->addForeignKey(
153
+ $this->getFkName(
154
+ 'brosolutions_custombackground/background_store',
155
+ 'background_id',
156
+ 'brosolutions_custombackground/background',
157
+ 'entity_id'
158
+ ),
159
+ 'background_id',
160
+ $this->getTable('brosolutions_custombackground/background'),
161
+ 'entity_id',
162
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
163
+ Varien_Db_Ddl_Table::ACTION_CASCADE
164
+ )
165
+ ->addForeignKey(
166
+ $this->getFkName(
167
+ 'brosolutions_custombackground/background_store',
168
+ 'store_id',
169
+ 'core/store',
170
+ 'store_id'
171
+ ),
172
+ 'store_id',
173
+ $this->getTable('core/store'),
174
+ 'store_id',
175
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
176
+ Varien_Db_Ddl_Table::ACTION_CASCADE
177
+ )
178
+ ->setComment('Backgrounds To Store Linkage Table');
179
+ $this->getConnection()->createTable($table);
180
+ $this->endSetup();
app/design/adminhtml/default/default/layout/brosolutions_custombackground.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BroSolutions_CustomBackground extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category BroSolutions
14
+ * @package BroSolutions_CustomBackground
15
+ * @copyright Copyright (c) 2015
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <adminhtml_custombackground_background_index>
21
+ <reference name="menu">
22
+ <action method="setActive">
23
+ <menupath>system/brosolutions_custombackground/background</menupath>
24
+ </action>
25
+ </reference>
26
+ <reference name="content">
27
+ <block type="brosolutions_custombackground/adminhtml_background" name="background" />
28
+
29
+ </reference>
30
+ </adminhtml_custombackground_background_index>
31
+ <adminhtml_custombackground_background_grid>
32
+ <block type="core/text_list" name="root" output="toHtml">
33
+ <block type="brosolutions_custombackground/adminhtml_background_grid" name="background_grid"/>
34
+ </block>
35
+ </adminhtml_custombackground_background_grid>
36
+ <!-- Background add/edit action -->
37
+ <adminhtml_custombackground_background_edit>
38
+ <update handle="editor"/>
39
+ <reference name="head">
40
+ <action method="addItem"><type>js</type><name>jscolor/jscolor.js</name><params/><if/></action>
41
+ </reference>
42
+ <reference name="menu">
43
+ <action method="setActive">
44
+ <menupath>system/brosolutions_custombackground/background</menupath>
45
+ </action>
46
+ </reference>
47
+ <reference name="content">
48
+ <block type="brosolutions_custombackground/adminhtml_background_edit" name="background_edit"></block>
49
+ </reference>
50
+ <reference name="left">
51
+ <block type="brosolutions_custombackground/adminhtml_background_edit_tabs" name="background_tabs"></block>
52
+ </reference>
53
+ </adminhtml_custombackground_background_edit>
54
+
55
+ </layout>
app/design/frontend/base/default/layout/brosolutions_custombackground.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BroSolutions_CustomBackground extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category BroSolutions
14
+ * @package BroSolutions_CustomBackground
15
+ * @copyright Copyright (c) 2015
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <layout>
20
+ <default>
21
+ <reference name="before_body_end">
22
+ <block type="brosolutions_custombackground/background" template="brosolutions/custombackground/js.phtml" />
23
+ </reference>
24
+ </default>
25
+ </layout>
app/design/frontend/base/default/template/brosolutions/custombackground/js.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if($this->isBackgroundNeeded()): ?>
2
+ <script>
3
+ if($$('<?php echo $this->getTargetElement() ?>').length>0){
4
+ $$('<?php echo $this->getTargetElement() ?>').each(function(element){
5
+ <?php foreach($this->getStyleOptions() as $style => $value): ?>
6
+ element.setStyle({<?php echo $style ?>: '<?php echo $value ?>'});
7
+ <?php endforeach ?>
8
+ })
9
+ }
10
+ </script>
11
+ <?php endif ?>
app/etc/modules/BroSolutions_CustomBackground.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * BroSolutions_CustomBackground extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category BroSolutions
14
+ * @package BroSolutions_CustomBackground
15
+ * @copyright Copyright (c) 2015
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <BroSolutions_CustomBackground>
22
+ <active>true</active>
23
+ <codePool>local</codePool>
24
+ <depends>
25
+ <Mage_Core />
26
+ </depends>
27
+ </BroSolutions_CustomBackground>
28
+ </modules>
29
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>BroSolutions_CustomBackground</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Site Background Management</summary>
10
+ <description>Extension allows to easy manage body background styles for different Magento's pages</description>
11
+ <notes>- CMS, Product, Category, Home,Cart and Checkout pages management&#xD;
12
+ - Custom styles&#xD;
13
+ - Custom body selector </notes>
14
+ <authors><author><name>Alex</name><user>silyadev</user><email>silyadev@gmail.com</email></author></authors>
15
+ <date>2015-04-06</date>
16
+ <time>08:32:13</time>
17
+ <contents><target name="mageetc"><dir name="modules"><file name="BroSolutions_CustomBackground.xml" hash="fd8564f260811ab0cb216e34a4807a76"/></dir></target><target name="magelocal"><dir name="BroSolutions"><dir name="CustomBackground"><dir name="Block"><dir name="Adminhtml"><dir name="Background"><dir name="Edit"><file name="Form.php" hash="1955003427d97afdfec3f45e51c808f7"/><dir name="Tab"><file name="Form.php" hash="2b3924af370e3530a7dec18c48d19689"/><file name="Stores.php" hash="60044040bd04a2b4bd5306145b6f7651"/></dir><file name="Tabs.php" hash="e6812a295272d6a03bcbbf9e33609e3c"/></dir><file name="Edit.php" hash="8c564addf37ba36e3d9498b04adf931f"/><file name="Grid.php" hash="f65fe5ebd21f5d933f90a9ad0b9fb682"/><dir name="Helper"><file name="Image.php" hash="f3afd5a7c960be3c33ddd086a9a9ba78"/></dir></dir><file name="Background.php" hash="c083a98aaa0fc7c2079c4eebfaea33da"/></dir><file name="Background.php" hash="aff336520053dcf2c9dced34b11d9094"/></dir><dir name="Controller"><dir name="Adminhtml"><file name="CustomBackground.php" hash="2933b0b527c03bc5b779661cfc7ccdbd"/></dir></dir><dir name="Helper"><dir name="Background"><file name="Image.php" hash="107791f7a251e6b024b64e93d7501619"/></dir><file name="Background.php" hash="0991f4266b4557db46c96083816e52a3"/><file name="Data.php" hash="542e49c132a0cc29d42207c486425349"/><dir name="Image"><file name="Abstract.php" hash="a278ee6e7409925e9299637a3ae21479"/></dir></dir><dir name="Model"><dir name="Background"><dir name="Attribute"><dir name="Source"><file name="Targettype.php" hash="b1350e6ae472b58bdff8678afb35e545"/></dir></dir></dir><file name="Background.php" hash="3cb7b611bebe104da2d72605317f52b9"/><dir name="Resource"><dir name="Background"><file name="Collection.php" hash="869d62a6b4e9bd09b054265b6f550f08"/></dir><file name="Background.php" hash="2907f4af0ba1bbe133e11f19ffd44bc0"/><file name="Setup.php" hash="09d865248c0c43cdb5c6f228a55ed7c5"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Custombackground"><file name="BackgroundController.php" hash="aff8178595156ca09ec4709fdc28e3c4"/></dir></dir><file name="BackgroundController.php" hash="bcb4f0610443dd724635cd05402cb5cf"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c9433a846f876fa6d015b12b708cf48d"/><file name="config.xml" hash="42d46b9b47b8629e47ae16c8341bd037"/><file name="system.xml" hash="e6a62b5df45f988b14cb914d27124f52"/></dir><dir name="sql"><dir name="brosolutions_custombackground_setup"><file name="install-1.0.0.php" hash="fad4bd8841906063870cb4e5cfcabcde"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="brosolutions_custombackground.xml" hash="18e4cf56d18e01a17a01ac3c5a213a40"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="brosolutions_custombackground.xml" hash="c8c4e587c13f7190e6b81466d42e1041"/></dir><dir name="template"><dir name="brosolutions"><dir name="custombackground"><file name="js.phtml" hash="ae2a33ab4e8bd62d5a8835f56f3f855f"/></dir></dir></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>