Indianic_Regionsplashpage - Version 1.0.0.1

Version Notes

latest stable version

Download this release

Release Info

Developer indianic
Extension Indianic_Regionsplashpage
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

Files changed (48) hide show
  1. app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields.php +12 -0
  2. app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit.php +45 -0
  3. app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit/Form.php +19 -0
  4. app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit/Tab/Form.php +91 -0
  5. app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit/Tabs.php +24 -0
  6. app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Grid.php +115 -0
  7. app/code/local/Indianic/Managefields/Block/Managefields.php +17 -0
  8. app/code/local/Indianic/Managefields/Helper/Data.php +6 -0
  9. app/code/local/Indianic/Managefields/Model/Managefields.php +10 -0
  10. app/code/local/Indianic/Managefields/Model/Mysql4/Managefields.php +10 -0
  11. app/code/local/Indianic/Managefields/Model/Mysql4/Managefields/Collection.php +10 -0
  12. app/code/local/Indianic/Managefields/Model/Status.php +15 -0
  13. app/code/local/Indianic/Managefields/controllers/Adminhtml/ManagefieldsController.php +209 -0
  14. app/code/local/Indianic/Managefields/etc/config.xml +126 -0
  15. app/code/local/Indianic/Managefields/sql/managefields_setup/mysql4-install-0.1.0.php +19 -0
  16. app/code/local/Indianic/Managefields/sql/managefields_setup/mysql4-upgrade-0.1.0-0.1.1.php +16 -0
  17. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage.php +12 -0
  18. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit.php +45 -0
  19. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Form.php +19 -0
  20. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Tab/Form.php +90 -0
  21. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Tab/Metadata.php +35 -0
  22. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Tabs.php +29 -0
  23. app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Grid.php +109 -0
  24. app/code/local/Indianic/Regionpage/Block/Copy of Regionpage.php +52 -0
  25. app/code/local/Indianic/Regionpage/Block/Regionpage.php +61 -0
  26. app/code/local/Indianic/Regionpage/Helper/Data.php +6 -0
  27. app/code/local/Indianic/Regionpage/Model/Mysql4/Regionpage.php +10 -0
  28. app/code/local/Indianic/Regionpage/Model/Mysql4/Regionpage/Collection.php +10 -0
  29. app/code/local/Indianic/Regionpage/Model/Regionpage.php +10 -0
  30. app/code/local/Indianic/Regionpage/Model/Status.php +15 -0
  31. app/code/local/Indianic/Regionpage/controllers/Adminhtml/RegionpageController.php +257 -0
  32. app/code/local/Indianic/Regionpage/controllers/IndexController.php +47 -0
  33. app/code/local/Indianic/Regionpage/etc/config.xml +133 -0
  34. app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-install-0.1.0.php +19 -0
  35. app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.0-0.1.1.php +18 -0
  36. app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.1-0.1.2.php +15 -0
  37. app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.2-0.1.3.php +19 -0
  38. app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.3-0.1.4.php +15 -0
  39. app/design/adminhtml/default/default/layout/managefields.xml +9 -0
  40. app/design/adminhtml/default/default/layout/regionpage.xml +17 -0
  41. app/design/adminhtml/default/default/template/managefields/managefieldssteps.phtml +4 -0
  42. app/design/adminhtml/default/default/template/regionpage/regionpage.phtml +8 -0
  43. app/design/adminhtml/default/default/template/regionpage/regionpagesteps.phtml +6 -0
  44. app/design/frontend/default/default/layout/regionpage.xml +10 -0
  45. app/design/frontend/default/default/template/regionpage/regionpage.phtml +3 -0
  46. app/etc/modules/Indianic_Managefields.xml +17 -0
  47. app/etc/modules/Indianic_Regionpage.xml +17 -0
  48. package.xml +18 -0
app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Indianic_Managefields_Block_Adminhtml_Managefields extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_managefields';
7
+ $this->_blockGroup = 'managefields';
8
+ $this->_headerText = Mage::helper('managefields')->__('Fields Manager');
9
+ $this->_addButtonLabel = Mage::helper('managefields')->__('Add Fields');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Block_Adminhtml_Managefields_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 = 'managefields';
11
+ $this->_controller = 'adminhtml_managefields';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('managefields')->__('Save Fields'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('managefields')->__('Delete Fields'));
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('managefields_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'managefields_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'managefields_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('managefields_data') && Mage::registry('managefields_data')->getId() ) {
40
+ return Mage::helper('managefields')->__("Edit Fields '%s'", $this->htmlEscape(Mage::registry('managefields_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('managefields')->__('Add Fields');
43
+ }
44
+ }
45
+ }
app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Block_Adminhtml_Managefields_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit/Tab/Form.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Block_Adminhtml_Managefields_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('managefields_form', array('legend'=>Mage::helper('managefields')->__('Fields information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('managefields')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+ /* if($this->getRequest()->getParam('id'))
18
+ {
19
+
20
+ $model = Mage::getModel('managefields/managefields')->load($this->getRequest()->getParam('id'));
21
+ $title = $model->getTitle();
22
+ }
23
+ else
24
+ {
25
+ $title = "";
26
+ }
27
+ $fieldset->addField('hidden', 'hidden', array(
28
+ 'label' => Mage::helper('managefields')->__('Title'),
29
+ 'value' => $title,
30
+ 'name' => 'hidden',
31
+ )); */
32
+
33
+
34
+ $fieldset->addField('type', 'select', array(
35
+ 'label' => Mage::helper('managefields')->__('Input Type'),
36
+ 'name' => 'type',
37
+ 'values' => array(
38
+ array(
39
+ 'value' => 'text',
40
+ 'label' => Mage::helper('managefields')->__('Text'),
41
+ ),
42
+
43
+ array(
44
+ 'value' => 'textarea',
45
+ 'label' => Mage::helper('managefields')->__('Textarea'),
46
+ ),
47
+ ),
48
+ ));
49
+
50
+
51
+ $fieldset->addField('required', 'select', array(
52
+ 'label' => Mage::helper('managefields')->__('Required'),
53
+ 'name' => 'required',
54
+ 'values' => array(
55
+ array(
56
+ 'value' => 1,
57
+ 'label' => Mage::helper('managefields')->__('Yes'),
58
+ ),
59
+
60
+ array(
61
+ 'value' => 0,
62
+ 'label' => Mage::helper('managefields')->__('No'),
63
+ ),
64
+ ),
65
+ ));
66
+ $fieldset->addField('status', 'select', array(
67
+ 'label' => Mage::helper('managefields')->__('Status'),
68
+ 'name' => 'status',
69
+ 'values' => array(
70
+ array(
71
+ 'value' => 1,
72
+ 'label' => Mage::helper('managefields')->__('Enabled'),
73
+ ),
74
+
75
+ array(
76
+ 'value' => 2,
77
+ 'label' => Mage::helper('managefields')->__('Disabled'),
78
+ ),
79
+ ),
80
+ ));
81
+
82
+ if ( Mage::getSingleton('adminhtml/session')->getManagefieldsData() )
83
+ {
84
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getManagefieldsData());
85
+ Mage::getSingleton('adminhtml/session')->setManagefieldsData(null);
86
+ } elseif ( Mage::registry('managefields_data') ) {
87
+ $form->setValues(Mage::registry('managefields_data')->getData());
88
+ }
89
+ return parent::_prepareForm();
90
+ }
91
+ }
app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Block_Adminhtml_Managefields_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('managefields_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('managefields')->__('Fields Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('managefields')->__('Fields Information'),
18
+ 'title' => Mage::helper('managefields')->__('Fields Information'),
19
+ 'content' => $this->getLayout()->createBlock('managefields/adminhtml_managefields_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Indianic/Managefields/Block/Adminhtml/Managefields/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Block_Adminhtml_Managefields_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('managefieldsGrid');
9
+ $this->setDefaultSort('managefields_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('managefields/managefields')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('managefields_id', array(
24
+ 'header' => Mage::helper('managefields')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'managefields_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('managefields')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('managefields')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('managefields')->__('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('managefields')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('managefields')->__('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
+
76
+
77
+ return parent::_prepareColumns();
78
+ }
79
+
80
+ protected function _prepareMassaction()
81
+ {
82
+ $this->setMassactionIdField('managefields_id');
83
+ $this->getMassactionBlock()->setFormFieldName('managefields');
84
+
85
+ $this->getMassactionBlock()->addItem('delete', array(
86
+ 'label' => Mage::helper('managefields')->__('Delete'),
87
+ 'url' => $this->getUrl('*/*/massDelete'),
88
+ 'confirm' => Mage::helper('managefields')->__('Are you sure?')
89
+ ));
90
+
91
+ $statuses = Mage::getSingleton('managefields/status')->getOptionArray();
92
+
93
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
94
+ $this->getMassactionBlock()->addItem('status', array(
95
+ 'label'=> Mage::helper('managefields')->__('Change status'),
96
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
97
+ 'additional' => array(
98
+ 'visibility' => array(
99
+ 'name' => 'status',
100
+ 'type' => 'select',
101
+ 'class' => 'required-entry',
102
+ 'label' => Mage::helper('managefields')->__('Status'),
103
+ 'values' => $statuses
104
+ )
105
+ )
106
+ ));
107
+ return $this;
108
+ }
109
+
110
+ public function getRowUrl($row)
111
+ {
112
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
113
+ }
114
+
115
+ }
app/code/local/Indianic/Managefields/Block/Managefields.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Indianic_Managefields_Block_Managefields extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getManagefields()
10
+ {
11
+ if (!$this->hasData('managefields')) {
12
+ $this->setData('managefields', Mage::registry('managefields'));
13
+ }
14
+ return $this->getData('managefields');
15
+
16
+ }
17
+ }
app/code/local/Indianic/Managefields/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Indianic/Managefields/Model/Managefields.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Model_Managefields extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('managefields/managefields');
9
+ }
10
+ }
app/code/local/Indianic/Managefields/Model/Mysql4/Managefields.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Model_Mysql4_Managefields extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the managefields_id refers to the key field in your database table.
8
+ $this->_init('managefields/managefields', 'managefields_id');
9
+ }
10
+ }
app/code/local/Indianic/Managefields/Model/Mysql4/Managefields/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Model_Mysql4_Managefields_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('managefields/managefields');
9
+ }
10
+ }
app/code/local/Indianic/Managefields/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_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('managefields')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('managefields')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Indianic/Managefields/controllers/Adminhtml/ManagefieldsController.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Managefields_Adminhtml_ManagefieldsController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('managefields/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Field 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('managefields/managefields')->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('managefields_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('managefields/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Field Manager'), Mage::helper('adminhtml')->__('Field Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Fields News'), Mage::helper('adminhtml')->__('Fields News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('managefields/adminhtml_managefields_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('managefields/adminhtml_managefields_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('managefields')->__('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
+ $data['title'] = strtolower(str_replace(' ','_',$data['title']));
56
+ $model = Mage::getModel('managefields/managefields');
57
+ $model->setData($data)
58
+ ->setId($this->getRequest()->getParam('id'));
59
+
60
+ try {
61
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
62
+ $model->setCreatedTime(now())
63
+ ->setUpdateTime(now());
64
+ } else {
65
+ $model->setUpdateTime(now());
66
+ }
67
+
68
+ $model->save();
69
+
70
+ $this->Altertable(strtolower($model->getTitle()));
71
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('managefields')->__('Field was successfully saved'));
72
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
73
+
74
+ if ($this->getRequest()->getParam('back')) {
75
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
76
+ return;
77
+ }
78
+ $this->_redirect('*/*/');
79
+ return;
80
+ } catch (Exception $e) {
81
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
82
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
83
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
84
+ return;
85
+ }
86
+ }
87
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('managefields')->__('Unable to find Field to save'));
88
+ $this->_redirect('*/*/');
89
+ }
90
+
91
+ public function deleteAction() {
92
+ if( $this->getRequest()->getParam('id') > 0 ) {
93
+ try {
94
+ $model = Mage::getModel('managefields/managefields');
95
+ $title = $model->load($this->getRequest()->getParam('id'));
96
+ $installer = Mage::getSingleton ( 'core/resource' );
97
+ $installer->getConnection()->dropColumn('regionpage', $title->getTitle());
98
+
99
+ $model->setId($this->getRequest()->getParam('id'))
100
+ ->delete();
101
+
102
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Field was successfully deleted'));
103
+ $this->_redirect('*/*/');
104
+ } catch (Exception $e) {
105
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
106
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
107
+ }
108
+ }
109
+ $this->_redirect('*/*/');
110
+ }
111
+
112
+ public function massDeleteAction() {
113
+ $managefieldsIds = $this->getRequest()->getParam('managefields');
114
+ if(!is_array($managefieldsIds)) {
115
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Field(s)'));
116
+ } else {
117
+ try {
118
+ $installer = Mage::getSingleton ( 'core/resource' );
119
+ foreach ($managefieldsIds as $managefieldsId) {
120
+ $managefields = Mage::getModel('managefields/managefields')->load($managefieldsId);
121
+ $installer->getConnection()->dropColumn('regionpage', $managefields->getTitle());
122
+ $managefields->delete();
123
+ }
124
+ Mage::getSingleton('adminhtml/session')->addSuccess(
125
+ Mage::helper('adminhtml')->__(
126
+ 'Total of %d record(s) were successfully deleted', count($managefieldsIds)
127
+ )
128
+ );
129
+ } catch (Exception $e) {
130
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
131
+ }
132
+ }
133
+ $this->_redirect('*/*/index');
134
+ }
135
+
136
+ public function massStatusAction()
137
+ {
138
+ $managefieldsIds = $this->getRequest()->getParam('managefields');
139
+ if(!is_array($managefieldsIds)) {
140
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
141
+ } else {
142
+ try {
143
+ foreach ($managefieldsIds as $managefieldsId) {
144
+ $managefields = Mage::getSingleton('managefields/managefields')
145
+ ->load($managefieldsId)
146
+ ->setStatus($this->getRequest()->getParam('status'))
147
+ ->setIsMassupdate(true)
148
+ ->save();
149
+ }
150
+ $this->_getSession()->addSuccess(
151
+ $this->__('Total of %d record(s) were successfully updated', count($managefieldsIds))
152
+ );
153
+ } catch (Exception $e) {
154
+ $this->_getSession()->addError($e->getMessage());
155
+ }
156
+ }
157
+ $this->_redirect('*/*/index');
158
+ }
159
+
160
+ public function exportCsvAction()
161
+ {
162
+ $fileName = 'managefields.csv';
163
+ $content = $this->getLayout()->createBlock('managefields/adminhtml_managefields_grid')
164
+ ->getCsv();
165
+
166
+ $this->_sendUploadResponse($fileName, $content);
167
+ }
168
+
169
+ public function exportXmlAction()
170
+ {
171
+ $fileName = 'managefields.xml';
172
+ $content = $this->getLayout()->createBlock('managefields/adminhtml_managefields_grid')
173
+ ->getXml();
174
+
175
+ $this->_sendUploadResponse($fileName, $content);
176
+ }
177
+
178
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
179
+ {
180
+ $response = $this->getResponse();
181
+ $response->setHeader('HTTP/1.1 200 OK','');
182
+ $response->setHeader('Pragma', 'public', true);
183
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
184
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
185
+ $response->setHeader('Last-Modified', date('r'));
186
+ $response->setHeader('Accept-Ranges', 'bytes');
187
+ $response->setHeader('Content-Length', strlen($content));
188
+ $response->setHeader('Content-type', $contentType);
189
+ $response->setBody($content);
190
+ $response->sendResponse();
191
+ die;
192
+ }
193
+
194
+ public function Altertable($title)
195
+ {
196
+ $installer = Mage::getSingleton ( 'core/resource' );
197
+ /* if($this->getRequest()->getParam('hidden'))
198
+ {
199
+ $installer->getConnection()->changeColumn('regionpage',$this->getRequest()->getParam('hidden'),$title,'text');
200
+ } */
201
+ $installer->getConnection()->addColumn('regionpage', $title, array(
202
+ 'nullable' => true,
203
+ 'length' => 255,
204
+ 'type' => 'text',
205
+ 'comment' => $title
206
+ )
207
+ );
208
+ }
209
+ }
app/code/local/Indianic/Managefields/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Indianic
5
+ * @package Indianic_Managefields
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Indianic_Managefields>
13
+ <version>0.1.1</version>
14
+ </Indianic_Managefields>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <managefields>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Indianic_Managefields</module>
22
+ <frontName>managefields</frontName>
23
+ </args>
24
+ </managefields>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <managefields>
29
+ <file>managefields.xml</file>
30
+ </managefields>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <managefields>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Indianic_Managefields</module>
40
+ <frontName>managefields</frontName>
41
+ </args>
42
+ </managefields>
43
+ </routers>
44
+ </admin>
45
+ <adminhtml>
46
+ <menu>
47
+ <regionpage module="regionpage">
48
+ <children>
49
+ <managefields module="managefields">
50
+ <title>Manage Fields</title>
51
+ <sort_order>0</sort_order>
52
+ <action>managefields/adminhtml_managefields</action>
53
+ </managefields >
54
+ </children>
55
+ </regionpage>
56
+ </menu>
57
+ <acl>
58
+ <resources>
59
+ <all>
60
+ <title>Allow Everything</title>
61
+ </all>
62
+ <admin>
63
+ <children>
64
+ <Indianic_Managefields>
65
+ <title>Managefields Module</title>
66
+ <sort_order>10</sort_order>
67
+ </Indianic_Managefields>
68
+ </children>
69
+ </admin>
70
+ </resources>
71
+ </acl>
72
+ <layout>
73
+ <updates>
74
+ <managefields>
75
+ <file>managefields.xml</file>
76
+ </managefields>
77
+ </updates>
78
+ </layout>
79
+ </adminhtml>
80
+ <global>
81
+ <models>
82
+ <managefields>
83
+ <class>Indianic_Managefields_Model</class>
84
+ <resourceModel>managefields_mysql4</resourceModel>
85
+ </managefields>
86
+ <managefields_mysql4>
87
+ <class>Indianic_Managefields_Model_Mysql4</class>
88
+ <entities>
89
+ <managefields>
90
+ <table>managefields</table>
91
+ </managefields>
92
+ </entities>
93
+ </managefields_mysql4>
94
+ </models>
95
+ <resources>
96
+ <managefields_setup>
97
+ <setup>
98
+ <module>Indianic_Managefields</module>
99
+ </setup>
100
+ <connection>
101
+ <use>core_setup</use>
102
+ </connection>
103
+ </managefields_setup>
104
+ <managefields_write>
105
+ <connection>
106
+ <use>core_write</use>
107
+ </connection>
108
+ </managefields_write>
109
+ <managefields_read>
110
+ <connection>
111
+ <use>core_read</use>
112
+ </connection>
113
+ </managefields_read>
114
+ </resources>
115
+ <blocks>
116
+ <managefields>
117
+ <class>Indianic_Managefields_Block</class>
118
+ </managefields>
119
+ </blocks>
120
+ <helpers>
121
+ <managefields>
122
+ <class>Indianic_Managefields_Helper</class>
123
+ </managefields>
124
+ </helpers>
125
+ </global>
126
+ </config>
app/code/local/Indianic/Managefields/sql/managefields_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('managefields')};
10
+ CREATE TABLE {$this->getTable('managefields')} (
11
+ `managefields_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `status` smallint(6) NOT NULL default '0',
14
+ PRIMARY KEY (`managefields_id`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16
+
17
+ ");
18
+
19
+ $installer->endSetup();
app/code/local/Indianic/Managefields/sql/managefields_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE {$this->getTable('managefields')} ADD type varchar(255) NULL AFTER title;
10
+ ALTER TABLE {$this->getTable('managefields')} ADD required varchar(255) NULL AFTER type;
11
+
12
+ ");
13
+
14
+ $installer->endSetup();
15
+
16
+
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_regionpage';
7
+ $this->_blockGroup = 'regionpage';
8
+ $this->_headerText = Mage::helper('regionpage')->__('Region Manager');
9
+ $this->_addButtonLabel = Mage::helper('regionpage')->__('Add Region');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage_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 = 'regionpage';
11
+ $this->_controller = 'adminhtml_regionpage';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('regionpage')->__('Save Region'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('regionpage')->__('Delete Region'));
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('regionpage_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'regionpage_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'regionpage_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('regionpage_data') && Mage::registry('regionpage_data')->getId() ) {
40
+ return Mage::helper('regionpage')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('regionpage_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('regionpage')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Tab/Form.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage_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('regionpage_form', array('legend'=>Mage::helper('regionpage')->__('Region information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('regionpage')->__('Title'),
13
+ 'name' => 'title',
14
+ 'note' => 'e.g. Country splash page',
15
+ ));
16
+
17
+ $fieldset->addField('url_key', 'text', array(
18
+ 'label' => Mage::helper('regionpage')->__('Url Key'),
19
+ 'name' => 'url_key',
20
+ 'note' => 'Url key something like region name or country name suppose example is url key then on frontend it will be like http://yourdomain.com/example.html',
21
+ ));
22
+
23
+
24
+ $collection = Mage::getModel('managefields/managefields')->getCollection()->addFieldToFilter('status',1);
25
+
26
+
27
+
28
+ foreach($collection as $data)
29
+ {
30
+ $required = 0;
31
+ $class = "";
32
+ $type = $data->getType();
33
+ $title = $data->getTitle();
34
+ $required = $data->getRequired();
35
+
36
+ if($required==1)
37
+ {
38
+ $required = true;
39
+ $class = 'required-entry';
40
+ }
41
+ else
42
+ {
43
+ $required = false;
44
+ }
45
+ switch ($type) {
46
+
47
+ case 'text' :
48
+ $fieldset->addField($title, 'text', array(
49
+ 'label' => Mage::helper('regionpage')->__(ucfirst($data->getTitle())),
50
+ 'class' => $class,
51
+ 'required' => $required,
52
+ 'name' => $title,
53
+ ));
54
+ break;
55
+ case 'textarea' :
56
+ $fieldset->addField($title, 'textarea', array(
57
+ 'label' => Mage::helper('regionpage')->__(ucfirst($data->getTitle())),
58
+ 'class' => $class,
59
+ 'required' => $required,
60
+ 'name' => $title,
61
+ ));
62
+ break;
63
+ }
64
+ }
65
+ $block = Mage::getModel('cms/block')->getCollection();
66
+ $arr_b=array();
67
+ $j=1;
68
+ foreach($block as $collection){
69
+ $arr_b[$j]['value'] = $collection->getIdentifier();
70
+ $arr_b[$j]['label'] = $collection->getTitle();
71
+ $j++;
72
+ }
73
+ $fieldset->addField('static_block', 'select', array(
74
+ 'label' => Mage::helper('regionpage')->__('Select static block'),
75
+ 'name' => 'static_block',
76
+ 'note' => 'Assign one of your static block for content',
77
+ 'values' => $arr_b,
78
+ ));
79
+
80
+
81
+ if ( Mage::getSingleton('adminhtml/session')->getRegionpageData() )
82
+ {
83
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getRegionpageData());
84
+ Mage::getSingleton('adminhtml/session')->setRegionpageData(null);
85
+ } elseif ( Mage::registry('regionpage_data') ) {
86
+ $form->setValues(Mage::registry('regionpage_data')->getData());
87
+ }
88
+ return parent::_prepareForm();
89
+ }
90
+ }
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Tab/Metadata.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage_Edit_Tab_Metadata 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('regionpage_form', array('legend'=>Mage::helper('regionpage')->__('Meta information')));
10
+
11
+ $fieldset->addField('meta_title', 'text', array(
12
+ 'label' => Mage::helper('regionpage')->__('Meta Title'),
13
+ 'name' => 'meta_title',
14
+ ));
15
+
16
+ $fieldset->addField('meta_keywords', 'textarea', array(
17
+ 'label' => Mage::helper('regionpage')->__('Meta Keywords'),
18
+ 'name' => 'meta_keywords',
19
+ ));
20
+
21
+ $fieldset->addField('meta_description', 'textarea', array(
22
+ 'label' => Mage::helper('regionpage')->__('Meta Description'),
23
+ 'name' => 'meta_description',
24
+ ));
25
+ if ( Mage::getSingleton('adminhtml/session')->getRegionpageData() )
26
+ {
27
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getRegionpageData());
28
+ Mage::getSingleton('adminhtml/session')->setRegionpageData(null);
29
+ } elseif ( Mage::registry('regionpage_data') ) {
30
+ $form->setValues(Mage::registry('regionpage_data')->getData());
31
+ }
32
+
33
+ return parent::_prepareForm();
34
+ }
35
+ }
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Edit/Tabs.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('regionpage_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('regionpage')->__('Region Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('regionpage')->__('Region Information'),
18
+ 'title' => Mage::helper('regionpage')->__('Region Information'),
19
+ 'content' => $this->getLayout()->createBlock('regionpage/adminhtml_regionpage_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ $this->addTab('tabid', array(
23
+ 'label' => Mage::helper('regionpage')->__('Meta Data'),
24
+ 'class' => 'ajax',
25
+ 'url' => $this->getUrl('*/*/customgrid', array('_current' => true)),
26
+ ));
27
+ return parent::_beforeToHtml();
28
+ }
29
+ }
app/code/local/Indianic/Regionpage/Block/Adminhtml/Regionpage/Grid.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Block_Adminhtml_Regionpage_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('regionpageGrid');
9
+ $this->setDefaultSort('regionpage_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('regionpage/regionpage')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('regionpage_id', array(
24
+ 'header' => Mage::helper('regionpage')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'regionpage_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('regionpage')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ $this->addColumn('url_key', array(
37
+ 'header' => Mage::helper('regionpage')->__('Url Key'),
38
+ 'align' =>'left',
39
+ 'index' => 'url_key',
40
+ ));
41
+
42
+ /*
43
+ $this->addColumn('content', array(
44
+ 'header' => Mage::helper('regionpage')->__('Item Content'),
45
+ 'width' => '150px',
46
+ 'index' => 'content',
47
+ ));
48
+ */
49
+
50
+ /*$this->addColumn('status', array(
51
+ 'header' => Mage::helper('regionpage')->__('Status'),
52
+ 'align' => 'left',
53
+ 'width' => '80px',
54
+ 'index' => 'status',
55
+ 'type' => 'options',
56
+ 'options' => array(
57
+ 1 => 'Enabled',
58
+ 2 => 'Disabled',
59
+ ),
60
+ ));*/
61
+
62
+ $this->addColumn('action',
63
+ array(
64
+ 'header' => Mage::helper('regionpage')->__('Action'),
65
+ 'width' => '100',
66
+ 'type' => 'action',
67
+ 'getter' => 'getId',
68
+ 'actions' => array(
69
+ array(
70
+ 'caption' => Mage::helper('regionpage')->__('Edit'),
71
+ 'url' => array('base'=> '*/*/edit'),
72
+ 'field' => 'id'
73
+ )
74
+ ),
75
+ 'filter' => false,
76
+ 'sortable' => false,
77
+ 'index' => 'stores',
78
+ 'is_system' => true,
79
+ ));
80
+
81
+
82
+
83
+ return parent::_prepareColumns();
84
+ }
85
+
86
+ protected function _prepareMassaction()
87
+ {
88
+ $this->setMassactionIdField('regionpage_id');
89
+ $this->getMassactionBlock()->setFormFieldName('regionpage');
90
+
91
+ $this->getMassactionBlock()->addItem('delete', array(
92
+ 'label' => Mage::helper('regionpage')->__('Delete'),
93
+ 'url' => $this->getUrl('*/*/massDelete'),
94
+ 'confirm' => Mage::helper('regionpage')->__('Are you sure?')
95
+ ));
96
+
97
+ $statuses = Mage::getSingleton('regionpage/status')->getOptionArray();
98
+
99
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
100
+
101
+ return $this;
102
+ }
103
+
104
+ public function getRowUrl($row)
105
+ {
106
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
107
+ }
108
+
109
+ }
app/code/local/Indianic/Regionpage/Block/Copy of Regionpage.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Indianic_Regionpage_Block_Regionpage extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ $region = $region = $this->getValue();
7
+ $head = $this->getLayout()->getBlock('head');
8
+ $head->setTitle($region->getMetaTitle());
9
+ $head->setKeywords($region->getMetaKeywords());
10
+ $head->setDescription($region->getMetaDescription());
11
+ return parent::_prepareLayout();
12
+ }
13
+
14
+ public function getRegionpage()
15
+ {
16
+ if (!$this->hasData('regionpage')) {
17
+ $this->setData('regionpage', Mage::registry('regionpage'));
18
+ }
19
+ return $this->getData('regionpage');
20
+
21
+ }
22
+ public function getValue()
23
+ {
24
+ $id = $this->getRequest()->getParam('id');
25
+ $region = Mage::getModel('regionpage/regionpage')->load($id);
26
+
27
+ return $region;
28
+ }
29
+ public function getStaticBlock()
30
+ {
31
+ $block = Mage::getModel('cms/block')
32
+ ->setStoreId(Mage::app()->getStore()->getId())
33
+ ->load('region-page');
34
+
35
+ $array = array();
36
+
37
+
38
+ $region = $this->getValue();
39
+
40
+ $array['city'] = $region->getTitle();
41
+
42
+ $array['address'] = $region->getAddress();
43
+
44
+ $array['number'] = $region->getNumber();
45
+
46
+ $filter = Mage::getModel('cms/template_filter');
47
+
48
+ $filter->setVariables($array);
49
+
50
+ return $filter->filter($block->getContent());
51
+ }
52
+ }
app/code/local/Indianic/Regionpage/Block/Regionpage.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Indianic_Regionpage_Block_Regionpage extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ $region = $region = $this->getValue();
7
+ $head = $this->getLayout()->getBlock('head');
8
+ $head->setTitle($region->getMetaTitle());
9
+ $head->setKeywords($region->getMetaKeywords());
10
+ $head->setDescription($region->getMetaDescription());
11
+ return parent::_prepareLayout();
12
+ }
13
+
14
+ public function getRegionpage()
15
+ {
16
+ if (!$this->hasData('regionpage')) {
17
+ $this->setData('regionpage', Mage::registry('regionpage'));
18
+ }
19
+ return $this->getData('regionpage');
20
+
21
+ }
22
+ public function getValue()
23
+ {
24
+ $id = $this->getRequest()->getParam('id');
25
+ $region = Mage::getModel('regionpage/regionpage')->load($id);
26
+
27
+ return $region;
28
+ }
29
+ public function getStaticBlock()
30
+ {
31
+
32
+ $region = $this->getValue();
33
+
34
+ $block = Mage::getModel('cms/block')
35
+ ->setStoreId(Mage::app()->getStore()->getId())
36
+ ->load($region->getStaticBlock());
37
+
38
+ $array = array();
39
+
40
+ $array['title'] = $region->getTitle();
41
+ $array['meta_title'] = $region->getMetaTitle();
42
+ $array['meta_keywords'] = $region->getMetaKeywords();
43
+ $array['meta_description'] = $region->getMetaDescription();
44
+
45
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
46
+ $result = $read->fetchAll("select title from managefields where status =1");
47
+
48
+ foreach($result as $data)
49
+ {
50
+ $data1 = get.ucfirst($data['title']);
51
+ $array[$data['title']] = $region->$data1();
52
+ }
53
+
54
+
55
+ $filter = Mage::getModel('cms/template_filter');
56
+
57
+ $filter->setVariables($array);
58
+
59
+ return $filter->filter($block->getContent());
60
+ }
61
+ }
app/code/local/Indianic/Regionpage/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Indianic/Regionpage/Model/Mysql4/Regionpage.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Model_Mysql4_Regionpage extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the regionpage_id refers to the key field in your database table.
8
+ $this->_init('regionpage/regionpage', 'regionpage_id');
9
+ }
10
+ }
app/code/local/Indianic/Regionpage/Model/Mysql4/Regionpage/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Model_Mysql4_Regionpage_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('regionpage/regionpage');
9
+ }
10
+ }
app/code/local/Indianic/Regionpage/Model/Regionpage.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Model_Regionpage extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('regionpage/regionpage');
9
+ }
10
+ }
app/code/local/Indianic/Regionpage/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_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('regionpage')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('regionpage')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Indianic/Regionpage/controllers/Adminhtml/RegionpageController.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Indianic_Regionpage_Adminhtml_RegionpageController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('regionpage/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Region Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+ public function cmscontentAction()
19
+ {
20
+ $block = Mage::getModel('cms/block')->load('region-page');
21
+ $url = $this->_redirect('adminhtml/cms_block/edit', array('block_id' => $block->getData('block_id')));
22
+ }
23
+ public function editAction() {
24
+ $id = $this->getRequest()->getParam('id');
25
+ $model = Mage::getModel('regionpage/regionpage')->load($id);
26
+
27
+ if ($model->getId() || $id == 0) {
28
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
29
+ if (!empty($data)) {
30
+ $model->setData($data);
31
+ }
32
+
33
+ Mage::register('regionpage_data', $model);
34
+
35
+ $this->loadLayout();
36
+ $this->_setActiveMenu('regionpage/items');
37
+
38
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Region Manager'), Mage::helper('adminhtml')->__('Region Manager'));
39
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Region News'), Mage::helper('adminhtml')->__('Region News'));
40
+
41
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
42
+
43
+ $this->_addContent($this->getLayout()->createBlock('regionpage/adminhtml_regionpage_edit'))
44
+ ->_addLeft($this->getLayout()->createBlock('regionpage/adminhtml_regionpage_edit_tabs'));
45
+
46
+ $this->renderLayout();
47
+ } else {
48
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('regionpage')->__('Item does not exist'));
49
+ $this->_redirect('*/*/');
50
+ }
51
+ }
52
+
53
+ public function newAction() {
54
+ $this->_forward('edit');
55
+ }
56
+
57
+ public function saveAction() {
58
+ if ($data = $this->getRequest()->getPost()) {
59
+
60
+ if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
61
+ try {
62
+ /* Starting upload */
63
+ $uploader = new Varien_File_Uploader('filename');
64
+
65
+ // Any extention would work
66
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
67
+ $uploader->setAllowRenameFiles(false);
68
+
69
+ // Set the file upload mode
70
+ // false -> get the file directly in the specified folder
71
+ // true -> get the file in the product like folders
72
+ // (file.jpg will go in something like /media/f/i/file.jpg)
73
+ $uploader->setFilesDispersion(false);
74
+
75
+ // We set media as the upload dir
76
+ $path = Mage::getBaseDir('media') . DS ;
77
+ $uploader->save($path, $_FILES['filename']['name'] );
78
+
79
+ } catch (Exception $e) {
80
+
81
+ }
82
+
83
+ //this way the name is saved in DB
84
+ $data['filename'] = $_FILES['filename']['name'];
85
+ }
86
+
87
+
88
+ $model = Mage::getModel('regionpage/regionpage');
89
+ $model->setData($data)
90
+ ->setId($this->getRequest()->getParam('id'));
91
+
92
+ try {
93
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
94
+ $model->setCreatedTime(now())
95
+ ->setUpdateTime(now());
96
+ } else {
97
+ $model->setUpdateTime(now());
98
+ }
99
+
100
+ $model->save();
101
+
102
+ $this->UrlRewrite($model);
103
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('regionpage')->__('Region was successfully saved'));
104
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
105
+
106
+ if ($this->getRequest()->getParam('back')) {
107
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
108
+ return;
109
+ }
110
+ $this->_redirect('*/*/');
111
+ return;
112
+ } catch (Exception $e) {
113
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
114
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
115
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
116
+ return;
117
+ }
118
+ }
119
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('regionpage')->__('Unable to find item to save'));
120
+ $this->_redirect('*/*/');
121
+ }
122
+
123
+ public function deleteAction() {
124
+ if( $this->getRequest()->getParam('id') > 0 ) {
125
+ try {
126
+ $model = Mage::getModel('regionpage/regionpage');
127
+
128
+ $model->setId($this->getRequest()->getParam('id'))
129
+ ->delete();
130
+
131
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Region was successfully deleted'));
132
+ $this->_redirect('*/*/');
133
+ } catch (Exception $e) {
134
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
135
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
136
+ }
137
+ }
138
+ $this->_redirect('*/*/');
139
+ }
140
+
141
+ public function massDeleteAction() {
142
+ $regionpageIds = $this->getRequest()->getParam('regionpage');
143
+ if(!is_array($regionpageIds)) {
144
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
145
+ } else {
146
+ try {
147
+ foreach ($regionpageIds as $regionpageId) {
148
+ $regionpage = Mage::getModel('regionpage/regionpage')->load($regionpageId);
149
+ $regionpage->delete();
150
+ }
151
+ Mage::getSingleton('adminhtml/session')->addSuccess(
152
+ Mage::helper('adminhtml')->__(
153
+ 'Total of %d record(s) were successfully deleted', count($regionpageIds)
154
+ )
155
+ );
156
+ } catch (Exception $e) {
157
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
158
+ }
159
+ }
160
+ $this->_redirect('*/*/index');
161
+ }
162
+
163
+ public function massStatusAction()
164
+ {
165
+ $regionpageIds = $this->getRequest()->getParam('regionpage');
166
+ if(!is_array($regionpageIds)) {
167
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
168
+ } else {
169
+ try {
170
+ foreach ($regionpageIds as $regionpageId) {
171
+ $regionpage = Mage::getSingleton('regionpage/regionpage')
172
+ ->load($regionpageId)
173
+ ->setStatus($this->getRequest()->getParam('status'))
174
+ ->setIsMassupdate(true)
175
+ ->save();
176
+ }
177
+ $this->_getSession()->addSuccess(
178
+ $this->__('Total of %d record(s) were successfully updated', count($regionpageIds))
179
+ );
180
+ } catch (Exception $e) {
181
+ $this->_getSession()->addError($e->getMessage());
182
+ }
183
+ }
184
+ $this->_redirect('*/*/index');
185
+ }
186
+
187
+ public function exportCsvAction()
188
+ {
189
+ $fileName = 'regionpage.csv';
190
+ $content = $this->getLayout()->createBlock('regionpage/adminhtml_regionpage_grid')
191
+ ->getCsv();
192
+
193
+ $this->_sendUploadResponse($fileName, $content);
194
+ }
195
+
196
+ public function exportXmlAction()
197
+ {
198
+ $fileName = 'regionpage.xml';
199
+ $content = $this->getLayout()->createBlock('regionpage/adminhtml_regionpage_grid')
200
+ ->getXml();
201
+
202
+ $this->_sendUploadResponse($fileName, $content);
203
+ }
204
+
205
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
206
+ {
207
+ $response = $this->getResponse();
208
+ $response->setHeader('HTTP/1.1 200 OK','');
209
+ $response->setHeader('Pragma', 'public', true);
210
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
211
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
212
+ $response->setHeader('Last-Modified', date('r'));
213
+ $response->setHeader('Accept-Ranges', 'bytes');
214
+ $response->setHeader('Content-Length', strlen($content));
215
+ $response->setHeader('Content-type', $contentType);
216
+ $response->setBody($content);
217
+ $response->sendResponse();
218
+ die;
219
+ }
220
+
221
+ public function metadataAction()
222
+ {
223
+ $id = (int) $this->getRequest()->getParam('id');
224
+ $model = Mage::getModel('regionpage/regionpage');
225
+
226
+ if ($id) {
227
+ $model->load($id);
228
+ }
229
+
230
+ Mage::register('regionpage_data', $model);
231
+
232
+ $this->getResponse()->setBody($this->getLayout()
233
+ ->createBlock('regionpage/adminhtml_regionpage_edit_tab_metadata')->toHtml());
234
+ }
235
+
236
+ public function UrlRewrite($model)
237
+ {
238
+ $id_path = "regionpage/".$model->getId();
239
+ if($model->getUrlKey())
240
+ {
241
+ $path = str_replace(" ",'-',$model->getUrlKey());
242
+ }
243
+ else
244
+ {
245
+ $path = $model->getTitle();
246
+ }
247
+ $path = strtolower($path);
248
+ $request_path = $path.'.html';
249
+ $target_path = "regionpage/index/index/id/".$model->getId();
250
+ $rewrite = Mage::getModel('core/url_rewrite')->load($id_path,id_path);
251
+ $rewrite->setIdPath($id_path)
252
+ ->setRequestPath($request_path)
253
+ ->setTargetPath($target_path)
254
+ ->setIsSystem(0)
255
+ ->save();
256
+ }
257
+ }
app/code/local/Indianic/Regionpage/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Indianic_Regionpage_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/regionpage?id=15
11
+ * or
12
+ * http://site.com/regionpage/id/15
13
+ */
14
+ /*
15
+ $regionpage_id = $this->getRequest()->getParam('id');
16
+
17
+ if($regionpage_id != null && $regionpage_id != '') {
18
+ $regionpage = Mage::getModel('regionpage/regionpage')->load($regionpage_id)->getData();
19
+ } else {
20
+ $regionpage = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($regionpage == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $regionpageTable = $resource->getTableName('regionpage');
32
+
33
+ $select = $read->select()
34
+ ->from($regionpageTable,array('regionpage_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $regionpage = $read->fetchRow($select);
39
+ }
40
+ Mage::register('regionpage', $regionpage);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Indianic/Regionpage/etc/config.xml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Indianic
5
+ * @package Indianic_Regionpage
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Indianic_Regionpage>
13
+ <version>0.1.4</version>
14
+ </Indianic_Regionpage>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <regionpage>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Indianic_Regionpage</module>
22
+ <frontName>regionpage</frontName>
23
+ </args>
24
+ </regionpage>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <regionpage>
29
+ <file>regionpage.xml</file>
30
+ </regionpage>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <regionpage>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Indianic_Regionpage</module>
40
+ <frontName>regionpage</frontName>
41
+ </args>
42
+ </regionpage>
43
+ </routers>
44
+ </admin>
45
+ <adminhtml>
46
+ <menu>
47
+ <regionpage module="regionpage">
48
+ <title>Regionpage</title>
49
+ <sort_order>71</sort_order>
50
+ <children>
51
+ <items module="regionpage">
52
+ <title>Manage Region</title>
53
+ <sort_order>0</sort_order>
54
+ <action>regionpage/adminhtml_regionpage</action>
55
+ </items>
56
+ <items1 module="regionpage">
57
+ <title>Manage Content</title>
58
+ <sort_order>1</sort_order>
59
+ <action>regionpage/adminhtml_regionpage/cmscontent</action>
60
+ </items1>
61
+ </children>
62
+ </regionpage>
63
+ </menu>
64
+ <acl>
65
+ <resources>
66
+ <all>
67
+ <title>Allow Everything</title>
68
+ </all>
69
+ <admin>
70
+ <children>
71
+ <Indianic_Regionpage>
72
+ <title>Regionpage Module</title>
73
+ <sort_order>10</sort_order>
74
+ </Indianic_Regionpage>
75
+ </children>
76
+ </admin>
77
+ </resources>
78
+ </acl>
79
+ <layout>
80
+ <updates>
81
+ <regionpage>
82
+ <file>regionpage.xml</file>
83
+ </regionpage>
84
+ </updates>
85
+ </layout>
86
+ </adminhtml>
87
+ <global>
88
+ <models>
89
+ <regionpage>
90
+ <class>Indianic_Regionpage_Model</class>
91
+ <resourceModel>regionpage_mysql4</resourceModel>
92
+ </regionpage>
93
+ <regionpage_mysql4>
94
+ <class>Indianic_Regionpage_Model_Mysql4</class>
95
+ <entities>
96
+ <regionpage>
97
+ <table>regionpage</table>
98
+ </regionpage>
99
+ </entities>
100
+ </regionpage_mysql4>
101
+ </models>
102
+ <resources>
103
+ <regionpage_setup>
104
+ <setup>
105
+ <module>Indianic_Regionpage</module>
106
+ </setup>
107
+ <connection>
108
+ <use>core_setup</use>
109
+ </connection>
110
+ </regionpage_setup>
111
+ <regionpage_write>
112
+ <connection>
113
+ <use>core_write</use>
114
+ </connection>
115
+ </regionpage_write>
116
+ <regionpage_read>
117
+ <connection>
118
+ <use>core_read</use>
119
+ </connection>
120
+ </regionpage_read>
121
+ </resources>
122
+ <blocks>
123
+ <regionpage>
124
+ <class>Indianic_Regionpage_Block</class>
125
+ </regionpage>
126
+ </blocks>
127
+ <helpers>
128
+ <regionpage>
129
+ <class>Indianic_Regionpage_Helper</class>
130
+ </regionpage>
131
+ </helpers>
132
+ </global>
133
+ </config>
app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('regionpage')};
10
+ CREATE TABLE {$this->getTable('regionpage')} (
11
+ `regionpage_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `status` smallint(6) NOT NULL default '0',
14
+ PRIMARY KEY (`regionpage_id`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16
+
17
+ ");
18
+
19
+ $installer->endSetup();
app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE {$this->getTable('regionpage')} ADD meta_title varchar(255) NULL AFTER title;
10
+ ALTER TABLE {$this->getTable('regionpage')} ADD meta_keywords text NULL AFTER meta_title;
11
+ ALTER TABLE {$this->getTable('regionpage')} ADD meta_description text NULL AFTER meta_keywords;
12
+
13
+
14
+ ");
15
+
16
+ $installer->endSetup();
17
+
18
+
app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE {$this->getTable('regionpage')} ADD url_key varchar(255) NULL AFTER title;
10
+
11
+ ");
12
+
13
+ $installer->endSetup();
14
+
15
+
app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
6
+
7
+ $staticBlock = array(
8
+ 'title' => 'Region Page Block',
9
+ 'identifier' => 'region-page',
10
+ 'is_active' => 1,
11
+ 'stores' => array(1)
12
+ );
13
+
14
+ Mage::getModel('cms/block')->setData($staticBlock)->save();
15
+
16
+
17
+ $installer->endSetup();
18
+
19
+
app/code/local/Indianic/Regionpage/sql/regionpage_setup/mysql4-upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ ALTER TABLE {$this->getTable('regionpage')} ADD static_block varchar(255) NOT NULL default 'region-page';
10
+
11
+ ");
12
+
13
+ $installer->endSetup();
14
+
15
+
app/design/adminhtml/default/default/layout/managefields.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <managefields_adminhtml_managefields_index>
4
+ <reference name="content">
5
+ <block type="core/template" template="managefields/managefieldssteps.phtml"></block>
6
+ <block type="managefields/adminhtml_managefields" name="managefields" />
7
+ </reference>
8
+ </managefields_adminhtml_managefields_index>
9
+ </layout>
app/design/adminhtml/default/default/layout/regionpage.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <regionpage_adminhtml_regionpage_index>
4
+ <reference name="content">
5
+ <block type="core/template" template="regionpage/regionpagesteps.phtml"></block>
6
+ <block type="regionpage/adminhtml_regionpage" name="regionpage" >
7
+
8
+ </block>
9
+ </reference>
10
+ </regionpage_adminhtml_regionpage_index>
11
+
12
+ <adminhtml_cms_block_edit>
13
+ <reference name="content">
14
+ <block type="adminhtml/cms_block_edit" template="regionpage/regionpage.phtml" ></block>
15
+ </reference>
16
+ </adminhtml_cms_block_edit>
17
+ </layout>
app/design/adminhtml/default/default/template/managefields/managefieldssteps.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ echo "<b>Step 1 : Add new field ( Add new fields for Country name or Address, etc... , these fields can be used as your variable in static block content eg:- variable name: country_name,address)</b>";
3
+ ?>
4
+
app/design/adminhtml/default/default/template/regionpage/regionpage.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <script>
2
+ value = $(block_identifier).value
3
+ if(value == 'region-page')
4
+ {
5
+ $(block_identifier).disable();
6
+ }
7
+ </script>
8
+
app/design/adminhtml/default/default/template/regionpage/regionpagesteps.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+
2
+ <b>Step 2 : Add new Region ( eg:- Title: India splash page , Url Key: India, etc.. )<br/>
3
+ Step 3 : Manage static block content (eg:- My Country is {{var country_name}} <br />
4
+ Step 4 : Go to http://yourdomain.com/india.html (you will get splash page like: "My Country is India" )</b>
5
+
6
+
app/design/frontend/default/default/layout/regionpage.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ </default>
5
+ <regionpage_index_index>
6
+ <reference name="content">
7
+ <block type="regionpage/regionpage" name="regionpage" template="regionpage/regionpage.phtml" />
8
+ </reference>
9
+ </regionpage_index_index>
10
+ </layout>
app/design/frontend/default/default/template/regionpage/regionpage.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ echo $this->getStaticBlock();
3
+ ?>
app/etc/modules/Indianic_Managefields.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Indianic
5
+ * @package Indianic_Managefields
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Indianic_Managefields>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Indianic_Managefields>
16
+ </modules>
17
+ </config>
app/etc/modules/Indianic_Regionpage.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Indianic
5
+ * @package Indianic_Regionpage
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Indianic_Regionpage>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Indianic_Regionpage>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Indianic_Regionsplashpage</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module display region wise splash pages </summary>
10
+ <description>This module display region wise splash pages </description>
11
+ <notes>latest stable version</notes>
12
+ <authors><author><name>indianic</name><user>indianic</user><email>enquiry@indianic.com</email></author></authors>
13
+ <date>2013-05-21</date>
14
+ <time>12:35:30</time>
15
+ <contents><target name="magelocal"><dir name="Indianic"><dir name="Managefields"><dir name="Block"><dir name="Adminhtml"><dir name="Managefields"><dir name="Edit"><file name="Form.php" hash="c5b801487a9b65333aae94052ccd4fb1"/><dir name="Tab"><file name="Form.php" hash="530dcee4a89804534749f64140fd4799"/></dir><file name="Tabs.php" hash="1ab555f87ee8f2b6bafb645a83e863ec"/></dir><file name="Edit.php" hash="c7ef2bcdfe625368de00f73b33edb4bf"/><file name="Grid.php" hash="1a502549993610ddbf67e2f5b2adaca5"/></dir><file name="Managefields.php" hash="4d500010e887d92efe8540ef0baaf874"/></dir><file name="Managefields.php" hash="93e78b20b8f9077c386680ca4270b4c5"/></dir><dir name="Helper"><file name="Data.php" hash="288f26acfaee32405397d4bc07ff2654"/></dir><dir name="Model"><file name="Managefields.php" hash="4c4a665436e25c7206658540b48201c9"/><dir name="Mysql4"><dir name="Managefields"><file name="Collection.php" hash="15027fac23438bf782f64474bea2373d"/></dir><file name="Managefields.php" hash="981b8a994668181c43a424025b64b7b2"/></dir><file name="Status.php" hash="25f45332e3cc24ff19a782145342fdc6"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ManagefieldsController.php" hash="9e95024f7322dce2b5dc19cd0d655ac7"/></dir></dir><dir name="etc"><file name="config.xml" hash="274094d72d464aa9cf27126f6ccaf38c"/></dir><dir name="sql"><dir name="managefields_setup"><file name="mysql4-install-0.1.0.php" hash="1446dc701bfa7b58080ff53a7a4d2fb8"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="29686d027af1a3505c372d80761dca2e"/></dir></dir></dir><dir name="Regionpage"><dir name="Block"><dir name="Adminhtml"><dir name="Regionpage"><dir name="Edit"><file name="Form.php" hash="e5509807b5229f40c31f29f1388e7e88"/><dir name="Tab"><file name="Form.php" hash="de54a95783b52be020edd7edeeb0e0e9"/><file name="Metadata.php" hash="df9960c0a1914e24191f5fa5fe4c6d5a"/></dir><file name="Tabs.php" hash="692a8feffd2cf038e4889578e6f350d8"/></dir><file name="Edit.php" hash="5404d47035624c64a5e264eb2740233c"/><file name="Grid.php" hash="32a28c192e1ffb650bea70dd30547a1e"/></dir><file name="Regionpage.php" hash="dcda3a732ca9c36cbec88c6fbb7de8ee"/></dir><file name="Copy of Regionpage.php" hash="b29642798a20fd636a6f001e8569f018"/><file name="Regionpage.php" hash="e06b338248e17f070f646475ec8ed955"/></dir><dir name="Helper"><file name="Data.php" hash="5974a9466c9b97a6631daee962fe9bbd"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Regionpage"><file name="Collection.php" hash="a704f6a839716c4d6e164b8f62af16e9"/></dir><file name="Regionpage.php" hash="c765ea483262dead4ea30006be38ce73"/></dir><file name="Regionpage.php" hash="b1af1e4a196fbfd61f6a568b119eff5d"/><file name="Status.php" hash="0e904f40dfedf79c68b4822737b1c4cd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="RegionpageController.php" hash="6739dc5cc12d8f63021ce39740b8b794"/></dir><file name="IndexController.php" hash="fa3911391e495f2900a25eb4cd447bf0"/></dir><dir name="etc"><file name="config.xml" hash="721446022afd711de5d96a8a24bcaf2f"/></dir><dir name="sql"><dir name="regionpage_setup"><file name="mysql4-install-0.1.0.php" hash="35e9e0ffb801bc277decd5334002ccd7"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="88d5cd64e0a8e901593b1a5b478a517c"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="c46c5226004cbc0f550b24fd165682ce"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="c2a3b376ecad3881f67468270107a537"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="9db13ec3b6263358a1f2a849a9c15dae"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="managefields.xml" hash="ceec601aa6a8db75a9483b1624b9aa0d"/><file name="regionpage.xml" hash="b0fdc6ef33028071c7f231a44122329d"/></dir><dir name="template"><dir name="regionpage"><file name="regionpage.phtml" hash="3e5cb53e7bbd01073fba8ec0869a1890"/><file name="regionpagesteps.phtml" hash="92df0a0cce603dc14ae7a84600cdf8de"/></dir><dir name="managefields"><file name="managefieldssteps.phtml" hash="00f8f72fd684c3d1cec6f488770b0ad2"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="regionpage.xml" hash="031ad40fa64f410a64df01bdffdf3894"/></dir><dir name="template"><dir name="regionpage"><file name="regionpage.phtml" hash="0546497d03d31577aaf4fb0ed518e50c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Indianic_Managefields.xml" hash="33204ab502e3af5bc3906db2725150b7"/><file name="Indianic_Regionpage.xml" hash="abd5ae61f48dfc8413fdd20c9a2b0bcc"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_core_modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package><extension><name>gd</name><min>2.0.28</min><max>3.0</max></extension></required></dependencies>
18
+ </package>