LMD_subscription_popup_constructor - Version 0.1.0

Version Notes

If you find any bugs, please report us!

Download this release

Release Info

Developer LMD Agency
Extension LMD_subscription_popup_constructor
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (21) hide show
  1. app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Form/Edit/Form.php +192 -0
  2. app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Form/Formcontainer.php +52 -0
  3. app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Grid/Grid.php +104 -0
  4. app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Grid/Gridcontainer.php +38 -0
  5. app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Grid/Renderer/Active.php +35 -0
  6. app/code/local/LMD/EasyPromoLightBox/Block/Frontend/Lightbox.php +36 -0
  7. app/code/local/LMD/EasyPromoLightBox/Helper/Data.php +23 -0
  8. app/code/local/LMD/EasyPromoLightBox/Model/Lightbox.php +26 -0
  9. app/code/local/LMD/EasyPromoLightBox/Model/Mysql4/Lightbox.php +27 -0
  10. app/code/local/LMD/EasyPromoLightBox/Model/Mysql4/Lightbox/Collection.php +26 -0
  11. app/code/local/LMD/EasyPromoLightBox/controllers/Adminhtml/LightboxController.php +181 -0
  12. app/code/local/LMD/EasyPromoLightBox/controllers/LightboxController.php +98 -0
  13. app/code/local/LMD/EasyPromoLightBox/etc/adminhtml.xml +15 -0
  14. app/code/local/LMD/EasyPromoLightBox/etc/config.xml +79 -0
  15. app/code/local/LMD/EasyPromoLightBox/sql/lmd_easypromolightbox_setup/install-0.1.0.php +51 -0
  16. app/design/adminhtml/default/default/layout/lmd_easypromolightbox.xml +16 -0
  17. app/design/frontend/base/default/layout/lmd_easypromolightbox.xml +37 -0
  18. app/design/frontend/base/default/template/lmd_easypromolightbox/index.phtml +166 -0
  19. app/etc/modules/LMD_EasyPromoLightBox.xml +9 -0
  20. package.xml +18 -0
  21. skin/frontend/base/default/css/lmd_easypromolightbox.css +41 -0
app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Form/Edit/Form.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: dev
6
+ * Date: 24.07.14
7
+ * Time: 15:17
8
+ */
9
+ class LMD_EasyPromoLightBox_Block_Adminhtml_Form_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+
14
+ if (Mage::registry('lmd_easypromolightbox')) {
15
+ $data = Mage::registry('lmd_easypromolightbox')->getData();
16
+ }
17
+
18
+ $form = new Varien_Data_Form(array(
19
+ 'id' => 'edit_form',
20
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
21
+ 'method' => 'post',
22
+ 'enctype' => 'multipart/form-data',
23
+ ));
24
+
25
+ $form->setUseContainer(true);
26
+
27
+ $this->setForm($form);
28
+
29
+ $fieldset = $form->addFieldset('lightbox_form', array(
30
+ 'legend' => Mage::helper('adminhtml')->__('Notification Edit')
31
+ ));
32
+
33
+ $fieldset->addField('notification_name', 'text', array(
34
+ 'label' => Mage::helper('adminhtml')->__('Name'),
35
+ 'class' => 'required-entry',
36
+ 'required' => true,
37
+ 'name' => 'notification_name',
38
+ 'note' => Mage::helper('adminhtml')->__('The name of lightbox. Will not be shown on frontend.'),
39
+ ));
40
+
41
+ $fieldset->addField('is_active', 'select', array(
42
+ 'options' => array('1' => 'Yes',
43
+ '0' => 'No'),
44
+ 'label' => Mage::helper('adminhtml')->__('Active'),
45
+ 'class' => 'required-entry',
46
+ 'required' => true,
47
+ 'name' => 'is_active',
48
+ ));
49
+
50
+ $fieldset->addField('title_text', 'text', array(
51
+ 'label' => Mage::helper('adminhtml')->__('Title text'),
52
+ 'class' => 'required-entry',
53
+ 'required' => true,
54
+ 'name' => 'title_text',
55
+ 'note' => Mage::helper('adminhtml')->__('Notification title.'),
56
+ ));
57
+
58
+ $fieldset->addField('title_text_color', 'text', array(
59
+ 'label' => Mage::helper('adminhtml')->__('Title text color'),
60
+ 'class' => 'required-entry color',
61
+ 'required' => true,
62
+ 'name' => 'title_text_color',
63
+ 'note' => Mage::helper('adminhtml')->__('HEX color code here.'),
64
+ ));
65
+
66
+ $fieldset->addField('notification_text', 'text', array(
67
+ 'label' => Mage::helper('adminhtml')->__('Notification text'),
68
+ 'class' => 'required-entry',
69
+ 'required' => true,
70
+ 'name' => 'notification_text',
71
+ 'note' => Mage::helper('adminhtml')->__('Notification text.'),
72
+ ));
73
+
74
+ $fieldset->addField('notification_text_color', 'text', array(
75
+ 'label' => Mage::helper('adminhtml')->__('Notification text color'),
76
+ 'class' => 'required-entry color',
77
+ 'required' => true,
78
+ 'name' => 'notification_text_color',
79
+ 'note' => Mage::helper('adminhtml')->__('HEX color code here.'),
80
+ ));
81
+
82
+ $fieldset->addField('body_type', 'select', array(
83
+ 'options' => array('1' => 'Color',
84
+ '0' => 'Picture'),
85
+ 'label' => Mage::helper('adminhtml')->__('Background type'),
86
+ 'class' => 'required-entry',
87
+ 'required' => true,
88
+ 'name' => 'body_type',
89
+ 'onchange' => 'showhide(this)',
90
+ 'note' => Mage::helper('adminhtml')->__('Select type of background.'),
91
+ ));
92
+
93
+ $fieldset->addField('body_color', 'text', array(
94
+ 'label' => Mage::helper('adminhtml')->__('Background color'),
95
+ 'required' => false,
96
+ 'class' => 'color, required-entry',
97
+ 'name' => 'body_color',
98
+ 'note' => Mage::helper('adminhtml')->__('HEX color code here.'),
99
+ ));
100
+
101
+ if ($data['body_type'] == 0 || !$data) {
102
+ $fieldset->addField('body_picture', 'image', array(
103
+ 'label' => Mage::helper('adminhtml')->__('Background picture'),
104
+ 'required' => false,
105
+ 'class' => 'color, required-entry',
106
+ 'name' => 'body_picture',
107
+ 'note' => Mage::helper('adminhtml')->__('Upload Your picture. NOTE: cyrillic names not allowed!'),
108
+ 'after_element_html' => "<script type=\"text/javascript\">
109
+ $('body_color').up(1).setStyle({display: 'none'});
110
+ </script>"
111
+ ));
112
+ } else {
113
+ $fieldset->addField('body_picture', 'image', array(
114
+ 'label' => Mage::helper('adminhtml')->__('Background picture'),
115
+ 'required' => false,
116
+ 'name' => 'body_picture',
117
+ 'note' => Mage::helper('adminhtml')->__('Upload Your picture. NOTE: cyrillic names not allowed!'),
118
+ 'after_element_html' => "<script type=\"text/javascript\">
119
+ $('body_picture').up(1).setStyle({display: 'none'});
120
+ </script>"
121
+ ));
122
+ }
123
+
124
+ $fieldset->addField('button_text', 'text', array(
125
+ 'label' => Mage::helper('adminhtml')->__('Button text'),
126
+ 'class' => 'required-entry',
127
+ 'required' => true,
128
+ 'name' => 'button_text',
129
+ 'note' => Mage::helper('adminhtml')->__('Text on button.'),
130
+ ));
131
+
132
+ $fieldset->addField('button_color', 'text', array(
133
+ 'label' => Mage::helper('adminhtml')->__('Button color'),
134
+ 'class' => 'required-entry color',
135
+ 'required' => true,
136
+ 'name' => 'button_color',
137
+ 'note' => Mage::helper('adminhtml')->__('HEX color code here.'),
138
+ ));
139
+
140
+ $fieldset->addField('notification_height', 'text', array(
141
+ 'label' => Mage::helper('adminhtml')->__('Notification height'),
142
+ 'class' => 'required-entry validate-digits',
143
+ 'required' => true,
144
+ 'name' => 'notification_height',
145
+ 'note' => Mage::helper('adminhtml')->__('In pixels.'),
146
+ ));
147
+
148
+ $fieldset->addField('notification_width', 'text', array(
149
+ 'label' => Mage::helper('adminhtml')->__('Notification width'),
150
+ 'class' => 'required-entry validate-digits',
151
+ 'required' => true,
152
+ 'name' => 'notification_width',
153
+ 'note' => Mage::helper('adminhtml')->__('In pixels.'),
154
+ ));
155
+
156
+ $fieldset->addField('cookies_lifetime', 'text', array(
157
+ 'label' => Mage::helper('adminhtml')->__('Cookies lifetime'),
158
+ 'class' => 'required-entry validate-digits',
159
+ 'required' => true,
160
+ 'name' => 'cookies_lifetime',
161
+ 'note' => Mage::helper('adminhtml')->__('In days.'),
162
+ ));
163
+
164
+ $fieldset->addField('time_to_show', 'text', array(
165
+ 'label' => Mage::helper('adminhtml')->__('Time before lightbox will shown'),
166
+ 'class' => 'required-entry validate-digits',
167
+ 'required' => true,
168
+ 'name' => 'time_to_show',
169
+ 'after_element_html' => "<script type=\"text/javascript\">
170
+ function showhide(a) {
171
+ var label = a.value;
172
+ if (label==1) {
173
+ $('body_color').up(1).setStyle({display: 'table-row'});
174
+ $('body_color').addClassName('required-entry');
175
+ $('body_picture').up(1).setStyle({display: 'none'});
176
+ $('body_picture').removeClassName('required-entry');
177
+ } else if (label==0) {
178
+ $('body_color').up(1).setStyle({display: 'none'});
179
+ $('body_color').removeClassName('required-entry');
180
+ $('body_picture').up(1).setStyle({display: 'table-row'});
181
+ $('body_picture').addClassName('required-entry');
182
+ }
183
+ }
184
+ </script>",
185
+ 'note' => Mage::helper('adminhtml')->__('In seconds.'),
186
+ ));
187
+
188
+ $form->setValues($data);
189
+
190
+ return parent::_prepareForm();
191
+ }
192
+ }
app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Form/Formcontainer.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Block_Adminhtml_Form_Formcontainer extends Mage_Adminhtml_Block_Widget_Form_Container
22
+ {
23
+ public function __construct()
24
+ {
25
+ $this->_blockGroup = 'lmd_easypromolightbox';
26
+ $this->_controller = 'adminhtml_form';
27
+ $this->_mode = 'edit';
28
+
29
+ parent::__construct();
30
+ }
31
+
32
+ protected function _prepareLayout()
33
+ {
34
+ if ($this->_blockGroup && $this->_controller)
35
+ {
36
+ $this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'));
37
+ }
38
+ return parent::_prepareLayout();
39
+ }
40
+
41
+ public function getHeaderText()
42
+ {
43
+ if (Mage::registry('lmd_easypromolightbox')->getId())
44
+ {
45
+ return $this->__('Edit Lightbox');
46
+ }
47
+ else
48
+ {
49
+ return $this->__('New Lightbox');
50
+ }
51
+ }
52
+ }
app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Grid/Grid.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Block_Adminhtml_Grid_Grid extends Mage_Adminhtml_Block_Widget_Grid
22
+ {
23
+
24
+ /**
25
+ * Set some default on the grid
26
+ */
27
+ public function __construct()
28
+ {
29
+ $this->setId('notification_grid');
30
+
31
+ //The 'id' matches the columnId
32
+ $this->setDefaultSort('entity_id');
33
+ $this->setDefaultDir('asc');
34
+ $this->setSaveParametersInSession(true);
35
+
36
+ parent::__construct();
37
+ }
38
+ /**
39
+ * Set the desired collection on our grid
40
+ * @return Mage_Adminhtml_Block_Widget_Grid
41
+ */
42
+ protected function _prepareCollection()
43
+ {
44
+ $collection = Mage::getModel('lmd_easypromolightbox/lightbox')->getCollection();
45
+ $this->setCollection($collection);
46
+ return parent::_prepareCollection();
47
+ }
48
+
49
+ /**
50
+ * @return Mage_Adminhtml_Block_Widget_Grid
51
+ */
52
+ protected function _prepareColumns()
53
+ {
54
+ $this->addColumn('id', array(
55
+ 'header' => Mage::helper('adminhtml')->__('ID'),
56
+ 'align' => 'center',
57
+ 'width' => '50px',
58
+ //must match the column
59
+ 'index' => 'entity_id',
60
+ ));
61
+
62
+ $this->addColumn('active', array(
63
+ 'header' => Mage::helper('adminhtml')->__('Active'),
64
+ 'align' => 'center',
65
+ 'width' => '50px',
66
+ //must match the column
67
+ 'index' => 'is_active',
68
+ 'renderer' => 'lmd_easypromolightbox/adminhtml_grid_renderer_active',
69
+ ));
70
+ $this->addColumn('Name', array(
71
+ 'header' => Mage::helper('adminhtml')->__('Name'),
72
+ 'align' => 'left',
73
+ //must match the column
74
+ 'index' => 'notification_name',
75
+ ));
76
+ $this->addColumn('Title', array(
77
+ 'header' => Mage::helper('adminhtml')->__('Title'),
78
+ 'align' => 'left',
79
+ //must match the column
80
+ 'index' => 'title_text',
81
+ ));
82
+ $this->addColumn('Updated', array(
83
+ 'header' => Mage::helper('adminhtml')->__('Last updated'),
84
+ 'align' => 'left',
85
+ 'width' => '140px',
86
+ //must match the column
87
+ 'index' => 'edit_date',
88
+ ));
89
+ $this->addColumn('Created', array(
90
+ 'header' => Mage::helper('adminhtml')->__('Created'),
91
+ 'align' => 'left',
92
+ 'width' => '140px',
93
+ //must match the column
94
+ 'index' => 'creation_date',
95
+ ));
96
+
97
+ return parent::_prepareColumns();
98
+ }
99
+
100
+ public function getRowUrl($row)
101
+ {
102
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
103
+ }
104
+ }
app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Grid/Gridcontainer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Block_Adminhtml_Grid_Gridcontainer extends Mage_Adminhtml_Block_Widget_Grid_Container
22
+ {
23
+ protected $_addButtonLabel = 'Add new Lightbox';
24
+
25
+ /**
26
+ * Set the desired collection on our grid
27
+ * Mage_Adminhtml_Block_Widget_Grid_Container
28
+ */
29
+ public function __construct()
30
+ {
31
+ $this->_headerText = 'Lightbox Manager';
32
+
33
+ $this->_controller = 'adminhtml_grid';
34
+ $this->_blockGroup = 'lmd_easypromolightbox';
35
+
36
+ parent::__construct();
37
+ }
38
+ }
app/code/local/LMD/EasyPromoLightBox/Block/Adminhtml/Grid/Renderer/Active.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Block_Adminhtml_Grid_Renderer_Active extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
22
+ {
23
+ public function render(Varien_Object $row)
24
+ {
25
+ switch ($row->getIsActive()){
26
+ case 0:
27
+ $result = 'No';
28
+ return $result;
29
+ case 1:
30
+ $result = 'Yes';
31
+ return $result;
32
+ }
33
+ return NULL;
34
+ }
35
+ }
app/code/local/LMD/EasyPromoLightBox/Block/Frontend/Lightbox.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Block_Frontend_Lightbox extends Mage_Core_Block_Template
22
+ {
23
+ /**
24
+ * Set the desired array of lightboxes sorted by date of last update
25
+ */
26
+ public function getLigthboxInfo()
27
+ {
28
+ $lightbox = Mage::getModel('lmd_easypromolightbox/lightbox')
29
+ ->getCollection()
30
+ ->addFieldToFilter('is_active', 1)
31
+ ->setOrder('edit_date')
32
+ ->getData();
33
+
34
+ return $lightbox;
35
+ }
36
+ }
app/code/local/LMD/EasyPromoLightBox/Helper/Data.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Helper_Data extends Mage_Core_Helper_Abstract {
22
+
23
+ }
app/code/local/LMD/EasyPromoLightBox/Model/Lightbox.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Model_Lightbox extends Mage_Core_Model_Abstract{
22
+
23
+ protected function _construct(){
24
+ $this->_init('lmd_easypromolightbox/lightbox');
25
+ }
26
+ }
app/code/local/LMD/EasyPromoLightBox/Model/Mysql4/Lightbox.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Model_Mysql4_Lightbox extends Mage_Core_Model_Mysql4_Abstract{
22
+
23
+ protected function _construct(){
24
+
25
+ $this->_init('lmd_easypromolightbox/lmd_easypromolightbox','entity_id');
26
+ }
27
+ }
app/code/local/LMD/EasyPromoLightBox/Model/Mysql4/Lightbox/Collection.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_Model_Mysql4_Lightbox_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
22
+
23
+ protected function _construct(){
24
+ $this->_init('lmd_easypromolightbox/lightbox');
25
+ }
26
+ }
app/code/local/LMD/EasyPromoLightBox/controllers/Adminhtml/LightboxController.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copyright (C) 2015 LMD Agency (alex)
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
20
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
21
+ */
22
+ class LMD_EasyPromoLightBox_Adminhtml_LightboxController extends Mage_Adminhtml_Controller_Action
23
+ {
24
+ public function indexAction()
25
+ {
26
+ $this->loadLayout()
27
+ ->_setActiveMenu('lmd_easypromolightbox');
28
+ $this->renderLayout();
29
+ }
30
+
31
+ public function newAction()
32
+ {
33
+ $this->_forward('edit');
34
+ }
35
+
36
+ public function editAction()
37
+ {
38
+ $this->_initAction();
39
+
40
+ // Get id if available
41
+ $id = $this->getRequest()->getParam('id');
42
+ $model = Mage::getModel('lmd_easypromolightbox/lightbox');
43
+
44
+ if ($id) {
45
+ // Load record
46
+ $model->load($id);
47
+
48
+ // Check if record is loaded
49
+ if (!$model->getId()) {
50
+ Mage::getSingleton('adminhtml/session')->addError($this->__('This notification no longer exists.'));
51
+ $this->_redirect('*/*/');
52
+
53
+ return;
54
+ }
55
+ }
56
+
57
+ $this->_title($model->getId() ? $model->getName() : $this->__('New Notification'));
58
+
59
+ Mage::register('lmd_easypromolightbox', $model);
60
+
61
+ $this->_initAction()
62
+ ->_addContent($this->getLayout()->createBlock('lmd_easypromolightbox/adminhtml_form_formcontainer')->setData('action', $this->getUrl('*/*/save')))
63
+ ->renderLayout();
64
+ }
65
+
66
+ protected function _initAction()
67
+ {
68
+ $this->loadLayout()
69
+ // Make the active menu match the menu config nodes (without 'children' inbetween)
70
+ ->_setActiveMenu('lmd_easypromolightbox');
71
+
72
+ return $this;
73
+ }
74
+
75
+ public function saveAction()
76
+ {
77
+ $model = Mage::getModel('lmd_easypromolightbox/lightbox');
78
+ if ($data = $this->getRequest()->getPost()) {
79
+ // Trying to save picture
80
+ if (isset($_FILES['body_picture']['name']) && $_FILES['body_picture']['name'] != '') {
81
+ try {
82
+ $uploader = new Varien_File_Uploader('body_picture');
83
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
84
+ $uploader->setAllowRenameFiles(false);
85
+ $uploader->setFilesDispersion(false);
86
+ $path = Mage::getBaseDir('media') . '/lmd/easypromolightbox' . DS;
87
+ $body_picture = $_FILES['body_picture']['name'];
88
+ $data['body_picture'] = 'lmd/easypromolightbox/' . $body_picture;
89
+ $uploader->save($path, $body_picture);
90
+ } catch (Exception $e) {
91
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
92
+ if ($model && $model->getId()) {
93
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
94
+ } else {
95
+ $this->_redirect('*/*/');
96
+ }
97
+ }
98
+ }
99
+ //Some tricks to prevent losing picture if lightbox was modified
100
+ elseif ($data['body_picture']['delete']) {
101
+ $data['body_picture'] = NULL;
102
+ if ($data['body_type'] == 0) {
103
+ $data['body_type'] = 1;
104
+ $data['body_color'] = 'FFFFFF';
105
+ }
106
+
107
+ } else {
108
+ $data['body_picture'] = $data['body_picture']['value'];
109
+ }
110
+
111
+ $model = Mage::getModel('lmd_easypromolightbox/lightbox');
112
+ $collection = $model->getCollection();
113
+ $id = $this->getRequest()->getParam('id');
114
+
115
+ if ($id) {
116
+ $model->load($id);
117
+ } else {
118
+ //If we creating new lightbox, there are setting creation date
119
+ $now = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
120
+ $data['creation_date'] = $now;
121
+ }
122
+ //Setting $data array to model
123
+ $model->setData($data);
124
+
125
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
126
+ //Trying to save model to database
127
+ try {
128
+
129
+ if ($id) {
130
+ $model->setId($id);
131
+ }
132
+ $model->save();
133
+
134
+ if (!$model->getId()) {
135
+ Mage::throwException(Mage::helper('adminhtml')->__('Error saving lightbox'));
136
+ }
137
+
138
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Lightbox was successfully saved.'));
139
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
140
+
141
+ // The following line decides if it is a "save" or "save and continue"
142
+ if ($this->getRequest()->getParam('back')) {
143
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
144
+ } else {
145
+ $this->_redirect('*/*/');
146
+ }
147
+
148
+ } catch (Exception $e) {
149
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
150
+ if ($model && $model->getId()) {
151
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
152
+ } else {
153
+ $this->_redirect('*/*/');
154
+ }
155
+ }
156
+
157
+ return;
158
+ }
159
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('No data found to save'));
160
+ $this->_redirect('*/*/');
161
+ }
162
+
163
+ public function deleteAction()
164
+ {
165
+ if ($this->getRequest()->getParam('id') > 0) {
166
+ try {
167
+ $model = Mage::getModel('lmd_easypromolightbox/lightbox');
168
+
169
+ $model->setId($this->getRequest()->getParam('id'))
170
+ ->delete();
171
+
172
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Notification was successfully deleted'));
173
+ $this->_redirect('*/*/');
174
+ } catch (Exception $e) {
175
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
176
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
177
+ }
178
+ }
179
+ $this->_redirect('*/*/');
180
+ }
181
+ }
app/code/local/LMD/EasyPromoLightBox/controllers/LightboxController.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ class LMD_EasyPromoLightBox_LightboxController extends Mage_Core_Controller_Front_Action
22
+ {
23
+ public function indexAction()
24
+ {
25
+ $this->loadLayout();
26
+ $this->renderLayout();
27
+ }
28
+ /**
29
+ * Action that subscribes customer
30
+ */
31
+ public function subscribeAction()
32
+ {
33
+ $email = $this->getRequest()->getParam('email');
34
+
35
+ if ($email) {
36
+ $session = Mage::getSingleton('core/session');
37
+ $customerSession = Mage::getSingleton('customer/session');
38
+ $customer = Mage::getSingleton('customer/session')->getCustomerId();
39
+ //Validating email
40
+ if (!Zend_Validate::is($email, 'EmailAddress')) {
41
+
42
+ $result['1'] = "Please enter a valid email address.";
43
+ $result['2'] = false;
44
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
45
+ $this->getResponse()->setBody(json_encode($result));
46
+ return;
47
+ }
48
+ try {
49
+ $ownerId = Mage::getModel('customer/customer')
50
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
51
+ ->loadByEmail($email)
52
+ ->getId();
53
+
54
+ $subscriberId = Mage::getModel('newsletter/subscriber')
55
+ ->loadByEmail($email)
56
+ ->getId();
57
+
58
+ //Validating throw already subscribed emails
59
+ if ($ownerId !== null && $ownerId != $customerSession->getId() || $subscriberId !== null) {
60
+ if ($ownerId == $customer) {
61
+ $result['1'] = "You're already subscribed.";
62
+ $result['2'] = true;
63
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
64
+ $this->getResponse()->setBody(json_encode($result));
65
+ return;
66
+ }
67
+ $result['1'] = 'This email address is already assigned to another user.';
68
+ $result['2'] = false;
69
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
70
+ $this->getResponse()->setBody(json_encode($result));
71
+ return;
72
+ }
73
+
74
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
75
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
76
+ $result = "Confirmation request has been sent.";
77
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
78
+ $this->getResponse()->setBody(json_encode($result));
79
+ return;
80
+ } else {
81
+ $result['1'] = "Thank you for your subscription.";
82
+ $result['2'] = true;
83
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
84
+ $this->getResponse()->setBody(json_encode($result));
85
+ return;
86
+ }
87
+ } catch (Mage_Core_Exception $e) {
88
+ $result = "There was a problem with the subscription:" . $e;
89
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
90
+ $this->getResponse()->setBody(json_encode($result));
91
+ } catch (Exception $e) {
92
+ $result = "There was a problem with the subscription" . $e;
93
+ $this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
94
+ $this->getResponse()->setBody(json_encode($result));
95
+ }
96
+ }
97
+ }
98
+ }
app/code/local/LMD/EasyPromoLightBox/etc/adminhtml.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <lmd_easypromolightbox>
5
+ <title>LMD Promo Lightbox</title>
6
+ <sort_order>80</sort_order>
7
+ <children>
8
+ <list>
9
+ <title>Manage</title>
10
+ <action>adminhtml/lightbox/index</action>
11
+ </list>
12
+ </children>
13
+ </lmd_easypromolightbox>
14
+ </menu>
15
+ </config>
app/code/local/LMD/EasyPromoLightBox/etc/config.xml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <LMD_EasyPromoLightBox>
5
+ <version>0.1.0</version>
6
+ </LMD_EasyPromoLightBox>
7
+ </modules>
8
+ <frontend>
9
+ <layout>
10
+ <updates>
11
+ <lmd_easypromolightbox>
12
+ <file>lmd_easypromolightbox.xml</file>
13
+ </lmd_easypromolightbox>
14
+ </updates>
15
+ </layout>
16
+ <routers>
17
+ <lmd_easypromolightbox>
18
+ <use>standard</use>
19
+ <args>
20
+ <module>LMD_EasyPromoLightBox</module>
21
+ <frontName>lightbox</frontName>
22
+ </args>
23
+ </lmd_easypromolightbox>
24
+ </routers>
25
+ </frontend>
26
+ <global>
27
+ <models>
28
+ <lmd_easypromolightbox>
29
+ <class>LMD_EasyPromoLightBox_Model</class>
30
+ <resourceModel>lmd_easypromolightbox_resource</resourceModel>
31
+ </lmd_easypromolightbox>
32
+ <lmd_easypromolightbox_resource>
33
+ <class>LMD_EasyPromoLightBox_Model_Mysql4</class>
34
+ <entities>
35
+ <lmd_easypromolightbox>
36
+ <table>lmd_easypromolightbox</table>
37
+ </lmd_easypromolightbox>
38
+ </entities>
39
+ </lmd_easypromolightbox_resource>
40
+ </models>
41
+ <blocks>
42
+ <lmd_easypromolightbox>
43
+ <class>LMD_EasyPromoLightBox_Block</class>
44
+ </lmd_easypromolightbox>
45
+ </blocks>
46
+ <helpers>
47
+ <lmd_easypromolightbox>
48
+ <class>LMD_EasyPromoLightBox_Helper</class>
49
+ </lmd_easypromolightbox>
50
+ </helpers>
51
+ <resources>
52
+ <lmd_easypromolightbox_setup>
53
+ <setup>
54
+ <module>LMD_EasyPromoLightBox</module>
55
+ </setup>
56
+ </lmd_easypromolightbox_setup>
57
+ </resources>
58
+ </global>
59
+ <adminhtml>
60
+ <layout>
61
+ <updates>
62
+ <lmd_easypromolightbox>
63
+ <file>lmd_easypromolightbox.xml</file>
64
+ </lmd_easypromolightbox>
65
+ </updates>
66
+ </layout>
67
+ </adminhtml>
68
+ <admin>
69
+ <routers>
70
+ <adminhtml>
71
+ <args>
72
+ <modules>
73
+ <lmd_easypromolightbox before="Mage_Adminhtml">LMD_EasyPromoLightBox_Adminhtml</lmd_easypromolightbox>
74
+ </modules>
75
+ </args>
76
+ </adminhtml>
77
+ </routers>
78
+ </admin>
79
+ </config>
app/code/local/LMD/EasyPromoLightBox/sql/lmd_easypromolightbox_setup/install-0.1.0.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ /* @var $installer Mage_Core_Model_Resource_Setup */
22
+ $installer = $this;
23
+
24
+ $installer->startSetup();
25
+
26
+ $installer->run("
27
+ DROP TABLE IF EXISTS {$this->getTable('lmd_easypromolightbox')};
28
+ CREATE TABLE {$this->getTable('lmd_easypromolightbox')} (
29
+ entity_id int(10) unsigned NOT NULL auto_increment,
30
+ is_active BOOLEAN,
31
+ notification_name varchar(255),
32
+ title_text varchar(255),
33
+ title_text_color varchar(255),
34
+ notification_text varchar(255),
35
+ notification_text_color varchar(255),
36
+ body_type BOOLEAN,
37
+ body_color varchar(255),
38
+ body_picture varchar(255),
39
+ button_text varchar(255),
40
+ button_color varchar(255),
41
+ notification_height varchar(255),
42
+ notification_width varchar(255),
43
+ cookies_lifetime varchar(255),
44
+ time_to_show varchar(255),
45
+ edit_date TIMESTAMP,
46
+ creation_date DATETIME,
47
+ PRIMARY KEY (entity_id)
48
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
49
+ ");
50
+
51
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/lmd_easypromolightbox.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout>
3
+ <adminhtml_lightbox_index>
4
+ <reference name="content">
5
+ <!--In the content we add our grid container-->
6
+ <block type="lmd_easypromolightbox/adminhtml_grid_gridcontainer" name="notification_grid"/>
7
+ </reference>
8
+ </adminhtml_lightbox_index>
9
+ <adminhtml_lightbox_edit>
10
+ <reference name="head">
11
+ <action method="addjs">
12
+ <file>jscolor/jscolor.js</file>
13
+ </action>
14
+ </reference>
15
+ </adminhtml_lightbox_edit>
16
+ </layout>
app/design/frontend/base/default/layout/lmd_easypromolightbox.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <!--<lmd_easypromolightbox_lightbox_index>-->
4
+ <!--<reference name="content">-->
5
+ <!--<block type="lmd_easypromolightbox/frontend_lightbox" name="lightbox.popup"-->
6
+ <!--template="lmd_easypromolightbox/index.phtml"/>-->
7
+ <!--</reference>-->
8
+ <!--</lmd_easypromolightbox_lightbox_index>-->
9
+
10
+ <default>
11
+ <reference name="after_body_start">
12
+ <block type="lmd_easypromolightbox/frontend_lightbox" name="lightbox.popup"
13
+ template="lmd_easypromolightbox/index.phtml" after="-"/>
14
+ </reference>
15
+ <reference name="head">
16
+ <action method="addCss">
17
+ <name>css/lmd_easypromolightbox.css</name>
18
+ </action>
19
+ <!---->
20
+ <!--<action method="addJs">-->
21
+ <!--<script>prototype/window.js</script>-->
22
+ <!--</action>-->
23
+ <!--<action method="addCss">-->
24
+ <!--<stylesheet>prototype/windows/themes/default.css</stylesheet>-->
25
+ <!--</action>-->
26
+ <!--<action method="addItem">-->
27
+ <!--<type>js_css</type>-->
28
+ <!--<name>prototype/windows/themes/default.css</name>-->
29
+ <!--</action>-->
30
+ <!--<action method="addItem">-->
31
+ <!--<type>js_css</type>-->
32
+ <!--<name>prototype/windows/themes/magento.css</name>-->
33
+ <!--</action>-->
34
+ <!---->
35
+ </reference>
36
+ </default>
37
+ </layout>
app/design/frontend/base/default/template/lmd_easypromolightbox/index.phtml ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2015 LMD Agency (alex)
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ * @copyright Copyright (c) 2015 LMD Agency (http://www.lmd-agency.com)
19
+ * @license http://www.gnu.org/licenses/ GNU General Public License (Version 3)
20
+ */
21
+ $lb = $this->getLigthboxInfo();
22
+
23
+ /**
24
+ * Getting last lightbox that has no cookie...
25
+ */
26
+
27
+ foreach ($lb as $notification) {
28
+ $name = 'lightbox' . $notification['entity_id'];
29
+ if (strtotime(htmlspecialchars($_COOKIE["$name"])) != strtotime($notification['edit_date'])) {
30
+ $lightbox = $notification;
31
+ break;
32
+ } else $lightbox = NULL;
33
+ }
34
+
35
+ /**
36
+ * if any is found, it will be shown
37
+ */
38
+
39
+ if ($lightbox) {
40
+ $basedomain = str_replace(array("http://", "https://"), "", Mage::getBaseUrl());
41
+ $basedomain = str_replace("index.php", "", $basedomain);
42
+ $basedomain = str_replace("//", "", $basedomain);
43
+ $basedomain = str_replace("/", "", $basedomain);
44
+ $domain_url = '.' . $basedomain;
45
+ $marginhorizontal = $lightbox['notification_width'] / 2;
46
+ $domain = Mage::getBaseUrl();
47
+ if (substr_count($domain, 'index.php') != 0)
48
+ $domain = str_replace("index.php/", "", $domain);
49
+ ?>
50
+
51
+ <div id="overlay"></div>
52
+ <div id="container">
53
+ <?php if ($lightbox['body_type'] == 1): ?>
54
+ <div id="popup"
55
+ style="margin-left: <?php echo '-' . $marginhorizontal . 'px'; ?>;
56
+ background: <?php echo '#' . $lightbox['body_color']; ?>;
57
+ height: <?php echo $lightbox['notification_height'] . 'px'; ?>;
58
+ width: <?php echo $lightbox['notification_width'] . 'px'; ?>">
59
+ <?php else: ?>
60
+ <div id="popup"
61
+ style="margin-left: <?php echo '-' . $marginhorizontal . 'px'; ?>;
62
+ background: <?php echo 'url(' . $domain . 'media/' . $lightbox['body_picture'] . ')'; ?>;
63
+ background-size: <?php echo $lightbox['notification_width'] . 'px'; ?> <?php echo $lightbox['notification_height'] . 'px'; ?>;
64
+ height: <?php echo $lightbox['notification_height'] . 'px'; ?>;
65
+ width: <?php echo $lightbox['notification_width'] . 'px'; ?>">
66
+ <?php endif; ?>
67
+ <div id="bar">
68
+ <span id="close">Close</span>
69
+ </div>
70
+ <div id="title">
71
+ <span id="popup-title"
72
+ style="color: <?php echo '#' . $lightbox['title_text_color']; ?>"><?php echo $lightbox['title_text']; ?></span>
73
+ </div>
74
+ <div id="body">
75
+ <h2><span id="popup-title"
76
+ style="color: <?php echo '#' . $lightbox['notification_text_color']; ?>"><?php echo $lightbox['notification_text']; ?></span>
77
+ </h2>
78
+ <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()) : ?>
79
+ <input type="text" id="subscribe-email" name="subscribe[email]" class="validate-email">
80
+ <?php else : ?>
81
+ <?php $customerEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail(); ?>
82
+ <input type="hidden" id="subscribe-email" value="<?php echo $customerEmail; ?>"/>
83
+ <?php endif; ?>
84
+ <button name="allow" class="lightbox-subscribe"
85
+ style="background-color: <?php echo '#' . $lightbox['button_color']; ?>"
86
+ onclick="subscribe('<?php echo Mage::helper('adminhtml')->getUrl('lightbox/lightbox/subscribe') ?>')"> <?php echo $lightbox['button_text']; ?></button>
87
+ </div>
88
+ </div>
89
+ </div>
90
+
91
+ <script type="text/javascript">// <![CDATA[
92
+
93
+ document.observe("dom:loaded", function () {
94
+ showLightbox.delay(<?php echo $lightbox['time_to_show']; ?>);
95
+ });
96
+
97
+ $('close').observe('click', function () {
98
+ closeAndSet();
99
+ });
100
+
101
+ $('overlay').observe('click', function () {
102
+ closeAndSet();
103
+ });
104
+
105
+ function showLightbox() {
106
+ $('overlay').setStyle({display: 'block'});
107
+ $('container').setStyle({display: 'block'});
108
+ }
109
+
110
+ /**
111
+ * Ajax request to controller for
112
+ * subscribe customer
113
+ */
114
+ function subscribe(url) {
115
+ var email = $('subscribe-email').value;
116
+ new Ajax.Request(url, {
117
+ method: 'post',
118
+ parameters: {email: email},
119
+ onSuccess: function (response) {
120
+ var json = response.responseText.evalJSON(true);
121
+ console.log(json);
122
+ alert(json[1]);
123
+ if (json[2] == true) {
124
+ closeAndSet()
125
+ }
126
+ }
127
+ });
128
+ }
129
+
130
+ function closeAndSet() {
131
+ $('overlay').setStyle({display: 'none'});
132
+ $('container').setStyle({display: 'none'});
133
+ var now = new Date();
134
+ var time = now.getTime();
135
+ time +=
136
+ <?php echo $lightbox['cookies_lifetime']; ?> *
137
+ 1000 * 60 * 60 * 24;
138
+ now.setTime(time);
139
+ setCookie('<?php echo 'lightbox' . $lightbox['entity_id']; ?>', '<?php echo $lightbox['edit_date']; ?>', now.toUTCString(), '<?php echo $domain_url; ?>', '/');
140
+ }
141
+
142
+ function setCookie(name, value, expires, domain, path, secure) {
143
+ document.cookie = name + "=" + escape(value) +
144
+ ((expires) ? "; expires=" + expires : "") +
145
+ ((path) ? "; path=" + path : "") +
146
+ ((domain) ? "; domain=" + domain : "") +
147
+ ((secure) ? "; secure" : "");
148
+ }
149
+
150
+ /**
151
+ * Some unused junk
152
+ * If you don't need it, just remove=)
153
+ */
154
+ function getCookie(name) {
155
+ var start = document.cookie.indexOf(name + "=");
156
+ var len = start + name.length + 1;
157
+ if (( !start ) && ( name != document.cookie.substring(0, name.length) )) {
158
+ return null;
159
+ }
160
+ if (start == -1) return null;
161
+ var end = document.cookie.indexOf(';', len);
162
+ if (end == -1) end = document.cookie.length;
163
+ return unescape(document.cookie.substring(len, end));
164
+ }
165
+ // ]]></script>
166
+ <?php } ?>
app/etc/modules/LMD_EasyPromoLightBox.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <LMD_EasyPromoLightBox>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </LMD_EasyPromoLightBox>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>LMD_subscription_popup_constructor</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>LMD newsletter subscription popup constructor</summary>
10
+ <description>Magento does not provide an easy way to subscribe to the newsletter so far. This extension gives you the opportunity. A pop-up window with the information that you want to tell the client - what could be easier? And if the customer will be interested in your offer, he will be able to subscribe to your newsletter.</description>
11
+ <notes>If you find any bugs, please report us!</notes>
12
+ <authors><author><name>LMD Agency</name><user>Alexander</user><email>aborodavkin@gmail.com</email></author></authors>
13
+ <date>2015-02-18</date>
14
+ <time>11:53:07</time>
15
+ <contents><target name="magelocal"><dir name="LMD"><dir name="EasyPromoLightBox"><dir name="Block"><dir name="Adminhtml"><dir name="Form"><dir name="Edit"><file name="Form.php" hash="a963c9642ed68f05814cce8e107e7261"/></dir><file name="Formcontainer.php" hash="793f395cdaf0051ba6c41f2f3948f82d"/></dir><dir name="Grid"><file name="Grid.php" hash="aafce276909e3ae6aff819fe9f5fff08"/><file name="Gridcontainer.php" hash="04153b4ec04613288c57db11b6c95116"/><dir name="Renderer"><file name="Active.php" hash="8a1f99931ddd3fa56c7d95b7607da497"/></dir></dir></dir><dir name="Frontend"><file name="Lightbox.php" hash="4be698cb28b01489d34e30cdb0d3f9d6"/></dir></dir><dir name="Helper"><file name="Data.php" hash="98034fe4af6f7b40e1a3d4c214c3f203"/></dir><dir name="Model"><file name="Lightbox.php" hash="bef4874325d177dddd317e28a2cb6c04"/><dir name="Mysql4"><dir name="Lightbox"><file name="Collection.php" hash="b1d67302e3afd4e682cbca082a0b4fc2"/></dir><file name="Lightbox.php" hash="5bd84b1fb3cba2cb0f87b52bb9c3b32d"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LightboxController.php" hash="0ca592aa1bd5f2fe5a4887fbb3d7fce7"/></dir><file name="LightboxController.php" hash="56ea3e5aa0871c3cdc0ef30ad2cb93a3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="14f13a93e07e88b7d0c842446c661866"/><file name="config.xml" hash="cb57af5378156ccc43b2f81e27533518"/></dir><dir name="sql"><dir name="lmd_easypromolightbox_setup"><file name="install-0.1.0.php" hash="ea2bdaf2da9094805f086e096eba0538"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lmd_easypromolightbox.xml" hash="c0d8f8e98ecb7d8fae08b3f13decc7f9"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="lmd_easypromolightbox.xml" hash="54cf97a9c3e3f27d00a9540329566245"/></dir><dir name="template"><dir name="lmd_easypromolightbox"><file name="index.phtml" hash="c1190bf4c9c823436888b19c6dcaa82a"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="lmd_easypromolightbox.css" hash="114a300c36200ef94216b2b18830bb2d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LMD_EasyPromoLightBox.xml" hash="d19dd61ec41ed0b13f63a041e9985984"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/lmd_easypromolightbox.css ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #container {
2
+ display: none;
3
+ position: fixed;
4
+ top: 40px;
5
+ z-index:99998;
6
+ width: 100%;
7
+ }
8
+
9
+ #popup {
10
+ color: #FFF;
11
+ position: absolute;
12
+ z-index:99999;
13
+ left: 50%;
14
+ }
15
+
16
+ #bar {
17
+ text-align: right;
18
+ height: 20px
19
+ }
20
+
21
+ #close{
22
+ cursor: pointer
23
+ }
24
+
25
+ #popup-title{
26
+
27
+ }
28
+
29
+ #title{
30
+ text-align: center;
31
+ }
32
+
33
+ #overlay{
34
+ display: none;
35
+ opacity: 0.3;
36
+ height: 100%;
37
+ width: 100%;
38
+ background-color: rgb(0, 0, 0);
39
+ z-index:99997;
40
+ position: absolute;
41
+ }