CP_Faq - Version 0.0.1

Version Notes

Frequently Asked Questions

Download this release

Release Info

Developer Commerce Pundit
Extension CP_Faq
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (39) hide show
  1. app/code/community/CP/Faq/Block/Adminhtml/Category.php +13 -0
  2. app/code/community/CP/Faq/Block/Adminhtml/Category/Edit.php +46 -0
  3. app/code/community/CP/Faq/Block/Adminhtml/Category/Edit/Form.php +19 -0
  4. app/code/community/CP/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php +45 -0
  5. app/code/community/CP/Faq/Block/Adminhtml/Category/Edit/Tabs.php +28 -0
  6. app/code/community/CP/Faq/Block/Adminhtml/Category/Grid.php +98 -0
  7. app/code/community/CP/Faq/Block/Adminhtml/Faq.php +13 -0
  8. app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit.php +52 -0
  9. app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit/Form.php +19 -0
  10. app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit/Tab/Form.php +91 -0
  11. app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit/Tabs.php +28 -0
  12. app/code/community/CP/Faq/Block/Adminhtml/Faq/Grid.php +197 -0
  13. app/code/community/CP/Faq/Block/Adminhtml/Widget/Grid/Column/Renderer/Category.php +17 -0
  14. app/code/community/CP/Faq/Block/Category.php +41 -0
  15. app/code/community/CP/Faq/Block/Faq.php +82 -0
  16. app/code/community/CP/Faq/Block/Toolbar.php +24 -0
  17. app/code/community/CP/Faq/Helper/Data.php +14 -0
  18. app/code/community/CP/Faq/Model/Category.php +23 -0
  19. app/code/community/CP/Faq/Model/Faq.php +11 -0
  20. app/code/community/CP/Faq/Model/Mysql4/Category.php +10 -0
  21. app/code/community/CP/Faq/Model/Mysql4/Category/Collection.php +11 -0
  22. app/code/community/CP/Faq/Model/Mysql4/Faq.php +10 -0
  23. app/code/community/CP/Faq/Model/Mysql4/Faq/Collection.php +11 -0
  24. app/code/community/CP/Faq/Model/Status.php +42 -0
  25. app/code/community/CP/Faq/controllers/Adminhtml/CategoryController.php +103 -0
  26. app/code/community/CP/Faq/controllers/Adminhtml/FaqController.php +140 -0
  27. app/code/community/CP/Faq/controllers/IndexController.php +97 -0
  28. app/code/community/CP/Faq/etc/config.xml +154 -0
  29. app/code/community/CP/Faq/sql/faq_setup/mysql4-install-0.1.0.php +69 -0
  30. app/design/adminhtml/default/default/layout/faq.xml +14 -0
  31. app/design/frontend/default/default/layout/faq.xml +63 -0
  32. app/design/frontend/default/default/template/faq/addfaq.phtml +65 -0
  33. app/design/frontend/default/default/template/faq/category.phtml +35 -0
  34. app/design/frontend/default/default/template/faq/list.phtml +33 -0
  35. app/etc/modules/CP_Faq.xml +10 -0
  36. app/locale/en_US/template/email/admin_create_faq_by_customer.html +50 -0
  37. app/locale/en_US/template/email/create_faq_by_customer.html +48 -0
  38. app/locale/en_US/template/email/reply_create_faq_by_customer.html +50 -0
  39. package.xml +33 -0
app/code/community/CP/Faq/Block/Adminhtml/Category.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Category extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_category';
7
+ $this->_blockGroup = 'faq';
8
+ $this->_headerText = Mage::helper('faq')->__('Manage Faq Category');
9
+ $this->_addButtonLabel = Mage::helper('faq')->__('Add Faq Category');
10
+ parent::__construct();
11
+ }
12
+
13
+ }
app/code/community/CP/Faq/Block/Adminhtml/Category/Edit.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Category_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'faq';
11
+ $this->_controller = 'adminhtml_category';
12
+ $this->_mode = 'edit';
13
+
14
+ $this->_addButton('save_and_continue', array(
15
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
16
+ 'onclick' => 'saveAndContinueEdit()',
17
+ 'class' => 'save',
18
+ ), -100);
19
+ $this->_updateButton('save', 'label', Mage::helper('faq')->__('Save'));
20
+
21
+ $this->_formScripts[] = "
22
+ function toggleEditor() {
23
+ if (tinyMCE.getInstanceById('form_content') == null) {
24
+ tinyMCE.execCommand('mceAddControl', false, 'edit_form');
25
+ } else {
26
+ tinyMCE.execCommand('mceRemoveControl', false, 'edit_form');
27
+ }
28
+ }
29
+
30
+ function saveAndContinueEdit(){
31
+ editForm.submit($('edit_form').action+'back/edit/');
32
+ }
33
+ ";
34
+ }
35
+
36
+ public function getHeaderText()
37
+ {
38
+ if (Mage::registry('category_data') && Mage::registry('category_data')->getId())
39
+ {
40
+ return Mage::helper('faq')->__('Edit Faq "%s"', $this->htmlEscape(Mage::registry('category_data')->getName()));
41
+ } else {
42
+ return Mage::helper('faq')->__('New Faq Category'); }
43
+ }
44
+
45
+ }
46
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Category/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Category_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
+ )
12
+ );
13
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+ }
19
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Category_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('category_form', array('legend'=>Mage::helper('faq')->__('Faq Category information')));
10
+
11
+ $fieldset->addField('name', 'text', array(
12
+ 'label' => Mage::helper('faq')->__('Category Name'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'name',
16
+ ));
17
+
18
+ $fieldset->addField('status', 'select', array(
19
+ 'label' => Mage::helper('faq')->__('Status'),
20
+ 'name' => 'status',
21
+ 'values' => array(
22
+ array(
23
+ 'value' => 1,
24
+ 'label' => Mage::helper('faq')->__('Active'),
25
+ ),
26
+
27
+ array(
28
+ 'value' => 0,
29
+ 'label' => Mage::helper('faq')->__('Inactive'),
30
+ ),
31
+ ),
32
+ ));
33
+
34
+
35
+ if ( Mage::getSingleton('adminhtml/session')->getCategoryData() )
36
+ {
37
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCategoryData());
38
+ Mage::getSingleton('adminhtml/session')->setCategoryData(null);
39
+ } elseif ( Mage::registry('category_data') ) {
40
+ $form->setValues(Mage::registry('category_data')->getData());
41
+ }
42
+ return parent::_prepareForm();
43
+ }
44
+ }
45
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Category/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Category_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('category_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('faq')->__('Faq Category Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => 'Faq Category',
18
+ 'title' => 'Faq Category',
19
+ 'content' => $this->getLayout()
20
+ ->createBlock('faq/adminhtml_category_edit_tab_form')
21
+ ->toHtml()
22
+ ));
23
+ return parent::_beforeToHtml();
24
+
25
+
26
+ }
27
+ }
28
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Category/Grid.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Category_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ /**
6
+ * Set defaults
7
+ */
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('categoryGrid');
12
+ $this->setDefaultSort('faq_cat_id');
13
+ $this->setDefaultDir('desc');
14
+ $this->setSaveParametersInSession(true);
15
+ $this->setUseAjax(true);
16
+ }
17
+
18
+ /**
19
+ * Instantiate and prepare collection
20
+ *
21
+ * @return Zeon_Faq_Block_Adminhtml_List_Grid
22
+ */
23
+ protected function _prepareCollection()
24
+ {
25
+ $collection = Mage::getModel('faq/category')->getCollection();
26
+ $this->setCollection($collection);
27
+ return parent::_prepareCollection();
28
+
29
+ }
30
+ /**
31
+ * Define grid columns
32
+ */
33
+ protected function _prepareColumns()
34
+ {
35
+ $this->addColumn(
36
+ 'faq_cat_id',
37
+ array(
38
+ 'header'=> Mage::helper('faq')->__('ID'),
39
+ 'type' => 'number',
40
+ 'width' => '1',
41
+ 'index' => 'faq_cat_id',
42
+ )
43
+ );
44
+
45
+ $this->addColumn(
46
+ 'name',
47
+ array(
48
+ 'header' => Mage::helper('faq')->__('Category Name'),
49
+ 'index' => 'name',
50
+ )
51
+ );
52
+
53
+ $this->addColumn(
54
+ 'status',
55
+ array(
56
+ 'header' => Mage::helper('faq')->__('Status'),
57
+ 'align' => 'center',
58
+ 'width' => 1,
59
+ 'index' => 'status',
60
+ 'type' => 'options',
61
+ 'options' => Mage::getModel('faq/status')->getAllOptions(),
62
+ )
63
+ );
64
+
65
+ $this->addColumn(
66
+ 'action',
67
+ array(
68
+ 'header' => Mage::helper('faq')->__('Action'),
69
+ 'width' => '50',
70
+ 'type' => 'action',
71
+ 'align' => 'center',
72
+ 'getter' => 'getId',
73
+ 'actions' => array(
74
+ array(
75
+ 'caption' => Mage::helper('faq')->__('Edit'),
76
+ 'url' => array('base'=> '*/*/edit'),
77
+ 'field' => 'id'
78
+ )
79
+ ),
80
+ 'filter' => false,
81
+ 'sortable' => false,
82
+ 'index' => 'action',
83
+ 'is_system' => true,
84
+ )
85
+ );
86
+
87
+ return parent::_prepareColumns();
88
+ }
89
+
90
+
91
+ public function getRowUrl($row)
92
+ {
93
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
94
+ }
95
+
96
+
97
+
98
+ }
app/code/community/CP/Faq/Block/Adminhtml/Faq.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Faq extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_faq';
7
+ $this->_blockGroup = 'faq';
8
+ $this->_headerText = Mage::helper('faq')->__('Manage Faq');
9
+ $this->_addButtonLabel = Mage::helper('faq')->__('Add Faq');
10
+ parent::__construct();
11
+ }
12
+
13
+ }
app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Faq_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ protected function _prepareLayout() {
6
+ parent::_prepareLayout();
7
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
8
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
9
+ }
10
+ }
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->_objectId = 'id';
16
+ $this->_blockGroup = 'faq';
17
+ $this->_controller = 'adminhtml_faq';
18
+ $this->_mode = 'edit';
19
+
20
+ $this->_addButton('save_and_continue', array(
21
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
22
+ 'onclick' => 'saveAndContinueEdit()',
23
+ 'class' => 'save',
24
+ ), -100);
25
+ $this->_updateButton('save', 'label', Mage::helper('faq')->__('Save Faq'));
26
+
27
+ $this->_formScripts[] = "
28
+ function toggleEditor() {
29
+ if (tinyMCE.getInstanceById('form_content') == null) {
30
+ tinyMCE.execCommand('mceAddControl', false, 'edit_form');
31
+ } else {
32
+ tinyMCE.execCommand('mceRemoveControl', false, 'edit_form');
33
+ }
34
+ }
35
+
36
+ function saveAndContinueEdit(){
37
+ editForm.submit($('edit_form').action+'back/edit/');
38
+ }
39
+ ";
40
+ }
41
+
42
+ public function getHeaderText()
43
+ {
44
+ if (Mage::registry('faq_data') && Mage::registry('faq_data')->getId())
45
+ {
46
+ return Mage::helper('faq')->__('Edit Faq "%s"', $this->htmlEscape(Mage::registry('faq_data')->getTitle()));
47
+ } else {
48
+ return Mage::helper('faq')->__('New Faq'); }
49
+ }
50
+
51
+ }
52
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Faq_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
+ )
12
+ );
13
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+ }
19
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit/Tab/Form.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Faq_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('faq_form', array('legend'=>Mage::helper('faq')->__('Faq information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('faq')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('status', 'select', array(
19
+ 'label' => Mage::helper('faq')->__('Status'),
20
+ 'name' => 'status',
21
+ 'values' => array(
22
+ array(
23
+ 'value' => 1,
24
+ 'label' => Mage::helper('faq')->__('Active'),
25
+ ),
26
+
27
+ array(
28
+ 'value' => 0,
29
+ 'label' => Mage::helper('faq')->__('Inactive'),
30
+ ),
31
+ ),
32
+ ));
33
+
34
+ $fieldset->addField('is_faq', 'select', array(
35
+ 'label' => Mage::helper('faq')->__('Is Most Frequently Asked Question'),
36
+ 'name' => 'is_faq',
37
+ 'values' => array(
38
+ array(
39
+ 'value' => 1,
40
+ 'label' => Mage::helper('faq')->__('Yes'),
41
+ ),
42
+
43
+ array(
44
+ 'value' => 0,
45
+ 'label' => Mage::helper('faq')->__('No'),
46
+ ),
47
+ ),
48
+ ));
49
+
50
+ $fieldset->addField('username', 'text', array(
51
+ 'label' => Mage::helper('faq')->__('Name'),
52
+ 'class' => 'required-entry',
53
+ 'name' => 'username',
54
+ 'readonly' => 'readonly',
55
+ ));
56
+
57
+ $fieldset->addField('useremail', 'text', array(
58
+ 'label' => Mage::helper('faq')->__('Email'),
59
+ 'class' => 'required-entry',
60
+ 'name' => 'useremail',
61
+ 'readonly' => 'readonly',
62
+ ));
63
+
64
+ $fieldset->addField('faq_category_id', 'select', array(
65
+ 'label' => Mage::helper('faq')->__('Faq Category'),
66
+ 'name' => 'faq_category_id',
67
+ 'values' => Mage::getModel('faq/category')->getCategories(),
68
+ ));
69
+
70
+
71
+ $fieldset->addField('description', 'editor', array(
72
+ 'name' => 'description',
73
+ 'label' => Mage::helper('faq')->__('Description'),
74
+ 'title' => Mage::helper('faq')->__('Description'),
75
+ 'style' => 'width:98%; height:400px;',
76
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
77
+ 'wysiwyg' => true,
78
+ 'required' => true,
79
+ ));
80
+
81
+ if ( Mage::getSingleton('adminhtml/session')->getFaqData() )
82
+ {
83
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getFaqData());
84
+ Mage::getSingleton('adminhtml/session')->setFaqData(null);
85
+ } elseif ( Mage::registry('faq_data') ) {
86
+ $form->setValues(Mage::registry('faq_data')->getData());
87
+ }
88
+ return parent::_prepareForm();
89
+ }
90
+ }
91
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Faq/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Block_Adminhtml_Faq_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('faq_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('faq')->__('Faq Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => 'Faq Information',
18
+ 'title' => 'Faq Information',
19
+ 'content' => $this->getLayout()
20
+ ->createBlock('faq/adminhtml_faq_edit_tab_form')
21
+ ->toHtml()
22
+ ));
23
+ return parent::_beforeToHtml();
24
+
25
+
26
+ }
27
+ }
28
+ ?>
app/code/community/CP/Faq/Block/Adminhtml/Faq/Grid.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ class CP_Faq_Block_Adminhtml_Faq_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+ /**
8
+ * Set defaults
9
+ */
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('faqGrid');
14
+ $this->setDefaultSort('faq_id');
15
+ $this->setDefaultDir('desc');
16
+ $this->setSaveParametersInSession(true);
17
+ $this->setUseAjax(true);
18
+ }
19
+
20
+ /**
21
+ * Instantiate and prepare collection
22
+ *
23
+ * @return Zeon_Faq_Block_Adminhtml_List_Grid
24
+ */
25
+ protected function _prepareCollection()
26
+ {
27
+ $collection = Mage::getModel('faq/faq')->getCollection();
28
+ $this->setCollection($collection);
29
+ return parent::_prepareCollection();
30
+
31
+ }
32
+ /**
33
+ * Define grid columns
34
+ */
35
+ protected function _prepareColumns()
36
+ {
37
+ $this->addColumn(
38
+ 'faq_id',
39
+ array(
40
+ 'header'=> Mage::helper('faq')->__('ID'),
41
+ 'type' => 'number',
42
+ 'width' => '1',
43
+ 'index' => 'faq_id',
44
+ )
45
+ );
46
+
47
+ $this->addColumn(
48
+ 'title',
49
+ array(
50
+ 'header' => Mage::helper('faq')->__('FAQ Title'),
51
+ 'index' => 'title',
52
+ )
53
+ );
54
+
55
+ $this->addColumn(
56
+ 'Faq Category',
57
+ array(
58
+ 'header' => Mage::helper('faq')->__('FAQ Category'),
59
+ 'index' => 'faq_category_id',
60
+ 'renderer' => 'faq/adminhtml_widget_grid_column_renderer_category',
61
+ )
62
+ );
63
+
64
+ /* $this->addColumn(
65
+ 'Most Frequently',
66
+ array(
67
+ 'header' => Mage::helper('faq')->__('Most Frequently'),
68
+ 'index' => 'is_faq',
69
+ 'type' => 'options',
70
+ 'options' =>
71
+ array(
72
+ CP_Faq_Model_Status::STATUS_ENABLED => Mage::helper('faq')->__('Yes'),
73
+ CP_Faq_Model_Status::STATUS_DISABLED => Mage::helper('faq')->__('No'),
74
+ ),
75
+ )
76
+ );
77
+ $this->addColumn(
78
+ 'status',
79
+ array(
80
+ 'header' => Mage::helper('faq')->__('Status'),
81
+ 'align' => 'center',
82
+ 'width' => 1,
83
+ 'index' => 'status',
84
+ 'type' => 'options',
85
+ //'options' => Mage::getModel('faq/status')->getAllOptions(),
86
+ 'options' =>
87
+ array(
88
+ CP_Faq_Model_Status::STATUS_ENABLED => Mage::helper('faq')->__('Yes'),
89
+ CP_Faq_Model_Status::STATUS_DISABLED => Mage::helper('faq')->__('No'),
90
+ ),
91
+ )
92
+ );*/
93
+ $this->addColumn(
94
+ 'Status',
95
+ array(
96
+ 'header' => Mage::helper('faq')->__('Status'),
97
+ 'index' => 'status',
98
+ 'type' => 'options',
99
+ 'options' =>
100
+ array(
101
+ CP_Faq_Model_Status::STATUS_ENABLED => Mage::helper('faq')->__('Active'),
102
+ CP_Faq_Model_Status::STATUS_DISABLED => Mage::helper('faq')->__('Inactive'),
103
+ ),
104
+ )
105
+ );
106
+
107
+ /* $this->addColumn(
108
+ 'faq_category',
109
+ array(
110
+ 'header' => Mage::helper('zeon_faq')->__('FAQ Category'),
111
+ 'type' => 'text',
112
+ 'index' => 'category_name',
113
+ )
114
+ );
115
+
116
+ $this->addColumn(
117
+ 'is_most_frequently',
118
+ array(
119
+ 'header' => Mage::helper('zeon_faq')->__('Most Frequently'),
120
+ 'index' => 'is_most_frequently',
121
+ 'type' => 'options',
122
+ 'options' =>
123
+ array(
124
+ Zeon_Faq_Model_Status::STATUS_ENABLED => Mage::helper('zeon_faq')->__('Yes'),
125
+ Zeon_Faq_Model_Status::STATUS_DISABLED => Mage::helper('zeon_faq')->__('No'),
126
+ ),
127
+ )
128
+ );
129
+
130
+ $this->addColumn(
131
+ 'update_time',
132
+ array(
133
+ 'header'=> Mage::helper('zeon_faq')->__('Last Updated'),
134
+ 'type' => 'datetime',
135
+ 'index'=> 'update_time',
136
+ )
137
+ );
138
+
139
+ $this->addColumn(
140
+ 'status',
141
+ array(
142
+ 'header' => Mage::helper('zeon_faq')->__('Status'),
143
+ 'align' => 'center',
144
+ 'width' => 1,
145
+ 'index' => 'status',
146
+ 'type' => 'options',
147
+ 'options' => Mage::getModel('zeon_faq/status')->getAllOptions(),
148
+ )
149
+ );
150
+
151
+
152
+ if (!Mage::app()->isSingleStoreMode()) {
153
+ $this->addColumn(
154
+ 'visible_in',
155
+ array(
156
+ 'header' => Mage::helper('zeon_faq')->__('Visible In'),
157
+ 'type' => 'store',
158
+ 'index' => 'stores',
159
+ 'sortable' => false,
160
+ 'store_view' => true,
161
+ 'width' => 200
162
+ )
163
+ );
164
+
165
+ }
166
+ */
167
+ $this->addColumn(
168
+ 'action',
169
+ array(
170
+ 'header' => Mage::helper('faq')->__('Action'),
171
+ 'width' => '50',
172
+ 'type' => 'action',
173
+ 'align' => 'center',
174
+ 'getter' => 'getId',
175
+ 'actions' => array(
176
+ array(
177
+ 'caption' => Mage::helper('faq')->__('Edit'),
178
+ 'url' => array('base'=> '*/*/edit'),
179
+ 'field' => 'id'
180
+ )
181
+ ),
182
+ 'filter' => false,
183
+ 'sortable' => false,
184
+ 'index' => 'action',
185
+ 'is_system' => true,
186
+ )
187
+ );
188
+
189
+ return parent::_prepareColumns();
190
+ }
191
+
192
+ public function getRowUrl($row)
193
+ {
194
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
195
+ }
196
+
197
+ }
app/code/community/CP/Faq/Block/Adminhtml/Widget/Grid/Column/Renderer/Category.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Block_Adminhtml_Widget_Grid_Column_Renderer_Category extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ /**
5
+ * Renders grid column
6
+ *
7
+ * @param Varien_Object $row
8
+ * @return string
9
+ */
10
+ public function render(Varien_Object $row)
11
+ {
12
+ if($row->getFaqCategoryId()){
13
+ $cat = Mage::getModel('faq/category')->load($row->getFaqCategoryId());
14
+ return $cat->getName();
15
+ }
16
+ }
17
+ }
app/code/community/CP/Faq/Block/Category.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Block_Category extends Mage_Core_Block_Template{
3
+
4
+ public function getCategoryCollection()
5
+ {
6
+ $this->_categoryCollection = Mage::getModel('faq/category')
7
+ ->getCollection()
8
+ ->distinct(true)
9
+ ->addFieldToFilter('status','1');
10
+
11
+
12
+ return $this->_categoryCollection;
13
+ }
14
+ public function isActiveCategory($category)
15
+ {
16
+ $current_catid = $this->getRequest()->getParam('category_id');
17
+
18
+ if($category->getData('faq_cat_id') == $current_catid)
19
+ {
20
+ return true;
21
+
22
+ }
23
+ else
24
+ {
25
+ return false;
26
+
27
+ }
28
+ }
29
+
30
+ public function getmfaqCollection()
31
+ {
32
+ $this->_mfaqCollection = Mage::getModel('faq/faq')
33
+ ->getCollection()
34
+ ->distinct(true)
35
+ ->addFilter('is_faq','1')
36
+ ->addFilter('status','1');
37
+
38
+ return $this->_mfaqCollection;
39
+ }
40
+
41
+ }
app/code/community/CP/Faq/Block/Faq.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Block_Faq extends Mage_Core_Block_Template{
3
+
4
+ protected $_faqCollection;
5
+
6
+
7
+ public function getCategoryCollection()
8
+ {
9
+ $this->_categoryCollection = Mage::getModel('faq/category')
10
+ ->getCollection()
11
+ ->distinct(true)
12
+ ->addFieldToFilter('status','1');
13
+
14
+
15
+ return $this->_categoryCollection;
16
+ }
17
+
18
+ protected function _prepareLayout()
19
+ {
20
+ parent::_prepareLayout();
21
+
22
+ $_pageAvailableLimit = array(4=>4,6=>6,10=>10,all=>all);
23
+ $pager = $this->getLayout()
24
+ ->createBlock('page/html_pager', 'my.pager');
25
+ $pager->setAvailableLimit($_pageAvailableLimit);
26
+ $pager->setCollection($this->getMyCollection());
27
+
28
+ $this->setChild('pager', $pager);
29
+ $this->getMyCollection()->load();
30
+
31
+ }
32
+
33
+ protected function getMyCollection()
34
+ {
35
+ if (is_null($this->_myCollection)) {
36
+
37
+ $this->_myCollection = Mage::getModel('faq/faq')
38
+ ->getCollection()
39
+ ->distinct(true)
40
+ ->addFilter('status','1');
41
+ $current_catid = $this->getRequest()->getParam('category_id');
42
+
43
+ // get identifier from faq_category table
44
+ $ident = Mage::getModel('faq/category')
45
+ ->getCollection()
46
+ ->addFieldToFilter('identifier',$current_catid)
47
+ ->addFieldToSelect('faq_cat_id')
48
+ ->getData();
49
+
50
+ $cat_id_from_tbl = $ident[0]['faq_cat_id'];
51
+
52
+ if($current_catid)
53
+ {
54
+ $this->_myCollection->addFieldToFilter('faq_category_id', $cat_id_from_tbl);
55
+ }
56
+ $mfaq = $this->getRequest()->getParam(0);
57
+ if($mfaq == 'mfaq')
58
+ {
59
+ $this->_myCollection->addFieldToFilter('is_faq', 1);
60
+ }
61
+ }
62
+
63
+ return $this->_myCollection;
64
+ }
65
+
66
+ public function getPagerHtml()
67
+ {
68
+ return $this->getChildHtml('pager');
69
+ }
70
+
71
+ public function getCatName($cat_id)
72
+ {
73
+
74
+ $catname = Mage::getModel('faq/category')->getCollection()->AddFieldToFilter('identifier',$cat_id)->AddFieldToSelect('name')->getData();
75
+ return($catname[0]['name']);
76
+ }
77
+
78
+
79
+
80
+
81
+
82
+ }
app/code/community/CP/Faq/Block/Toolbar.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Block_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar{
3
+ public function getPagerHtml()
4
+ {
5
+ // echo 'asdasd'; exit;
6
+ $pagerBlock = $this->getLayout()->createBlock('page/html_pager');
7
+
8
+ if ($pagerBlock instanceof Varien_Object) {
9
+
10
+ /* @var $pagerBlock Mage_Page_Block_Html_Pager */
11
+ $pagerBlock->setAvailableLimit($this->getAvailableLimit());
12
+
13
+ $pagerBlock->setUseContainer(false)
14
+ ->setShowPerPage(false)
15
+ ->setShowAmounts(false)
16
+ ->setLimitVarName($this->getLimitVarName())
17
+ ->setPageVarName($this->getPageVarName())
18
+ ->setLimit(2)//$this->getLimit())
19
+ ->setCollection($this->getCollection());
20
+ return $pagerBlock->toHtml();
21
+ }
22
+ return '';
23
+ }
24
+ }
app/code/community/CP/Faq/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ /**
5
+ * Retrieve Faq URL
6
+ *
7
+ * @return string
8
+ */
9
+ public function getFaqUrl()
10
+ {
11
+ return $this->_getUrl('faq');
12
+ }
13
+ }
14
+
app/code/community/CP/Faq/Model/Category.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Model_Category extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/category');
9
+ }
10
+
11
+ public function getCategories() {
12
+
13
+ $statesArray = array();
14
+ foreach($this->getCollection() as $state){
15
+ $statesArray[$state->getfaq_cat_id()] = $state->getName();
16
+
17
+ }
18
+
19
+ return $statesArray;
20
+
21
+ }
22
+ }
23
+ ?>
app/code/community/CP/Faq/Model/Faq.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Model_Faq extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faq/faq');
9
+ }
10
+ }
11
+ ?>
app/code/community/CP/Faq/Model/Mysql4/Category.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('faq/category', 'faq_cat_id');
8
+ }
9
+ }
10
+ ?>
app/code/community/CP/Faq/Model/Mysql4/Category/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::__construct();
8
+ $this->_init('faq/category');
9
+ }
10
+ }
11
+ ?>
app/code/community/CP/Faq/Model/Mysql4/Faq.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Model_Mysql4_Faq extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('faq/faq', 'faq_id');
8
+ }
9
+ }
10
+ ?>
app/code/community/CP/Faq/Model/Mysql4/Faq/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CP_Faq_Model_Mysql4_Faq_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::__construct();
8
+ $this->_init('faq/faq');
9
+ }
10
+ }
11
+ ?>
app/code/community/CP/Faq/Model/Status.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * zeonsolutions inc.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the EULA
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://www.zeonsolutions.com/shop/license-community.txt
12
+ *
13
+ * =================================================================
14
+ * MAGENTO EDITION USAGE NOTICE
15
+ * This package designed for Magento COMMUNITY edition
16
+ * =================================================================
17
+ * zeonsolutions does not guarantee correct work of this extension
18
+ * on any other Magento edition except Magento COMMUNITY edition.
19
+ * zeonsolutions does not provide extension support in case of
20
+ * incorrect edition usage.
21
+ * =================================================================
22
+ *
23
+ * @category Zeon
24
+ * @package Zeon_Faq
25
+ * @version 0.0.1
26
+ * @copyright @copyright Copyright (c) 2013 zeonsolutions.Inc. (http://www.zeonsolutions.com)
27
+ * @license http://www.zeonsolutions.com/shop/license-community.txt
28
+ */
29
+
30
+ class CP_Faq_Model_Status extends Varien_Object
31
+ {
32
+ const STATUS_ENABLED = 1;
33
+ const STATUS_DISABLED = 0;
34
+
35
+ static public function getAllOptions()
36
+ {
37
+ return array(
38
+ self::STATUS_ENABLED => Mage::helper('faq')->__('Enabled'),
39
+ self::STATUS_DISABLED => Mage::helper('faq')->__('Disabled')
40
+ );
41
+ }
42
+ }
app/code/community/CP/Faq/controllers/Adminhtml/CategoryController.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Adminhtml_CategoryController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->_title($this->__("FAQ Categories"));
8
+ $this->renderLayout();
9
+ }
10
+ public function editAction()
11
+ {
12
+ $faqId = $this->getRequest()->getParam('id');
13
+ $faqModel = Mage::getModel('faq/category')->load($faqId);
14
+
15
+ if ($faqModel->getId() || $faqId == 0) {
16
+
17
+ Mage::register('category_data', $faqModel);
18
+
19
+ $this->loadLayout();
20
+ $this->_setActiveMenu('category/items');
21
+
22
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
23
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
24
+
25
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
26
+
27
+ $this->_addContent($this->getLayout()->createBlock('faq/adminhtml_category_edit'))
28
+ ->_addLeft($this->getLayout()->createBlock('faq/adminhtml_category_edit_tabs'));
29
+
30
+ $this->renderLayout();
31
+ } else {
32
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Faq does not exist'));
33
+ $this->_redirect('*/*/');
34
+ }
35
+ }
36
+
37
+ public function newAction()
38
+ {
39
+ $this->_forward('edit');
40
+ }
41
+
42
+ public function saveAction()
43
+ {
44
+ if ( $this->getRequest()->getPost() ) {
45
+ try {
46
+ $postData = $this->getRequest()->getPost();
47
+ $faqModel = Mage::getModel('faq/category');
48
+
49
+
50
+ $ident = strtolower(preg_replace("/[^a-zA-Z0-9]+/", "_", $postData['name']));
51
+
52
+ //echo $ident; exit;
53
+ $faqModel->setId($this->getRequest()->getParam('id'))
54
+ ->setName($postData['name'])
55
+ ->setStatus($postData['status'])
56
+ ->setIdentifier($ident)
57
+ ->save();
58
+
59
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Faq Category was successfully saved'));
60
+ Mage::getSingleton('adminhtml/session')->setcategoryData(false);
61
+
62
+ $this->_redirect('*/*/');
63
+ return;
64
+ } catch (Exception $e) {
65
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
66
+ Mage::getSingleton('adminhtml/session')->setCategoryData($this->getRequest()->getPost());
67
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
68
+ return;
69
+ }
70
+ }
71
+ $this->_redirect('*/*/');
72
+ }
73
+
74
+ public function deleteAction()
75
+ {
76
+ if( $this->getRequest()->getParam('id') > 0 ) {
77
+ try {
78
+ $faqModel = Mage::getModel('faq/category');
79
+
80
+ $faqModel->setId($this->getRequest()->getParam('id'))
81
+ ->delete();
82
+
83
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Faq Category was successfully deleted'));
84
+ $this->_redirect('*/*/');
85
+ } catch (Exception $e) {
86
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
87
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
88
+ }
89
+ }
90
+ $this->_redirect('*/*/');
91
+ }
92
+ /**
93
+ * Product grid for AJAX request.
94
+ * Sort and filter result for example.
95
+ */
96
+ public function gridAction()
97
+ {
98
+ $this->loadLayout();
99
+ $this->getResponse()->setBody(
100
+ $this->getLayout()->createBlock('faq/adminhtml_category_grid')->toHtml()
101
+ );
102
+ }
103
+ }
app/code/community/CP/Faq/controllers/Adminhtml/FaqController.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_Adminhtml_FaqController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->_title($this->__("Frequently Asked Questions"));
8
+ $this->renderLayout();
9
+ }
10
+ public function editAction()
11
+ {
12
+ $faqId = $this->getRequest()->getParam('id');
13
+ $faqModel = Mage::getModel('faq/faq')->load($faqId);
14
+
15
+ if ($faqModel->getId() || $faqId == 0) {
16
+
17
+ Mage::register('faq_data', $faqModel);
18
+
19
+ $this->loadLayout();
20
+ $this->_setActiveMenu('faq/items');
21
+
22
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
23
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
24
+
25
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
26
+
27
+ $this->_addContent($this->getLayout()->createBlock('faq/adminhtml_faq_edit'))
28
+ ->_addLeft($this->getLayout()->createBlock('faq/adminhtml_faq_edit_tabs'));
29
+
30
+ $this->renderLayout();
31
+ } else {
32
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Faq does not exist'));
33
+ $this->_redirect('*/*/');
34
+ }
35
+ }
36
+
37
+ public function newAction()
38
+ {
39
+ $this->_forward('edit');
40
+ }
41
+
42
+ public function saveAction()
43
+ {
44
+ if ( $this->getRequest()->getPost() ) {
45
+ try {
46
+ $postData = $this->getRequest()->getPost();
47
+ $faqModel = Mage::getModel('faq/faq');
48
+ //echo '<pre>'; print_r($postData); exit;
49
+ $faqModel->setId($this->getRequest()->getParam('id'))
50
+ ->setTitle($postData['title'])
51
+ ->setDescription($postData['description'])
52
+ ->setFaqCategoryId($postData['faq_category_id'])
53
+ ->setStatus($postData['status'])
54
+ ->setIsFaq($postData['is_faq'])
55
+ ->save();
56
+
57
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Faq was successfully saved'));
58
+ Mage::getSingleton('adminhtml/session')->setfaqData(false);
59
+
60
+
61
+ } catch (Exception $e) {
62
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
63
+ Mage::getSingleton('adminhtml/session')->setFaqData($this->getRequest()->getPost());
64
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
65
+ return;
66
+ }
67
+ if($postData['username'] != '' && $postData['status'] == 1)
68
+ {
69
+
70
+ //Email send to admin
71
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('reply_create_faq_by_customer_template');
72
+ $faq_cat_identifier = Mage::getModel('faq/category')->load($postData['faq_category_id'])->getIdentifier();
73
+ $faq_cat = Mage::getModel('faq/category')->load($postData['faq_category_id'])->getName();
74
+ $emailTemplateVariables = array();
75
+ $emailTemplateVariables['username'] = $postData['username'];
76
+ $emailTemplateVariables['useremail'] = $postData['useremail'];
77
+ $emailTemplateVariables['title'] = $postData['title'];
78
+ $emailTemplateVariables['faq_category_name'] = $faq_cat;
79
+ $emailTemplateVariables['description'] = $postData['description'];
80
+ $emailTemplateVariables['faq_cat_identifier'] = $faq_cat_identifier;
81
+ $emailTemplateVariables['status'] = $postData['status'];
82
+
83
+ $from_email = Mage::getStoreConfig('trans_email/ident_general/email');
84
+ $from_name = Mage::getStoreConfig('trans_email/ident_general/name');
85
+
86
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
87
+ $mail = Mage::getModel('core/email')
88
+ ->setToName($postData['username'])
89
+ ->setToEmail($postData['useremail'])
90
+ ->setBody($processedTemplate)
91
+ ->setSubject('FAQ reply')
92
+ ->setFromEmail($from_email)
93
+ ->setFromName($from_name)
94
+ ->setType('html');
95
+ try{
96
+ $mail->send();
97
+ $this->_redirect('*/*/');
98
+ return;
99
+ }
100
+ catch(Exception $error)
101
+ {
102
+ Mage::getSingleton('core/session')->addError($error->getMessage());
103
+ return false;
104
+ }
105
+ }
106
+ // Email send code End
107
+ }
108
+ $this->_redirect('*/*/');
109
+ }
110
+
111
+ public function deleteAction()
112
+ {
113
+ if( $this->getRequest()->getParam('id') > 0 ) {
114
+ try {
115
+ $faqModel = Mage::getModel('faq/faq');
116
+
117
+ $faqModel->setId($this->getRequest()->getParam('id'))
118
+ ->delete();
119
+
120
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Faq was successfully deleted'));
121
+ $this->_redirect('*/*/');
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
125
+ }
126
+ }
127
+ $this->_redirect('*/*/');
128
+ }
129
+ /**
130
+ * Product grid for AJAX request.
131
+ * Sort and filter result for example.
132
+ */
133
+ public function gridAction()
134
+ {
135
+ $this->loadLayout();
136
+ $this->getResponse()->setBody(
137
+ $this->getLayout()->createBlock('faq/adminhtml_faq_grid')->toHtml()
138
+ );
139
+ }
140
+ }
app/code/community/CP/Faq/controllers/IndexController.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CP_Faq_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function indexAction() {
4
+ $this->loadLayout();
5
+ $this->renderLayout();
6
+ }
7
+
8
+ public function addfaqAction()
9
+ {
10
+
11
+ if($this->getRequest()->getPost())
12
+ {
13
+ $username = $this->getRequest()->getParam('username');
14
+ $useremail = $this->getRequest()->getParam('useremail');
15
+ $question = $this->getRequest()->getParam('question');
16
+ //$ques_desc = $this->getRequest()->getParam('ques_desc');
17
+ $drp_category = $this->getRequest()->getParam('drp_category');
18
+ if(!$drp_category)
19
+ $mostFaqAskd = 1;
20
+ $faqmodel = Mage::getModel('faq/faq');
21
+ $data = array('title'=>$question ,
22
+ 'faq_category_id'=>$drp_category,
23
+ 'is_faq'=>$mostFaqAskd,
24
+ 'description'=>$ques_desc,
25
+ 'username' => $username,
26
+ 'useremail'=>$useremail,
27
+ 'status'=>'0',
28
+ );
29
+
30
+ $faqmodel->setData($data);
31
+ $faqmodel->save();
32
+ $faq_cat = Mage::getModel('faq/category')->load($drp_category)->getName();
33
+ $faq_cat_identifier = Mage::getModel('faq/category')->load($drp_category)->getIdentifier();
34
+ // Send email to CUSTOMER code started
35
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('create_faq_by_customer_template');
36
+ $emailTemplateVariables = array();
37
+ $emailTemplateVariables['username'] = $username;
38
+ $emailTemplateVariables['useremail'] = $useremail;
39
+ $emailTemplateVariables['title'] = $question;
40
+ $emailTemplateVariables['faq_category_name'] = $faq_cat;
41
+ $emailTemplateVariables['faq_cat_identifier'] = $faq_cat_identifier;
42
+ $from_email = Mage::getStoreConfig('trans_email/ident_general/email');
43
+ $from_name = Mage::getStoreConfig('trans_email/ident_general/name');
44
+
45
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
46
+ $mail = Mage::getModel('core/email')
47
+ ->setToName($username)
48
+ ->setToEmail($useremail)
49
+ ->setBody($processedTemplate)
50
+ ->setSubject('New Faq by customer')
51
+ ->setFromEmail($from_email)
52
+ ->setFromName($from_name)
53
+ ->setType('html');
54
+ try{
55
+ $mail->send();
56
+ }
57
+ catch(Exception $error)
58
+ {
59
+ Mage::getSingleton('core/session')->addError($error->getMessage());
60
+ return false;
61
+ }
62
+ // Send email to ADMIN code started
63
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('admin_create_faq_by_customer_template');
64
+ $emailTemplateVariables = array();
65
+ $emailTemplateVariables['username'] = $username;
66
+ $emailTemplateVariables['useremail'] = $useremail;
67
+ $emailTemplateVariables['title'] = $question;
68
+ $emailTemplateVariables['faq_category_name'] = $faq_cat;
69
+ // $emailTemplateVariables['description'] = $ques_desc;
70
+ $emailTemplateVariables['faq_cat_identifier'] = $faq_cat_identifier;
71
+ $from_email = Mage::getStoreConfig('trans_email/ident_general/email');
72
+ $from_name = Mage::getStoreConfig('trans_email/ident_general/name');
73
+
74
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
75
+ $mail1 = Mage::getModel('core/email')
76
+ ->setToName($from_name)
77
+ ->setToEmail($from_email)
78
+ ->setBody($processedTemplate)
79
+ ->setSubject('New Faq by customer')
80
+ ->setFromEmail($from_email)
81
+ ->setFromName($from_name)
82
+ ->setType('html');
83
+ try{
84
+ $mail1->send();
85
+ }
86
+ catch(Exception $error)
87
+ {
88
+ Mage::getSingleton('core/session')->addError($error->getMessage());
89
+ return false;
90
+ }
91
+
92
+ Mage::getSingleton('core/session')->addSuccess('Your question is saved. You will get email once admin approves your question.');
93
+ }
94
+ $this->loadLayout();
95
+ $this->renderLayout();
96
+ }
97
+ }
app/code/community/CP/Faq/etc/config.xml ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CP_Faq>
5
+ <version>0.1.0</version>
6
+ </CP_Faq>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <faq>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>CP_Faq</module>
14
+ <frontName>faq</frontName>
15
+ </args>
16
+ </faq>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <faq>
21
+ <file>faq.xml</file>
22
+ </faq>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+
28
+ <models>
29
+ <faq>
30
+ <class>CP_Faq_Model</class>
31
+ <resourceModel>faq_mysql4</resourceModel>
32
+ </faq>
33
+ <faq_mysql4>
34
+ <class>CP_Faq_Model_Mysql4</class>
35
+ <entities>
36
+ <faq>
37
+ <table>faq</table>
38
+ </faq>
39
+ <category>
40
+ <table>faq_category</table>
41
+ </category>
42
+ </entities>
43
+ </faq_mysql4>
44
+ </models>
45
+ <helpers>
46
+ <faq>
47
+ <class>CP_Faq_Helper</class>
48
+ </faq>
49
+ </helpers>
50
+ <blocks>
51
+ <faq>
52
+ <class>CP_Faq_Block</class>
53
+ </faq>
54
+
55
+ </blocks>
56
+ <resources>
57
+ <faq_setup>
58
+ <setup>
59
+ <module>CP_Faq</module>
60
+ </setup>
61
+ <connection>
62
+ <use>core_setup</use>
63
+ </connection>
64
+ </faq_setup>
65
+ <faq_write>
66
+ <connection>
67
+ <use>core_write</use>
68
+ </connection>
69
+ </faq_write>
70
+ <faq_read>
71
+ <connection>
72
+ <use>core_read</use>
73
+ </connection>
74
+ </faq_read>
75
+ </resources>
76
+ <template>
77
+ <email>
78
+ <create_faq_by_customer_template module="faq">
79
+ <label>Create Faq by Customer</label>
80
+ <file>create_faq_by_customer.html</file>
81
+ <type>html</type>
82
+ </create_faq_by_customer_template>
83
+ <admin_create_faq_by_customer_template module="faq">
84
+ <label>Admin Create Faq by Customer</label>
85
+ <file>admin_create_faq_by_customer.html</file>
86
+ <type>html</type>
87
+ </admin_create_faq_by_customer_template>
88
+ <reply_create_faq_by_customer_template module="faq">
89
+ <label>Reply Create Faq by Customer</label>
90
+ <file>reply_create_faq_by_customer.html</file>
91
+ <type>html</type>
92
+ </reply_create_faq_by_customer_template>
93
+ </email>
94
+ </template>
95
+ </global>
96
+ <admin>
97
+ <routers>
98
+ <admin_faq>
99
+ <use>admin</use>
100
+ <args>
101
+ <module>CP_Faq</module>
102
+ <frontName>admin_faq</frontName>
103
+ </args>
104
+ </admin_faq>
105
+ </routers>
106
+ </admin>
107
+ <adminhtml>
108
+ <menu>
109
+ <faq module="faq">
110
+ <title>Faq</title>
111
+ <sort_order>100</sort_order>
112
+ <children>
113
+ <faq module="faq">
114
+ <title>Frequently Asked Questions</title>
115
+ <sort_order>0</sort_order>
116
+ <action>admin_faq/adminhtml_faq</action>
117
+ </faq>
118
+ <faq_category module="faq">
119
+ <title>FAQ Categories</title>
120
+ <sort_order>1</sort_order>
121
+ <action>admin_faq/adminhtml_category</action>
122
+ </faq_category>
123
+ </children>
124
+ </faq>
125
+ </menu>
126
+ <acl>
127
+ <resources>
128
+ <all>
129
+ <title>Allow Everything</title>
130
+ </all>
131
+ <admin>
132
+ <children>
133
+ <faq translate="title" module="faq">
134
+ <title>Faq</title>
135
+ <sort_order>1000</sort_order>
136
+ <children>
137
+ <faq translate="title">
138
+ <title>Frequently Asked Questions</title>
139
+ </faq>
140
+ </children>
141
+ </faq>
142
+ </children>
143
+ </admin>
144
+ </resources>
145
+ </acl>
146
+ <layout>
147
+ <updates>
148
+ <faq>
149
+ <file>faq.xml</file>
150
+ </faq>
151
+ </updates>
152
+ </layout>
153
+ </adminhtml>
154
+ </config>
app/code/community/CP/Faq/sql/faq_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $table = $installer->getConnection()
6
+ ->newTable($installer->getTable('faq'))
7
+ ->addColumn('faq_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
8
+ 'identity' => true,
9
+ 'unsigned' => true,
10
+ 'nullable' => false,
11
+ 'primary' => true,
12
+ ), 'Increment ID')
13
+ ->addColumn('title', Varien_Db_Ddl_Table::TYPE_VARCHAR, 125, array(
14
+ 'unsigned' => true,
15
+ 'nullable' => false,
16
+ ), 'title')
17
+ ->addColumn('description', Varien_Db_Ddl_Table::TYPE_VARCHAR, 500, array(
18
+ 'unsigned' => true,
19
+ 'nullable' => false,
20
+ ), 'description')
21
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
22
+ 'unsigned' => true,
23
+ 'nullable' => false,
24
+ ), 'status')
25
+ ->addColumn('faq_category_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
26
+ 'unsigned' => true,
27
+ 'default' => '0',
28
+ ), 'faq_category_id')
29
+ ->addColumn('is_faq', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
30
+ 'unsigned' => true,
31
+ 'nullable' => false,
32
+ ), 'is_faq')
33
+ ->addColumn('username', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
34
+ 'unsigned' => true,
35
+ 'nullable' => false,
36
+ ), 'username')
37
+ ->addColumn('useremail', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
38
+ 'unsigned' => true,
39
+ 'nullable' => false,
40
+ ), 'useremail')
41
+ ->setComment('Faq Main Table');
42
+ $installer->getConnection()->createTable($table);
43
+
44
+
45
+ $table = $installer->getConnection()
46
+ ->newTable($installer->getTable('faq_category'))
47
+ ->addColumn('faq_cat_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
48
+ 'identity' => true,
49
+ 'unsigned' => true,
50
+ 'nullable' => false,
51
+ 'primary' => true,
52
+ ), 'Increment ID')
53
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 125, array(
54
+ 'unsigned' => true,
55
+ 'nullable' => false,
56
+ ), 'name')
57
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
58
+ 'unsigned' => true,
59
+ 'nullable' => false,
60
+ ), 'status')
61
+ ->addColumn('identifier', Varien_Db_Ddl_Table::TYPE_VARCHAR, 100, array(
62
+ 'unsigned' => true,
63
+ 'default' => '0',
64
+ ), 'identifier')
65
+ ->setComment('Faq Category Main Table');
66
+ $installer->getConnection()->createTable($table);
67
+
68
+ $installer->endSetup();
69
+
app/design/adminhtml/default/default/layout/faq.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <admin_faq_adminhtml_faq_index>
4
+ <reference name="content">
5
+ <block type="faq/adminhtml_faq" name="faq"/>
6
+ </reference>
7
+ </admin_faq_adminhtml_faq_index>
8
+ <admin_faq_adminhtml_category_index>
9
+ <reference name="content">
10
+ <block type="faq/adminhtml_category" name="category"/>
11
+ </reference>
12
+ </admin_faq_adminhtml_category_index>
13
+
14
+ </layout>
app/design/frontend/default/default/layout/faq.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="root">
5
+ <reference name="top.links">
6
+ <action method="addLink" translate="label title" module="faq"><label>FAQs</label><url helper="faq/getFaqUrl"/><title>FAQs</title><prepare/><urlParams/><position>100</position></action>
7
+ </reference>
8
+ </reference>
9
+ </default>
10
+
11
+ <faq_index_index translate="label">
12
+ <reference name="head">
13
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq.css</name><params/></action>
14
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq_responsive.css</name><params/></action>
15
+ </reference>
16
+
17
+
18
+ <reference name="root">
19
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
20
+
21
+ </reference>
22
+ <reference name="left">
23
+ <remove name="catalog.leftnav" />
24
+ <remove name="catalog.leftnav.filter" />
25
+ <remove name="sidenav" />
26
+ <remove name="left.catalog.compare.sidebar" />
27
+ <block type="faq/category" template="faq/category.phtml" />
28
+ </reference>
29
+ <reference name="content">
30
+ <block type="faq/faq" template="faq/list.phtml" >
31
+ <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
32
+ <block type="page/html_pager" name="product_list_toolbar_pager" />
33
+
34
+ </block>
35
+
36
+ </block>
37
+ </reference>
38
+
39
+ </faq_index_index>
40
+
41
+ <faq_index_addfaq>
42
+ <reference name="head">
43
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq.css</name><params/></action>
44
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq_responsive.css</name><params/></action>
45
+ </reference>
46
+ <reference name="root">
47
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
48
+ </reference>
49
+
50
+ <reference name="left">
51
+ <remove name="catalog.leftnav" />
52
+ <remove name="catalog.leftnav.filter" />
53
+ <remove name="sidenav" />
54
+ <remove name="left.catalog.compare.sidebar" />
55
+ <block type="faq/category" template="faq/category.phtml" />
56
+ </reference>
57
+ <reference name="content">
58
+ <block type="faq/faq" name="addfaq" template="faq/addfaq.phtml" />
59
+ </reference>
60
+ </faq_index_addfaq>
61
+
62
+ </layout>
63
+
app/design/frontend/default/default/template/faq/addfaq.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+
3
+ <h1><?php echo $this->__('Frequently Asked Questions') ?></h1>
4
+
5
+ </div>
6
+ <div class="block">
7
+ <div class="block-title">
8
+ <strong><span><?php echo $this->__('Add FAQ') ?></span></strong>
9
+ </div>
10
+ <div class="block-content">
11
+ <form name="addfaq" id="addfaq" action="<?php echo Mage::getUrl('faq')?>index/addfaq" method="post">
12
+ <div class="fieldset">
13
+
14
+ <ul class="form-list">
15
+ <li class="fields">
16
+ <div class="field">
17
+ <label for="username"><?php echo $this->__('Name') ?> <span class="required">*</span></label>
18
+ <input name="username" id="username" title="user name" value="" class="input-text required-entry" type="text" />
19
+ </div>
20
+ <div class="field">
21
+ <label for="useremail"><?php echo $this->__('Email') ?> <span class="required">*</span></label>
22
+ <input name="useremail" id="useremail" title="useremail" value="" class="input-text required-entry validate-email" type="text" />
23
+ </div>
24
+ </li>
25
+
26
+ <?php $categories = $this->getCategoryCollection(); ?>
27
+ <?php if(count($categories)): ?>
28
+ <li class="fields">
29
+ <div class="field">
30
+ <label for="drp_category"><?php echo $this->__('Category') ?></label>
31
+ <div class="faqinput-select">
32
+ <select name="drp_category" id="drp_category">
33
+ <?php
34
+ foreach($categories as $cat)
35
+ {
36
+ echo '<option value="'.$cat->getFaqCatId().'">'.$cat->getName().'</option>';
37
+ }
38
+ ?>
39
+
40
+ </select>
41
+ </div>
42
+ </div>
43
+ </li>
44
+ <?php endif; ?>
45
+
46
+ <li class="wide">
47
+ <div class="field">
48
+ <label for="question"><?php echo $this->__('Question') ?> <span class="required">*</span></label>
49
+ <input name="question" id="question" title="Question" value="" class="input-text required-entry" type="text" />
50
+ </div>
51
+ </li>
52
+ </ul>
53
+ </div>
54
+ <div class="buttons-set">
55
+ <input type="submit" name="submit" value="<?php echo $this->__('Submit') ?>" />
56
+ </div>
57
+ <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
58
+ </form>
59
+ <script type="text/javascript">
60
+ //< ![CDATA[
61
+ var customForm = new VarienForm('addfaq');
62
+ //]]>
63
+ </script>
64
+ </div>
65
+ </div>
app/design/frontend/default/default/template/faq/category.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_categories = $this->getCategoryCollection(); ?>
2
+ <?php $_mfaqQuestions = $this->getmfaqCollection(); ?>
3
+ <?php if($_categories->count()): ?>
4
+ <div class="block">
5
+ <div class="block-title">
6
+ <strong><span><?php echo $this->__('Filter By Categories') ?></span></strong>
7
+ </div>
8
+ <div class="block-content">
9
+ <ul id="narrow-by-list">
10
+ <?php if($_mfaqQuestions->count()):?>
11
+ <li><a href="<?php echo $this->getUrl('faq',array('mfaq')) ?>"><?php echo $this->__('Frequently Asked Questions') ?></a></li>
12
+ <?php endif;?>
13
+ <?php foreach ($_categories as $_category): ?>
14
+ <li <?php if($this->isActiveCategory($_category)): ?>class="active"<?php endif;?>>
15
+ <a href="<?php echo Mage::getUrl('faq', array('category_id' => $_category->getIdentifier())); ?>">
16
+ <?php echo $this->__($_category->getName()) ?></a>
17
+ </li>
18
+ <?php endforeach; ?>
19
+ </ul>
20
+ </div>
21
+ </div>
22
+ <?php else:?>
23
+ <?php if($_mfaqQuestions->count()):?>
24
+ <div class="block">
25
+ <div class="block-title">
26
+ <strong><span><?php echo $this->__('Filter By Categories') ?></span></strong>
27
+ </div>
28
+ <div class="block-content">
29
+ <ul id="narrow-by-list">
30
+ <li><a href="<?php echo $this->getUrl('faq',array('mfaq')) ?>"><?php echo $this->__('Frequently Asked Questions') ?></a></li>
31
+ </ul>
32
+ </div>
33
+ </div>
34
+ <?php endif;?>
35
+ <?php endif;?>
app/design/frontend/default/default/template/faq/list.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_faqCollection=$this->getMyCollection(); ?>
2
+ <div class="page-title">
3
+ <?php if($categoryId = $this->getRequest()->getParam('category_id')): ?>
4
+ <?php $categoryTitle = $this->getCatName($categoryId); ?>
5
+ <h1><?php echo $this->__('Frequently Asked Questions - ') ?><?php echo $this->htmlEscape($categoryTitle) ?></h1>
6
+ <?php elseif ($this->getRequest()->getParam('mfaq')):?>
7
+ <h1><?php echo $this->__('Frequently Asked Questions') ?></h1>
8
+ <?php else: ?>
9
+ <h1><?php echo $this->__('Frequently Asked Questions') ?></h1>
10
+ <?php endif; ?>
11
+ </div>
12
+ <div class="add-faq" >
13
+ <a href="<?php echo Mage::getUrl('faq') ?>index/addfaq">Add FAQ</a>
14
+ </div>
15
+ <?php echo $this->getChildHtml('faq_search_form') ?>
16
+ <?php echo $this->getPagerHtml() ?>
17
+ <?php if(!$_faqCollection->count()): ?>
18
+ <p class="note-msg"><?php echo $this->__('There are no faq matching the selection.') ?></p>
19
+ <?php else: ?>
20
+ <div class="std">
21
+ <ul class="disc">
22
+ <?php foreach ($_faqCollection as $_faq): ?>
23
+ <li><a href="<?php echo "#".$this->htmlEscape($_faq->getTitle()) ?>"><?php echo $this->htmlEscape($_faq->getTitle()) ?></a></li>
24
+ <?php endforeach; ?>
25
+ </ul>
26
+ <dl class="generic-dl">
27
+ <?php foreach ($_faqCollection as $_faq): ?>
28
+ <dt id="<?php echo $this->htmlEscape($_faq->getTitle()) ?>"><?php echo $this->__('Q. ').$this->htmlEscape($_faq->getTitle()) ?></dt>
29
+ <dd><strong>A. </strong><?php echo $_faq->getDescription() ?></dd>
30
+ <?php endforeach; ?>
31
+ </dl>
32
+ </div>
33
+ <?php endif; ?>
app/etc/modules/CP_Faq.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CP_Faq>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ </CP_Faq>
9
+ </modules>
10
+ </config>
app/locale/en_US/template/email/admin_create_faq_by_customer.html ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Faq! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "var name":"User Name"
6
+ }
7
+ @-->
8
+ <!--@styles
9
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
10
+ @-->
11
+
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
19
+ <!-- [ header starts here] -->
20
+ <tr>
21
+ <td valign="top"><a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+
25
+ <tr>
26
+ <td class="action-content">
27
+ <p>Hello Admin,</p>
28
+ <p>We get new question in Faq section. Please find below details</p>
29
+ <p>
30
+ <ul>
31
+ <li>Name : {{var username}}</li>
32
+ <li>Email : {{var useremail}}</li>
33
+ <li>Question : {{var title}}</li>
34
+ {{depend faq_category_name}}
35
+ <li>Category : {{var faq_category_name}}</li>
36
+ {{/depend}}
37
+ </ul>
38
+ </p>
39
+ </td>
40
+ </tr>
41
+
42
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
43
+ </tr>
44
+
45
+ </table>
46
+ </td>
47
+ </tr>
48
+ </table>
49
+ </div>
50
+ </body>
app/locale/en_US/template/email/create_faq_by_customer.html ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Faq! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "var name":"User Name"
6
+ }
7
+ @-->
8
+ <!--@styles
9
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
10
+ @-->
11
+
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
19
+ <!-- [ header starts here] -->
20
+ <tr>
21
+ <td valign="top"><a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+
25
+ <tr>
26
+ <td class="action-content">
27
+ <p>Hello {{var username}},</p>
28
+ <p>We have received your Question. we will send reply to your faq by mail. Below are the data you have sent us.</p>
29
+ <p>
30
+ <ul>
31
+ <li>Faq : {{var title}}</li>
32
+ {{depend faq_category_name}}
33
+ <li>Category : {{var faq_category_name}}</li>
34
+ {{/depend}}
35
+ </ul>
36
+ </p>
37
+ </td>
38
+ </tr>
39
+
40
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
41
+ </tr>
42
+
43
+ </table>
44
+ </td>
45
+ </tr>
46
+ </table>
47
+ </div>
48
+ </body>
app/locale/en_US/template/email/reply_create_faq_by_customer.html ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Faq! @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "var name":"User Name"
6
+ }
7
+ @-->
8
+ <!--@styles
9
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
10
+ @-->
11
+
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
19
+ <!-- [ header starts here] -->
20
+ <tr>
21
+ <td valign="top"><a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+
25
+ <tr>
26
+ <td class="action-content">
27
+ <p>Hello Admin,</p>
28
+ <p>We get new question in Faq section. Please find below details</p>
29
+ <p>
30
+ <ul>
31
+ <li>Name : {{var username}}</li>
32
+ <li>Email : {{var useremail}}</li>
33
+ <li>Question : {{var title}}</li>
34
+ {{depend faq_category_name}}
35
+ <li>Category : {{var faq_category_name}}</li>
36
+ {{/depend}}
37
+ </ul>
38
+ </p>
39
+ </td>
40
+ </tr>
41
+
42
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
43
+ </tr>
44
+
45
+ </table>
46
+ </td>
47
+ </tr>
48
+ </table>
49
+ </div>
50
+ </body>
package.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>CP_Faq</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Frequently Asked Questions</summary>
10
+ <description>FAQ Magento extension by Commerce Pundit will help you manage your FAQ. Set up your own beautiful and informative FAQ page easily without technical knowledge!.&lt;br /&gt;&#xD;
11
+ &#xD;
12
+ &lt;b&gt;Overview&lt;/b&gt;&lt;br/&gt;&#xD;
13
+ Customer will always have many questions in mind before purchasing the products. Our FAQ extension allows admin and customer to add questions and answers and list them on front end with category. The listing is simple and like accordian style which don't take much space on front end. The extension also allows admin to approve question and give answer when some one will ask question. It would be a editor so that admin can provide style to answer of question. User will get notified when admin will give answer of his Question.&#xD;
14
+ &#xD;
15
+ &lt;br /&gt;&lt;br /&gt;&#xD;
16
+ &lt;br /&gt;&#xD;
17
+ &lt;b&gt;Features&lt;/b&gt;&#xD;
18
+ &lt;ul&gt;&#xD;
19
+ &lt;li&gt;Managing the FAQ's categories from admin.&lt;/li&gt;&#xD;
20
+ &lt;li&gt;Managing the FAQ's items from admin.&lt;/li&gt;&#xD;
21
+ &lt;li&gt;Admin Approve System for Faq&lt;/li&gt;&#xD;
22
+ &lt;li&gt;Responsive&lt;/li&gt;&#xD;
23
+ &lt;li&gt;Great experience using the wysiwyg editor for adding the FAQ items content.&lt;/li&gt;&#xD;
24
+ &lt;li&gt;Easy Installation&lt;/li&gt;&#xD;
25
+ &lt;/ul&gt;</description>
26
+ <notes>Frequently Asked Questions</notes>
27
+ <authors><author><name>Commerce Pundit</name><user>CPExtensions</user><email>magento@commercepundit.com</email></author></authors>
28
+ <date>2015-06-13</date>
29
+ <time>11:33:54</time>
30
+ <contents><target name="magecommunity"><dir name="CP"><dir name="Faq"><dir name="Block"><dir name="Adminhtml"><dir name="Category"><dir name="Edit"><file name="Form.php" hash="5a9cbd091785d45dcc99c1996b00ccbd"/><dir name="Tab"><file name="Form.php" hash="16d224c02ffb6a8a097b794551bb40af"/></dir><file name="Tabs.php" hash="519dc23ec98d1d59e4dc9b4f0cf0b2cc"/></dir><file name="Edit.php" hash="2049f3b05de6a4d263bc11c9e1d0b536"/><file name="Grid.php" hash="9ec91341ce78f6a525ff35347058d8f1"/></dir><file name="Category.php" hash="492bac33018c2b9d39a931395d7c00f9"/><dir name="Faq"><dir name="Edit"><file name="Form.php" hash="e8d880dbf495d2779f330b1acd4a6cb9"/><dir name="Tab"><file name="Form.php" hash="c7faa340109beb63d0d204001fd5014f"/></dir><file name="Tabs.php" hash="1b6261d8917cb01d39e2726a872f7d68"/></dir><file name="Edit.php" hash="ffb954ec7d237a81b815f48d64729556"/><file name="Grid.php" hash="b67c6c6ef85cd51dce2e7a37bf0ba2b6"/></dir><file name="Faq.php" hash="4ce4562ddb13650508dce56b95b6ddf7"/><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Category.php" hash="ac203386e526dd3e125f9de7e4d9dc6f"/></dir></dir></dir></dir></dir><file name="Category.php" hash="ef3dd8202081d2ab34ad9c2ae405af5c"/><file name="Faq.php" hash="69215d305441a4103b0fc0329a9ae5c9"/><file name="Toolbar.php" hash="d264e6e16496d0c02bbf2f6133f8b6a5"/></dir><dir name="Helper"><file name="Data.php" hash="951ac7e3bad00e6c43c17b3da4f11477"/></dir><dir name="Model"><file name="Category.php" hash="eff968834060e3d5a5f71f70a9b36920"/><file name="Faq.php" hash="d083fb86c6cc8b555e761f96517f4ac7"/><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="6f48c9344d8682a5113465688d9747f0"/></dir><file name="Category.php" hash="1f233119fd0472ff7fa5606b4cf682c5"/><dir name="Faq"><file name="Collection.php" hash="f8404b2e484f57c3fc7ecf5ab3a0f27a"/></dir><file name="Faq.php" hash="9ad35cc2cdfd04a0e14f30de2a076754"/></dir><file name="Status.php" hash="217a3e6758f8bc342243bd414023184f"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CategoryController.php" hash="cdeece13a0e57057fd6934e00aa053d2"/><file name="FaqController.php" hash="f982eea571e9c1ae94832cf1842cc967"/></dir><file name="IndexController.php" hash="30a1b491b9adb983b719fc1196fba0b4"/></dir><dir name="etc"><file name="config.xml" hash="6eb1179c80d6d6334554df6230696503"/></dir><dir name="sql"><dir name="faq_setup"><file name="mysql4-install-0.1.0.php" hash="edd8743eae9495d7813b2ef0be9206c9"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CP_Faq.xml" hash="253be0cb3b632dcf1e125b2da65b60c6"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="create_faq_by_customer.html" hash="50fdf6caf77d3a4aa9cbf68297a0ea1f"/><file name="admin_create_faq_by_customer.html" hash="d02fc3c7948d0c51e402817c8671fd9f"/><file name="reply_create_faq_by_customer.html" hash="d02fc3c7948d0c51e402817c8671fd9f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="faq.xml" hash="8c48af58b406221286190d83b067d7e4"/></dir><dir name="template"><dir name="faq"><file name="addfaq.phtml" hash="2c04ec5f826af8c8f9e60e50b76e4fb7"/><file name="category.phtml" hash="f2cc34d6631eb31995b370e335a3ac15"/><file name="list.phtml" hash="427d981827e249808e60a85bd40f5703"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="layout"><file name="faq.xml" hash=""/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="faq.xml" hash="18182b75d1607927ad2fd13a0deba533"/></dir></dir></dir></dir></target></contents>
31
+ <compatible/>
32
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
33
+ </package>