Version Notes
This module was tested in Magento Commerce version 1.4.0.1, 1.5.0.1 and 1.6.2.0, and work in this version smoothly. Also test in Firefox 3.6, Chrome, Opera and IE 7,8,9.
Download this release
Release Info
Developer | Magento Core Team |
Extension | PSystem_ProductSlider |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item.php +20 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit.php +43 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit/Form.php +30 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit/Tab/Form.php +166 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit/Tabs.php +25 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Grid.php +59 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider.php +20 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit.php +33 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit/Form.php +19 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit/Tab/Form.php +102 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit/Tabs.php +25 -0
- app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Grid.php +48 -0
- app/code/community/PSystem/ProductSlider/Block/Slider.php +258 -0
- app/code/community/PSystem/ProductSlider/Helper/Data.php +116 -0
- app/code/community/PSystem/ProductSlider/Model/Item.php +16 -0
- app/code/community/PSystem/ProductSlider/Model/Mysql4/Item.php +16 -0
- app/code/community/PSystem/ProductSlider/Model/Mysql4/Item/Collection.php +16 -0
- app/code/community/PSystem/ProductSlider/Model/Mysql4/Slider.php +16 -0
- app/code/community/PSystem/ProductSlider/Model/Mysql4/Slider/Collection.php +16 -0
- app/code/community/PSystem/ProductSlider/Model/Slider.php +16 -0
- app/code/community/PSystem/ProductSlider/controllers/Adminhtml/ItemController.php +184 -0
- app/code/community/PSystem/ProductSlider/controllers/Adminhtml/SliderController.php +107 -0
- app/code/community/PSystem/ProductSlider/etc/adminhtml.xml +59 -0
- app/code/community/PSystem/ProductSlider/etc/config.xml +93 -0
- app/code/community/PSystem/ProductSlider/etc/system.xml +146 -0
- app/code/community/PSystem/ProductSlider/sql/productslider_setup/mysql4-install-1.0.0.php +57 -0
- app/design/adminhtml/default/default/layout/ps_productslider.xml +17 -0
- app/design/frontend/default/default/layout/ps_productslider.xml +22 -0
- app/design/frontend/default/default/template/productslider/slider.phtml +119 -0
- app/etc/modules/PSystem_ProductSlider.xml +20 -0
- app/locale/en_US/PSystem_ProductSlider.csv +50 -0
- js/pascalsystem/productslider.js +147 -0
- package.xml +21 -0
- skin/frontend/default/default/css/pascalsystem/productslider.css +111 -0
- skin/frontend/default/default/images/pascalsystem/productslider-point.png +0 -0
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Item extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
9 |
+
/**
|
10 |
+
* Constructor backend widget grid container
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
public function __construct() {
|
14 |
+
$this->_controller = 'adminhtml_item';
|
15 |
+
$this->_blockGroup = 'productslider';
|
16 |
+
$this->_headerText = Mage::helper('productslider')->__('Slider Item Manager');
|
17 |
+
$this->_addButtonLabel = Mage::helper('productslider')->__('Add Slider Item');
|
18 |
+
parent::__construct();
|
19 |
+
}
|
20 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Item_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
9 |
+
/**
|
10 |
+
* Form container constructor
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$this->_objectId = 'id';
|
16 |
+
$this->_blockGroup = 'productslider';
|
17 |
+
$this->_controller = 'adminhtml_item';
|
18 |
+
$this->_updateButton('save', 'label', Mage::helper('productslider')->__('Save Slider Item'));
|
19 |
+
$this->_updateButton('delete', 'label', Mage::helper('productslider')->__('Delete Slider Item'));
|
20 |
+
|
21 |
+
$this->_formScripts[] = "
|
22 |
+
function toggleEditor() {
|
23 |
+
if (tinyMCE.getInstanceById('html') == null) {
|
24 |
+
tinyMCE.execCommand('mceAddControl', false, 'html');
|
25 |
+
} else {
|
26 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'html');
|
27 |
+
}
|
28 |
+
}
|
29 |
+
";
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Prepare header text
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
public function getHeaderText() {
|
37 |
+
if( Mage::registry('productslider_item_data') && Mage::registry('productslider_item_data')->getId() ) {
|
38 |
+
return Mage::helper('productslider')->__("Edit Slider Item '%s'", $this->htmlEscape(Mage::registry('productslider_item_data')->getId()));
|
39 |
+
} else {
|
40 |
+
return Mage::helper('productslider')->__('Add Slider Item');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit/Form.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Item_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
9 |
+
/**
|
10 |
+
* Load Wysiwyg on demand and Prepare layout
|
11 |
+
*/
|
12 |
+
protected function _prepareLayout() {
|
13 |
+
parent::_prepareLayout();
|
14 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
15 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareForm() {
|
20 |
+
$form = new Varien_Data_Form(array(
|
21 |
+
'id' => 'edit_form',
|
22 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
23 |
+
'method' => 'post',
|
24 |
+
'enctype'=>'multipart/form-data',
|
25 |
+
));
|
26 |
+
$form->setUseContainer(true);
|
27 |
+
$this->setForm($form);
|
28 |
+
return parent::_prepareForm();
|
29 |
+
}
|
30 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Item_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
9 |
+
protected function _prepareForm() {
|
10 |
+
$form = new Varien_Data_Form();
|
11 |
+
|
12 |
+
$this->setForm($form);
|
13 |
+
$fieldset = $form->addFieldset('productslider_form', array('legend'=>Mage::helper('productslider')->__('Slider Item Information')));
|
14 |
+
|
15 |
+
$optProducts = array(''=>'');
|
16 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSort('sku');
|
17 |
+
foreach ($products as $product) {
|
18 |
+
$optProducts[$product->getId()] = $product->getSku();
|
19 |
+
}
|
20 |
+
unset($products);
|
21 |
+
|
22 |
+
$optCategories = array(''=>'');
|
23 |
+
$this->_buildCategoryTree($optCategories);
|
24 |
+
|
25 |
+
$optPages = array(''=>'');
|
26 |
+
$pages = Mage::getModel('cms/page')->getCollection();
|
27 |
+
$select = $pages->getSelect()->order('title');
|
28 |
+
foreach ($pages as $page) {
|
29 |
+
$optPages[$page->getId()] = $page->getTitle().' ['.$page->getId().']';
|
30 |
+
}
|
31 |
+
|
32 |
+
$optSliders = array(''=>'');
|
33 |
+
$sliders = Mage::getModel('productslider/slider')->getCollection();
|
34 |
+
$sliders->getSelect()->order('identifier');
|
35 |
+
foreach ($sliders as $slider) {
|
36 |
+
$optSliders[$slider->getId()] = $slider->getData('identifier');
|
37 |
+
}
|
38 |
+
|
39 |
+
$wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
|
40 |
+
array('tab_id' => $this->getTabId())
|
41 |
+
);
|
42 |
+
|
43 |
+
$fieldset->addField('title', 'text', array(
|
44 |
+
'label' => Mage::helper('productslider')->__('Slider Item Title'),
|
45 |
+
'name' => 'title',
|
46 |
+
));
|
47 |
+
$fieldset->addField('slider_id', 'select', array(
|
48 |
+
'label' => Mage::helper('productslider')->__('Slider Identifier'),
|
49 |
+
'name' => 'slider_id',
|
50 |
+
'class' => 'required-entry',
|
51 |
+
'required' => true,
|
52 |
+
'options' => $optSliders,
|
53 |
+
));
|
54 |
+
$image1 = $fieldset->addField('image1', 'image', array(
|
55 |
+
'label' => Mage::helper('productslider')->__('Slider Item Background'),
|
56 |
+
'class' => 'input-file',
|
57 |
+
'name' => 'image1',
|
58 |
+
));
|
59 |
+
$fieldset->addField('product_id', 'select', array(
|
60 |
+
'label' => Mage::helper('productslider')->__('Slider Item Product'),
|
61 |
+
'name' => 'product_id',
|
62 |
+
'options' => $optProducts,
|
63 |
+
));
|
64 |
+
$fieldset->addField('category_id', 'select', array(
|
65 |
+
'label' => Mage::helper('productslider')->__('Slider Item Category'),
|
66 |
+
'name' => 'category_id',
|
67 |
+
'options' => $optCategories,
|
68 |
+
));
|
69 |
+
$fieldset->addField('page_id', 'select', array(
|
70 |
+
'label' => Mage::helper('productslider')->__('Slider Item Page'),
|
71 |
+
'name' => 'page_id',
|
72 |
+
'options' => $optPages,
|
73 |
+
));
|
74 |
+
$image2 = $fieldset->addField('image2', 'image', array(
|
75 |
+
'label' => Mage::helper('productslider')->__('Slider Item Page Image'),
|
76 |
+
'class' => 'input-file',
|
77 |
+
'name' => 'image2',
|
78 |
+
));
|
79 |
+
$fieldset->addField('internal_url', 'text', array(
|
80 |
+
'label' => Mage::helper('productslider')->__('Slider Internal URL'),
|
81 |
+
'name' => 'internal_url',
|
82 |
+
));
|
83 |
+
$image3 = $fieldset->addField('image3', 'image', array(
|
84 |
+
'label' => Mage::helper('productslider')->__('Slider Item Image Internal Url'),
|
85 |
+
'class' => 'input-file',
|
86 |
+
'name' => 'image3',
|
87 |
+
));
|
88 |
+
$fieldset->addField('external_url', 'text', array(
|
89 |
+
'label' => Mage::helper('productslider')->__('Slider External URL'),
|
90 |
+
'name' => 'external_url',
|
91 |
+
));
|
92 |
+
$image4 = $fieldset->addField('image4', 'image', array(
|
93 |
+
'label' => Mage::helper('productslider')->__('Slider Item Image External Url'),
|
94 |
+
'class' => 'input-file',
|
95 |
+
'name' => 'image4',
|
96 |
+
));
|
97 |
+
$fieldset->addField('description', 'textarea', array(
|
98 |
+
'label' => Mage::helper('productslider')->__('Slider Item Description'),
|
99 |
+
'class' => 'textarea',
|
100 |
+
'name' => 'description',
|
101 |
+
));
|
102 |
+
$fieldset->addField('html', 'editor', array(
|
103 |
+
'label' => Mage::helper('productslider')->__('Slider Item Content'),
|
104 |
+
'name' => 'html',
|
105 |
+
'style' => 'height:200px;',
|
106 |
+
'config' => $wysiwygConfig,
|
107 |
+
));
|
108 |
+
$fieldset->addField('active', 'select', array(
|
109 |
+
'label' => Mage::helper('productslider')->__('Slider Item Active'),
|
110 |
+
'name' => 'active',
|
111 |
+
'options' => array(
|
112 |
+
0 => $this->__('No'),
|
113 |
+
1 => $this->__('Yes'),
|
114 |
+
)
|
115 |
+
));
|
116 |
+
$fieldset->addField('priority', 'text', array(
|
117 |
+
'label' => Mage::helper('productslider')->__('Slider Item Priority'),
|
118 |
+
'name' => 'priority',
|
119 |
+
));
|
120 |
+
|
121 |
+
if (Mage::getSingleton('adminhtml/session')->getProductSliderData()) {
|
122 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getProductSliderData());
|
123 |
+
Mage::getSingleton('adminhtml/session')->setProductSliderData(null);
|
124 |
+
} elseif (Mage::registry('productslider_item_data')) {
|
125 |
+
$form->setValues(Mage::registry('productslider_item_data')->getData());
|
126 |
+
}
|
127 |
+
|
128 |
+
$mediaDir = Mage::helper('productslider')->getProductSliderDirectory();
|
129 |
+
if ($fileName = $image1->getValue()) {
|
130 |
+
$image1->setValue($mediaDir.'/'.$fileName);
|
131 |
+
}
|
132 |
+
if ($fileName = $image2->getValue()) {
|
133 |
+
$image2->setValue($mediaDir.'/'.$fileName);
|
134 |
+
}
|
135 |
+
if ($fileName = $image3->getValue()) {
|
136 |
+
$image3->setValue($mediaDir.'/'.$fileName);
|
137 |
+
}
|
138 |
+
if ($fileName = $image4->getValue()) {
|
139 |
+
$image4->setValue($mediaDir.'/'.$fileName);
|
140 |
+
}
|
141 |
+
|
142 |
+
return parent::_prepareForm();
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Build categories select with level
|
147 |
+
*
|
148 |
+
* @return array
|
149 |
+
*/
|
150 |
+
protected function _buildCategoryTree(array &$results, $parent = null, $level = 0) {
|
151 |
+
$collection = Mage::getModel('catalog/category')->getCollection();
|
152 |
+
$collection->addAttributeToSelect('name')
|
153 |
+
->addAttributeToSort('name');
|
154 |
+
$where = ($parent)?'e.parent_id='.intval($parent):'e.level=1';
|
155 |
+
$select = $collection->getSelect()->where($where);
|
156 |
+
foreach ($collection as $category) {
|
157 |
+
$name = '';
|
158 |
+
for ($i=0;$i<$level;$i++) {
|
159 |
+
$name.= ' - ';
|
160 |
+
}
|
161 |
+
$name.= $category->getName();
|
162 |
+
$results[$category->getId()] = $name;
|
163 |
+
$this->_buildCategoryTree($results, $category->getId(), $level+1);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Edit/Tabs.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Item_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
9 |
+
public function __construct() {
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('productslider_tabs');
|
12 |
+
$this->setDestElementId('edit_form');
|
13 |
+
$this->setTitle(Mage::helper('productslider')->__('Slider Item Information'));
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _beforeToHtml() {
|
17 |
+
$this->addTab('form_section', array(
|
18 |
+
'label' => Mage::helper('productslider')->__('Slider Item Information'),
|
19 |
+
'title' => Mage::helper('productslider')->__('Slider Item Information'),
|
20 |
+
'content' => $this->getLayout()->createBlock('productslider/adminhtml_item_edit_tab_form')->toHtml(),
|
21 |
+
));
|
22 |
+
|
23 |
+
return parent::_beforeToHtml();
|
24 |
+
}
|
25 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Item/Grid.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Item_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
9 |
+
public function __construct() {
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('productsliderGrid');
|
12 |
+
// This is the primary key of the database
|
13 |
+
$this->setDefaultSort('item_id');
|
14 |
+
$this->setDefaultDir('ASC');
|
15 |
+
$this->setSaveParametersInSession(true);
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function _prepareCollection() {
|
19 |
+
$collection = Mage::getModel('productslider/item')->getCollection();
|
20 |
+
$this->setCollection($collection);
|
21 |
+
return parent::_prepareCollection();
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareColumns() {
|
25 |
+
$this->addColumn('item_id', array(
|
26 |
+
'header' => Mage::helper('productslider')->__('Slider Item ID'),
|
27 |
+
'align' => 'right',
|
28 |
+
'width' => '50px',
|
29 |
+
'index' => 'item_id',
|
30 |
+
));
|
31 |
+
$this->addColumn('title', array(
|
32 |
+
'header' => Mage::helper('productslider')->__('Slider Item Title'),
|
33 |
+
'align' => 'left',
|
34 |
+
'index' => 'title',
|
35 |
+
));
|
36 |
+
$this->addColumn('active', array(
|
37 |
+
'header' => Mage::helper('productslider')->__('Slider Item Active'),
|
38 |
+
'align' => 'left',
|
39 |
+
'index' => 'active',
|
40 |
+
'type' => 'options',
|
41 |
+
'options' => array(
|
42 |
+
0 => Mage::helper('cms')->__('No'),
|
43 |
+
1 => Mage::helper('cms')->__('Yes')
|
44 |
+
),
|
45 |
+
));
|
46 |
+
$this->addColumn('priority', array(
|
47 |
+
'header' => Mage::helper('productslider')->__('Slider Item Priority'),
|
48 |
+
'align' => 'left',
|
49 |
+
'width' => '100px',
|
50 |
+
'index' => 'priority',
|
51 |
+
));
|
52 |
+
|
53 |
+
return parent::_prepareColumns();
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getRowUrl($row) {
|
57 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
58 |
+
}
|
59 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Slider extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
9 |
+
/**
|
10 |
+
* Constructor backend widget grid container
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
public function __construct() {
|
14 |
+
$this->_controller = 'adminhtml_slider';
|
15 |
+
$this->_blockGroup = 'productslider';
|
16 |
+
$this->_headerText = Mage::helper('productslider')->__('Slider Manager');
|
17 |
+
$this->_addButtonLabel = Mage::helper('productslider')->__('Add Slider');
|
18 |
+
parent::__construct();
|
19 |
+
}
|
20 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Slider_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
9 |
+
/**
|
10 |
+
* Form container constructor
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$this->_objectId = 'id';
|
16 |
+
$this->_blockGroup = 'productslider';
|
17 |
+
$this->_controller = 'adminhtml_slider';
|
18 |
+
$this->_updateButton('save', 'label', Mage::helper('productslider')->__('Save Slider'));
|
19 |
+
$this->_updateButton('delete', 'label', Mage::helper('productslider')->__('Delete Slider'));
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Prepare header text
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
public function getHeaderText() {
|
27 |
+
if( Mage::registry('productslider_slider_data') && Mage::registry('productslider_slider_data')->getId() ) {
|
28 |
+
return Mage::helper('productslider')->__("Edit Slider '%s'", $this->htmlEscape(Mage::registry('productslider_slider_data')->getId()));
|
29 |
+
} else {
|
30 |
+
return Mage::helper('productslider')->__('Add Slider');
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Slider_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
9 |
+
protected function _prepareForm() {
|
10 |
+
$form = new Varien_Data_Form(array(
|
11 |
+
'id' => 'edit_form',
|
12 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
13 |
+
'method' => 'post',
|
14 |
+
));
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Slider_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
9 |
+
protected function _prepareForm() {
|
10 |
+
$form = new Varien_Data_Form();
|
11 |
+
$this->setForm($form);
|
12 |
+
$fieldset = $form->addFieldset('productslider_form', array('legend'=>Mage::helper('productslider')->__('Slider information')));
|
13 |
+
$zeroBugs = array();
|
14 |
+
|
15 |
+
$fieldset->addField('identifier', 'text', array(
|
16 |
+
'label' => Mage::helper('productslider')->__('Slider Identifier'),
|
17 |
+
'class' => 'validate-xml-identifier',
|
18 |
+
'required' => true,
|
19 |
+
'name' => 'identifier',
|
20 |
+
));
|
21 |
+
$fieldset->addField('title', 'text', array(
|
22 |
+
'label' => Mage::helper('productslider')->__('Slider Title'),
|
23 |
+
'class' => 'required-entry',
|
24 |
+
'required' => true,
|
25 |
+
'name' => 'title',
|
26 |
+
));
|
27 |
+
$zeroBugs[] = $fieldset->addField('product_width', 'text', array(
|
28 |
+
'label' => Mage::helper('productslider')->__('Product Slider Width Product Image'),
|
29 |
+
'class' => 'validate-greater-than-zero',
|
30 |
+
'name' => 'product_width',
|
31 |
+
));
|
32 |
+
$zeroBugs[] = $fieldset->addField('product_height', 'text', array(
|
33 |
+
'label' => Mage::helper('productslider')->__('Product Slider Height Product Image'),
|
34 |
+
'class' => 'validate-greater-than-zero',
|
35 |
+
'name' => 'product_height',
|
36 |
+
));
|
37 |
+
$zeroBugs[] = $fieldset->addField('category_width', 'text', array(
|
38 |
+
'label' => Mage::helper('productslider')->__('Product Slider Width Category Image'),
|
39 |
+
'class' => 'validate-greater-than-zero',
|
40 |
+
'name' => 'category_width',
|
41 |
+
));
|
42 |
+
$zeroBugs[] = $fieldset->addField('category_height', 'text', array(
|
43 |
+
'label' => Mage::helper('productslider')->__('Product Slider Height Category Image'),
|
44 |
+
'class' => 'validate-greater-than-zero',
|
45 |
+
'name' => 'category_height',
|
46 |
+
));
|
47 |
+
$zeroBugs[] = $fieldset->addField('page_width', 'text', array(
|
48 |
+
'label' => Mage::helper('productslider')->__('Product Slider Width Page Image'),
|
49 |
+
'class' => 'validate-greater-than-zero',
|
50 |
+
'name' => 'page_width',
|
51 |
+
));
|
52 |
+
$zeroBugs[] = $fieldset->addField('page_height', 'text', array(
|
53 |
+
'label' => Mage::helper('productslider')->__('Product Slider Height Page Image'),
|
54 |
+
'class' => 'validate-greater-than-zero',
|
55 |
+
'name' => 'page_height',
|
56 |
+
));
|
57 |
+
$zeroBugs[] = $fieldset->addField('internal_width', 'text', array(
|
58 |
+
'label' => Mage::helper('productslider')->__('Product Slider Width Internal Url Image'),
|
59 |
+
'class' => 'validate-greater-than-zero',
|
60 |
+
'name' => 'internal_width',
|
61 |
+
));
|
62 |
+
$zeroBugs[] = $fieldset->addField('internal_height', 'text', array(
|
63 |
+
'label' => Mage::helper('productslider')->__('Product Slider Height Internal Url Image'),
|
64 |
+
'class' => 'validate-greater-than-zero',
|
65 |
+
'name' => 'internal_height',
|
66 |
+
));
|
67 |
+
$zeroBugs[] = $fieldset->addField('external_width', 'text', array(
|
68 |
+
'label' => Mage::helper('productslider')->__('Product Slider Width External Url Image'),
|
69 |
+
'class' => 'validate-greater-than-zero',
|
70 |
+
'name' => 'external_width',
|
71 |
+
));
|
72 |
+
$zeroBugs[] = $fieldset->addField('external_height', 'text', array(
|
73 |
+
'label' => Mage::helper('productslider')->__('Product Slider Height External Url Image'),
|
74 |
+
'class' => 'validate-greater-than-zero',
|
75 |
+
'name' => 'external_height',
|
76 |
+
));
|
77 |
+
$zeroBugs[] = $fieldset->addField('image_width', 'text', array(
|
78 |
+
'label' => Mage::helper('productslider')->__('Product Slider Width Background Image'),
|
79 |
+
'class' => 'validate-greater-than-zero',
|
80 |
+
'name' => 'image_width',
|
81 |
+
));
|
82 |
+
$zeroBugs[] = $fieldset->addField('image_height', 'text', array(
|
83 |
+
'label' => Mage::helper('productslider')->__('Product Slider Height Background Image'),
|
84 |
+
'class' => 'validate-greater-than-zero',
|
85 |
+
'name' => 'image_height',
|
86 |
+
));
|
87 |
+
|
88 |
+
if (Mage::getSingleton('adminhtml/session')->getProductSliderData()) {
|
89 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getProductSliderData());
|
90 |
+
Mage::getSingleton('adminhtml/session')->setProductSliderData(null);
|
91 |
+
} elseif (Mage::registry('productslider_slider_data')) {
|
92 |
+
$form->setValues(Mage::registry('productslider_slider_data')->getData());
|
93 |
+
}
|
94 |
+
|
95 |
+
foreach ($zeroBugs as $zeroBug) {
|
96 |
+
if ($zeroBug->getValue() == 0)
|
97 |
+
$zeroBug->setValue('');
|
98 |
+
}
|
99 |
+
|
100 |
+
return parent::_prepareForm();
|
101 |
+
}
|
102 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Edit/Tabs.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Slider_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
9 |
+
public function __construct() {
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('productslider_tabs');
|
12 |
+
$this->setDestElementId('edit_form');
|
13 |
+
$this->setTitle(Mage::helper('productslider')->__('Slider Information'));
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _beforeToHtml() {
|
17 |
+
$this->addTab('form_section', array(
|
18 |
+
'label' => Mage::helper('productslider')->__('Slider Information'),
|
19 |
+
'title' => Mage::helper('productslider')->__('Slider Information'),
|
20 |
+
'content' => $this->getLayout()->createBlock('productslider/adminhtml_slider_edit_tab_form')->toHtml(),
|
21 |
+
));
|
22 |
+
|
23 |
+
return parent::_beforeToHtml();
|
24 |
+
}
|
25 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Adminhtml/Slider/Grid.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Block_Adminhtml_Slider_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
9 |
+
public function __construct() {
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('productsliderGrid');
|
12 |
+
// This is the primary key of the database
|
13 |
+
$this->setDefaultSort('slider_id');
|
14 |
+
$this->setDefaultDir('ASC');
|
15 |
+
$this->setSaveParametersInSession(true);
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function _prepareCollection() {
|
19 |
+
$collection = Mage::getModel('productslider/slider')->getCollection();
|
20 |
+
$this->setCollection($collection);
|
21 |
+
return parent::_prepareCollection();
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareColumns() {
|
25 |
+
$this->addColumn('slider_id', array(
|
26 |
+
'header' => Mage::helper('productslider')->__('Slider ID'),
|
27 |
+
'align' =>'right',
|
28 |
+
'width' => '50px',
|
29 |
+
'index' => 'slider_id',
|
30 |
+
));
|
31 |
+
$this->addColumn('identifier', array(
|
32 |
+
'header' => Mage::helper('productslider')->__('Slider Identifier'),
|
33 |
+
'align' =>'left',
|
34 |
+
'index' => 'identifier',
|
35 |
+
));
|
36 |
+
$this->addColumn('title', array(
|
37 |
+
'header' => Mage::helper('productslider')->__('Slider Title'),
|
38 |
+
'align' =>'left',
|
39 |
+
'index' => 'title',
|
40 |
+
));
|
41 |
+
|
42 |
+
return parent::_prepareColumns();
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getRowUrl($row) {
|
46 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
47 |
+
}
|
48 |
+
}
|
app/code/community/PSystem/ProductSlider/Block/Slider.php
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Pascal Catalog Ajax config block
|
11 |
+
*
|
12 |
+
* @category PSystem
|
13 |
+
* @package PSystem_ProductSlider
|
14 |
+
* @author Pascal System <info@pascalsystem.pl>
|
15 |
+
* @version 1.0.0
|
16 |
+
*/
|
17 |
+
class PSystem_ProductSlider_Block_Slider extends Mage_Core_Block_Template {
|
18 |
+
/**
|
19 |
+
* Product collection
|
20 |
+
*
|
21 |
+
*@var Varien_Data_Collection
|
22 |
+
*/
|
23 |
+
protected $_collection;
|
24 |
+
/**
|
25 |
+
* Slider identifier
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
protected $_identifier;
|
30 |
+
/**
|
31 |
+
* Slider
|
32 |
+
*
|
33 |
+
* @var PSystem_ProductSlider_Model_Slider
|
34 |
+
*/
|
35 |
+
protected $_slider;
|
36 |
+
/**
|
37 |
+
* Products cache
|
38 |
+
*
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
protected $_cacheProducts = array();
|
42 |
+
/**
|
43 |
+
* Categories cache
|
44 |
+
*
|
45 |
+
* @var array
|
46 |
+
*/
|
47 |
+
protected $_cacheCategories = array();
|
48 |
+
/**
|
49 |
+
* Pages cache
|
50 |
+
*
|
51 |
+
* @var array
|
52 |
+
*/
|
53 |
+
protected $_cachePages = array();
|
54 |
+
/**
|
55 |
+
* Image size config
|
56 |
+
*
|
57 |
+
* @var array
|
58 |
+
*/
|
59 |
+
protected $_imageConf;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Set slider indentifier
|
63 |
+
*
|
64 |
+
* @param string $identifier
|
65 |
+
* @return PSystem_ProductSlider_Block_Slider
|
66 |
+
*/
|
67 |
+
public function setIdentifier($identifier) {
|
68 |
+
$this->_identifier = $identifier;
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get slider identifier
|
74 |
+
*
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getIdentifier() {
|
78 |
+
return isset($this->_identifier)?$this->_identifier:'';
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Return image width after reading slider object
|
83 |
+
*
|
84 |
+
* @param $key
|
85 |
+
* @return int
|
86 |
+
*/
|
87 |
+
public function getWidth($key) {
|
88 |
+
$this->_loadImageConf();
|
89 |
+
return isset($this->_imageConf['width'][$key])?$this->_imageConf['width'][$key]:null;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Return image height after reading slider object
|
94 |
+
*
|
95 |
+
* @param $key
|
96 |
+
* @return int
|
97 |
+
*/
|
98 |
+
public function getHeight($key) {
|
99 |
+
$this->_loadImageConf();
|
100 |
+
return isset($this->_imageConf['height'][$key])?$this->_imageConf['height'][$key]:null;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Get slider
|
105 |
+
*
|
106 |
+
* @return PSystem_ProductSlider_Model_Slider
|
107 |
+
*/
|
108 |
+
public function getSlider() {
|
109 |
+
if (!isset($this->_slider)) {
|
110 |
+
$this->getCollection();
|
111 |
+
}
|
112 |
+
return $this->_slider;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Return product collection
|
117 |
+
*
|
118 |
+
* @return Varien_Data_Collection
|
119 |
+
*/
|
120 |
+
public function getCollection() {
|
121 |
+
if (!isset($this->_collection)) {
|
122 |
+
$productIDs = array();
|
123 |
+
$categoryIDs = array();
|
124 |
+
$pageIDs = array();
|
125 |
+
|
126 |
+
$this->_collection = new Varien_Data_Collection();
|
127 |
+
$this->_slider = Mage::getModel('productslider/slider')->load($this->getIdentifier(),'identifier');
|
128 |
+
|
129 |
+
if (!$this->_slider->getId()) {
|
130 |
+
return $this->_collection;
|
131 |
+
}
|
132 |
+
|
133 |
+
$items = Mage::getModel('productslider/item')->getCollection();
|
134 |
+
$items->getSelect()
|
135 |
+
->where('slider_id = ?', $this->_slider->getId())
|
136 |
+
->order('priority')
|
137 |
+
;
|
138 |
+
|
139 |
+
foreach ($items as $item) {
|
140 |
+
if ($item->getData('product_id'))
|
141 |
+
$productIDs[] = $item->getData('product_id');
|
142 |
+
if ($item->getData('category_id'))
|
143 |
+
$categoryIDs[] = $item->getData('category_id');
|
144 |
+
if ($item->getData('page_id'))
|
145 |
+
$pageIDs[] = $item->getData('page_id');
|
146 |
+
|
147 |
+
$this->_collection->addItem($item);
|
148 |
+
}
|
149 |
+
|
150 |
+
if (count($productIDs)) {
|
151 |
+
$c = Mage::getModel('catalog/product')->getCollection();
|
152 |
+
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
|
153 |
+
$c->addAttributeToSelect($attributes)
|
154 |
+
->addMinimalPrice()
|
155 |
+
->addFinalPrice()
|
156 |
+
->addTaxPercents()
|
157 |
+
->addStoreFilter()
|
158 |
+
;
|
159 |
+
$c->getSelect()->where('e.entity_id IN ('.implode(',',$productIDs).')');
|
160 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($c);
|
161 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($c);
|
162 |
+
foreach ($c as $i) {
|
163 |
+
$this->_cacheProducts[$i->getId()] = $i;
|
164 |
+
}
|
165 |
+
unset($c);
|
166 |
+
}
|
167 |
+
|
168 |
+
if (count($categoryIDs)) {
|
169 |
+
$c = Mage::getModel('catalog/category')->getCollection()
|
170 |
+
->addIsActiveFilter()
|
171 |
+
->addAttributeToSelect('name')
|
172 |
+
->addAttributeToSelect('url_path')
|
173 |
+
->addAttributeToSelect('image')
|
174 |
+
;
|
175 |
+
$c->getSelect()->where('e.entity_id IN ('.implode(',',$categoryIDs).')');
|
176 |
+
foreach ($c as $i) {
|
177 |
+
$this->_cacheCategories[$i->getId()] = $i;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
if (count($pageIDs)) {
|
182 |
+
$c = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore());
|
183 |
+
$c->getSelect()
|
184 |
+
->where('main_table.page_id IN ('.implode(',',$pageIDs).')')
|
185 |
+
->where('main_table.is_active = ?', 1)
|
186 |
+
;
|
187 |
+
foreach ($c as $i) {
|
188 |
+
$this->_cachePages[$i->getId()] = $i;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
foreach ($this->_collection as $itemSlider) {
|
193 |
+
if ($itemSlider->getData('product_id') && isset($this->_cacheProducts[$itemSlider->getData('product_id')])) {
|
194 |
+
$itemSlider->setData('product', $this->_cacheProducts[$itemSlider->getData('product_id')]);
|
195 |
+
}
|
196 |
+
if ($itemSlider->getData('category_id') && isset($this->_cacheCategories[$itemSlider->getData('category_id')])) {
|
197 |
+
$itemSlider->setData('category', $this->_cacheCategories[$itemSlider->getData('category_id')]);
|
198 |
+
}
|
199 |
+
if ($itemSlider->getData('page_id') && isset($this->_cachePages[$itemSlider->getData('page_id')])) {
|
200 |
+
$itemSlider->setData('page', $this->_cachePages[$itemSlider->getData('page_id')]);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
return $this->_collection;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Get price html
|
209 |
+
*
|
210 |
+
* @param Mage_Catalog_Model_Product $product
|
211 |
+
* @param boolean $displayMinimalPrice
|
212 |
+
* @return string
|
213 |
+
*/
|
214 |
+
public function getPriceHtml(Mage_Catalog_Model_Product $product, $displayMinimalPrice = false) {
|
215 |
+
return $this->getLayout()->createBlock('catalog/product_price')
|
216 |
+
->setTemplate('catalog/product/price.phtml')
|
217 |
+
->setProduct($product)
|
218 |
+
->setDisplayMinimalPrice($displayMinimalPrice)
|
219 |
+
->setIdSuffix('-productslider'.$this->getSlider()->getId())
|
220 |
+
->setUseLinkForAsLowAs(true)
|
221 |
+
->toHtml();
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Load image config
|
226 |
+
*
|
227 |
+
* @return void
|
228 |
+
*/
|
229 |
+
protected function _loadImageConf() {
|
230 |
+
if (isset($this->_imageConf))
|
231 |
+
return;
|
232 |
+
if (!$this->_slider->getId())
|
233 |
+
$this->getCollection();
|
234 |
+
$data = array(
|
235 |
+
'image' => array(685,200),
|
236 |
+
'product' => array(135,135),
|
237 |
+
'category' => array(135,135),
|
238 |
+
'page' => array(135,135),
|
239 |
+
'internal' => array(135,95),
|
240 |
+
'external' => array(135,95),
|
241 |
+
);
|
242 |
+
$dataOpt = array('width','height');
|
243 |
+
$this->_imageConf = array();
|
244 |
+
foreach ($dataOpt as $optKey)
|
245 |
+
$this->_imageConf[$optKey] = array();
|
246 |
+
foreach ($data as $key => $conf) {
|
247 |
+
foreach ($dataOpt as $optId => $optKey) {
|
248 |
+
$testKey = $key.'_'.$optKey;
|
249 |
+
$val = intval($this->_slider->getData($testKey));
|
250 |
+
if ($val <= 0)
|
251 |
+
$val = intval(Mage::getStoreConfig('psproductslider/images/'.$testKey));
|
252 |
+
if ($val <= 0)
|
253 |
+
$val = $conf[$optId];
|
254 |
+
$this->_imageConf[$optKey][$key] = $val;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
app/code/community/PSystem/ProductSlider/Helper/Data.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Pascal Catalog Ajax config block
|
11 |
+
*
|
12 |
+
* @category PSystem
|
13 |
+
* @package PSystem_ProductSlider
|
14 |
+
* @author Pascal System <info@pascalsystem.pl>
|
15 |
+
* @version 1.0.0
|
16 |
+
*/
|
17 |
+
class PSystem_ProductSlider_Helper_Data extends Mage_Core_Helper_Abstract {
|
18 |
+
/**
|
19 |
+
* Get media dir
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getMediaDir() {
|
24 |
+
return Mage::getBaseDir('media').DS.$this->getProductSliderDirectory();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Directory for storage slider image
|
29 |
+
*
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getProductSliderDirectory() {
|
33 |
+
return 'productslider';
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get image url
|
38 |
+
*
|
39 |
+
* @param string $imageFile
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getImage($imageFile, $width, $height, $isFrame = false) {
|
43 |
+
$cacheDir = $this->getMediaDir().DS.'cache';
|
44 |
+
if (!is_dir($cacheDir)) mkdir($cacheDir, 0777);
|
45 |
+
$ext = 'jpg';
|
46 |
+
if (preg_match('/\.([^\.]+)$/', $imageFile, $regs)) {
|
47 |
+
$ext = $regs[1];
|
48 |
+
}
|
49 |
+
$cacheFileName = substr(md5(serialize(array($imageFile,$width,$height,$isFrame))),0,16).'.'.$ext;
|
50 |
+
if (!file_exists($cacheDir.DS.$cacheFileName)) {
|
51 |
+
$img = new Varien_Image($this->getMediaDir().DS.$imageFile);
|
52 |
+
$img->keepAspectRatio(true);
|
53 |
+
if ($isFrame) {
|
54 |
+
$img->keepFrame(true);
|
55 |
+
$img->backgroundColor(array(255,255,255));
|
56 |
+
}
|
57 |
+
$img->resize($width, $height);
|
58 |
+
$img->save($cacheDir, $cacheFileName);
|
59 |
+
}
|
60 |
+
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$this->getProductSliderDirectory().'/cache/'.$cacheFileName;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Generate category image
|
65 |
+
*
|
66 |
+
* @param Mage_Catalog_Model_Category $category
|
67 |
+
* @param int $width
|
68 |
+
* @param int $height
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function getCategoryImage(Mage_Catalog_Model_Category $category, $width, $height) {
|
72 |
+
if (!$category->getImage())
|
73 |
+
return '';
|
74 |
+
$catDir = $this->getMediaDir().DS.'category';
|
75 |
+
$ext = 'jpg';
|
76 |
+
if (preg_match('/([^\.]+)$/', $category->getImage(), $regs)) {
|
77 |
+
$ext = strtolower($regs[1]);
|
78 |
+
}
|
79 |
+
$fileName = md5(serialize(array($category->getImage(),$width,$height))).'.'.$ext;
|
80 |
+
|
81 |
+
if (!file_exists($catDir.DS.$fileName)) {
|
82 |
+
if (!is_dir($catDir)) mkdir($catDir, 0777);
|
83 |
+
$img = new Varien_Image(Mage::getBaseDir('media').DS.'catalog'.DS.'category'.DS.$category->getImage());
|
84 |
+
$img->keepAspectRatio(true);
|
85 |
+
$img->resize($width, $height);
|
86 |
+
$img->save($catDir, $fileName);
|
87 |
+
}
|
88 |
+
|
89 |
+
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$this->getProductSliderDirectory().'/category/'.$fileName;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Generate internal url
|
94 |
+
*
|
95 |
+
* @param PSystem_ProductSlider_Model_Item $item
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
public function getInternalUrl(PSystem_ProductSlider_Model_Item $item) {
|
99 |
+
$url = $item->getData('internal_url');
|
100 |
+
if (!$url) return '';
|
101 |
+
$url = Mage::getUrl($url);
|
102 |
+
return preg_replace('/\.html\/$/','.html',$url);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Generate external url
|
107 |
+
*
|
108 |
+
* @param PSystem_ProductSlider_Model_Item $item
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function getExternalUrl(PSystem_ProductSlider_Model_Item $item) {
|
112 |
+
$url = $item->getData('external_url');
|
113 |
+
if (!$url || (strpos($url, 'http://')!==0)) return '';
|
114 |
+
return $url;
|
115 |
+
}
|
116 |
+
}
|
app/code/community/PSystem/ProductSlider/Model/Item.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Model_Item extends Mage_Core_Model_Abstract {
|
9 |
+
/**
|
10 |
+
* Initialize resource model
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('productslider/item');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/PSystem/ProductSlider/Model/Mysql4/Item.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Model_Mysql4_Item extends Mage_Core_Model_Mysql4_Abstract {
|
9 |
+
/**
|
10 |
+
* Initialize resource model
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('productslider/item', 'item_id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/PSystem/ProductSlider/Model/Mysql4/Item/Collection.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Model_Mysql4_Item_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
9 |
+
/**
|
10 |
+
* Initialize resource model collection
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('productslider/item');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/PSystem/ProductSlider/Model/Mysql4/Slider.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Model_Mysql4_Slider extends Mage_Core_Model_Mysql4_Abstract {
|
9 |
+
/**
|
10 |
+
* Initialize resource model
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('productslider/slider', 'slider_id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/PSystem/ProductSlider/Model/Mysql4/Slider/Collection.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Model_Mysql4_Slider_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
9 |
+
/**
|
10 |
+
* Initialize resource model collection
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('productslider/slider');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/PSystem/ProductSlider/Model/Slider.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Model_Slider extends Mage_Core_Model_Abstract {
|
9 |
+
/**
|
10 |
+
* Initialize resource model
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('productslider/slider');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/PSystem/ProductSlider/controllers/Adminhtml/ItemController.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Adminhtml_ItemController extends Mage_Adminhtml_Controller_Action {
|
9 |
+
protected function _initAction() {
|
10 |
+
$this->loadLayout()
|
11 |
+
/*->_setActiveMenu('')*/
|
12 |
+
->_addBreadcrumb(Mage::helper('productslider')->__('Items Manager'), Mage::helper('productslider')->__('Item Manager'));
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction() {
|
17 |
+
$this->_initAction();
|
18 |
+
$this->_addContent($this->getLayout()->createBlock('productslider/adminhtml_item'));
|
19 |
+
$this->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function editAction() {
|
23 |
+
$itemId = $this->getRequest()->getParam('id');
|
24 |
+
$itemModel = Mage::getModel('productslider/item')->load($itemId);
|
25 |
+
if ($itemModel->getId() || $itemId == 0) {
|
26 |
+
Mage::register('productslider_item_data', $itemModel);
|
27 |
+
$this->loadLayout();
|
28 |
+
$this->_addBreadcrumb(Mage::helper('productslider')->__('Item Manager'), Mage::helper('productslider')->__('Item Manager'));
|
29 |
+
$this->_addBreadcrumb(Mage::helper('productslider')->__('Item Information'), Mage::helper('productslider')->__('Item Information'));
|
30 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
31 |
+
|
32 |
+
$this->_addContent($this->getLayout()->createBlock('productslider/adminhtml_item_edit'))
|
33 |
+
->_addLeft($this->getLayout()->createBlock('productslider/adminhtml_item_edit_tabs'));
|
34 |
+
$this->renderLayout();
|
35 |
+
} else {
|
36 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productslider')->__('Item does not exist'));
|
37 |
+
$this->_redirect('*/*/');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function newAction() {
|
42 |
+
$this->_forward('edit');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function saveAction() {
|
46 |
+
if ($this->getRequest()->getPost()) {
|
47 |
+
try {
|
48 |
+
$postData = $this->getRequest()->getPost();
|
49 |
+
|
50 |
+
$this->_saveImage($postData, 'image1');
|
51 |
+
$this->_saveImage($postData, 'image2');
|
52 |
+
$this->_saveImage($postData, 'image3');
|
53 |
+
|
54 |
+
$itemModel = Mage::getModel('productslider/item');
|
55 |
+
$itemModelId = intval($this->getRequest()->getParam('id'));
|
56 |
+
if ($itemModelId) {
|
57 |
+
$itemModel->load($itemModelId);
|
58 |
+
}
|
59 |
+
$itemModel
|
60 |
+
->setData('title', $postData['title'])
|
61 |
+
->setData('internal_url', $postData['internal_url'])
|
62 |
+
->setData('external_url', $postData['external_url'])
|
63 |
+
->setData('description', $postData['description'])
|
64 |
+
->setData('html', $postData['html'])
|
65 |
+
->setData('active', ($postData['active'])?1:0)
|
66 |
+
->setData('priority', intval($postData['priority']))
|
67 |
+
;
|
68 |
+
|
69 |
+
if (!empty($postData['product_id']))
|
70 |
+
$itemModel->setData('product_id', $postData['product_id']);
|
71 |
+
if (!empty($postData['category_id']))
|
72 |
+
$itemModel->setData('category_id', $postData['category_id']);
|
73 |
+
if (!empty($postData['page_id']))
|
74 |
+
$itemModel->setData('page_id', $postData['page_id']);
|
75 |
+
if (!empty($postData['slider_id']))
|
76 |
+
$itemModel->setData('slider_id', $postData['slider_id']);
|
77 |
+
|
78 |
+
$deleteFiles = array();
|
79 |
+
for ($i=1;$i<=4;$i++) {
|
80 |
+
$keyName = 'image'.$i;
|
81 |
+
if (!empty($postData[$keyName])) {
|
82 |
+
if ($postData[$keyName] == 'deletefile') {
|
83 |
+
$itemModel->setData($keyName, '');
|
84 |
+
if ($itemModel->getOrigData($keyName))
|
85 |
+
$deleteFiles[] = $itemModel->getOrigData($keyName);
|
86 |
+
} else {
|
87 |
+
$itemModel->setData($keyName, $postData[$keyName]);
|
88 |
+
var_dump($itemModel->getOrigData($keyName));
|
89 |
+
if ($itemModel->getOrigData($keyName))
|
90 |
+
$deleteFiles[] = $itemModel->getOrigData($keyName);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
foreach ($deleteFiles as $deleteFile) {
|
95 |
+
$fileDelete = Mage::helper('productslider')->getMediaDir().DS.$deleteFile;
|
96 |
+
if (file_exists($fileDelete))
|
97 |
+
unlink($fileDelete);
|
98 |
+
}
|
99 |
+
|
100 |
+
$itemModel->save();
|
101 |
+
|
102 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productslider')->__('Item was successfully saved'));
|
103 |
+
Mage::getSingleton('adminhtml/session')->setitemData(false);
|
104 |
+
|
105 |
+
$this->_redirect('*/*/');
|
106 |
+
return;
|
107 |
+
} catch (Exception $e) {
|
108 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
109 |
+
Mage::getSingleton('adminhtml/session')->setitemData($this->getRequest()->getPost());
|
110 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if($this->getRequest()->getParam('id') > 0) {
|
119 |
+
try {
|
120 |
+
$itemModel = Mage::getModel('productslider/item');
|
121 |
+
$itemModel->setId($this->getRequest()->getParam('id'))->delete();
|
122 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productslider')->__('Item was successfully deleted'));
|
123 |
+
$this->_redirect('*/*/');
|
124 |
+
} catch (Exception $e) {
|
125 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
126 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
127 |
+
}
|
128 |
+
}
|
129 |
+
$this->_redirect('*/*/');
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Product grid for AJAX request.
|
134 |
+
* Sort and filter result for example.
|
135 |
+
*/
|
136 |
+
public function gridAction() {
|
137 |
+
$this->loadLayout();
|
138 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('productslider/adminhtml_item_grid')->toHtml());
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Try save image before save model
|
143 |
+
*
|
144 |
+
* @param array &$postData
|
145 |
+
* @param string $name
|
146 |
+
* @return string
|
147 |
+
* @throws Exception
|
148 |
+
*/
|
149 |
+
protected function _saveImage(array &$postData, $name) {
|
150 |
+
unset($postData[$name]);
|
151 |
+
if (!empty($_FILES[$name]['tmp_name']) && !$_FILES[$name]['error']) {
|
152 |
+
//(is_uploaded_file($_FILES[$name]['tmp_name']));
|
153 |
+
$nameFile = strtolower($_FILES[$name]['name']);
|
154 |
+
$temp = explode('.',$nameFile);
|
155 |
+
$ext = $temp[count($temp)-1];
|
156 |
+
if ($ext == 'jpeg') $ext = 'jpg';
|
157 |
+
if (!in_array($ext, array('jpg','jpeg','gif','png')) || (count($temp)<2)) {
|
158 |
+
throw new Mage_Exception(Mage::helper('productslider')->__('Not valid extension product slider image, allowed extension jpg,jpeg,gif,png'));
|
159 |
+
}
|
160 |
+
|
161 |
+
$baseFile = preg_replace('/([^a-z0-9\_]+)/','_',implode('.',array_slice($temp, 0, count($temp)-1)));
|
162 |
+
$fullFileName = '';
|
163 |
+
$mediaDir = Mage::helper('productslider')->getMediaDir();
|
164 |
+
if (!is_dir($mediaDir)) {
|
165 |
+
mkdir($mediaDir, 0777);
|
166 |
+
}
|
167 |
+
$numFile = 0;
|
168 |
+
do {
|
169 |
+
$fullFileName = $baseFile.(($numFile>0)?'-'.$numFile:'').'.'.$ext;
|
170 |
+
$numFile++;
|
171 |
+
} while (file_exists($mediaDir.DS.$fullFileName));
|
172 |
+
|
173 |
+
$uploader = new Varien_File_Uploader($name);
|
174 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
175 |
+
$uploader->setAllowRenameFiles(false);
|
176 |
+
$uploader->setFilesDispersion(false);
|
177 |
+
$uploader->save($mediaDir, $fullFileName);
|
178 |
+
|
179 |
+
$postData[$name] = $fullFileName;
|
180 |
+
} elseif (!empty($_POST[$name]['delete'])) {
|
181 |
+
$postData[$name] = 'deletefile';
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
app/code/community/PSystem/ProductSlider/controllers/Adminhtml/SliderController.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
class PSystem_ProductSlider_Adminhtml_SliderController extends Mage_Adminhtml_Controller_Action {
|
9 |
+
protected function _initAction() {
|
10 |
+
$this->loadLayout()
|
11 |
+
->_setActiveMenu('cms/productslider/slider')
|
12 |
+
->_addBreadcrumb(Mage::helper('productslider')->__('Slider Manager'), Mage::helper('productslider')->__('Slider Manager'));
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function indexAction() {
|
17 |
+
$this->_initAction();
|
18 |
+
$this->_addContent($this->getLayout()->createBlock('productslider/adminhtml_slider'));
|
19 |
+
$this->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function editAction() {
|
23 |
+
$sliderId = $this->getRequest()->getParam('id');
|
24 |
+
$sliderModel = Mage::getModel('productslider/slider')->load($sliderId);
|
25 |
+
if ($sliderModel->getId() || $sliderId == 0) {
|
26 |
+
Mage::register('productslider_slider_data', $sliderModel);
|
27 |
+
$this->loadLayout();
|
28 |
+
$this->_addBreadcrumb(Mage::helper('productslider')->__('Slider Manager'), Mage::helper('productslider')->__('Slider Manager'));
|
29 |
+
$this->_addBreadcrumb(Mage::helper('productslider')->__('Slider Information'), Mage::helper('productslider')->__('Slider Information'));
|
30 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
31 |
+
|
32 |
+
$this->_addContent($this->getLayout()->createBlock('productslider/adminhtml_slider_edit'))
|
33 |
+
->_addLeft($this->getLayout()->createBlock('productslider/adminhtml_slider_edit_tabs'));
|
34 |
+
$this->renderLayout();
|
35 |
+
} else {
|
36 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productslider')->__('Slider does not exist'));
|
37 |
+
$this->_redirect('*/*/');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function newAction() {
|
42 |
+
$this->_forward('edit');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function saveAction() {
|
46 |
+
if ($this->getRequest()->getPost()) {
|
47 |
+
try {
|
48 |
+
$postData = $this->getRequest()->getPost();
|
49 |
+
$imgsConfig = array(
|
50 |
+
'image', 'product', 'category', 'page', 'internal', 'external'
|
51 |
+
);
|
52 |
+
$sliderModel = Mage::getModel('productslider/slider');
|
53 |
+
$sliderModel->setId($this->getRequest()->getParam('id'))
|
54 |
+
->setTitle($postData['title'])
|
55 |
+
->setIdentifier($postData['identifier']);
|
56 |
+
foreach ($imgsConfig as $imgConfig) {
|
57 |
+
if (isset($postData[$imgConfig.'_width']) && ($val=intval($postData[$imgConfig.'_width']))) {
|
58 |
+
$sliderModel->setData($imgConfig.'_width', $val);
|
59 |
+
} else {
|
60 |
+
$sliderModel->setData($imgConfig.'_width', 0);
|
61 |
+
}
|
62 |
+
if (isset($postData[$imgConfig.'_height']) && ($val=intval($postData[$imgConfig.'_height']))) {
|
63 |
+
$sliderModel->setData($imgConfig.'_height', $val);
|
64 |
+
} else {
|
65 |
+
$sliderModel->setData($imgConfig.'_height', 0);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
$sliderModel->save();
|
69 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productslider')->__('Slider was successfully saved'));
|
70 |
+
Mage::getSingleton('adminhtml/session')->setsliderData(false);
|
71 |
+
|
72 |
+
$this->_redirect('*/*/');
|
73 |
+
return;
|
74 |
+
} catch (Exception $e) {
|
75 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
76 |
+
Mage::getSingleton('adminhtml/session')->setsliderData($this->getRequest()->getPost());
|
77 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
$this->_redirect('*/*/');
|
82 |
+
}
|
83 |
+
|
84 |
+
public function deleteAction() {
|
85 |
+
if($this->getRequest()->getParam('id') > 0) {
|
86 |
+
try {
|
87 |
+
$sliderModel = Mage::getModel('productslider/slider');
|
88 |
+
$sliderModel->setId($this->getRequest()->getParam('id'))->delete();
|
89 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productslider')->__('Slider was successfully deleted'));
|
90 |
+
$this->_redirect('*/*/');
|
91 |
+
} catch (Exception $e) {
|
92 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
93 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
94 |
+
}
|
95 |
+
}
|
96 |
+
$this->_redirect('*/*/');
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Product grid for AJAX request.
|
101 |
+
* Sort and filter result for example.
|
102 |
+
*/
|
103 |
+
public function gridAction() {
|
104 |
+
$this->loadLayout();
|
105 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('productslider/adminhtml_slider_grid')->toHtml());
|
106 |
+
}
|
107 |
+
}
|
app/code/community/PSystem/ProductSlider/etc/adminhtml.xml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category PSystem
|
5 |
+
* @package PSystem_ProductSlider
|
6 |
+
* @author Pascal System <info@pascalsystem.pl>
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<acl>
|
12 |
+
<resources>
|
13 |
+
<admin>
|
14 |
+
<children>
|
15 |
+
<system>
|
16 |
+
<children>
|
17 |
+
<config>
|
18 |
+
<children>
|
19 |
+
<psproductslider translate="title" module="productslider">
|
20 |
+
<title>Product Slider</title>
|
21 |
+
</psproductslider>
|
22 |
+
</children>
|
23 |
+
</config>
|
24 |
+
</children>
|
25 |
+
</system>
|
26 |
+
<cms>
|
27 |
+
<children>
|
28 |
+
<productslider translate="title" module="productslider">
|
29 |
+
<title>Product Slider</title>
|
30 |
+
</productslider>
|
31 |
+
</children>
|
32 |
+
</cms>
|
33 |
+
</children>
|
34 |
+
</admin>
|
35 |
+
</resources>
|
36 |
+
</acl>
|
37 |
+
<menu>
|
38 |
+
<cms>
|
39 |
+
<children>
|
40 |
+
<productslider translate="title" module="productslider">
|
41 |
+
<title>Product Slider</title>
|
42 |
+
<sort_order>100</sort_order>
|
43 |
+
<children>
|
44 |
+
<slider translate="title" module="productslider">
|
45 |
+
<title>Slider</title>
|
46 |
+
<sort_order>10</sort_order>
|
47 |
+
<action>productslider/adminhtml_slider</action>
|
48 |
+
</slider>
|
49 |
+
<item translate="title" module="productslider">
|
50 |
+
<title>Item</title>
|
51 |
+
<sort_order>20</sort_order>
|
52 |
+
<action>productslider/adminhtml_item</action>
|
53 |
+
</item>
|
54 |
+
</children>
|
55 |
+
</productslider>
|
56 |
+
</children>
|
57 |
+
</cms>
|
58 |
+
</menu>
|
59 |
+
</config>
|
app/code/community/PSystem/ProductSlider/etc/config.xml
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category PSystem
|
5 |
+
* @package PSystem_ProductSlider
|
6 |
+
* @author Pascal System <info@pascalsystem.pl>
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<PSystem_ProductSlider>
|
13 |
+
<version>1.0.0</version>
|
14 |
+
</PSystem_ProductSlider>
|
15 |
+
</modules>
|
16 |
+
<global>
|
17 |
+
<helpers>
|
18 |
+
<productslider>
|
19 |
+
<class>PSystem_ProductSlider_Helper</class>
|
20 |
+
</productslider>
|
21 |
+
</helpers>
|
22 |
+
<blocks>
|
23 |
+
<productslider>
|
24 |
+
<class>PSystem_ProductSlider_Block</class>
|
25 |
+
</productslider>
|
26 |
+
</blocks>
|
27 |
+
<models>
|
28 |
+
<productslider>
|
29 |
+
<class>PSystem_ProductSlider_Model</class>
|
30 |
+
<resourceModel>productslider_mysql4</resourceModel>
|
31 |
+
</productslider>
|
32 |
+
<productslider_mysql4>
|
33 |
+
<class>PSystem_ProductSlider_Model_Mysql4</class>
|
34 |
+
<entities>
|
35 |
+
<slider>
|
36 |
+
<table>psystem_productslider_slider</table>
|
37 |
+
</slider>
|
38 |
+
<item>
|
39 |
+
<table>psystem_productslider_item</table>
|
40 |
+
</item>
|
41 |
+
</entities>
|
42 |
+
</productslider_mysql4>
|
43 |
+
</models>
|
44 |
+
<resources>
|
45 |
+
<productslider_setup>
|
46 |
+
<setup>
|
47 |
+
<module>PSystem_ProductSlider</module>
|
48 |
+
</setup>
|
49 |
+
<connection>
|
50 |
+
<use>core_setup</use>
|
51 |
+
</connection>
|
52 |
+
</productslider_setup>
|
53 |
+
</resources>
|
54 |
+
</global>
|
55 |
+
<admin>
|
56 |
+
<translate>
|
57 |
+
<modules>
|
58 |
+
<PSystem_ProductSlider>
|
59 |
+
<files>
|
60 |
+
<default>PSystem_ProductSlider.csv</default>
|
61 |
+
</files>
|
62 |
+
</PSystem_ProductSlider>
|
63 |
+
</modules>
|
64 |
+
</translate>
|
65 |
+
<routers>
|
66 |
+
<productslider>
|
67 |
+
<use>admin</use>
|
68 |
+
<args>
|
69 |
+
<module>PSystem_ProductSlider</module>
|
70 |
+
<frontName>productslider</frontName>
|
71 |
+
</args>
|
72 |
+
</productslider>
|
73 |
+
</routers>
|
74 |
+
</admin>
|
75 |
+
<adminhtml>
|
76 |
+
<layout>
|
77 |
+
<updates>
|
78 |
+
<psproductslider module="PSystem_ProductSlider">
|
79 |
+
<file>ps_productslider.xml</file>
|
80 |
+
</psproductslider>
|
81 |
+
</updates>
|
82 |
+
</layout>
|
83 |
+
</adminhtml>
|
84 |
+
<frontend>
|
85 |
+
<layout>
|
86 |
+
<updates>
|
87 |
+
<psproductslider module="PSystem_ProductSlider">
|
88 |
+
<file>ps_productslider.xml</file>
|
89 |
+
</psproductslider>
|
90 |
+
</updates>
|
91 |
+
</layout>
|
92 |
+
</frontend>
|
93 |
+
</config>
|
app/code/community/PSystem/ProductSlider/etc/system.xml
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category PSystem
|
5 |
+
* @package PSystem_ProductSlider
|
6 |
+
* @author Pascal System <info@pascalsystem.pl>
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<tabs>
|
12 |
+
<psystem translate="label">
|
13 |
+
<label>Pascal System</label>
|
14 |
+
<sort_order>100</sort_order>
|
15 |
+
</psystem>
|
16 |
+
</tabs>
|
17 |
+
<sections>
|
18 |
+
<psproductslider translate="label" module="productslider">
|
19 |
+
<label>Product Slider</label>
|
20 |
+
<tab>psystem</tab>
|
21 |
+
<sort_order>50</sort_order>
|
22 |
+
<show_in_default>1</show_in_default>
|
23 |
+
<show_in_website>1</show_in_website>
|
24 |
+
<show_in_store>1</show_in_store>
|
25 |
+
<groups>
|
26 |
+
<images translate="label">
|
27 |
+
<label>Product Slider Images</label>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
<sort_order>5</sort_order>
|
32 |
+
<fields>
|
33 |
+
<product_width translate="label,comment">
|
34 |
+
<label>Product Slider Width Product Image</label>
|
35 |
+
<comment><![CDATA[default: 135px]]></comment>
|
36 |
+
<frontend_type>text</frontend_type>
|
37 |
+
<sort_order>5</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>1</show_in_website>
|
40 |
+
<show_in_store>1</show_in_store>
|
41 |
+
</product_width>
|
42 |
+
<product_height translate="label,comment">
|
43 |
+
<label>Product Slider Height Product Image</label>
|
44 |
+
<comment><![CDATA[default: 135px]]></comment>
|
45 |
+
<frontend_type>text</frontend_type>
|
46 |
+
<sort_order>10</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>1</show_in_store>
|
50 |
+
</product_height>
|
51 |
+
<category_width translate="label,comment">
|
52 |
+
<label>Product Slider Width Category Image</label>
|
53 |
+
<comment><![CDATA[default: 135px]]></comment>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<sort_order>15</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>1</show_in_store>
|
59 |
+
</category_width>
|
60 |
+
<category_height translate="label,comment">
|
61 |
+
<label>Product Slider Height Category Image</label>
|
62 |
+
<comment><![CDATA[default: 135px]]></comment>
|
63 |
+
<frontend_type>text</frontend_type>
|
64 |
+
<sort_order>20</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
</category_height>
|
69 |
+
<page_width translate="label,comment">
|
70 |
+
<label>Product Slider Width Page Image</label>
|
71 |
+
<comment><![CDATA[default: 135px]]></comment>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<sort_order>25</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
+
</page_width>
|
78 |
+
<page_height translate="label,comment">
|
79 |
+
<label>Product Slider Height Page Image</label>
|
80 |
+
<comment><![CDATA[default: 135px]]></comment>
|
81 |
+
<frontend_type>text</frontend_type>
|
82 |
+
<sort_order>30</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>1</show_in_website>
|
85 |
+
<show_in_store>1</show_in_store>
|
86 |
+
</page_height>
|
87 |
+
<internal_wdth translate="label,comment">
|
88 |
+
<label>Product Slider Width Internal Url Image</label>
|
89 |
+
<comment><![CDATA[default: 135px]]></comment>
|
90 |
+
<frontend_type>text</frontend_type>
|
91 |
+
<sort_order>35</sort_order>
|
92 |
+
<show_in_default>1</show_in_default>
|
93 |
+
<show_in_website>1</show_in_website>
|
94 |
+
<show_in_store>1</show_in_store>
|
95 |
+
</internal_wdth>
|
96 |
+
<internal_height translate="label,comment">
|
97 |
+
<label>Product Slider Height Internal Url Image</label>
|
98 |
+
<comment><![CDATA[default: 95px]]></comment>
|
99 |
+
<frontend_type>text</frontend_type>
|
100 |
+
<sort_order>40</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>1</show_in_store>
|
104 |
+
</internal_height>
|
105 |
+
<external_wdth translate="label,comment">
|
106 |
+
<label>Product Slider Width External Url Image</label>
|
107 |
+
<comment><![CDATA[default: 135px]]></comment>
|
108 |
+
<frontend_type>text</frontend_type>
|
109 |
+
<sort_order>45</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>1</show_in_store>
|
113 |
+
</external_wdth>
|
114 |
+
<external_height translate="label,comment">
|
115 |
+
<label>Product Slider Height External Url Image</label>
|
116 |
+
<comment><![CDATA[default: 95px]]></comment>
|
117 |
+
<frontend_type>text</frontend_type>
|
118 |
+
<sort_order>50</sort_order>
|
119 |
+
<show_in_default>1</show_in_default>
|
120 |
+
<show_in_website>1</show_in_website>
|
121 |
+
<show_in_store>1</show_in_store>
|
122 |
+
</external_height>
|
123 |
+
<image_width translate="label,comment">
|
124 |
+
<label>Product Slider Width Background Image</label>
|
125 |
+
<comment><![CDATA[default: 685px]]></comment>
|
126 |
+
<frontend_type>text</frontend_type>
|
127 |
+
<sort_order>55</sort_order>
|
128 |
+
<show_in_default>1</show_in_default>
|
129 |
+
<show_in_website>1</show_in_website>
|
130 |
+
<show_in_store>1</show_in_store>
|
131 |
+
</image_width>
|
132 |
+
<image_height translate="label,comment">
|
133 |
+
<label>Product Slider Height Background Image</label>
|
134 |
+
<comment><![CDATA[default: 200px]]></comment>
|
135 |
+
<frontend_type>text</frontend_type>
|
136 |
+
<sort_order>60</sort_order>
|
137 |
+
<show_in_default>1</show_in_default>
|
138 |
+
<show_in_website>1</show_in_website>
|
139 |
+
<show_in_store>1</show_in_store>
|
140 |
+
</image_height>
|
141 |
+
</fields>
|
142 |
+
</images>
|
143 |
+
</groups>
|
144 |
+
</psproductslider>
|
145 |
+
</sections>
|
146 |
+
</config>
|
app/code/community/PSystem/ProductSlider/sql/productslider_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
DROP TABLE IF EXISTS {$this->getTable('psystem_productslider_slider')};
|
9 |
+
CREATE TABLE {$this->getTable('psystem_productslider_slider')} (
|
10 |
+
`slider_id` smallint(3) unsigned NOT NULL AUTO_INCREMENT,
|
11 |
+
`identifier` varchar(255) NOT NULL,
|
12 |
+
`title` varchar(255) NOT NULL,
|
13 |
+
`image_width` smallint(5) unsigned NOT NULL,
|
14 |
+
`image_height` smallint(5) unsigned NOT NULL,
|
15 |
+
`product_width` smallint(5) unsigned NOT NULL,
|
16 |
+
`product_height` smallint(5) unsigned NOT NULL,
|
17 |
+
`category_width` smallint(5) unsigned NOT NULL,
|
18 |
+
`category_height` smallint(5) unsigned NOT NULL,
|
19 |
+
`page_width` smallint(5) unsigned NOT NULL,
|
20 |
+
`page_height` smallint(5) unsigned NOT NULL,
|
21 |
+
`internal_width` smallint(5) unsigned NOT NULL,
|
22 |
+
`internal_height` smallint(5) unsigned NOT NULL,
|
23 |
+
`external_width` smallint(5) unsigned NOT NULL,
|
24 |
+
`external_height` smallint(5) unsigned NOT NULL,
|
25 |
+
PRIMARY KEY (`slider_id`),
|
26 |
+
UNIQUE KEY `IDx_{$this->getTable('psystem_productslider_slider')}_identifier` (`identifier`)
|
27 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
28 |
+
|
29 |
+
DROP TABLE IF EXISTS {$this->getTable('psystem_productslider_item')};
|
30 |
+
CREATE TABLE {$this->getTable('psystem_productslider_item')} (
|
31 |
+
`item_id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
|
32 |
+
`slider_id` smallint(3) unsigned NOT NULL,
|
33 |
+
`title` varchar(255) CHARACTER SET latin1 NOT NULL,
|
34 |
+
`product_id` int(10) unsigned NOT NULL,
|
35 |
+
`category_id` int(10) unsigned NOT NULL,
|
36 |
+
`page_id` int(10) unsigned NOT NULL,
|
37 |
+
`internal_url` varchar(255) CHARACTER SET latin1 NOT NULL,
|
38 |
+
`external_url` varchar(255) CHARACTER SET latin1 NOT NULL,
|
39 |
+
`image1` varchar(255) CHARACTER SET latin1 NOT NULL,
|
40 |
+
`image2` varchar(255) CHARACTER SET latin1 NOT NULL,
|
41 |
+
`image3` varchar(255) CHARACTER SET latin1 NOT NULL,
|
42 |
+
`description` text CHARACTER SET latin1 NOT NULL,
|
43 |
+
`html` text CHARACTER SET latin1 NOT NULL,
|
44 |
+
`active` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
45 |
+
`priority` smallint(5) unsigned NOT NULL DEFAULT '0',
|
46 |
+
`image4` varchar(255) NOT NULL,
|
47 |
+
PRIMARY KEY (`item_id`),
|
48 |
+
KEY `FK_{$this->getTable('psystem_productslider_item')}_slider` (`slider_id`),
|
49 |
+
KEY `IDx_{$this->getTable('psystem_productslider_item')}_active` (`active`),
|
50 |
+
CONSTRAINT `FK_{$this->getTable('psystem_productslider_item')}_slider` FOREIGN KEY (`slider_id`) REFERENCES `{$this->getTable('psystem_productslider_slider')}` (`slider_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
51 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
52 |
+
");
|
53 |
+
|
54 |
+
$installer->endSetup();
|
55 |
+
|
56 |
+
|
57 |
+
|
app/design/adminhtml/default/default/layout/ps_productslider.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category PSystem
|
5 |
+
* @package PSystem_ProductSlider
|
6 |
+
* @author Pascal System <info@pascalsystem.pl>
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<layout version="1.0.0">
|
11 |
+
<productslider_adminhtml_item_new>
|
12 |
+
<update handle="productslider_adminhtml_item_edit" />
|
13 |
+
</productslider_adminhtml_item_new>
|
14 |
+
<productslider_adminhtml_item_edit>
|
15 |
+
<update handle="editor"/>
|
16 |
+
</productslider_adminhtml_item_edit>
|
17 |
+
</layout>
|
app/design/frontend/default/default/layout/ps_productslider.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category PSystem
|
5 |
+
* @package PSystem_ProductSlider
|
6 |
+
* @author Pascal System <info@pascalsystem.pl>
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<layout version="1.0.0">
|
11 |
+
<cms_index_index>
|
12 |
+
<reference name="head">
|
13 |
+
<action method="addJs"><script>pascalsystem/productslider.js</script></action>
|
14 |
+
<action method="addCss"><stylesheet>css/pascalsystem/productslider.css</stylesheet></action>
|
15 |
+
</reference>
|
16 |
+
<reference name="content">
|
17 |
+
<block type="productslider/slider" name="productslider.slider" before="-" template="productslider/slider.phtml">
|
18 |
+
<action method="setIdentifier"><identifier>homepage</identifier></action>
|
19 |
+
</block>
|
20 |
+
</reference>
|
21 |
+
</cms_index_index>
|
22 |
+
</layout>
|
app/design/frontend/default/default/template/productslider/slider.phtml
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category PSystem
|
4 |
+
* @package PSystem_ProductSlider
|
5 |
+
* @author Pascal System <info@pascalsystem.pl>
|
6 |
+
* @version 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Pascal Catalog Ajax config block
|
11 |
+
*
|
12 |
+
* @category PSystem
|
13 |
+
* @package PSystem_ProductSlider
|
14 |
+
* @author Pascal System <info@pascalsystem.pl>
|
15 |
+
* @version 1.0.0
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
|
19 |
+
<?php
|
20 |
+
$_collection = $this->getCollection();
|
21 |
+
$_slider = $this->getSlider();
|
22 |
+
$_nums = $_collection->count();
|
23 |
+
$_helper = $this->helper('productslider');
|
24 |
+
$_bgWidth = $this->getWidth('image');
|
25 |
+
$_bgHeight = $this->getHeight('image');
|
26 |
+
$_productWidth = $this->getWidth('product');
|
27 |
+
$_productHeight = $this->getHeight('product');
|
28 |
+
$_categoryWidth = $this->getWidth('category');
|
29 |
+
$_categoryHeight = $this->getHeight('category');
|
30 |
+
$_pageWidth = $this->getWidth('page');
|
31 |
+
$_pageHeight = $this->getHeight('page');
|
32 |
+
$_internalWidth = $this->getWidth('internal');
|
33 |
+
$_internalHeight = $this->getHeight('internal');
|
34 |
+
$_externalWidth = $this->getWidth('external');
|
35 |
+
$_externalHeight = $this->getHeight('external');
|
36 |
+
?>
|
37 |
+
|
38 |
+
<?php if ($_nums): ?>
|
39 |
+
<div class="productslidercontainer productslidercontainer-<?php echo $_slider->getIdentifier() ?>">
|
40 |
+
<div class="productslider productslider-<?php echo $_slider->getIdentifier() ?>">
|
41 |
+
<div class="productslider-items">
|
42 |
+
<?php foreach ($_collection as $_item): ?>
|
43 |
+
<div class="productslider-item">
|
44 |
+
<?php if ($_item->getData('image1')): ?>
|
45 |
+
<img class="productslider-image"<?php echo ($_bgWidth)?' width="'.$_bgWidth.'"':'' ?><?php echo ($_bgWidth)?' height="'.$_bgHeight.'"':'' ?> src="<?php echo $_helper->getImage($_item->getData('image1'), $_bgWidth, $_bgHeight, true) ?>" alt="" />
|
46 |
+
<?php endif; ?>
|
47 |
+
|
48 |
+
<?php if ($_item->getTitle()): ?>
|
49 |
+
<h2 class="productslider-title"><?php echo $_item->getTitle() ?></h2>
|
50 |
+
<?php endif; ?>
|
51 |
+
|
52 |
+
<?php if ($_item->getDescription()): ?>
|
53 |
+
<div class="productslider-description"><?php echo $_item->getDescription() ?></div>
|
54 |
+
<?php endif; ?>
|
55 |
+
|
56 |
+
<?php if (trim(strip_tags($_item->getHtml()))): ?>
|
57 |
+
<div class="productslider-html"><?php echo $_item->getHtml() ?></div>
|
58 |
+
<?php endif; ?>
|
59 |
+
|
60 |
+
<?php if ($_product = $_item->getProduct()): ?>
|
61 |
+
<div class="product-cont">
|
62 |
+
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()); ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_productWidth, $_productHeight); ?>" width="<?php echo $_productWidth ?>" height="<?php echo $_productHeight ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>
|
63 |
+
<?php echo $this->getPriceHtml($_product, true); ?>
|
64 |
+
</div>
|
65 |
+
<?php endif; ?>
|
66 |
+
|
67 |
+
<?php if ($_category = $_item->getCategory()): ?>
|
68 |
+
<div class="category-cont">
|
69 |
+
<a href="<?php echo $_category->getUrl() ?>" title="<?php echo $this->htmlEscape($_category->getName()); ?>">
|
70 |
+
<?php if ($src = $_helper->getCategoryImage($_category, $_categoryWidth, $_categoryHeight)): ?>
|
71 |
+
<img src="<?php echo $src ?>" alt="<?php echo $this->htmlEscape($_category->getName()); ?>" />
|
72 |
+
<?php else: ?>
|
73 |
+
<span class="productslider-noimage-label"><?php echo $_category->getName() ?></span>
|
74 |
+
<?php endif; ?>
|
75 |
+
</a>
|
76 |
+
</div>
|
77 |
+
<?php endif; ?>
|
78 |
+
|
79 |
+
<?php if ($_page = $_item->getPage()): ?>
|
80 |
+
<div class="page-cont">
|
81 |
+
<a href="<?php echo Mage::getUrl($_page->getIdentifier()) ?>" title="<?php echo $this->htmlEscape($_page->getTitle()) ?>">
|
82 |
+
<?php if ($_item->getData('image2')): ?>
|
83 |
+
<img src="<?php echo $_helper->getImage($_item->getData('image2'), $_pageWidth, $_pageHeight) ?>" alt="<?php echo $this->htmlEscape($_page->getTitle()) ?>" />
|
84 |
+
<?php else: ?>
|
85 |
+
<span class="productslider-noimage-label"><?php echo $_page->getTitle() ?></span>
|
86 |
+
<?php endif; ?>
|
87 |
+
</a>
|
88 |
+
</div>
|
89 |
+
<?php endif; ?>
|
90 |
+
|
91 |
+
<?php if ($_internal = $_helper->getInternalUrl($_item)): ?>
|
92 |
+
<div class="internal-cont">
|
93 |
+
<a href="<?php echo $_internal ?>">
|
94 |
+
<?php if ($_item->getData('image3')): ?>
|
95 |
+
<img src="<?php echo $_helper->getImage($_item->getData('image3'), $_internalWidth, $_internalHeight) ?>" alt="" />
|
96 |
+
<?php else: ?>
|
97 |
+
<span class="productslider-noimage-label"><?php echo $_item->getInternalUrl() ?></span>
|
98 |
+
<?php endif; ?>
|
99 |
+
</a>
|
100 |
+
</div>
|
101 |
+
<?php endif; ?>
|
102 |
+
|
103 |
+
<?php if ($_external = $_helper->getExternalUrl($_item)): ?>
|
104 |
+
<div class="external-cont">
|
105 |
+
<a href="<?php echo $_external ?>">
|
106 |
+
<?php if ($_item->getData('image4')): ?>
|
107 |
+
<img src="<?php echo $_helper->getImage($_item->getData('image4'), $_externalWidth, $_externalHeight) ?>" alt="" />
|
108 |
+
<?php else: ?>
|
109 |
+
<span class="productslider-noimage-label"><?php echo $_external ?></span>
|
110 |
+
<?php endif; ?>
|
111 |
+
</a>
|
112 |
+
</div>
|
113 |
+
<?php endif; ?>
|
114 |
+
</div>
|
115 |
+
<?php endforeach; ?>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
<?php endif; ?>
|
app/etc/modules/PSystem_ProductSlider.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category PSystem
|
5 |
+
* @package PSystem_ProductSlider
|
6 |
+
* @author Pascal System <info@pascalsystem.pl>
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<PSystem_ProductSlider>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>community</codePool>
|
15 |
+
<depends>
|
16 |
+
<PSystem_Base/>
|
17 |
+
</depends>
|
18 |
+
</PSystem_ProductSlider>
|
19 |
+
</modules>
|
20 |
+
</config>
|
app/locale/en_US/PSystem_ProductSlider.csv
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Product Slider","Product Slider"
|
2 |
+
"Product Slider Images","Product Slider Images"
|
3 |
+
"Product Slider Width Background Image","Product Slider Width Background Image"
|
4 |
+
"Product Slider Height Background Image","Product Slider Height Background Image"
|
5 |
+
"Product Slider Width Product Image","Product Slider Width Product Image"
|
6 |
+
"Product Slider Height Product Image","Product Slider Height Product Image"
|
7 |
+
"Product Slider Width Category Image","Product Slider Width Category Image"
|
8 |
+
"Product Slider Height Category Image","Product Slider Height Category Image"
|
9 |
+
"Product Slider Width Page Image","Product Slider Width Page Image"
|
10 |
+
"Product Slider Height Page Image","Product Slider Height Page Image"
|
11 |
+
"Product Slider Width Internal Url Image","Product Slider Width Internal Url Image"
|
12 |
+
"Product Slider Height Internal Url Image","Product Slider Height Internal Url Image"
|
13 |
+
"Product Slider Width External Url Image","Product Slider Width External Url Image"
|
14 |
+
"Product Slider Height External Url Image","Product Slider Height External Url Image"
|
15 |
+
"Slider Manager","Slider Manager"
|
16 |
+
"Add Slider","Add Slider"
|
17 |
+
"Slider ID","Slider ID"
|
18 |
+
"Slider Identifier","Slider Identifier"
|
19 |
+
"Slider Title","Slider Title"
|
20 |
+
"Save Slider","Save Slider"
|
21 |
+
"Delete Slider","Delete Slider"
|
22 |
+
"Edit Slider '%s'","Edit Slider '%s'"
|
23 |
+
"Slider Information","Slider Information"
|
24 |
+
"Slider Item Manager","Slider Item Manager"
|
25 |
+
"Add Slider Item","Add Slider Item"
|
26 |
+
"Slider does not exist","Slider does not exist"
|
27 |
+
"Slider was successfully saved","Slider was successfully saved"
|
28 |
+
"Slider was successfully deleted","Slider was successfully deleted"
|
29 |
+
"Slider Item ID","Slider Item ID"
|
30 |
+
"Slider Identifier","Slider Identifier"
|
31 |
+
"Slider Item Title","Slider Item Title"
|
32 |
+
"Slider Item Active","Slider Item Active"
|
33 |
+
"Slider Item Priority","Slider Item Priority"
|
34 |
+
"Save Slider Item","Save Slider Item"
|
35 |
+
"Delete Slider Item","Delete Slider Item"
|
36 |
+
"Edit Slider Item '%s'","Edit Slider Item '%s'"
|
37 |
+
"Add Slider Item","Add Slider Item"
|
38 |
+
"Slider Item Information","Slider Item Information"
|
39 |
+
"Slider Item Product","Slider Item Product"
|
40 |
+
"Slider Item Category","Slider Item Category"
|
41 |
+
"Slider Item Page","Slider Item Page"
|
42 |
+
"Slider Internal URL","Slider Internal URL"
|
43 |
+
"Slider External URL","Slider External URL"
|
44 |
+
"Slider Item Background","Slider Item Background"
|
45 |
+
"Slider Item Page Image","Slider Item Page Image"
|
46 |
+
"Slider Item Image Internal Url","Slider Item Image Internal Url"
|
47 |
+
"Slider Item Image External Url","Slider Item Image External Url"
|
48 |
+
"Slider Item Description","Slider Item Description"
|
49 |
+
"Slider Item Content","Slider Item Content"
|
50 |
+
"Not valid extension product slider image, allowed extension jpg,jpeg,gif,png","Not valid extension product slider image, allowed extension jpg,jpeg,gif,png"
|
js/pascalsystem/productslider.js
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PS.onload(function(){
|
2 |
+
initProductSlider('.productslidercontainer');
|
3 |
+
/*
|
4 |
+
setTimeout(function(){
|
5 |
+
getProductSlider('homepage').moveSlider(1);
|
6 |
+
},3000);*/
|
7 |
+
});
|
8 |
+
function initProductSlider(selector) {
|
9 |
+
var els = $$(selector);
|
10 |
+
if (typeof window._productSlider == 'undefined')
|
11 |
+
window._productSlider = new Array();
|
12 |
+
for (var i=0;i<els.length;i++) {
|
13 |
+
window._productSlider[i] = new ProductSlider(els[i]);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
function getProductSlider(identifier) {
|
17 |
+
if (typeof window._productSlider == 'undefined')
|
18 |
+
return false;
|
19 |
+
for (var i=0;i<window._productSlider.length;i++) {
|
20 |
+
if (window._productSlider[i].getClassName().split('productslidercontainer-'+identifier).length > 1)
|
21 |
+
return window._productSlider[i];
|
22 |
+
}
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
function ProductSlider(cont) {
|
26 |
+
this.config = {
|
27 |
+
'spped' : 20,
|
28 |
+
'lastSteep' : 3,
|
29 |
+
'min_steep' : 3,
|
30 |
+
'difference_num' : 10,
|
31 |
+
'auto_play' : 7500,
|
32 |
+
'panel_tabs' : true,
|
33 |
+
'panel_tabs_pos' : 'right'
|
34 |
+
};
|
35 |
+
this.className = cont.className.toString();
|
36 |
+
this.cont = cont;
|
37 |
+
this.containerWidth = 0;
|
38 |
+
this.getContainer();
|
39 |
+
this.getSliders();
|
40 |
+
if (this.config.panel_tabs) this.renderTabs();
|
41 |
+
if (this.config.auto_play) this.autoPlay();
|
42 |
+
}
|
43 |
+
ProductSlider.prototype.getClassName = function() {
|
44 |
+
return this.className;
|
45 |
+
}
|
46 |
+
ProductSlider.prototype.getContainer = function() {
|
47 |
+
if (typeof this.container == 'undefined') {
|
48 |
+
this.container = $(this.cont).getElementsBySelector('.productslider-items')[0];
|
49 |
+
var sliders = this.getSliders();
|
50 |
+
this.containerWidth = sliders[0].getWidth();
|
51 |
+
this.container.style.width = (this.containerWidth*sliders.length).toString()+'px';
|
52 |
+
}
|
53 |
+
return this.container;
|
54 |
+
}
|
55 |
+
ProductSlider.prototype.getSliders = function() {
|
56 |
+
if (typeof this.sliders == 'undefined') {
|
57 |
+
this.sliders = $(this.container).getElementsBySelector('.productslider-item');
|
58 |
+
for (var i=0;i<this.sliders.length;i++) {
|
59 |
+
$(this.sliders[i]).setStyle({
|
60 |
+
'float' : 'left'
|
61 |
+
});
|
62 |
+
}
|
63 |
+
}
|
64 |
+
return this.sliders;
|
65 |
+
}
|
66 |
+
ProductSlider.prototype.renderTabs = function() {
|
67 |
+
this.tabs = document.createElement('div');
|
68 |
+
this.cont.appendChild(this.tabs);
|
69 |
+
this.tabs.className = 'productslider-tabs';
|
70 |
+
this.tabs.ul = document.createElement('ul');
|
71 |
+
this.tabs.appendChild(this.tabs.ul);
|
72 |
+
this.tabs.li = new Array();
|
73 |
+
for (var i=0;i<this.getSliders().length;i++) {
|
74 |
+
this.tabs.li[i] = document.createElement('li');
|
75 |
+
this.tabs.ul.appendChild(this.tabs.li[i]);
|
76 |
+
this.tabs.li[i].span = document.createElement('span');
|
77 |
+
this.tabs.li[i].appendChild(this.tabs.li[i].span);
|
78 |
+
this.tabs.li[i].productslider = this;
|
79 |
+
this.tabs.li[i].num = i;
|
80 |
+
this.tabs.li[i].onclick = function() {
|
81 |
+
this.productslider.resetAutoPlay();
|
82 |
+
this.productslider.moveSlider(this.num);
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
if (this.config.panel_tabs_pos == 'right') {
|
87 |
+
this.tabs.style.marginLeft = (this.containerWidth - $(this.tabs).getWidth() - 10).toString()+'px';
|
88 |
+
}
|
89 |
+
}
|
90 |
+
ProductSlider.prototype.autoPlay = function() {
|
91 |
+
var el = this;
|
92 |
+
this.animatorAutoPlay = setInterval(function(){
|
93 |
+
el._autoPlay();
|
94 |
+
}, this.config.auto_play);
|
95 |
+
}
|
96 |
+
ProductSlider.prototype.resetAutoPlay = function() {
|
97 |
+
if (!this.config.auto_play) {
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
if ((typeof this.animatorAutoPlay != 'undefined') && this.animatorAutoPlay) {
|
101 |
+
clearInterval(this.animatorAutoPlay);
|
102 |
+
this.animatorAutoPlay = null;
|
103 |
+
this.animatorAutoPlay = false;
|
104 |
+
}
|
105 |
+
this.autoPlay();
|
106 |
+
}
|
107 |
+
ProductSlider.prototype._autoPlay = function() {
|
108 |
+
var maxNumSlider = this.getSliders().length;
|
109 |
+
var nextNum = 0;
|
110 |
+
if (this.current<(maxNumSlider-1)) {
|
111 |
+
nextNum = this.current+1;
|
112 |
+
}
|
113 |
+
this.moveSlider(nextNum);
|
114 |
+
}
|
115 |
+
ProductSlider.prototype.moveSlider = function(num) {
|
116 |
+
if ((num>=0) && (num<this.getSliders().length) && (num!=this.current)) {
|
117 |
+
this.destMargin = -1 * num * this.containerWidth;
|
118 |
+
this.current = num;
|
119 |
+
this._animate();
|
120 |
+
}
|
121 |
+
}
|
122 |
+
ProductSlider.prototype._animate = function() {
|
123 |
+
var el = this;
|
124 |
+
if ((typeof this.animator == 'undefined') || !this.animator) {
|
125 |
+
this.animator = setInterval(function(){el._animateEffect()}, this.config['difference_num']);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
ProductSlider.prototype._animateEffect = function() {
|
129 |
+
var curMarginLeft = new Number(this.container.style.marginLeft.toString().replace(/[a-z]+/, ''));
|
130 |
+
if (isNaN(curMarginLeft)) curMarginLeft = 0;
|
131 |
+
var steepVal = (this.destMargin - curMarginLeft) / this.config['spped'];
|
132 |
+
if (steepVal > 0) {
|
133 |
+
if (steepVal < this.config.min_steep)
|
134 |
+
steepVal = this.config.min_steep;
|
135 |
+
} else {
|
136 |
+
if (steepVal > (-1 * this.config.min_steep))
|
137 |
+
steepVal = -1 * this.config.min_steep;
|
138 |
+
}
|
139 |
+
var nextMargin = curMarginLeft + steepVal;
|
140 |
+
if ((nextMargin-this.config['lastSteep'] < this.destMargin) && (nextMargin+this.config['lastSteep'] > this.destMargin)) {
|
141 |
+
nextMargin = this.destMargin;
|
142 |
+
clearInterval(this.animator);
|
143 |
+
this.animator = null;
|
144 |
+
this.animator = false;
|
145 |
+
}
|
146 |
+
this.container.style.marginLeft = nextMargin.toString()+'px';
|
147 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>PSystem_ProductSlider</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Banner Slider with supports: products, category, pages, internal and external links.</summary>
|
10 |
+
<description>You can create many independent slider and associate product, category, page or links.
|
11 |
+
This module has many function in AdminPanel please see screen and you can try this.
|
12 |
+
You can set width and height for all images on item slider.
|
13 |
+
Customer can manually switch slider items, or use autoplay.</description>
|
14 |
+
<notes>This module was tested in Magento Commerce version 1.4.0.1, 1.5.0.1 and 1.6.2.0, and work in this version smoothly. Also test in Firefox 3.6, Chrome, Opera and IE 7,8,9.</notes>
|
15 |
+
<authors><author><name>Pascal System</name><user>auto-converted</user><email>info@pascalsystem.pl</email></author></authors>
|
16 |
+
<date>2012-02-25</date>
|
17 |
+
<time>12:58:18</time>
|
18 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ps_productslider.xml" hash="5e2a6922382859611e700cfd4fe475b7"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ps_productslider.xml" hash="9a8b99be33c67fb5115b52dd47784915"/></dir><dir name="template"><dir name="productslider"><file name="slider.phtml" hash="087088b4af3d12932d32ca0cdb6c89a4"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PSystem_ProductSlider.csv" hash="836d281e38af0f8201fdcf759710cef4"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><dir name="pascalsystem"><file name="productslider.css" hash="92af1622b3b138638ae032cdeced1543"/></dir></dir><dir name="images"><dir name="pascalsystem"><file name="productslider-point.png" hash="7b29dbc8353c7aaa6048fb0213a2ea5d"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="pascalsystem"><file name="productslider.js" hash="7e2cf29c93bea484fe68dff8ac8c9fec"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PSystem_ProductSlider.xml" hash="5e87754e77737612e95e791d3539fc0e"/></dir></target><target name="magecommunity"><dir name="PSystem"><dir name="ProductSlider"><dir name="Block"><dir name="Adminhtml"><dir name="Item"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="fe78f527f5b4e2bbe20203f0dbaa089b"/></dir><file name="Form.php" hash="bd5d8fdcce9d577000d7f193f96513f0"/><file name="Tabs.php" hash="9eafac1b247799382b7c10af05957034"/></dir><file name="Edit.php" hash="72f18b12d23271e86890c987a5d7392c"/><file name="Grid.php" hash="aa7649a64873cd022102c26fc466487b"/></dir><dir name="Slider"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="698b579701f55213cbc268fb164a0afc"/></dir><file name="Form.php" hash="94c5ac833cb71e350ee0eb7337b77a58"/><file name="Tabs.php" hash="1bbd2b5728044cdb57e9264bee07472c"/></dir><file name="Edit.php" hash="3752f54bec2e8a0ee4d76e52f57670ec"/><file name="Grid.php" hash="2527076fe034e260b85de07f44cc2d5d"/></dir><file name="Item.php" hash="3cd50b910e24abd183eaec3e7b4a0e18"/><file name="Slider.php" hash="8d88997b66875517ff58519734b418fc"/></dir><file name="Slider.php" hash="452a6d481a8dafc98dd21bb5847e225d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ItemController.php" hash="92d83ac00844278cc0bf7b0a6b99ba72"/><file name="SliderController.php" hash="aa730af37d2918f10d1b899a8b59434a"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8fdc937324e238c5d1a9790e4bb408dd"/><file name="config.xml" hash="f89e7dffe2137bb33fe2ed1205ddd518"/><file name="system.xml" hash="39b95059e92066735faca4195c314f80"/></dir><dir name="Helper"><file name="Data.php" hash="a966a1a126cf64ab95f2afe5841944ec"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Item"><file name="Collection.php" hash="96d09550e461116abcdd208d9efbeecb"/></dir><dir name="Slider"><file name="Collection.php" hash="c2d266f1bcc7b3839786cc55eaea6952"/></dir><file name="Item.php" hash="827c6f6bf2bc341aa54593f0cda06c18"/><file name="Slider.php" hash="812a6a547a627c134b9a14b3a22c0740"/></dir><file name="Item.php" hash="8ecf97cf9de0d98e6b77d04b1491165e"/><file name="Slider.php" hash="c16d7c9983594fe1bd0a6cf95819741d"/></dir><dir name="sql"><dir name="productslider_setup"><file name="mysql4-install-1.0.0.php" hash="2362305cc46d08935505c3ff13652db0"/></dir></dir></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><package><name>PSystem_Base</name><channel>community</channel><min>1.1.1</min><max></max></package></required></dependencies>
|
21 |
+
</package>
|
skin/frontend/default/default/css/pascalsystem/productslider.css
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.productslidercontainer {
|
2 |
+
width:685px;
|
3 |
+
height:200px;
|
4 |
+
margin-bottom:10px;
|
5 |
+
}
|
6 |
+
.productslider {
|
7 |
+
border:1px solid #000000;
|
8 |
+
width:685px;
|
9 |
+
height:200px;
|
10 |
+
overflow:hidden;
|
11 |
+
position:absolute;
|
12 |
+
}
|
13 |
+
.productslider .productslider-item {
|
14 |
+
width:685px;
|
15 |
+
height:200px;
|
16 |
+
overflow:hidden;
|
17 |
+
}
|
18 |
+
.productslider .productslider-image {
|
19 |
+
position:absolute;
|
20 |
+
}
|
21 |
+
.productslider .product-cont {
|
22 |
+
position:absolute;
|
23 |
+
margin-top:35px;
|
24 |
+
margin-left:15px;
|
25 |
+
}
|
26 |
+
.productslider .product-cont img {
|
27 |
+
border:1px solid #000000;
|
28 |
+
}
|
29 |
+
.productslider .product-cont .price-box {
|
30 |
+
text-align:center;
|
31 |
+
margin:0px;
|
32 |
+
overflow:hidden;
|
33 |
+
height:20px;
|
34 |
+
}
|
35 |
+
.productslider .product-cont .price-box p {
|
36 |
+
display:inline;
|
37 |
+
margin-right:10px;
|
38 |
+
}
|
39 |
+
.productslider .product-cont .price-box .price-label {
|
40 |
+
display:none;
|
41 |
+
}
|
42 |
+
.productslider .productslider-noimage-label {
|
43 |
+
font-size:16px;
|
44 |
+
font-weight:bold;
|
45 |
+
}
|
46 |
+
.productslider .category-cont {
|
47 |
+
position:absolute;
|
48 |
+
margin-left:185px;
|
49 |
+
margin-top:5px;
|
50 |
+
}
|
51 |
+
.productslider .page-cont {
|
52 |
+
position:absolute;
|
53 |
+
margin-left:335px;
|
54 |
+
margin-top:75px;
|
55 |
+
}
|
56 |
+
.productslider .internal-cont {
|
57 |
+
position:absolute;
|
58 |
+
margin-left:550px;
|
59 |
+
margin-top:5px;
|
60 |
+
}
|
61 |
+
.productslider .internal-cont .productslider-noimage-label {
|
62 |
+
font-size:12px;
|
63 |
+
font-weight:normal;
|
64 |
+
}
|
65 |
+
.productslider .external-cont {
|
66 |
+
position:absolute;
|
67 |
+
margin-left:550px;
|
68 |
+
margin-top:100px;
|
69 |
+
}
|
70 |
+
.productslider .external-cont .productslider-noimage-label {
|
71 |
+
font-size:12px;
|
72 |
+
font-weight:normal;
|
73 |
+
}
|
74 |
+
.productslider .productslider-title {
|
75 |
+
margin-top:2px;
|
76 |
+
margin-left:2px;
|
77 |
+
position:absolute;
|
78 |
+
}
|
79 |
+
.productslider .productslider-description {
|
80 |
+
margin-top:100px;
|
81 |
+
margin-left:165px;
|
82 |
+
width:150px;
|
83 |
+
position:absolute;
|
84 |
+
}
|
85 |
+
.productslider .productslider-html {
|
86 |
+
position:absolute;
|
87 |
+
margin-top:5px;
|
88 |
+
margin-left:340px;
|
89 |
+
width:200px;
|
90 |
+
}
|
91 |
+
.productslidercontainer .productslider-tabs {
|
92 |
+
margin-top:180px;
|
93 |
+
margin-right:10px;
|
94 |
+
position:absolute;
|
95 |
+
}
|
96 |
+
.productslidercontainer .productslider-tabs ul, .productslidercontainer .productslider-tabs li {
|
97 |
+
margin:0px;
|
98 |
+
padding:0px;
|
99 |
+
list-style:none;
|
100 |
+
}
|
101 |
+
.productslidercontainer .productslider-tabs li {
|
102 |
+
margin-right:5px;
|
103 |
+
float:left;
|
104 |
+
cursor:pointer;
|
105 |
+
}
|
106 |
+
.productslidercontainer .productslider-tabs li span {
|
107 |
+
width:18px;
|
108 |
+
height:18px;
|
109 |
+
background:url(../../images/pascalsystem/productslider-point.png) center center no-repeat;
|
110 |
+
display:block;
|
111 |
+
}
|
skin/frontend/default/default/images/pascalsystem/productslider-point.png
ADDED
Binary file
|