Cybernetikz_Background - Version 0.4.0

Version Notes

- Fully customized background feature are added
- Small bugs are fixed

Download this release

Release Info

Developer CyberNetikz
Extension Cybernetikz_Background
Version 0.4.0
Comparing to
See all releases


Code changes from version 0.3.0 to 0.4.0

app/code/local/Cybernetikz/Background/Block/Background.php CHANGED
@@ -5,44 +5,69 @@ class Cybernetikz_Background_Block_Background extends Mage_Core_Block_Template{
5
 
6
  protected function _getCollection()
7
  {
8
- $collection=Mage::getResourceModel('background/background_collection');
9
-
10
  $ccontrollername = Mage::app()->getFrontController()->getRequest()->getControllerName();
11
  $cmodulename = Mage::app()->getFrontController()->getRequest()->getModuleName();
 
12
 
 
 
13
  if($ccontrollername=='category' || $ccontrollername=="product"){
14
- $currentcategory = Mage::registry('current_category');
15
- if( $ccontrollername=="product"){
16
- $catid = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
17
- if(empty($catid) || ($catid==2) ){
18
- $cat = Mage::registry('current_product')->getCategoryIds();
19
- if($cat[0]==2){
20
- $catid = $cat[1];
 
 
 
 
 
 
21
  }else{
22
- $catid = $cat[0];
 
 
 
 
 
 
 
 
 
23
  }
24
  }
25
- $collection->addFieldToFilter('page_id',"{$catid}");
 
26
  $collection->addFieldToFilter('bg_type',"category");
 
27
  }else{
28
- $collection->addFieldToFilter('page_id',"{$currentcategory->getEntityId()}");
 
 
29
  $collection->addFieldToFilter('bg_type',"category");
 
30
  }
31
-
32
  }
33
 
 
34
  if($cmodulename=="cms"){
35
- $pageid = Mage::getSingleton('cms/page')->getId();
36
- $collection->addFieldToFilter('page_id',"{$pageid}");
37
  $collection->addFieldToFilter('bg_type',"{$cmodulename}");
38
  }
39
-
40
  $collection->getSelect()->order('id','ASC');
41
- $collection->getSelect()->limit(1);
42
 
43
- //echo $collection->getSelect()->__toString();
44
- //print_r($collection->getData());
45
- //exit;
 
 
 
 
 
46
 
47
  return $collection;
48
 
@@ -56,7 +81,7 @@ class Cybernetikz_Background_Block_Background extends Mage_Core_Block_Template{
56
  return $this->_backgroundCollection;
57
  }
58
 
59
- public function getImageUrl($url)
60
  {
61
  return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$url;
62
  }
5
 
6
  protected function _getCollection()
7
  {
 
 
8
  $ccontrollername = Mage::app()->getFrontController()->getRequest()->getControllerName();
9
  $cmodulename = Mage::app()->getFrontController()->getRequest()->getModuleName();
10
+ $rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
11
 
12
+ $collection = Mage::getResourceModel('background/background_collection');
13
+ // Check Category / Product Page
14
  if($ccontrollername=='category' || $ccontrollername=="product"){
15
+ // Product Page
16
+ if($ccontrollername=="product"){
17
+ $catId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
18
+ if(empty($catId) || ($catId==$rootCategoryId) ){
19
+ $currentProduct = Mage::registry('current_product');
20
+ if(!method_exists($currentProduct, 'getCategoryIds')){
21
+ $params = Mage::app()->getFrontController()->getRequest()->getParams();
22
+ if($params['cat_id']){
23
+ $catId = $params['cat_id'];
24
+ $categoryIds = NULL;
25
+ }else{
26
+ $categoryIds = Mage::getModel('catalog/product')->load($params['id'])->getCategoryIds();
27
+ }
28
  }else{
29
+ $categoryIds = $currentProduct->getCategoryIds();
30
+ }
31
+
32
+ if(count($categoryIds)>0){
33
+ foreach($categoryIds as $categroyId){
34
+ if($categroyId != $rootCategoryId){
35
+ $catId = $categroyId;
36
+ break;
37
+ }
38
+ }
39
  }
40
  }
41
+
42
+ $collection->addFieldToFilter('page_id',"{$catId}");
43
  $collection->addFieldToFilter('bg_type',"category");
44
+
45
  }else{
46
+ // Category Page
47
+ $currentCategory = Mage::registry('current_category');
48
+ $collection->addFieldToFilter('page_id',"{$currentCategory->getEntityId()}");
49
  $collection->addFieldToFilter('bg_type',"category");
50
+
51
  }
 
52
  }
53
 
54
+ // Check CMS Page
55
  if($cmodulename=="cms"){
56
+ $pageId = Mage::getSingleton('cms/page')->getId();
57
+ $collection->addFieldToFilter('page_id',"{$pageId}");
58
  $collection->addFieldToFilter('bg_type',"{$cmodulename}");
59
  }
60
+
61
  $collection->getSelect()->order('id','ASC');
 
62
 
63
+
64
+ // If background not found, check default background
65
+ if($collection->count() || $collection->count()==0){
66
+ $collection = Mage::getResourceModel('background/background_collection');
67
+ $collection->addFieldToFilter('page_id',"0");
68
+ $collection->addFieldToFilter('bg_type',"default");
69
+ $collection->getSelect()->order('id','ASC');
70
+ }
71
 
72
  return $collection;
73
 
81
  return $this->_backgroundCollection;
82
  }
83
 
84
+ public function getImageFullUrl($url)
85
  {
86
  return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$url;
87
  }
app/code/local/Cybernetikz/Background/controllers/Adminhtml/BackgroundController.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cybernetikz_Background_Adminhtml_BackgroundController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->_title($this->__('Manage Background'));
8
+ $this->loadLayout()->renderLayout();
9
+ }
10
+
11
+ public function newAction()
12
+ {
13
+ $this->_title($this->__('Add New Background'));
14
+ $this->loadLayout()->renderLayout();
15
+ }
16
+
17
+ public function postAction()
18
+ {
19
+ if ($data = $this->getRequest()->getPost()) {
20
+ // Set Page Id
21
+ if($data['bg_type'] == "default"){
22
+ $data['page_id'] = 0;
23
+ }elseif(!empty($data['page_id'])){
24
+ $data['page_id'] = $data['page_id'];
25
+ }else{
26
+ $data['page_id'] = $data['category_id'];
27
+ }
28
+ // Set Custom Selector
29
+ if($data['selector'] == "custom" && !empty($data['custom_selector'])){
30
+ $data['selector'] = $data['custom_selector'];
31
+ }
32
+
33
+ $backgroundCollections=Mage::getResourceModel('background/background_collection');
34
+ $backgroundCollections->addFieldToFilter('page_id',$data['page_id']);
35
+ $backgroundCollections->addFieldToFilter('bg_type',$data['bg_type']);
36
+ $backgroundCollections->addFieldToFilter('selector',$data['selector']);
37
+ $backgroundCollections->getSelect()->order('id','ASC');
38
+ $backgroundCollections->getSelect()->limit(1);
39
+ $background=$backgroundCollections->getData();
40
+ $count = count($background);
41
+ if($count<=0){
42
+ if(isset($_FILES['image_url']['name']) && $_FILES['image_url']['name'] != '') {
43
+ try {
44
+ /* Starting upload */
45
+ $uploader = new Varien_File_Uploader('image_url');
46
+ // Any extention would work
47
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
48
+ $uploader->setAllowRenameFiles(true);
49
+ $uploader->setFilesDispersion(false);
50
+ // We set media as the upload dir
51
+ $path = Mage::getBaseDir('media'). DS . "background" . DS ;
52
+
53
+ $image_file_name = $_FILES['image_url']['name'];
54
+ $retrnimage = $uploader->save($path, $image_file_name);
55
+ } catch (Exception $e) {
56
+ $this->_getSession()->addException($e, Mage::helper('background')->__('Error uploading file. Please try again later.'));
57
+ }
58
+ $data['image_url'] = "background/".$retrnimage['file'];
59
+ }
60
+
61
+ $background = Mage::getModel('background/background')->setData($data);
62
+ try {
63
+
64
+ $background->save();
65
+
66
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('background')->__('Background has been successfully saved.'));
67
+
68
+ // check if 'Save and Continue'
69
+ if ($this->getRequest()->getParam('back')) {
70
+ $this->_redirect('*/*/edit', array('id' => $background->getId()));
71
+ return;
72
+ }
73
+
74
+ // go to grid
75
+ $this->getResponse()->setRedirect($this->getUrl('*/*'));
76
+ return;
77
+
78
+ } catch (Exception $e){
79
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
80
+ $this->_redirectReferer();
81
+ return;
82
+ }
83
+ }else{
84
+ Mage::getSingleton('adminhtml/session')->addError("Same selector background not allowed. You already uplaoded a background for '".$background[0]['selector']."' selector.");
85
+ $this->_redirectReferer();
86
+ return;
87
+ }
88
+ }
89
+
90
+ $this->getResponse()->setRedirect($this->getUrl('*/*'));
91
+ return;
92
+ }
93
+
94
+ public function editAction()
95
+ {
96
+ $this->_title($this->__('Edit Background'));
97
+
98
+ $id = $this->getRequest()->getParam('id',true);
99
+ $background = Mage::getModel('background/background')->load($id, 'id')->getData();
100
+ if(!empty($background)){
101
+ $this->loadLayout()->renderLayout();
102
+ }else{
103
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('background')->__('Wrong URL. Please try again later.'));
104
+ $this->getResponse()->setRedirect($this->getUrl('*/*'));
105
+ return;
106
+ }
107
+ }
108
+
109
+ public function saveAction()
110
+ {
111
+ $data = $this->getRequest()->getPost();
112
+ $id = $data['id'];
113
+ if ($data = $this->getRequest()->getPost()) {
114
+ // Set Page Id
115
+ if($data['bg_type'] == "default"){
116
+ $data['page_id'] = 0;
117
+ }elseif(!empty($data['page_id'])){
118
+ $data['page_id'] = $data['page_id'];
119
+ }else{
120
+ $data['page_id'] = $data['category_id'];
121
+ }
122
+ // Set Custom Selector
123
+ if($data['selector'] == "custom" && !empty($data['custom_selector'])){
124
+ $data['selector'] = $data['custom_selector'];
125
+ }
126
+
127
+ //Slider Image file
128
+ if(isset($_FILES['image_url']['name']) && $_FILES['image_url']['name'] != '') {
129
+ try {
130
+ /* Starting upload */
131
+ $uploader = new Varien_File_Uploader('image_url');
132
+ // Any extention would work
133
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
134
+ $uploader->setAllowRenameFiles(true);
135
+ $uploader->setFilesDispersion(false);
136
+ // We set media as the upload dir
137
+ $path = Mage::getBaseDir('media'). DS . "background" . DS ;
138
+
139
+ $image_file_name = $_FILES['image_url']['name'];
140
+ $retrnimage = $uploader->save($path, $image_file_name );
141
+ } catch (Exception $e) {
142
+ $this->_getSession()->addException($e, Mage::helper('background')->__('Error uploading file. Please try again later.'));
143
+ }
144
+ $data['image_url'] = "background/".$retrnimage['file'];
145
+ }
146
+
147
+ $background = Mage::getModel('background/background')->load($id)->addData($data);
148
+ try {
149
+ $background->setId($id)->save();
150
+
151
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('background')->__('Background has been successfully updated.'));
152
+
153
+ // check if 'Save and Continue'
154
+ if ($this->getRequest()->getParam('back')) {
155
+ $this->_redirect('*/*/edit', array('id' => $background->getId()));
156
+ return;
157
+ }
158
+
159
+ // go to grid
160
+ $this->getResponse()->setRedirect($this->getUrl('*/*'));
161
+ return;
162
+
163
+ } catch (Exception $e){
164
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
165
+
166
+ // redirect to edit form
167
+ $this->_redirect('*/*/edit', array('id' => $id));
168
+ return;
169
+ }
170
+ }
171
+ $this->getResponse()->setRedirect($this->getUrl('*/*'));
172
+ }
173
+
174
+ public function deleteAction()
175
+ {
176
+ $id = $this->getRequest()->getParam('id', false);
177
+
178
+ try {
179
+ Mage::getModel('background/background')->setId($id)->delete();
180
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('background')->__('Background has been successfully deleted.'));
181
+ } catch (Exception $e){
182
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
183
+
184
+ // check if error found and detele action from edit page
185
+ if ($this->getRequest()->getParam('back')) {
186
+ $this->_redirect('*/*/edit', array('id' => $id));
187
+ return;
188
+ }
189
+ }
190
+
191
+ $this->getResponse()->setRedirect($this->getUrl('*/*'));
192
+ }
193
+ }
194
+ ?>
app/code/local/Cybernetikz/Background/controllers/Adminhtml/MyformController.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
-
3
- class Cybernetikz_Background_Adminhtml_MyformController extends Mage_Adminhtml_Controller_Action
4
- {
5
- public function indexAction()
6
- {
7
- $this->loadLayout()->renderLayout();
8
- }
9
-
10
- public function pagemanageAction()
11
- {
12
- $this->loadLayout()->renderLayout();
13
- }
14
-
15
- public function deleteAction()
16
- {
17
- $id = $this->getRequest()->getParam('id', false);
18
-
19
- try {
20
- Mage::getModel('background/background')->setId($id)->delete();
21
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('background')->__('Background Image successfully deleted.'));
22
- } catch (Exception $e){
23
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
- }
25
-
26
- $this->_redirectReferer();
27
- }
28
-
29
-
30
- public function postAction()
31
- {
32
- if ($data = $this->getRequest()->getPost()) {
33
- if(!empty($data['page_id'])){
34
- $data['page_id']= $data['page_id'];
35
- }else{
36
- $data['page_id']= $data['category_id'];
37
- }
38
-
39
- $collection=Mage::getResourceModel('background/background_collection');
40
- $collection->addFieldToFilter('page_id',$data['page_id']);
41
- $collection->addFieldToFilter('bg_type',$data['bg_type']);
42
- $collection->getSelect()->order('id','ASC');
43
- $collection->getSelect()->limit(1);
44
- $backgroundCollection=$collection->getData();
45
- $count=count($backgroundCollection);
46
- if($count<=0){
47
- if(isset($_FILES['image_url']['name']) && $_FILES['image_url']['name'] != '') {
48
- try {
49
- /* Starting upload */
50
- $uploader = new Varien_File_Uploader('image_url');
51
- // Any extention would work
52
- $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
53
- $uploader->setAllowRenameFiles(false);
54
- $uploader->setFilesDispersion(false);
55
- // We set media as the upload dir
56
- $path = Mage::getBaseDir('media'). DS . "background" . DS ;
57
- $filename = $_FILES['image_url']['name'];
58
- $image_file_name = time().'-'.$filename;
59
- $retrnimage=$uploader->save($path, $image_file_name);
60
- } catch (Exception $e) {
61
- $this->_getSession()->addException($e, Mage::helper('background')->__('Error uploading file. Please try again later.'));
62
- }
63
- $data['image_url'] = "background/".$retrnimage['file'];
64
- }
65
- $background = Mage::getModel('background/background')->setData($data);
66
- try {
67
- $background->save();
68
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('background')->__('Background Image was successfully saved.'));
69
- $this->getResponse()->setRedirect($this->getUrl('*/*/pagemanage'));
70
- return;
71
- } catch (Exception $e){
72
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
73
- }
74
- }else{
75
- Mage::getSingleton('adminhtml/session')->addError("Already uplaod background for this page.");
76
- $this->_redirectReferer();
77
- return;
78
- }
79
-
80
- }
81
- $this->getResponse()->setRedirect($this->getUrl('*/*/pagemanage'));
82
- return;
83
- }
84
-
85
- public function editpageAction()
86
- {
87
- $this->loadLayout()->renderLayout();
88
- }
89
-
90
- public function saveAction()
91
- {
92
- $data = $this->getRequest()->getPost();
93
- $id = $data['id'];
94
- if ($data = $this->getRequest()->getPost()) {
95
- //Slider Image file
96
- if(isset($_FILES['image_url']['name']) && $_FILES['image_url']['name'] != '') {
97
- try {
98
- /* Starting upload */
99
- $uploader = new Varien_File_Uploader('image_url');
100
- // Any extention would work
101
- $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
102
- $uploader->setAllowRenameFiles(false);
103
- $uploader->setFilesDispersion(false);
104
- // We set media as the upload dir
105
- $path = Mage::getBaseDir('media'). DS . "background" . DS ;
106
-
107
- $filename = $_FILES['image_url']['name'];
108
- $image_file_name = time().'-'.$filename;
109
- $retrnimage=$uploader->save($path, $image_file_name );
110
- } catch (Exception $e) {
111
- $this->_getSession()->addException($e, Mage::helper('background')->__('Error uploading file. Please try again later.'));
112
- }
113
- $data['image_url'] = "background/".$retrnimage['file'];
114
- }
115
-
116
- $background = Mage::getModel('background/background')->load($id)->addData($data);
117
- try {
118
- $background->setId($id)->save();
119
-
120
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('background')->__('Background Image successfully updated.'));
121
- $this->getResponse()->setRedirect($this->getUrl('*/*/pagemanage'));
122
- return;
123
- } catch (Exception $e){
124
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
125
- }
126
- }
127
- $this->getResponse()->setRedirect($this->getUrl('*/*/pagemanage'));
128
- }
129
- }
130
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Cybernetikz/Background/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Cybernetikz_Background>
5
- <version>0.3.0</version>
6
  </Cybernetikz_Background>
7
  </modules>
8
 
@@ -52,16 +52,16 @@
52
  </background_read>
53
  </resources>
54
  </global>
55
-
56
- <admin>
57
  <routers>
58
- <background>
59
- <use>admin</use>
60
  <args>
61
- <module>Cybernetikz_Background</module>
62
- <frontName>background</frontName>
 
63
  </args>
64
- </background>
65
  </routers>
66
  </admin>
67
 
@@ -92,7 +92,7 @@
92
  <background_adminform translate="title" module="background">
93
  <title>Manage Background</title>
94
  <sort_order>106</sort_order>
95
- <action>background/adminhtml_myform/pagemanage</action>
96
  </background_adminform>
97
  </children>
98
  </cms>
2
  <config>
3
  <modules>
4
  <Cybernetikz_Background>
5
+ <version>0.4.0</version>
6
  </Cybernetikz_Background>
7
  </modules>
8
 
52
  </background_read>
53
  </resources>
54
  </global>
55
+
56
+ <admin>
57
  <routers>
58
+ <adminhtml>
 
59
  <args>
60
+ <modules>
61
+ <Cybernetikz_Background before="Mage_Adminhtml">Cybernetikz_Background_Adminhtml</Cybernetikz_Background>
62
+ </modules>
63
  </args>
64
+ </adminhtml>
65
  </routers>
66
  </admin>
67
 
92
  <background_adminform translate="title" module="background">
93
  <title>Manage Background</title>
94
  <sort_order>106</sort_order>
95
+ <action>adminhtml/background</action>
96
  </background_adminform>
97
  </children>
98
  </cms>
app/code/local/Cybernetikz/Background/sql/background_setup/mysql4-install-0.1.0.php CHANGED
@@ -4,11 +4,11 @@ $installer->startSetup();
4
 
5
  $installer->run("
6
  CREATE TABLE {$this->getTable('background/background')} (
7
- `id` INT(10) NOT NULL AUTO_INCREMENT,
8
- `bg_type` VARCHAR(100) NOT NULL,
9
- `page_id` INT NOT NULL,
10
- `image_url` VARCHAR(255) NOT NULL,
11
- PRIMARY KEY (`id`)
12
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13
  ");
14
 
4
 
5
  $installer->run("
6
  CREATE TABLE {$this->getTable('background/background')} (
7
+ `id` INT(10) NOT NULL AUTO_INCREMENT,
8
+ `bg_type` VARCHAR(100) NOT NULL,
9
+ `page_id` INT NOT NULL,
10
+ `image_url` VARCHAR(255) NOT NULL,
11
+ PRIMARY KEY (`id`)
12
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13
  ");
14
 
app/code/local/Cybernetikz/Background/sql/background_setup/mysql4-upgrade-0.3.0-0.4.0.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->run("
6
+ ALTER TABLE {$this->getTable('background/background')} ADD `selector` VARCHAR(255) NOT NULL AFTER `image_url`;
7
+ ALTER TABLE {$this->getTable('background/background')} ADD `repeat` varchar(50) NULL AFTER `selector`;
8
+ ALTER TABLE {$this->getTable('background/background')} ADD `position` varchar(50) NULL AFTER `repeat`;
9
+ ALTER TABLE {$this->getTable('background/background')} ADD `attachment` varchar(50) NULL AFTER `position`;
10
+ ALTER TABLE {$this->getTable('background/background')} ADD `color` varchar(50) NULL AFTER `attachment`;
11
+ ALTER TABLE {$this->getTable('background/background')} ADD `size` varchar(50) NULL AFTER `color`;
12
+ ALTER TABLE {$this->getTable('background/background')} ADD `origin` varchar(50) NULL AFTER `size`;
13
+ ALTER TABLE {$this->getTable('background/background')} ADD `clip` varchar(50) NULL AFTER `origin`;
14
+ ALTER TABLE {$this->getTable('background/background')} ADD `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation Time' AFTER `clip`;
15
+ ");
16
+
17
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/background.xml CHANGED
@@ -1,29 +1,29 @@
1
  <?xml version="1.0"?>
2
- <layout>
3
- <background_adminhtml_myform_index>
4
- <update handle="background_myform_index"/>
 
 
 
 
 
 
5
  <reference name="head">
6
  <action method="addJs"><script>backgroundjs/jquery-1.10.1.min.js</script></action>
 
7
  </reference>
8
  <reference name="content">
9
- <block type="adminhtml/template" name="myform" template="background/myform.phtml"/>
10
- </reference>
11
- </background_adminhtml_myform_index>
12
-
13
- <background_adminhtml_myform_pagemanage>
14
- <update handle="background_myform_pagemanage"/>
15
- <reference name="content">
16
- <block type="adminhtml/template" name="myform" template="background/pagemanage.phtml"/>
17
  </reference>
18
- </background_adminhtml_myform_pagemanage>
19
 
20
- <background_adminhtml_myform_editpage>
21
- <update handle="background_myform_editpage"/>
22
  <reference name="head">
23
  <action method="addJs"><script>backgroundjs/jquery-1.10.1.min.js</script></action>
 
24
  </reference>
25
  <reference name="content">
26
- <block type="adminhtml/template" name="myform" template="background/editpage.phtml"/>
27
  </reference>
28
- </background_adminhtml_myform_editpage>
29
  </layout>
1
  <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_background_index>
4
+ <update handle="background_background_index"/>
5
+ <reference name="content">
6
+ <block type="adminhtml/template" name="background" template="background/grid.phtml"/>
7
+ </reference>
8
+ </adminhtml_background_index>
9
+
10
+ <adminhtml_background_new>
11
  <reference name="head">
12
  <action method="addJs"><script>backgroundjs/jquery-1.10.1.min.js</script></action>
13
+ <action method="addJs"><script>jscolor/jscolor.js</script></action>
14
  </reference>
15
  <reference name="content">
16
+ <block type="adminhtml/template" name="background" template="background/new.phtml"/>
 
 
 
 
 
 
 
17
  </reference>
18
+ </adminhtml_background_new>
19
 
20
+ <adminhtml_background_edit>
 
21
  <reference name="head">
22
  <action method="addJs"><script>backgroundjs/jquery-1.10.1.min.js</script></action>
23
+ <action method="addJs"><script>jscolor/jscolor.js</script></action>
24
  </reference>
25
  <reference name="content">
26
+ <block type="adminhtml/template" name="background" template="background/edit.phtml"/>
27
  </reference>
28
+ </adminhtml_background_edit>
29
  </layout>
app/design/adminhtml/default/default/template/background/edit.phtml ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $id = $this->getRequest()->getParam('id',true);
3
+ $background = Mage::getModel('background/background')->load($id, 'id')->getData();
4
+ ?>
5
+ <div class="content-header">
6
+ <table cellspacing="0" class="grid-header">
7
+ <tr>
8
+ <td><h3><?php echo $this->__('Edit %s', 'Background')?></h3></td>
9
+ <td class="a-right">
10
+ <button onclick="location.href='<?php echo Mage::helper("adminhtml")->getUrl("*/*");?>'" class="scalable back" type="button" <?php echo $this->__('Back')?>><span><?php echo $this->__('Back')?></span></button>
11
+ <button type="button" class="scalable delete" onclick="deleteConfirm('Are you sure you want to do this?', '<?php echo $this->getUrl("*/*/delete/back/edit/id/".$background['id'].""); ?>')" title="<?php echo $this->__('Delete')?>"><span><span><span><?php echo $this->__('Delete')?></span></span></span></button>
12
+ <button onclick="editForm.submit()" class="scalable save" type="button" title="<?php echo $this->__('Save')?>"><span><span><span><?php echo $this->__('Save')?></span></span></span></button>
13
+ <button onclick="saveAndContinueEdit();" class="scalable save" type="button" title="<?php echo $this->__('Save and Continue Edit')?>"><span><span><span><?php echo $this->__('Save and Continue Edit')?></span></span></span></button>
14
+ </td>
15
+ </tr>
16
+ </table>
17
+ </div>
18
+ <div id="containment-wrapper" class="entry-edit">
19
+ <div class="entry-edit-head">
20
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Edit %s', 'Background')?></h4>
21
+ <div class="form-buttons"></div>
22
+ </div>
23
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/save')?>" enctype="multipart/form-data">
24
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
25
+ <fieldset class="fieldset-wide">
26
+ <table cellspacing="0" class="form-list">
27
+ <tr>
28
+ <td width="50%">
29
+ <table cellspacing="0" class="form-list">
30
+ <tr>
31
+ <td class="label"><?php echo $this->__('Page Type')?> <span class="required">*</span></td>
32
+ <td class="label value">
33
+ <select name="bg_type" id="bg_type" class="required-entry" onchange="catgeturl(this.value);" disabled="disabled">
34
+ <option value="">-- Select Page Type --</option>
35
+ <option value="default"<?php echo ($background['bg_type']=="default")?' selected="selected"':'';?>>Default</option>
36
+ <option value="cms"<?php echo ($background['bg_type']=="cms")?' selected="selected"':'';?>>CMS Page</option>
37
+ <option value="category"<?php echo ($background['bg_type']=="category")?' selected="selected"':'';?>>Category</option>
38
+ </select>
39
+ </td>
40
+ </tr>
41
+ <tr id="cms_page_list"<?php echo ($background['bg_type']!="cms")?'style="display:none;"':''?>>
42
+ <td class="label"><?php echo $this->__('Page')?> <span class="required">*</span></td>
43
+ <td class="label value">
44
+ <?php $cms_pages = Mage::getModel('cms/page')->getCollection();
45
+ $cms_pages->load();
46
+ ?>
47
+
48
+ <select name="page_id" id="page_id" disabled="disabled">
49
+ <option value="">-- Select CMS Page --</option>
50
+ <?php foreach($cms_pages as $_page): ?>
51
+ <?php $data = $_page->getData(); ?>
52
+ <option value="<?php echo $data['page_id'] ?>"<?php if(($background['bg_type']=="cms") && ($background['page_id']==$data['page_id'])){?> selected="selected"<?php } ?>><?php echo $data['title']; ?></option>
53
+ <?php endforeach; ?>
54
+ </select>
55
+ </td>
56
+ </tr>
57
+
58
+ <tr id="category_list"<?php echo ($background['bg_type']!="category")?' style="display:none;"':'';?>>
59
+ <td class="label"><?php echo $this->__('Category')?> <span class="required">*</span></td>
60
+ <td class="label value">
61
+ <select name="category_id" id="category_id" disabled="disabled">
62
+ <option value="">-- Select Category --</option>
63
+ <?php foreach (Mage::app()->getWebsites() as $website):?>
64
+ <optgroup label="<?php echo $website->getName(); ?>">
65
+ <?php foreach ($website->getGroups() as $group):?>
66
+ <?php $stores = $group->getStores(); ?>
67
+ <optgroup label="<?php echo "&nbsp;&nbsp;".$group->getName(); ?>">
68
+ <?php foreach ($stores as $store): ?>
69
+ <optgroup label="<?php echo "&nbsp;&nbsp;&nbsp;&nbsp;".$store->getName(); ?>"></optgroup>
70
+ <?php endforeach;?>
71
+ <?php
72
+ $root_categoryid=Mage::app()->getStore($store->getStoreId())->getRootCategoryId();
73
+ $_categories = Mage::getModel('catalog/category')->load($root_categoryid);
74
+ $_categories = $_categories->getChildrenCategories();
75
+ if (count($_categories) > 0):
76
+ ?>
77
+ <?php foreach($_categories as $_category):?>
78
+ <?php $_category = Mage::getModel('catalog/category')->load($_category->getId());?>
79
+ <?php //print_r($_category->getData());exit; ?>
80
+ <?php if($_category->getIsActive() && $_category->getName()!=""): ?>
81
+ <option style="margin-left:25px;" value="<?php echo $_category->getId() ?>" <?php if(($background['bg_type']=="category") && ($background['page_id']==$_category->getId())){?> selected="selected" <?php } ?>><?php echo $_category->getName() ?></option>
82
+ <?php $_subcategories = $_category->getChildrenCategories() ?>
83
+ <?php if (count($_subcategories) > 0): ?>
84
+ <?php foreach($_subcategories as $_subcategory): ?>
85
+ <?php if($_subcategory->getIsActive() && $_subcategory->getName()!=""): ?>
86
+ <option style="margin-left:35px;" value="<?php echo $_subcategory->getId() ?>" <?php if(($background['bg_type']=="category") && ($background['page_id']==$_subcategory->getId())){?> selected="selected" <?php } ?>><?php echo $_subcategory->getName() ?></option>
87
+ <?php $_subcategorylevel4 = Mage::getModel('catalog/category')->load($_subcategory->getId());?>
88
+ <?php $_level4subcategories = $_subcategorylevel4->getChildrenCategories() ?>
89
+ <?php if (count($_level4subcategories) > 0): ?>
90
+ <?php foreach($_level4subcategories as $_level4subcategory): ?>
91
+ <?php if($_level4subcategory->getIsActive() && $_level4subcategory->getName()!=""): ?>
92
+ <option style="margin-left:45px;" value="<?php echo $_level4subcategory->getId() ?>" <?php if(($background['bg_type']=="category") && ($background['page_id']==$_level4subcategory->getId())){?> selected="selected" <?php } ?>><?php echo $_level4subcategory->getName() ?></option>
93
+ <?php endif; ?>
94
+ <?php endforeach; ?>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
97
+ <?php endforeach; ?>
98
+ <?php endif; ?>
99
+ <?php endif; ?>
100
+ <?php endforeach; ?>
101
+ <?php endif; ?>
102
+ </optgroup>
103
+ <?php endforeach;?>
104
+ </optgroup>
105
+ <?php endforeach;?>
106
+ </select>
107
+ </td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td class="label"><?php echo $this->__('Background Image')?> <span class="required">*</span></td>
112
+ <td class="label value">
113
+ <input type="file" name="image_url" id="image_url" />
114
+ <?php if($background['image_url']){?>
115
+ <br /><br />
116
+ <a href="javascript:void(0);" onclick="window.open('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$background['image_url'];?>','','width=600,height=400');"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$background['image_url'];?>" height="30" width="30" alt="Uplaod Image" border="0" style="border:none;" /></a>
117
+ <?php }?>
118
+ </td>
119
+ </tr>
120
+ <tr>
121
+ <td class="label"><?php echo $this->__('Background Selector')?> <span class="required">*</span></td>
122
+ <td class="label value">
123
+ <select name="selector" id="selector" class="required-entry" onchange="customSelector(this.value);" disabled="disabled">
124
+ <option value="">-- Select Selector --</option>
125
+ <option value="body"<?php echo ($background['selector']=="body")?' selected="selected"':'';?>>Body</option>
126
+ <option value="custom"<?php echo ($background['selector']!="body")?' selected="selected"':'';?>>Custom</option>
127
+ </select>
128
+ </td>
129
+ </tr>
130
+ <tr id="custom_selector_block"<?php echo ($background['selector']=="body")?' style="display:none;"':'';?>>
131
+ <td class="label"><?php echo $this->__('Custom Selector')?> <span class="required">*</span></td>
132
+ <td class="label value">
133
+ <input name="custom_selector" id="custom_selector" type="text"<?php echo ($background['selector']!="body")?' class="input-text required-entry" value="'.$background['selector'].'"':' class="input-text"';?> style="width: 274px ! important;" disabled="disabled" />
134
+ <p id="note_identifier" class="note"><span>Use CSS selector ie: class(.class-name) / id(#id) / others selector. For multi selector use , seperator like ".selector1, .selector2"</span></p>
135
+ </td>
136
+ </tr>
137
+ <tr>
138
+ <td class="label"><?php echo $this->__('Background Repeat')?> <span class="required">*</span></td>
139
+ <td class="label value">
140
+ <?php $backgroundRepeats = array("repeat","repeat-x", "repeat-y", "no-repeat", "initial", "inherit"); ?>
141
+ <select name="repeat" id="repeat" class="required-entry">
142
+ <option value="">-- Select Repeat --</option>
143
+ <?php foreach($backgroundRepeats as $repeat):?>
144
+ <option value="<?php echo $repeat; ?>"<?php echo ($background['repeat']==$repeat)?' selected="selected"':'';?>><?php echo $repeat; ?></option>
145
+ <?php endforeach; ?>
146
+ </select>
147
+ </td>
148
+ </tr>
149
+ <tr>
150
+ <td class="label"><?php echo $this->__('Background Position')?> <span class="required">*</span></td>
151
+ <td class="label value">
152
+ <?php $backgroundPositions = array("left top","left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom", "initial", "inherit"); ?>
153
+ <select name="position" id="position" class="required-entry">
154
+ <option value="">-- Select Position --</option>
155
+ <?php foreach($backgroundPositions as $position):?>
156
+ <option value="<?php echo $position; ?>"<?php echo ($background['position']==$position)?' selected="selected"':'';?>><?php echo $position; ?></option>
157
+ <?php endforeach; ?>
158
+ </select>
159
+ </td>
160
+ </tr>
161
+ <tr>
162
+ <td class="label"><?php echo $this->__('Background Attachment')?></td>
163
+ <td class="label value">
164
+ <?php $backgroundAttachments = array("scroll","fixed", "local", "initial", "inherit"); ?>
165
+ <select name="attachment" id="attachment" class="required-entry">
166
+ <?php foreach($backgroundAttachments as $attachment):?>
167
+ <option value="<?php echo $attachment; ?>"<?php echo ($background['attachment']==$attachment)?' selected="selected"':'';?>><?php echo $attachment; ?></option>
168
+ <?php endforeach; ?>
169
+ </select>
170
+ </td>
171
+ </tr>
172
+ <tr>
173
+ <td class="label"><?php echo $this->__('Background Color')?></td>
174
+ <td class="label value">
175
+ <input name="color" id="color" type="text" class="color input-text required-entry" value="<?php echo $background['color'];?>" style="width: 274px ! important;" />
176
+ <p id="note_identifier" class="note"><span>Please pick your preferred color.</span></p>
177
+ </td>
178
+ </tr>
179
+ <tr>
180
+ <td class="label"><?php echo $this->__('Background Size')?></td>
181
+ <td class="label value">
182
+ <?php $backgroundSizes = array("auto","cover", "contain", "initial", "inherit"); ?>
183
+ <select name="size" id="size" class="required-entry">
184
+ <?php foreach($backgroundSizes as $size):?>
185
+ <option value="<?php echo $size; ?>"<?php echo ($background['size']==$size)?' selected="selected"':'';?>><?php echo $size; ?></option>
186
+ <?php endforeach; ?>
187
+ </select>
188
+ </td>
189
+ </tr>
190
+ <tr>
191
+ <td class="label"><?php echo $this->__('Background Origin')?></td>
192
+ <td class="label value">
193
+ <?php $backgroundOrigins = array("padding-box","border-box", "content-box", "initial", "inherit"); ?>
194
+ <select name="origin" id="origin" class="required-entry">
195
+ <?php foreach($backgroundOrigins as $origin):?>
196
+ <option value="<?php echo $origin; ?>"<?php echo ($background['origin']==$origin)?' selected="selected"':'';?>><?php echo $origin; ?></option>
197
+ <?php endforeach; ?>
198
+ </select>
199
+ </td>
200
+ </tr>
201
+ <tr>
202
+ <td class="label"><?php echo $this->__('Background Clip')?></td>
203
+ <td class="label value">
204
+ <?php $backgroundClips = array("padding-box","border-box", "content-box", "initial", "inherit"); ?>
205
+ <select name="clip" id="clip" class="required-entry">
206
+ <?php foreach($backgroundClips as $clip):?>
207
+ <option value="<?php echo $clip; ?>"<?php echo ($background['clip']==$clip)?' selected="selected"':'';?>><?php echo $clip; ?></option>
208
+ <?php endforeach; ?>
209
+ </select>
210
+ </td>
211
+ </tr>
212
+ </table>
213
+ </td>
214
+ <td width="50%" class="a-center v-middle">
215
+ <a target="_blank" href="http://www.cybernetikz.com/store/magento-extension.html">
216
+ <img src="http://cybernetikz.com/images/cybernetikz-magento-extensions.jpg" align="Cybernetikz Magento Extensions" />
217
+ </a>
218
+ </td>
219
+ </tr>
220
+ </table>
221
+ </fieldset>
222
+ <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
223
+ </form>
224
+
225
+ </div>
226
+ <script type="text/javascript">
227
+ function catgeturl(e){
228
+ if(e=="cms"){
229
+ jQuery("#cms_page_list").show();
230
+ jQuery("#cms_page_list select").addClass("required-entry");
231
+ jQuery("#category_list select").removeClass("required-entry");
232
+ jQuery("#category_list select").val("");
233
+ jQuery("#category_list").hide();
234
+
235
+ }
236
+ if(e=="category"){
237
+ jQuery("#category_list").show();
238
+ jQuery("#category_list select").addClass("required-entry");
239
+ jQuery("#cms_page_list select").removeClass("required-entry");
240
+ jQuery("#cms_page_list select").val("");
241
+ jQuery("#cms_page_list").hide();
242
+ }
243
+ if(e=="" || e=="default"){
244
+ jQuery("#cms_page_list").hide();
245
+ jQuery("#category_list").hide();
246
+ jQuery("#category_list select").removeClass("required-entry");
247
+ jQuery("#cms_page_list select").removeClass("required-entry");
248
+ jQuery("#category_list select").val("");
249
+ jQuery("#cms_page_list select").val("");
250
+ }
251
+ }
252
+
253
+ // Custom Selector
254
+ function customSelector(e){
255
+ if(e=="custom"){
256
+ jQuery("#custom_selector_block").show();
257
+ jQuery("#custom_selector_block input#custom_selector").addClass("required-entry");
258
+
259
+ }else{
260
+ jQuery("#custom_selector_block").hide();
261
+ jQuery("#custom_selector_block input#custom_selector").removeClass("required-entry");
262
+ jQuery("#custom_selector_block input#custom_selector").val("");
263
+ }
264
+ }
265
+
266
+ // Form Validation
267
+ var editForm = new varienForm('edit_form');
268
+
269
+ function saveAndContinueEdit(){
270
+ editForm.submit($('edit_form').action+'back/edit/');
271
+ }
272
+ </script>
app/design/adminhtml/default/default/template/background/editpage.phtml DELETED
@@ -1,154 +0,0 @@
1
- <?php /*?><script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
2
- <script type="text/javascript">
3
- jQuery.noConflict();
4
- </script><?php */?>
5
- <?php
6
- $id = $this->getRequest()->getParam('id',true);
7
- $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
8
- $signgleinfo = Mage::getModel('background/background')->load($id, 'id')->getData();
9
- ?>
10
- <div class="content-header">
11
- <table cellspacing="0" class="grid-header">
12
- <tr>
13
- <td><h3><?php echo $this->__('Edit Background')?></h3></td>
14
- <td class="a-right">
15
- <button onclick="location.href='<?php echo Mage::helper("adminhtml")->getUrl("background/adminhtml_myform/pagemanage");?>'" class="scalable back" type="button"><span>Back</span></button> <button onclick="editForm.submit()" class="scalable save" type="button"><span>Submit</span></button>
16
- </td>
17
- </tr>
18
- </table>
19
- </div>
20
- <div id="containment-wrapper" class="entry-edit">
21
- <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/save')?>" enctype="multipart/form-data">
22
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
23
- <fieldset id="my-fieldset">
24
- <table cellspacing="0" class="form-list">
25
- <tr>
26
- <td class="label"><?php echo $this->__('Page Type')?> <span class="required">*</span></td>
27
- <td class="input-ele">
28
- <select name="bg_type" id="bg_type" class="required-entry" style="width:200px;" onchange="catgeturl(this.value);" disabled="disabled">
29
- <option value="">Select Page Type</option>
30
- <option value="cms" <?php echo ($signgleinfo['bg_type']=="cms")?'selected="selected"':"";?>>CMS Page</option>
31
- <option value="category" <?php echo ($signgleinfo['bg_type']=="category")?'selected="selected"':"";?>>Category</option>
32
- </select>
33
- </td>
34
- </tr>
35
- <tr id="cms_page_list" style="<?php echo ($signgleinfo['bg_type']!="cms")?'display:none':''?>;">
36
- <td class="label"><?php echo $this->__('Page')?> <span class="required">*</span></td>
37
- <td class="input-ele">
38
- <?php $cms_pages = Mage::getModel('cms/page')->getCollection();
39
- $cms_pages->load();
40
- ?>
41
-
42
- <select name="page_id" id="page_id" style="width:200px;" disabled="disabled">
43
- <option value="">Select Page</option>
44
- <?php foreach($cms_pages as $_page): ?>
45
- <?php $data = $_page->getData(); ?>
46
- <option value="<?php echo $data['page_id'] ?>" <?php if(($signgleinfo['bg_type']=="cms") && ($signgleinfo['page_id']==$data['page_id'])){?> selected="selected" <?php } ?>><?php echo $data['title']; ?></option>
47
- <?php endforeach; ?>
48
- </select>
49
- </td>
50
- </tr>
51
-
52
- <tr id="category_list" style="<?php echo ($signgleinfo['bg_type']!="category")?'display:none':'';?>;">
53
- <td class="label"><?php echo $this->__('Category')?> <span class="required">*</span></td>
54
- <td class="input-ele">
55
- <select name="category_id" id="category_id" style="width:200px;" <?php echo ($signgleinfo['bg_type']=="category")?'disabled="disabled"':''?>>
56
- <option value="">Select Category</option>
57
- <?php foreach (Mage::app()->getWebsites() as $website):?>
58
- <optgroup label="<?php echo $website->getName(); ?>">
59
- <?php foreach ($website->getGroups() as $group):?>
60
- <?php $stores = $group->getStores(); ?>
61
- <optgroup label="<?php echo "&nbsp;&nbsp;".$group->getName(); ?>">
62
- <?php foreach ($stores as $store): ?>
63
- <optgroup label="<?php echo "&nbsp;&nbsp;&nbsp;&nbsp;".$store->getName(); ?>"></optgroup>
64
- <?php endforeach;?>
65
- <?php
66
- $root_categoryid=Mage::app()->getStore($store->getStoreId())->getRootCategoryId();
67
- $_categories = Mage::getModel('catalog/category')->load($root_categoryid);
68
- $_categories = $_categories->getChildrenCategories();
69
- if (count($_categories) > 0):
70
- ?>
71
- <?php foreach($_categories as $_category):?>
72
- <?php $_category = Mage::getModel('catalog/category')->load($_category->getId());?>
73
- <?php //print_r($_category->getData());exit; ?>
74
- <?php if($_category->getIsActive() && $_category->getName()!=""): ?>
75
- <option style="margin-left:25px;" value="<?php echo $_category->getId() ?>" <?php if(($signgleinfo['bg_type']=="category") && ($signgleinfo['page_id']==$_category->getId())){?> selected="selected" <?php } ?>><?php echo $_category->getName() ?></option>
76
- <?php $_subcategories = $_category->getChildrenCategories() ?>
77
- <?php if (count($_subcategories) > 0): ?>
78
- <?php foreach($_subcategories as $_subcategory): ?>
79
- <?php if($_subcategory->getIsActive() && $_subcategory->getName()!=""): ?>
80
- <option style="margin-left:35px;" value="<?php echo $_subcategory->getId() ?>" <?php if(($signgleinfo['bg_type']=="category") && ($signgleinfo['page_id']==$_subcategory->getId())){?> selected="selected" <?php } ?>><?php echo $_subcategory->getName() ?></option>
81
- <?php $_subcategorylevel4 = Mage::getModel('catalog/category')->load($_subcategory->getId());?>
82
- <?php $_level4subcategories = $_subcategorylevel4->getChildrenCategories() ?>
83
- <?php if (count($_level4subcategories) > 0): ?>
84
- <?php foreach($_level4subcategories as $_level4subcategory): ?>
85
- <?php if($_level4subcategory->getIsActive() && $_level4subcategory->getName()!=""): ?>
86
- <option style="margin-left:45px;" value="<?php echo $_level4subcategory->getId() ?>" <?php if(($signgleinfo['bg_type']=="category") && ($signgleinfo['page_id']==$_level4subcategory->getId())){?> selected="selected" <?php } ?>><?php echo $_level4subcategory->getName() ?></option>
87
- <?php endif; ?>
88
- <?php endforeach; ?>
89
- <?php endif; ?>
90
- <?php endif; ?>
91
- <?php endforeach; ?>
92
- <?php endif; ?>
93
- <?php endif; ?>
94
- <?php endforeach; ?>
95
- <?php endif; ?>
96
- </optgroup>
97
- <?php endforeach;?>
98
- </optgroup>
99
- <?php endforeach;?>
100
- </select>
101
- </td>
102
- </tr>
103
-
104
- <tr>
105
- <td class="label"><?php echo $this->__('Background Image')?> <span class="required">*</span></td>
106
- <td class="input-ele">
107
- <input type="file" name="image_url" id="image_url" class="required-entry" />
108
- <?php if($signgleinfo['image_url']){?>
109
- <br /><?php /*?><input type="checkbox" name="[image_url][delete]" id="delete" value="1" onclick="jQuery('#image_url').removeClass('required-entry');" /><?php */?><br />
110
- <a href="javascript:void(0);" onclick="window.open('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$signgleinfo['image_url'];?>','','width=600,height=400');"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$signgleinfo['image_url'];?>" height="30" width="30" alt="Uplaod Image" border="0" style="border:none;" /></a>
111
- <?php }?>
112
- </td>
113
- </tr>
114
-
115
-
116
- </table>
117
- </fieldset>
118
- <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
119
- </form>
120
-
121
- </div>
122
- <script type="text/javascript">
123
- function catgeturl(e){
124
- if(e=="cms"){
125
- jQuery("#cms_page_list").show();
126
- jQuery("#cms_page_list select").addClass("required-entry");
127
- jQuery("#category_list select").removeClass("required-entry");
128
- jQuery("#category_list select").val("");
129
- jQuery("#category_list").hide();
130
-
131
- }
132
- if(e=="category"){
133
- jQuery("#category_list").show();
134
- jQuery("#category_list select").addClass("required-entry");
135
- jQuery("#cms_page_list select").removeClass("required-entry");
136
- jQuery("#cms_page_list select").val("");
137
- jQuery("#cms_page_list").hide();
138
- }
139
- if(e==""){
140
- jQuery("#cms_page_list").hide();
141
- jQuery("#category_list").hide();
142
- jQuery("#category_list select").removeClass("required-entry");
143
- jQuery("#cms_page_list select").removeClass("required-entry");
144
- jQuery("#category_list select").val("");
145
- jQuery("#cms_page_list select").val("");
146
- }
147
- }
148
-
149
- jQuery(document).ready(function(){
150
-
151
- });
152
-
153
- var editForm = new varienForm('edit_form');
154
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/background/grid.phtml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3><?php echo $this->__('Manage %s', 'Backgrounds')?></h3></td>
5
+ <td class="a-right">
6
+ <button onclick="javascript:location.href='<?php echo $this->getUrl("*/*/new"); ?>'" class="scalable save" type="button" title="<?php echo $this->__('Add New %s', 'Background')?>"><span><?php echo $this->__('Add New %s', 'Background')?></span></button>
7
+ </td>
8
+ </tr>
9
+ </table>
10
+ </div>
11
+ <div class="entry-edit grid">
12
+ <?php
13
+ $backgroundCollections = Mage::getModel('background/background')->getCollection()->getItems();
14
+
15
+ ?>
16
+ <table cellspacing="0" id="cmsPageGrid_table" class="data" width="100%">
17
+ <thead>
18
+ <tr class="headings">
19
+ <th width="25%" align="center"><?php echo $this->__('Page Title'); ?></th>
20
+ <th width="15%" align="center"><?php echo $this->__('Page Type'); ?></th>
21
+ <th width="20%" align="center"><?php echo $this->__('Background Image'); ?></th>
22
+ <th width="20%" align="center"><?php echo $this->__('Background Selector'); ?></th>
23
+ <th width="20%" align="center" class=" no-link last"><span class="nobr"><?php echo $this->__('Action'); ?></span></th>
24
+ </tr>
25
+ </thead>
26
+
27
+ <tbody id="">
28
+ <?php if(count($backgroundCollections)>=1): ?>
29
+ <?php $i=0; foreach($backgroundCollections as $i=>$background): ?>
30
+ <tr class="<?php echo ($i%2==0)?"even":"odd"; ?>">
31
+ <td align="center">
32
+ <?php
33
+ if($background->getBgType()=="default"){
34
+ $pageTitle = "Default Background";
35
+ }elseif($background->getBgType()=="cms"){
36
+ $_page = Mage::getModel('cms/page')->load($background->getPageId());
37
+ $pageTitle = $_page->getTitle();
38
+ }else{
39
+ $_category = Mage::getModel('catalog/category')->load($background->getPageId());
40
+ $pageTitle = $_category->getName();
41
+ }
42
+ echo $pageTitle;
43
+ ?>
44
+ </td>
45
+ <td align="center">
46
+ <?php
47
+ if($background->getBgType()=="default"){
48
+ $pageType = "Default";
49
+ }elseif($background->getBgType()=="cms"){
50
+ $pageType = "CMS Page";
51
+ }else{
52
+ $pageType = "Category Page";
53
+ }
54
+
55
+ echo $pageType;
56
+ ?>
57
+ </td>
58
+ <td align="center">
59
+ <a href="javascript:void(0);" onclick="window.open('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$background->getImageUrl();?>','','width=600,height=400');"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$background->getImageUrl();?>" height="30" width="30" alt="<?php echo $pageTitle; ?>" border="0" style="border:none;" /></a>
60
+ </td>
61
+ <td align="center">
62
+ <?php echo $background->getSelector(); ?>
63
+ </td>
64
+ <td align="center">
65
+ <a href="<?php echo $this->getUrl("*/*/edit/id/{$background->getId()}"); ?>" title="<?php echo $this->__('Edit')?>"><?php echo $this->__('Edit')?></a>&nbsp;/&nbsp;<a onclick="deleteConfirm('Are you sure you want to do this?', '<?php echo $this->getUrl("*/*/delete/id/{$background->getId()}"); ?>')" href="javascript:void(0);<?php //echo $this->getUrl("*/*/delete/id/{$background->getId()}"); ?>" title="<?php echo $this->__('Delete')?>"><?php echo $this->__('Delete')?></a>
66
+ </td>
67
+ </tr>
68
+ <?php $i++; endforeach; ?>
69
+ <?php else: ?>
70
+ <tr class="<?php echo ($i%2==0)?"even":"odd"; ?>">
71
+ <td colspan="5" align="center">No background found.</td>
72
+ </tr>
73
+ <?php endif; ?>
74
+ </tbody>
75
+ </table>
76
+ </div>
77
+ <style type="text/css">
78
+ table tr td,
79
+ table tr th{
80
+ text-align:center;
81
+ vertical-align:middle;
82
+ }
83
+ </style>
app/design/adminhtml/default/default/template/background/myform.phtml DELETED
@@ -1,143 +0,0 @@
1
- <?php /*?><script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
2
- <script type="text/javascript">
3
- jQuery.noConflict();
4
- </script><?php */?>
5
- <div class="content-header">
6
- <table cellspacing="0" class="grid-header">
7
- <tr>
8
- <td><h3><?php echo $this->__('New Background')?></h3></td>
9
- <td class="a-right">
10
- <button onclick="location.href='<?php echo Mage::helper("adminhtml")->getUrl("background/adminhtml_myform/pagemanage");?>'" class="scalable back" type="button"><span>Back</span></button> <button onclick="editForm.submit()" class="scalable save" type="button"><span>Submit</span></button>
11
- </td>
12
- </tr>
13
- </table>
14
- </div>
15
- <div id="containment-wrapper" class="entry-edit">
16
- <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post')?>" enctype="multipart/form-data">
17
- <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
18
-
19
- <fieldset id="my-fieldset">
20
- <table cellspacing="0" class="form-list">
21
- <tr>
22
- <td class="label"><?php echo $this->__('Page Type')?> <span class="required">*</span></td>
23
- <td class="input-ele">
24
- <select name="bg_type" id="bg_type" class="required-entry" style="width:200px;" onchange="catgeturl(this.value);">
25
- <option value="">Select Page Type</option>
26
- <option value="cms">CMS Page</option>
27
- <option value="category">Category</option>
28
- </select>
29
- </td>
30
- </tr>
31
- <tr id="cms_page_list" style="display:none;">
32
- <td class="label"><?php echo $this->__('Page')?> <span class="required">*</span></td>
33
- <td class="input-ele">
34
- <?php $cms_pages = Mage::getModel('cms/page')->getCollection();
35
- $cms_pages->load();
36
- ?>
37
-
38
- <select name="page_id" id="page_id" style="width:200px;">
39
- <option value="">Select Page</option>
40
- <?php foreach($cms_pages as $_page): ?>
41
- <?php $data = $_page->getData();?>
42
- <option value="<?php echo $data['page_id'] ?>"><?php echo $data['title']; ?></option>
43
- <?php endforeach; ?>
44
- </select>
45
- </td>
46
- </tr>
47
-
48
- <tr id="category_list" style="display:none;">
49
- <td class="label"><?php echo $this->__('Category')?> <span class="required">*</span></td>
50
- <td class="input-ele">
51
- <select name="category_id" id="category_id" style="width:200px;">
52
- <option value="">Select Category</option>
53
- <?php foreach (Mage::app()->getWebsites() as $website):?>
54
- <optgroup label="<?php echo $website->getName(); ?>">
55
- <?php foreach ($website->getGroups() as $group):?>
56
- <?php $stores = $group->getStores(); ?>
57
- <optgroup label="<?php echo "&nbsp;&nbsp;".$group->getName(); ?>">
58
- <?php foreach ($stores as $store): ?>
59
- <optgroup label="<?php echo "&nbsp;&nbsp;&nbsp;&nbsp;".$store->getName(); ?>"></optgroup>
60
- <?php endforeach;?>
61
- <?php
62
- $root_categoryid=Mage::app()->getStore($store->getStoreId())->getRootCategoryId();
63
- $_categories = Mage::getModel('catalog/category')->load($root_categoryid);
64
- $_categories = $_categories->getChildrenCategories();
65
- if (count($_categories) > 0):
66
- ?>
67
- <?php foreach($_categories as $_category):?>
68
- <?php $_category = Mage::getModel('catalog/category')->load($_category->getId());?>
69
- <?php //print_r($_category->getData());exit; ?>
70
- <?php if($_category->getIsActive() && $_category->getName()!=""): ?>
71
- <option style="margin-left:25px;" value="<?php echo $_category->getId() ?>"><?php echo $_category->getName() ?></option>
72
- <?php $_subcategories = $_category->getChildrenCategories() ?>
73
- <?php if (count($_subcategories) > 0): ?>
74
- <?php foreach($_subcategories as $_subcategory): ?>
75
- <?php if($_subcategory->getIsActive() && $_subcategory->getName()!=""): ?>
76
- <option style="margin-left:35px;" value="<?php echo $_subcategory->getId() ?>"><?php echo $_subcategory->getName() ?></option>
77
- <?php $_subcategorylevel4 = Mage::getModel('catalog/category')->load($_subcategory->getId());?>
78
- <?php $_level4subcategories = $_subcategorylevel4->getChildrenCategories() ?>
79
- <?php if (count($_level4subcategories) > 0): ?>
80
- <?php foreach($_level4subcategories as $_level4subcategory): ?>
81
- <?php if($_level4subcategory->getIsActive() && $_level4subcategory->getName()!=""): ?>
82
- <option style="margin-left:45px;" value="<?php echo $_level4subcategory->getId() ?>"><?php echo $_level4subcategory->getName() ?></option>
83
- <?php endif; ?>
84
- <?php endforeach; ?>
85
- <?php endif; ?>
86
- <?php endif; ?>
87
- <?php endforeach; ?>
88
- <?php endif; ?>
89
- <?php endif; ?>
90
- <?php endforeach; ?>
91
- <?php endif; ?>
92
- </optgroup>
93
- <?php endforeach;?>
94
- </optgroup>
95
- <?php endforeach;?>
96
- </select>
97
- </td>
98
- </tr>
99
-
100
- <tr>
101
- <td class="label"><?php echo $this->__('Background Image')?> <span class="required">*</span></td>
102
- <td class="input-ele">
103
- <input type="file" name="image_url" id="image_url" class="required-entry" />
104
- </td>
105
- </tr>
106
-
107
- </table>
108
- </fieldset>
109
- </form>
110
- </div>
111
- <script type="text/javascript">
112
- function catgeturl(e){
113
- if(e=="cms"){
114
- jQuery("#cms_page_list").show();
115
- jQuery("#cms_page_list select").addClass("required-entry");
116
- jQuery("#category_list select").removeClass("required-entry");
117
- jQuery("#category_list select").val("");
118
- jQuery("#category_list").hide();
119
-
120
- }
121
- if(e=="category"){
122
- jQuery("#category_list").show();
123
- jQuery("#category_list select").addClass("required-entry");
124
- jQuery("#cms_page_list select").removeClass("required-entry");
125
- jQuery("#cms_page_list select").val("");
126
- jQuery("#cms_page_list").hide();
127
- }
128
- if(e==""){
129
- jQuery("#cms_page_list").hide();
130
- jQuery("#category_list").hide();
131
- jQuery("#category_list select").removeClass("required-entry");
132
- jQuery("#cms_page_list select").removeClass("required-entry");
133
- jQuery("#category_list select").val("");
134
- jQuery("#cms_page_list select").val("");
135
- }
136
- }
137
-
138
- jQuery(document).ready(function(){
139
-
140
- });
141
-
142
- var editForm = new varienForm('edit_form');
143
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/background/new.phtml ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3><?php echo $this->__('Add New %s', 'Background')?></h3></td>
5
+ <td class="a-right">
6
+ <button onclick="location.href='<?php echo Mage::helper("adminhtml")->getUrl("*/*");?>'" class="scalable back" type="button" title="<?php echo $this->__('Back')?>"><span><?php echo $this->__('Back')?></span></button>
7
+ <button onclick="editForm.submit()" class="scalable save" type="button"><span>Submit</span></button>
8
+ <button onclick="saveAndContinueEdit();" class="scalable save" type="button" title="<?php echo $this->__('Save and Continue Edit')?>"><span><span><span><?php echo $this->__('Save and Continue Edit')?></span></span></span></button>
9
+ </td>
10
+ </tr>
11
+ </table>
12
+ </div>
13
+ <div id="containment-wrapper" class="entry-edit">
14
+ <div class="entry-edit-head">
15
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Add New %s', 'Background')?></h4>
16
+ <div class="form-buttons"></div>
17
+ </div>
18
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/post')?>" enctype="multipart/form-data">
19
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
20
+
21
+ <fieldset class="fieldset-wide">
22
+ <table cellspacing="0" class="form-list">
23
+ <tr>
24
+ <td width="50%">
25
+ <table cellspacing="0" class="form-list">
26
+ <tr>
27
+ <td class="label"><?php echo $this->__('Page Type')?> <span class="required">*</span></td>
28
+ <td class="label value">
29
+ <select name="bg_type" id="bg_type" class="required-entry" onchange="catgeturl(this.value);">
30
+ <option value="">-- Select Page Type --</option>
31
+ <option value="default">Deafult</option>
32
+ <option value="cms">CMS Page</option>
33
+ <option value="category">Category</option>
34
+ </select>
35
+ </td>
36
+ </tr>
37
+ <tr id="cms_page_list" style="display:none;">
38
+ <td class="label"><?php echo $this->__('CMS Page')?> <span class="required">*</span></td>
39
+ <td class="label value">
40
+ <?php $cms_pages = Mage::getModel('cms/page')->getCollection();
41
+ $cms_pages->load();
42
+ ?>
43
+
44
+ <select name="page_id" id="page_id">
45
+ <option value="">-- Select CMS Page --</option>
46
+ <?php foreach($cms_pages as $_page): ?>
47
+ <?php $data = $_page->getData();?>
48
+ <option value="<?php echo $data['page_id'] ?>"><?php echo $data['title']; ?></option>
49
+ <?php endforeach; ?>
50
+ </select>
51
+ </td>
52
+ </tr>
53
+
54
+ <tr id="category_list" style="display:none;">
55
+ <td class="label"><?php echo $this->__('Category')?> <span class="required">*</span></td>
56
+ <td class="label value">
57
+ <select name="category_id" id="category_id">
58
+ <option value="">-- Select Category --</option>
59
+ <?php foreach (Mage::app()->getWebsites() as $website):?>
60
+ <optgroup label="<?php echo $website->getName(); ?>">
61
+ <?php foreach ($website->getGroups() as $group):?>
62
+ <?php $stores = $group->getStores(); ?>
63
+ <optgroup label="<?php echo "&nbsp;&nbsp;".$group->getName(); ?>">
64
+ <?php foreach ($stores as $store): ?>
65
+ <optgroup label="<?php echo "&nbsp;&nbsp;&nbsp;&nbsp;".$store->getName(); ?>"></optgroup>
66
+ <?php endforeach;?>
67
+ <?php
68
+ $root_categoryid=Mage::app()->getStore($store->getStoreId())->getRootCategoryId();
69
+ $_categories = Mage::getModel('catalog/category')->load($root_categoryid);
70
+ $_categories = $_categories->getChildrenCategories();
71
+ if (count($_categories) > 0):
72
+ ?>
73
+ <?php foreach($_categories as $_category):?>
74
+ <?php $_category = Mage::getModel('catalog/category')->load($_category->getId());?>
75
+ <?php //print_r($_category->getData());exit; ?>
76
+ <?php if($_category->getIsActive() && $_category->getName()!=""): ?>
77
+ <option style="margin-left:25px;" value="<?php echo $_category->getId() ?>"><?php echo $_category->getName() ?></option>
78
+ <?php $_subcategories = $_category->getChildrenCategories() ?>
79
+ <?php if (count($_subcategories) > 0): ?>
80
+ <?php foreach($_subcategories as $_subcategory): ?>
81
+ <?php if($_subcategory->getIsActive() && $_subcategory->getName()!=""): ?>
82
+ <option style="margin-left:35px;" value="<?php echo $_subcategory->getId() ?>"><?php echo $_subcategory->getName() ?></option>
83
+ <?php $_subcategorylevel4 = Mage::getModel('catalog/category')->load($_subcategory->getId());?>
84
+ <?php $_level4subcategories = $_subcategorylevel4->getChildrenCategories() ?>
85
+ <?php if (count($_level4subcategories) > 0): ?>
86
+ <?php foreach($_level4subcategories as $_level4subcategory): ?>
87
+ <?php if($_level4subcategory->getIsActive() && $_level4subcategory->getName()!=""): ?>
88
+ <option style="margin-left:45px;" value="<?php echo $_level4subcategory->getId() ?>"><?php echo $_level4subcategory->getName() ?></option>
89
+ <?php endif; ?>
90
+ <?php endforeach; ?>
91
+ <?php endif; ?>
92
+ <?php endif; ?>
93
+ <?php endforeach; ?>
94
+ <?php endif; ?>
95
+ <?php endif; ?>
96
+ <?php endforeach; ?>
97
+ <?php endif; ?>
98
+ </optgroup>
99
+ <?php endforeach;?>
100
+ </optgroup>
101
+ <?php endforeach;?>
102
+ </select>
103
+ </td>
104
+ </tr>
105
+
106
+ <tr>
107
+ <td class="label"><?php echo $this->__('Background Image')?> <span class="required">*</span></td>
108
+ <td class="label value">
109
+ <input type="file" name="image_url" id="image_url" class="required-entry" />
110
+ </td>
111
+ </tr>
112
+ <tr>
113
+ <td class="label"><?php echo $this->__('Background Selector')?> <span class="required">*</span></td>
114
+ <td class="label value">
115
+ <select name="selector" id="selector" class="required-entry" onchange="customSelector(this.value);">
116
+ <option value="">-- Select Selector --</option>
117
+ <option value="body">Body</option>
118
+ <option value="custom">Custom</option>
119
+ </select>
120
+ </td>
121
+ </tr>
122
+ <tr id="custom_selector_block" style="display:none;">
123
+ <td class="label"><?php echo $this->__('Custom Selector')?> <span class="required">*</span></td>
124
+ <td class="label value">
125
+ <input name="custom_selector" id="custom_selector" type="text" class="input-text" style="width: 274px ! important;" />
126
+ <p id="note_identifier" class="note"><span>Use CSS selector ie: class(.class-name) / id(#id) / others selector. For multi selector use , seperator like ".selector1, .selector2"</span></p>
127
+ </td>
128
+ </tr>
129
+ <tr>
130
+ <td class="label"><?php echo $this->__('Background Repeat')?> <span class="required">*</span></td>
131
+ <td class="label value">
132
+ <?php $backgroundRepeats = array("repeat","repeat-x", "repeat-y", "no-repeat", "initial", "inherit"); ?>
133
+ <select name="repeat" id="repeat" class="required-entry">
134
+ <option value="">-- Select Repeat --</option>
135
+ <?php foreach($backgroundRepeats as $repeat):?>
136
+ <option value="<?php echo $repeat; ?>"><?php echo $repeat; ?></option>
137
+ <?php endforeach; ?>
138
+ </select>
139
+ </td>
140
+ </tr>
141
+ <tr>
142
+ <td class="label"><?php echo $this->__('Background Position')?> <span class="required">*</span></td>
143
+ <td class="label value">
144
+ <?php $backgroundPositions = array("left top","left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom", "initial", "inherit"); ?>
145
+ <select name="position" id="position" class="required-entry">
146
+ <option value="">-- Select Position --</option>
147
+ <?php foreach($backgroundPositions as $position):?>
148
+ <option value="<?php echo $position; ?>"><?php echo $position; ?></option>
149
+ <?php endforeach; ?>
150
+ </select>
151
+ </td>
152
+ </tr>
153
+ <tr>
154
+ <td class="label"><?php echo $this->__('Background Attachment')?></td>
155
+ <td class="label value">
156
+ <?php $backgroundAttachments = array("scroll","fixed", "local", "initial", "inherit"); ?>
157
+ <select name="attachment" id="attachment" class="required-entry">
158
+ <?php foreach($backgroundAttachments as $attachment):?>
159
+ <option value="<?php echo $attachment; ?>"<?php echo ($attachment=="scroll")?' selected="selected"':'';?>><?php echo $attachment; ?></option>
160
+ <?php endforeach; ?>
161
+ </select>
162
+ </td>
163
+ </tr>
164
+ <tr>
165
+ <td class="label"><?php echo $this->__('Background Color')?></td>
166
+ <td class="label value">
167
+ <input name="color" id="color" type="text" class="color input-text required-entry" style="width: 274px ! important;" />
168
+ <p id="note_identifier" class="note"><span>Please pick your preferred color.</span></p>
169
+ </td>
170
+ </tr>
171
+ <tr>
172
+ <td class="label"><?php echo $this->__('Background Size')?></td>
173
+ <td class="label value">
174
+ <?php $backgroundSizes = array("auto","cover", "contain", "initial", "inherit"); ?>
175
+ <?php $defaultVal = "initial"; ?>
176
+ <select name="size" id="size" class="required-entry">
177
+ <?php foreach($backgroundSizes as $size):?>
178
+ <option value="<?php echo $size; ?>"<?php echo ($size==$defaultVal)?' selected="selected"':'';?>><?php echo $size; ?></option>
179
+ <?php endforeach; ?>
180
+ </select>
181
+ </td>
182
+ </tr>
183
+ <tr>
184
+ <td class="label"><?php echo $this->__('Background Origin')?></td>
185
+ <td class="label value">
186
+ <?php $backgroundOrigins = array("padding-box","border-box", "content-box", "initial", "inherit"); ?>
187
+ <select name="origin" id="origin" class="required-entry">
188
+ <?php foreach($backgroundOrigins as $origin):?>
189
+ <option value="<?php echo $origin; ?>"<?php echo ($origin==$defaultVal)?' selected="selected"':'';?>><?php echo $origin; ?></option>
190
+ <?php endforeach; ?>
191
+ </select>
192
+ </td>
193
+ </tr>
194
+ <tr>
195
+ <td class="label"><?php echo $this->__('Background Clip')?></td>
196
+ <td class="label value">
197
+ <?php $backgroundClips = array("padding-box","border-box", "content-box", "initial", "inherit"); ?>
198
+ <select name="clip" id="clip" class="required-entry">
199
+ <?php foreach($backgroundClips as $clip):?>
200
+ <option value="<?php echo $clip; ?>"<?php echo ($clip==$defaultVal)?' selected="selected"':'';?>><?php echo $clip; ?></option>
201
+ <?php endforeach; ?>
202
+ </select>
203
+ </td>
204
+ </tr>
205
+ </table>
206
+ </td>
207
+ <td width="50%" class="a-center v-middle">
208
+ <a target="_blank" href="http://www.cybernetikz.com/store/magento-extension.html">
209
+ <img src="http://cybernetikz.com/images/cybernetikz-magento-extensions.jpg" align="Cybernetikz Magento Extensions" />
210
+ </a>
211
+ </td>
212
+ </tr>
213
+ </table>
214
+ </fieldset>
215
+ </form>
216
+ </div>
217
+ <script type="text/javascript">
218
+ function catgeturl(e){
219
+ if(e=="cms"){
220
+ jQuery("#cms_page_list").show();
221
+ jQuery("#cms_page_list select").addClass("required-entry");
222
+ jQuery("#category_list select").removeClass("required-entry");
223
+ jQuery("#category_list select").val("");
224
+ jQuery("#category_list").hide();
225
+
226
+ }
227
+ if(e=="category"){
228
+ jQuery("#category_list").show();
229
+ jQuery("#category_list select").addClass("required-entry");
230
+ jQuery("#cms_page_list select").removeClass("required-entry");
231
+ jQuery("#cms_page_list select").val("");
232
+ jQuery("#cms_page_list").hide();
233
+ }
234
+ if(e=="" || e=="default"){
235
+ jQuery("#cms_page_list").hide();
236
+ jQuery("#category_list").hide();
237
+ jQuery("#category_list select").removeClass("required-entry");
238
+ jQuery("#cms_page_list select").removeClass("required-entry");
239
+ jQuery("#category_list select").val("");
240
+ jQuery("#cms_page_list select").val("");
241
+ }
242
+ }
243
+
244
+ // Custom Selector
245
+ function customSelector(e){
246
+ if(e=="custom"){
247
+ jQuery("#custom_selector_block").show();
248
+ jQuery("#custom_selector_block input#custom_selector").addClass("required-entry");
249
+
250
+ }else{
251
+ jQuery("#custom_selector_block").hide();
252
+ jQuery("#custom_selector_block input#custom_selector").removeClass("required-entry");
253
+ jQuery("#custom_selector_block input#custom_selector").val("");
254
+ }
255
+ }
256
+
257
+ // Form Validation
258
+ var editForm = new varienForm('edit_form');
259
+
260
+ function saveAndContinueEdit(){
261
+ editForm.submit($('edit_form').action+'back/edit/');
262
+ }
263
+ </script>
app/design/adminhtml/default/default/template/background/pagemanage.phtml DELETED
@@ -1,66 +0,0 @@
1
- <div class="content-header">
2
- <table cellspacing="0" class="grid-header">
3
- <tr>
4
- <td><h3><?php echo $this->__('Manage Background')?></h3></td>
5
- <td class="a-right">
6
- <button onclick="javascript:location.href='<?php echo $this->getUrl("background/adminhtml_myform/index"); ?>'" class="scalable save" type="button"><span>Add New Background</span></button>
7
- </td>
8
- </tr>
9
- </table>
10
- </div>
11
- <div class="entry-edit grid">
12
- <?php
13
- $totalbackground = Mage::getModel('background/background')->getCollection()->getItems();
14
-
15
- ?>
16
- <table cellspacing="0" id="cmsPageGrid_table" class="data" width="100%">
17
- <thead>
18
- <tr class="headings">
19
- <th width="35%" align="center"><?php echo $this->__('Page Title'); ?></th>
20
- <th width="20%" align="center"><?php echo $this->__('Page Type'); ?></th>
21
- <th width="20%" align="center" class=" no-link last"><span class="nobr"><?php echo $this->__('Action'); ?></span></th>
22
- </tr>
23
- </thead>
24
-
25
- <tbody id="">
26
- <?php if(count($totalbackground)>=1): ?>
27
- <?php $i=0; foreach($totalbackground as $i=>$page): ?>
28
- <tr class="<?php echo ($i%2==0)?"even":"odd"; ?>">
29
- <td align="center">
30
- <?php
31
- if($page->getBgType()=="cms"){
32
- $_page = Mage::getModel('cms/page')->load($page->getPageId());
33
- echo $_page->getTitle();
34
- }else{
35
- $_category = Mage::getModel('catalog/category')->load($page->getPageId());
36
- echo $_category->getName();
37
- }
38
- ?>
39
- </td>
40
- <td align="center">
41
- <?php
42
- if($page->getBgType()=="cms"){
43
- echo "CMS Page";
44
- }else{
45
- echo "Category Page";
46
- }
47
- ?>
48
- </td>
49
- <td align="center">
50
- <a href="<?php echo $this->getUrl("*/*/editpage/id/{$page->getId()}"); ?>" title="Edit">Edit</a>&nbsp;/&nbsp;<a href="<?php echo $this->getUrl("*/*/delete/id/{$page->getId()}"); ?>" title="Delete">Delete</a>
51
- </td>
52
- </tr>
53
- <?php $i++; endforeach; ?>
54
- <?php else: ?>
55
- <tr class="<?php echo ($i%2==0)?"even":"odd"; ?>">
56
- <td colspan="3" align="center">No background found.</td>
57
- </tr>
58
- <?php endif; ?>
59
- </tbody>
60
- </table>
61
- </div>
62
- <style type="text/css">
63
- table tr td,table tr th{
64
- text-align:center;
65
- }
66
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/background/background.phtml CHANGED
@@ -1,14 +1,23 @@
1
- <?php
2
- $_backgroundCollection=$this->getBackgroundCollection()->getData();
3
- $background=false;
4
- $count=count($_backgroundCollection);
5
- if($count>0){
6
- $background=true;
7
- }
8
  ?>
9
-
10
- <?php if($background===true):?>
11
  <style type="text/css">
12
- body{background:#000 url(<?php echo $this->getImageUrl($_backgroundCollection[0]['image_url']); ?>) repeat top center fixed !important;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  </style>
14
  <?php endif;?>
1
+ <?php
2
+ $_backgroundCollections = $this->getBackgroundCollection();
 
 
 
 
 
3
  ?>
4
+ <?php if($_backgroundCollections->count()>0):?>
 
5
  <style type="text/css">
6
+ <?php foreach($_backgroundCollections as $_background):?>
7
+ <?php
8
+ // If selector NULL, set default 'body' as selector
9
+ if(!$_background->getSelector()){ $_background->setSelector('body'); }
10
+ ?>
11
+ <?php echo $_background->getSelector();?>{
12
+ background-image: url("<?php echo $this->getImageFullUrl($_background->getImageUrl()); ?>") !important;
13
+ background-color: <?php echo $_background->getColor();?> !important;
14
+ background-repeat: <?php echo $_background->getRepeat();?> !important;
15
+ background-position: <?php echo $_background->getPosition();?> !important;
16
+ background-attachment: <?php echo $_background->getAttachment();?> !important;
17
+ background-size: <?php echo $_background->getSize();?> !important;
18
+ background-origin: <?php echo $_background->getOrigin();?> !important;
19
+ background-clip: <?php echo $_background->getClip();?> !important;
20
+ }
21
+ <?php endforeach; ?>
22
  </style>
23
  <?php endif;?>
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cybernetikz_Background</name>
4
- <version>0.3.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Upload Unique Background Image for Each CMS &amp; Category Page. Product page will use Category Background Image.</summary>
10
  <description>Background Uploader Magento Extension is made for Store CMS and Category Page Background Image Change. Admin will able to easily change background image for CMS page and Category Page. Admin can upload unique background image. Product page will use there category Background Image.</description>
11
- <notes>Category pages issue fix. Multiple store category support.</notes>
 
12
  <authors><author><name>CyberNetikz</name><user>CyberNetikz</user><email>admin@cybernetikz.com</email></author></authors>
13
- <date>2014-01-16</date>
14
- <time>09:02:17</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Cybernetikz_Background.xml" hash="62fbb8010ada4e672b36101145c5dc5a"/></dir></target><target name="magelocal"><dir name="Cybernetikz"><dir name="Background"><dir name="Block"><file name="Background.php" hash="88a1bc1b72ecc0202444d8d59a162ea4"/></dir><dir name="Helper"><file name="Data.php" hash="ed004387bb74393082e11af95378ab0f"/></dir><dir name="Model"><file name="Background.php" hash="f6fa810151c1d5eccbfaec96f25930d1"/><dir name="Mysql4"><dir name="Background"><file name="Collection.php" hash="2cc15973dcc9aae2339fcd0f3fe5740d"/></dir><file name="Background.php" hash="2659a9da799392f8b96fa8d90440837c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="MyformController.php" hash="3f899c2edab3ef733a171c2766c1ba33"/></dir></dir><dir name="etc"><file name="config.xml" hash="b17da603408dad80c41b4ad318e17220"/></dir><dir name="sql"><dir name="background_setup"><file name="mysql4-install-0.1.0.php" hash="f1342309acacfa446aa81994a2da937e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="background"><file name="editpage.phtml" hash="11e9cf90080dd0852a81c88560a4ec7e"/><file name="myform.phtml" hash="018a636edcd9cfc9f8f8f2065d660317"/><file name="pagemanage.phtml" hash="f79624239b04492ba8c920e9e42ca831"/></dir></dir><dir name="layout"><file name="background.xml" hash="c70a1011f416d7bb86e90ae1d1f427cf"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="background.xml" hash="c2df88e1cab087ed24f380be120592a2"/></dir><dir name="template"><dir name="background"><file name="background.phtml" hash="75023dd005b84d8e58ea4834fbd3c4e5"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="backgroundjs"><file name="jquery-1.10.1.min.js" hash="94ee4d9e6232eda246263c50b469ab4a"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cybernetikz_Background</name>
4
+ <version>0.4.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Upload Unique Background Image for Each CMS &amp; Category Page. Product page will use Category Background Image.</summary>
10
  <description>Background Uploader Magento Extension is made for Store CMS and Category Page Background Image Change. Admin will able to easily change background image for CMS page and Category Page. Admin can upload unique background image. Product page will use there category Background Image.</description>
11
+ <notes>- Fully customized background feature are added&#xD;
12
+ - Small bugs are fixed</notes>
13
  <authors><author><name>CyberNetikz</name><user>CyberNetikz</user><email>admin@cybernetikz.com</email></author></authors>
14
+ <date>2015-07-15</date>
15
+ <time>06:16:50</time>
16
+ <contents><target name="mageetc"><dir name="modules"><file name="Cybernetikz_Background.xml" hash="62fbb8010ada4e672b36101145c5dc5a"/></dir></target><target name="magelocal"><dir name="Cybernetikz"><dir name="Background"><dir name="Block"><file name="Background.php" hash="0aea03b0b38ecf31d610f71328f0e4c3"/></dir><dir name="Helper"><file name="Data.php" hash="ed004387bb74393082e11af95378ab0f"/></dir><dir name="Model"><file name="Background.php" hash="f6fa810151c1d5eccbfaec96f25930d1"/><dir name="Mysql4"><dir name="Background"><file name="Collection.php" hash="2cc15973dcc9aae2339fcd0f3fe5740d"/></dir><file name="Background.php" hash="2659a9da799392f8b96fa8d90440837c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BackgroundController.php" hash="91bfd3d9c7e5a43653f4abbe64e2c303"/></dir></dir><dir name="etc"><file name="config.xml" hash="722379cc1b95361c9b15de9e5e888021"/></dir><dir name="sql"><dir name="background_setup"><file name="mysql4-install-0.1.0.php" hash="b887593bb3c2befd1505e424814259b8"/><file name="mysql4-upgrade-0.3.0-0.4.0.php" hash="e79a91e21d6502e1d765b2fe67741d92"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="background"><file name="edit.phtml" hash="4926d2872518562a6e047f13c9d2013f"/><file name="grid.phtml" hash="a68fc9fbaab31c0e4c8ec2f5d37ad2dd"/><file name="new.phtml" hash="cfcfc27bad59b7d41f0a001e89efb3f2"/></dir></dir><dir name="layout"><file name="background.xml" hash="69d302cfd97e38315b76c058db238eeb"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="background.xml" hash="c2df88e1cab087ed24f380be120592a2"/></dir><dir name="template"><dir name="background"><file name="background.phtml" hash="ddac4e7f0fe4ef28720d83e4d544c1b9"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="backgroundjs"><file name="jquery-1.10.1.min.js" hash="94ee4d9e6232eda246263c50b469ab4a"/></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>