Version Notes
1. Added new field "Custom Code" for Embeded Html/Flash Code.
2. Added feature that fixes native Magento bug with widgets ordering on page. Now to output widget before all - just put value "0" to the field "Sort Order".
Uploaded for Magento Connect 2.0
Download this release
Release Info
Developer | Magento Core Team |
Extension | Lanot_EasyBanner |
Version | 1.1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0.2 to 1.1.1.0
- app/code/community/Lanot/Core/Block/Adminhtml/Grid/Abstract.php +329 -0
- app/code/community/Lanot/Core/Controller/Adminhtml/AbstractController.php +334 -0
- app/code/community/Lanot/Core/Model/Item/Interface.php +37 -0
- app/code/community/Lanot/EasyBanner/Block/Adminhtml/Banner/Edit.php +8 -1
- app/code/community/Lanot/EasyBanner/Block/Adminhtml/Banner/Edit/Tab/Main.php +58 -14
- app/code/community/Lanot/EasyBanner/Block/Adminhtml/Category/Edit/Tab/Main.php +14 -2
- app/code/community/Lanot/EasyBanner/Block/Adminhtml/Grid/Abstract.php +3 -269
- app/code/community/Lanot/EasyBanner/Block/Adminhtml/Renderer/Banner.php +0 -1
- app/code/community/Lanot/EasyBanner/Block/Banner/Renderer/Custom.php +28 -0
- app/code/community/Lanot/EasyBanner/Block/Banner/Renderer/Flash.php +1 -1
- app/code/community/Lanot/EasyBanner/Controller/Adminhtml/AbstractController.php +1 -277
- app/code/community/Lanot/EasyBanner/Model/Banner.php +80 -6
- app/code/community/Lanot/EasyBanner/Model/Category.php +3 -1
- app/code/community/Lanot/EasyBanner/Model/Mysql4/Banner/Collection.php +1 -5
- app/code/community/Lanot/EasyBanner/Model/Widget/Instance.php +48 -0
- app/code/community/Lanot/EasyBanner/controllers/Adminhtml/BannerController.php +1 -1
- app/code/community/Lanot/EasyBanner/etc/config.xml +8 -1
- app/code/community/Lanot/EasyBanner/sql/lanot_easybanner_setup/mysql4-upgrade-1.0.1.0-1.1.0.0.php +31 -0
- app/design/adminhtml/default/default/template/lanot/easybanner/widget/form/renderer/fieldset.phtml +60 -0
- package.xml +10 -9
app/code/community/Lanot/Core/Block/Adminhtml/Grid/Abstract.php
ADDED
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Lanot
|
16 |
+
* @package Lanot_Core
|
17 |
+
* @copyright Copyright (c) 2012 Lanot
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* core grid abstract
|
23 |
+
*
|
24 |
+
* @author Lanot
|
25 |
+
*/
|
26 |
+
class Lanot_Core_Block_Adminhtml_Grid_Abstract
|
27 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
28 |
+
{
|
29 |
+
protected $_gridId = 'lanot_core_list_grid';
|
30 |
+
protected $_entityIdField = 'entity_id';
|
31 |
+
protected $_itemParam = 'entity_id';
|
32 |
+
protected $_formFieldName = 'entity';
|
33 |
+
protected $_columnPrefix = '';
|
34 |
+
protected $_checkboxFieldName = 'in_selected';
|
35 |
+
protected $_isTabGrid = false;
|
36 |
+
|
37 |
+
/** @var Mage_Core_Model_Abstract */
|
38 |
+
protected $_item = null;
|
39 |
+
protected $_selectedLinks = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Init Grid default properties
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
public function __construct()
|
46 |
+
{
|
47 |
+
parent::__construct();
|
48 |
+
|
49 |
+
$this->setId($this->_gridId);
|
50 |
+
$this->setDefaultSort('sort_order');
|
51 |
+
$this->setDefaultDir('ASC');
|
52 |
+
$this->setSaveParametersInSession(true);
|
53 |
+
$this->setUseAjax(true);
|
54 |
+
|
55 |
+
if ($this->isReadonly()) {
|
56 |
+
$this->setFilterVisibility(false);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
62 |
+
*/
|
63 |
+
protected function _prepareCollection()
|
64 |
+
{
|
65 |
+
$collection = $this->_getItemModel()->getCollection();
|
66 |
+
|
67 |
+
//filter colelction if it show in tab
|
68 |
+
if ($this->_isTabGrid && $this->isReadonly()) {
|
69 |
+
$valueIds = $this->_getSelectedLinks();
|
70 |
+
if (empty($valueIds)) {
|
71 |
+
$valueIds = array(0);
|
72 |
+
}
|
73 |
+
$collection->addFieldToFilter($this->_entityIdField, array('in' => $valueIds));
|
74 |
+
}
|
75 |
+
|
76 |
+
Mage::dispatchEvent('lanot_grid_prepare_collection', array('grid' => $this, 'collection' => $collection));
|
77 |
+
|
78 |
+
$this->setCollection($collection);
|
79 |
+
|
80 |
+
return parent::_prepareCollection();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param $row
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function getRowUrl($row)
|
88 |
+
{
|
89 |
+
return (!$this->_isTabGrid) ? $this->getUrl('*/*/edit', array('id' => $row->getId())) : '#';
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public function getGridUrl()
|
96 |
+
{
|
97 |
+
return (!$this->_isTabGrid) ?
|
98 |
+
$this->getUrl('*/*/grid', array('_current' => true)) :
|
99 |
+
$this->getUrl('*/*/ajaxgridonly', array('_current' => true));
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Prepare Grid columns
|
104 |
+
*
|
105 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
106 |
+
*/
|
107 |
+
protected function _prepareColumns()
|
108 |
+
{
|
109 |
+
if ($this->_isTabGrid) {
|
110 |
+
$this->addColumn('in_selected', array(
|
111 |
+
'header_css_class' => 'a-center',
|
112 |
+
'type' => 'checkbox',
|
113 |
+
'name' => 'in_selected',
|
114 |
+
'values' => $this->_getSelectedLinks(),
|
115 |
+
'align' => 'center',
|
116 |
+
'index' => $this->_entityIdField,
|
117 |
+
));
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->addColumn($this->_entityIdField, array(
|
121 |
+
'header' => $this->_getHelper()->__('ID'),
|
122 |
+
'index' => $this->_entityIdField,
|
123 |
+
'type' => 'number',
|
124 |
+
'width' => '50px',
|
125 |
+
));
|
126 |
+
|
127 |
+
$this->addColumn('title', array(
|
128 |
+
'header' => $this->_getHelper()->__('Title'),
|
129 |
+
'index' => 'title',
|
130 |
+
));
|
131 |
+
|
132 |
+
$this->addColumn('is_active', array(
|
133 |
+
'header' => $this->_getHelper()->__('Active'),
|
134 |
+
'index' => 'is_active',
|
135 |
+
'type' => 'options',
|
136 |
+
'options' => $this->_getItemModel()->getAvailableStatuses(),
|
137 |
+
'width' => '100px',
|
138 |
+
));
|
139 |
+
|
140 |
+
$this->addColumn('updated_at', array(
|
141 |
+
'header' => $this->_getHelper()->__('Updated'),
|
142 |
+
'index' => 'updated_at',
|
143 |
+
'width' => '150px',
|
144 |
+
));
|
145 |
+
|
146 |
+
if (!$this->_isTabGrid) {
|
147 |
+
$this->addColumn('action',
|
148 |
+
array(
|
149 |
+
'header' => $this->_getHelper()->__('Action'),
|
150 |
+
'width' => '70px',
|
151 |
+
'align' => 'center',
|
152 |
+
'type' => 'action',
|
153 |
+
'getter' => 'getId',
|
154 |
+
'actions' => array(
|
155 |
+
array(
|
156 |
+
'caption' => $this->_getHelper()->__('Edit'),
|
157 |
+
'url' => array('base' => '*/*/edit'),
|
158 |
+
'field' => 'id'
|
159 |
+
)
|
160 |
+
),
|
161 |
+
'filter' => false,
|
162 |
+
'sortable' => false,
|
163 |
+
'index' => 'banner',
|
164 |
+
));
|
165 |
+
}
|
166 |
+
|
167 |
+
Mage::dispatchEvent('lanot_grid_prepare_columns', array('grid' => $this));
|
168 |
+
|
169 |
+
return parent::_prepareColumns();
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
175 |
+
*/
|
176 |
+
protected function _prepareMassaction()
|
177 |
+
{
|
178 |
+
if (!$this->isMassActionAllowed()) {
|
179 |
+
return $this;
|
180 |
+
}
|
181 |
+
|
182 |
+
$this->setMassactionIdField($this->_entityIdField);
|
183 |
+
$this->getMassactionBlock()->setFormFieldName($this->_formFieldName);
|
184 |
+
|
185 |
+
$this->getMassactionBlock()->addItem('active_enable', array(
|
186 |
+
'label' => $this->_getHelper()->__('Enable'),
|
187 |
+
'url' => $this->getUrl('*/*/mass', array('type' => 'enable'))
|
188 |
+
));
|
189 |
+
|
190 |
+
$this->getMassactionBlock()->addItem('active_disable', array(
|
191 |
+
'label' => $this->_getHelper()->__('Disable'),
|
192 |
+
'url' => $this->getUrl('*/*/mass', array('type' => 'disable'))
|
193 |
+
));
|
194 |
+
|
195 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
196 |
+
'label' => $this->_getHelper()->__('Delete'),
|
197 |
+
'confirm' => $this->_getHelper()->__('Are you sure?'),
|
198 |
+
'url' => $this->getUrl('*/*/mass', array('type' => 'delete')),
|
199 |
+
));
|
200 |
+
|
201 |
+
Mage::dispatchEvent('lanot_grid_prepare_massaction', array('grid' => $this));
|
202 |
+
|
203 |
+
return $this;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Retrieve selected values
|
208 |
+
*
|
209 |
+
* @return array
|
210 |
+
*/
|
211 |
+
public function getSelectedLinks()
|
212 |
+
{
|
213 |
+
if (null === $this->_selectedLinks) {
|
214 |
+
$this->_selectedLinks = $this->_getItem()->getSelectedLinks();
|
215 |
+
}
|
216 |
+
return $this->_selectedLinks;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Retrieve selected values
|
221 |
+
*
|
222 |
+
* @return array
|
223 |
+
*/
|
224 |
+
protected function _getSelectedLinks()
|
225 |
+
{
|
226 |
+
return $this->getSelectedLinks();
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Add column to grid
|
231 |
+
*
|
232 |
+
* @param string $columnId
|
233 |
+
* @param array || Varien_Object $column
|
234 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
235 |
+
*/
|
236 |
+
public function addColumn($columnId, $column)
|
237 |
+
{
|
238 |
+
return parent::addColumn($this->_columnPrefix . $columnId, $column);
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
243 |
+
*/
|
244 |
+
protected function _getItem()
|
245 |
+
{
|
246 |
+
if ($this->_item !== null) {
|
247 |
+
return $this->_item;
|
248 |
+
}
|
249 |
+
|
250 |
+
$itemId = $this->getRequest()->getParam($this->_itemParam);
|
251 |
+
$this->_item = $this->_getItemModel();
|
252 |
+
if ($itemId) {
|
253 |
+
$this->_item->load($itemId);
|
254 |
+
}
|
255 |
+
return $this->_item;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* @param $column
|
260 |
+
* @return Lanot_Core_Block_Adminhtml_Grid_Abstract
|
261 |
+
*/
|
262 |
+
protected function _addColumnFilterToCollection($column)
|
263 |
+
{
|
264 |
+
// Set custom filter by selected values
|
265 |
+
if ($this->_isTabGrid && $column->getId() == $this->_checkboxFieldName) {
|
266 |
+
$valueIds = $this->_getSelectedLinks();
|
267 |
+
if (empty($valueIds)) {
|
268 |
+
$valueIds = 0;
|
269 |
+
}
|
270 |
+
|
271 |
+
if ($column->getFilter()->getValue()) {
|
272 |
+
$this->getCollection()->addFieldToFilter($this->_entityIdField, array('in' => $valueIds));
|
273 |
+
} else {
|
274 |
+
if($valueIds) {
|
275 |
+
$this->getCollection()->addFieldToFilter($this->_entityIdField, array('nin' => $valueIds));
|
276 |
+
}
|
277 |
+
}
|
278 |
+
} else {
|
279 |
+
parent::_addColumnFilterToCollection($column);
|
280 |
+
}
|
281 |
+
return $this;
|
282 |
+
}
|
283 |
+
|
284 |
+
//--------------------------- methods must be overwritten -----------------------------//
|
285 |
+
/**
|
286 |
+
* Checks when this block is readonly
|
287 |
+
*
|
288 |
+
* @return boolean
|
289 |
+
*/
|
290 |
+
public function isReadonly()
|
291 |
+
{
|
292 |
+
return false;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Checks when this block is not available
|
297 |
+
*
|
298 |
+
* @return boolean
|
299 |
+
*/
|
300 |
+
public function isMassActionAllowed()
|
301 |
+
{
|
302 |
+
return !$this->_isTabGrid;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* @return Mage_Core_Model_Abstract
|
307 |
+
*/
|
308 |
+
protected function _getItemModel()
|
309 |
+
{
|
310 |
+
return null;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* @return Mage_Core_Helper_Abstract
|
315 |
+
*/
|
316 |
+
protected function _getHelper()
|
317 |
+
{
|
318 |
+
return null;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* @return Mage_Core_Helper_Abstract
|
323 |
+
*/
|
324 |
+
protected function _getAclHelper()
|
325 |
+
{
|
326 |
+
return null;
|
327 |
+
}
|
328 |
+
//--------------------------- methods must be overwritten-----------------------------//
|
329 |
+
}
|
app/code/community/Lanot/Core/Controller/Adminhtml/AbstractController.php
ADDED
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Lanot
|
16 |
+
* @package Lanot_Core
|
17 |
+
* @copyright Copyright (c) 2012 Lanot
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* core controller abstract
|
23 |
+
*
|
24 |
+
* @author Lanot
|
25 |
+
*/
|
26 |
+
class Lanot_Core_Controller_Adminhtml_AbstractController
|
27 |
+
extends Mage_Adminhtml_Controller_Action
|
28 |
+
{
|
29 |
+
protected $_msgTitle = 'Items';
|
30 |
+
protected $_msgHeader = 'Items';
|
31 |
+
protected $_msgItemDoesNotExist = 'Item does not exist.';
|
32 |
+
protected $_msgItemNotFound = 'Unable to find an item. #%s';
|
33 |
+
protected $_msgItemEdit = 'Edit Item';
|
34 |
+
protected $_msgItemNew = 'New Item';
|
35 |
+
protected $_msgItemSaved = 'The item has been saved.';
|
36 |
+
protected $_msgItemDeleted = 'The item has been deleted.';
|
37 |
+
protected $_msgError = 'An error occurred while edit the item. %s';
|
38 |
+
protected $_msgErrorItems = 'An error occurred while edit the items. %s';
|
39 |
+
protected $_msgItems = 'The items %s has been';
|
40 |
+
|
41 |
+
protected $_menuActive = null;
|
42 |
+
protected $_aclSection = null;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Check the permission to run it
|
46 |
+
*
|
47 |
+
* @return boolean
|
48 |
+
*/
|
49 |
+
protected function _isAllowed()
|
50 |
+
{
|
51 |
+
switch ($this->getRequest()->getActionName()) {
|
52 |
+
case 'new':
|
53 |
+
case 'edit':
|
54 |
+
case 'save':
|
55 |
+
case 'mass':
|
56 |
+
return $this->_getAclHelper()->isActionAllowed($this->_aclSection . '/save');
|
57 |
+
break;
|
58 |
+
case 'delete':
|
59 |
+
return $this->_getAclHelper()->isActionAllowed($this->_aclSection . '/delete');
|
60 |
+
break;
|
61 |
+
default:
|
62 |
+
return $this->_getAclHelper()->isActionAllowed($this->_aclSection);
|
63 |
+
break;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Init actions
|
69 |
+
*
|
70 |
+
* @return Lanot_Core_Controller_Adminhtml_AbstractController
|
71 |
+
*/
|
72 |
+
protected function _initAction()
|
73 |
+
{
|
74 |
+
// load layout, set active menu and breadcrumbs
|
75 |
+
$this->loadLayout()
|
76 |
+
->_setActiveMenu($this->_menuActive)
|
77 |
+
->_addBreadcrumb(
|
78 |
+
$this->_getHelper()->__($this->_msgTitle),
|
79 |
+
$this->_getHelper()->__($this->_msgTitle)
|
80 |
+
)
|
81 |
+
->_addBreadcrumb(
|
82 |
+
$this->_getHelper()->__($this->_msgHeader),
|
83 |
+
$this->_getHelper()->__($this->_msgHeader)
|
84 |
+
);
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Index action
|
91 |
+
*/
|
92 |
+
public function indexAction()
|
93 |
+
{
|
94 |
+
$this->_title($this->__($this->_msgTitle))
|
95 |
+
->_title($this->__($this->_msgHeader))
|
96 |
+
->_initAction()
|
97 |
+
->renderLayout();
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Grid action
|
102 |
+
*/
|
103 |
+
public function gridAction()
|
104 |
+
{
|
105 |
+
$this->loadLayout();
|
106 |
+
$this->renderLayout();
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Create new Item
|
111 |
+
*/
|
112 |
+
public function newAction()
|
113 |
+
{
|
114 |
+
$this->_forward('edit');
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Edit item
|
119 |
+
*/
|
120 |
+
public function editAction()
|
121 |
+
{
|
122 |
+
$this->_title($this->__($this->_msgTitle))
|
123 |
+
->_title($this->__($this->_msgHeader));
|
124 |
+
|
125 |
+
// 1. instance model
|
126 |
+
$model = $this->_getItemModel();
|
127 |
+
|
128 |
+
// 2. if exists id, check it and load data
|
129 |
+
$itemId = $this->getRequest()->getParam('id');
|
130 |
+
if ($itemId) {
|
131 |
+
$model->load($itemId);
|
132 |
+
if (!$model->getId()) {
|
133 |
+
$this->_getSession()->addError($this->_getHelper()->__($this->_msgItemNotFound, $itemId));
|
134 |
+
return $this->_redirect('*/*/');
|
135 |
+
}
|
136 |
+
// prepare title
|
137 |
+
$this->_title($model->getTitle());
|
138 |
+
$breadCrumb = $this->_getHelper()->__($this->_msgItemEdit);
|
139 |
+
} else {
|
140 |
+
$this->_title($this->_getHelper()->__($this->_msgItemNew));
|
141 |
+
$breadCrumb = $this->_getHelper()->__($this->_msgItemNew);
|
142 |
+
}
|
143 |
+
// 3. Set entered data if was error when we do save
|
144 |
+
$data = $this->_getSession()->getFormData(true);
|
145 |
+
if (!empty($data)) {
|
146 |
+
$model->addData($data);
|
147 |
+
}
|
148 |
+
// 4. Register model to use later in blocks
|
149 |
+
$this->_registerItem($model);
|
150 |
+
|
151 |
+
// Init breadcrumbs
|
152 |
+
$this->_initAction()->_addBreadcrumb($breadCrumb, $breadCrumb);
|
153 |
+
|
154 |
+
// 5. render layout
|
155 |
+
$this->renderLayout();
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Save action
|
160 |
+
*/
|
161 |
+
public function saveAction()
|
162 |
+
{
|
163 |
+
$redirectPath = '*/*';
|
164 |
+
$redirectParams = array();
|
165 |
+
$hasError = false;
|
166 |
+
// check if data sent
|
167 |
+
$data = $this->getRequest()->getPost();
|
168 |
+
if ($data) {
|
169 |
+
$data = $this->_preparePostData($data);
|
170 |
+
|
171 |
+
//1. instance model
|
172 |
+
$model = $this->_getItemModel();
|
173 |
+
//2. if exists id, try to load data
|
174 |
+
$itemId = $this->getRequest()->getParam('id');
|
175 |
+
if ($itemId) {
|
176 |
+
$model->load($itemId);
|
177 |
+
}
|
178 |
+
$model->addData($data);
|
179 |
+
|
180 |
+
try {
|
181 |
+
//3. save the data
|
182 |
+
$model->save();
|
183 |
+
//4. display success message
|
184 |
+
$msg = $this->_getHelper()->__($this->_msgItemSaved);
|
185 |
+
$this->_getSession()->addSuccess($msg);
|
186 |
+
//5. check if 'Save and Continue'
|
187 |
+
if ($this->getRequest()->getParam('back')) {
|
188 |
+
$redirectPath = '*/*/edit';
|
189 |
+
$redirectParams = array('id' => $model->getId());
|
190 |
+
}
|
191 |
+
} catch (Mage_Core_Exception $e) {
|
192 |
+
$hasError = true;
|
193 |
+
$this->_getSession()->addError($e->getMessage());
|
194 |
+
} catch (Exception $e) {
|
195 |
+
$hasError = true;
|
196 |
+
$msg = $this->_getHelper()->__($this->_msgError);
|
197 |
+
$this->_getSession()->addException($e, $msg);
|
198 |
+
}
|
199 |
+
//6. check if errors happened
|
200 |
+
if ($hasError) {
|
201 |
+
$this->_getSession()->setFormData($data);
|
202 |
+
$redirectPath = '*/*/edit';
|
203 |
+
$redirectParams = array('id' => $this->getRequest()->getParam('id'));
|
204 |
+
}
|
205 |
+
}
|
206 |
+
//7. go to grid or edit form
|
207 |
+
$this->_redirect($redirectPath, $redirectParams);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Delete action
|
212 |
+
*/
|
213 |
+
public function deleteAction()
|
214 |
+
{
|
215 |
+
$itemId = $this->getRequest()->getParam('id');
|
216 |
+
if ($itemId) {
|
217 |
+
try {
|
218 |
+
// 1. instance model
|
219 |
+
$model = $this->_getItemModel();
|
220 |
+
// 2. if exists id, load data
|
221 |
+
$model->load($itemId);
|
222 |
+
// 3. check if elements exists
|
223 |
+
if (!$model->getId()) {
|
224 |
+
$msg = $this->_getHelper()->__($this->_msgItemDoesNotExist);
|
225 |
+
Mage::throwException($msg);
|
226 |
+
}
|
227 |
+
// 4. delete item
|
228 |
+
$model->delete();
|
229 |
+
// display success message
|
230 |
+
$msg = $this->_getHelper()->__($this->_msgItemDeleted);
|
231 |
+
$this->_getSession()->addSuccess($msg);
|
232 |
+
} catch (Mage_Core_Exception $e) {
|
233 |
+
$this->_getSession()->addError($e->getMessage());
|
234 |
+
} catch (Exception $e) {
|
235 |
+
$msg = $this->_getHelper()->__($this->_msgError, $e->getMessage());
|
236 |
+
$this->_getSession()->addException($e, $msg);
|
237 |
+
}
|
238 |
+
}
|
239 |
+
// 5. go to grid
|
240 |
+
$this->_redirect('*/*/');
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Mass Update/Delete Action
|
245 |
+
*/
|
246 |
+
public function massAction()
|
247 |
+
{
|
248 |
+
$msg = '';
|
249 |
+
$key = $this->getRequest()->getParam('massaction_prepare_key');
|
250 |
+
$itemIds = $this->getRequest()->getParam($key);
|
251 |
+
$type = $this->getRequest()->getParam('type');
|
252 |
+
$active = $this->_getItemModel()->getStatusDisabled();
|
253 |
+
|
254 |
+
if (is_array($itemIds) && count($itemIds)) {
|
255 |
+
try {
|
256 |
+
foreach($itemIds as $itemId) {
|
257 |
+
// 1. instance banner model
|
258 |
+
$model = $this->_getItemModel();
|
259 |
+
// 2. if exists id, load data
|
260 |
+
$model->load($itemId);
|
261 |
+
// 3. check if elements exists
|
262 |
+
if (!$model->getId()) {
|
263 |
+
Mage::throwException($this->_getHelper()->__($this->_msgItemNotFound));
|
264 |
+
}
|
265 |
+
// 4. main logic
|
266 |
+
switch ($type) {
|
267 |
+
case 'enable':
|
268 |
+
$active = $this->_getItemModel()->getStatusEnabled();
|
269 |
+
case 'disable':
|
270 |
+
$model->setIsActive($active);
|
271 |
+
$model->save();
|
272 |
+
$msg = $this->_msgItems .
|
273 |
+
(($active == $this->_getItemModel()->getStatusDisabled()) ? ' disabled' : ' enabled') . '.';
|
274 |
+
break;
|
275 |
+
case 'delete':
|
276 |
+
$model->delete();
|
277 |
+
$msg = $this->_msgItems . ' deleted.';
|
278 |
+
break;
|
279 |
+
}
|
280 |
+
}
|
281 |
+
// display success message
|
282 |
+
$this->_getSession()->addSuccess($this->_getHelper()->__($msg, implode(', ', $itemIds)));
|
283 |
+
} catch (Mage_Core_Exception $e) {
|
284 |
+
$this->_getSession()->addError($e->getMessage());
|
285 |
+
} catch (Exception $e) {
|
286 |
+
$this->_getSession()->addException($e, $this->_getHelper()->__($this->_msgErrorItems,$e->getMessage()));
|
287 |
+
}
|
288 |
+
}
|
289 |
+
// 5. go to grid
|
290 |
+
$this->_redirect('*/*/');
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* @param array $data
|
295 |
+
* @return array
|
296 |
+
*/
|
297 |
+
protected function _preparePostData($data)
|
298 |
+
{
|
299 |
+
return $data;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* @return Mage_Core_Helper_Abstract
|
304 |
+
*/
|
305 |
+
protected function _getHelper()
|
306 |
+
{
|
307 |
+
return null;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* @return Mage_Core_Helper_Abstract
|
312 |
+
*/
|
313 |
+
protected function _getAclHelper()
|
314 |
+
{
|
315 |
+
return null;
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* @return Mage_Core_Model_Abstract
|
320 |
+
*/
|
321 |
+
protected function _getItemModel()
|
322 |
+
{
|
323 |
+
return null;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* @param Mage_Core_Model_Abstract $model
|
328 |
+
* @return Lanot_Core_Controller_Adminhtml_AbstractController
|
329 |
+
*/
|
330 |
+
protected function _registerItem(Mage_Core_Model_Abstract $model)
|
331 |
+
{
|
332 |
+
return $this;
|
333 |
+
}
|
334 |
+
}
|
app/code/community/Lanot/Core/Model/Item/Interface.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Lanot
|
16 |
+
* @package Lanot_Core
|
17 |
+
* @copyright Copyright (c) 2012 Lanot
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
interface Lanot_Core_Model_Item_Interface
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @return array
|
25 |
+
*/
|
26 |
+
public function getAvailableStatuses();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return int
|
30 |
+
*/
|
31 |
+
public function getStatusDisabled();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return int
|
35 |
+
*/
|
36 |
+
public function getStatusEnabled();
|
37 |
+
}
|
app/code/community/Lanot/EasyBanner/Block/Adminhtml/Banner/Edit.php
CHANGED
@@ -50,7 +50,14 @@ class Lanot_EasyBanner_Block_Adminhtml_Banner_Edit
|
|
50 |
$this->_formScripts[] = "
|
51 |
function saveAndContinueEdit(){
|
52 |
editForm.submit($('edit_form').action+'back/edit/');
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
} else {
|
55 |
$this->_removeButton('save');
|
56 |
}
|
50 |
$this->_formScripts[] = "
|
51 |
function saveAndContinueEdit(){
|
52 |
editForm.submit($('edit_form').action+'back/edit/');
|
53 |
+
}
|
54 |
+
|
55 |
+
function changeBannerTypeId(value) {
|
56 |
+
document.getElementById('form_edit_container_file_fieldset').addClassName('no-display');
|
57 |
+
document.getElementById('form_edit_container_custom_fieldset').addClassName('no-display');
|
58 |
+
document.getElementById('form_edit_container_' + value + '_fieldset').removeClassName('no-display');
|
59 |
+
}
|
60 |
+
";
|
61 |
} else {
|
62 |
$this->_removeButton('save');
|
63 |
}
|
app/code/community/Lanot/EasyBanner/Block/Adminhtml/Banner/Edit/Tab/Main.php
CHANGED
@@ -45,8 +45,10 @@ class Lanot_EasyBanner_Block_Adminhtml_Banner_Edit_Tab_Main
|
|
45 |
protected function _prepareForm()
|
46 |
{
|
47 |
$model = $this->_getItemModel();
|
|
|
|
|
48 |
$extensions = $model->getAllowedExtensions();
|
49 |
-
$bannerHtml = '';
|
50 |
|
51 |
/**
|
52 |
* Checking if user have permissions to save information
|
@@ -57,14 +59,33 @@ class Lanot_EasyBanner_Block_Adminhtml_Banner_Edit_Tab_Main
|
|
57 |
$isElementDisabled = true;
|
58 |
}
|
59 |
|
|
|
60 |
$form = new Varien_Data_Form();
|
61 |
$form->setHtmlIdPrefix('banner_main_');
|
|
|
62 |
|
|
|
63 |
$fieldset = $form->addFieldset('base_fieldset', array(
|
64 |
'legend' => $this->_getHelper()->__('Banner Item Info')
|
65 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
//apply additional renderers
|
67 |
$this->_addElementTypes($fieldset);
|
|
|
|
|
|
|
68 |
|
69 |
if ($model->getId()) {
|
70 |
$fieldset->addField('banner_id', 'hidden', array(
|
@@ -72,6 +93,7 @@ class Lanot_EasyBanner_Block_Adminhtml_Banner_Edit_Tab_Main
|
|
72 |
));
|
73 |
}
|
74 |
|
|
|
75 |
if ($model->getType()) {
|
76 |
$bannerHtml = $this->_getHelper()
|
77 |
->getBannerRenderer($model->getType())
|
@@ -84,15 +106,33 @@ class Lanot_EasyBanner_Block_Adminhtml_Banner_Edit_Tab_Main
|
|
84 |
}
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
$fieldset->addField('is_active', 'select', array(
|
88 |
'name' => 'is_active',
|
89 |
'label' => $this->_getHelper()->__('Is Active'),
|
90 |
'required' => true,
|
91 |
'options' => $model->getAvailableStatuses(),
|
92 |
-
'style' => 'width:
|
93 |
'disabled' => $isElementDisabled,
|
94 |
));
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
$fieldset->addField('title', 'text', array(
|
97 |
'name' => 'title',
|
98 |
'label' => $this->_getHelper()->__('Title'),
|
@@ -104,48 +144,52 @@ class Lanot_EasyBanner_Block_Adminhtml_Banner_Edit_Tab_Main
|
|
104 |
'name' => 'description',
|
105 |
'label' => $this->_getHelper()->__('Description'),
|
106 |
'title' => $this->_getHelper()->__('Description'),
|
107 |
-
'required' => false,
|
108 |
'disabled' => $isElementDisabled,
|
|
|
109 |
));
|
110 |
|
111 |
-
|
|
|
112 |
'name' => 'url',
|
113 |
'label' => $this->_getHelper()->__('Url'),
|
114 |
'disabled' => $isElementDisabled,
|
115 |
));
|
116 |
|
117 |
-
$
|
118 |
'name' => 'width',
|
119 |
'label' => $this->_getHelper()->__('Banner Width (px)'),
|
120 |
'disabled' => $isElementDisabled,
|
121 |
'style' => 'width: 50px',
|
122 |
-
'required' => true,
|
123 |
));
|
124 |
|
125 |
-
$
|
126 |
'name' => 'height',
|
127 |
'label' => $this->_getHelper()->__('Banner Height (px)'),
|
128 |
'disabled' => $isElementDisabled,
|
129 |
'style' => 'width: 50px',
|
130 |
-
'required' => true,
|
131 |
));
|
132 |
-
|
133 |
-
$
|
134 |
'name' => 'banner_file',
|
135 |
'label' => $this->_getHelper()->__('File'),
|
136 |
'comment' => $this->_getHelper()->__('Allowed extensions: %s', implode(',', $extensions)),
|
137 |
-
'required' => true,
|
138 |
'disabled' => $isElementDisabled,
|
139 |
'style' => 'width: 200px;',
|
140 |
-
))->setBannerHtml($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
Mage::dispatchEvent('adminhtml_easybanner_banner_edit_tab_main_prepare_form', array('form' => $form));
|
143 |
|
144 |
$form->setValues($model->getData());
|
145 |
-
//$form->setUseContainer(true);
|
146 |
$this->setForm($form);
|
147 |
|
148 |
-
|
149 |
return parent::_prepareForm();
|
150 |
}
|
151 |
|
45 |
protected function _prepareForm()
|
46 |
{
|
47 |
$model = $this->_getItemModel();
|
48 |
+
$typeId = $model->getTypeId();
|
49 |
+
|
50 |
$extensions = $model->getAllowedExtensions();
|
51 |
+
$bannerHtml = $bannerHtmlFile = $bannerHtmlCustom = '';
|
52 |
|
53 |
/**
|
54 |
* Checking if user have permissions to save information
|
59 |
$isElementDisabled = true;
|
60 |
}
|
61 |
|
62 |
+
|
63 |
$form = new Varien_Data_Form();
|
64 |
$form->setHtmlIdPrefix('banner_main_');
|
65 |
+
$form->getFieldsetRenderer()->setTemplate('lanot/easybanner/widget/form/renderer/fieldset.phtml');
|
66 |
|
67 |
+
//prepare fieldsets
|
68 |
$fieldset = $form->addFieldset('base_fieldset', array(
|
69 |
'legend' => $this->_getHelper()->__('Banner Item Info')
|
70 |
));
|
71 |
+
|
72 |
+
$fileFieldset = $form->addFieldset('file_fieldset', array(
|
73 |
+
'legend' => $this->_getHelper()->__('Banner File Info'),
|
74 |
+
'fieldset_container_id' => 'form_edit_container_file_fieldset',
|
75 |
+
'fieldset_container_class' => ($typeId != Lanot_EasyBanner_Model_Banner::TYPE_ID_FILE) ? 'no-display' : '',
|
76 |
+
));
|
77 |
+
|
78 |
+
$customFieldset = $form->addFieldset('custom_fieldset', array(
|
79 |
+
'legend' => $this->_getHelper()->__('Banner Custom Code Info'),
|
80 |
+
'fieldset_container_id' => 'form_edit_container_custom_fieldset',
|
81 |
+
'fieldset_container_class' => ($typeId != Lanot_EasyBanner_Model_Banner::TYPE_ID_CUSTOM) ? 'no-display' : '',
|
82 |
+
));
|
83 |
+
|
84 |
//apply additional renderers
|
85 |
$this->_addElementTypes($fieldset);
|
86 |
+
$this->_addElementTypes($fileFieldset);
|
87 |
+
$this->_addElementTypes($customFieldset);
|
88 |
+
|
89 |
|
90 |
if ($model->getId()) {
|
91 |
$fieldset->addField('banner_id', 'hidden', array(
|
93 |
));
|
94 |
}
|
95 |
|
96 |
+
//prepare banner HTML
|
97 |
if ($model->getType()) {
|
98 |
$bannerHtml = $this->_getHelper()
|
99 |
->getBannerRenderer($model->getType())
|
106 |
}
|
107 |
}
|
108 |
|
109 |
+
if ($typeId === Lanot_EasyBanner_Model_Banner::TYPE_ID_CUSTOM) {
|
110 |
+
$bannerHtmlCustom = $bannerHtml;
|
111 |
+
} else {
|
112 |
+
$bannerHtmlFile = $bannerHtml;
|
113 |
+
}
|
114 |
+
|
115 |
+
//general information
|
116 |
$fieldset->addField('is_active', 'select', array(
|
117 |
'name' => 'is_active',
|
118 |
'label' => $this->_getHelper()->__('Is Active'),
|
119 |
'required' => true,
|
120 |
'options' => $model->getAvailableStatuses(),
|
121 |
+
'style' => 'width: 200px',
|
122 |
'disabled' => $isElementDisabled,
|
123 |
));
|
124 |
|
125 |
+
$fieldset->addField('type_id', 'select', array(
|
126 |
+
'name' => 'type_id',
|
127 |
+
'label' => $this->_getHelper()->__('Banner Type'),
|
128 |
+
'required' => true,
|
129 |
+
'options' => $model->getAvailableTypes(),
|
130 |
+
'style' => 'width: 200px',
|
131 |
+
'disabled' => $isElementDisabled,
|
132 |
+
'value' => $typeId,
|
133 |
+
'onchange' => 'changeBannerTypeId(this.value)'
|
134 |
+
));
|
135 |
+
|
136 |
$fieldset->addField('title', 'text', array(
|
137 |
'name' => 'title',
|
138 |
'label' => $this->_getHelper()->__('Title'),
|
144 |
'name' => 'description',
|
145 |
'label' => $this->_getHelper()->__('Description'),
|
146 |
'title' => $this->_getHelper()->__('Description'),
|
|
|
147 |
'disabled' => $isElementDisabled,
|
148 |
+
'style' => 'height: 60px',
|
149 |
));
|
150 |
|
151 |
+
//file information
|
152 |
+
$fileFieldset->addField('url', 'text', array(
|
153 |
'name' => 'url',
|
154 |
'label' => $this->_getHelper()->__('Url'),
|
155 |
'disabled' => $isElementDisabled,
|
156 |
));
|
157 |
|
158 |
+
$fileFieldset->addField('width', 'text', array(
|
159 |
'name' => 'width',
|
160 |
'label' => $this->_getHelper()->__('Banner Width (px)'),
|
161 |
'disabled' => $isElementDisabled,
|
162 |
'style' => 'width: 50px',
|
|
|
163 |
));
|
164 |
|
165 |
+
$fileFieldset->addField('height', 'text', array(
|
166 |
'name' => 'height',
|
167 |
'label' => $this->_getHelper()->__('Banner Height (px)'),
|
168 |
'disabled' => $isElementDisabled,
|
169 |
'style' => 'width: 50px',
|
|
|
170 |
));
|
171 |
+
|
172 |
+
$fileFieldset->addField('path', 'banner', array(
|
173 |
'name' => 'banner_file',
|
174 |
'label' => $this->_getHelper()->__('File'),
|
175 |
'comment' => $this->_getHelper()->__('Allowed extensions: %s', implode(',', $extensions)),
|
|
|
176 |
'disabled' => $isElementDisabled,
|
177 |
'style' => 'width: 200px;',
|
178 |
+
))->setBannerHtml($bannerHtmlFile);
|
179 |
+
|
180 |
+
//custom code information
|
181 |
+
$customFieldset->addField('code', 'textarea', array(
|
182 |
+
'name' => 'code',
|
183 |
+
'label' => $this->_getHelper()->__('Custom Code'),
|
184 |
+
'disabled' => $isElementDisabled,
|
185 |
+
))->setAfterElementHtml($bannerHtmlCustom);
|
186 |
+
|
187 |
|
188 |
Mage::dispatchEvent('adminhtml_easybanner_banner_edit_tab_main_prepare_form', array('form' => $form));
|
189 |
|
190 |
$form->setValues($model->getData());
|
|
|
191 |
$this->setForm($form);
|
192 |
|
|
|
193 |
return parent::_prepareForm();
|
194 |
}
|
195 |
|
app/code/community/Lanot/EasyBanner/Block/Adminhtml/Category/Edit/Tab/Main.php
CHANGED
@@ -60,6 +60,7 @@ class Lanot_EasyBanner_Block_Adminhtml_Category_Edit_Tab_Main
|
|
60 |
));
|
61 |
}
|
62 |
|
|
|
63 |
$fieldset->addField('title', 'text', array(
|
64 |
'name' => 'title',
|
65 |
'label' => $this->_getHelper()->__('Title'),
|
@@ -84,8 +85,19 @@ class Lanot_EasyBanner_Block_Adminhtml_Category_Edit_Tab_Main
|
|
84 |
'required' => true,
|
85 |
'disabled' => $isElementDisabled,
|
86 |
'options' => $model->getAvailableStatuses(),
|
87 |
-
));
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
$form->setValues($model->getData());
|
90 |
|
91 |
Mage::dispatchEvent('adminhtml_easybanner_category_edit_tab_main_prepare_form', array('form' => $form));
|
60 |
));
|
61 |
}
|
62 |
|
63 |
+
//Add main elements to the category
|
64 |
$fieldset->addField('title', 'text', array(
|
65 |
'name' => 'title',
|
66 |
'label' => $this->_getHelper()->__('Title'),
|
85 |
'required' => true,
|
86 |
'disabled' => $isElementDisabled,
|
87 |
'options' => $model->getAvailableStatuses(),
|
88 |
+
));
|
89 |
+
|
90 |
+
/*
|
91 |
+
//Add layout updates elements to the category
|
92 |
+
$lBlock = $this->getLayout()->createBlock('lanot_easybanner/adminhtml_widget_instance_edit_tab_main_layout');
|
93 |
+
$fieldset = $form->addFieldset('layout_updates_fieldset', array(
|
94 |
+
'legend' => $this->_getHelper()->__('Layout Updates')
|
95 |
+
));
|
96 |
+
|
97 |
+
$fieldset->addField('layout_updates', 'note', array());
|
98 |
+
$form->getElement('layout_updates_fieldset')->setRenderer($lBlock);
|
99 |
+
*/
|
100 |
+
|
101 |
$form->setValues($model->getData());
|
102 |
|
103 |
Mage::dispatchEvent('adminhtml_easybanner_category_edit_tab_main_prepare_form', array('form' => $form));
|
app/code/community/Lanot/EasyBanner/Block/Adminhtml/Grid/Abstract.php
CHANGED
@@ -24,181 +24,12 @@
|
|
24 |
* @author Lanot
|
25 |
*/
|
26 |
class Lanot_EasyBanner_Block_Adminhtml_Grid_Abstract
|
27 |
-
|
28 |
{
|
29 |
-
protected $_gridId = 'easybanner_list_grid';
|
30 |
-
protected $_entityIdField = 'entity_id';
|
31 |
-
protected $_itemParam = 'entity_id';
|
32 |
-
protected $_formFieldName = 'entity';
|
33 |
-
protected $_columnPrefix = '';
|
34 |
-
protected $_checkboxFieldName = 'in_selected';
|
35 |
-
protected $_isTabGrid = false;
|
36 |
-
|
37 |
-
/** @var Mage_Core_Model_Abstract */
|
38 |
-
protected $_item = null;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Init Grid default properties
|
42 |
-
*
|
43 |
-
*/
|
44 |
-
public function __construct()
|
45 |
-
{
|
46 |
-
parent::__construct();
|
47 |
-
|
48 |
-
$this->setId($this->_gridId);
|
49 |
-
$this->setDefaultSort('sort_order');
|
50 |
-
$this->setDefaultDir('ASC');
|
51 |
-
$this->setSaveParametersInSession(true);
|
52 |
-
$this->setUseAjax(true);
|
53 |
-
|
54 |
-
if ($this->isReadonly()) {
|
55 |
-
$this->setFilterVisibility(false);
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @return this
|
61 |
-
*/
|
62 |
-
protected function _prepareCollection()
|
63 |
-
{
|
64 |
-
$collection = $this->_getItemModel()->getCollection();
|
65 |
-
|
66 |
-
//filter colelction if it show in tab
|
67 |
-
if ($this->_isTabGrid && $this->isReadonly()) {
|
68 |
-
$valueIds = $this->getSelectedLinks();
|
69 |
-
if (empty($valueIds)) {
|
70 |
-
$valueIds = array(0);
|
71 |
-
}
|
72 |
-
$collection->addFieldToFilter($this->_entityIdField, array('in' => $valueIds));
|
73 |
-
}
|
74 |
-
|
75 |
-
$this->setCollection($collection);
|
76 |
-
|
77 |
-
return parent::_prepareCollection();
|
78 |
-
}
|
79 |
|
80 |
/**
|
81 |
-
|
82 |
-
|
83 |
-
*/
|
84 |
-
public function getRowUrl($row)
|
85 |
-
{
|
86 |
-
return (!$this->_isTabGrid) ? $this->getUrl('*/*/edit', array('id' => $row->getId())) : '#';
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @return string
|
91 |
-
*/
|
92 |
-
public function getGridUrl()
|
93 |
-
{
|
94 |
-
return (!$this->_isTabGrid) ?
|
95 |
-
$this->getUrl('*/*/grid', array('_current' => true)) :
|
96 |
-
$this->getUrl('*/*/ajaxgridonly', array('_current' => true));
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Prepare Grid columns
|
101 |
-
*
|
102 |
-
* @return Lanot_EasyBanner_Block_Adminhtml_Banner_Grid
|
103 |
-
*/
|
104 |
-
protected function _prepareColumns()
|
105 |
-
{
|
106 |
-
if ($this->_isTabGrid) {
|
107 |
-
$this->addColumn('in_selected', array(
|
108 |
-
'header_css_class' => 'a-center',
|
109 |
-
'type' => 'checkbox',
|
110 |
-
'name' => 'in_selected',
|
111 |
-
'values' => $this->getSelectedLinks(),
|
112 |
-
'align' => 'center',
|
113 |
-
'index' => $this->_entityIdField,
|
114 |
-
));
|
115 |
-
}
|
116 |
-
|
117 |
-
$this->addColumn($this->_entityIdField, array(
|
118 |
-
'header' => $this->_getHelper()->__('ID'),
|
119 |
-
'index' => $this->_entityIdField,
|
120 |
-
'type' => 'number',
|
121 |
-
'width' => '50px',
|
122 |
-
));
|
123 |
-
|
124 |
-
$this->addColumn('title', array(
|
125 |
-
'header' => $this->_getHelper()->__('Title'),
|
126 |
-
'index' => 'title',
|
127 |
-
));
|
128 |
-
|
129 |
-
$this->addColumn('is_active', array(
|
130 |
-
'header' => $this->_getHelper()->__('Active'),
|
131 |
-
'index' => 'is_active',
|
132 |
-
'type' => 'options',
|
133 |
-
'options' => $this->_getItemModel()->getAvailableStatuses(),
|
134 |
-
'width' => '100px',
|
135 |
-
));
|
136 |
-
|
137 |
-
$this->addColumn('updated_at', array(
|
138 |
-
'header' => $this->_getHelper()->__('Updated'),
|
139 |
-
'index' => 'updated_at',
|
140 |
-
'width' => '150px',
|
141 |
-
));
|
142 |
-
|
143 |
-
if (!$this->_isTabGrid) {
|
144 |
-
$this->addColumn('action',
|
145 |
-
array(
|
146 |
-
'header' => $this->_getHelper()->__('Action'),
|
147 |
-
'width' => '70px',
|
148 |
-
'align' => 'center',
|
149 |
-
'type' => 'action',
|
150 |
-
'getter' => 'getId',
|
151 |
-
'actions' => array(
|
152 |
-
array(
|
153 |
-
'caption' => $this->_getHelper()->__('Edit'),
|
154 |
-
'url' => array('base' => '*/*/edit'),
|
155 |
-
'field' => 'id'
|
156 |
-
)
|
157 |
-
),
|
158 |
-
'filter' => false,
|
159 |
-
'sortable' => false,
|
160 |
-
'index' => 'banner',
|
161 |
-
));
|
162 |
-
}
|
163 |
-
|
164 |
-
return parent::_prepareColumns();
|
165 |
-
}
|
166 |
-
|
167 |
-
|
168 |
-
/**
|
169 |
-
* @return Lanot_EasyBanner_Block_Adminhtml_Grid_Abstract
|
170 |
-
*/
|
171 |
-
protected function _prepareMassaction()
|
172 |
-
{
|
173 |
-
if (!$this->isMassActionAllowed()) {
|
174 |
-
return $this;
|
175 |
-
}
|
176 |
-
|
177 |
-
$this->setMassactionIdField($this->_entityIdField);
|
178 |
-
$this->getMassactionBlock()->setFormFieldName($this->_formFieldName);
|
179 |
-
|
180 |
-
$this->getMassactionBlock()->addItem('delete', array(
|
181 |
-
'label' => $this->_getHelper()->__('Delete'),
|
182 |
-
'confirm' => $this->_getHelper()->__('Are you sure?'),
|
183 |
-
'url' => $this->getUrl('*/*/mass', array('type' => 'delete')),
|
184 |
-
));
|
185 |
-
|
186 |
-
$this->getMassactionBlock()->addItem('active_enable', array(
|
187 |
-
'label' => $this->_getHelper()->__('Enable'),
|
188 |
-
'url' => $this->getUrl('*/*/mass', array('type' => 'enable'))
|
189 |
-
));
|
190 |
-
|
191 |
-
$this->getMassactionBlock()->addItem('active_disable', array(
|
192 |
-
'label' => $this->_getHelper()->__('Disable'),
|
193 |
-
'url' => $this->getUrl('*/*/mass', array('type' => 'disable'))
|
194 |
-
));
|
195 |
-
|
196 |
-
return $this;
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* @return Lanot_EasyBanner_Helper_Data
|
201 |
-
*/
|
202 |
protected function _getHelper()
|
203 |
{
|
204 |
return Mage::helper('lanot_easybanner');
|
@@ -211,101 +42,4 @@ class Lanot_EasyBanner_Block_Adminhtml_Grid_Abstract
|
|
211 |
{
|
212 |
return Mage::helper('lanot_easybanner/admin');
|
213 |
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Retrieve selected categories
|
217 |
-
*
|
218 |
-
* @return array
|
219 |
-
*/
|
220 |
-
public function getSelectedLinks()
|
221 |
-
{
|
222 |
-
return $this->_getItem()->getSelectedLinks();
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Add column to grid
|
227 |
-
*
|
228 |
-
* @param string $columnId
|
229 |
-
* @param array || Varien_Object $column
|
230 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
231 |
-
*/
|
232 |
-
public function addColumn($columnId, $column)
|
233 |
-
{
|
234 |
-
return parent::addColumn($this->_columnPrefix . $columnId, $column);
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* @return Lanot_EasyBanner_Model_Banner|null
|
239 |
-
*/
|
240 |
-
protected function _getItem()
|
241 |
-
{
|
242 |
-
if ($this->_item !== null) {
|
243 |
-
return $this->_item;
|
244 |
-
}
|
245 |
-
|
246 |
-
$itemId = $this->getRequest()->getParam($this->_itemParam);
|
247 |
-
$this->_item = $this->_getItemModel();
|
248 |
-
if ($itemId) {
|
249 |
-
$this->_item->load($itemId);
|
250 |
-
}
|
251 |
-
return $this->_item;
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* @param $column
|
256 |
-
* @return Lanot_EasyBanner_Block_Adminhtml_Grid_Abstract
|
257 |
-
*/
|
258 |
-
protected function _addColumnFilterToCollection($column)
|
259 |
-
{
|
260 |
-
if (!$this->_isTabGrid) {
|
261 |
-
return $this;
|
262 |
-
}
|
263 |
-
|
264 |
-
// Set custom filter by selected values
|
265 |
-
if ($column->getId() == $this->_checkboxFieldName) {
|
266 |
-
$valueIds = $this->getSelectedLinks();
|
267 |
-
if (empty($valueIds)) {
|
268 |
-
$valueIds = 0;
|
269 |
-
}
|
270 |
-
|
271 |
-
if ($column->getFilter()->getValue()) {
|
272 |
-
$this->getCollection()->addFieldToFilter($this->_entityIdField, array('in' => $valueIds));
|
273 |
-
} else {
|
274 |
-
if($valueIds) {
|
275 |
-
$this->getCollection()->addFieldToFilter($this->_entityIdField, array('nin' => $valueIds));
|
276 |
-
}
|
277 |
-
}
|
278 |
-
} else {
|
279 |
-
parent::_addColumnFilterToCollection($column);
|
280 |
-
}
|
281 |
-
return $this;
|
282 |
-
}
|
283 |
-
|
284 |
-
/**
|
285 |
-
* Checks when this block is readonly
|
286 |
-
*
|
287 |
-
* @return boolean
|
288 |
-
*/
|
289 |
-
public function isReadonly()
|
290 |
-
{
|
291 |
-
return false;
|
292 |
-
}
|
293 |
-
|
294 |
-
/**
|
295 |
-
* Checks when this block is not available
|
296 |
-
*
|
297 |
-
* @return boolean
|
298 |
-
*/
|
299 |
-
public function isMassActionAllowed()
|
300 |
-
{
|
301 |
-
return true;
|
302 |
-
}
|
303 |
-
|
304 |
-
/**
|
305 |
-
* @return Mage_Core_Model_Abstract
|
306 |
-
*/
|
307 |
-
protected function _getItemModel()
|
308 |
-
{
|
309 |
-
return null;
|
310 |
-
}
|
311 |
}
|
24 |
* @author Lanot
|
25 |
*/
|
26 |
class Lanot_EasyBanner_Block_Adminhtml_Grid_Abstract
|
27 |
+
extends Lanot_Core_Block_Adminhtml_Grid_Abstract
|
28 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
/**
|
31 |
+
* @return Lanot_EasyBanner_Helper_Data
|
32 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
protected function _getHelper()
|
34 |
{
|
35 |
return Mage::helper('lanot_easybanner');
|
42 |
{
|
43 |
return Mage::helper('lanot_easybanner/admin');
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
app/code/community/Lanot/EasyBanner/Block/Adminhtml/Renderer/Banner.php
CHANGED
@@ -25,7 +25,6 @@
|
|
25 |
*/
|
26 |
class Lanot_EasyBanner_Block_Adminhtml_Renderer_Banner extends Varien_Data_Form_Element_Image
|
27 |
{
|
28 |
-
|
29 |
/**
|
30 |
* Enter description here...
|
31 |
*
|
25 |
*/
|
26 |
class Lanot_EasyBanner_Block_Adminhtml_Renderer_Banner extends Varien_Data_Form_Element_Image
|
27 |
{
|
|
|
28 |
/**
|
29 |
* Enter description here...
|
30 |
*
|
app/code/community/Lanot/EasyBanner/Block/Banner/Renderer/Custom.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Lanot
|
16 |
+
* @package Lanot_EasyBanner
|
17 |
+
* @copyright Copyright (c) 2012 Lanot
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
class Lanot_EasyBanner_Block_Banner_Renderer_Custom
|
22 |
+
extends Lanot_EasyBanner_Block_Banner_Renderer_Abstract
|
23 |
+
{
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return $this->_banner->getCode();
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Lanot/EasyBanner/Block/Banner/Renderer/Flash.php
CHANGED
@@ -33,7 +33,7 @@ class Lanot_EasyBanner_Block_Banner_Renderer_Flash
|
|
33 |
}
|
34 |
|
35 |
$code = ''.
|
36 |
-
|
37 |
data="' . $this->_banner->getPathUrl() . '"
|
38 |
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
39 |
codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
|
33 |
}
|
34 |
|
35 |
$code = ''.
|
36 |
+
'<object type="application/x-shockwave-flash"
|
37 |
data="' . $this->_banner->getPathUrl() . '"
|
38 |
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
39 |
codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
|
app/code/community/Lanot/EasyBanner/Controller/Adminhtml/AbstractController.php
CHANGED
@@ -19,267 +19,8 @@
|
|
19 |
*/
|
20 |
|
21 |
class Lanot_EasyBanner_Controller_Adminhtml_AbstractController
|
22 |
-
|
23 |
{
|
24 |
-
protected $_msgTitle = 'Items';
|
25 |
-
protected $_msgHeader = 'Items';
|
26 |
-
protected $_msgItemDoesNotExist = 'Item does not exist.';
|
27 |
-
protected $_msgItemNotFound = 'Unable to find an item. #%s';
|
28 |
-
protected $_msgItemEdit = 'Edit Item';
|
29 |
-
protected $_msgItemNew = 'New Item';
|
30 |
-
protected $_msgItemSaved = 'The item has been saved.';
|
31 |
-
protected $_msgItemDeleted = 'The item has been deleted.';
|
32 |
-
protected $_msgError = 'An error occurred while edit the item. %s';
|
33 |
-
protected $_msgErrorItems = 'An error occurred while edit the items. %s';
|
34 |
-
protected $_msgItems = 'The items %s has been';
|
35 |
-
|
36 |
-
protected $_aclSection = null;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Check the permission to run it
|
40 |
-
*
|
41 |
-
* @return boolean
|
42 |
-
*/
|
43 |
-
protected function _isAllowed()
|
44 |
-
{
|
45 |
-
switch ($this->getRequest()->getActionName()) {
|
46 |
-
case 'new':
|
47 |
-
case 'edit':
|
48 |
-
case 'save':
|
49 |
-
case 'mass':
|
50 |
-
return $this->_getAclHelper()->isActionAllowed($this->_aclSection . '/save');
|
51 |
-
break;
|
52 |
-
case 'delete':
|
53 |
-
return $this->_getAclHelper()->isActionAllowed($this->_aclSection . '/delete');
|
54 |
-
break;
|
55 |
-
default:
|
56 |
-
return $this->_getAclHelper()->isActionAllowed($this->_aclSection);
|
57 |
-
break;
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Init actions
|
63 |
-
*
|
64 |
-
* @return Lanot_EasyBanner_Controller_Adminhtml_AbstractController
|
65 |
-
*/
|
66 |
-
protected function _initAction()
|
67 |
-
{
|
68 |
-
// load layout, set active menu and breadcrumbs
|
69 |
-
$this->loadLayout()
|
70 |
-
->_setActiveMenu('lanot/lanot_easybanner')
|
71 |
-
->_addBreadcrumb(
|
72 |
-
$this->_getHelper()->__($this->_msgTitle),
|
73 |
-
$this->_getHelper()->__($this->_msgTitle)
|
74 |
-
)
|
75 |
-
->_addBreadcrumb(
|
76 |
-
$this->_getHelper()->__($this->_msgHeader),
|
77 |
-
$this->_getHelper()->__($this->_msgHeader)
|
78 |
-
);
|
79 |
-
|
80 |
-
return $this;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Index action
|
85 |
-
*/
|
86 |
-
public function indexAction()
|
87 |
-
{
|
88 |
-
$this->_title($this->__($this->_msgTitle))
|
89 |
-
->_title($this->__($this->_msgHeader))
|
90 |
-
->_initAction()
|
91 |
-
->renderLayout();
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Grid action
|
96 |
-
*/
|
97 |
-
public function gridAction()
|
98 |
-
{
|
99 |
-
$this->loadLayout();
|
100 |
-
$this->renderLayout();
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Create new Item
|
105 |
-
*/
|
106 |
-
public function newAction()
|
107 |
-
{
|
108 |
-
$this->_forward('edit');
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Edit item
|
113 |
-
*/
|
114 |
-
public function editAction()
|
115 |
-
{
|
116 |
-
$this->_title($this->__($this->_msgTitle))
|
117 |
-
->_title($this->__($this->_msgHeader));
|
118 |
-
|
119 |
-
// 1. instance model
|
120 |
-
$model = $this->_getItemModel();
|
121 |
-
|
122 |
-
// 2. if exists id, check it and load data
|
123 |
-
$itemId = $this->getRequest()->getParam('id');
|
124 |
-
if ($itemId) {
|
125 |
-
$model->load($itemId);
|
126 |
-
if (!$model->getId()) {
|
127 |
-
$this->_getSession()->addError($this->_getHelper()->__($this->_msgItemNotFound, $itemId));
|
128 |
-
return $this->_redirect('*/*/');
|
129 |
-
}
|
130 |
-
// prepare title
|
131 |
-
$this->_title($model->getTitle());
|
132 |
-
$breadCrumb = $this->_getHelper()->__($this->_msgItemEdit);
|
133 |
-
} else {
|
134 |
-
$this->_title($this->_getHelper()->__($this->_msgItemNew));
|
135 |
-
$breadCrumb = $this->_getHelper()->__($this->_msgItemNew);
|
136 |
-
}
|
137 |
-
// 3. Set entered data if was error when we do save
|
138 |
-
$data = $this->_getSession()->getFormData(true);
|
139 |
-
if (!empty($data)) {
|
140 |
-
$model->addData($data);
|
141 |
-
}
|
142 |
-
// 4. Register model to use later in blocks
|
143 |
-
$this->_registerItem($model);
|
144 |
-
|
145 |
-
// Init breadcrumbs
|
146 |
-
$this->_initAction()->_addBreadcrumb($breadCrumb, $breadCrumb);
|
147 |
-
|
148 |
-
// 5. render layout
|
149 |
-
$this->renderLayout();
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Save action
|
154 |
-
*/
|
155 |
-
public function saveAction()
|
156 |
-
{
|
157 |
-
$redirectPath = '*/*';
|
158 |
-
$redirectParams = array();
|
159 |
-
$hasError = false;
|
160 |
-
// check if data sent
|
161 |
-
$data = $this->getRequest()->getPost();
|
162 |
-
if ($data) {
|
163 |
-
//1. instance model
|
164 |
-
$model = $this->_getItemModel();
|
165 |
-
//2. if exists id, try to load data
|
166 |
-
$itemId = $this->getRequest()->getParam('id');
|
167 |
-
if ($itemId) {
|
168 |
-
$model->load($itemId);
|
169 |
-
}
|
170 |
-
$model->addData($data);
|
171 |
-
|
172 |
-
try {
|
173 |
-
//3. save the data
|
174 |
-
$model->save();
|
175 |
-
//4. display success message
|
176 |
-
$msg = $this->_getHelper()->__($this->_msgItemSaved);
|
177 |
-
$this->_getSession()->addSuccess($msg);
|
178 |
-
//5. check if 'Save and Continue'
|
179 |
-
if ($this->getRequest()->getParam('back')) {
|
180 |
-
$redirectPath = '*/*/edit';
|
181 |
-
$redirectParams = array('id' => $model->getId());
|
182 |
-
}
|
183 |
-
} catch (Mage_Core_Exception $e) {
|
184 |
-
$this->_getSession()->addError($e->getMessage());
|
185 |
-
} catch (Exception $e) {
|
186 |
-
$msg = $this->_getHelper()->__($this->_msgError);
|
187 |
-
$this->_getSession()->addException($e, $msg);
|
188 |
-
}
|
189 |
-
//6. check if errors happened
|
190 |
-
if ($hasError) {
|
191 |
-
$this->_getSession()->setFormData($data);
|
192 |
-
$redirectPath = '*/*/edit';
|
193 |
-
$redirectParams = array('id' => $this->getRequest()->getParam('id'));
|
194 |
-
}
|
195 |
-
}
|
196 |
-
//7. go to grid or edit form
|
197 |
-
$this->_redirect($redirectPath, $redirectParams);
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Delete action
|
202 |
-
*/
|
203 |
-
public function deleteAction()
|
204 |
-
{
|
205 |
-
$itemId = $this->getRequest()->getParam('id');
|
206 |
-
if ($itemId) {
|
207 |
-
try {
|
208 |
-
// 1. instance model
|
209 |
-
$model = $this->_getItemModel();
|
210 |
-
// 2. if exists id, load data
|
211 |
-
$model->load($itemId);
|
212 |
-
// 3. check if elements exists
|
213 |
-
if (!$model->getId()) {
|
214 |
-
$msg = $this->_getHelper()->__($this->_msgItemDoesNotExist);
|
215 |
-
Mage::throwException($msg);
|
216 |
-
}
|
217 |
-
// 4. delete banner
|
218 |
-
$model->delete();
|
219 |
-
// display success message
|
220 |
-
$msg = $this->_getHelper()->__($this->_msgItemDeleted);
|
221 |
-
$this->_getSession()->addSuccess($msg);
|
222 |
-
} catch (Mage_Core_Exception $e) {
|
223 |
-
$this->_getSession()->addError($e->getMessage());
|
224 |
-
} catch (Exception $e) {
|
225 |
-
$msg = $this->_getHelper()->__($this->_msgError, $e->getMessage());
|
226 |
-
$this->_getSession()->addException($e, $msg);
|
227 |
-
}
|
228 |
-
}
|
229 |
-
// 5. go to grid
|
230 |
-
$this->_redirect('*/*/');
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
*
|
235 |
-
*/
|
236 |
-
public function massAction()
|
237 |
-
{
|
238 |
-
$msg = '';
|
239 |
-
$key = $this->getRequest()->getParam('massaction_prepare_key');
|
240 |
-
$itemIds = $this->getRequest()->getParam($key);
|
241 |
-
$type = $this->getRequest()->getParam('type');
|
242 |
-
$active = $this->_getItemModel()->getStatusDisabled();
|
243 |
-
|
244 |
-
if (is_array($itemIds) && count($itemIds)) {
|
245 |
-
try {
|
246 |
-
foreach($itemIds as $itemId) {
|
247 |
-
// 1. instance banner model
|
248 |
-
$model = $this->_getItemModel();
|
249 |
-
// 2. if exists id, load data
|
250 |
-
$model->load($itemId);
|
251 |
-
// 3. check if elements exists
|
252 |
-
if (!$model->getId()) {
|
253 |
-
Mage::throwException($this->_getHelper()->__($this->_msgItemNotFound));
|
254 |
-
}
|
255 |
-
// 4. main logic
|
256 |
-
switch ($type) {
|
257 |
-
case 'enable':
|
258 |
-
$active = $this->_getItemModel()->getStatusEnabled();
|
259 |
-
case 'disable':
|
260 |
-
$model->setIsActive($active);
|
261 |
-
$model->save();
|
262 |
-
$msg = $this->_msgItems .
|
263 |
-
(($active == $this->_getItemModel()->getStatusDisabled()) ? ' enabled' : ' disabled') . '.';
|
264 |
-
break;
|
265 |
-
case 'delete':
|
266 |
-
$model->delete();
|
267 |
-
$msg = $this->_msgItems . ' deleted.';
|
268 |
-
break;
|
269 |
-
}
|
270 |
-
}
|
271 |
-
// display success message
|
272 |
-
$this->_getSession()->addSuccess($this->_getHelper()->__($msg, implode(', ', $itemIds)));
|
273 |
-
} catch (Mage_Core_Exception $e) {
|
274 |
-
$this->_getSession()->addError($e->getMessage());
|
275 |
-
} catch (Exception $e) {
|
276 |
-
$this->_getSession()->addException($e, $this->_getHelper()->__($this->_msgErrorItems,$e->getMessage()));
|
277 |
-
}
|
278 |
-
}
|
279 |
-
// 5. go to grid
|
280 |
-
$this->_redirect('*/*/');
|
281 |
-
}
|
282 |
-
|
283 |
/**
|
284 |
* @return Lanot_EasyBanner_Helper_Data
|
285 |
*/
|
@@ -295,21 +36,4 @@ class Lanot_EasyBanner_Controller_Adminhtml_AbstractController
|
|
295 |
{
|
296 |
return Mage::helper('lanot_easybanner/admin');
|
297 |
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* @return Mage_Core_Model_Abstract
|
301 |
-
*/
|
302 |
-
protected function _getItemModel()
|
303 |
-
{
|
304 |
-
return null;
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* @param Mage_Core_Model_Abstract $model
|
309 |
-
* @return Lanot_EasyBanner_Controller_Adminhtml_AbstractController
|
310 |
-
*/
|
311 |
-
protected function _registerItem(Mage_Core_Model_Abstract $model)
|
312 |
-
{
|
313 |
-
return $this;
|
314 |
-
}
|
315 |
}
|
19 |
*/
|
20 |
|
21 |
class Lanot_EasyBanner_Controller_Adminhtml_AbstractController
|
22 |
+
extends Lanot_Core_Controller_Adminhtml_AbstractController
|
23 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
/**
|
25 |
* @return Lanot_EasyBanner_Helper_Data
|
26 |
*/
|
36 |
{
|
37 |
return Mage::helper('lanot_easybanner/admin');
|
38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
app/code/community/Lanot/EasyBanner/Model/Banner.php
CHANGED
@@ -20,10 +20,14 @@
|
|
20 |
|
21 |
class Lanot_EasyBanner_Model_Banner
|
22 |
extends Mage_Core_Model_Abstract
|
23 |
-
|
|
|
24 |
const STATUS_ENABLED = 1;
|
25 |
const STATUS_DISABLED = 0;
|
26 |
|
|
|
|
|
|
|
27 |
/**
|
28 |
* @var array
|
29 |
*/
|
@@ -39,6 +43,16 @@ class Lanot_EasyBanner_Model_Banner
|
|
39 |
$this->_init('lanot_easybanner/banner');
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* @return Lanot_EasyBanner_Helper_Data
|
44 |
*/
|
@@ -47,6 +61,32 @@ class Lanot_EasyBanner_Model_Banner
|
|
47 |
return Mage::helper('lanot_easybanner');
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
/**
|
51 |
* @return array
|
52 |
*/
|
@@ -74,6 +114,17 @@ class Lanot_EasyBanner_Model_Banner
|
|
74 |
return self::STATUS_ENABLED;
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
/**
|
78 |
* @return array
|
79 |
*/
|
@@ -81,7 +132,6 @@ class Lanot_EasyBanner_Model_Banner
|
|
81 |
{
|
82 |
$this->prepareExtensions();
|
83 |
return $this->_extensions;
|
84 |
-
|
85 |
}
|
86 |
|
87 |
/**
|
@@ -141,9 +191,7 @@ class Lanot_EasyBanner_Model_Banner
|
|
141 |
*/
|
142 |
public function getPathUrl()
|
143 |
{
|
144 |
-
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) .
|
145 |
-
$this->getMediaPath() .
|
146 |
-
$this->getPath();
|
147 |
}
|
148 |
|
149 |
/**
|
@@ -170,7 +218,13 @@ class Lanot_EasyBanner_Model_Banner
|
|
170 |
}
|
171 |
$this->setData('updated_at', Varien_Date::now());
|
172 |
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
$this->_prepareCategories();
|
175 |
|
176 |
return $this;
|
@@ -233,6 +287,8 @@ class Lanot_EasyBanner_Model_Banner
|
|
233 |
*/
|
234 |
protected function _prepareFileInfo()
|
235 |
{
|
|
|
|
|
236 |
//upload file
|
237 |
$fileData = $this->getBannerFile();
|
238 |
$isPathDeleted = (is_array($fileData) && !empty($fileData['delete']));
|
@@ -257,10 +313,28 @@ class Lanot_EasyBanner_Model_Banner
|
|
257 |
if (null !== $oldPath) {
|
258 |
$this->_deleteFile($oldPath);
|
259 |
}
|
|
|
|
|
260 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
return $this;
|
262 |
}
|
263 |
|
|
|
264 |
/**
|
265 |
* @return Lanot_EasyBanner_Model_Banner
|
266 |
*/
|
20 |
|
21 |
class Lanot_EasyBanner_Model_Banner
|
22 |
extends Mage_Core_Model_Abstract
|
23 |
+
implements Lanot_Core_Model_Item_Interface
|
24 |
+
{
|
25 |
const STATUS_ENABLED = 1;
|
26 |
const STATUS_DISABLED = 0;
|
27 |
|
28 |
+
const TYPE_ID_FILE = 'file';
|
29 |
+
const TYPE_ID_CUSTOM = 'custom';
|
30 |
+
|
31 |
/**
|
32 |
* @var array
|
33 |
*/
|
43 |
$this->_init('lanot_easybanner/banner');
|
44 |
}
|
45 |
|
46 |
+
/**
|
47 |
+
* @return Lanot_EasyBanner_Model_Banner
|
48 |
+
*/
|
49 |
+
protected function _afterLoad()
|
50 |
+
{
|
51 |
+
parent::_afterLoad();
|
52 |
+
$this->_prepareTypeId();
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
/**
|
57 |
* @return Lanot_EasyBanner_Helper_Data
|
58 |
*/
|
61 |
return Mage::helper('lanot_easybanner');
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
+
* @return Lanot_EasyBanner_Model_Banner
|
66 |
+
*/
|
67 |
+
protected function _prepareTypeId()
|
68 |
+
{
|
69 |
+
if (!$this->getData('type_id')) {
|
70 |
+
if ($this->getType() == self::TYPE_ID_CUSTOM) {
|
71 |
+
$this->setData('type_id', self::TYPE_ID_CUSTOM);
|
72 |
+
} else {
|
73 |
+
$this->setData('type_id', self::TYPE_ID_FILE);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
public function getTypeId()
|
83 |
+
{
|
84 |
+
if (!$this->hasData('type_id')) {
|
85 |
+
$this->setData('type_id', self::TYPE_ID_FILE);
|
86 |
+
}
|
87 |
+
return $this->getData('type_id');
|
88 |
+
}
|
89 |
+
|
90 |
/**
|
91 |
* @return array
|
92 |
*/
|
114 |
return self::STATUS_ENABLED;
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* @return array
|
119 |
+
*/
|
120 |
+
public function getAvailableTypes()
|
121 |
+
{
|
122 |
+
return array(
|
123 |
+
self::TYPE_ID_FILE => $this->_getHelper()->__('File (Image, Flash)'),
|
124 |
+
self::TYPE_ID_CUSTOM => $this->_getHelper()->__('Custom Code (Html, Embed Code)'),
|
125 |
+
);
|
126 |
+
}
|
127 |
+
|
128 |
/**
|
129 |
* @return array
|
130 |
*/
|
132 |
{
|
133 |
$this->prepareExtensions();
|
134 |
return $this->_extensions;
|
|
|
135 |
}
|
136 |
|
137 |
/**
|
191 |
*/
|
192 |
public function getPathUrl()
|
193 |
{
|
194 |
+
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $this->getMediaPath() . $this->getPath();
|
|
|
|
|
195 |
}
|
196 |
|
197 |
/**
|
218 |
}
|
219 |
$this->setData('updated_at', Varien_Date::now());
|
220 |
|
221 |
+
|
222 |
+
if ($this->getTypeId() == self::TYPE_ID_CUSTOM) {
|
223 |
+
$this->_prepareCodeInfo();
|
224 |
+
} else {
|
225 |
+
$this->_prepareFileInfo();
|
226 |
+
}
|
227 |
+
|
228 |
$this->_prepareCategories();
|
229 |
|
230 |
return $this;
|
287 |
*/
|
288 |
protected function _prepareFileInfo()
|
289 |
{
|
290 |
+
$this->setCode(null);
|
291 |
+
|
292 |
//upload file
|
293 |
$fileData = $this->getBannerFile();
|
294 |
$isPathDeleted = (is_array($fileData) && !empty($fileData['delete']));
|
313 |
if (null !== $oldPath) {
|
314 |
$this->_deleteFile($oldPath);
|
315 |
}
|
316 |
+
} elseif($this->getType() == self::TYPE_ID_CUSTOM) {
|
317 |
+
$this->setType(null);
|
318 |
}
|
319 |
+
|
320 |
+
return $this;
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* @return Lanot_EasyBanner_Model_Banner
|
325 |
+
*/
|
326 |
+
protected function _prepareCodeInfo()
|
327 |
+
{
|
328 |
+
$this->setPath(null);
|
329 |
+
$this->setUrl(null);
|
330 |
+
$this->setWidth(null);
|
331 |
+
$this->setHeight(null);
|
332 |
+
$this->setType(self::TYPE_ID_CUSTOM);
|
333 |
+
|
334 |
return $this;
|
335 |
}
|
336 |
|
337 |
+
|
338 |
/**
|
339 |
* @return Lanot_EasyBanner_Model_Banner
|
340 |
*/
|
app/code/community/Lanot/EasyBanner/Model/Category.php
CHANGED
@@ -18,7 +18,9 @@
|
|
18 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
*/
|
20 |
|
21 |
-
class Lanot_EasyBanner_Model_Category
|
|
|
|
|
22 |
{
|
23 |
const STATUS_ENABLED = 1;
|
24 |
const STATUS_DISABLED = 0;
|
18 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
*/
|
20 |
|
21 |
+
class Lanot_EasyBanner_Model_Category
|
22 |
+
extends Mage_Core_Model_Abstract
|
23 |
+
implements Lanot_Core_Model_Item_Interface
|
24 |
{
|
25 |
const STATUS_ENABLED = 1;
|
26 |
const STATUS_DISABLED = 0;
|
app/code/community/Lanot/EasyBanner/Model/Mysql4/Banner/Collection.php
CHANGED
@@ -55,7 +55,6 @@ extends Mage_Core_Model_Mysql4_Collection_Abstract
|
|
55 |
public function useRandom()
|
56 |
{
|
57 |
$this->getSelect()->order(new Zend_Db_Expr('RAND()'));
|
58 |
-
|
59 |
return $this;
|
60 |
}
|
61 |
|
@@ -65,7 +64,6 @@ extends Mage_Core_Model_Mysql4_Collection_Abstract
|
|
65 |
public function useLast()
|
66 |
{
|
67 |
$this->setOrder('main_table.banner_id','DESC');
|
68 |
-
|
69 |
return $this;
|
70 |
}
|
71 |
|
@@ -74,9 +72,7 @@ extends Mage_Core_Model_Mysql4_Collection_Abstract
|
|
74 |
*/
|
75 |
public function useActive()
|
76 |
{
|
77 |
-
$this->addFilter('main_table.is_active',
|
78 |
-
Lanot_EasyBanner_Model_Banner::STATUS_ENABLED);
|
79 |
-
|
80 |
return $this;
|
81 |
}
|
82 |
}
|
55 |
public function useRandom()
|
56 |
{
|
57 |
$this->getSelect()->order(new Zend_Db_Expr('RAND()'));
|
|
|
58 |
return $this;
|
59 |
}
|
60 |
|
64 |
public function useLast()
|
65 |
{
|
66 |
$this->setOrder('main_table.banner_id','DESC');
|
|
|
67 |
return $this;
|
68 |
}
|
69 |
|
72 |
*/
|
73 |
public function useActive()
|
74 |
{
|
75 |
+
$this->addFilter('main_table.is_active', Lanot_EasyBanner_Model_Banner::STATUS_ENABLED);
|
|
|
|
|
76 |
return $this;
|
77 |
}
|
78 |
}
|
app/code/community/Lanot/EasyBanner/Model/Widget/Instance.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Lanot
|
16 |
+
* @package Lanot_EasyBanner
|
17 |
+
* @copyright Copyright (c) 2012 Lanot
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Magento core model rewrite
|
23 |
+
*
|
24 |
+
* @author Lanot
|
25 |
+
*/
|
26 |
+
class Lanot_EasyBanner_Model_Widget_Instance extends Mage_Widget_Model_Widget_Instance
|
27 |
+
{
|
28 |
+
protected $_eventPrefix = 'widget_instance';
|
29 |
+
protected $_eventObject = 'widget_instance';
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Generate layout update xml
|
33 |
+
*
|
34 |
+
* @param string $blockReference
|
35 |
+
* @param string $position
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function generateLayoutUpdateXml($blockReference, $templatePath = '')
|
39 |
+
{
|
40 |
+
$xml = parent::generateLayoutUpdateXml($blockReference, $templatePath);
|
41 |
+
|
42 |
+
if ($xml && ($this->getSortOrder() == 0) && (strpos($xml, 'before=') === false)) {
|
43 |
+
$xml = str_replace('<block ', '<block before="-" ', $xml);
|
44 |
+
}
|
45 |
+
|
46 |
+
return $xml;
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Lanot/EasyBanner/controllers/Adminhtml/BannerController.php
CHANGED
@@ -45,7 +45,7 @@ class Lanot_EasyBanner_Adminhtml_BannerController
|
|
45 |
|
46 |
/**
|
47 |
* @param Mage_Core_Model_Abstract $model
|
48 |
-
* @return
|
49 |
*/
|
50 |
protected function _registerItem(Mage_Core_Model_Abstract $model)
|
51 |
{
|
45 |
|
46 |
/**
|
47 |
* @param Mage_Core_Model_Abstract $model
|
48 |
+
* @return Lanot_EasyBanner_Adminhtml_BannerController
|
49 |
*/
|
50 |
protected function _registerItem(Mage_Core_Model_Abstract $model)
|
51 |
{
|
app/code/community/Lanot/EasyBanner/etc/config.xml
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
|
4 |
<modules>
|
5 |
<Lanot_EasyBanner>
|
6 |
-
<version>1.
|
7 |
</Lanot_EasyBanner>
|
8 |
</modules>
|
9 |
|
@@ -41,6 +41,12 @@
|
|
41 |
</banner_category>
|
42 |
</entities>
|
43 |
</lanot_easybanner_resource>
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
</models>
|
45 |
|
46 |
<!-- MySQL INSTALL SCRIPTS -->
|
@@ -80,6 +86,7 @@
|
|
80 |
<renderers>
|
81 |
<image>lanot_easybanner/banner_renderer_image</image>
|
82 |
<flash>lanot_easybanner/banner_renderer_flash</flash>
|
|
|
83 |
</renderers>
|
84 |
</lanot_easybanner>
|
85 |
|
3 |
|
4 |
<modules>
|
5 |
<Lanot_EasyBanner>
|
6 |
+
<version>1.1.1.0</version>
|
7 |
</Lanot_EasyBanner>
|
8 |
</modules>
|
9 |
|
41 |
</banner_category>
|
42 |
</entities>
|
43 |
</lanot_easybanner_resource>
|
44 |
+
|
45 |
+
<widget>
|
46 |
+
<rewrite>
|
47 |
+
<widget_instance>Lanot_EasyBanner_Model_Widget_Instance</widget_instance>
|
48 |
+
</rewrite>
|
49 |
+
</widget>
|
50 |
</models>
|
51 |
|
52 |
<!-- MySQL INSTALL SCRIPTS -->
|
86 |
<renderers>
|
87 |
<image>lanot_easybanner/banner_renderer_image</image>
|
88 |
<flash>lanot_easybanner/banner_renderer_flash</flash>
|
89 |
+
<custom>lanot_easybanner/banner_renderer_custom</custom>
|
90 |
</renderers>
|
91 |
</lanot_easybanner>
|
92 |
|
app/code/community/Lanot/EasyBanner/sql/lanot_easybanner_setup/mysql4-upgrade-1.0.1.0-1.1.0.0.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Lanot
|
16 |
+
* @package Lanot_EasyBanner
|
17 |
+
* @copyright Copyright (c) 2012 Lanot
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
$installer = $this;
|
22 |
+
|
23 |
+
$installer->startSetup();
|
24 |
+
|
25 |
+
//tables definition
|
26 |
+
$bannerTable = $installer->getTable('lanot_easybanner/banner');
|
27 |
+
|
28 |
+
//add column `code`
|
29 |
+
$this->run("ALTER TABLE `{$bannerTable}` ADD `code` TEXT DEFAULT NULL AFTER `description`");
|
30 |
+
|
31 |
+
$this->endSetup();
|
app/design/adminhtml/default/default/template/lanot/easybanner/widget/form/renderer/fieldset.phtml
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php $_element = $this->getElement() ?>
|
28 |
+
<?php if ($_element->getFieldsetContainerId()): ?>
|
29 |
+
<div id="<?php echo $_element->getFieldsetContainerId(); ?>" <?php if ($_element->getFieldsetContainerClass()): ?>class="<?php echo $_element->getFieldsetContainerClass(); ?>" <?php endif;?>>
|
30 |
+
<?php endif; ?>
|
31 |
+
<?php if ($_element->getLegend()): ?>
|
32 |
+
<div class="entry-edit-head">
|
33 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo $_element->getLegend() ?></h4>
|
34 |
+
<div class="form-buttons"><?php echo $_element->getHeaderBar() ?></div>
|
35 |
+
</div>
|
36 |
+
<?php endif; ?>
|
37 |
+
<?php if (!$_element->getNoContainer()): ?>
|
38 |
+
<div class="fieldset <?php echo $_element->getClass() ?>" id="<?php echo $_element->getHtmlId() ?>">
|
39 |
+
<?php endif; ?>
|
40 |
+
<div class="hor-scroll">
|
41 |
+
<?php if ($_element->getComment()): ?>
|
42 |
+
<p class="comment"><?php echo $this->escapeHtml($_element->getComment()) ?></p>
|
43 |
+
<?php endif; ?>
|
44 |
+
<?php if ($_element->hasHtmlContent()): ?>
|
45 |
+
<?php echo $_element->getHtmlContent(); ?>
|
46 |
+
<?php else: ?>
|
47 |
+
<table cellspacing="0" class="<?php echo $_element->hasTableClass() ? $_element->getTableClass() : 'form-list'?>">
|
48 |
+
<tbody>
|
49 |
+
<?php echo $_element->getChildrenHtml(); ?>
|
50 |
+
</tbody>
|
51 |
+
</table>
|
52 |
+
<?php endif; ?>
|
53 |
+
</div>
|
54 |
+
<?php echo $_element->getSubFieldsetHtml() ?>
|
55 |
+
<?php if (!$_element->getNoContainer()): ?>
|
56 |
+
</div>
|
57 |
+
<?php endif; ?>
|
58 |
+
<?php if ($_element->getFieldsetContainerId()): ?>
|
59 |
+
</div>
|
60 |
+
<?php endif; ?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lanot_EasyBanner</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
@@ -12,14 +12,15 @@
|
|
12 |
<description>First release of module:
|
13 |
1. Managing banners and banner categories
|
14 |
2. Prepared widget for banners rotation</description>
|
15 |
-
<notes>
|
16 |
-
|
17 |
-
2.
|
|
|
18 |
Uploaded for Magento Connect 2.0</notes>
|
19 |
-
<authors><author><name>Lanot</name><user>
|
20 |
-
<date>
|
21 |
-
<time>
|
22 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Lanot_EasyBanner.xml" hash="273ba017ba61426ff63b69f81ceadf17"/></dir></target><target name="magecommunity"><dir name="Lanot"><dir name="EasyBanner"><dir name="Block"><dir name="Adminhtml"><dir name="Banner"><dir name="Edit"><
|
23 |
<compatible/>
|
24 |
-
<dependencies
|
25 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lanot_EasyBanner</name>
|
4 |
+
<version>1.1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
12 |
<description>First release of module:
|
13 |
1. Managing banners and banner categories
|
14 |
2. Prepared widget for banners rotation</description>
|
15 |
+
<notes>1. Added new field "Custom Code" for Embeded Html/Flash Code.
|
16 |
+

|
17 |
+
2. Added feature that fixes native Magento bug with widgets ordering on page. Now to output widget before all - just put value "0" to the field "Sort Order".
|
18 |
+

|
19 |
Uploaded for Magento Connect 2.0</notes>
|
20 |
+
<authors><author><name>Lanot</name><user>auto-converted</user><email>lanot.biz@gmail.com</email></author></authors>
|
21 |
+
<date>2013-01-26</date>
|
22 |
+
<time>10:06:22</time>
|
23 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Lanot_EasyBanner.xml" hash="273ba017ba61426ff63b69f81ceadf17"/></dir></target><target name="magecommunity"><dir name="Lanot"><dir name="EasyBanner"><dir name="Block"><dir name="Adminhtml"><dir name="Banner"><dir name="Edit"><dir name="Tab"><file name="Categories.php" hash="f0257286002d647ec20ad6e8fda6a519"/><file name="Main.php" hash="79cdcadbb6175a00fdb4f00775834fa3"/></dir><file name="Form.php" hash="625c5be13eefa416166822c5e9808735"/><file name="Tabs.php" hash="fad2873cc2a30d9e96f3011321bd2967"/></dir><file name="Edit.php" hash="de45f2c7663c84d538830ebd6a90faa6"/><file name="Grid.php" hash="f118b433daa7616279c41207da81f84e"/></dir><dir name="Category"><dir name="Edit"><dir name="Tab"><file name="Banners.php" hash="f3e4f0add2a4dd34a2f9850175d2d8c1"/><file name="Main.php" hash="f6442a263d27a1176b61ed8ab5ad57b0"/></dir><file name="Form.php" hash="a0a5880c32be1c48bd656df9927770d2"/><file name="Tabs.php" hash="0bbd1e95ff227b9b3dea47df4896aaca"/></dir><file name="Edit.php" hash="d21f4789e92be2ee956d468c1301f078"/><file name="Grid.php" hash="46fcc38c036253c5174554204bb07770"/></dir><dir name="Grid"><file name="Abstract.php" hash="52ba05e1a7598043dcc7baffe014a9fe"/></dir><dir name="Renderer"><file name="Banner.php" hash="14f6b39e75f66763583e13ed7762ff17"/></dir><file name="Banner.php" hash="86f631a4e53cdc33ecde372603f10383"/><file name="Category.php" hash="5d7b4d0a98da5a5760a5ee0dd7ffcd14"/></dir><dir name="Banner"><dir name="Renderer"><file name="Abstract.php" hash="0c95b8dcc6718cece7ba1e92cfb73a04"/><file name="Custom.php" hash="9b495242c3ac5bc154bcb5f7bcebd9dc"/><file name="Flash.php" hash="bb721a11875826e1cb658b5bc6dd5bba"/><file name="Image.php" hash="00793dd76a9b5b7bc94e643fc47ae205"/></dir></dir><dir name="Widget"><file name="Banners.php" hash="b4dbf8fecee3f04118c07482316d2f67"/></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="AbstractController.php" hash="6d5194b725748352733fcea7076e1c46"/></dir></dir><dir name="Helper"><file name="Admin.php" hash="24f06226a48455294475be1dec8f95a8"/><file name="Data.php" hash="b04e281337d392437e58c6df452abe1c"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Banner"><file name="Collection.php" hash="311b0c2ef352ccf311b1c94fd6d4399c"/></dir><dir name="Category"><file name="Collection.php" hash="13a499e8951138bd82a4e381ffc01f9c"/></dir><file name="Banner.php" hash="3b130f81fab23450f2941a61465eb315"/><file name="Category.php" hash="5cd283cc2f69699f15e31f3ce77668c2"/></dir><dir name="Widget"><file name="Instance.php" hash="3a1f4ab3f3230a0a4d88c9598bba9b4c"/></dir><file name="Banner.php" hash="15a0eb509b78140d7cd140a3d1b7cf40"/><file name="Category.php" hash="4345e5d6fe7757b12cab2a2eb02c526a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="BannerController.php" hash="a4d8469959c968f6035672d08549850b"/><file name="CategoryController.php" hash="6330b90002bffad43e512a123f3b7fc2"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="45883fcc010c975f8dc8d59f1b551c51"/><file name="config.xml" hash="c0c390e558461d1b42fd428db798aa44"/><file name="system.xml" hash="14b36d1b55e5cb18ee35b93a636e4967"/><file name="widget.xml" hash="5f55fb3c9b308936c3fe2a1f7cabbd37"/></dir><dir name="sql"><dir name="lanot_easybanner_setup"><file name="mysql4-install-1.0.0.0.php" hash="186135eeadca5ed3b8590561c9dcf19b"/><file name="mysql4-upgrade-1.0.1.0-1.1.0.0.php" hash="0b1c60650ce4d5a54561d5cf52c021cb"/></dir></dir></dir><dir name="Core"><dir name="Block"><dir name="Adminhtml"><dir name="Grid"><file name="Abstract.php" hash="fd0a241fb2cf4f42a732ba72dc4b8d5d"/></dir></dir></dir><dir name="Controller"><dir name="Adminhtml"><file name="AbstractController.php" hash="9ebfaeab2c78fbe828449695f34bd733"/></dir></dir><dir name="Model"><dir name="Item"><file name="Interface.php" hash="19a7bde224ad3eb288119e9f36ca43e0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="lanot"><dir name="easybanner"><file name="banners.phtml" hash="6d1879f31e40c2462056852af645650f"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lanot_easybanner.xml" hash="94542a0c03411ab9703b374407bebd17"/></dir><dir name="template"><dir name="lanot"><dir name="easybanner"><dir name="widget"><dir name="form"><dir name="renderer"><file name="fieldset.phtml" hash="0d6eb989d50e5ac518999eb3caa79a00"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
24 |
<compatible/>
|
25 |
+
<dependencies/>
|
26 |
</package>
|