free_testimonials_extension - Version 1.1.0

Version Notes

Magento Easy Tabs Community Module

Download this release

Release Info

Developer TemplatesMaster
Extension free_testimonials_extension
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

Files changed (46) hide show
  1. app/code/local/TM/Testimonials/Block/Adminhtml/Page.php +28 -0
  2. app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit.php +117 -0
  3. app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit/Form.php +17 -0
  4. app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit/Tab/Main.php +211 -0
  5. app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit/Tabs.php +12 -0
  6. app/code/local/TM/Testimonials/Block/Adminhtml/Page/Grid.php +130 -0
  7. app/code/local/TM/Testimonials/Block/Adminhtml/Page/Helper/Image.php +15 -0
  8. app/code/local/TM/Testimonials/Block/Form/Container.php +5 -0
  9. app/code/local/TM/Testimonials/Block/Form/Form.php +76 -0
  10. app/code/local/TM/Testimonials/Block/List/Bottom.php +33 -0
  11. app/code/local/TM/Testimonials/Block/List/Content.php +76 -0
  12. app/code/local/TM/Testimonials/Block/List/Title.php +6 -0
  13. app/code/local/TM/Testimonials/Block/Widget/Form.php +29 -0
  14. app/code/local/TM/Testimonials/Block/Widget/List.php +68 -0
  15. app/code/local/TM/Testimonials/Block/Widget/ListFull.php +65 -0
  16. app/code/local/TM/Testimonials/Block/Widget/Review.php +70 -0
  17. app/code/local/TM/Testimonials/Helper/Data.php +321 -0
  18. app/code/local/TM/Testimonials/Helper/Image.php +63 -0
  19. app/code/local/TM/Testimonials/Model/Data.php +36 -0
  20. app/code/local/TM/Testimonials/Model/Observer.php +98 -0
  21. app/code/local/TM/Testimonials/Model/Resource/Data.php +121 -0
  22. app/code/local/TM/Testimonials/Model/Resource/Data/Collection.php +74 -0
  23. app/code/local/TM/Testimonials/Model/Resource/Setup.php +4 -0
  24. app/code/local/TM/Testimonials/Model/System/Config/Backend/Image.php +21 -0
  25. app/code/local/TM/Testimonials/controllers/Adminhtml/Testimonials/IndexController.php +253 -0
  26. app/code/local/TM/Testimonials/controllers/IndexController.php +125 -0
  27. app/code/local/TM/Testimonials/etc/adminhtml.xml +71 -0
  28. app/code/local/TM/Testimonials/etc/config.xml +188 -0
  29. app/code/local/TM/Testimonials/etc/system.xml +245 -0
  30. app/code/local/TM/Testimonials/etc/widget.xml +72 -0
  31. app/code/local/TM/Testimonials/sql/tm_testimonials_setup/mysql4-install-1.0.0.php +87 -0
  32. app/design/adminhtml/default/default/layout/tm/testimonials.xml +28 -0
  33. app/design/frontend/base/default/layout/tm/testimonials.xml +66 -0
  34. app/design/frontend/base/default/template/tm/testimonials/form/container.phtml +5 -0
  35. app/design/frontend/base/default/template/tm/testimonials/form/form.phtml +99 -0
  36. app/design/frontend/base/default/template/tm/testimonials/list/bottom.phtml +21 -0
  37. app/design/frontend/base/default/template/tm/testimonials/list/content.phtml +85 -0
  38. app/design/frontend/base/default/template/tm/testimonials/list/title.phtml +12 -0
  39. app/design/frontend/base/default/template/tm/testimonials/widget/list.phtml +105 -0
  40. app/design/frontend/base/default/template/tm/testimonials/widget/review.phtml +18 -0
  41. app/etc/modules/TM_Testimonials.xml +10 -0
  42. app/locale/en_US/TM_Testimonials.csv +35 -0
  43. app/locale/en_US/template/email/testimonials_admin_notification.html +49 -0
  44. package.xml +30 -0
  45. skin/frontend/base/default/css/tm/testimonials.css +258 -0
  46. skin/frontend/base/default/js/tm/testimonials.js +22 -0
app/code/local/TM/Testimonials/Block/Adminhtml/Page.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Adminhtml_Page extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'testimonials';
8
+ $this->_controller = 'adminhtml_page';
9
+ $this->_headerText = Mage::helper('testimonials')->__('Manage Testimonials');
10
+
11
+ parent::__construct();
12
+
13
+ if (!$this->_isAllowedAction('save')) {
14
+ $this->_removeButton('add');
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Check permission for passed action
20
+ *
21
+ * @param string $action
22
+ * @return bool
23
+ */
24
+ protected function _isAllowedAction($action)
25
+ {
26
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/' . $action);
27
+ }
28
+ }
app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Block_Adminhtml_Page_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+
7
+ $this->_blockGroup = 'testimonials';
8
+ $this->_objectId = 'testimonial_id';
9
+ $this->_controller = 'adminhtml_page';
10
+
11
+ parent::__construct();
12
+
13
+ if ($this->_isAllowedAction('save')) {
14
+ $this->_addButton('saveandcontinue', array(
15
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
16
+ 'onclick' => 'saveAndContinueEdit(\''.$this->_getSaveAndContinueUrl().'\')',
17
+ 'class' => 'save',
18
+ ), -100);
19
+ } else {
20
+ $this->_removeButton('save');
21
+ }
22
+ if (!$this->_isAllowedAction('delete')) {
23
+ $this->_removeButton('delete');
24
+ }
25
+
26
+ if ($this->_isAllowedAction('approve')) {
27
+ if (Mage::registry('testimonials_data')->getStatus() == TM_Testimonials_Model_Data::STATUS_AWAITING_APPROVAL) {
28
+ $this->addButton('approve', array(
29
+ 'label' => Mage::helper('testimonials')->__('Approve'),
30
+ 'onclick' => "setLocation('" . $this->_getApproveUrl() . "')",
31
+ 'class' => 'save'
32
+ ));
33
+ }
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Retrieve text for header element depending on loaded page
39
+ *
40
+ * @return string
41
+ */
42
+ public function getHeaderText()
43
+ {
44
+ if (Mage::registry('testimonials_data')->getId()) {
45
+ return Mage::helper('testimonials')->__("Edit Testimonial");
46
+ }
47
+ else {
48
+ return Mage::helper('testimonials')->__('New Testimonial');
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Check permission for passed action
54
+ *
55
+ * @param string $action
56
+ * @return bool
57
+ */
58
+ protected function _isAllowedAction($action)
59
+ {
60
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/' . $action);
61
+ }
62
+
63
+ public function getSaveUrl()
64
+ {
65
+ return $this->getUrl('*/*/save', array(
66
+ '_current' => true
67
+ ));
68
+ }
69
+
70
+ /**
71
+ * Getter of url for "Save and Continue" button
72
+ * tab_id will be replaced by desired by JS later
73
+ *
74
+ * @return string
75
+ */
76
+ protected function _getSaveAndContinueUrl()
77
+ {
78
+ return $this->getUrl('*/*/save', array(
79
+ '_current' => true,
80
+ 'back' => 'edit',
81
+ 'active_tab' => '{{tab_id}}'
82
+ ));
83
+ }
84
+
85
+ protected function _getApproveUrl()
86
+ {
87
+ return $this->getUrl('*/*/approve', array(
88
+ '_current' => true
89
+ ));
90
+ }
91
+
92
+ protected function _prepareLayout()
93
+ {
94
+ $tabsBlock = $this->getLayout()->getBlock('testimonials_page_edit_tabs');
95
+ if ($tabsBlock) {
96
+ $tabsBlockJsObject = $tabsBlock->getJsObjectName();
97
+ $tabsBlockPrefix = $tabsBlock->getId() . '_';
98
+ } else {
99
+ $tabsBlockJsObject = 'page_tabsJsTabs';
100
+ $tabsBlockPrefix = 'page_tabs_';
101
+ }
102
+
103
+ $this->_formScripts[] = "
104
+ function saveAndContinueEdit(urlTemplate) {
105
+ var tabsIdValue = " . $tabsBlockJsObject . ".activeTab.id;
106
+ var tabsBlockPrefix = '" . $tabsBlockPrefix . "';
107
+ if (tabsIdValue.startsWith(tabsBlockPrefix)) {
108
+ tabsIdValue = tabsIdValue.substr(tabsBlockPrefix.length)
109
+ }
110
+ var template = new Template(urlTemplate, /(^|.|\\r|\\n)({{(\w+)}})/);
111
+ var url = template.evaluate({tab_id:tabsIdValue});
112
+ editForm.submit(url);
113
+ }
114
+ ";
115
+ return parent::_prepareLayout();
116
+ }
117
+ }
app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Adminhtml_Page_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getData('action'),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ ));
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit/Tab/Main.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Adminhtml_Page_Edit_Tab_Main
4
+ extends Mage_Adminhtml_Block_Widget_Form
5
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
+ {
7
+ protected function _prepareForm()
8
+ {
9
+ $model = Mage::registry('testimonials_data');
10
+ $form = new Varien_Data_Form();
11
+ $form->setHtmlIdPrefix('page_');
12
+
13
+ $fieldset = $form->addFieldset('base_fieldset', array(
14
+ 'legend' => Mage::helper('testimonials')->__('Testimonial Information'),
15
+ 'class' => 'fieldset-wide'
16
+ ));
17
+
18
+ if ($model->getTestimonialId()) {
19
+ $fieldset->addField('testimonial_id', 'hidden', array(
20
+ 'name' => 'testimonial_id'
21
+ ));
22
+ }
23
+
24
+ if ($this->_isAllowedAction('save')) {
25
+ $isElementDisabled = false;
26
+ } else {
27
+ $isElementDisabled = true;
28
+ }
29
+
30
+ $fieldset->addField('name', 'text', array(
31
+ 'name' => 'name',
32
+ 'label' => Mage::helper('catalog')->__('Name'),
33
+ 'title' => Mage::helper('catalog')->__('Name'),
34
+ 'required' => true,
35
+ 'disabled' => $isElementDisabled
36
+ ));
37
+
38
+ $fieldset->addField('email', 'text', array(
39
+ 'name' => 'email',
40
+ 'label' => Mage::helper('contacts')->__('Email'),
41
+ 'title' => Mage::helper('contacts')->__('Email'),
42
+ 'required' => true,
43
+ 'class' => 'validate-email',
44
+ 'disabled' => $isElementDisabled
45
+ ));
46
+
47
+ if (!Mage::app()->isSingleStoreMode()) {
48
+ $field = $fieldset->addField('store_id', 'multiselect', array(
49
+ 'name' => 'stores[]',
50
+ 'label' => Mage::helper('cms')->__('Store View'),
51
+ 'title' => Mage::helper('cms')->__('Store View'),
52
+ 'required' => true,
53
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
54
+ 'disabled' => $isElementDisabled
55
+ ));
56
+ } else {
57
+ $fieldset->addField('store_id', 'hidden', array(
58
+ 'name' => 'stores[]',
59
+ 'value' => Mage::app()->getStore(true)->getId()
60
+ ));
61
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
62
+ }
63
+
64
+ $fieldset->addField('message', 'textarea', array(
65
+ 'name' => 'message',
66
+ 'label' => Mage::helper('testimonials')->__('Message'),
67
+ 'title' => Mage::helper('testimonials')->__('Message'),
68
+ 'required' => true,
69
+ 'disabled' => $isElementDisabled
70
+ ));
71
+
72
+ $fieldset->addField('company', 'text', array(
73
+ 'name' => 'company',
74
+ 'label' => Mage::helper('testimonials')->__('Company'),
75
+ 'title' => Mage::helper('testimonials')->__('Company'),
76
+ 'disabled' => $isElementDisabled
77
+ ));
78
+
79
+ $fieldset->addField('website', 'text', array(
80
+ 'name' => 'website',
81
+ 'label' => Mage::helper('testimonials')->__('Website'),
82
+ 'title' => Mage::helper('testimonials')->__('Website'),
83
+ 'disabled' => $isElementDisabled
84
+ ));
85
+
86
+ $fieldset->addField('facebook', 'text', array(
87
+ 'name' => 'facebook',
88
+ 'label' => Mage::helper('testimonials')->__('Facebook'),
89
+ 'title' => Mage::helper('testimonials')->__('Facebook'),
90
+ 'disabled' => $isElementDisabled
91
+ ));
92
+
93
+ $fieldset->addField('twitter', 'text', array(
94
+ 'name' => 'twitter',
95
+ 'label' => Mage::helper('testimonials')->__('Twitter'),
96
+ 'title' => Mage::helper('testimonials')->__('Twitter'),
97
+ 'disabled' => $isElementDisabled
98
+ ));
99
+
100
+ $fieldset->addField('rating', 'select', array(
101
+ 'name' => 'rating',
102
+ 'label' => Mage::helper('testimonials')->__('Rating'),
103
+ 'title' => Mage::helper('testimonials')->__('Rating'),
104
+ 'options' => array('-1' => Mage::helper('testimonials')->__('No rating'),
105
+ '1' => '1 ' . Mage::helper('testimonials')->__('star'),
106
+ '2' => '2 ' . Mage::helper('testimonials')->__('stars'),
107
+ '3' => '3 ' . Mage::helper('testimonials')->__('stars'),
108
+ '4' => '4 ' . Mage::helper('testimonials')->__('stars'),
109
+ '5' => '5 ' . Mage::helper('testimonials')->__('stars')),
110
+ 'disabled' => $isElementDisabled
111
+ ));
112
+
113
+ $this->_addElementTypes($fieldset); //register own image element
114
+ $fieldset->addField('image', 'image', array(
115
+ 'name' => 'image',
116
+ 'label' => Mage::helper('catalog')->__('Profile image'),
117
+ 'title' => Mage::helper('catalog')->__('Profile image'),
118
+ 'disabled' => $isElementDisabled
119
+ ));
120
+
121
+ $fieldset->addField('status', 'select', array(
122
+ 'name' => 'status',
123
+ 'label' => Mage::helper('cms')->__('Status'),
124
+ 'title' => Mage::helper('cms')->__('Status'),
125
+ 'options' => $model->getAvailableStatuses(),
126
+ 'disabled' => $isElementDisabled,
127
+ 'required' => true
128
+ ));
129
+
130
+ $fieldset->addField('widget', 'select', array(
131
+ 'name' => 'widget',
132
+ 'label' => Mage::helper('testimonials')->__('Display in widget'),
133
+ 'title' => Mage::helper('testimonials')->__('Display in widget'),
134
+ 'options' => Mage::getModel('adminhtml/system_config_source_yesno')->toArray(),
135
+ 'disabled' => $isElementDisabled,
136
+ 'value' => 1
137
+ ));
138
+
139
+ $fieldset->addField('date', 'date', array(
140
+ 'name' => 'date',
141
+ 'label' => Mage::helper('testimonials')->__('Created date'),
142
+ 'title' => Mage::helper('testimonials')->__('Created date'),
143
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
144
+ 'format' => Mage::app()->getLocale()->getDateFormatWithLongYear(),
145
+ 'disabled' => $isElementDisabled
146
+ ));
147
+
148
+ $form->addValues($model->getData());
149
+ $form->setFieldNameSuffix('testimonials');
150
+ $this->setForm($form);
151
+ return parent::_prepareForm();
152
+ }
153
+
154
+ protected function _getAdditionalElementTypes()
155
+ {
156
+ return array(
157
+ 'image' => Mage::getConfig()->getBlockClassName('testimonials/adminhtml_page_helper_image')
158
+ );
159
+ }
160
+
161
+ /**
162
+ * Prepare label for tab
163
+ *
164
+ * @return string
165
+ */
166
+ public function getTabLabel()
167
+ {
168
+ return Mage::helper('testimonials')->__('Testimonial Information');
169
+ }
170
+
171
+ /**
172
+ * Prepare title for tab
173
+ *
174
+ * @return string
175
+ */
176
+ public function getTabTitle()
177
+ {
178
+ return Mage::helper('testimonials')->__('Testimonial Information');
179
+ }
180
+
181
+ /**
182
+ * Returns status flag about this tab can be shown or not
183
+ *
184
+ * @return true
185
+ */
186
+ public function canShowTab()
187
+ {
188
+ return true;
189
+ }
190
+
191
+ /**
192
+ * Returns status flag about this tab hidden or not
193
+ *
194
+ * @return true
195
+ */
196
+ public function isHidden()
197
+ {
198
+ return false;
199
+ }
200
+
201
+ /**
202
+ * Check permission for passed action
203
+ *
204
+ * @param string $action
205
+ * @return bool
206
+ */
207
+ protected function _isAllowedAction($action)
208
+ {
209
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/' . $action);
210
+ }
211
+ }
app/code/local/TM/Testimonials/Block/Adminhtml/Page/Edit/Tabs.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Adminhtml_Page_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('page_tabs');
9
+ $this->setDestElementId('edit_form');
10
+ $this->setTitle(Mage::helper('testimonials')->__('Testimonial Information'));
11
+ }
12
+ }
app/code/local/TM/Testimonials/Block/Adminhtml/Page/Grid.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Block_Adminhtml_Page_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('testimonialsGrid');
8
+ $this->setDefaultSort('testimonial_id');
9
+ $this->setDefaultDir('ASC');
10
+ }
11
+
12
+ protected function _prepareCollection()
13
+ {
14
+ $collection = Mage::getModel('tm_testimonials/data')->getCollection();
15
+ $this->setCollection($collection);
16
+ return parent::_prepareCollection();
17
+ }
18
+
19
+ protected function _prepareColumns()
20
+ {
21
+ $this->addColumn('testimonial_id', array(
22
+ 'header' => Mage::helper('testimonials')->__('Id'),
23
+ 'index' => 'testimonial_id',
24
+ 'width' => 50
25
+ ));
26
+
27
+ $this->addColumn('name', array(
28
+ 'header' => Mage::helper('testimonials')->__('Name'),
29
+ 'index' => 'name'
30
+ ));
31
+
32
+ $this->addColumn('email', array(
33
+ 'header' => Mage::helper('testimonials')->__('Email'),
34
+ 'index' => 'email'
35
+ ));
36
+
37
+ if (!Mage::app()->isSingleStoreMode()) {
38
+ $this->addColumn('store_id', array(
39
+ 'header' => Mage::helper('cms')->__('Store View'),
40
+ 'index' => 'store_id',
41
+ 'type' => 'store',
42
+ 'store_all' => true,
43
+ 'store_view' => true,
44
+ 'sortable' => false,
45
+ 'filter_condition_callback'
46
+ => array($this, '_filterStoreCondition')
47
+ ));
48
+ }
49
+
50
+ $this->addColumn('date', array(
51
+ 'header' => Mage::helper('testimonials')->__('Created Date'),
52
+ 'index' => 'date',
53
+ 'width' => 150,
54
+ 'type' => 'datetime'
55
+ ));
56
+
57
+ $this->addColumn('status', array(
58
+ 'header' => Mage::helper('testimonials')->__('Status'),
59
+ 'index' => 'status',
60
+ 'type' => 'options',
61
+ 'width' => 150,
62
+ 'options' => Mage::getSingleton('tm_testimonials/data')->getAvailableStatuses()
63
+ ));
64
+ return parent::_prepareColumns();
65
+ }
66
+
67
+ protected function _prepareMassaction()
68
+ {
69
+ $this->setMassactionIdField('testimonial_id');
70
+ $this->getMassactionBlock()->setFormFieldName('testimonials');
71
+
72
+ if ($this->_isAllowedAction('delete')) {
73
+ $this->getMassactionBlock()->addItem('delete', array(
74
+ 'label'=> Mage::helper('catalog')->__('Delete'),
75
+ 'url' => $this->getUrl('*/*/massDelete'),
76
+ 'confirm' => Mage::helper('catalog')->__('Are you sure?')
77
+ ));
78
+ }
79
+
80
+ if ($this->_isAllowedAction('approve')) {
81
+ $statuses = Mage::getSingleton('tm_testimonials/data')->getAvailableStatuses();
82
+
83
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
84
+ $this->getMassactionBlock()->addItem('status', array(
85
+ 'label'=> Mage::helper('catalog')->__('Change status'),
86
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
87
+ 'additional' => array(
88
+ 'visibility' => array(
89
+ 'name' => 'status',
90
+ 'type' => 'select',
91
+ 'class' => 'required-entry',
92
+ 'label' => Mage::helper('catalog')->__('Status'),
93
+ 'values' => $statuses
94
+ )
95
+ )
96
+ ));
97
+ }
98
+
99
+ return $this;
100
+ }
101
+
102
+ protected function _afterLoadCollection()
103
+ {
104
+ $this->getCollection()->walk('afterLoad');
105
+ parent::_afterLoadCollection();
106
+ }
107
+
108
+ protected function _filterStoreCondition($collection, $column)
109
+ {
110
+ if (!$value = $column->getFilter()->getValue()) {
111
+ return;
112
+ }
113
+ $this->getCollection()->addStoreFilter($value);
114
+ }
115
+
116
+ public function getRowUrl($row)
117
+ {
118
+ return $this->getUrl('*/*/edit', array('testimonial_id' => $row->getTestimonialId()));
119
+ }
120
+ /**
121
+ * Check permission for passed action
122
+ *
123
+ * @param string $action
124
+ * @return bool
125
+ */
126
+ protected function _isAllowedAction($action)
127
+ {
128
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/' . $action);
129
+ }
130
+ }
app/code/local/TM/Testimonials/Block/Adminhtml/Page/Helper/Image.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Adminhtml_Page_Helper_Image extends Varien_Data_Form_Element_Image
4
+ {
5
+ protected function _getUrl()
6
+ {
7
+ $url = false;
8
+ if ($this->getValue()) {
9
+ $url = Mage::getBaseUrl('media')
10
+ . TM_Testimonials_Model_Data::IMAGE_PATH
11
+ . $this->getValue();
12
+ }
13
+ return $url;
14
+ }
15
+ }
app/code/local/TM/Testimonials/Block/Form/Container.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Block_Form_Container extends Mage_Core_Block_Template
3
+ {
4
+
5
+ }
app/code/local/TM/Testimonials/Block/Form/Form.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Block_Form_Form extends Mage_Core_Block_Template
3
+ {
4
+ public function getUserName()
5
+ {
6
+ if ($data = $this->_getSessionData('name')) {
7
+ return $data;
8
+ }
9
+ return $this->helper('contacts')->getUserName();
10
+ }
11
+
12
+ public function getUserEmail()
13
+ {
14
+ if ($data = $this->_getSessionData('email')) {
15
+ return $data;
16
+ }
17
+ return $this->helper('contacts')->getUserEmail();
18
+ }
19
+
20
+ public function getUserMessage()
21
+ {
22
+ if ($data = $this->_getSessionData('message')) {
23
+ return $data;
24
+ }
25
+ return '';
26
+ }
27
+
28
+ public function getCompany()
29
+ {
30
+ if ($data = $this->_getSessionData('company')) {
31
+ return $data;
32
+ }
33
+ return '';
34
+ }
35
+
36
+ public function getWebSite()
37
+ {
38
+ if ($data = $this->_getSessionData('website')) {
39
+ return $data;
40
+ }
41
+ return '';
42
+ }
43
+
44
+ public function getTwitter()
45
+ {
46
+ if ($data = $this->_getSessionData('twitter')) {
47
+ return $data;
48
+ }
49
+ return '';
50
+ }
51
+
52
+ public function getFacebook()
53
+ {
54
+ if ($data = $this->_getSessionData('facebook')) {
55
+ return $data;
56
+ }
57
+ return '';
58
+ }
59
+
60
+ public function checkRating($rating)
61
+ {
62
+ if ($data = $this->_getSessionData('rating')) {
63
+ return ($data == $rating);
64
+ }
65
+ return false;
66
+ }
67
+
68
+ protected function _getSessionData($key)
69
+ {
70
+ $data = Mage::getSingleton('customer/session')->getTestimonialsFormData();
71
+ if ($data && isset($data[$key])) {
72
+ return $data[$key];
73
+ }
74
+ return false;
75
+ }
76
+ }
app/code/local/TM/Testimonials/Block/List/Bottom.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_List_Bottom extends Mage_Core_Block_Template
4
+ {
5
+ protected function _beforeToHtml()
6
+ {
7
+ if ($this->getLayout()->getBlock('testimonials.list.content')) {
8
+ $testimonials = $this->getLayout()
9
+ ->getBlock('testimonials.list.content')
10
+ ->getTestimonials();
11
+ } else {
12
+ $testimonials = Mage::getModel('tm_testimonials/data')->getCollection()
13
+ ->addFieldToSelect('*')
14
+ ->addStoreFilter(Mage::app()->getStore())
15
+ ->addFieldToFilter('status', TM_Testimonials_Model_Data::STATUS_ENABLED)
16
+ ->setOrder('date', 'desc')
17
+ ->setPageSize($this->getPerPage())
18
+ ->setCurPage($this->getCurrentPage());
19
+ }
20
+
21
+ $this->setTestimonials($testimonials);
22
+ return parent::_beforeToHtml();
23
+ }
24
+
25
+ public function getPerPage()
26
+ {
27
+ $perPage = $this->getData('per_page');
28
+ if (!$perPage) {
29
+ $perPage = Mage::helper('testimonials')->getTestimonialsPerPage();
30
+ }
31
+ return $perPage;
32
+ }
33
+ }
app/code/local/TM/Testimonials/Block/List/Content.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_List_Content extends Mage_Core_Block_Template
4
+ {
5
+ protected $_placeholderImage;
6
+ /**
7
+ * Initialize block's cache
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+
13
+ $this->addData(array(
14
+ 'cache_lifetime' => false,
15
+ 'cache_tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
16
+ ));
17
+ }
18
+
19
+ /**
20
+ * Get Key pieces for caching block content
21
+ *
22
+ * @return array
23
+ */
24
+ public function getCacheKeyInfo()
25
+ {
26
+ return array(
27
+ 'TM_TESTIMONIALS_LIST',
28
+ Mage::app()->getStore()->getId(),
29
+ (int)Mage::app()->getStore()->isCurrentlySecure(),
30
+ Mage::getDesign()->getPackageName(),
31
+ Mage::getDesign()->getTheme('template'),
32
+ $this->getTemplate(),
33
+ $this->getPerPage(),
34
+ $this->getCurrentPage()
35
+ );
36
+ }
37
+
38
+ protected function _beforeToHtml()
39
+ {
40
+ $testimonials = Mage::getModel('tm_testimonials/data')->getCollection()
41
+ ->addFieldToSelect('*')
42
+ ->addStoreFilter(Mage::app()->getStore())
43
+ ->addFieldToFilter('status', TM_Testimonials_Model_Data::STATUS_ENABLED)
44
+ ->setOrder('date', 'desc')
45
+ ->setPageSize($this->getPerPage())
46
+ ->setCurPage($this->getCurrentPage());
47
+
48
+ $this->setTestimonials($testimonials);
49
+ $this->_placeholderImage = Mage::helper('testimonials')->getPlaceholderImage();
50
+ return parent::_beforeToHtml();
51
+ }
52
+
53
+ public function getPerPage()
54
+ {
55
+ $perPage = $this->getData('per_page');
56
+ if (!$perPage) {
57
+ $perPage = Mage::helper('testimonials')->getTestimonialsPerPage();
58
+ }
59
+ return $perPage;
60
+ }
61
+
62
+ public function canShowSocial($testimonial)
63
+ {
64
+ return (($testimonial->getFacebook() && Mage::helper('testimonials')->isFacebookEnabled())||
65
+ ($testimonial->getTwitter() && Mage::helper('testimonials')->isTwitterEnabled()));
66
+ }
67
+
68
+ public function getImagePath($testimonial)
69
+ {
70
+ $image = $testimonial->getImage();
71
+ if (!$image && $this->_placeholderImage) {
72
+ $image = $this->_placeholderImage;
73
+ }
74
+ return $image;
75
+ }
76
+ }
app/code/local/TM/Testimonials/Block/List/Title.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_List_Title extends Mage_Core_Block_Template
4
+ {
5
+
6
+ }
app/code/local/TM/Testimonials/Block/Widget/Form.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Widget_Form extends TM_Testimonials_Block_Form_Form
4
+ implements Mage_Widget_Block_Interface
5
+ {
6
+ public function getTemplate()
7
+ {
8
+ $template = parent::getTemplate();
9
+ if (!$template) {
10
+ $template = 'tm/testimonials/form/form.phtml';
11
+ }
12
+ return $template;
13
+ }
14
+
15
+ protected function _prepareLayout()
16
+ {
17
+ $head = $this->getLayout()->getBlock('head');
18
+ if ($head) {
19
+ $head->addJs('mage/captcha.js');
20
+ }
21
+ $this->append(
22
+ $this->getLayout()->createBlock('captcha/captcha', 'captcha')
23
+ ->setFormId('testimonials_form')
24
+ ->setImgWidth(230)
25
+ ->setImgHeight(50)
26
+ );
27
+ return parent::_prepareLayout();
28
+ }
29
+ }
app/code/local/TM/Testimonials/Block/Widget/List.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Widget_List extends Mage_Core_Block_Template
4
+ implements Mage_Widget_Block_Interface
5
+ {
6
+
7
+ /**
8
+ * Initialize block's cache
9
+ */
10
+ protected function _construct()
11
+ {
12
+ parent::_construct();
13
+
14
+ $this->addData(array(
15
+ 'cache_lifetime' => false,
16
+ 'cache_tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
17
+ ));
18
+ }
19
+
20
+ /**
21
+ * Get Key pieces for caching block content
22
+ *
23
+ * @return array
24
+ */
25
+ public function getCacheKeyInfo()
26
+ {
27
+ return array(
28
+ 'TM_TESTIMONIALS_WIDGET_LIST',
29
+ Mage::app()->getStore()->getId(),
30
+ (int)Mage::app()->getStore()->isCurrentlySecure(),
31
+ Mage::getDesign()->getPackageName(),
32
+ Mage::getDesign()->getTheme('template'),
33
+ $this->getTemplate()
34
+ );
35
+ }
36
+
37
+ public function getTemplate()
38
+ {
39
+ $template = parent::getTemplate();
40
+ if (!$template) {
41
+ $template = 'tm/testimonials/widget/list.phtml';
42
+ }
43
+ return $template;
44
+ }
45
+
46
+ protected function _beforeToHtml()
47
+ {
48
+ $testimonials = Mage::getModel('tm_testimonials/data')->getCollection()
49
+ ->addFieldToFilter('status', TM_Testimonials_Model_Data::STATUS_ENABLED)
50
+ ->addStoreFilter(Mage::app()->getStore())
51
+ ->addFieldToFilter('widget', 1);
52
+
53
+ $testimonials->getSelect()
54
+ ->order(new Zend_Db_Expr('RAND()'))
55
+ ->limit($this->getItemsNumber());
56
+
57
+ $this->setTestimonials($testimonials);
58
+ return parent::_beforeToHtml();
59
+ }
60
+
61
+ protected function _toHtml()
62
+ {
63
+ if ($this->getTestimonials()) {
64
+ return parent::_toHtml();
65
+ }
66
+ return '';
67
+ }
68
+ }
app/code/local/TM/Testimonials/Block/Widget/ListFull.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Widget_ListFull extends TM_Testimonials_Block_List_Content
4
+ implements Mage_Widget_Block_Interface
5
+ {
6
+ /**
7
+ * Initialize block's cache
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+
13
+ $this->addData(array(
14
+ 'cache_lifetime' => false,
15
+ 'cache_tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
16
+ ));
17
+ }
18
+
19
+ /**
20
+ * Get Key pieces for caching block content
21
+ *
22
+ * @return array
23
+ */
24
+ public function getCacheKeyInfo()
25
+ {
26
+ return array(
27
+ 'TM_TESTIMONIALS_WIDGET_LISTFULL',
28
+ Mage::app()->getStore()->getId(),
29
+ (int)Mage::app()->getStore()->isCurrentlySecure(),
30
+ Mage::getDesign()->getPackageName(),
31
+ Mage::getDesign()->getTheme('template'),
32
+ $this->getTemplate()
33
+ );
34
+ }
35
+
36
+ public function getTemplate()
37
+ {
38
+ $template = parent::getTemplate();
39
+ if (!$template) {
40
+ $template = 'tm/testimonials/list/content.phtml';
41
+ }
42
+ return $template;
43
+ }
44
+
45
+ protected function _afterToHtml($html)
46
+ {
47
+ $titleBlock = $this->getLayout()
48
+ ->createBlock('testimonials/list_title')
49
+ ->setTemplate('tm/testimonials/list/title.phtml')
50
+ ->setShowTitle($this->getShowTitle())
51
+ ->toHtml();
52
+
53
+ $bottomBlock = $this->getLayout()
54
+ ->createBlock('testimonials/list_bottom')
55
+ ->setTemplate('tm/testimonials/list/bottom.phtml')
56
+ ->toHtml();
57
+
58
+ return $titleBlock . $html . $bottomBlock;
59
+ }
60
+
61
+ public function getShowTitle()
62
+ {
63
+ return (bool) $this->_getData('show_title');
64
+ }
65
+ }
app/code/local/TM/Testimonials/Block/Widget/Review.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Block_Widget_Review extends Mage_Core_Block_Template
4
+ implements Mage_Widget_Block_Interface
5
+ {
6
+ /**
7
+ * Initialize block's cache
8
+ */
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+
13
+ $this->addData(array(
14
+ 'cache_lifetime' => false,
15
+ 'cache_tags' => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
16
+ ));
17
+ }
18
+
19
+ /**
20
+ * Get Key pieces for caching block content
21
+ *
22
+ * @return array
23
+ */
24
+ public function getCacheKeyInfo()
25
+ {
26
+ return array(
27
+ 'TM_TESTIMONIALS_WIDGET_REVIEW',
28
+ Mage::app()->getStore()->getId(),
29
+ (int)Mage::app()->getStore()->isCurrentlySecure(),
30
+ Mage::getDesign()->getPackageName(),
31
+ Mage::getDesign()->getTheme('template'),
32
+ $this->getTemplate()
33
+ );
34
+ }
35
+
36
+ public function getTemplate()
37
+ {
38
+ $template = parent::getTemplate();
39
+ if (!$template) {
40
+ $template = 'tm/testimonials/widget/review.phtml';
41
+ }
42
+ return $template;
43
+ }
44
+
45
+ protected function _beforeToHtml()
46
+ {
47
+ $testimonials = Mage::getModel('tm_testimonials/data')->getCollection()
48
+ ->addFieldToFilter('rating', array("gt" => 0));
49
+
50
+ if ($testimonials) {
51
+ $total = 0;
52
+ foreach ($testimonials as $testimonial) {
53
+ $total += (int)$testimonial->getRating();
54
+ }
55
+ $avgRating = $total / $testimonials->getSize();
56
+ }
57
+ $this->setTestimonials($testimonials);
58
+ $this->setAvgRating(number_format($avgRating, 2));
59
+
60
+ return parent::_beforeToHtml();
61
+ }
62
+
63
+ protected function _toHtml()
64
+ {
65
+ if ($this->getTestimonials()) {
66
+ return parent::_toHtml();
67
+ }
68
+ return '';
69
+ }
70
+ }
app/code/local/TM/Testimonials/Helper/Data.php ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ /**
5
+ * Path to store config if frontend output is enabled
6
+ *
7
+ * @var string
8
+ */
9
+ const XML_PATH_ENABLED = 'testimonials/general/enabled';
10
+ /**
11
+ * Path to store config of testimonial auto approve
12
+ *
13
+ * @var string
14
+ */
15
+ const XML_PATH_APPROVE = 'testimonials/general/approve';
16
+ /**
17
+ * Path to store config for testimonials list layout
18
+ *
19
+ * @var string
20
+ */
21
+ const XML_LIST_LAYOUT = 'testimonials/list/layout';
22
+ /**
23
+ * Path to store config where count of news posts per page is stored
24
+ *
25
+ * @var string
26
+ */
27
+ const XML_PATH_ITEMS_PER_PAGE = 'testimonials/list/items_per_page';
28
+ /**
29
+ * Path to store config testimonial image width
30
+ *
31
+ * @var string
32
+ */
33
+ const XML_PATH_IMAGE_W = 'testimonials/list/image_width';
34
+ /**
35
+ * Path to store config testimonial image height
36
+ *
37
+ * @var string
38
+ */
39
+ const XML_PATH_IMAGE_H = 'testimonials/list/image_height';
40
+ /**
41
+ * Path to store config for placeholder image
42
+ *
43
+ * @var string
44
+ */
45
+ const XML_PLACEHOLDER_IMAGE = 'testimonials/list/placeholder_image';
46
+ /**
47
+ * Path to store config for show user email in list
48
+ *
49
+ * @var string
50
+ */
51
+ const XML_LIST_EMAIL = 'testimonials/list/show_email';
52
+ /**
53
+ * Path to store config for testimonials form layout
54
+ *
55
+ * @var string
56
+ */
57
+ const XML_FORM_LAYOUT = 'testimonials/form/layout';
58
+ /**
59
+ * Path to store config company field enabled
60
+ *
61
+ * @var string
62
+ */
63
+ const XML_COMPANY_ENABLED = 'testimonials/form/enable_company';
64
+ /**
65
+ * Path to store config website field enabled
66
+ *
67
+ * @var string
68
+ */
69
+ const XML_WEBSITE_ENABLED = 'testimonials/form/enable_website';
70
+ /**
71
+ * Path to store config twitter field enabled
72
+ *
73
+ * @var string
74
+ */
75
+ const XML_TWITTER_ENABLED = 'testimonials/form/enable_twitter';
76
+ /**
77
+ * Path to store config facebook field enabled
78
+ *
79
+ * @var string
80
+ */
81
+ const XML_FACEBOOK_ENABLED = 'testimonials/form/enable_facebook';
82
+ /**
83
+ * Path to store config sent message
84
+ *
85
+ * @var string
86
+ */
87
+ const XML_SENT_MESSAGE = 'testimonials/form/sent_message';
88
+ /**
89
+ * Path to store config admin email notification enable
90
+ *
91
+ * @var string
92
+ */
93
+ const XML_ADMIN_EMAIL_ENABLED = 'testimonials/email_admin/send_enable';
94
+ /**
95
+ * Path to store config send email for admin from
96
+ *
97
+ * @var string
98
+ */
99
+ const XML_ADMIN_EMAIL_SEND_FROM = 'testimonials/email_admin/send_from';
100
+ /**
101
+ * Path to store config admin email
102
+ *
103
+ * @var string
104
+ */
105
+ const XML_ADMIN_EMAIL = 'testimonials/email_admin/admin_email';
106
+ /**
107
+ * Path to store config admin email subject
108
+ *
109
+ * @var string
110
+ */
111
+ const XML_ADMIN_EMAIL_SUBJECT = 'testimonials/email_admin/email_subject';
112
+ /**
113
+ * Path to store config admin email template
114
+ *
115
+ * @var string
116
+ */
117
+ const XML_ADMIN_EMAIL_TEMPLATE = 'testimonials/email_admin/email_template';
118
+
119
+ /**
120
+ * Checks whether testimonials can be displayed in the frontend
121
+ *
122
+ * @param integer|string|Mage_Core_Model_Store $store
123
+ * @return boolean
124
+ */
125
+ public function isEnabled($store = null)
126
+ {
127
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
128
+ }
129
+ /**
130
+ * Return the number of items per page
131
+ *
132
+ * @param integer|string|Mage_Core_Model_Store $store
133
+ * @return int
134
+ */
135
+ public function getTestimonialsPerPage($store = null)
136
+ {
137
+ return abs((int)Mage::getStoreConfig(self::XML_PATH_ITEMS_PER_PAGE, $store));
138
+ }
139
+ /**
140
+ * Return testimonial image width
141
+ *
142
+ * @param integer|string|Mage_Core_Model_Store $store
143
+ * @return int
144
+ */
145
+ public function getImageWidth($store = null)
146
+ {
147
+ return abs((int)Mage::getStoreConfig(self::XML_PATH_IMAGE_W, $store));
148
+ }
149
+ /**
150
+ * Return testimonial image height
151
+ *
152
+ * @param integer|string|Mage_Core_Model_Store $store
153
+ * @return int
154
+ */
155
+ public function getImageHeight($store = null)
156
+ {
157
+ return abs((int)Mage::getStoreConfig(self::XML_PATH_IMAGE_H, $store));
158
+ }
159
+ /**
160
+ * Checks whether company field enabled
161
+ *
162
+ * @param integer|string|Mage_Core_Model_Store $store
163
+ * @return boolean
164
+ */
165
+ public function isCompanyEnabled($store = null)
166
+ {
167
+ return Mage::getStoreConfigFlag(self::XML_COMPANY_ENABLED, $store);
168
+ }
169
+ /**
170
+ * Checks whether website field enabled
171
+ *
172
+ * @param integer|string|Mage_Core_Model_Store $store
173
+ * @return boolean
174
+ */
175
+ public function isWebsiteEnabled($store = null)
176
+ {
177
+ return Mage::getStoreConfigFlag(self::XML_WEBSITE_ENABLED, $store);
178
+ }
179
+ /**
180
+ * Checks whether twitter field enabled
181
+ *
182
+ * @param integer|string|Mage_Core_Model_Store $store
183
+ * @return boolean
184
+ */
185
+ public function isTwitterEnabled($store = null)
186
+ {
187
+ return Mage::getStoreConfigFlag(self::XML_TWITTER_ENABLED, $store);
188
+ }
189
+ /**
190
+ * Checks whether facebook field enabled
191
+ *
192
+ * @param integer|string|Mage_Core_Model_Store $store
193
+ * @return boolean
194
+ */
195
+ public function isFacebookEnabled($store = null)
196
+ {
197
+ return Mage::getStoreConfigFlag(self::XML_FACEBOOK_ENABLED, $store);
198
+ }
199
+ /**
200
+ * Return testimonial sent message
201
+ *
202
+ * @param integer|string|Mage_Core_Model_Store $store
203
+ * @return String
204
+ */
205
+ public function getSentMessage($store = null)
206
+ {
207
+ return Mage::getStoreConfig(self::XML_SENT_MESSAGE, $store);
208
+ }
209
+ /**
210
+ * Return testimonial placeholder image
211
+ *
212
+ * @param integer|string|Mage_Core_Model_Store $store
213
+ * @return String
214
+ */
215
+ public function getPlaceholderImage($store = null)
216
+ {
217
+ return Mage::getStoreConfig(self::XML_PLACEHOLDER_IMAGE, $store);
218
+ }
219
+ /**
220
+ * Checks whether user mail should be displayed in testimonials list
221
+ *
222
+ * @param integer|string|Mage_Core_Model_Store $store
223
+ * @return boolean
224
+ */
225
+ public function showUserEmail($store = null)
226
+ {
227
+ return Mage::getStoreConfigFlag(self::XML_LIST_EMAIL, $store);
228
+ }
229
+ /**
230
+ * Return facebook icon path
231
+ * @return String
232
+ */
233
+ public function getFacebookIcon()
234
+ {
235
+ return Mage::getBaseUrl('media') . 'testimonials/pictures/facebook.png';
236
+ }
237
+ /**
238
+ * Return twitter icon path
239
+ * @return String
240
+ */
241
+ public function getTwitterIcon()
242
+ {
243
+ return Mage::getBaseUrl('media') . 'testimonials/pictures/twitter.png';
244
+ }
245
+ /**
246
+ * Return testimonials list layout
247
+ * @return String
248
+ */
249
+ public function getListLayout($store = null)
250
+ {
251
+ return Mage::getStoreConfig(self::XML_LIST_LAYOUT, $store);
252
+ }
253
+ /**
254
+ * Return testimonials form layout
255
+ * @return String
256
+ */
257
+ public function getFormLayout($store = null)
258
+ {
259
+ return Mage::getStoreConfig(self::XML_FORM_LAYOUT, $store);
260
+ }
261
+ /**
262
+ * Checks whether testimonials should be approved automatically
263
+ *
264
+ * @param integer|string|Mage_Core_Model_Store $store
265
+ * @return boolean
266
+ */
267
+ public function isAutoApprove($store = null)
268
+ {
269
+ return Mage::getStoreConfigFlag(self::XML_PATH_APPROVE, $store);
270
+ }
271
+ /**
272
+ * Checks if send email for admin enabled
273
+ *
274
+ * @param integer|string|Mage_Core_Model_Store $store
275
+ * @return boolean
276
+ */
277
+ public function isAdminNotificationEnabled($store = null)
278
+ {
279
+ return Mage::getStoreConfigFlag(self::XML_ADMIN_EMAIL_ENABLED, $store);
280
+ }
281
+ /**
282
+ * Return admin email send from contact
283
+ *
284
+ * @param integer|string|Mage_Core_Model_Store $store
285
+ * @return String
286
+ */
287
+ public function getAdminNotificationSendFrom($store = null)
288
+ {
289
+ return Mage::getStoreConfig(self::XML_ADMIN_EMAIL_SEND_FROM, $store);
290
+ }
291
+ /**
292
+ * Return admin email
293
+ *
294
+ * @param integer|string|Mage_Core_Model_Store $store
295
+ * @return String
296
+ */
297
+ public function getAdminEmail($store = null)
298
+ {
299
+ return Mage::getStoreConfig(self::XML_ADMIN_EMAIL, $store);
300
+ }
301
+ /**
302
+ * Return admin email subject
303
+ *
304
+ * @param integer|string|Mage_Core_Model_Store $store
305
+ * @return String
306
+ */
307
+ public function getAdminEmailSubject($store = null)
308
+ {
309
+ return Mage::getStoreConfig(self::XML_ADMIN_EMAIL_SUBJECT, $store);
310
+ }
311
+ /**
312
+ * Return admin email template
313
+ *
314
+ * @param integer|string|Mage_Core_Model_Store $store
315
+ * @return String
316
+ */
317
+ public function getAdminEmailTemplate($store = null)
318
+ {
319
+ return Mage::getStoreConfig(self::XML_ADMIN_EMAIL_TEMPLATE, $store);
320
+ }
321
+ }
app/code/local/TM/Testimonials/Helper/Image.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Helper_Image extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ protected $_image;
7
+
8
+ public function init($image, $mode = 'image')
9
+ {
10
+ $this->_image = $image;
11
+ return $this;
12
+ }
13
+
14
+ public function resize($width, $height)
15
+ {
16
+ if (!$imageUrl = $this->getImageUrl()) {
17
+ return '';
18
+ }
19
+
20
+ $dir = Mage::getBaseDir('media')
21
+ . DS . "testimonials"
22
+ . DS . "pictures"
23
+ . DS . "resized";
24
+
25
+ if (!file_exists($dir)) {
26
+ mkdir($dir, 0777);
27
+ };
28
+
29
+ $imageName = substr(strrchr($imageUrl, "/"), 1);
30
+ $imageName = $width . '_' . $height . '_' . $imageName;
31
+
32
+ $imageResized = $dir . DS . $imageName;
33
+
34
+ $imagePath = str_replace(Mage::getBaseUrl('media'), 'media/', $imageUrl);
35
+ $imagePath = Mage::getBaseDir() . DS . str_replace("/", DS, $imagePath);
36
+
37
+ if (!file_exists($imageResized) && file_exists($imagePath)) {
38
+ $imageObj = new Varien_Image($imagePath);
39
+ $imageObj->constrainOnly(true);
40
+ $imageObj->keepAspectRatio(true);
41
+ $imageObj->keepFrame(false);
42
+ $imageObj->keepTransparency(true);
43
+ $imageObj->resize($width, $height);
44
+ $imageObj->save($imageResized);
45
+ }
46
+ $imageUrl = Mage::getBaseUrl('media')
47
+ . "testimonials/pictures/resized/"
48
+ . $imageName;
49
+
50
+ return $imageUrl;
51
+ }
52
+
53
+ public function getImageUrl()
54
+ {
55
+ $image = $this->_image;
56
+ if (empty($image)) {
57
+ return false;
58
+ }
59
+ return Mage::getBaseUrl('media')
60
+ . 'testimonials/pictures/'
61
+ . trim($image, '/');
62
+ }
63
+ }
app/code/local/TM/Testimonials/Model/Data.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Model_Data extends Mage_Core_Model_Abstract
3
+ {
4
+ /**
5
+ * Testimonial's Statuses
6
+ */
7
+ const STATUS_AWAITING_APPROVAL = 1;
8
+ const STATUS_ENABLED = 2;
9
+ const STATUS_DISABLED = 3;
10
+
11
+ const IMAGE_PATH = '/testimonials/pictures/';
12
+
13
+ public function __construct()
14
+ {
15
+ $this->_init('tm_testimonials/data');
16
+ parent::_construct();
17
+ }
18
+
19
+ /**
20
+ * Prepare testimonial's statuses.
21
+ *
22
+ * @return array
23
+ */
24
+ public function getAvailableStatuses()
25
+ {
26
+ $statuses = new Varien_Object(array(
27
+ self::STATUS_AWAITING_APPROVAL => Mage::helper('testimonials')->__('Awaiting approval'),
28
+ self::STATUS_ENABLED => Mage::helper('cms')->__('Enabled'),
29
+ self::STATUS_DISABLED => Mage::helper('cms')->__('Disabled')
30
+ ));
31
+
32
+ Mage::dispatchEvent('testimonials_data_get_available_statuses', array('statuses' => $statuses));
33
+
34
+ return $statuses->getData();
35
+ }
36
+ }
app/code/local/TM/Testimonials/Model/Observer.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Model_Observer
3
+ {
4
+ /**
5
+ * Get Captcha String
6
+ *
7
+ * @param Varien_Object $request
8
+ * @param string $formId
9
+ * @return string
10
+ */
11
+ protected function _getCaptchaString($request, $formId)
12
+ {
13
+ $captchaParams = $request->getPost(Mage_Captcha_Helper_Data::INPUT_NAME_FIELD_VALUE);
14
+ return $captchaParams[$formId];
15
+ }
16
+
17
+ /**
18
+ * Break the execution in case of incorrect CAPTCHA
19
+ *
20
+ * @param Varien_Event_Observer $observer
21
+ * @return TM_Testimonials_Model_Observer
22
+ */
23
+ public function checkCaptcha($observer)
24
+ {
25
+ $formId = 'testimonials_form';
26
+ $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
27
+ if ($captchaModel->isRequired()) {
28
+ $controller = $observer->getControllerAction();
29
+ if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
30
+ Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
31
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
32
+ Mage::getSingleton('customer/session')->setTestimonialsFormData($controller->getRequest()->getPost());
33
+ $url = Mage::helper('core/http')->getHttpReferer() ?
34
+ Mage::helper('core/http')->getHttpReferer() :
35
+ Mage::getUrl();
36
+ $controller->getResponse()->setRedirect($url);
37
+ }
38
+ }
39
+
40
+ return $this;
41
+ }
42
+ /**
43
+ * Send notification for admin about new testimonial added
44
+ *
45
+ * @param Varien_Event_Observer $observer
46
+ * @return TM_Testimonials_Model_Observer
47
+ */
48
+ public function sendNotificationToAdmin(Varien_Event_Observer $observer)
49
+ {
50
+ if (!Mage::helper('testimonials')->isAdminNotificationEnabled()) {
51
+ return $this;
52
+ }
53
+
54
+ $emailData = $observer->getEvent()->getTestimonial();
55
+ $adminEmail = Mage::helper('testimonials')->getAdminEmail();
56
+ $subject = Mage::helper('testimonials')->getAdminEmailSubject();
57
+ $templateId = Mage::helper('testimonials')->getAdminEmailTemplate();
58
+ $senderId = Mage::helper('testimonials')->getAdminNotificationSendFrom();
59
+
60
+ $storeId = Mage::app()->getStore()->getId();
61
+ $image = $emailData['image'] ? Mage::helper('testimonials')->__("Yes") :
62
+ Mage::helper('testimonials')->__("No");
63
+ $statuses = Mage::getModel('tm_testimonials/data')->getAvailableStatuses();
64
+ $status = $statuses[isset($emailData['status']) ? $emailData['status'] : TM_Testimonials_Model_Data::STATUS_AWAITING_APPROVAL];
65
+ $vars = array(
66
+ 'admin_subject' => $subject,
67
+ 'user_name' => $emailData['name'],
68
+ 'user_email' => $emailData['email'],
69
+ 'message' => $emailData['message'],
70
+ 'company' => isset($emailData['company']) ? $emailData['company'] : '',
71
+ 'website' => isset($emailData['website']) ? $emailData['website'] : '',
72
+ 'facebook' => isset($emailData['facebook']) ? $emailData['facebook'] : '',
73
+ 'twitter' => isset($emailData['twitter']) ? $emailData['twitter'] : '',
74
+ 'rating' => isset($emailData['rating']) ? $emailData['rating'] : -1,
75
+ 'image' => $image,
76
+ 'status' => $status,
77
+ 'store_view' => Mage::app()->getStore()->getFrontendName()
78
+ );
79
+
80
+ $translate = Mage::getSingleton('core/translate');
81
+ $translate->setTranslateInline(false);
82
+
83
+ $mailTemplate = Mage::getModel('core/email_template');
84
+ $mailTemplate->setTemplateSubject($subject)
85
+ ->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))
86
+ ->sendTransactional(
87
+ $templateId,
88
+ $senderId,
89
+ $adminEmail,
90
+ Mage::helper('testimonials')->__('Store Administrator'),
91
+ $vars
92
+ );
93
+
94
+ $translate->setTranslateInline(true);
95
+
96
+ return $this;
97
+ }
98
+ }
app/code/local/TM/Testimonials/Model/Resource/Data.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Model_Resource_Data extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('tm_testimonials/data','testimonial_id');
8
+ }
9
+
10
+ /**
11
+ * Perform operations before object save
12
+ *
13
+ * @param Mage_Cms_Model_Block $object
14
+ * @return TM_Testimonials_Model_Resource_Data
15
+ */
16
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
17
+ {
18
+ if (!$object->getId() && !$object->getDate()) {
19
+ $object->setDate(Mage::getSingleton('core/date')->gmtDate());
20
+ }
21
+ return $this;
22
+ }
23
+
24
+ /**
25
+ * Assign page to store views
26
+ *
27
+ * @param Mage_Core_Model_Abstract $object
28
+ * @return TM_Testimonials_Model_Resource
29
+ */
30
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
31
+ {
32
+ $oldStores = $this->lookupStoreIds($object->getId());
33
+ $newStores = (array)$object->getStores();
34
+ if (empty($newStores)) {
35
+ $newStores = (array)$object->getStoreId();
36
+ }
37
+ $table = $this->getTable('tm_testimonials/store');
38
+ $insert = array_diff($newStores, $oldStores);
39
+ $delete = array_diff($oldStores, $newStores);
40
+
41
+ if ($delete) {
42
+ $where = array(
43
+ 'testimonial_id = ?' => (int) $object->getId(),
44
+ 'store_id IN (?)' => $delete
45
+ );
46
+ $this->_getWriteAdapter()->delete($table, $where);
47
+ }
48
+
49
+ if ($insert) {
50
+ $data = array();
51
+ foreach ($insert as $storeId) {
52
+ $data[] = array(
53
+ 'testimonial_id' => (int) $object->getId(),
54
+ 'store_id' => (int) $storeId
55
+ );
56
+ }
57
+ $this->_getWriteAdapter()->insertMultiple($table, $data);
58
+ }
59
+
60
+ return parent::_afterSave($object);
61
+ }
62
+
63
+ /**
64
+ * Perform operations after object load
65
+ *
66
+ * @param Mage_Core_Model_Abstract $object
67
+ * @return TM_Testimonials_Model_Resource_Data
68
+ */
69
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
70
+ {
71
+ if ($object->getId()) {
72
+ $stores = $this->lookupStoreIds($object->getId());
73
+ $object->setData('store_id', $stores);
74
+ }
75
+ return parent::_afterLoad($object);
76
+ }
77
+
78
+ /**
79
+ * Retrieve select object for load object data
80
+ *
81
+ * @param string $field
82
+ * @param mixed $value
83
+ * @param TM_Testimonials_Model_Data $object
84
+ * @return Zend_Db_Select
85
+ */
86
+ protected function _getLoadSelect($field, $value, $object)
87
+ {
88
+ $select = parent::_getLoadSelect($field, $value, $object);
89
+
90
+ if ($object->getStoreId()) {
91
+ $storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
92
+ $select->join(
93
+ array('store' => $this->getTable('tm_testimonials/store')),
94
+ $this->getMainTable() . '.testimonial_id = store.testimonial_id',
95
+ array())
96
+ ->where('status = ?', 1)
97
+ ->where('store.store_id IN (?)', $storeIds)
98
+ ->order('store.store_id DESC')
99
+ ->limit(1);
100
+ }
101
+
102
+ return $select;
103
+ }
104
+
105
+ /**
106
+ * Get store ids to which specified item is assigned
107
+ *
108
+ * @param int $id
109
+ * @return array
110
+ */
111
+ public function lookupStoreIds($testimonialId)
112
+ {
113
+ $adapter = $this->_getReadAdapter();
114
+
115
+ $select = $adapter->select()
116
+ ->from($this->getTable('tm_testimonials/store'), 'store_id')
117
+ ->where('testimonial_id = ?',(int)$testimonialId);
118
+
119
+ return $adapter->fetchCol($select);
120
+ }
121
+ }
app/code/local/TM/Testimonials/Model/Resource/Data/Collection.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Model_Resource_Data_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('tm_testimonials/data');
8
+ $this->_map['fields']['testimonial_id'] = 'main_table.testimonial_id';
9
+ $this->_map['fields']['store'] = 'store_table.store_id';
10
+ }
11
+
12
+ /**
13
+ * Add filter by store
14
+ *
15
+ * @param int|Mage_Core_Model_Store $store
16
+ * @param bool $withAdmin
17
+ * @return TM_Testimonials_Model_Resource_Data_Collection
18
+ */
19
+ public function addStoreFilter($store, $withAdmin = true)
20
+ {
21
+ if (!$this->getFlag('store_filter_added')) {
22
+ if ($store instanceof Mage_Core_Model_Store) {
23
+ $store = array($store->getId());
24
+ }
25
+
26
+ if (!is_array($store)) {
27
+ $store = array($store);
28
+ }
29
+
30
+ if ($withAdmin) {
31
+ $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
32
+ }
33
+
34
+
35
+ $this->addFilter('store', array('in' => $store), 'public');
36
+ }
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Join store relation table if there is store filter
42
+ */
43
+ protected function _renderFiltersBefore()
44
+ {
45
+ if ($this->getFilter('store')) {
46
+ $this->getSelect()->join(
47
+ array('store_table' => $this->getTable('tm_testimonials/store')),
48
+ 'main_table.testimonial_id = store_table.testimonial_id',
49
+ array()
50
+ )->group('main_table.testimonial_id');
51
+
52
+ /*
53
+ * Allow analytic functions usage because of one field grouping
54
+ */
55
+ $this->_useAnalyticFunction = true;
56
+ }
57
+ return parent::_renderFiltersBefore();
58
+ }
59
+
60
+ /**
61
+ * Get SQL for get record count.
62
+ * Extra GROUP BY strip added.
63
+ *
64
+ * @return Varien_Db_Select
65
+ */
66
+ public function getSelectCountSql()
67
+ {
68
+ $countSelect = parent::getSelectCountSql();
69
+
70
+ $countSelect->reset(Zend_Db_Select::GROUP);
71
+
72
+ return $countSelect;
73
+ }
74
+ }
app/code/local/TM/Testimonials/Model/Resource/Setup.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
3
+
4
+ }
app/code/local/TM/Testimonials/Model/System/Config/Backend/Image.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TM_Testimonials_Model_System_Config_Backend_Image extends Mage_Adminhtml_Model_System_Config_Backend_Image
4
+ {
5
+ protected function _beforeSave()
6
+ {
7
+ if ($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value']) {
8
+ return parent::_beforeSave();
9
+ }
10
+
11
+ $value = $this->getValue();
12
+ if (is_array($value) && !empty($value['delete'])) {
13
+ $this->setValue('');
14
+ }
15
+ // fix to save default config value on the first save
16
+ /* else {
17
+ $this->unsValue();
18
+ }*/
19
+ return $this;
20
+ }
21
+ }
app/code/local/TM/Testimonials/controllers/Adminhtml/Testimonials/IndexController.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_Adminhtml_Testimonials_IndexController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ /**
5
+ * Init actions
6
+ *
7
+ */
8
+ protected function _initAction()
9
+ {
10
+ $this->loadLayout()
11
+ ->_setActiveMenu('templates_master/testimonials_index/index')
12
+ ->_addBreadcrumb(
13
+ Mage::helper('testimonials')->__('Testimonials'),
14
+ Mage::helper('testimonials')->__('Manage Testimonials')
15
+ );
16
+ return $this;
17
+ }
18
+
19
+ public function indexAction()
20
+ {
21
+ $this->_title($this->__('Templates Master'))
22
+ ->_title($this->__('Testimonials'))
23
+ ->_title($this->__('Manage Testimonials'));
24
+
25
+ $this->_initAction();
26
+ $this->renderLayout();
27
+ }
28
+
29
+ public function newAction()
30
+ {
31
+ // the same form is used to create and edit
32
+ $this->_forward('edit');
33
+ }
34
+
35
+ public function editAction()
36
+ {
37
+ $this->_title($this->__('Templates Master'))
38
+ ->_title($this->__('Testimonials'))
39
+ ->_title($this->__('Manage Testimonials'));
40
+
41
+ $id = $this->getRequest()->getParam('testimonial_id');
42
+ $model = Mage::getModel('tm_testimonials/data');
43
+
44
+ if ($id) {
45
+ $model->load($id);
46
+ if (! $model->getId()) {
47
+ Mage::getSingleton('adminhtml/session')->addError(
48
+ Mage::helper('cms')->__('This page no longer exists.'));
49
+ $this->_redirect('*/*/');
50
+ return;
51
+ }
52
+ }
53
+
54
+ $this->_title($model->getId() ? $model->getName() : $this->__('New Testimonial'));
55
+
56
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
57
+ if (! empty($data)) {
58
+ $model->setData($data);
59
+ }
60
+
61
+ Mage::register('testimonials_data', $model);
62
+
63
+ $this->_initAction()
64
+ ->_addBreadcrumb(
65
+ $id ? Mage::helper('testimonials')->__('Edit Testimonial')
66
+ : Mage::helper('testimonials')->__('New Testimonial'),
67
+ $id ? Mage::helper('testimonials')->__('Edit Testimonial')
68
+ : Mage::helper('testimonials')->__('New Testimonial'));
69
+
70
+ $this->renderLayout();
71
+ }
72
+ /**
73
+ * Save action
74
+ */
75
+ public function saveAction()
76
+ {
77
+ if (!$data = $this->getRequest()->getPost('testimonials')) {
78
+ $this->_redirect('*/*/');
79
+ return;
80
+ }
81
+
82
+ $model = Mage::getModel('tm_testimonials/data');
83
+ if ($id = $this->getRequest()->getParam('testimonial_id')) {
84
+ $model->load($id);
85
+ }
86
+
87
+ try {
88
+ $mediaPath = Mage::getBaseDir('media') . DS . TM_Testimonials_Model_Data::IMAGE_PATH;
89
+ if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
90
+ try {
91
+ $uploader = new Varien_File_Uploader('image');
92
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png', 'bmp'));
93
+ $uploader->setAllowRenameFiles(true);
94
+ $uploader->setFilesDispersion(true);
95
+ $res = $uploader->save($mediaPath);
96
+ $data['image'] = $uploader->getUploadedFileName();
97
+ } catch (Exception $e) {
98
+ $this->_getSession()->addError($e->getMessage());
99
+ }
100
+ }
101
+
102
+ if (isset($data['image']) && is_array($data['image'])) {
103
+ if (!empty($data['image']['delete'])) {
104
+ @unlink($mediaPath . $data['image']['value']);
105
+ $data['image'] = null;
106
+ } else {
107
+ $data['image'] = $data['image']['value'];
108
+ }
109
+ }
110
+
111
+ $model->addData($data);
112
+
113
+ $date = Mage::app()->getLocale()->date($data['date'], Zend_Date::DATE_SHORT, null, false);
114
+ $model->setDate($date->toString('YYYY-MM-dd HH:mm:ss'));
115
+
116
+ $model->save();
117
+
118
+ Mage::getSingleton('adminhtml/session')->addSuccess(
119
+ Mage::helper('testimonials')->__('Testimonial has been saved.')
120
+ );
121
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
122
+ if ($this->getRequest()->getParam('back')) {
123
+ $this->_redirect('*/*/edit', array('testimonial_id' => $model->getId(), '_current' => true));
124
+ return;
125
+ }
126
+ $this->_redirect('*/*/');
127
+ return;
128
+ } catch (Exception $e) {
129
+ $this->_getSession()->addError($e->getMessage());
130
+ }
131
+ $this->_getSession()->setFormData($data);
132
+ $this->_redirect('*/*/edit', array('testimonial_id' => $this->getRequest()->getParam('testimonial_id'), '_current'=>true));
133
+ }
134
+
135
+ /**
136
+ * Delete action
137
+ */
138
+ public function deleteAction()
139
+ {
140
+ if ($id = $this->getRequest()->getParam('testimonial_id')) {
141
+ try {
142
+ $model = Mage::getModel('tm_testimonials/data');
143
+ $model->load($id);
144
+ $model->delete();
145
+ Mage::getSingleton('adminhtml/session')->addSuccess(
146
+ Mage::helper('testimonials')->__('The testimonial has been deleted.'));
147
+ $this->_redirect('*/*/');
148
+ return;
149
+ } catch (Exception $e) {
150
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
151
+ $this->_redirect('*/*/edit', array('testimonial_id' => $id));
152
+ return;
153
+ }
154
+ }
155
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('testimonials')->__('Unable to find a testimonial to delete.'));
156
+ $this->_redirect('*/*/');
157
+ }
158
+
159
+ public function massDeleteAction()
160
+ {
161
+ $testimonialsIds = $this->getRequest()->getParam('testimonials');
162
+ if (!is_array($testimonialsIds)) {
163
+ $this->_getSession()->addError($this->__('Please select testimonial(s).'));
164
+ } else {
165
+ if (!empty($testimonialsIds)) {
166
+ try {
167
+ foreach ($testimonialsIds as $testimonialId) {
168
+ $testimonial = Mage::getModel('tm_testimonials/data')->load($testimonialId);
169
+ $testimonial->delete();
170
+ }
171
+ $this->_getSession()->addSuccess(
172
+ $this->__('Total of %d record(s) have been deleted.', count($testimonialsIds))
173
+ );
174
+ } catch (Exception $e) {
175
+ $this->_getSession()->addError($e->getMessage());
176
+ }
177
+ }
178
+ }
179
+ $this->_redirect('*/*/index');
180
+ }
181
+
182
+ public function massStatusAction()
183
+ {
184
+ $testimonialsIds = (array)$this->getRequest()->getParam('testimonials');
185
+ $status = (int)$this->getRequest()->getParam('status');
186
+ try {
187
+ foreach ($testimonialsIds as $testimonialId) {
188
+ $testimonial = Mage::getModel('tm_testimonials/data')->load($testimonialId);
189
+ $testimonial->setStatus($status)->save();
190
+ }
191
+
192
+ $this->_getSession()->addSuccess(
193
+ $this->__('Total of %d record(s) have been updated.', count($testimonialsIds))
194
+ );
195
+ }
196
+ catch (Mage_Core_Model_Exception $e) {
197
+ $this->_getSession()->addError($e->getMessage());
198
+ } catch (Mage_Core_Exception $e) {
199
+ $this->_getSession()->addError($e->getMessage());
200
+ } catch (Exception $e) {
201
+ $this->_getSession()
202
+ ->addException($e, $this->__('An error occurred while updating the product(s) status.'));
203
+ }
204
+
205
+ $this->_redirect('*/*/');
206
+ }
207
+
208
+ public function approveAction()
209
+ {
210
+ $model = Mage::getModel('tm_testimonials/data');
211
+ if ($id = $this->getRequest()->getParam('testimonial_id')) {
212
+ $model->load($id);
213
+ }
214
+
215
+ try {
216
+ $model->setStatus(TM_Testimonials_Model_Data::STATUS_ENABLED);
217
+ $model->save();
218
+
219
+ Mage::getSingleton('adminhtml/session')->addSuccess(
220
+ Mage::helper('testimonials')->__('Testimonial approved.')
221
+ );
222
+ $this->_redirect('*/*/');
223
+ return;
224
+ } catch (Exception $e) {
225
+ $this->_getSession()->addError($e->getMessage());
226
+ }
227
+ $this->_redirect('*/*/edit', array('testimonial_id' => $this->getRequest()->getParam('testimonial_id'), '_current'=>true));
228
+ }
229
+
230
+ /**
231
+ * Check the permission to run it
232
+ *
233
+ * @return boolean
234
+ */
235
+ protected function _isAllowed()
236
+ {
237
+ switch ($this->getRequest()->getActionName()) {
238
+ case 'new':
239
+ case 'save':
240
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/save');
241
+ break;
242
+ case 'delete':
243
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/delete');
244
+ break;
245
+ case 'approve':
246
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials/approve');
247
+ break;
248
+ default:
249
+ return Mage::getSingleton('admin/session')->isAllowed('templates_master/testimonials/testimonials');
250
+ break;
251
+ }
252
+ }
253
+ }
app/code/local/TM/Testimonials/controllers/IndexController.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TM_Testimonials_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ /**
5
+ * Pre dispatch action that allows to redirect to no route page in case
6
+ * of disabled extension through Admin panel
7
+ */
8
+ public function preDispatch()
9
+ {
10
+ parent::preDispatch();
11
+
12
+ if (!Mage::helper('testimonials')->isEnabled()) {
13
+ $this->setFlag('', 'no-dispatch', true);
14
+ $this->_redirect('noRoute');
15
+ }
16
+ }
17
+
18
+ public function indexAction()
19
+ {
20
+ $layout = $this->loadLayout()->getLayout();
21
+ $isAjax = Mage::app()->getRequest()->isAjax();
22
+ if ($isAjax) {
23
+ $currentPage = (int)$this->getRequest()->getParam('page', 1);
24
+ $output = $layout->getBlock('testimonials.list.content')
25
+ ->setCurrentPage($currentPage)
26
+ ->setIsAjax(true)
27
+ ->toHtml();
28
+ $this->getResponse()->setBody(
29
+ Mage::helper('core')->jsonEncode(array('outputHtml' => $output))
30
+ );
31
+ } else {
32
+ $this->getLayout()->getBlock('head')->setTitle(
33
+ Mage::helper('testimonials')->__('Testimonials')
34
+ );
35
+ //apply custom layout from config
36
+ $this->getLayout()->getBlock('root')
37
+ ->helper('page/layout')
38
+ ->applyTemplate(Mage::helper('testimonials')->getListLayout());
39
+ $this->renderLayout();
40
+ }
41
+ }
42
+
43
+ public function newAction()
44
+ {
45
+ $this->loadLayout();
46
+ $this->_initLayoutMessages('customer/session');
47
+ $this->_initLayoutMessages('catalog/session');
48
+ $this->getLayout()->getBlock('head')->setTitle(
49
+ Mage::helper('testimonials')->__('New Testimonial')
50
+ );
51
+ //apply custom layout from config
52
+ $this->getLayout()->getBlock('root')
53
+ ->helper('page/layout')
54
+ ->applyTemplate(Mage::helper('testimonials')->getFormLayout());
55
+ $this->renderLayout();
56
+ }
57
+
58
+ public function postAction()
59
+ {
60
+ $this->_initLayoutMessages('customer/session');
61
+ // check if data sent
62
+ if ($data = $this->getRequest()->getPost()) {
63
+ $model = Mage::getModel('tm_testimonials/data');
64
+
65
+ $model->setStoreId(Mage::app()->getStore()->getStoreId());
66
+ $model->setName($data['name']);
67
+ $model->setEmail($data['email']);
68
+ $model->setMessage($data['message']);
69
+ $model->setCompany(isset($data['company']) ? $data['company'] : '');
70
+ $model->setWebsite(isset($data['website']) ? $data['website'] : '');
71
+ $model->setTwitter(isset($data['twitter']) ? $data['twitter'] : '');
72
+ $model->setFacebook(isset($data['facebook']) ? $data['facebook'] : '');
73
+ if (isset($data['rating'])) $model->setRating($data['rating']);
74
+ if (Mage::helper('testimonials')->isAutoApprove())
75
+ $model->setStatus(TM_Testimonials_Model_Data::STATUS_ENABLED);
76
+
77
+ // upload image
78
+ if (isset($_FILES['image']['name']) && ($_FILES['image']['tmp_name'] != NULL)) {
79
+ $path = Mage::getBaseDir('media') . TM_Testimonials_Model_Data::IMAGE_PATH;
80
+ try {
81
+ $uploader = new Varien_File_Uploader('image');
82
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
83
+ $uploader->setAllowRenameFiles(true);
84
+ $uploader->setFilesDispersion(true);
85
+ $uploader->save($path, $_FILES['image']['name']);
86
+ $uploadedImg = $uploader->getUploadedFileName();
87
+ $model->setImage($uploadedImg);
88
+ } catch (Exception $e) {
89
+ Mage::getSingleton('customer/session')->addError($e->getMessage());
90
+ Mage::getSingleton('customer/session')->setTestimonialsFormData($data);
91
+ $this->_redirectReferer();
92
+ return;
93
+ }
94
+ }
95
+
96
+ // try to save form data
97
+ try {
98
+ $model->save();
99
+ Mage::getSingleton('customer/session')->
100
+ addSuccess(Mage::helper('testimonials')->
101
+ getSentMessage());
102
+ Mage::getSingleton('customer/session')->unsTestimonialsFormData();
103
+
104
+ // send email notification to admin
105
+ try {
106
+ $data['status'] = $model->getStatus();
107
+ $data['image'] = $model->getImage();
108
+ Mage::dispatchEvent('testimonials_notify_admin_testimonial_submit',
109
+ array( 'testimonial' => $data )
110
+ );
111
+ } catch (Mage_Core_Exception $e) {
112
+ Mage::getSingleton('customer/session')->addError(
113
+ $e->getMessage()
114
+ );
115
+ }
116
+ } catch (Exception $e) {
117
+ Mage::getSingleton('customer/session')->addError($e->getMessage());
118
+ Mage::getSingleton('customer/session')->setTestimonialsFormData($data);
119
+ $this->_redirectReferer();
120
+ return;
121
+ }
122
+ }
123
+ $this->_redirectReferer();
124
+ }
125
+ }
app/code/local/TM/Testimonials/etc/adminhtml.xml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <templates_master>
5
+ <title>Templates Master</title>
6
+ <sort_order>71</sort_order>
7
+ <children>
8
+ <testimonials translate="title" module="testimonials">
9
+ <title>Testimonials</title>
10
+ <sort_order>2021</sort_order>
11
+ <children>
12
+ <testimonials>
13
+ <title>Manage Testimonials</title>
14
+ <sort_order>10</sort_order>
15
+ <action>adminhtml/testimonials_index/index</action>
16
+ </testimonials>
17
+ </children>
18
+ </testimonials>
19
+ </children>
20
+ </templates_master>
21
+ </menu>
22
+ <acl>
23
+ <resources>
24
+ <admin>
25
+ <children>
26
+ <system>
27
+ <children>
28
+ <config>
29
+ <children>
30
+ <testimonials translate="title" module="testimonials">
31
+ <title>Testimonials Settings</title>
32
+ </testimonials>
33
+ </children>
34
+ </config>
35
+ </children>
36
+ </system>
37
+ <templates_master>
38
+ <title>Templates Master</title>
39
+ <sort_order>71</sort_order>
40
+ <children>
41
+ <testimonials translate="title" module="testimonials">
42
+ <title>Testimonials</title>
43
+ <sort_order>20</sort_order>
44
+ <children>
45
+ <testimonials>
46
+ <title>Manage Testimonials</title>
47
+ <sort_order>10</sort_order>
48
+ <children>
49
+ <save translate="title">
50
+ <title>Save</title>
51
+ <sort_order>0</sort_order>
52
+ </save>
53
+ <delete translate="title">
54
+ <title>Delete</title>
55
+ <sort_order>10</sort_order>
56
+ </delete>
57
+ <approve translate="title">
58
+ <title>Approve</title>
59
+ <sort_order>10</sort_order>
60
+ </approve>
61
+ </children>
62
+ </testimonials>
63
+ </children>
64
+ </testimonials>
65
+ </children>
66
+ </templates_master>
67
+ </children>
68
+ </admin>
69
+ </resources>
70
+ </acl>
71
+ </config>
app/code/local/TM/Testimonials/etc/config.xml ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <TM_Testimonials>
5
+ <version>1.0.1</version>
6
+ </TM_Testimonials>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <tm_testimonials>
11
+ <class>TM_Testimonials_Model</class>
12
+ <resourceModel>tm_testimonials_resource</resourceModel>
13
+ </tm_testimonials>
14
+ <tm_testimonials_resource>
15
+ <class>TM_Testimonials_Model_Resource</class>
16
+ <entities>
17
+ <data>
18
+ <table>tm_testimonials_data</table>
19
+ </data>
20
+ <store>
21
+ <table>tm_testimonials_store</table>
22
+ </store>
23
+ </entities>
24
+ </tm_testimonials_resource>
25
+ </models>
26
+ <resources>
27
+ <tm_testimonials_setup>
28
+ <setup>
29
+ <module>TM_Testimonials</module>
30
+ <class>TM_Testimonials_Model_Resource_Setup</class>
31
+ </setup>
32
+ </tm_testimonials_setup>
33
+ <testimonials_write>
34
+ <connection>
35
+ <use>core_write</use>
36
+ </connection>
37
+ </testimonials_write>
38
+ <testimonials_read>
39
+ <connection>
40
+ <use>core_read</use>
41
+ </connection>
42
+ </testimonials_read>
43
+ </resources>
44
+ <blocks>
45
+ <testimonials>
46
+ <class>TM_Testimonials_Block</class>
47
+ </testimonials>
48
+ </blocks>
49
+ <helpers>
50
+ <testimonials>
51
+ <class>TM_Testimonials_Helper</class>
52
+ </testimonials>
53
+ </helpers>
54
+ <template>
55
+ <email>
56
+ <testimonials_email_admin_email_template translate="label"
57
+ module="testimonials">
58
+ <label>Testimonials Administrator Notification</label>
59
+ <file>testimonials_admin_notification.html</file>
60
+ <type>html</type>
61
+ </testimonials_email_admin_email_template>
62
+ </email>
63
+ </template>
64
+ </global>
65
+ <frontend>
66
+ <routers>
67
+ <tm_testimonials>
68
+ <use>standard</use>
69
+ <args>
70
+ <module>TM_Testimonials</module>
71
+ <frontName>testimonials</frontName>
72
+ </args>
73
+ </tm_testimonials>
74
+ </routers>
75
+ <layout>
76
+ <updates>
77
+ <tm_testimonials>
78
+ <file>tm/testimonials.xml</file>
79
+ </tm_testimonials>
80
+ </updates>
81
+ </layout>
82
+ <translate>
83
+ <modules>
84
+ <TM_Testimonials>
85
+ <files>
86
+ <default>TM_Testimonials.csv</default>
87
+ </files>
88
+ </TM_Testimonials>
89
+ </modules>
90
+ </translate>
91
+ <events>
92
+ <controller_action_predispatch_tm_testimonials_index_post>
93
+ <observers>
94
+ <testimonials>
95
+ <class>tm_testimonials/observer</class>
96
+ <method>checkCaptcha</method>
97
+ </testimonials>
98
+ </observers>
99
+ </controller_action_predispatch_tm_testimonials_index_post>
100
+ <testimonials_notify_admin_testimonial_submit>
101
+ <observers>
102
+ <testimonials>
103
+ <class>tm_testimonials/observer</class>
104
+ <method>sendNotificationToAdmin</method>
105
+ </testimonials>
106
+ </observers>
107
+ </testimonials_notify_admin_testimonial_submit>
108
+ </events>
109
+ </frontend>
110
+ <default>
111
+ <captcha>
112
+ <frontend>
113
+ <areas>
114
+ <testimonials_form>
115
+ <label>Testimonials Form</label>
116
+ </testimonials_form>
117
+ </areas>
118
+ </frontend>
119
+ </captcha>
120
+ <customer>
121
+ <captcha>
122
+ <always_for>
123
+ <testimonials_form>1</testimonials_form>
124
+ </always_for>
125
+ </captcha>
126
+ </customer>
127
+ <testimonials>
128
+ <general>
129
+ <enabled>0</enabled>
130
+ <approve>0</approve>
131
+ <top_links>0</top_links>
132
+ <footer_links>0</footer_links>
133
+ </general>
134
+ <list>
135
+ <layout>one_column</layout>
136
+ <items_per_page>10</items_per_page>
137
+ <image_width>100</image_width>
138
+ <image_height>100</image_height>
139
+ <placeholder_image>empty.gif</placeholder_image>
140
+ <show_email>0</show_email>
141
+ </list>
142
+ <form>
143
+ <layout>two_columns_left</layout>
144
+ <enable_company>0</enable_company>
145
+ <enable_website>0</enable_website>
146
+ <enable_twitter>0</enable_twitter>
147
+ <enable_facebook>0</enable_facebook>
148
+ <sent_message>Thank you for your testimonial</sent_message>
149
+ </form>
150
+ <email_admin>
151
+ <send_enable>0</send_enable>
152
+ <send_from>0</send_from>
153
+ <admin_email></admin_email>
154
+ <email_subject>New testimonial was submitted</email_subject>
155
+ <email_template>testimonials_email_admin_email_template</email_template>
156
+ </email_admin>
157
+ </testimonials>
158
+ </default>
159
+ <admin>
160
+ <routers>
161
+ <adminhtml>
162
+ <args>
163
+ <modules>
164
+ <tm_testimonials before="Mage_Adminhtml">TM_Testimonials_Adminhtml</tm_testimonials>
165
+ </modules>
166
+ </args>
167
+ </adminhtml>
168
+ </routers>
169
+ </admin>
170
+ <adminhtml>
171
+ <translate>
172
+ <modules>
173
+ <TM_Testimonials>
174
+ <files>
175
+ <default>TM_Testimonials.csv</default>
176
+ </files>
177
+ </TM_Testimonials>
178
+ </modules>
179
+ </translate>
180
+ <layout>
181
+ <updates>
182
+ <tm_testimonials module="tm_testimonials">
183
+ <file>tm/testimonials.xml</file>
184
+ </tm_testimonials>
185
+ </updates>
186
+ </layout>
187
+ </adminhtml>
188
+ </config>
app/code/local/TM/Testimonials/etc/system.xml ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <!-- Testimonials -->
4
+ <tabs>
5
+ <templates_master translate="label" module="testimonials">
6
+ <label>Templates-master</label>
7
+ <sort_order>195</sort_order>
8
+ </templates_master>
9
+ </tabs>
10
+ <sections>
11
+ <testimonials translate="label" module="testimonials">
12
+ <label>Testimonials</label>
13
+ <tab>templates_master</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>2021</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <general translate="label" module="testimonials">
21
+ <label>General</label>
22
+ <sort_order>600</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Testimonials</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enabled>
36
+ <approve translate="label">
37
+ <label>Automatically approve testimonials</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>20</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </approve>
45
+ <top_links translate="label">
46
+ <label>Add link to top links</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>30</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </top_links>
54
+ <footer_links translate="label">
55
+ <label>Add link to footer links</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>40</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </footer_links>
63
+ </fields>
64
+ </general>
65
+ <list translate="label" module="testimonials">
66
+ <label>Testimonials List</label>
67
+ <sort_order>610</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <fields>
72
+ <layout translate="label">
73
+ <label>Testimonials list layout</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>page/source_layout</source_model>
76
+ <sort_order>10</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </layout>
81
+ <items_per_page translate="label">
82
+ <label>Testimonials per page</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>20</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </items_per_page>
89
+ <image_width translate="label">
90
+ <label>Image width</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>30</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </image_width>
97
+ <image_height translate="label">
98
+ <label>Image height</label>
99
+ <frontend_type>text</frontend_type>
100
+ <sort_order>40</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </image_height>
105
+ <placeholder_image translate="label comment">
106
+ <label>Image placeholder</label>
107
+ <comment>Allowed file types: jpeg, gif, png.</comment>
108
+ <frontend_type>image</frontend_type>
109
+ <backend_model>tm_testimonials/system_config_backend_image</backend_model>
110
+ <upload_dir config="system/filesystem/media" scope_info="1">testimonials/pictures</upload_dir>
111
+ <base_url type="media" scope_info="1">testimonials/pictures</base_url>
112
+ <sort_order>50</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </placeholder_image>
117
+ <show_email translate="label">
118
+ <label>Show user email in testimonials list</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>adminhtml/system_config_source_yesno</source_model>
121
+ <sort_order>60</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </show_email>
126
+ </fields>
127
+ </list>
128
+ <form translate="label" module="testimonials">
129
+ <label>Testimonials Submit Form</label>
130
+ <sort_order>620</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ <fields>
135
+ <layout translate="label">
136
+ <label>Testimonials form layout</label>
137
+ <frontend_type>select</frontend_type>
138
+ <source_model>page/source_layout</source_model>
139
+ <sort_order>10</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ </layout>
144
+ <enable_company translate="label">
145
+ <label>Enable company field</label>
146
+ <frontend_type>select</frontend_type>
147
+ <source_model>adminhtml/system_config_source_yesno</source_model>
148
+ <sort_order>20</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </enable_company>
153
+ <enable_website translate="label">
154
+ <label>Enable website field</label>
155
+ <frontend_type>select</frontend_type>
156
+ <source_model>adminhtml/system_config_source_yesno</source_model>
157
+ <sort_order>30</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>1</show_in_store>
161
+ </enable_website>
162
+ <enable_twitter translate="label">
163
+ <label>Enable twitter field</label>
164
+ <frontend_type>select</frontend_type>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <sort_order>40</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ </enable_twitter>
171
+ <enable_facebook translate="label">
172
+ <label>Enable facebook field</label>
173
+ <frontend_type>select</frontend_type>
174
+ <source_model>adminhtml/system_config_source_yesno</source_model>
175
+ <sort_order>50</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ </enable_facebook>
180
+ <sent_message translate="label">
181
+ <label>Message shown after testimonial sent</label>
182
+ <frontend_type>textarea</frontend_type>
183
+ <sort_order>60</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ </sent_message>
188
+ </fields>
189
+ </form>
190
+ <email_admin translate="label" module="testimonials">
191
+ <label>Administrator Email Notifications</label>
192
+ <sort_order>640</sort_order>
193
+ <show_in_default>1</show_in_default>
194
+ <show_in_website>1</show_in_website>
195
+ <show_in_store>1</show_in_store>
196
+ <fields>
197
+ <send_enable translate="label">
198
+ <label>Email notification for admin on new testimonial</label>
199
+ <frontend_type>select</frontend_type>
200
+ <source_model>adminhtml/system_config_source_yesno</source_model>
201
+ <sort_order>10</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ </send_enable>
206
+ <send_from translate="label">
207
+ <label>Send email from</label>
208
+ <frontend_type>select</frontend_type>
209
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
210
+ <sort_order>20</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ </send_from>
215
+ <admin_email translate="label">
216
+ <label>Administrator email</label>
217
+ <frontend_type>text</frontend_type>
218
+ <sort_order>30</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>1</show_in_store>
222
+ </admin_email>
223
+ <email_subject translate="label">
224
+ <label>Administrator email subject</label>
225
+ <frontend_type>text</frontend_type>
226
+ <sort_order>40</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ </email_subject>
231
+ <email_template translate="label">
232
+ <label>Administrator email template</label>
233
+ <frontend_type>select</frontend_type>
234
+ <source_model>adminhtml/system_config_source_email_template</source_model>
235
+ <sort_order>50</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </email_template>
240
+ </fields>
241
+ </email_admin>
242
+ </groups>
243
+ </testimonials>
244
+ </sections>
245
+ </config>
app/code/local/TM/Testimonials/etc/widget.xml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <widgets>
3
+ <testimonials_list type="testimonials/widget_list" translate="name" module="testimonials">
4
+ <name>Testimonials: List of testimonials (for side panel)</name>
5
+ <description type="desc">Shows changing testimonials list in side panel</description>
6
+ <parameters>
7
+ <show_block_design translate="label">
8
+ <required>0</required>
9
+ <visible>1</visible>
10
+ <label>Display block title and link</label>
11
+ <description>Disable if you want to use your own title design or link</description>
12
+ <type>select</type>
13
+ <source_model>adminhtml/system_config_source_yesno</source_model>
14
+ <value>1</value>
15
+ </show_block_design>
16
+ <items_number translate="label">
17
+ <required>1</required>
18
+ <visible>1</visible>
19
+ <label>Number of testimonials</label>
20
+ <type>text</type>
21
+ <value>5</value>
22
+ </items_number>
23
+ <view_time translate="label">
24
+ <required>1</required>
25
+ <visible>1</visible>
26
+ <label>Show next testimonial after, ms</label>
27
+ <type>text</type>
28
+ <value>10000</value>
29
+ </view_time>
30
+ <anim_duration translate="label">
31
+ <required>1</required>
32
+ <visible>1</visible>
33
+ <label>Change animation duration, ms</label>
34
+ <type>text</type>
35
+ <value>1000</value>
36
+ </anim_duration>
37
+ </parameters>
38
+ </testimonials_list>
39
+ <testimonials_review type="testimonials/widget_review" translate="name" module="testimonials">
40
+ <name>Testimonials: Review block (for side panel)</name>
41
+ <description type="desc">Shows number of testimonials and average testimonial rating in side panel</description>
42
+ <parameters>
43
+ <show_block_design translate="label">
44
+ <required>0</required>
45
+ <visible>1</visible>
46
+ <label>Display block title and link</label>
47
+ <description>Disable if you want to use your own title design or link</description>
48
+ <type>select</type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <value>1</value>
51
+ </show_block_design>
52
+ </parameters>
53
+ </testimonials_review>
54
+ <testimonials_form type="testimonials/widget_form" translate="name" module="testimonials">
55
+ <name>Testimonials: Submit Form</name>
56
+ <description type="desc">Shows testimonials submit form</description>
57
+ </testimonials_form>
58
+ <testimonials_listFull type="testimonials/widget_listFull" translate="name" module="testimonials">
59
+ <name>Testimonials: Full testimonials list</name>
60
+ <description type="desc">Shows full testimonials list</description>
61
+ <parameters>
62
+ <show_title translate="label">
63
+ <required>0</required>
64
+ <visible>1</visible>
65
+ <label>Show list title</label>
66
+ <type>select</type>
67
+ <source_model>adminhtml/system_config_source_yesno</source_model>
68
+ <value>1</value>
69
+ </show_title>
70
+ </parameters>
71
+ </testimonials_listFull>
72
+ </widgets>
app/code/local/TM/Testimonials/sql/tm_testimonials_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ /**
7
+ * Create table 'tm_testimonials/data'
8
+ */
9
+ if ($installer->getConnection()->isTableExists($installer->getTable('tm_testimonials/data')) != true) {
10
+ $table = $installer->getConnection()
11
+ ->newTable($installer->getTable('tm_testimonials/data'))
12
+ ->addColumn('testimonial_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
13
+ 'identity' => true,
14
+ 'unsigned' => true,
15
+ 'nullable' => false,
16
+ 'primary' => true,
17
+ ), 'Testimonial id')
18
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
19
+ 'default' => 1
20
+ ), 'Testimonial status')
21
+ ->addColumn('date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
22
+ 'nullable' => false
23
+ ), 'Testimonial creation time')
24
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 100, array(
25
+ 'nullable' => false
26
+ ), 'User name')
27
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
28
+ 'nullable' => false
29
+ ), 'User email')
30
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
31
+ 'nullable' => false
32
+ ), 'User message')
33
+ ->addColumn('company', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(),
34
+ 'User company')
35
+ ->addColumn('website', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(),
36
+ 'User website')
37
+ ->addColumn('twitter', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(),
38
+ 'User twitter')
39
+ ->addColumn('facebook', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(),
40
+ 'User facebook')
41
+ ->addColumn('image', Varien_Db_Ddl_Table::TYPE_VARCHAR, 100, array(),
42
+ 'User image path')
43
+ ->addColumn('rating', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(),
44
+ 'User rating')
45
+ ->addColumn('widget', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
46
+ 'default' => 1
47
+ ), 'Show testimonial in widget')
48
+ ->setComment('Templates Master Testimonials Data Table');
49
+ $installer->getConnection()->createTable($table);
50
+ }
51
+
52
+ /**
53
+ * Create table 'tm_testimonials/store'
54
+ */
55
+ if ($installer->getConnection()->isTableExists($installer->getTable('tm_testimonials/store')) != true) {
56
+ $table = $installer->getConnection()
57
+ ->newTable($installer->getTable('tm_testimonials/store'))
58
+ ->addColumn('testimonial_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
59
+ 'nullable' => false,
60
+ 'primary' => true
61
+ ), 'Testimonial ID')
62
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
63
+ 'unsigned' => true,
64
+ 'nullable' => false,
65
+ 'primary' => true
66
+ ), 'Store ID')
67
+ ->addIndex($installer->getIdxName('tm_testimonials/store', array('store_id')),
68
+ array('store_id'))
69
+ ->addForeignKey(
70
+ $installer->getFkName('tm_testimonials/store', 'testimonial_id', 'tm_testimonials/data', 'testimonial_id'),
71
+ 'testimonial_id',
72
+ $installer->getTable('tm_testimonials/data'),
73
+ 'testimonial_id',
74
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
75
+ Varien_Db_Ddl_Table::ACTION_CASCADE)
76
+ ->addForeignKey(
77
+ $installer->getFkName('tm_testimonials/store', 'store_id', 'core/store', 'store_id'),
78
+ 'store_id',
79
+ $installer->getTable('core/store'),
80
+ 'store_id',
81
+ Varien_Db_Ddl_Table::ACTION_CASCADE,
82
+ Varien_Db_Ddl_Table::ACTION_CASCADE)
83
+ ->setComment('Testimonial To Store Linkage Table');
84
+ $installer->getConnection()->createTable($table);
85
+ }
86
+
87
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/tm/testimonials.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_testimonials_index_index>
4
+ <reference name="content">
5
+ <block type="testimonials/adminhtml_page" name="testimonials_list"/>
6
+ </reference>
7
+ </adminhtml_testimonials_index_index>
8
+
9
+ <adminhtml_testimonials_index_new>
10
+ <update handle="adminhtml_testimonials_index_edit" />
11
+ </adminhtml_testimonials_index_new>
12
+
13
+ <adminhtml_testimonials_index_edit>
14
+ <update handle="editor"/>
15
+ <reference name="content">
16
+ <block type="testimonials/adminhtml_page_edit" name="testimonials_page_edit"></block>
17
+ </reference>
18
+ <reference name="left">
19
+ <block type="testimonials/adminhtml_page_edit_tabs" name="testimonials_page_edit_tabs">
20
+ <block type="testimonials/adminhtml_page_edit_tab_main" name="testimonials_page_edit_tab_main" />
21
+ <action method="addTab">
22
+ <name>main_section</name>
23
+ <block>testimonials_page_edit_tab_main</block>
24
+ </action>
25
+ </block>
26
+ </reference>
27
+ </adminhtml_testimonials_index_edit>
28
+ </layout>
app/design/frontend/base/default/layout/tm/testimonials.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addItem"><type>skin_css</type><name>css/tm/testimonials.css</name></action>
6
+ <action method="addItem"><type>skin_js</type><name>js/tm/testimonials.js</name></action>
7
+ </reference>
8
+ <reference name="top.links">
9
+ <action method="addLink" translate="label title" module="testimonials" ifconfig="testimonials/general/top_links">
10
+ <label>Testimonials</label>
11
+ <url>testimonials</url>
12
+ <title>Testimonials</title>
13
+ <prepare/>
14
+ <urlParams/>
15
+ <position>200</position>
16
+ </action>
17
+ </reference>
18
+ <reference name="footer_links">
19
+ <action method="addLink" translate="label title" module="testimonials" ifconfig="testimonials/general/footer_links">
20
+ <label>Testimonials</label>
21
+ <url>testimonials</url>
22
+ <title>Testimonials</title>
23
+ <prepare/>
24
+ <urlParams/>
25
+ <position>200</position>
26
+ </action>
27
+ </reference>
28
+ </default>
29
+ <tm_testimonials_index_new>
30
+ <reference name="content">
31
+ <block type="testimonials/form_container" name="testimonials.form.container"
32
+ template="tm/testimonials/form/container.phtml">
33
+ <block type="testimonials/form_form" name="testimonials.form"
34
+ template="tm/testimonials/form/form.phtml" as="testimonials_form">
35
+ <block type="captcha/captcha" name="captcha">
36
+ <reference name="head">
37
+ <action method="addJs"><file>mage/captcha.js</file></action>
38
+ </reference>
39
+ <action method="setFormId">
40
+ <formId>testimonials_form</formId>
41
+ </action>
42
+ <action method="setImgWidth">
43
+ <width>230</width>
44
+ </action>
45
+ <action method="setImgHeight">
46
+ <width>50</width>
47
+ </action>
48
+ </block>
49
+ </block>
50
+ </block>
51
+ </reference>
52
+ </tm_testimonials_index_new>
53
+ <tm_testimonials_index_index>
54
+ <reference name="content">
55
+ <block type="testimonials/list_content" name="testimonials.list.content"
56
+ template="tm/testimonials/list/content.phtml">
57
+ <block type="testimonials/list_title" name="testimonials.list.title"
58
+ template="tm/testimonials/list/title.phtml">
59
+ </block>
60
+ <block type="testimonials/list_bottom" name="testimonials.list.bottom"
61
+ template="tm/testimonials/list/bottom.phtml">
62
+ </block>
63
+ </block>
64
+ </reference>
65
+ </tm_testimonials_index_index>
66
+ </layout>
app/design/frontend/base/default/template/tm/testimonials/form/container.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
2
+ <div class="page-title">
3
+ <h1><?php echo $this->__('Submit your testimonial') ?></h1>
4
+ </div>
5
+ <?php echo $this->getChildHtml('testimonials_form'); ?>
app/design/frontend/base/default/template/tm/testimonials/form/form.phtml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form action="<?php echo $this->getUrl('testimonials/index/post'); ?>"
2
+ id="testimonialForm"
3
+ class="testimonialForm"
4
+ method="post"
5
+ enctype="multipart/form-data">
6
+ <div class="fieldset">
7
+ <h2 class="legend"><?php echo $this->__('Testimonial') ?></h2>
8
+ <ul class="form-list">
9
+ <li class="fields">
10
+ <div class="field">
11
+ <label for="name" class="required"><em>*</em><?php echo $this->__('Name') ?></label>
12
+ <div class="input-box">
13
+ <input name="name" id="name"
14
+ title="<?php echo $this->__('Name') ?>"
15
+ value="<?php echo $this->escapeHtml($this->getUserName()) ?>" class="input-text required-entry" type="text" />
16
+ </div>
17
+ </div>
18
+ <div class="field">
19
+ <label for="email" class="required"><em>*</em><?php echo $this->__('Email') ?></label>
20
+ <div class="input-box">
21
+ <input name="email" id="email" title="<?php echo $this->__('Email') ?>" value="<?php echo $this->escapeHtml($this->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
22
+ </div>
23
+ </div>
24
+ <?php if (Mage::helper('testimonials')->isCompanyEnabled()): ?>
25
+ <div class="field">
26
+ <label for="company"><?php echo $this->__('Company') ?></label>
27
+ <div class="input-box">
28
+ <input name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->escapeHtml($this->getCompany()) ?>" class="input-text" type="text" />
29
+ </div>
30
+ </div>
31
+ <?php endif ?>
32
+ <?php if (Mage::helper('testimonials')->isWebsiteEnabled()): ?>
33
+ <div class="field">
34
+ <label for="website"><?php echo $this->__('Website') ?></label>
35
+ <div class="input-box">
36
+ <input name="website" id="website" title="<?php echo $this->__('Website') ?>" value="<?php echo $this->escapeHtml($this->getWebSite()) ?>" class="input-text" type="text" />
37
+ </div>
38
+ </div>
39
+ <?php endif ?>
40
+ <?php if (Mage::helper('testimonials')->isTwitterEnabled()): ?>
41
+ <div class="field">
42
+ <label for="twitter"><?php echo $this->__('Twitter') ?></label>
43
+ <div class="input-box">
44
+ <input name="twitter" id="twitter" title="<?php echo $this->__('Twitter') ?>" value="<?php echo $this->escapeHtml($this->getTwitter()) ?>" class="input-text" type="text" />
45
+ </div>
46
+ </div>
47
+ <?php endif ?>
48
+ <?php if (Mage::helper('testimonials')->isFacebookEnabled()): ?>
49
+ <div class="field">
50
+ <label for="facebook"><?php echo $this->__('Facebook') ?></label>
51
+ <div class="input-box">
52
+ <input name="facebook" id="facebook" title="<?php echo $this->__('Facebook') ?>" value="<?php echo $this->escapeHtml($this->getFacebook()) ?>" class="input-text" type="text" />
53
+ </div>
54
+ </div>
55
+ <?php endif ?>
56
+ <div class="field">
57
+ <label for="image"><?php echo $this->__('Profile image') ?></label>
58
+ <div class="input-box">
59
+ <input name="image" id="image" title="<?php echo $this->__('Image') ?>"
60
+ type="file" />
61
+ </div>
62
+ </div>
63
+ <div class="field">
64
+ <label><?php echo $this->__('Rating') ?></label>
65
+ <div class="input-box">
66
+ <?php for ($i = 1; $i <= 5; ++$i) { ?>
67
+ <label for="rating_<?php echo $i; ?>"><?php echo $i; ?>
68
+ <input type="radio" name="rating" id="rating_<?php echo $i; ?>" value="<?php echo $i; ?>" class="radio" <?php if ($this->checkRating($i)): ?>checked="checked"<?php endif; ?> />
69
+ </label>
70
+ <?php } ?>
71
+ </div>
72
+ </div>
73
+ </li>
74
+ <li <?php if ($this->getLayout()->getBlock('root')
75
+ ->getTemplate() != "page/3columns.phtml"): ?>class="wide"<?php endif ?>>
76
+ <label for="message" class="required"><em>*</em><?php echo $this->__('Message') ?></label>
77
+ <div class="input-box">
78
+ <textarea name="message" id="message"
79
+ title="<?php echo $this->__('Message') ?>"
80
+ class="required-entry input-text" cols="5" rows="3"><?php echo $this->getUserMessage(); ?></textarea>
81
+ </div>
82
+ </li>
83
+ <?php echo $this->getChildHtml('captcha'); ?>
84
+ </ul>
85
+ </div>
86
+ <div class="buttons-set">
87
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
88
+ <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
89
+ <button type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
90
+ <button class="button" onclick="setLocation('<?php echo $this->getUrl('testimonials'); ?>'); return false;">
91
+ <span><span><?php echo $this->__('Back') ?></span></span>
92
+ </button>
93
+ </div>
94
+ </form>
95
+ <script type="text/javascript">
96
+ //<![CDATA[
97
+ var testimonialForm = new VarienForm('testimonialForm', true);
98
+ //]]>
99
+ </script>
app/design/frontend/base/default/template/tm/testimonials/list/bottom.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ </div>
2
+ <div class="more-button">
3
+ <a id="viewMore" target="blank" href=""><?php echo $this->__('Show more testimonials') ?></a>
4
+ </div>
5
+ <div class="copyright">
6
+ <!-- This extension is available under Creative Commons License http://creativecommons.org/licenses/by/3.0/. Removing links to is similarly prohibited. -->
7
+ Magento testimonial extension by <a href="http://templates-master.com/magento-extensions.html" title="Magento extensions by Templates-master.com" rel="nofollow" target="_blank">templates-master.com</a>
8
+ <!-- Removing links to is similarly prohibited. -->
9
+ </div>
10
+ </div>
11
+ <script type="text/javascript">
12
+ //<![CDATA[
13
+ var testimonials = new Testimonials("<?php echo $this->getUrl('testimonials/index/index') ?>",
14
+ '.testimonials');
15
+ $('viewMore').observe('click', testimonials.makeAjaxCall.bind(testimonials));
16
+ <?php $_testimonials = $this->getTestimonials(); ?>
17
+ <?php if ($this->getPerPage() >= $_testimonials->getSize()): ?>
18
+ $('viewMore').hide();
19
+ <?php endif ?>
20
+ //]]>
21
+ </script>
app/design/frontend/base/default/template/tm/testimonials/list/content.phtml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!$this->getIsAjax()) {
3
+ echo $this->getChildHtml('testimonials.list.title');
4
+ }
5
+ $_testimonials = $this->getTestimonials();
6
+ $_width = Mage::helper('testimonials')->getImageWidth();
7
+ $_height = Mage::helper('testimonials')->getImageHeight();
8
+ ?>
9
+ <?php if($_testimonials->getSize()): ?>
10
+ <?php foreach ($_testimonials as $_testimonial): ?>
11
+ <div class="testimonial">
12
+ <?php if ($image = $this->getImagePath($_testimonial)): ?>
13
+ <div class="testimonial-image" style="width: <?php echo ($_width + 10) ?>px">
14
+ <img src="<?php echo $this->helper('testimonials/image')->
15
+ init($image)->resize($_width, $_height); ?>"
16
+ alt="Profile image" />
17
+ </div>
18
+ <?php endif ?>
19
+ <div style="width: auto; margin-left: <?php echo $image ? ($_width + 10) : 0 ?>px">
20
+ <div class="content-wrapper">
21
+ <div class="message-wrapper">
22
+ <div class="message"><?php echo $_testimonial->getMessage() ?>
23
+ <span class="author-info">
24
+ <?php echo $_testimonial->getName();
25
+ if ($_testimonial->getCompany() &&
26
+ Mage::helper('testimonials')->isCompanyEnabled()): ?>,
27
+ <?php if ($_testimonial->getWebsite() &&
28
+ Mage::helper('testimonials')->isWebsiteEnabled()): ?>
29
+ <a href="<?php echo $_testimonial->getWebsite() ?>">
30
+ <?php echo $_testimonial->getCompany(); ?></a><?php
31
+ else:
32
+ echo $_testimonial->getCompany();
33
+ endif;
34
+ endif; ?>
35
+ <?php if (Mage::helper('testimonials')->showUserEmail()):
36
+ echo ', ' . $_testimonial->getEmail();
37
+ endif ?>
38
+ </span>
39
+ <?php if ($this->canShowSocial($_testimonial)): ?>
40
+ <div class="socialInfo">
41
+ <?php echo Mage::helper('testimonials')->__('Find us on'); ?>
42
+ <?php if ($_testimonial->getFacebook() &&
43
+ Mage::helper('testimonials')->isFacebookEnabled()): ?>
44
+ <a href="<?php echo $_testimonial->getFacebook() ?>">
45
+ <img src="<?php echo Mage::helper('testimonials')->getFacebookIcon() ?>" /><?php echo Mage::helper('testimonials')->__('Facebook') ?></a>
46
+ <?php endif ?>
47
+ <?php if ($_testimonial->getTwitter() &&
48
+ Mage::helper('testimonials')->isTwitterEnabled()): ?>
49
+ , <a href="<?php echo $_testimonial->getTwitter() ?>">
50
+ <img src="<?php echo Mage::helper('testimonials')->getTwitterIcon() ?>" /><?php echo Mage::helper('testimonials')->__('Twitter') ?></a><?php endif ?>
51
+ </div>
52
+ <?php endif ?>
53
+ </div>
54
+ </div>
55
+ <div style="margin: 10px 0 0 <?php echo $image ? 40 : 80 ?>px">
56
+ <div class="rating-wrapper ratings-table">
57
+ <?php if ($_testimonial->getRating()): ?>
58
+ <div class="rating-title"><?php echo $this->__('Rating') ?></div>
59
+ <div class="rating-box"><div class="rating" style="width: <?php echo $_testimonial->getRating() / 5 * 100 ?>%;"></div></div>
60
+ <?php endif ?>
61
+ </div>
62
+ <div class="testimonial-date">
63
+ <span><?php echo $this->__('Placed on') ?></span>
64
+ <span class="nobr"><?php echo $this->formatDate($_testimonial->getDate(), 'long') ?></span>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
+ <?php endforeach; ?>
71
+ <?php else: ?>
72
+ <p><?php echo $this->__('No testimonials found.'); ?></p>
73
+ <?php endif ?>
74
+ <?php if ($_testimonials->getCurPage() * $_testimonials->getPageSize() >= $_testimonials->getSize()): ?>
75
+ <script type="text/javascript">
76
+ //<![CDATA[
77
+ if ($('viewMore')) $('viewMore').hide();
78
+ //]]>
79
+ </script>
80
+ <?php endif ?>
81
+ <?php
82
+ if (!$this->getIsAjax()):
83
+ echo $this->getChildHtml('testimonials.list.bottom');
84
+ endif
85
+ ?>
app/design/frontend/base/default/template/tm/testimonials/list/title.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="testimonials-list">
2
+ <?php if (is_null($this->getShowTitle()) || $this->getShowTitle()): ?>
3
+ <div class="page-title">
4
+ <h1><?php echo $this->__('Testimonials') ?></h1>
5
+ <div class="submit-testimonial">
6
+ <button class="button" onclick="setLocation('<?php echo $this->getUrl('testimonials/index/new'); ?>')">
7
+ <span><span><?php echo $this->__('Submit Your Testimonial') ?></span></span>
8
+ </button>
9
+ </div>
10
+ </div>
11
+ <?php endif ?>
12
+ <div class="testimonials">
app/design/frontend/base/default/template/tm/testimonials/widget/list.phtml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $testimonials = $this->getTestimonials();
3
+ if (!count($testimonials)) {
4
+ return;
5
+ }
6
+ ?>
7
+
8
+ <div id="testimonialsList" class="block block-testimonials <?php if (!$this->getShowBlockDesign()): ?>empty-design<?php endif ?>">
9
+ <div class="block-title">
10
+ <strong><span><?php echo $this->__('Testimonials') ?></span></strong>
11
+ </div>
12
+ <div class="block-content">
13
+ <div class="testimonial-container">
14
+ <?php $itemId = 0; ?>
15
+ <?php foreach ($testimonials as $testimonial): ?>
16
+ <div id="testimonial_<?php echo $itemId ?>" class="content"
17
+ <?php if ($itemId > 0): ?> style="display: none;"<?php endif ?>>
18
+ <div class="content-wrapper ratings-table">
19
+ <?php if ($testimonial->getRating()): ?>
20
+ <div class="rating-title"><?php echo $this->__('Rating: ') ?></div>
21
+ <div class="rating-box"><div class="rating" style="width: <?php echo $testimonial->getRating() / 5 * 100 ?>%;"></div></div>
22
+ <?php endif ?>
23
+ <div class="message"><?php echo $testimonial->getMessage(); ?></div>
24
+ </div>
25
+ <div class="name"><?php echo $testimonial->getName(); ?></div>
26
+ <a class="read-more" href="#"><?php echo $this->__('Read more') ?></a>
27
+ <a class="read-less" href="#" style="display: none;"><?php echo $this->__('Read less') ?></a>
28
+ </div>
29
+ <?php ++$itemId; ?>
30
+ <?php endforeach; ?>
31
+ </div>
32
+ <div class="actions">
33
+ <a href="<?php echo $this->getUrl('testimonials') ?>"><?php echo $this->__('View all testimonials') ?></a>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <script type="text/javascript">
38
+ //<![CDATA[
39
+ var curTestimonial = 0,
40
+ showMoreActive = false,
41
+ changeInterval,
42
+ contentHeight = $$('.block-testimonials .block-content .content .content-wrapper')[0].getStyle('height'),
43
+ numTestimonials = <?php echo count($testimonials); ?>,
44
+ viewTime = <?php echo $this->getViewTime(); ?>,
45
+ changeAnimDuration = <?php echo $this->getAnimDuration(); ?>;
46
+
47
+ startChangeTimer();
48
+
49
+ Event.observe('testimonialsList', 'mouseenter', function() {
50
+ if (!showMoreActive) clearInterval(changeInterval);
51
+ });
52
+
53
+ Event.observe('testimonialsList', 'mouseleave', startChangeTimer);
54
+
55
+ Event.observe($('testimonial_0').down('.read-more'), 'click', showMore);
56
+ Event.observe($('testimonial_0').down('.read-less'), 'click', showLess);
57
+
58
+ function showMore(e) {
59
+ e.stop();
60
+ showMoreActive = true;
61
+ this.hide();
62
+ this.up().down('.read-less').show();
63
+ this.up().down('.content-wrapper').setStyle( { height: 'auto' } );
64
+ }
65
+
66
+ function showLess(e) {
67
+ e.stop();
68
+ showMoreActive = false;
69
+ this.hide();
70
+ this.up().down('.read-more').show();
71
+ this.up().down('.content-wrapper').setStyle( { height: contentHeight } );
72
+ }
73
+
74
+ function startChangeTimer() {
75
+ if (!showMoreActive) {
76
+ changeInterval = setInterval(nextTestimonial, viewTime);
77
+ }
78
+ }
79
+
80
+ function nextTestimonial() {
81
+ if (numTestimonials < 2) {
82
+ return;
83
+ }
84
+
85
+ $('testimonial_' + curTestimonial).down('.read-more').stopObserving();
86
+ $('testimonial_' + curTestimonial).down('.read-less').stopObserving();
87
+ Effect.Fade('testimonial_' + curTestimonial, {
88
+ duration: changeAnimDuration / 1000
89
+ });
90
+
91
+ ++curTestimonial;
92
+ if (curTestimonial >= numTestimonials) curTestimonial = 0;
93
+
94
+ setTimeout(function() {
95
+ Effect.Appear('testimonial_' + curTestimonial, {
96
+ duration: changeAnimDuration / 1000
97
+ });
98
+ Event.observe($('testimonial_' + curTestimonial).down('.read-more'),
99
+ 'click', showMore);
100
+ Event.observe($('testimonial_' + curTestimonial).down('.read-less'),
101
+ 'click', showLess);
102
+ }, changeAnimDuration);
103
+ }
104
+ //]]>
105
+ </script>
app/design/frontend/base/default/template/tm/testimonials/widget/review.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="block block-testimonials <?php if (!$this->getShowBlockDesign()): ?>empty-design<?php endif ?>">
2
+ <div class="block-title">
3
+ <strong><span><?php echo $this->__('Store Review') ?></span></strong>
4
+ </div>
5
+ <div class="block-content">
6
+ <span itemscope itemtype="http://schema.org/Store">
7
+ <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="review">
8
+ <div itemprop="ratingValue" class="score"><?php echo $this->getAvgRating() ?></div>
9
+ <div class="score-info"><?php echo ' ' . $this->__('out of') . ' 5 (' ?><span itemprop="ratingCount"><?php echo $this->getTestimonials()->getSize() ?></span><?php echo ' ' . $this->__('votes') . ')' ?>
10
+ </div>
11
+ </div>
12
+ <meta itemprop="name" content="<?php echo Mage::app()->getStore()->getFrontendName() ?>">
13
+ </span>
14
+ <div class="actions">
15
+ <a href="<?php echo $this->getUrl('testimonials') ?>"><?php echo $this->__('View all testimonials') ?></a>
16
+ </div>
17
+ </div>
18
+ </div>
app/etc/modules/TM_Testimonials.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <!-- Testimonials -->
4
+ <modules>
5
+ <TM_Testimonials>
6
+ <active>true</active>
7
+ <codePool>local</codePool>
8
+ </TM_Testimonials>
9
+ </modules>
10
+ </config>
app/locale/en_US/TM_Testimonials.csv ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Submit your testimonial","Submit your testimonial"
2
+ "Testimonial","Testimonial"
3
+ "Message","Message"
4
+ "Unable to find items to save","Unable to find items to save"
5
+ "New Testimonial","New Testimonial"
6
+ "Edit Testimonial","Edit Testimonial"
7
+ "Testimonial Information","Testimonial Information"
8
+ "Company","Company"
9
+ "Website","Website"
10
+ "Facebook","Facebook"
11
+ "Twitter","Twitter"
12
+ "Rating","Rating"
13
+ "Rating:","Rating:"
14
+ "star","star"
15
+ "stars","stars"
16
+ "No rating","No rating"
17
+ "Unable to find a testimonial to delete.","Unable to find a testimonial to delete."
18
+ "The testimonial has been deleted.","The testimonial has been deleted."
19
+ "Testimonial has been saved.","Testimonial has been saved."
20
+ "No testimonials found.","No testimonials found."
21
+ "Please select testimonial(s).","Please select testimonial(s)."
22
+ "Show more testimonials","Show more testimonials"
23
+ "View all testimonials","View all testimonials"
24
+ "Display in widget","Display in widget"
25
+ "out of","out of"
26
+ "votes","votes"
27
+ "Store Review","Store Review"
28
+ "Added:","Added:"
29
+ "Placed on","Placed on"
30
+ "Profile image","Profile image"
31
+ "Approve","Approve"
32
+ "Testimonial approved.","Testimonial approved."
33
+ "Find us on","Find us on"
34
+ "Read more","Read more"
35
+ "Read less","Read less"
app/locale/en_US/template/email/testimonials_admin_notification.html ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
2
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
3
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
4
+ <tr>
5
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
6
+ <!-- [ header starts here] -->
7
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
8
+ <tr>
9
+ <td valign="top">
10
+ <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
11
+ </tr>
12
+ <!-- [ middle starts here] -->
13
+ <tr>
14
+ <td valign="top">
15
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">{{var admin_subject}}</h1>
16
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Testimonial data:</strong></p>
17
+
18
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>User Name : </strong> {{var user_name}}</p>
19
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>User Email : </strong> {{var user_email}}</p>
20
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Store View : </strong> {{var store_view}}</p>
21
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Message : </strong> {{var message}}</p>
22
+ {{depend company}}
23
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Company : </strong> {{var company}}</p>
24
+ {{/depend}}
25
+ {{depend website}}
26
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Website : </strong> {{var website}}</p>
27
+ {{/depend}}
28
+ {{depend facebook}}
29
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Facebook : </strong> {{var facebook}}</p>
30
+ {{/depend}}
31
+ {{depend twitter}}
32
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Twitter : </strong> {{var twitter}}</p>
33
+ {{/depend}}
34
+ {{depend rating}}
35
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Rating : </strong> {{var rating}}</p>
36
+ {{/depend}}
37
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Has image : </strong> {{var image}}</p>
38
+ <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>Status : </strong> {{var status}}</p>
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;"><strong>{{var store.getFrontendName()}}</strong></p></center></td>
43
+ </tr>
44
+ </table>
45
+ </td>
46
+ </tr>
47
+ </table>
48
+ </div>
49
+ </body>
package.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>free_testimonials_extension</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://creativecommons.org/licenses/by/3.0/">Creative Commons License </license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Free Magento Testimonials extension</summary>
10
+ <description>Fixes&#xD;
11
+ * Added check for testimonials qty before animation&#xD;
12
+ * Fixed date issue in different locales in admin&#xD;
13
+ * Added missing translations&#xD;
14
+ * Removed notices on form submit&#xD;
15
+ * Widget are hidden now if no testimonials are found&#xD;
16
+ * rwd template fixes&#xD;
17
+ &#xD;
18
+ Improvements&#xD;
19
+ * Added config to show testimonials link in top and footer links&#xD;
20
+ * Widget specific configuration moved to widget creation window&#xD;
21
+ * Tested with magento 1.9.1&#xD;
22
+ </description>
23
+ <notes>Magento Easy Tabs Community Module</notes>
24
+ <authors><author><name>TemplatesMaster</name><user>TemplatesMaster</user><email>support@templates-master.com</email></author></authors>
25
+ <date>2015-01-23</date>
26
+ <time>11:11:46</time>
27
+ <contents><target name="magelocal"><dir name="TM"><dir name="Testimonials"><dir name="Block"><dir name="Adminhtml"><dir name="Page"><dir name="Edit"><file name="Form.php" hash="31812badeb61963ebd41d000c565b994"/><dir name="Tab"><file name="Main.php" hash="0923031c06b94ac3e6abf979df66a5fd"/></dir><file name="Tabs.php" hash="ee96415e07758fca2ae7a2e2010d69e8"/></dir><file name="Edit.php" hash="d322da030cd3fb0955149db4334f9097"/><file name="Grid.php" hash="6b902e78ea5c871d1ccbedcf4cbfced6"/><dir name="Helper"><file name="Image.php" hash="c1bec4553f23aee1e069d631d233ef17"/></dir></dir><file name="Page.php" hash="554b7e2338bc5e4b20021411df9fedc5"/></dir><dir name="Form"><file name="Container.php" hash="800b09dfab07cb6d98404c72b0cfc4d3"/><file name="Form.php" hash="c3c0b4a086aef7215e0f2178ba314af2"/></dir><dir name="List"><file name="Bottom.php" hash="0b4d5338aeed17b6da84d19b57452b97"/><file name="Content.php" hash="d379ac1567cc4e42f0b5b47f1372cca1"/><file name="Title.php" hash="22e4679f6c70a2cfc2e9ad9719afcb3c"/></dir><dir name="Widget"><file name="Form.php" hash="d1eabb9a51887d6fab49820e0374a87d"/><file name="List.php" hash="de4461d8e13af86e02e45713aeb9f76b"/><file name="ListFull.php" hash="c03078edce1d8f0d49cd5c4149bbc5cb"/><file name="Review.php" hash="eda3c3ce564015865f3e1cbd2bab06be"/></dir></dir><dir name="Helper"><file name="Data.php" hash="dabf52846e52154aff7e5cda5587098e"/><file name="Image.php" hash="64cb9db1afa06cb1e59c42cf695b4c7f"/></dir><dir name="Model"><file name="Data.php" hash="dac0f5409efa811f5eab67bedbe4925b"/><file name="Observer.php" hash="da0e5e6a406ae4369653b475a59d352c"/><dir name="Resource"><dir name="Data"><file name="Collection.php" hash="bb4002420093933c9bb7cb2f044f175b"/></dir><file name="Data.php" hash="02cbba52ad8e861b0fc6990eaed9cf5a"/><file name="Setup.php" hash="cca012d39e55c3fb12b749110211bceb"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Image.php" hash="be450b5a17a44fae105b1ebe0d662b92"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Testimonials"><file name="IndexController.php" hash="52f08a97a85bfc43c6864c9ff012f97d"/></dir></dir><file name="IndexController.php" hash="7dbe08ff9bcc420889fc39cee2ed5fd2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ac4ac021fd129b7262932d509d27da4b"/><file name="config.xml" hash="8444671c445acfa02edea6e3db57d18b"/><file name="system.xml" hash="85ac5e0c8c1cee04223131cf306d5c24"/><file name="widget.xml" hash="753d8ead5869b53768807dd65fc76bf5"/></dir><dir name="sql"><dir name="tm_testimonials_setup"><file name="mysql4-install-1.0.0.php" hash="3bdb83a71fd3db4717bfaf12fc463a4d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="tm"><file name="testimonials.xml" hash="094af48d59de30d0706e43e51052a719"/></dir></dir><dir name="template"><dir name="tm"><dir name="testimonials"><dir><dir name="form"><file name="container.phtml" hash="1ce57290286480d4a041f9929f843754"/><file name="form.phtml" hash="84f6f1176284092b55c78fa670af9b57"/></dir><dir name="list"><file name="bottom.phtml" hash="c5ed73a92062bf8e24928694739c2abd"/><file name="content.phtml" hash="d6f84e73fffb0bd6362c2dc114b5b3b4"/><file name="title.phtml" hash="f3e2d101f532abdb950ddd5004c690aa"/></dir><dir name="widget"><file name="list.phtml" hash="2196612ad162ae820c3596bf73534aa7"/><file name="review.phtml" hash="6f63ab0b8b802b531e9acfe9a1fab332"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="tm"><file name="testimonials.xml" hash="3db48f3732a87c393719a999a74fb7c6"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="tm"><file name="testimonials.css" hash="fbdb82889b535eb1d118a41a2b3eaf40"/></dir></dir><dir name="js"><dir name="tm"><file name="testimonials.js" hash="ea1aacc945c48a382a716556ed527376"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TM_Testimonials.xml" hash="9c88a7c606829ce69a14da4d27d2c206"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="testimonials_admin_notification.html" hash="ec53090da82c969ef0b00f5462ae0909"/></dir></dir><file name="TM_Testimonials.csv" hash="a8bcd63dc424fb6080c3f3cc18bb77bc"/></dir></target></contents>
28
+ <compatible/>
29
+ <dependencies><required><php><min>5.2.0</min><max>5.9.0</max></php></required></dependencies>
30
+ </package>
skin/frontend/base/default/css/tm/testimonials.css ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .testimonials-list .testimonial {
2
+ font-family: Helvetica, Arial, sans-serif;
3
+ font-size: 14px;
4
+ margin-top: 40px;
5
+ position: relative;
6
+ }
7
+
8
+ .testimonials-list .testimonials {
9
+ margin: 0 10px 0 10px;
10
+ }
11
+
12
+ .testimonials-list .testimonial:first-child {
13
+ margin-top: 0px;
14
+ }
15
+
16
+ .testimonials-list .more-button {
17
+ width: 100%;
18
+ text-align: center;
19
+ float: left;
20
+ margin-top: 20px;
21
+ margin-bottom: 20px;
22
+ display: inline-block;
23
+ border-radius: 1px;
24
+ font-size: 18px;
25
+ text-align: center;
26
+ }
27
+
28
+ .testimonials-list .more-button a {
29
+ color: #fff;
30
+ background: #479ccf;
31
+ border: 1px solid #3793cb;
32
+ text-shadow: 0 1px 0 #3188bc;
33
+ text-decoration: none;
34
+ padding: 11px 30px;
35
+ transition: background 0.2s linear 0;
36
+ }
37
+
38
+ .testimonials-list .more-button a:focus,
39
+ .testimonials-list .more-button a:hover {
40
+ background: #5ba7d4;
41
+ color: #fff;
42
+ }
43
+
44
+ .testimonials-list .more-button a:focus {
45
+ background: #5ba7d4;
46
+ color: #fff;
47
+ box-shadow: inset 0 0 8px #3188bc;
48
+ }
49
+
50
+ .testimonials-list .more-button .disabled {
51
+ opacity: 0.5;
52
+ cursor: wait;
53
+ }
54
+
55
+ .testimonials-list .page-title button {
56
+ float: right;
57
+ }
58
+
59
+ .testimonials-list .page-title h1 {
60
+ float: left;
61
+ border-bottom: none;
62
+ }
63
+
64
+ .testimonials-list .page-title:after {
65
+ display: block;
66
+ content: ".";
67
+ clear: both;
68
+ font-size: 0;
69
+ line-height: 0;
70
+ height: 0;
71
+ overflow: hidden;
72
+ }
73
+
74
+ .testimonials-list .testimonial-image {
75
+ float: left;
76
+ }
77
+
78
+ .testimonials-list .testimonial .message-wrapper {
79
+ clear: both;
80
+ }
81
+
82
+ .testimonials-list .testimonial .content-wrapper {
83
+ float: left;
84
+ width: 100%;
85
+ }
86
+
87
+ .testimonials-list .testimonial .message {
88
+ font-style: italic;
89
+ position: relative;
90
+ padding: 15px;
91
+ margin: 0 0 0 30px;
92
+ border: 1px solid #CFCFCF;
93
+ border-bottom: 2px solid #CFCFCF;
94
+ color: #333;
95
+ background: #fff;
96
+ }
97
+
98
+ .testimonials-list .testimonial .message:before {
99
+ content: "";
100
+ position: absolute;
101
+ top: 15px;
102
+ bottom: auto;
103
+ left: -23px;
104
+ border-width: 10px 23px 10px 0;
105
+ border-style: solid;
106
+ border-color: transparent #CFCFCF;
107
+ display: block;
108
+ width: 0;
109
+ }
110
+
111
+ .testimonials-list .testimonial .message:after {
112
+ content: "";
113
+ position: absolute;
114
+ top: 16px;
115
+ bottom: auto;
116
+ left: -21px;
117
+ border-width: 9px 21px 9px 0;
118
+ border-style: solid;
119
+ border-color: transparent #fff;
120
+ display: block;
121
+ width: 0;
122
+ }
123
+
124
+ .testimonials-list .testimonial .testimonial-date {
125
+ float: right;
126
+ font-size: 12px;
127
+ }
128
+
129
+ .testimonials-list .testimonial .rating-wrapper {
130
+ float: left;
131
+ font-size: 12px;
132
+ }
133
+
134
+ .testimonials-list .testimonial .socialInfo {
135
+ font-size: 12px;
136
+ padding-top: 5px;
137
+ }
138
+
139
+ .testimonials-list .testimonial .author-info {
140
+ font-weight: bold;
141
+ font-style: italic;
142
+ }
143
+
144
+ .testimonials-list .testimonial .socialInfo a {
145
+ white-space: nowrap;
146
+ }
147
+
148
+ .testimonials-list .testimonial .socialInfo img {
149
+ margin-right: 5px;
150
+ margin-left: 5px;
151
+ display: inline;
152
+ }
153
+
154
+ .testimonials-list .testimonial .rating-title {
155
+ float: left;
156
+ margin-right: 10px;
157
+ line-height: 1.25;
158
+ }
159
+
160
+ .testimonials-list .testimonial .rating-box {
161
+ float: left;
162
+ }
163
+
164
+ .testimonials-list .copyright {
165
+ text-align: center;
166
+ color: #000;
167
+ font-size: .9em;
168
+ }
169
+
170
+ /** widgets styles */
171
+ .block-testimonials .actions a {
172
+ float: none;
173
+ }
174
+
175
+ .block-testimonials .block-content a {
176
+ color: #1b2d3b;
177
+ }
178
+
179
+ .block-testimonials {
180
+ font-size: 11px;
181
+ line-height: 1.25;
182
+ }
183
+
184
+ .block-testimonials .block-content .content {
185
+ padding: 10px 10px 20px 10px;
186
+ }
187
+
188
+ .block-testimonials .block-content .testimonial-container {
189
+ min-height: 130px;
190
+ }
191
+
192
+ .block-testimonials .block-content .content .content-wrapper {
193
+ height: 75px;
194
+ min-height: 75px;
195
+ display: block;
196
+ overflow: hidden;
197
+ }
198
+
199
+ .block-testimonials .block-content .read-more,
200
+ .block-testimonials .block-content .read-less {
201
+ padding-top: 10px;
202
+ display: inline-block;
203
+ }
204
+
205
+ .block-testimonials .block-content .review {
206
+ text-align: center;
207
+ }
208
+
209
+ .block-testimonials .block-content .review .score {
210
+ font-weight: bold;
211
+ font-size: 40px;
212
+ color: #e26703;
213
+ }
214
+
215
+ .block-testimonials .block-content .content .rating-title {
216
+ float: left;
217
+ margin-right: 10px;
218
+ }
219
+
220
+ .block-testimonials .block-content .content .message {
221
+ margin-top: 10px;
222
+ }
223
+
224
+ .block-testimonials .block-content .content .name {
225
+ float: right;
226
+ margin-top: 10px;
227
+ font-style: italic;
228
+ }
229
+
230
+ .block-testimonials.empty-design .actions,
231
+ .block-testimonials.empty-design .block-title {
232
+ display: none;
233
+ }
234
+
235
+ .block-testimonials.empty-design,
236
+ .block-testimonials.empty-design .block-content {
237
+ background: none;
238
+ border: none;
239
+ }
240
+
241
+ .block-testimonials.empty-design .block-content .content {
242
+ padding: 0;
243
+ }
244
+
245
+ .std .testimonialForm li {
246
+ list-style: none;
247
+ }
248
+
249
+ .testimonials-list .testimonial { zoom: 1; }
250
+ .testimonials-list .testimonial:after { content: '.'; clear: both; height: 0; font-size: 0; display: block; visibility: hidden; }
251
+
252
+ @media (max-width: 480px) {
253
+ .testimonials-list .testimonial .testimonial-date {
254
+ float: left;
255
+ margin-bottom: 10px;
256
+ clear: both;
257
+ }
258
+ }
skin/frontend/base/default/js/tm/testimonials.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Testimonials = Class.create();
2
+ Testimonials.prototype = {
3
+ initialize: function(ajaxCallUrl, divToUpdate) {
4
+ this.url = ajaxCallUrl;
5
+ this.div = $$(divToUpdate)[0];
6
+ this.currentPage = 1;
7
+ },
8
+
9
+ makeAjaxCall: function(event) {
10
+ event.stop();
11
+ if ($$('.more-button a')[0].hasClassName('disabled')) return;
12
+ $$('.more-button a')[0].addClassName('disabled');
13
+ ++this.currentPage;
14
+ new Ajax.Request(this.url + 'page/' + this.currentPage, {
15
+ onSuccess: function(transport) {
16
+ var response = transport.responseText.evalJSON();
17
+ this.div.insert(response.outputHtml);
18
+ $$('.more-button a')[0].removeClassName('disabled');
19
+ }.bind(this)
20
+ });
21
+ }
22
+ };