PI_Comments - Version 0.1.0

Version Notes

This is a stable version.

Download this release

Release Info

Developer pureimagination
Extension PI_Comments
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (24) hide show
  1. app/code/local/PI/Comments/Block/Adminhtml/Commentss.php +17 -0
  2. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit.php +50 -0
  3. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit/Form.php +19 -0
  4. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit/Tab/Form.php +78 -0
  5. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit/Tabs.php +24 -0
  6. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Grid.php +93 -0
  7. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Renderer/Status.php +24 -0
  8. app/code/local/PI/Comments/Block/Adminhtml/Commentss/Renderer/Thumbnail.php +25 -0
  9. app/code/local/PI/Comments/Helper/Data.php +7 -0
  10. app/code/local/PI/Comments/Model/Commentss.php +11 -0
  11. app/code/local/PI/Comments/Model/Resource/Commentss.php +10 -0
  12. app/code/local/PI/Comments/Model/Resource/Commentss/Collection.php +10 -0
  13. app/code/local/PI/Comments/controllers/Adminhtml/CommentssController.php +134 -0
  14. app/code/local/PI/Comments/controllers/DetailController.php +12 -0
  15. app/code/local/PI/Comments/controllers/IndexController.php +42 -0
  16. app/code/local/PI/Comments/etc/adminhtml.xml +37 -0
  17. app/code/local/PI/Comments/etc/config.xml +88 -0
  18. app/code/local/PI/Comments/sql/comments_setup/mysql4-install-0.1.0.php +35 -0
  19. app/design/frontend/base/default/layout/comments.xml +22 -0
  20. app/design/frontend/base/default/template/comments/comments.phtml +58 -0
  21. app/design/frontend/base/default/template/comments/detail.phtml +69 -0
  22. app/design/frontend/base/default/template/comments/form.phtml +118 -0
  23. app/etc/modules/PI_Comments.xml +8 -0
  24. package.xml +27 -0
app/code/local/PI/Comments/Block/Adminhtml/Commentss.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+
7
+ $this->_controller = 'adminhtml_commentss';
8
+ $this->_blockGroup = 'comments';
9
+ $this->_headerText = Mage::helper('comments')->__('Customer comments');
10
+ parent::__construct();
11
+ $this->_removeButton('add');
12
+
13
+
14
+
15
+ }
16
+
17
+ }
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+
8
+ $this->_objectId = 'id';
9
+ $this->_blockGroup = 'comments';
10
+ $this->_controller = 'adminhtml_commentss'; /* adminhtml is a folder name and brand is a folder name in which edit.php inside a block exists */
11
+
12
+
13
+
14
+ $this->_updateButton('delete', 'label', Mage::helper('comments')->__('Delete'));
15
+
16
+
17
+ $this->_updateButton('save', 'label', Mage::helper('comments')->__('Save'));
18
+
19
+
20
+ $this->_addButton('saveandcontinue', array(
21
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
22
+ 'onclick' => 'saveAndContinueEdit()',
23
+ 'class' => 'save',
24
+ ), -100);
25
+
26
+ $this->_formScripts[] = "
27
+ function toggleEditor() {
28
+ if (tinyMCE.getInstanceById('edge_content') == null) {
29
+ tinyMCE.execCommand('mceAddControl', false, 'edge_content');
30
+ } else {
31
+ tinyMCE.execCommand('mceRemoveControl', false, 'edge_content');
32
+ }
33
+ }
34
+
35
+ function saveAndContinueEdit(){
36
+ editForm.submit($('edit_form').action+'back/edit/');
37
+
38
+ }
39
+ ";
40
+ }
41
+
42
+ public function getHeaderText() {
43
+ if (Mage::registry('customer_data') && Mage::registry('customer_data')->getId()) {
44
+ return Mage::helper('comments')->__("Customer Details '%s'", $this->htmlEscape(Mage::registry('customer_data')->getCustomerName()));
45
+ } else {
46
+ return Mage::helper('comments')->__('Add comments Location');
47
+ }
48
+ }
49
+
50
+ }
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit/Tab/Form.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ $fieldset = $form->addFieldset('comments_form', array('legend' => Mage::helper('comments')->__('Customer Details')));
9
+
10
+ $fieldset->addField('customer_email', 'text', array(
11
+ 'label' => Mage::helper('comments')->__('Customer Name'),
12
+ 'class' => 'required-entry',
13
+ 'required' => true,
14
+ 'readonly' => true,
15
+ 'name' => 'customer_email',
16
+ ));
17
+
18
+ $fieldset->addField('customer_name', 'text', array(
19
+ 'label' => Mage::helper('comments')->__('Customer Email'),
20
+ 'class' => 'required-entry',
21
+ 'required' => true,
22
+ 'readonly' => true,
23
+ 'name' => 'customer_name',
24
+ ));
25
+
26
+ $fieldset->addField('comments', 'textarea', array(
27
+ 'label' => Mage::helper('comments')->__('Comments'),
28
+ 'class' => 'required-entry',
29
+ 'required' => true,
30
+
31
+ 'name' => 'comments',
32
+ ));
33
+
34
+
35
+ $fieldset->addField('status', 'select', array(
36
+ 'label' => Mage::helper('comments')->__('Status'),
37
+ 'name' => 'status',
38
+ 'values' => array(
39
+ array(
40
+ 'value' => 1,
41
+ 'label' => Mage::helper('comments')->__('Enabled'),
42
+ ),
43
+
44
+ array(
45
+ 'value' => 2,
46
+ 'label' => Mage::helper('comments')->__('Disabled'),
47
+ ),
48
+ ),
49
+ ));
50
+
51
+ $fieldset->addType('thumbnail','PI_Comments_Block_Adminhtml_Commentss_Renderer_Thumbnail');
52
+ //image type make image display in front at the time of editing.
53
+ $fieldset->addField('picture', 'thumbnail', array(
54
+ 'label' => Mage::helper('comments')->__('Picture'),
55
+ 'required' => false,
56
+
57
+ 'style' => "display:none;",
58
+ 'readonly' => true,
59
+
60
+ 'name' => 'picture',
61
+ ));
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+ if (Mage::getSingleton('adminhtml/session')->getDriverData()) {
70
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getDriverData());
71
+ Mage::getSingleton('adminhtml/session')->setDriverData(null);
72
+ } elseif (Mage::registry('customer_data')) {
73
+ $form->setValues(Mage::registry('customer_data')->getData());
74
+ }
75
+ return parent::_prepareForm();
76
+ }
77
+
78
+ }
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('driver_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('comments')->__('Customer Commentss'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('comments')->__('Customer Comments'),
18
+ 'title' => Mage::helper('comments')->__('Customer Comments'),
19
+ 'content' => $this->getLayout()->createBlock('comments/adminhtml_commentss_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Grid.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('commentGrid');
8
+ $this->setDefaultSort('id');// sorting according to which colunm name
9
+ }
10
+
11
+ protected function _prepareCollection() {
12
+
13
+ $collection = Mage::getModel('comments/commentss')->getCollection();
14
+ $this->setCollection($collection);
15
+ //print_r($collection->getData());exit;
16
+ return parent::_prepareCollection();
17
+ }
18
+
19
+ protected function _prepareColumns() {
20
+ $this->addColumn('id', array(
21
+ 'header' => Mage::helper('comments')->__('ID'),
22
+ 'width' => '10%',
23
+ 'index' => 'id',
24
+ ));
25
+
26
+ $this->addColumn('customer_email', array(
27
+ 'header' => Mage::helper('comments')->__('Customer Email'),
28
+ 'width' => '15%',
29
+ 'index' => 'customer_email',
30
+ ));
31
+ $this->addColumn('customer_name', array(
32
+ 'header' => Mage::helper('comments')->__('Customer Name'),
33
+ 'width' => '15%',
34
+ 'index' => 'customer_name',
35
+ ));
36
+
37
+
38
+
39
+ $this->addColumn('status', array(
40
+ 'header' => Mage::helper('core')->__('status'),
41
+ 'align' =>'center',
42
+ 'width' => '10%',
43
+ 'height' => '100px',
44
+ 'filter' => false,
45
+ 'sortable' => false,
46
+ 'renderer' => 'PI_comments_Block_Adminhtml_commentss_Renderer_Status',
47
+
48
+
49
+ ));
50
+
51
+ $this->addColumn('action', array(
52
+ 'header' => Mage::helper('comments')->__('Action'),
53
+ 'width' => '100',
54
+ 'type' => 'action',
55
+ 'getter' => 'getId',
56
+ 'actions' => array(
57
+ array(
58
+ 'caption' => Mage::helper('comments')->__('View'),
59
+ 'url' => array('base' => '*/*/edit'),
60
+ 'field' => 'id'
61
+ )
62
+ ),
63
+ 'filter' => false,
64
+ 'sortable' => false,
65
+ 'index' => 'stores',
66
+ 'is_system' => true,
67
+ ));
68
+
69
+ return parent::_prepareColumns();
70
+ }
71
+
72
+ protected function _prepareMassaction() {
73
+
74
+
75
+
76
+ $this->setMassactionIdField('comments_id');
77
+ $this->getMassactionBlock()->setFormFieldName('comments_id');
78
+
79
+ $this->getMassactionBlock()->addItem('delete', array(
80
+ 'label' => Mage::helper(' core')->__('Delete'),
81
+ 'url' => $this->getUrl('*/*/massDelete'),
82
+ 'confirm' => Mage::helper('core')->__('Are you sure?')
83
+ ));
84
+
85
+ return $this;
86
+ }
87
+
88
+ public function getRowUrl($row) {
89
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
90
+ }
91
+
92
+ }
93
+
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Renderer/Status.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Block_Adminhtml_Commentss_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ return ($this->_getStatus($row));
7
+ }
8
+
9
+ protected function _getStatus(Varien_Object $row) {
10
+
11
+ $status = $row->getStatus();
12
+ $result = '';
13
+
14
+ if ($status == '1') {
15
+ $result = 'Enabled';
16
+ } else {
17
+ $result = 'Disabled';
18
+ }
19
+ return $result;
20
+ }
21
+
22
+ }
23
+
24
+ ?>
app/code/local/PI/Comments/Block/Adminhtml/Commentss/Renderer/Thumbnail.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class PI_Comments_Block_Adminhtml_Commentss_Renderer_Thumbnail extends Varien_Data_Form_Element_Abstract {
3
+ public function __construct($data) {
4
+ parent::__construct($data);
5
+ $this->setType('file');
6
+ }
7
+
8
+ public function getElementHtml() {
9
+ $html = '';
10
+ if ($this->getValue()) {
11
+
12
+
13
+ $html = '
14
+ <img id="'.$this->getHtmlId().'_image" style="border: 1px solid #d6d6d6;" title="'.$this->getValue().'" src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$this->getValue().'" alt="'.$this->getValue().'" width="50">
15
+
16
+ ';
17
+ }
18
+ $this->setClass('input-file');
19
+ $html.= parent::getElementHtml();
20
+ return $html;
21
+ }
22
+
23
+
24
+ }
25
+ ?>
app/code/local/PI/Comments/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+
6
+
7
+ }
app/code/local/PI/Comments/Model/Commentss.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Model_Commentss extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('comments/commentss'); /* driver is the frontname and order is current file name */
8
+ }
9
+
10
+
11
+ }
app/code/local/PI/Comments/Model/Resource/Commentss.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Model_Resource_Commentss extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the id refers to the key field in your database table and it is a primary key.
8
+ $this->_init('comments/customer_commentss', 'id');
9
+ }
10
+ }
app/code/local/PI/Comments/Model/Resource/Commentss/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Model_Resource_Commentss_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('Comments/Commentss');
9
+ }
10
+ }
app/code/local/PI/Comments/controllers/Adminhtml/CommentssController.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_Adminhtml_CommentssController extends Mage_Adminhtml_Controller_action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+
8
+ /** set active menu* */
9
+ $this->_setActiveMenu('picomments/comments');
10
+ $this->_addContent($this->getLayout()->createBlock('comments/adminhtml_commentss'));
11
+ $this->renderLayout();
12
+ }
13
+
14
+ public function editAction() {
15
+ $id = $this->getRequest()->getParam('id');
16
+ $model = Mage::getModel('comments/commentss')->load($id);
17
+
18
+ if ($model->getId() || $id == 0) {
19
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
20
+ if (!empty($data)) {
21
+ $model->setData($data);
22
+ }
23
+
24
+
25
+ Mage::register('customer_data', $model);
26
+
27
+ $this->loadLayout();
28
+ $this->_setActiveMenu('ggpfast/driver');
29
+
30
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
31
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
32
+
33
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
34
+
35
+ $this->_addContent($this->getLayout()->createBlock('comments/adminhtml_commentss_edit'))
36
+ ->_addLeft($this->getLayout()->createBlock('comments/adminhtml_commentss_edit_tabs'));
37
+
38
+ $this->renderLayout();
39
+ } else {
40
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('comments')->__('Driver Location does not exist'));
41
+ $this->_redirect('*/*/');
42
+ }
43
+ }
44
+
45
+ public function newAction() {
46
+ $this->_forward('edit');
47
+ }
48
+
49
+ public function saveAction() {
50
+ $id = $this->getRequest()->getParam('id');
51
+ $data = $this->getRequest()->getPost();
52
+ if ($data = $this->getRequest()->getPost()) {
53
+
54
+ $driverOrder = Mage::getModel('comments/commentss');
55
+
56
+ $model = Mage::getModel('comments/commentss');
57
+
58
+ $driverData = $data;
59
+
60
+
61
+ $model->setData($driverData)
62
+ ->setId($this->getRequest()->getParam('id'));
63
+
64
+
65
+ try {
66
+
67
+
68
+ $model->save();
69
+
70
+
71
+
72
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('comments')->__('Status Successfully Updated.'));
73
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
74
+
75
+ if ($this->getRequest()->getParam('back')) {
76
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
77
+ return;
78
+ }
79
+ $this->_redirect('*/*/');
80
+ return;
81
+ } catch (Exception $e) {
82
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
83
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
84
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
85
+ return;
86
+ }
87
+ }
88
+
89
+
90
+ $this->_redirect('*/*/');
91
+ }
92
+
93
+ public function deleteAction() {
94
+ if ($this->getRequest()->getParam('id') > 0) {
95
+ try {
96
+ $model = Mage::getModel('comments/commentss');
97
+
98
+ $model->setId($this->getRequest()->getParam('id'))
99
+ ->delete();
100
+
101
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Customer comments successfully deleted'));
102
+ $this->_redirect('*/*/');
103
+ } catch (Exception $e) {
104
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
105
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
106
+ }
107
+ }
108
+ $this->_redirect('*/*/');
109
+ }
110
+
111
+ public function massDeleteAction() {
112
+ $driverIds = $this->getRequest()->getParam('comments_id');
113
+ if (!is_array($driverIds)) {
114
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Customer Commentss(s)'));
115
+ } else {
116
+ try {
117
+ foreach ($driverIds as $driverId) {
118
+ $driver = Mage::getModel('comments/commentss')->load($driverId);
119
+ $driver->delete();
120
+ }
121
+ Mage::getSingleton('adminhtml/session')->addSuccess(
122
+ Mage::helper('adminhtml')->__(
123
+ 'Total of %d record(s) is successfully deleted', count($driverIds)
124
+ )
125
+ );
126
+ } catch (Exception $e) {
127
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
128
+ }
129
+ }
130
+ $this->_redirect('*/*/index');
131
+ }
132
+
133
+ }
134
+
app/code/local/PI/Comments/controllers/DetailController.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_DetailController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+
11
+ }
12
+
app/code/local/PI/Comments/controllers/IndexController.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PI_Comments_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+
11
+ public function saveAction() {
12
+
13
+ try {
14
+ $model = Mage::getModel('comments/commentss');
15
+ $data = $this->getRequest()->getParams();
16
+
17
+ //print_r($data);print_r($_FILES);exit;
18
+
19
+ $now = time();
20
+ $path = Mage::getBaseDir('media') . DS . 'picomments' . DS . 'comments';
21
+ $uploader_main = new Varien_File_Uploader('picture');
22
+ $uploader_main->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png', 'svg', 'eps'));
23
+ $uploader_main->setAllowRenameFiles(false);
24
+ $uploader_main->setFilesDispersion(false);
25
+ $img_name = explode('.', $_FILES['picture']['name']);
26
+ $img_name_main = $now . '.' . $img_name[count($img_name) - 1];
27
+ $uploader_main->save($path, $img_name_main);
28
+ /* * unlink images * */
29
+ $data['picture'] = 'picomments/comments/'. $img_name_main;
30
+
31
+ $model->setData($data);
32
+ $model->save();
33
+
34
+ Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__('Comments has been successfully saved.'));
35
+ } catch (Exception $e) {
36
+ Mage::getSingleton('core/session')->addError($e->getMessage());
37
+ }
38
+ $this->_redirectReferer();
39
+ }
40
+
41
+ }
42
+
app/code/local/PI/Comments/etc/adminhtml.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <menu>
5
+ <picomments translate="title">
6
+ <title>Manage comments</title>
7
+ <sort_order>75</sort_order>
8
+ <children>
9
+ <commentss translate="title">
10
+ <title>comments</title>
11
+ <sort_order>6</sort_order>
12
+ <action>adminhtml/commentss</action>
13
+ <!--on click i.e on action our controller inside the adminhtml will call.-->
14
+ </commentss>
15
+ </children>
16
+ </picomments>
17
+ </menu>
18
+ <acl>
19
+ <resources>
20
+ <admin>
21
+ <children>
22
+ <picomments translate="title" module="comments">
23
+ <title>Manage comments</title>
24
+ <sort_order>75</sort_order>
25
+ <children>
26
+ <commentss translate="title" module="comments">
27
+ <title>comments</title>
28
+ </commentss>
29
+ </children>
30
+ </picomments>
31
+
32
+ </children>
33
+ </admin>
34
+ </resources>
35
+ </acl>
36
+ </config>
37
+
app/code/local/PI/Comments/etc/config.xml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <PI_Comments>
4
+ <version>0.1.0</version>
5
+ </PI_Comments>
6
+ </modules>
7
+ <frontend>
8
+ <routers>
9
+ <comments>
10
+ <use>standard</use>
11
+ <args>
12
+ <module>PI_Comments</module>
13
+ <frontName>comments</frontName>
14
+ </args>
15
+ </comments>
16
+ </routers>
17
+ <layout>
18
+ <updates>
19
+ <comments>
20
+ <file>comments.xml</file>
21
+ </comments>
22
+ </updates>
23
+ </layout>
24
+
25
+ </frontend>
26
+ <global>
27
+ <models>
28
+ <comments>
29
+ <class>PI_Comments_Model</class>
30
+ <resourceModel>comments_mysql4</resourceModel>
31
+ </comments>
32
+ <comments_mysql4>
33
+ <class>PI_Comments_Model_Resource</class>
34
+ <entities>
35
+ <customer_commentss>
36
+ <table>customer_commentss</table>
37
+ </customer_commentss>
38
+ <admin_user>
39
+ <table>admin_user</table>
40
+ </admin_user>
41
+ </entities>
42
+ </comments_mysql4>
43
+ </models>
44
+
45
+ <blocks>
46
+ <comments>
47
+ <class>PI_Comments_Block</class>
48
+ </comments>
49
+ </blocks>
50
+ <resources>
51
+ <comments_setup>
52
+ <setup>
53
+ <module>PI_Comments</module>
54
+ </setup>
55
+ <connection>
56
+ <use>core_setup</use>
57
+ </connection>
58
+ </comments_setup>
59
+ <comments_write>
60
+ <connection>
61
+ <use>core_write</use>
62
+ </connection>
63
+ </comments_write>
64
+ <comments_read>
65
+ <connection>
66
+ <use>core_read</use>
67
+ </connection>
68
+ </comments_read>
69
+ </resources>
70
+ <helpers>
71
+ <comments>
72
+ <class>PI_Comments_Helper</class>
73
+ </comments>
74
+ </helpers>
75
+ </global>
76
+ <admin>
77
+ <routers>
78
+ <adminhtml>
79
+ <args>
80
+ <modules>
81
+ <PI_Comments before="Mage_Adminhtml">PI_Comments_Adminhtml</PI_Comments>
82
+ </modules>
83
+ </args>
84
+ </adminhtml>
85
+ </routers>
86
+ </admin>
87
+
88
+ </config>
app/code/local/PI/Comments/sql/comments_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $table = $installer->getTable('comments/customer_commentss');
8
+
9
+ $tableDdlObj = $installer->getConnection()
10
+ ->newTable($table)
11
+ ->addColumn("id", Varien_Db_Ddl_Table::TYPE_INTEGER, NULL, array(
12
+ 'identity' => true,
13
+ 'nullable' => false,
14
+ 'primary' => true,
15
+ 'unsigned' => true,
16
+ ), 'Id')
17
+
18
+ ->addColumn("customer_email", Varien_Db_Ddl_Table::TYPE_TEXT, 200, array(
19
+ ), 'Customer Email')
20
+ ->addColumn("customer_name", Varien_Db_Ddl_Table::TYPE_TEXT, 200, array(
21
+ ), 'Customer Name')
22
+ ->addColumn("comments", Varien_Db_Ddl_Table::TYPE_TEXT, 200, array(
23
+ ), 'Comments')
24
+ ->addColumn("picture", Varien_Db_Ddl_Table::TYPE_TEXT, 200, array(
25
+ ), 'Picture')
26
+ ->addColumn("status", Varien_Db_Ddl_Table::TYPE_TEXT, 200, array(
27
+ ), 'status')
28
+
29
+ ->setComment("customer status");
30
+
31
+
32
+ $installer->getConnection()->createTable($tableDdlObj);
33
+
34
+
35
+ $installer->endSetup();
app/design/frontend/base/default/layout/comments.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout>
2
+ <comments_index_index>
3
+ <reference name="root">
4
+ <action method="setTemplate">
5
+ <template>page/2columns-left.phtml</template>
6
+ </action>
7
+ </reference>
8
+ <reference name="content">
9
+ <block type="core/template" name="myform" template="comments/form.phtml"/>
10
+ </reference>
11
+ </comments_index_index>
12
+ <comments_detail_index>
13
+ <reference name="root">
14
+ <action method="setTemplate">
15
+ <template>page/1column.phtml</template>
16
+ </action>
17
+ </reference>
18
+ <reference name="content">
19
+ <block type="core/template" name="detailtest" template="comments/detail.phtml"/>
20
+ </reference>
21
+ </comments_detail_index>
22
+ </layout>
app/design/frontend/base/default/template/comments/comments.phtml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <table class="data-table">
2
+ <colgroup>
3
+ <col width="100px"/>
4
+ <col/>
5
+ </colgroup>
6
+
7
+ <thead>
8
+ <tr>
9
+ <td colspan="2"> <h1 class="left"><?php echo $this->__('Customer Comments')?></h1></td>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <?php
15
+ $model = Mage::getModel('comments/commentss');
16
+ $collection = $model->getCollection()
17
+ ->addFieldToFilter('status', 1);
18
+ $data = $collection->getData();
19
+ foreach ($data as $row):
20
+ ?>
21
+ <tr>
22
+ <td>
23
+ <?php echo '<img class="img-responsive img-circle" width="70" src="' . Mage::getBaseUrl('media') . $row["picture"] . '"/>'; ?>
24
+ </td>
25
+ <td>
26
+
27
+ <dl>
28
+ <dt><?php $string = $row["comments"]; ?></dt>
29
+ <dd><?php
30
+ $string = strip_tags($string);
31
+
32
+ if (strlen($string) > 175) {
33
+ $stringCut = substr($string, 0, 175);
34
+ $string = substr($stringCut, 0, strrpos($stringCut, ' ')) . '..<a class="read-more" href="' . $this->getUrl('comments/detail/index', array('id' => $row["id"])) . '">Read More</a>';
35
+ }
36
+ echo $string;
37
+ ?></dd>
38
+ </dl>
39
+ <h4 class="right">- <?php echo $row["customer_name"]; ?></h4>
40
+
41
+
42
+ </td>
43
+ </tr>
44
+ <?php endforeach; ?>
45
+ </tbody>
46
+
47
+ <tfoot>
48
+ <tr>
49
+ <td colspan="2">
50
+ <button class="button right" title="<?php echo $this->__('Add comments') ?>" type="button"
51
+ onclick="setLocation('<?php echo $this->getUrl('comments/index/index'); ?>')">
52
+ <span><span><?php echo $this->__('Add comments') ?></span></span>
53
+ </button>
54
+ </td>
55
+ </tr>
56
+ </tfoot>
57
+
58
+ </table>
app/design/frontend/base/default/template/comments/detail.phtml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ <div class="account-create testi">
4
+ <div class="page-title">
5
+ <h1><?php echo $this->__('Comments Details'); ?></h1>
6
+ </div>
7
+
8
+ <div class="fieldset">
9
+
10
+ <p class="form-instructions"><?php echo $this->__('Details of Comments'); ?></p>
11
+
12
+ <ul class="form-list">
13
+
14
+
15
+ <?php
16
+ $id = $this->getRequest()->getParams('id');
17
+ foreach (array_values($id) as $i => $value)
18
+ {
19
+ $value;
20
+ }
21
+ $value;
22
+ $model = Mage::getModel('comments/commentss');
23
+ $collection = $model->getCollection()
24
+ ->addFieldToFilter('status', 1)
25
+ ->addFieldToFilter('id',$value);
26
+ $data = $collection->getData();
27
+ foreach($data as $row):
28
+ ?>
29
+
30
+ <li>
31
+ <div class="list-inner contentcomments">
32
+ <div>
33
+ <?php echo '<img class="img-responsive img-circle" width="70" src="' . Mage::getBaseUrl('media').'/'.$row["picture"] . '"/>';?>
34
+ </div>
35
+ </br>
36
+ <div>
37
+ <p>
38
+ <?php echo $row["comments"]; ?>
39
+ </p>
40
+ </div>
41
+ <div>
42
+ -<a href="#"><span class="testname">- <?php echo $row["customer_name"]; ?></span></a>
43
+
44
+ </div>
45
+ </div>
46
+
47
+ </li>
48
+
49
+
50
+ <?php endforeach; ?>
51
+
52
+
53
+
54
+ </ul>
55
+
56
+
57
+ </div>
58
+
59
+
60
+ <div class="buttons-set">
61
+ <p class="back-link"><a href="<?php echo Mage::helper('core/url')->getHomeUrl(); ?>" class="back-link"><small>« </small><?php echo $this->__('Back'); ?></a></p>
62
+
63
+ </div>
64
+
65
+
66
+
67
+
68
+
69
+ </div>
app/design/frontend/base/default/template/comments/form.phtml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ <div class="account-create testi">
4
+ <div class="page-title">
5
+ <h1><?php echo $this->__('Post your Comments'); ?></h1>
6
+ </div>
7
+ <form action="<?php echo $this->getUrl('comments/index/save'); ?>" method="post" id="form-validate" class="scaffold-form" enctype="multipart/form-data">
8
+ <div class="fieldset">
9
+ <?php echo $this->getBlockHtml('formkey')?>
10
+ <input type="hidden" name="success_url" value="">
11
+ <input type="hidden" name="error_url" value="">
12
+ <p class="form-instructions"><?php echo $this->__('Please enter the following information to post your Comments.'); ?></p>
13
+ <p class="required"><?php echo $this->__('* Required Fields'); ?></p>
14
+ <ul class="form-list">
15
+
16
+
17
+ <?php
18
+ $email="";
19
+ $first="";
20
+ $middle="";
21
+ $last="";
22
+ if (Mage::getSingleton("customer/session")->isLoggedIn()):
23
+ $customer = Mage::getSingleton("customer/session")->getCustomer();
24
+ $email = $customer->getEmail();
25
+ $first = $customer->getFirstname();
26
+ $middle = $customer->getMiddlename();
27
+ $last = $customer->getLastname();
28
+ endif;
29
+
30
+
31
+ ?>
32
+
33
+ <input type="hidden" id="status" name="status" value="2">
34
+ <li>
35
+ <label for="email_address" class="required"><em>*</em>
36
+
37
+ <?php echo $this->__('Customer Email Address'); ?>
38
+ </label>
39
+ <div class="input-box">
40
+ <input type="email" value="<?php echo $email; ?>" autocapitalize="off" autocorrect="off" spellcheck="false" name="customer_email" id="email_address" value="" title="Email Address" class="input-text validate-email required-entry">
41
+ </div>
42
+ </li>
43
+
44
+
45
+ <li class="fields">
46
+ <div class="customer-name">
47
+ <div class="field name-firstname">
48
+ <label for="firstname" class="required"><em>*</em>
49
+ <?php echo $this->__('Customer Name'); ?>
50
+ </label>
51
+ <div class="input-box">
52
+ <input type="text" id="name" name="customer_name" value="<?php echo $first; ?> <?php echo $last; ?>" title="Name" maxlength="255" class="input-text required-entry">
53
+ </div>
54
+ </div>
55
+
56
+ </div>
57
+ </li>
58
+
59
+ <li class="fields">
60
+ <div class="customer-name">
61
+ <div class="field name-firstname">
62
+ <label for="name" class="required"><em>*</em>
63
+ <?php echo $this->__('Comments'); ?></label>
64
+ <div class="input-box">
65
+ <textarea class="input-text required-entry" cols="10" name="comments" rows="3"></textarea>
66
+ </div>
67
+ </div>
68
+
69
+
70
+ </div>
71
+
72
+
73
+
74
+
75
+ </li>
76
+ <li class="fields">
77
+ <div class="customer-name">
78
+ <div class="field name-firstname">
79
+ <label for="firstname" class="required"><em>*</em>
80
+ <?php echo $this->__('Picture'); ?>
81
+ </label>
82
+ <div class="input-box">
83
+
84
+ <input type="file" name="picture" class="required-entry"/>
85
+
86
+ </div>
87
+
88
+ </div>
89
+ </div>
90
+
91
+ </div>
92
+ </li>
93
+
94
+
95
+ </ul>
96
+
97
+
98
+ </div>
99
+ <div class="buttons-set">
100
+
101
+ <button style="float:left;" type="submit" title="Register" class="button"><span><span><?php echo $this->__('Submit'); ?>
102
+ </span></span></button>
103
+ </div>
104
+
105
+ <div class="buttons-set">
106
+ <p class="back-link"><a href="<?php echo Mage::helper('core/url')->getHomeUrl(); ?>" class="back-link"><small>« </small><?php echo $this->__('Back to home'); ?></a></p>
107
+
108
+ </div>
109
+ </form>
110
+ <script type="text/javascript">
111
+ //<![CDATA[
112
+ var dataForm = new VarienForm('form-validate', true);
113
+ <?php //if($this->getShowAddressFields()): ?>
114
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
115
+ <?php //endif; ?>
116
+ //]]>
117
+ </script>
118
+ </div>
app/etc/modules/PI_Comments.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <PI_Comments>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </PI_Comments>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>PI_Comments</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>You can use this extension to comment on website.</summary>
10
+ <description>We can use this extension for customer reviews, i.e customers can write their comments for the site. After that admin can display these comments on front-end.&#xD;
11
+ &#xD;
12
+ Features&#xD;
13
+ &#xF02D; No core files are changed.&#xD;
14
+ &#xF02D; There is a separate section in order to manage customer comments.&#xD;
15
+ &#xF02D; Customer can write their comment for site.&#xD;
16
+ &#xF02D; Customer can also upload their images with their comments.&#xD;
17
+ &#xF02D; Admin has a functionality to approve the submitted comments.&#xD;
18
+ &#xF02D; If admin approve these comments then it will be dispaly on front-end.&#xD;
19
+ </description>
20
+ <notes>This is a stable version.</notes>
21
+ <authors><author><name>pureimagination</name><user>pureimagination</user><email>johncarter15oct@gmail.com</email></author></authors>
22
+ <date>2015-05-09</date>
23
+ <time>11:22:27</time>
24
+ <contents><target name="magelocal"><dir name="PI"><dir name="Comments"><dir name="Block"><dir name="Adminhtml"><dir name="Commentss"><dir name="Edit"><file name="Form.php" hash="a3e1bf67f8ba546d8d07d836cb8f42b7"/><dir name="Tab"><file name="Form.php" hash="9111bb1a98fc146acd14cfa744c5b63c"/></dir><file name="Tabs.php" hash="dbd372951e525dd1ed8556914169b1ab"/></dir><file name="Edit.php" hash="32d095012c9c19b6d92eeace37756096"/><file name="Grid.php" hash="681e862e84f8681cf088152886cb1993"/><dir name="Renderer"><file name="Status.php" hash="944a485d2adbc435c698ade45e6f267a"/><file name="Thumbnail.php" hash="d6853ce2705327e9c313fa078310a2ca"/></dir></dir><file name="Commentss.php" hash="be6dc760770acaecd79e65f8f87dbcf3"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7fb9fedcc862511ce1e414ff5043f4fb"/></dir><dir name="Model"><file name="Commentss.php" hash="d20b0c4d36ec2e0be83d88628f1584ce"/><dir name="Resource"><dir name="Commentss"><file name="Collection.php" hash="d818616c2a349a669a014f1c80a32c21"/></dir><file name="Commentss.php" hash="efa5193207f2e98cec18f79aaddf3f54"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CommentssController.php" hash="7d5e6b7ab78c2080a878e2b6671702bb"/></dir><file name="DetailController.php" hash="ce06c88d11c5826c18c2011f056702bd"/><file name="IndexController.php" hash="9c578cac46b3384408dabca19e27338b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="69af512cf7a8ebef521a289d6370af67"/><file name="config.xml" hash="c5f0d6ff873da5362a94080d39765739"/></dir><dir name="sql"><dir name="comments_setup"><file name="mysql4-install-0.1.0.php" hash="5d444f920879f7bdd36dcb33d6679f73"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PI_Comments.xml" hash="0146d803c3a866b70d9cc932ed9f002d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="comments.xml" hash="7654b7c7df2f2d01dae5ec8e475d1831"/></dir><dir name="template"><dir name="comments"><file name="comments.phtml" hash="7f5b7da2ad5ed97ecae6cf6328732359"/><file name="detail.phtml" hash="1b3da6b12e2dcc243ba83ff23b4f6ddf"/><file name="form.phtml" hash="3b69f09ebb5c21316ba52158a23d5a99"/></dir></dir></dir></dir></dir></target></contents>
25
+ <compatible/>
26
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
27
+ </package>