Version Notes
Banner slider renamed
Download this release
Release Info
Developer | Magento Core Team |
Extension | magestore_banner |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Magestore/Banner/Block/Adminhtml/Banner.php +12 -0
- app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit.php +45 -0
- app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit/Form.php +19 -0
- app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit/Tab/Form.php +64 -0
- app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit/Tabs.php +24 -0
- app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Grid.php +116 -0
- app/code/community/Magestore/Banner/Block/Banner.php +17 -0
- app/code/community/Magestore/Banner/Helper/Data.php +6 -0
- app/code/community/Magestore/Banner/Model/Banner.php +10 -0
- app/code/community/Magestore/Banner/Model/Mysql4/Banner.php +10 -0
- app/code/community/Magestore/Banner/Model/Mysql4/Banner/Collection.php +10 -0
- app/code/community/Magestore/Banner/Model/Status.php +15 -0
- app/code/community/Magestore/Banner/controllers/Adminhtml/BannerController.php +214 -0
- app/code/community/Magestore/Banner/controllers/IndexController.php +47 -0
- app/code/community/Magestore/Banner/etc/config.xml +120 -0
- app/code/community/Magestore/Banner/sql/banner_setup/mysql4-install-1.0.0.php +24 -0
- app/design/adminhtml/default/default/layout/banner.xml +8 -0
- app/design/frontend/default/default/layout/banner.xml +10 -0
- app/design/frontend/default/default/template/banner/banner.phtml +54 -0
- app/etc/modules/Magestore_Banner.xml +9 -0
- package.xml +18 -0
- skin/frontend/default/default/banner/ajaxtabs.js +159 -0
- skin/frontend/default/default/banner/banner.css +86 -0
app/code/community/Magestore/Banner/Block/Adminhtml/Banner.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Banner_Block_Adminhtml_Banner extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_banner';
|
7 |
+
$this->_blockGroup = 'banner';
|
8 |
+
$this->_headerText = Mage::helper('banner')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('banner')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Block_Adminhtml_Banner_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'banner';
|
11 |
+
$this->_controller = 'adminhtml_banner';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('banner')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('banner')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('banner_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'banner_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'banner_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('banner_data') && Mage::registry('banner_data')->getId() ) {
|
40 |
+
return Mage::helper('banner')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('banner_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('banner')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Block_Adminhtml_Banner_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Block_Adminhtml_Banner_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('banner_form', array('legend'=>Mage::helper('banner')->__('Item information')));
|
10 |
+
|
11 |
+
$fieldset->addField('title', 'text', array(
|
12 |
+
'label' => Mage::helper('banner')->__('Title'),
|
13 |
+
'class' => 'required-entry',
|
14 |
+
'required' => true,
|
15 |
+
'name' => 'title',
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('filename', 'file', array(
|
19 |
+
'label' => Mage::helper('banner')->__('File'),
|
20 |
+
'required' => false,
|
21 |
+
'name' => 'filename',
|
22 |
+
));
|
23 |
+
|
24 |
+
$fieldset->addField('status', 'select', array(
|
25 |
+
'label' => Mage::helper('banner')->__('Status'),
|
26 |
+
'name' => 'status',
|
27 |
+
'values' => array(
|
28 |
+
array(
|
29 |
+
'value' => 1,
|
30 |
+
'label' => Mage::helper('banner')->__('Enabled'),
|
31 |
+
),
|
32 |
+
|
33 |
+
array(
|
34 |
+
'value' => 2,
|
35 |
+
'label' => Mage::helper('banner')->__('Disabled'),
|
36 |
+
),
|
37 |
+
),
|
38 |
+
));
|
39 |
+
|
40 |
+
$fieldset->addField('weblink', 'text', array(
|
41 |
+
'label' => Mage::helper('bannerslider')->__('Web Url'),
|
42 |
+
'required' => false,
|
43 |
+
'name' => 'weblink',
|
44 |
+
));
|
45 |
+
|
46 |
+
$fieldset->addField('content', 'editor', array(
|
47 |
+
'name' => 'content',
|
48 |
+
'label' => Mage::helper('banner')->__('Description'),
|
49 |
+
'title' => Mage::helper('banner')->__('Description'),
|
50 |
+
'style' => 'width:700px; height:500px;',
|
51 |
+
'wysiwyg' => false,
|
52 |
+
'required' => false,
|
53 |
+
));
|
54 |
+
|
55 |
+
if ( Mage::getSingleton('adminhtml/session')->getBannerData() )
|
56 |
+
{
|
57 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getBannerData());
|
58 |
+
Mage::getSingleton('adminhtml/session')->setBannerData(null);
|
59 |
+
} elseif ( Mage::registry('banner_data') ) {
|
60 |
+
$form->setValues(Mage::registry('banner_data')->getData());
|
61 |
+
}
|
62 |
+
return parent::_prepareForm();
|
63 |
+
}
|
64 |
+
}
|
app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Block_Adminhtml_Banner_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('banner_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('banner')->__('Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('banner')->__('Item Information'),
|
18 |
+
'title' => Mage::helper('banner')->__('Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('banner/adminhtml_banner_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Magestore/Banner/Block/Adminhtml/Banner/Grid.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Block_Adminhtml_Banner_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('bannerGrid');
|
9 |
+
$this->setDefaultSort('banner_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('banner/banner')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('banner_id', array(
|
24 |
+
'header' => Mage::helper('banner')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'banner_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('banner')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
/*
|
37 |
+
$this->addColumn('content', array(
|
38 |
+
'header' => Mage::helper('banner')->__('Item Content'),
|
39 |
+
'width' => '150px',
|
40 |
+
'index' => 'content',
|
41 |
+
));
|
42 |
+
*/
|
43 |
+
|
44 |
+
$this->addColumn('status', array(
|
45 |
+
'header' => Mage::helper('banner')->__('Status'),
|
46 |
+
'align' => 'left',
|
47 |
+
'width' => '80px',
|
48 |
+
'index' => 'status',
|
49 |
+
'type' => 'options',
|
50 |
+
'options' => array(
|
51 |
+
1 => 'Enabled',
|
52 |
+
2 => 'Disabled',
|
53 |
+
),
|
54 |
+
));
|
55 |
+
|
56 |
+
$this->addColumn('action',
|
57 |
+
array(
|
58 |
+
'header' => Mage::helper('banner')->__('Action'),
|
59 |
+
'width' => '100',
|
60 |
+
'type' => 'action',
|
61 |
+
'getter' => 'getId',
|
62 |
+
'actions' => array(
|
63 |
+
array(
|
64 |
+
'caption' => Mage::helper('banner')->__('Edit'),
|
65 |
+
'url' => array('base'=> '*/*/edit'),
|
66 |
+
'field' => 'id'
|
67 |
+
)
|
68 |
+
),
|
69 |
+
'filter' => false,
|
70 |
+
'sortable' => false,
|
71 |
+
'index' => 'stores',
|
72 |
+
'is_system' => true,
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('banner')->__('CSV'));
|
76 |
+
$this->addExportType('*/*/exportXml', Mage::helper('banner')->__('XML'));
|
77 |
+
|
78 |
+
return parent::_prepareColumns();
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _prepareMassaction()
|
82 |
+
{
|
83 |
+
$this->setMassactionIdField('banner_id');
|
84 |
+
$this->getMassactionBlock()->setFormFieldName('banner');
|
85 |
+
|
86 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
87 |
+
'label' => Mage::helper('banner')->__('Delete'),
|
88 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
89 |
+
'confirm' => Mage::helper('banner')->__('Are you sure?')
|
90 |
+
));
|
91 |
+
|
92 |
+
$statuses = Mage::getSingleton('banner/status')->getOptionArray();
|
93 |
+
|
94 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
95 |
+
$this->getMassactionBlock()->addItem('status', array(
|
96 |
+
'label'=> Mage::helper('banner')->__('Change status'),
|
97 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
98 |
+
'additional' => array(
|
99 |
+
'visibility' => array(
|
100 |
+
'name' => 'status',
|
101 |
+
'type' => 'select',
|
102 |
+
'class' => 'required-entry',
|
103 |
+
'label' => Mage::helper('banner')->__('Status'),
|
104 |
+
'values' => $statuses
|
105 |
+
)
|
106 |
+
)
|
107 |
+
));
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getRowUrl($row)
|
112 |
+
{
|
113 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
app/code/community/Magestore/Banner/Block/Banner.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Banner_Block_Banner extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getBanner()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('banner')) {
|
12 |
+
$this->setData('banner', Mage::registry('banner'));
|
13 |
+
}
|
14 |
+
return $this->getData('banner');
|
15 |
+
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Magestore/Banner/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Magestore/Banner/Model/Banner.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Model_Banner extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('banner/banner');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Banner/Model/Mysql4/Banner.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Model_Mysql4_Banner extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the banner_id refers to the key field in your database table.
|
8 |
+
$this->_init('banner/banner', 'banner_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Banner/Model/Mysql4/Banner/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Model_Mysql4_Banner_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('banner/banner');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Magestore/Banner/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('banner')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('banner')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Magestore/Banner/controllers/Adminhtml/BannerController.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Magestore_Banner_Adminhtml_BannerController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('banner/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('banner/banner')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('banner_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('banner/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('banner/adminhtml_banner_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('banner/adminhtml_banner_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('banner')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
$model = Mage::getModel('banner/banner');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('banner')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('banner')->__('Unable to find item to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('banner/banner');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$bannerIds = $this->getRequest()->getParam('banner');
|
137 |
+
if(!is_array($bannerIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($bannerIds as $bannerId) {
|
142 |
+
$banner = Mage::getModel('banner/banner')->load($bannerId);
|
143 |
+
$banner->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($bannerIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$bannerIds = $this->getRequest()->getParam('banner');
|
160 |
+
if(!is_array($bannerIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($bannerIds as $bannerId) {
|
165 |
+
$banner = Mage::getSingleton('banner/banner')
|
166 |
+
->load($bannerId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($bannerIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function exportCsvAction()
|
182 |
+
{
|
183 |
+
$fileName = 'banner.csv';
|
184 |
+
$content = $this->getLayout()->createBlock('banner/adminhtml_banner_grid')
|
185 |
+
->getCsv();
|
186 |
+
|
187 |
+
$this->_sendUploadResponse($fileName, $content);
|
188 |
+
}
|
189 |
+
|
190 |
+
public function exportXmlAction()
|
191 |
+
{
|
192 |
+
$fileName = 'banner.xml';
|
193 |
+
$content = $this->getLayout()->createBlock('banner/adminhtml_banner_grid')
|
194 |
+
->getXml();
|
195 |
+
|
196 |
+
$this->_sendUploadResponse($fileName, $content);
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
200 |
+
{
|
201 |
+
$response = $this->getResponse();
|
202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
203 |
+
$response->setHeader('Pragma', 'public', true);
|
204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
206 |
+
$response->setHeader('Last-Modified', date('r'));
|
207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
208 |
+
$response->setHeader('Content-Length', strlen($content));
|
209 |
+
$response->setHeader('Content-type', $contentType);
|
210 |
+
$response->setBody($content);
|
211 |
+
$response->sendResponse();
|
212 |
+
die;
|
213 |
+
}
|
214 |
+
}
|
app/code/community/Magestore/Banner/controllers/IndexController.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Magestore_Banner_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Load an object by id
|
9 |
+
* Request looking like:
|
10 |
+
* http://site.com/banner?id=15
|
11 |
+
* or
|
12 |
+
* http://site.com/banner/id/15
|
13 |
+
*/
|
14 |
+
/*
|
15 |
+
$banner_id = $this->getRequest()->getParam('id');
|
16 |
+
|
17 |
+
if($banner_id != null && $banner_id != '') {
|
18 |
+
$banner = Mage::getModel('banner/banner')->load($banner_id)->getData();
|
19 |
+
} else {
|
20 |
+
$banner = null;
|
21 |
+
}
|
22 |
+
*/
|
23 |
+
|
24 |
+
/*
|
25 |
+
* If no param we load a the last created item
|
26 |
+
*/
|
27 |
+
/*
|
28 |
+
if($banner == null) {
|
29 |
+
$resource = Mage::getSingleton('core/resource');
|
30 |
+
$read= $resource->getConnection('core_read');
|
31 |
+
$bannerTable = $resource->getTableName('banner');
|
32 |
+
|
33 |
+
$select = $read->select()
|
34 |
+
->from($bannerTable,array('banner_id','title','content','status'))
|
35 |
+
->where('status',1)
|
36 |
+
->order('created_time DESC') ;
|
37 |
+
|
38 |
+
$banner = $read->fetchRow($select);
|
39 |
+
}
|
40 |
+
Mage::register('banner', $banner);
|
41 |
+
*/
|
42 |
+
|
43 |
+
|
44 |
+
$this->loadLayout();
|
45 |
+
$this->renderLayout();
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Magestore/Banner/etc/config.xml
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magestore_Banner>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Magestore_Banner>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<banner>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Magestore_Banner</module>
|
14 |
+
<frontName>banner</frontName>
|
15 |
+
</args>
|
16 |
+
</banner>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<banner>
|
21 |
+
<file>banner.xml</file>
|
22 |
+
</banner>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<banner>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Magestore_Banner</module>
|
32 |
+
<frontName>banner</frontName>
|
33 |
+
</args>
|
34 |
+
</banner>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<banner module="banner">
|
40 |
+
<title>Banner</title>
|
41 |
+
<sort_order>71</sort_order>
|
42 |
+
<children>
|
43 |
+
<items module="banner">
|
44 |
+
<title>Manage Items</title>
|
45 |
+
<sort_order>0</sort_order>
|
46 |
+
<action>banner/adminhtml_banner</action>
|
47 |
+
</items>
|
48 |
+
</children>
|
49 |
+
</banner>
|
50 |
+
</menu>
|
51 |
+
<acl>
|
52 |
+
<resources>
|
53 |
+
<all>
|
54 |
+
<title>Allow Everything</title>
|
55 |
+
</all>
|
56 |
+
<admin>
|
57 |
+
<children>
|
58 |
+
<Magestore_Banner>
|
59 |
+
<title>Banner Module</title>
|
60 |
+
<sort_order>10</sort_order>
|
61 |
+
</Magestore_Banner>
|
62 |
+
</children>
|
63 |
+
</admin>
|
64 |
+
</resources>
|
65 |
+
</acl>
|
66 |
+
<layout>
|
67 |
+
<updates>
|
68 |
+
<banner>
|
69 |
+
<file>banner.xml</file>
|
70 |
+
</banner>
|
71 |
+
</updates>
|
72 |
+
</layout>
|
73 |
+
</adminhtml>
|
74 |
+
<global>
|
75 |
+
<models>
|
76 |
+
<banner>
|
77 |
+
<class>Magestore_Banner_Model</class>
|
78 |
+
<resourceModel>banner_mysql4</resourceModel>
|
79 |
+
</banner>
|
80 |
+
<banner_mysql4>
|
81 |
+
<class>Magestore_Banner_Model_Mysql4</class>
|
82 |
+
<entities>
|
83 |
+
<banner>
|
84 |
+
<table>banner</table>
|
85 |
+
</banner>
|
86 |
+
</entities>
|
87 |
+
</banner_mysql4>
|
88 |
+
</models>
|
89 |
+
<resources>
|
90 |
+
<banner_setup>
|
91 |
+
<setup>
|
92 |
+
<module>Magestore_Banner</module>
|
93 |
+
</setup>
|
94 |
+
<connection>
|
95 |
+
<use>core_setup</use>
|
96 |
+
</connection>
|
97 |
+
</banner_setup>
|
98 |
+
<banner_write>
|
99 |
+
<connection>
|
100 |
+
<use>core_write</use>
|
101 |
+
</connection>
|
102 |
+
</banner_write>
|
103 |
+
<banner_read>
|
104 |
+
<connection>
|
105 |
+
<use>core_read</use>
|
106 |
+
</connection>
|
107 |
+
</banner_read>
|
108 |
+
</resources>
|
109 |
+
<blocks>
|
110 |
+
<banner>
|
111 |
+
<class>Magestore_Banner_Block</class>
|
112 |
+
</banner>
|
113 |
+
</blocks>
|
114 |
+
<helpers>
|
115 |
+
<banner>
|
116 |
+
<class>Magestore_Banner_Helper</class>
|
117 |
+
</banner>
|
118 |
+
</helpers>
|
119 |
+
</global>
|
120 |
+
</config>
|
app/code/community/Magestore/Banner/sql/banner_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('banner')};
|
10 |
+
CREATE TABLE {$this->getTable('banner')} (
|
11 |
+
`banner_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`title` varchar(255) NOT NULL default '',
|
13 |
+
`filename` varchar(255) NOT NULL default '',
|
14 |
+
`content` text NULL,
|
15 |
+
`status` smallint(6) NOT NULL default '0',
|
16 |
+
`weblink` varchar(255) NULL,
|
17 |
+
`created_time` datetime NULL,
|
18 |
+
`update_time` datetime NULL,
|
19 |
+
PRIMARY KEY (`banner_id`)
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
21 |
+
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/banner.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<banner_adminhtml_banner_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="banner/adminhtml_banner" name="banner" />
|
6 |
+
</reference>
|
7 |
+
</banner_adminhtml_banner_index>
|
8 |
+
</layout>
|
app/design/frontend/default/default/layout/banner.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
</default>
|
5 |
+
<banner_index_index>
|
6 |
+
<reference name="content">
|
7 |
+
<block type="banner/banner" name="banner" template="banner/banner.phtml" />
|
8 |
+
</reference>
|
9 |
+
</banner_index_index>
|
10 |
+
</layout>
|
app/design/frontend/default/default/template/banner/banner.phtml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('banner/ajaxtabs.js') ?>"></script>
|
2 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('banner/banner.css');?>" media="all" />
|
3 |
+
|
4 |
+
<?php
|
5 |
+
$bannerCollection = Mage::getModel('banner/banner')->getCollection();
|
6 |
+
$configData = Mage::getStoreConfig('banner');
|
7 |
+
$i = 0;
|
8 |
+
?>
|
9 |
+
<div class="slide-container">
|
10 |
+
<div class="slide-show" id="slide-images">
|
11 |
+
<div id="pettabs" class="indentmenu">
|
12 |
+
<ul>
|
13 |
+
<?php
|
14 |
+
foreach($bannerCollection as $banner):
|
15 |
+
$i++;
|
16 |
+
?>
|
17 |
+
<li><a href="#" rel="tab<?php echo $i;?>" <?php if ($i == 1) { echo 'class="selected"'; }?>><?php echo $i;?></a></li>
|
18 |
+
<?php
|
19 |
+
endforeach;
|
20 |
+
?>
|
21 |
+
</ul>
|
22 |
+
</div>
|
23 |
+
<div style="width:240px;text-align:justify;padding: 5px; margin-bottom:1em">
|
24 |
+
<?php
|
25 |
+
$i = 0;
|
26 |
+
foreach ($bannerCollection as $banner):
|
27 |
+
$i++;
|
28 |
+
?>
|
29 |
+
<div id="tab<?php echo $i;?>" class="tabcontent">
|
30 |
+
<a href="<?php echo $banner['weblink'];?>">
|
31 |
+
<img title="<?php echo $banner['title']?>" alt="<?php echo $banner['title']?>" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $banner['filename']?>" alt="" style="width:442px; height:232px;"/>
|
32 |
+
<?php if ($configData['settings']['show_description'] == '1'):?>
|
33 |
+
<div class="banner_content"><p><?php echo $banner['content']; ?></p></div>
|
34 |
+
<?php endif;?>
|
35 |
+
</a>
|
36 |
+
</div>
|
37 |
+
<?php
|
38 |
+
endforeach;
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
</div>
|
43 |
+
<?php
|
44 |
+
$timeDelay = $configData['settings']['time_delay'] * 1000;
|
45 |
+
?>
|
46 |
+
<script type="text/javascript">
|
47 |
+
<?php
|
48 |
+
echo 'var delay = ' . $timeDelay . ';';
|
49 |
+
?>
|
50 |
+
var mypets=new ddtabcontent("pettabs");
|
51 |
+
mypets.setpersist(true);
|
52 |
+
mypets.setselectedClassTarget("link");
|
53 |
+
mypets.init(delay);
|
54 |
+
</script>
|
app/etc/modules/Magestore_Banner.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magestore_Banner>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Magestore_Banner>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>magestore_banner</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Module banner slider renamed</summary>
|
10 |
+
<description>Module banner slider renamed</description>
|
11 |
+
<notes>Banner slider renamed</notes>
|
12 |
+
<authors><author><name>Magestore</name><user>auto-converted</user><email>magestore@gmail.com</email></author></authors>
|
13 |
+
<date>2009-08-29</date>
|
14 |
+
<time>16:08:51</time>
|
15 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="banner.xml" hash="2dde54c25c682ce98b28dee3444144af"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="banner.xml" hash="ed159617341d54b8dab520c4fe8a7f63"/></dir><dir name="template"><dir name="banner"><file name="banner.phtml" hash="f4559996cb548870e685432a46db947e"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="banner"><file name="ajaxtabs.js" hash="d8f9c4444580d285972803eed7392b8f"/><file name="banner.css" hash="e4186a5d5d445f618dec0fbbf913ad4b"/></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Magestore"><dir name="Banner"><dir name="Block"><file name="Banner.php" hash="00d030aa4783d16672926dacbe4a0105"/><dir name="Adminhtml"><file name="Banner.php" hash="7a2d16ee3501dd021d0dcf4fcdb8980f"/><dir name="Banner"><file name="Edit.php" hash="53453f0d90c582dfc438546703675559"/><file name="Grid.php" hash="2125182b582f4c68189b7921d055961c"/><dir name="Edit"><file name="Form.php" hash="6e29e5f686a13e81f21530e14443c7ca"/><file name="Tabs.php" hash="4f7291b2839f1ffbb84edb88908e4e38"/><dir name="Tab"><file name="Form.php" hash="46a98ca60f98f314d7213469cb3e1ab4"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="096b6815481306dc3e24d47cdddfab35"/><dir name="Adminhtml"><file name="BannerController.php" hash="7338ae86621fab4eb35589db93178480"/></dir></dir><dir name="etc"><file name="config.xml" hash="944570e68fb5c8df90ad9dc88ab963d0"/></dir><dir name="Helper"><file name="Data.php" hash="8016a51ab3922da84d5060d0c247858c"/></dir><dir name="Model"><file name="Banner.php" hash="e63cf30dde02e3caa31e5962b92a5372"/><file name="Status.php" hash="04e4b62e5ac7c3fbcac28b352e1dcf9a"/><dir name="Mysql4"><file name="Banner.php" hash="23c679cd0e1555501d1f61821e98576b"/><dir name="Banner"><file name="Collection.php" hash="e39c21689287a9bcfc1b107544b8ccf7"/></dir></dir></dir><dir name="sql"><dir name="banner_setup"><file name="mysql4-install-1.0.0.php" hash="72cd6dbb54c384bd8dc8d1271e076bd1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magestore_Banner.xml" hash="50616a2b2a2066845e30351d8afb22db"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|
skin/frontend/default/default/banner/ajaxtabs.js
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
//** Tab Content script v2.0- � Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
|
2 |
+
//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:
|
3 |
+
// -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected
|
4 |
+
// -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted
|
5 |
+
// -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)
|
6 |
+
// -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container
|
7 |
+
//** Updated Feb 18th, 08 to version 2.1: Adds a "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically
|
8 |
+
//** Updated April 8th, 08 to version 2.2: Adds support for expanding a tab using a URL parameter (ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0)
|
9 |
+
|
10 |
+
////NO NEED TO EDIT BELOW////////////////////////
|
11 |
+
|
12 |
+
function ddtabcontent(tabinterfaceid){
|
13 |
+
this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
|
14 |
+
this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
|
15 |
+
this.enabletabpersistence=true
|
16 |
+
this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
|
17 |
+
this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
|
18 |
+
this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
|
19 |
+
this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
|
20 |
+
this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
|
21 |
+
}
|
22 |
+
|
23 |
+
ddtabcontent.getCookie=function(Name){
|
24 |
+
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
|
25 |
+
if (document.cookie.match(re)) //if cookie found
|
26 |
+
return document.cookie.match(re)[0].split("=")[1] //return its value
|
27 |
+
return ""
|
28 |
+
}
|
29 |
+
|
30 |
+
ddtabcontent.setCookie=function(name, value){
|
31 |
+
document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
|
32 |
+
}
|
33 |
+
|
34 |
+
ddtabcontent.prototype={
|
35 |
+
|
36 |
+
expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
|
37 |
+
this.cancelautorun() //stop auto cycling of tabs (if running)
|
38 |
+
var tabref=""
|
39 |
+
try{
|
40 |
+
if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
|
41 |
+
tabref=document.getElementById(tabid_or_position)
|
42 |
+
else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
|
43 |
+
tabref=this.tabs[tabid_or_position]
|
44 |
+
}
|
45 |
+
catch(err){alert("Invalid Tab ID or position entered!")}
|
46 |
+
if (tabref!="") //if a valid tab is found based on function parameter
|
47 |
+
this.expandtab(tabref) //expand this tab
|
48 |
+
},
|
49 |
+
|
50 |
+
cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
|
51 |
+
if (dir=="next"){
|
52 |
+
var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
|
53 |
+
}
|
54 |
+
else if (dir=="prev"){
|
55 |
+
var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
|
56 |
+
}
|
57 |
+
if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
|
58 |
+
this.cancelautorun() //stop auto cycling of tabs (if running)
|
59 |
+
this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
|
60 |
+
},
|
61 |
+
|
62 |
+
setpersist:function(bool){ //PUBLIC function to toggle persistence feature
|
63 |
+
this.enabletabpersistence=bool
|
64 |
+
},
|
65 |
+
|
66 |
+
setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
|
67 |
+
this.selectedClassTarget=objstr || "link"
|
68 |
+
},
|
69 |
+
|
70 |
+
getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
|
71 |
+
return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
|
72 |
+
},
|
73 |
+
|
74 |
+
urlparamselect:function(tabinterfaceid){
|
75 |
+
var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
|
76 |
+
return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
|
77 |
+
},
|
78 |
+
|
79 |
+
expandtab:function(tabref){
|
80 |
+
var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
|
81 |
+
//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
|
82 |
+
var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
|
83 |
+
this.expandsubcontent(subcontentid)
|
84 |
+
this.expandrevcontent(associatedrevids)
|
85 |
+
for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
|
86 |
+
this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
|
87 |
+
}
|
88 |
+
if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
|
89 |
+
ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
|
90 |
+
this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
|
91 |
+
},
|
92 |
+
|
93 |
+
expandsubcontent:function(subcontentid){
|
94 |
+
for (var i=0; i<this.subcontentids.length; i++){
|
95 |
+
var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
|
96 |
+
subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
|
97 |
+
}
|
98 |
+
},
|
99 |
+
|
100 |
+
expandrevcontent:function(associatedrevids){
|
101 |
+
var allrevids=this.revcontentids
|
102 |
+
for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
|
103 |
+
//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
|
104 |
+
document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
|
105 |
+
}
|
106 |
+
},
|
107 |
+
|
108 |
+
setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
|
109 |
+
for (var i=0; i<this.hottabspositions.length; i++){
|
110 |
+
if (tabposition==this.hottabspositions[i]){
|
111 |
+
this.currentTabIndex=i
|
112 |
+
break
|
113 |
+
}
|
114 |
+
}
|
115 |
+
},
|
116 |
+
|
117 |
+
autorun:function(){ //function to auto cycle through and select tabs based on a set interval
|
118 |
+
this.cycleit('next', true)
|
119 |
+
},
|
120 |
+
|
121 |
+
cancelautorun:function(){
|
122 |
+
if (typeof this.autoruntimer!="undefined")
|
123 |
+
clearInterval(this.autoruntimer)
|
124 |
+
},
|
125 |
+
|
126 |
+
init:function(automodeperiod){
|
127 |
+
var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
|
128 |
+
var selectedtab=-1 //Currently selected tab index (-1 meaning none)
|
129 |
+
var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
|
130 |
+
this.automodeperiod=automodeperiod || 0
|
131 |
+
for (var i=0; i<this.tabs.length; i++){
|
132 |
+
this.tabs[i].tabposition=i //remember position of tab relative to its peers
|
133 |
+
if (this.tabs[i].getAttribute("rel")){
|
134 |
+
var tabinstance=this
|
135 |
+
this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
|
136 |
+
this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
|
137 |
+
this.tabs[i].onclick=function(){
|
138 |
+
tabinstance.expandtab(this)
|
139 |
+
tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
|
140 |
+
return false
|
141 |
+
}
|
142 |
+
if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
|
143 |
+
this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
|
144 |
+
}
|
145 |
+
if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
|
146 |
+
selectedtab=i //Selected tab index, if found
|
147 |
+
}
|
148 |
+
}
|
149 |
+
} //END for loop
|
150 |
+
if (selectedtab!=-1) //if a valid default selected tab index is found
|
151 |
+
this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
|
152 |
+
else //if no valid default selected index found
|
153 |
+
this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
|
154 |
+
if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
|
155 |
+
this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
|
156 |
+
}
|
157 |
+
} //END int() function
|
158 |
+
|
159 |
+
} //END Prototype assignment
|
skin/frontend/default/default/banner/banner.css
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.slide-container {
|
2 |
+
position:relative;
|
3 |
+
width:520px;
|
4 |
+
|
5 |
+
height:auto;
|
6 |
+
text-align:center;
|
7 |
+
margin:0px 0px 40px 0px;
|
8 |
+
padding-top:10px;
|
9 |
+
}
|
10 |
+
|
11 |
+
.slide-show{
|
12 |
+
background-position:center center;
|
13 |
+
background-repeat:no-repeat;
|
14 |
+
text-align:center;
|
15 |
+
height:260px;
|
16 |
+
width:520px;
|
17 |
+
position:relative;
|
18 |
+
left:10px;
|
19 |
+
}
|
20 |
+
|
21 |
+
.indentmenu{
|
22 |
+
font: bold 11px Arial;
|
23 |
+
width: 100%; /*leave this value as is in most cases*/
|
24 |
+
}
|
25 |
+
|
26 |
+
.indentmenu ul{
|
27 |
+
margin: 2px;
|
28 |
+
padding: 0;
|
29 |
+
float: left;
|
30 |
+
/* width: 80%; width of menu*/
|
31 |
+
background: transparent;
|
32 |
+
}
|
33 |
+
|
34 |
+
.indentmenu ul li{
|
35 |
+
display: inline;
|
36 |
+
}
|
37 |
+
|
38 |
+
.indentmenu ul li a{
|
39 |
+
float: left;
|
40 |
+
margin: 2px;
|
41 |
+
color: #000; /*text color*/
|
42 |
+
padding: 5px 11px;
|
43 |
+
text-decoration: none;
|
44 |
+
border: 1px solid #ccc;
|
45 |
+
}
|
46 |
+
|
47 |
+
.indentmenu ul li a:hover{
|
48 |
+
background:#ddd;
|
49 |
+
}
|
50 |
+
|
51 |
+
.indentmenu ul li a:visited{
|
52 |
+
color: #000;
|
53 |
+
}
|
54 |
+
|
55 |
+
.indentmenu ul li a.selected{
|
56 |
+
color: white !important;
|
57 |
+
padding-top: 6px; /*shift text down 1px*/
|
58 |
+
padding-bottom: 4px;
|
59 |
+
border: 1px solid #F85601;
|
60 |
+
background:#F85601;
|
61 |
+
}
|
62 |
+
|
63 |
+
.tabcontentstyle{ /*style of tab content container*/
|
64 |
+
border: 1px solid gray;
|
65 |
+
width: 450px;
|
66 |
+
margin-bottom: 1em;
|
67 |
+
padding: 10px;
|
68 |
+
}
|
69 |
+
|
70 |
+
.tabcontent{
|
71 |
+
display:none;
|
72 |
+
}
|
73 |
+
|
74 |
+
@media print {
|
75 |
+
.tabcontent {
|
76 |
+
display:block !important;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
.banner_content {
|
81 |
+
width:430px;
|
82 |
+
left:10px;
|
83 |
+
top:220px;
|
84 |
+
position:absolute;
|
85 |
+
color:#A7C6DD;
|
86 |
+
}
|