inic_faq - Version 1.1.2

Version Notes

This extension allows the user to create the faq question and their categories.

Download this release

Release Info

Developer bejoy balan
Extension inic_faq
Version 1.1.2
Comparing to
See all releases


Version 1.1.2

Files changed (50) hide show
  1. app/code/local/Inic/Faq/Block/Adminhtml/Category.php +45 -0
  2. app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit.php +78 -0
  3. app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit/Form.php +35 -0
  4. app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit/Tab/Main.php +85 -0
  5. app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit/Tabs.php +54 -0
  6. app/code/local/Inic/Faq/Block/Adminhtml/Category/Grid.php +167 -0
  7. app/code/local/Inic/Faq/Block/Adminhtml/Form_/Edit/Renderer/Label.php +16 -0
  8. app/code/local/Inic/Faq/Block/Adminhtml/Item.php +45 -0
  9. app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit.php +79 -0
  10. app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit/Form.php +35 -0
  11. app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit/Tab/Main.php +125 -0
  12. app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit/Tabs.php +54 -0
  13. app/code/local/Inic/Faq/Block/Adminhtml/Item/Grid.php +155 -0
  14. app/code/local/Inic/Faq/Block/Frontend/Category.php +64 -0
  15. app/code/local/Inic/Faq/Block/Frontend/Detail.php +54 -0
  16. app/code/local/Inic/Faq/Block/Frontend/FaqSearch/Result.php +48 -0
  17. app/code/local/Inic/Faq/Block/Frontend/FaqSearch/Search.php +37 -0
  18. app/code/local/Inic/Faq/Block/Frontend/List.php +182 -0
  19. app/code/local/Inic/Faq/Helper/Data.php +39 -0
  20. app/code/local/Inic/Faq/Model/Category.php +42 -0
  21. app/code/local/Inic/Faq/Model/Faq.php +26 -0
  22. app/code/local/Inic/Faq/Model/Mysql4/Category.php +107 -0
  23. app/code/local/Inic/Faq/Model/Mysql4/Category/Collection.php +109 -0
  24. app/code/local/Inic/Faq/Model/Mysql4/Faq.php +144 -0
  25. app/code/local/Inic/Faq/Model/Mysql4/Faq/Collection.php +136 -0
  26. app/code/local/Inic/Faq/Model/System/Config/Source/View.php +44 -0
  27. app/code/local/Inic/Faq/controllers/Adminhtml/Faq/CategoryController.php +193 -0
  28. app/code/local/Inic/Faq/controllers/Adminhtml/FaqController.php +200 -0
  29. app/code/local/Inic/Faq/controllers/IndexController.php +51 -0
  30. app/code/local/Inic/Faq/etc/adminhtml.xml +63 -0
  31. app/code/local/Inic/Faq/etc/config.xml +133 -0
  32. app/code/local/Inic/Faq/etc/system.xml +69 -0
  33. app/code/local/Inic/Faq/sql/faq_setup/mysql4-install-0.1.0.php +37 -0
  34. app/code/local/Inic/Faq/sql/faq_setup/mysql4-install-1.0.7.php +67 -0
  35. app/code/local/Inic/Faq/sql/faq_setup/mysql4-upgrade-1.0.6-1.0.7.php +52 -0
  36. app/design/frontend/base/default/layout/faq.xml +89 -0
  37. app/design/frontend/base/default/template/faq/categoty.phtml +84 -0
  38. app/design/frontend/base/default/template/faq/detail.phtml +30 -0
  39. app/design/frontend/base/default/template/faq/list(2).phtml +94 -0
  40. app/design/frontend/base/default/template/faq/list.phtml +161 -0
  41. app/design/frontend/base/default/template/faq/search/result.phtml +59 -0
  42. app/design/frontend/base/default/template/faq/search/search.phtml +16 -0
  43. app/etc/modules/Inic_Faq.xml +9 -0
  44. package.xml +21 -0
  45. skin/frontend/base/default/css/faq/faq.css +137 -0
  46. skin/frontend/base/default/images/faq/faq_search_bar.png +0 -0
  47. skin/frontend/base/default/images/faq/minus.png +0 -0
  48. skin/frontend/base/default/images/faq/plus.png +0 -0
  49. skin/frontend/base/default/images/faq/search.gif +0 -0
  50. skin/frontend/base/default/js/faq/faq.js +72 -0
app/code/local/Inic/Faq/Block/Adminhtml/Category.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2009 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Category extends Mage_Adminhtml_Block_Widget_Grid_Container
18
+ {
19
+ /**
20
+ * Constructor for FAQ Adminhtml Block
21
+ */
22
+ public function __construct()
23
+ {
24
+ $this->_blockGroup = 'faq';
25
+ $this->_controller = 'adminhtml_category';
26
+ $this->_headerText = Mage::helper('faq')->__('Manage FAQ Categories');
27
+ $this->_addButtonLabel = Mage::helper('faq')->__('Add New FAQ Category');
28
+
29
+ parent::__construct();
30
+ }
31
+
32
+ /**
33
+ * Returns the CSS class for the header
34
+ *
35
+ * Usually 'icon-head' and a more precise class is returned. We return
36
+ * only an empty string to avoid spacing on the left of the header as we
37
+ * don't have an icon.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getHeaderCssClass()
42
+ {
43
+ return '';
44
+ }
45
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Category_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
18
+ {
19
+ /**
20
+ * Constructor for the FAQ edit form
21
+ */
22
+ public function __construct()
23
+ {
24
+ $this->_objectId = 'category_id';
25
+ $this->_blockGroup = 'faq';
26
+ $this->_controller = 'adminhtml_category';
27
+
28
+ parent::__construct();
29
+
30
+ $this->_updateButton('save', 'label', Mage::helper('faq')->__('Save FAQ Category'));
31
+ $this->_updateButton('delete', 'label', Mage::helper('faq')->__('Delete FAQ Category'));
32
+
33
+ $this->_addButton('saveandcontinue', array (
34
+ 'label' => Mage::helper('faq')->__('Save and continue edit'),
35
+ 'onclick' => 'saveAndContinueEdit()',
36
+ 'class' => 'save' ), -100);
37
+
38
+ $this->_formScripts[] = "
39
+ function saveAndContinueEdit(){
40
+ editForm.submit($('edit_form').action+'back/edit/');
41
+ }
42
+ ";
43
+ }
44
+
45
+ /**
46
+ * Helper function to edit the header of the current form
47
+ *
48
+ * @return string Returns an "edit" or "new" text depending on the type of modifications.
49
+ */
50
+ public function getHeaderText()
51
+ {
52
+ if (Mage::registry('faq_category')->getFaqId()) {
53
+ return Mage::helper('faq')->__("Edit FAQ Category '%s'", $this->htmlEscape(Mage::registry('faq_category')->getCategoryName()));
54
+ }
55
+ else {
56
+ return Mage::helper('faq')->__('New FAQ Category');
57
+ }
58
+ }
59
+
60
+ public function getFormActionUrl()
61
+ {
62
+ return $this->getUrl('*/*/save');
63
+ }
64
+
65
+ /**
66
+ * Returns the CSS class for the header
67
+ *
68
+ * Usually 'icon-head' and a more precise class is returned. We return
69
+ * only an empty string to avoid spacing on the left of the header as we
70
+ * don't have an icon.
71
+ *
72
+ * @return string
73
+ */
74
+ public function getHeaderCssClass()
75
+ {
76
+ return '';
77
+ }
78
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Category_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Preperation of current form
21
+ *
22
+ * @return Inic_Faq_Block_Adminhtml_Category_Edit_Form
23
+ */
24
+ protected function _prepareForm()
25
+ {
26
+ $form = new Varien_Data_Form(array (
27
+ 'id' => 'edit_form',
28
+ 'action' => $this->getData('action'),
29
+ 'method' => 'post',
30
+ 'enctype' => 'multipart/form-data' ));
31
+ $form->setUseContainer(true);
32
+ $this->setForm($form);
33
+ return parent::_prepareForm();
34
+ }
35
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit/Tab/Main.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Category_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Preparation of current form
21
+ *
22
+ * @return Inic_Faq_Block_Adminhtml_Category_Edit_Tab_Main
23
+ */
24
+ protected function _prepareForm()
25
+ {
26
+ $model = Mage::registry('faq_category');
27
+
28
+ $form = new Varien_Data_Form();
29
+ $form->setHtmlIdPrefix('faq_');
30
+
31
+ $fieldset = $form->addFieldset('base_fieldset', array (
32
+ 'legend' => Mage::helper('faq')->__('General information'),
33
+ 'class' => 'fieldset-wide' ));
34
+
35
+ if ($model->getCategoryId()) {
36
+ $fieldset->addField('category_id', 'hidden', array (
37
+ 'name' => 'category_id'
38
+ ));
39
+ }
40
+
41
+
42
+
43
+ $fieldset->addField('category_name', 'text', array (
44
+ 'name' => 'category_name',
45
+ 'label' => Mage::helper('faq')->__('Category Name'),
46
+ 'title' => Mage::helper('faq')->__('Category Name'),
47
+ 'required' => true,
48
+ ));
49
+
50
+
51
+ /**
52
+ * Check is single store mode
53
+ */
54
+ if (!Mage::app()->isSingleStoreMode()) {
55
+ $fieldset->addField('store_id', 'multiselect',
56
+ array (
57
+ 'name' => 'stores[]',
58
+ 'label' => Mage::helper('faq')->__('Store view'),
59
+ 'title' => Mage::helper('faq')->__('Store view'),
60
+ 'required' => true,
61
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ));
62
+ }
63
+ else {
64
+ $fieldset->addField('store_id', 'hidden', array (
65
+ 'name' => 'stores[]',
66
+ 'value' => Mage::app()->getStore(true)->getId() ));
67
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
68
+ }
69
+
70
+ $fieldset->addField('is_active', 'select',
71
+ array (
72
+ 'label' => Mage::helper('faq')->__('Status'),
73
+ 'title' => Mage::helper('faq')->__('Category Status'),
74
+ 'name' => 'is_active',
75
+ 'required' => true,
76
+ 'options' => array (
77
+ '1' => Mage::helper('faq')->__('Enabled'),
78
+ '0' => Mage::helper('faq')->__('Disabled') ) ));
79
+
80
+ $form->setValues($model->getData());
81
+ $this->setForm($form);
82
+
83
+ return parent::_prepareForm();
84
+ }
85
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Category/Edit/Tabs.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Category_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
18
+ {
19
+ /**
20
+ * Constructs current object
21
+ *
22
+ */
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId('faq_tabs');
27
+ $this->setDestElementId('edit_form');
28
+ $this->setTitle(Mage::helper('faq')->__('Category Information'));
29
+ }
30
+
31
+ /**
32
+ * Prepares the page layout
33
+ *
34
+ * Adds the tabs to the left tab menu.
35
+ *
36
+ * @return Inic_Faq_Block_Adminhtml_Category_Edit_Tabs
37
+ */
38
+ protected function _prepareLayout()
39
+ {
40
+ $return = parent::_prepareLayout();
41
+
42
+ $this->addTab(
43
+ 'main_section',
44
+ array(
45
+ 'label' => Mage::helper('faq')->__('General information'),
46
+ 'title' => Mage::helper('faq')->__('General information'),
47
+ 'content' => $this->getLayout()->createBlock('faq/adminhtml_category_edit_tab_main')->toHtml(),
48
+ 'active' => true,
49
+ )
50
+ );
51
+
52
+ return $return;
53
+ }
54
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Category/Grid.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Category_Grid extends Mage_Adminhtml_Block_Widget_Grid
18
+ {
19
+ /**
20
+ * Constructor of Grid
21
+ *
22
+ */
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId('faq_grid');
27
+ $this->setUseAjax(false);
28
+ $this->setDefaultSort('creation_time');
29
+ $this->setDefaultDir('DESC');
30
+ $this->setSaveParametersInSession(true);
31
+ }
32
+
33
+ /**
34
+ * Preparation of the data that is displayed by the grid.
35
+ *
36
+ * @return Inic_Faq_Block_Admin_Grid Self
37
+ */
38
+ protected function _prepareCollection()
39
+ {
40
+ $collection = Mage::getResourceModel('faq/category_collection');
41
+ $this->setCollection($collection);
42
+ return parent::_prepareCollection();
43
+ }
44
+
45
+ /**
46
+ * Preparation of the requested columns of the grid
47
+ *
48
+ * @return Inic_Faq_Block_Admin_Grid Self
49
+ */
50
+ protected function _prepareColumns()
51
+ {
52
+ $this->addColumn('category_id', array (
53
+ 'header' => Mage::helper('faq')->__('Category #'),
54
+ 'width' => '80px',
55
+ 'type' => 'text',
56
+ 'index' => 'category_id' ));
57
+
58
+ if (!Mage::app()->isSingleStoreMode()) {
59
+ $this->addColumn('store_id',
60
+ array (
61
+ 'header' => Mage::helper('faq')->__('Store view'),
62
+ 'index' => 'store_id',
63
+ 'type' => 'store',
64
+ 'store_all' => true,
65
+ 'store_view' => true,
66
+ 'sortable' => false,
67
+ 'filter_condition_callback' => array (
68
+ $this,
69
+ '_filterStoreCondition' ) ));
70
+ }
71
+
72
+ $this->addColumn(
73
+ 'category_name',
74
+ array(
75
+ 'header' => Mage::helper('faq')->__('Category Name'),
76
+ 'index' => 'category_name',
77
+ )
78
+ );
79
+
80
+ $this->addColumn('is_active',
81
+ array (
82
+ 'header' => Mage::helper('faq')->__('Active'),
83
+ 'index' => 'is_active',
84
+ 'type' => 'options',
85
+ 'width' => '70px',
86
+ 'options' => array (
87
+ 0 => Mage::helper('faq')->__('No'),
88
+ 1 => Mage::helper('faq')->__('Yes') ) ));
89
+
90
+ $this->addColumn(
91
+ 'action',
92
+ array (
93
+ 'header' => Mage::helper('faq')->__('Action'),
94
+ 'width' => '50px',
95
+ 'type' => 'action',
96
+ 'getter' => 'getId',
97
+ 'actions' => array (
98
+ array (
99
+ 'caption' => Mage::helper('faq')->__('Edit'),
100
+ 'url' => array (
101
+ 'base' => '*/*/edit'
102
+ ),
103
+ 'field' => 'category_id'
104
+ ),
105
+ ),
106
+ 'filter' => false,
107
+ 'sortable' => false,
108
+ 'index' => 'stores',
109
+ 'is_system' => true,
110
+ )
111
+ );
112
+
113
+ return parent::_prepareColumns();
114
+ }
115
+
116
+ /**
117
+ * Helper function to do after load modifications
118
+ *
119
+ */
120
+ protected function _afterLoadCollection()
121
+ {
122
+ $this->getCollection()->walk('afterLoad');
123
+ parent::_afterLoadCollection();
124
+ }
125
+
126
+ /**
127
+ * Helper function to add store filter condition
128
+ *
129
+ * @param Mage_Core_Model_Mysql4_Collection_Abstract $collection Data collection
130
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column Column information to be filtered
131
+ */
132
+ protected function _filterStoreCondition($collection, $column)
133
+ {
134
+ if (!$value = $column->getFilter()->getValue()) {
135
+ return;
136
+ }
137
+
138
+ $this->getCollection()->addStoreFilter($value);
139
+ }
140
+
141
+ /**
142
+ * Helper function to reveive on row click url
143
+ *
144
+ * @param Inic_Faq_Model_Faq $row Current rows dataset
145
+ * @return string URL for current row's onclick event
146
+ */
147
+ public function getRowUrl($row)
148
+ {
149
+ return $this->getUrl('*/*/edit', array (
150
+ 'category_id' => $row->getCategoryId() ));
151
+ }
152
+
153
+ /**
154
+ * Helper function to receive grid functionality urls for current grid
155
+ *
156
+ * @return string Requested URL
157
+ */
158
+ public function getGridUrl()
159
+ {
160
+ return $this->getUrl(
161
+ '*/*/',
162
+ array (
163
+ '_current' => true,
164
+ )
165
+ );
166
+ }
167
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Form_/Edit/Renderer/Label.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Inic_Faq_Block_Adminhtml_Form_Edit_Renderer_Label extends Varien_Data_Form_Element_Multiselect
3
+ {
4
+
5
+ /**
6
+ * Retrieve Element HTML fragment
7
+ *
8
+ * @return string
9
+ */
10
+ public function getElementHtml()
11
+ {
12
+ //print_r($this->getCheckboxLabel());exit;
13
+ $html ="hi";
14
+ return $html;
15
+ }
16
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Item.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Item extends Mage_Adminhtml_Block_Widget_Grid_Container
18
+ {
19
+ /**
20
+ * Constructor for FAQ Adminhtml Block
21
+ */
22
+ public function __construct()
23
+ {
24
+ $this->_blockGroup = 'faq';
25
+ $this->_controller = 'adminhtml_item';
26
+ $this->_headerText = Mage::helper('faq')->__('Manage FAQ Items');
27
+ $this->_addButtonLabel = Mage::helper('faq')->__('Add New FAQ Item');
28
+
29
+ parent::__construct();
30
+ }
31
+
32
+ /**
33
+ * Returns the CSS class for the header
34
+ *
35
+ * Usually 'icon-head' and a more precise class is returned. We return
36
+ * only an empty string to avoid spacing on the left of the header as we
37
+ * don't have an icon.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getHeaderCssClass()
42
+ {
43
+ return '';
44
+ }
45
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Item_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
18
+ {
19
+ /**
20
+ * Constructor for the FAQ edit form
21
+ *
22
+ */
23
+ public function __construct()
24
+ {
25
+ $this->_objectId = 'faq_id';
26
+ $this->_blockGroup = 'faq';
27
+ $this->_controller = 'adminhtml_item';
28
+
29
+ parent::__construct();
30
+
31
+ $this->_updateButton('save', 'label', Mage::helper('faq')->__('Save FAQ item'));
32
+ $this->_updateButton('delete', 'label', Mage::helper('faq')->__('Delete FAQ item'));
33
+
34
+ $this->_addButton('saveandcontinue', array (
35
+ 'label' => Mage::helper('faq')->__('Save and continue edit'),
36
+ 'onclick' => 'saveAndContinueEdit()',
37
+ 'class' => 'save' ), -100);
38
+
39
+ $this->_formScripts[] = "
40
+ function saveAndContinueEdit(){
41
+ editForm.submit($('edit_form').action+'back/edit/');
42
+ }
43
+ ";
44
+ }
45
+
46
+ /**
47
+ * Helper function to edit the header of the current form
48
+ *
49
+ * @return string Returns an "edit" or "new" text depending on the type of modifications.
50
+ */
51
+ public function getHeaderText()
52
+ {
53
+ if (Mage::registry('faq')->getFaqId()) {
54
+ return Mage::helper('faq')->__("Edit FAQ item '%s'", $this->htmlEscape(Mage::registry('faq')->getQuestion()));
55
+ }
56
+ else {
57
+ return Mage::helper('faq')->__('New FAQ item');
58
+ }
59
+ }
60
+
61
+ public function getFormActionUrl()
62
+ {
63
+ return $this->getUrl('*/faq/save');
64
+ }
65
+
66
+ /**
67
+ * Returns the CSS class for the header
68
+ *
69
+ * Usually 'icon-head' and a more precise class is returned. We return
70
+ * only an empty string to avoid spacing on the left of the header as we
71
+ * don't have an icon.
72
+ *
73
+ * @return string
74
+ */
75
+ public function getHeaderCssClass()
76
+ {
77
+ return '';
78
+ }
79
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Item_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Preperation of current form
21
+ *
22
+ * @return Inic_Faq_Block_Adminhtml_Item_Edit_Form
23
+ */
24
+ protected function _prepareForm()
25
+ {
26
+ $form = new Varien_Data_Form(array (
27
+ 'id' => 'edit_form',
28
+ 'action' => $this->getData('action'),
29
+ 'method' => 'post',
30
+ 'enctype' => 'multipart/form-data' ));
31
+ $form->setUseContainer(true);
32
+ $this->setForm($form);
33
+ return parent::_prepareForm();
34
+ }
35
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit/Tab/Main.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Item_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Prepares the page layout
21
+ *
22
+ * Loads the WYSIWYG editor on demand if enabled.
23
+ *
24
+ * @return Inic_Faq_Block_Admin_Edit
25
+ */
26
+ protected function _prepareLayout()
27
+ {
28
+ $return = parent::_prepareLayout();
29
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
30
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
31
+ }
32
+ return $return;
33
+ }
34
+
35
+ /**
36
+ * Preparation of current form
37
+ *
38
+ * @return Inic_Faq_Block_Admin_Edit_Tab_Main Self
39
+ */
40
+ protected function _prepareForm()
41
+ {
42
+ $model = Mage::registry('faq');
43
+
44
+ $form = new Varien_Data_Form();
45
+ $form->setHtmlIdPrefix('faq_');
46
+
47
+ $fieldset = $form->addFieldset('base_fieldset', array (
48
+ 'legend' => Mage::helper('faq')->__('General information'),
49
+ 'class' => 'fieldset-wide' ));
50
+
51
+ if ($model->getFaqId()) {
52
+ $fieldset->addField('faq_id', 'hidden', array (
53
+ 'name' => 'faq_id' ));
54
+ }
55
+
56
+ $fieldset->addField('question', 'text', array (
57
+ 'name' => 'question',
58
+ 'label' => Mage::helper('faq')->__('FAQ item question'),
59
+ 'title' => Mage::helper('faq')->__('FAQ item question'),
60
+ 'required' => true ));
61
+
62
+ /**
63
+ * Check is single store mode
64
+ */
65
+ if (!Mage::app()->isSingleStoreMode()) {
66
+ $fieldset->addField('store_id', 'multiselect',
67
+ array (
68
+ 'name' => 'stores[]',
69
+ 'label' => Mage::helper('faq')->__('Store view'),
70
+ 'title' => Mage::helper('faq')->__('Store view'),
71
+ 'required' => true,
72
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ));
73
+ }
74
+ else {
75
+ $fieldset->addField('store_id', 'hidden', array (
76
+ 'name' => 'stores[]',
77
+ 'value' => Mage::app()->getStore(true)->getId() ));
78
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
79
+ }
80
+
81
+ $fieldset->addField('is_active', 'select',
82
+ array (
83
+ 'label' => Mage::helper('faq')->__('Status'),
84
+ 'title' => Mage::helper('faq')->__('Item status'),
85
+ 'name' => 'is_active',
86
+ 'required' => true,
87
+ 'options' => array (
88
+ '1' => Mage::helper('faq')->__('Enabled'),
89
+ '0' => Mage::helper('faq')->__('Disabled') ) ));
90
+
91
+ $fieldset->addField('is_most_frequent', 'select',
92
+ array (
93
+ 'label' => Mage::helper('faq')->__('Is Most Frequent'),
94
+ 'title' => Mage::helper('faq')->__('Is Most Frequent'),
95
+ 'name' => 'is_most_frequent',
96
+ 'required' => true,
97
+ 'options' => array (
98
+ '1' => Mage::helper('faq')->__('Yes'),
99
+ '0' => Mage::helper('faq')->__('No') ) ));
100
+
101
+ $fieldset->addField('category_id', 'multiselect',
102
+ array (
103
+ 'label' => Mage::helper('faq')->__('Category'),
104
+ 'title' => Mage::helper('faq')->__('Category'),
105
+ 'name' => 'categories[]',
106
+ 'required' => false,
107
+ 'values' => Mage::getResourceSingleton('faq/category_collection')->toOptionArray(),
108
+ )
109
+ );
110
+
111
+ $fieldset->addField('answer', 'editor',
112
+ array (
113
+ 'name' => 'answer',
114
+ 'label' => Mage::helper('faq')->__('Content'),
115
+ 'title' => Mage::helper('faq')->__('Content'),
116
+ 'style' => 'height:36em;',
117
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
118
+ 'required' => true ));
119
+
120
+ $form->setValues($model->getData());
121
+ $this->setForm($form);
122
+
123
+ return parent::_prepareForm();
124
+ }
125
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Item/Edit/Tabs.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Item_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
18
+ {
19
+ /**
20
+ * Constructs current object
21
+ *
22
+ */
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId('faq_tabs');
27
+ $this->setDestElementId('edit_form');
28
+ $this->setTitle(Mage::helper('faq')->__('FAQ item information'));
29
+ }
30
+
31
+ /**
32
+ * Prepares the page layout
33
+ *
34
+ * Adds the tabs to the left tab menu.
35
+ *
36
+ * @return Inic_Faq_Block_Admin_Edit
37
+ */
38
+ protected function _prepareLayout()
39
+ {
40
+ $return = parent::_prepareLayout();
41
+
42
+ $this->addTab(
43
+ 'main_section',
44
+ array(
45
+ 'label' => Mage::helper('faq')->__('General information'),
46
+ 'title' => Mage::helper('faq')->__('General information'),
47
+ 'content' => $this->getLayout()->createBlock('faq/adminhtml_item_edit_tab_main')->toHtml(),
48
+ 'active' => true,
49
+ )
50
+ );
51
+
52
+ return $return;
53
+ }
54
+ }
app/code/local/Inic/Faq/Block/Adminhtml/Item/Grid.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Adminhtml_Item_Grid extends Mage_Adminhtml_Block_Widget_Grid
18
+ {
19
+ /**
20
+ * Constructor of Grid
21
+ *
22
+ */
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId('faq_grid');
27
+ $this->setUseAjax(false);
28
+ $this->setDefaultSort('creation_time');
29
+ $this->setDefaultDir('DESC');
30
+ $this->setSaveParametersInSession(true);
31
+ }
32
+
33
+ /**
34
+ * Preparation of the data that is displayed by the grid.
35
+ *
36
+ * @return Inic_Faq_Block_Admin_Grid Self
37
+ */
38
+ protected function _prepareCollection()
39
+ {
40
+ //TODO: add full name logic
41
+ $collection = Mage::getResourceModel('faq/faq_collection');
42
+ $this->setCollection($collection);
43
+ #Mage::Log($collection->getData());
44
+ return parent::_prepareCollection();
45
+ }
46
+
47
+ /**
48
+ * Preparation of the requested columns of the grid
49
+ *
50
+ * @return Inic_Faq_Block_Admin_Grid Self
51
+ */
52
+ protected function _prepareColumns()
53
+ {
54
+ $this->addColumn('faq_id', array (
55
+ 'header' => Mage::helper('faq')->__('FAQ #'),
56
+ 'width' => '80px',
57
+ 'type' => 'text',
58
+ 'index' => 'faq_id' ));
59
+
60
+ if (!Mage::app()->isSingleStoreMode()) {
61
+ $this->addColumn('store_id',
62
+ array (
63
+ 'header' => Mage::helper('faq')->__('Store view'),
64
+ 'index' => 'store_id',
65
+ 'type' => 'store',
66
+ 'store_all' => true,
67
+ 'store_view' => true,
68
+ 'sortable' => false,
69
+ 'filter_condition_callback' => array (
70
+ $this,
71
+ '_filterStoreCondition' ) ));
72
+ }
73
+
74
+ $this->addColumn('question', array (
75
+ 'header' => Mage::helper('faq')->__('Question'),
76
+ 'index' => 'question' ));
77
+
78
+ $this->addColumn('is_active',
79
+ array (
80
+ 'header' => Mage::helper('faq')->__('Active'),
81
+ 'index' => 'is_active',
82
+ 'type' => 'options',
83
+ 'width' => '70px',
84
+ 'options' => array (
85
+ 0 => Mage::helper('faq')->__('No'),
86
+ 1 => Mage::helper('faq')->__('Yes') ) ));
87
+
88
+ $this->addColumn('action',
89
+ array (
90
+ 'header' => Mage::helper('faq')->__('Action'),
91
+ 'width' => '50px',
92
+ 'type' => 'action',
93
+ 'getter' => 'getId',
94
+ 'actions' => array (
95
+ array (
96
+ 'caption' => Mage::helper('faq')->__('Edit'),
97
+ 'url' => array (
98
+ 'base' => 'adminhtml/faq/edit' ),
99
+ 'field' => 'faq_id' ) ),
100
+ 'filter' => false,
101
+ 'sortable' => false,
102
+ 'index' => 'stores',
103
+ 'is_system' => true ));
104
+
105
+ return parent::_prepareColumns();
106
+ }
107
+
108
+ /**
109
+ * Helper function to do after load modifications
110
+ *
111
+ */
112
+ protected function _afterLoadCollection()
113
+ {
114
+ $this->getCollection()->walk('afterLoad');
115
+ parent::_afterLoadCollection();
116
+ }
117
+
118
+ /**
119
+ * Helper function to add store filter condition
120
+ *
121
+ * @param Mage_Core_Model_Mysql4_Collection_Abstract $collection Data collection
122
+ * @param Mage_Adminhtml_Block_Widget_Grid_Column $column Column information to be filtered
123
+ */
124
+ protected function _filterStoreCondition($collection, $column)
125
+ {
126
+ if (!$value = $column->getFilter()->getValue()) {
127
+ return;
128
+ }
129
+
130
+ $this->getCollection()->addStoreFilter($value);
131
+ }
132
+
133
+ /**
134
+ * Helper function to reveive on row click url
135
+ *
136
+ * @param Inic_Faq_Model_Faq $row Current rows dataset
137
+ * @return string URL for current row's onclick event
138
+ */
139
+ public function getRowUrl($row)
140
+ {
141
+ return $this->getUrl('adminhtml/faq/edit', array (
142
+ 'faq_id' => $row->getFaqId() ));
143
+ }
144
+
145
+ /**
146
+ * Helper function to receive grid functionality urls for current grid
147
+ *
148
+ * @return string Requested URL
149
+ */
150
+ public function getGridUrl()
151
+ {
152
+ return $this->getUrl('adminhtml/faq/index', array (
153
+ '_current' => true ));
154
+ }
155
+ }
app/code/local/Inic/Faq/Block/Frontend/Category.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2009 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Frontend_Category extends Mage_Core_Block_Template {
18
+
19
+ protected $_catfaq;
20
+ protected $_catfaqcCollection;
21
+
22
+
23
+ protected function _prepareLayout()
24
+ {
25
+ $categoryfaq = $this->getCategory();
26
+ if ($categoryfaq !== false && $head = $this->getLayout()->getBlock('head')) {
27
+ $head->setTitle($this->htmlEscape($categoryfaq->getName()) . ' - ' . $head->getTitle());
28
+ }
29
+ }
30
+
31
+ public function getCategory() {
32
+ if (!$this->_catfaq) {
33
+ $id = intval($this->getRequest()->getParam('cat_id'));
34
+ try {
35
+ $this->_catfaq = Mage :: getModel('faq/category')->load($id);
36
+
37
+ if ($this->_catfaq->getIsActive() != 1){
38
+ Mage::throwException('Catagory is not active');
39
+ }
40
+ }catch (Exception $e) {
41
+ $this->_catfaq = false;
42
+ }
43
+ }
44
+ return $this->_catfaq;
45
+ }
46
+
47
+ /**
48
+ * Function to gather the current faq item
49
+ *
50
+ * @return Inic_Faq_Model_Faq The current faq item
51
+ */
52
+ public function getcatFaqCollection() {
53
+ try{
54
+ if (!$this->_catfaq) {
55
+ Mage::throwException('Please Select Category');
56
+ }else{
57
+ $this->_catfaqcCollection=$this->_catfaq->getItemCollection()->addIsActiveFilter()->addStoreFilter(Mage::app()->getStore());
58
+ }
59
+ }catch (Exception $e) {
60
+ $this->_catfaqcCollection = false;
61
+ }
62
+ return $this->_catfaqcCollection;
63
+ }
64
+ }
app/code/local/Inic/Faq/Block/Frontend/Detail.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2009 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Frontend_Detail extends Mage_Core_Block_Template {
18
+
19
+ protected $_faq;
20
+ protected $_images;
21
+
22
+
23
+ protected function _prepareLayout()
24
+ {
25
+ $faq = $this->getFaq();
26
+
27
+ if ($faq !== false && $head = $this->getLayout()->getBlock('head')) {
28
+ $head->setTitle($this->htmlEscape($faq->getQuestion()) . ' - ' . $head->getTitle());
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Function to gather the current faq item
34
+ *
35
+ * @return Inic_Faq_Model_Faq The current faq item
36
+ */
37
+ public function getFaq() {
38
+ if (!$this->_faq) {
39
+ $id = intval($this->getRequest()->getParam('faq'));
40
+ try {
41
+ $this->_faq = Mage :: getModel('faq/faq')->load($id);
42
+
43
+ if ($this->_faq->getIsActive() != 1){
44
+ Mage::throwException('Faq Item is not active');
45
+ }
46
+ }
47
+ catch (Exception $e) {
48
+ $this->_faq = false;
49
+ }
50
+ }
51
+
52
+ return $this->_faq;
53
+ }
54
+ }
app/code/local/Inic/Faq/Block/Frontend/FaqSearch/Result.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2009 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Frontend_FaqSearch_Result extends Mage_Core_Block_Template {
18
+
19
+ protected $_search;
20
+
21
+ protected function _prepareLayout()
22
+ {
23
+ $search = $this->getSearch();
24
+ $keyword=$this->getRequest()->getParam('keyword');
25
+ if ($search !== false && $head = $this->getLayout()->getBlock('head')) {
26
+ $head->setTitle('Search Result For : '.$this->htmlEscape($keyword) . ' - ' . $head->getTitle());
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Function to gather the searched terms in questions
32
+ *
33
+ * @return Inic_Faq_Model_Faq Collection
34
+ */
35
+ public function getSearch() {
36
+ if (!$this->_search) {
37
+ $keyword=$this->getRequest()->getParam('keyword');
38
+ $this->_search = Mage :: getModel('faq/faq')->getCollection();
39
+ if($this->getRequest()->getParam('cat_id')){
40
+ $id=$this->getRequest()->getParam('cat_id');
41
+ $category = Mage :: getModel('faq/category')->load($id);
42
+ $this->_search=$category->getItemCollection()->addIsActiveFilter()->addStoreFilter(Mage::app()->getStore());
43
+ }
44
+ $this->_search=$this->_search->addFieldToFilter(array('question','answer'),array(array('question','like' => '%'.$keyword.'%'), array('answer', 'like' => '%'.$keyword.'%')));
45
+ }
46
+ return $this->_search;
47
+ }
48
+ }
app/code/local/Inic/Faq/Block/Frontend/FaqSearch/Search.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2009 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Frontend_FaqSearch_Search extends Mage_Core_Block_Template {
18
+
19
+ /**
20
+ * Function to return search result page url
21
+ *
22
+ * @return Search Url
23
+ */
24
+ public function getSearchUrl() {
25
+ return $this->getUrl('faq/index/result');
26
+ }
27
+
28
+ /**
29
+ * Function to check search is enabled or not
30
+ *
31
+ * @return bool;
32
+ */
33
+ public function isSearchEnabled()
34
+ {
35
+ return Mage::getStoreConfig('faq_section/general/search_enable') ? true : false;
36
+ }
37
+ }
app/code/local/Inic/Faq/Block/Frontend/List.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Block_Frontend_List extends Mage_Core_Block_Template
18
+ {
19
+ protected $_faqCollection;
20
+ protected $_faqfrequentCollection;
21
+
22
+ protected function _prepareLayout()
23
+ {
24
+ if ($head = $this->getLayout()->getBlock('head')) {
25
+ $head->setTitle($this->htmlEscape($this->__('Frequently Asked Questions')) . ' - ' . $head->getTitle());
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Returns collection of current FAQ entries
31
+ *
32
+ * @param int $pageSize
33
+ * @return Inic_Faq_Model_Mysql_Faq_Collection collection of current FAQ entries
34
+ */
35
+ public function getFaqCollection($pageSize = null)
36
+ {
37
+ if (!$this->_faqCollection || (intval($pageSize) > 0
38
+ && $this->_faqCollection->getSize() != intval($pageSize))
39
+ ) {
40
+ $this->_faqCollection = Mage :: getModel('faq/faq')
41
+ ->getCollection()
42
+ ->addStoreFilter(Mage :: app()->getStore())
43
+ ->addIsActiveFilter();
44
+
45
+ if (isset($pageSize) && intval($pageSize) && intval($pageSize) > 0) {
46
+ $this->_faqCollection->setPageSize(intval($pageSize));
47
+ }
48
+ }
49
+
50
+ return $this->_faqCollection;
51
+ }
52
+
53
+ /**
54
+ * Returns collection of Frequent FAQ entries
55
+ *
56
+ * @param int $pageSize
57
+ * @return Inic_Faq_Model_Mysql_Faq_Collection collection of Frequent FAQ entries
58
+ */
59
+ public function getFrequentFaqCollection($pageSize = null)
60
+ {
61
+ $this->_faqfrequentCollection = Mage :: getModel('faq/faq');
62
+ if(Mage::getStoreConfig('faq_section/general/no_most_frequent_que')){
63
+ $pageSize = Mage::getStoreConfig('faq_section/general/no_most_frequent_que');
64
+ }
65
+ if (Mage::getStoreConfig('faq_section/general/frequent_enable') && !$this->_faqfrequentCollection || (intval($pageSize) > 0 && $this->_faqfrequentCollection->getSize() != intval($pageSize))
66
+ ) {
67
+ $this->_faqfrequentCollection = Mage :: getModel('faq/faq')
68
+ ->getCollection()
69
+ ->addStoreFilter(Mage :: app()->getStore())
70
+ ->addFieldToFilter('is_most_frequent',array('eq'=>1))
71
+ ->addIsActiveFilter();
72
+
73
+ if (isset($pageSize) && intval($pageSize) && intval($pageSize) > 0) {
74
+ $this->_faqfrequentCollection->setPageSize(intval($pageSize));
75
+ }
76
+ }
77
+
78
+ return $this->_faqfrequentCollection;
79
+ }
80
+
81
+ /**
82
+ * Returns all active categories
83
+ *
84
+ * @return Inic_Faq_Model_Mysql4_Category_Collection
85
+ */
86
+ public function getCategoryCollection()
87
+ {
88
+ $categories = $this->getData('category_collection');
89
+ if (is_null($categories)) {
90
+ $categories = Mage::getResourceSingleton('faq/category_collection')
91
+ ->addStoreFilter(Mage::app()->getStore())
92
+ ->addIsActiveFilter();
93
+ $this->setData('category_collection', $categories);
94
+ }
95
+ return $categories;
96
+ }
97
+
98
+ /**
99
+ * Returns the item collection for the given category
100
+ *
101
+ * @param Inic_Faq_Model_Category $category
102
+ * @return Inic_Faq_Model_Mysql4_Faq_Collection
103
+ */
104
+ public function getItemCollectionByCategory(Inic_Faq_Model_Category $category)
105
+ {
106
+ $pageSize=null;
107
+ if(Mage::getStoreConfig('faq_section/general/no_of_cat_que')){
108
+ $pageSize = Mage::getStoreConfig('faq_section/general/no_of_cat_que');
109
+ }
110
+ $catQuestions=$category->getItemCollection()->addIsActiveFilter()->addStoreFilter(Mage::app()->getStore());
111
+ if (isset($pageSize) && intval($pageSize) && intval($pageSize) > 0) {
112
+ $catQuestions->setPageSize(intval($pageSize));
113
+ }
114
+ return $catQuestions;
115
+ }
116
+
117
+ public function getCategoryUrl(Inic_Faq_Model_Category $category){
118
+ return $this->getUrl('faq/index/categoryshow',array('_secure'=>true,'cat_id'=>$category->getId()));
119
+ }
120
+
121
+ /**
122
+ * Returns the item collection count for the given category
123
+ *
124
+ * @param Inic_Faq_Model_Category $category
125
+ * @return int
126
+ */
127
+ public function getItemCollectionByCategoryCount(Inic_Faq_Model_Category $category){
128
+ $category->setData('item_collection',null);
129
+ $catQuestionsCollection=$category->getItemCollection()->addIsActiveFilter()->addStoreFilter(Mage::app()->getStore());
130
+ return (count($catQuestionsCollection) > Mage::getStoreConfig('faq_section/general/no_of_cat_que')) ? true:false;
131
+ }
132
+
133
+ /**
134
+ * Simple helper function to determine, whether there are FAQ entries or not.
135
+ *
136
+ * @return boolean True, if FAQ are given.
137
+ */
138
+ public function hasFaq()
139
+ {
140
+ return $this->getFaqCollection()->getSize() > 0;
141
+ }
142
+
143
+ /**
144
+ * Simple helper function to determine, whether there are Frequent FAQ entries or not.
145
+ * And the backend Configuration is set to yes or not
146
+ * @return boolean
147
+ */
148
+ public function hasFrequent()
149
+ {
150
+ $size=0;
151
+ $flg=false;
152
+ if(isset($this->_faqfrequentCollection)){
153
+ $size=$this->_faqfrequentCollection->getSize();
154
+ }else{
155
+ $size=$this->getFrequentFaqCollection()->getSize();
156
+ }
157
+ if(Mage::getStoreConfig('faq_section/general/frequent_enable') && $size > 0)
158
+ {
159
+ $flg=true;
160
+ }
161
+
162
+ return $flg;
163
+ }
164
+
165
+ public function getIntro($faqItem)
166
+ {
167
+ $_intro = strip_tags($faqItem->getContent());
168
+ $_intro = mb_substr($_intro, 0, mb_strpos($_intro, "\n"));
169
+
170
+ $length = 100 - mb_strlen($faqItem->getQuestion());
171
+ if ($length < 0) {
172
+ return '';
173
+ }
174
+ if (mb_strlen($_intro) > $length) {
175
+ $_intro = mb_substr($_intro, 0, $length);
176
+ $_intro = mb_substr($_intro, 0, mb_strrpos($_intro, ' ')).'...';
177
+ }
178
+
179
+ return $_intro;
180
+ }
181
+
182
+ }
app/code/local/Inic/Faq/Helper/Data.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Helper_Data extends Mage_Core_Helper_Abstract
18
+ {
19
+ /**
20
+ * Returns config data
21
+ *
22
+ * @param string $field Requested field
23
+ * @return array config Configuration information
24
+ */
25
+ public function getConfigData($field)
26
+ {
27
+ $path = 'faq/config/' . $field;
28
+ $config = Mage::getStoreConfig($path, Mage::app()->getStore());
29
+ return $config;
30
+ }
31
+
32
+ /**
33
+ * Returns the class on the basis of backend layout settings
34
+ * @return varchar
35
+ */
36
+ public function getQuestionView(){
37
+ return (Mage::getStoreConfig('faq_section/general/view_style')==1 ? 'grid' : 'list');
38
+ }
39
+ }
app/code/local/Inic/Faq/Model/Category.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013
8
+ */
9
+
10
+ /**
11
+ * Category Model for FAQ Items
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Model_Category extends Mage_Core_Model_Abstract
18
+ {
19
+ /**
20
+ * Constructor
21
+ */
22
+ protected function _construct()
23
+ {
24
+ $this->_init('faq/category');
25
+ }
26
+
27
+ public function getName()
28
+ {
29
+ return $this->getCategoryName();
30
+ }
31
+
32
+ public function getItemCollection()
33
+ {
34
+ $collection = $this->getData('item_collection');
35
+ if (is_null($collection)) {
36
+ $collection = Mage::getSingleton('faq/faq')->getCollection()
37
+ ->addCategoryFilter($this);
38
+ $this->setData('item_collection', $collection);
39
+ }
40
+ return $collection;
41
+ }
42
+ }
app/code/local/Inic/Faq/Model/Faq.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Indianic
16
+ */
17
+ class Inic_Faq_Model_Faq extends Mage_Core_Model_Abstract
18
+ {
19
+ /**
20
+ * Constructor
21
+ */
22
+ protected function _construct()
23
+ {
24
+ $this->_init('faq/faq');
25
+ }
26
+ }
app/code/local/Inic/Faq/Model/Mysql4/Category.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * Category Resource Model for FAQ Items
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
18
+ {
19
+ /**
20
+ * Constructor
21
+ */
22
+ protected function _construct()
23
+ {
24
+ $this->_init('faq/category', 'category_id');
25
+ }
26
+
27
+ /**
28
+ * Retrieve select object for load object data
29
+ *
30
+ * @param string $field
31
+ * @param mixed $value
32
+ * @return Zend_Db_Select
33
+ */
34
+ protected function _getLoadSelect($field, $value, $object)
35
+ {
36
+ $select = parent::_getLoadSelect($field, $value, $object);
37
+
38
+ if ($object->getStoreId()) {
39
+ $select->join(
40
+ array('nns' => $this->getTable('faq/category_store')),
41
+ $this->getMainTable() . '.item_id = `nns`.category_id'
42
+ )->where('is_active=1 AND `nns`.store_id in (0, ?) ',
43
+ $object->getStoreId())->order('creation_time DESC')->limit(1);
44
+ }
45
+ return $select;
46
+ }
47
+
48
+ /**
49
+ * Sets the creation and update timestamps
50
+ *
51
+ * @param Mage_Core_Model_Abstract $object Current faq category
52
+ * @return Inic_Faq_Model_Mysql4_Category
53
+ */
54
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
55
+ {
56
+ if (!$object->getId()) {
57
+ $object->setCreationTime(Mage::getSingleton('core/date')->gmtDate());
58
+ }
59
+ $object->setUpdateTime(Mage::getSingleton('core/date')->gmtDate());
60
+
61
+ return parent::_beforeSave($object);
62
+ }
63
+
64
+ /**
65
+ * Assign page to store views
66
+ *
67
+ * @param Mage_Core_Model_Abstract $object
68
+ */
69
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
70
+ {
71
+ $condition = $this->_getWriteAdapter()->quoteInto('category_id = ?', $object->getId());
72
+ $this->_getWriteAdapter()->delete($this->getTable('faq/category_store'), $condition);
73
+
74
+ foreach ((array) $object->getData('stores') as $store) {
75
+ $storeArray = array ();
76
+ $storeArray['category_id'] = $object->getId();
77
+ $storeArray['store_id'] = $store;
78
+ $this->_getWriteAdapter()->insert(
79
+ $this->getTable('faq/category_store'), $storeArray
80
+ );
81
+ }
82
+
83
+ return parent::_afterSave($object);
84
+ }
85
+
86
+ /**
87
+ * Do store processing after loading
88
+ *
89
+ * @param Mage_Core_Model_Abstract $object Current faq item
90
+ */
91
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
92
+ {
93
+ $select = $this->_getReadAdapter()->select()->from(
94
+ $this->getTable('faq/category_store')
95
+ )->where('category_id = ?', $object->getId());
96
+
97
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
98
+ $storesArray = array ();
99
+ foreach ($data as $row) {
100
+ $storesArray[] = $row['store_id'];
101
+ }
102
+ $object->setData('store_id', $storesArray);
103
+ }
104
+
105
+ return parent::_afterLoad($object);
106
+ }
107
+ }
app/code/local/Inic/Faq/Model/Mysql4/Category/Collection.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
18
+ {
19
+ protected $_previewFlag;
20
+
21
+ /**
22
+ * Constructor
23
+ *
24
+ */
25
+ protected function _construct()
26
+ {
27
+ $this->_init('faq/category');
28
+ }
29
+
30
+ /**
31
+ * Add Filter by store
32
+ *
33
+ * @param int|Mage_Core_Model_Store $store Store to be filtered
34
+ * @return Inic_Faq_Model_Mysql4_Category_Collection
35
+ */
36
+ public function addStoreFilter($store)
37
+ {
38
+ if ($store instanceof Mage_Core_Model_Store) {
39
+ $store = array($store->getId());
40
+ }
41
+
42
+ $this->getSelect()->join(
43
+ array('store_table' => $this->getTable('faq/category_store')),
44
+ 'main_table.category_id = store_table.category_id',
45
+ array ()
46
+ )->where('store_table.store_id in (?)', array (
47
+ 0,
48
+ $store
49
+ ))->group('main_table.category_id');
50
+
51
+ return $this;
52
+ }
53
+
54
+
55
+ /**
56
+ * After load processing - adds store information to the datasets
57
+ *
58
+ */
59
+ protected function _afterLoad()
60
+ {
61
+ if ($this->_previewFlag) {
62
+ $items = $this->getColumnValues('faq_id');
63
+ if (count($items)) {
64
+ $select = $this->getConnection()->select()->from(
65
+ $this->getTable('faq/category_store')
66
+ )->where(
67
+ $this->getTable('faq/category_store') . '.category_id IN (?)',
68
+ $items
69
+ );
70
+ if ($result = $this->getConnection()->fetchPairs($select)) {
71
+ foreach ($this as $item) {
72
+ if (!isset($result[$item->getData('category_id')])) {
73
+ continue;
74
+ }
75
+ if ($result[$item->getData('category_id')] == 0) {
76
+ $stores = Mage::app()->getStores(false, true);
77
+ $storeId = current($stores)->getId();
78
+ $storeCode = key($stores);
79
+ }
80
+ else {
81
+ $storeId = $result[$item->getData('category_id')];
82
+ $storeCode = Mage::app()->getStore($storeId)->getCode();
83
+ }
84
+ $item->setData('_first_store_id', $storeId);
85
+ $item->setData('store_code', $storeCode);
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ parent::_afterLoad();
92
+ }
93
+
94
+ protected function _toOptionArray($valueField = 'category_id', $labelField = 'category_name', $additional = array())
95
+ {
96
+ return parent::_toOptionArray($valueField, $labelField, $additional);
97
+ }
98
+
99
+ protected function _toOptionHash($valueField = 'category_id', $labelField='category_name')
100
+ {
101
+ return parent::_toOptionHash($valueField, $labelField);
102
+ }
103
+
104
+ public function addIsActiveFilter()
105
+ {
106
+ $this->addFilter('is_active', 1);
107
+ return $this;
108
+ }
109
+ }
app/code/local/Inic/Faq/Model/Mysql4/Faq.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Model_Mysql4_Faq extends Mage_Core_Model_Mysql4_Abstract {
18
+
19
+
20
+ /**
21
+ * Constructor
22
+ *
23
+ */
24
+ protected function _construct() {
25
+
26
+ $this->_init('faq/faq', 'faq_id');
27
+ }
28
+
29
+
30
+ /**
31
+ * Retrieve select object for load object data
32
+ *
33
+ * @param string $field
34
+ * @param mixed $value
35
+ * @return Zend_Db_Select
36
+ */
37
+ protected function _getLoadSelect($field, $value, $object) {
38
+
39
+ $select = parent::_getLoadSelect($field, $value, $object);
40
+
41
+ if ($object->getStoreId()) {
42
+ $select->join(
43
+ array('nns' => $this->getTable('faq/faq_store')),
44
+ $this->getMainTable() . '.item_id = `nns`.faq_id'
45
+ )->where('is_active=1 AND `nns`.store_id in (0, ?) ',
46
+ $object->getStoreId())->order('creation_time DESC')->limit(1);
47
+ }
48
+
49
+ return $select;
50
+ }
51
+
52
+
53
+ /**
54
+ * Some processing prior to saving to database - processes the given images
55
+ * and the store configuration
56
+ *
57
+ * @param Mage_Core_Model_Abstract $object Current faq item
58
+ */
59
+ protected function _beforeSave(Mage_Core_Model_Abstract $object) {
60
+
61
+ if (!$object->getId()) {
62
+ $object->setCreationTime(Mage :: getSingleton('core/date')->gmtDate());
63
+ }
64
+
65
+ $object->setPublicationTime(
66
+ Mage::app()->getLocale()->date($object->getPublicationTime(),
67
+ Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
68
+ null, false)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
69
+ );
70
+
71
+ $object->setUpdateTime(Mage :: getSingleton('core/date')->gmtDate());
72
+ }
73
+
74
+
75
+ /**
76
+ * Assign page to store views
77
+ *
78
+ * @param Mage_Core_Model_Abstract $object
79
+ */
80
+ protected function _afterSave(Mage_Core_Model_Abstract $object)
81
+ {
82
+ $condition = $this->_getWriteAdapter()->quoteInto('faq_id = ?', $object->getId());
83
+
84
+ // process faq item to store relation
85
+ $this->_getWriteAdapter()->delete($this->getTable('faq/faq_store'), $condition);
86
+ foreach ((array) $object->getData('stores') as $store) {
87
+ $storeArray = array ();
88
+ $storeArray['faq_id'] = $object->getId();
89
+ $storeArray['store_id'] = $store;
90
+ $this->_getWriteAdapter()->insert(
91
+ $this->getTable('faq/faq_store'), $storeArray
92
+ );
93
+ }
94
+
95
+ // process faq item to category relation
96
+ $this->_getWriteAdapter()->delete($this->getTable('faq/category_item'), $condition);
97
+ foreach ((array) $object->getData('categories') as $categoryId) {
98
+ $categoryArray = array ();
99
+ $categoryArray['faq_id'] = $object->getId();
100
+ $categoryArray['category_id'] = $categoryId;
101
+ $this->_getWriteAdapter()->insert(
102
+ $this->getTable('faq/category_item'), $categoryArray
103
+ );
104
+ }
105
+
106
+ return parent::_afterSave($object);
107
+ }
108
+
109
+ /**
110
+ * Do store and category processing after loading
111
+ *
112
+ * @param Mage_Core_Model_Abstract $object Current faq item
113
+ */
114
+ protected function _afterLoad(Mage_Core_Model_Abstract $object)
115
+ {
116
+ // process faq item to store relation
117
+ $select = $this->_getReadAdapter()->select()->from(
118
+ $this->getTable('faq/faq_store')
119
+ )->where('faq_id = ?', $object->getId());
120
+
121
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
122
+ $storesArray = array ();
123
+ foreach ($data as $row) {
124
+ $storesArray[] = $row['store_id'];
125
+ }
126
+ $object->setData('store_id', $storesArray);
127
+ }
128
+
129
+ // process faq item to category relation
130
+ $select = $this->_getReadAdapter()->select()->from(
131
+ $this->getTable('faq/category_item')
132
+ )->where('faq_id = ?', $object->getId());
133
+
134
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
135
+ $categoryArray = array ();
136
+ foreach ($data as $row) {
137
+ $categoryArray[] = $row['category_id'];
138
+ }
139
+ $object->setData('category_id', $categoryArray);
140
+ }
141
+
142
+ return parent::_afterLoad($object);
143
+ }
144
+ }
app/code/local/Inic/Faq/Model/Mysql4/Faq/Collection.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Model_Mysql4_Faq_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
18
+ {
19
+ protected $_previewFlag;
20
+
21
+ /**
22
+ * Constructor
23
+ *
24
+ */
25
+ protected function _construct()
26
+ {
27
+ $this->_init('faq/faq')
28
+ ->setOrder('question', 'ASC');
29
+ }
30
+
31
+ /**
32
+ * Creates an options array for grid filter functionality
33
+ *
34
+ * @return array Options array
35
+ */
36
+ public function toOptionArray()
37
+ {
38
+ return $this->_toOptionArray('faq_id', 'question');
39
+ }
40
+
41
+ public function addIsActiveFilter()
42
+ {
43
+ $this->addFilter('is_active', 1);
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Add Filter by category
49
+ *
50
+ * @param int|Inic_Faq_Model_Category $category Category to be filtered
51
+ * @return Inic_Faq_Model_Mysql4_Category_Collection
52
+ */
53
+ public function addCategoryFilter($category)
54
+ {
55
+ if ($category instanceof Inic_Faq_Model_Category) {
56
+ $category = array($category->getId());
57
+ }
58
+
59
+ $this->getSelect()->join(
60
+ array('category_table' => $this->getTable('faq/category_item')),
61
+ 'main_table.faq_id = category_table.faq_id',
62
+ array ()
63
+ )->where('category_table.category_id in (?)', array (
64
+ 0,
65
+ $category
66
+ ))->group('main_table.faq_id');
67
+
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * Add Filter by store
73
+ *
74
+ * @param int|Mage_Core_Model_Store $store Store to be filtered
75
+ * @return Inic_Faq_Model_Mysql4_Faq_Collection Self
76
+ */
77
+ public function addStoreFilter($store)
78
+ {
79
+ if ($store instanceof Mage_Core_Model_Store) {
80
+ $store = array (
81
+ $store->getId()
82
+ );
83
+ }
84
+
85
+ $this->getSelect()->join(
86
+ array('store_table' => $this->getTable('faq/faq_store')),
87
+ 'main_table.faq_id = store_table.faq_id',
88
+ array ()
89
+ )->where('store_table.store_id in (?)', array (
90
+ 0,
91
+ $store
92
+ ))->group('main_table.faq_id');
93
+
94
+ return $this;
95
+ }
96
+
97
+
98
+ /**
99
+ * After load processing - adds store information to the datasets
100
+ *
101
+ */
102
+ protected function _afterLoad()
103
+ {
104
+ if ($this->_previewFlag) {
105
+ $items = $this->getColumnValues('faq_id');
106
+ if (count($items)) {
107
+ $select = $this->getConnection()->select()->from(
108
+ $this->getTable('faq/faq_store')
109
+ )->where(
110
+ $this->getTable('faq/faq_store') . '.faq_id IN (?)',
111
+ $items
112
+ );
113
+ if ($result = $this->getConnection()->fetchPairs($select)) {
114
+ foreach ($this as $item) {
115
+ if (!isset($result[$item->getData('faq_id')])) {
116
+ continue;
117
+ }
118
+ if ($result[$item->getData('faq_id')] == 0) {
119
+ $stores = Mage::app()->getStores(false, true);
120
+ $storeId = current($stores)->getId();
121
+ $storeCode = key($stores);
122
+ }
123
+ else {
124
+ $storeId = $result[$item->getData('faq_id')];
125
+ $storeCode = Mage::app()->getStore($storeId)->getCode();
126
+ }
127
+ $item->setData('_first_store_id', $storeId);
128
+ $item->setData('store_code', $storeCode);
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ parent::_afterLoad();
135
+ }
136
+ }
app/code/local/Inic/Faq/Model/System/Config/Source/View.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Model_System_Config_Source_View
18
+ {
19
+ /**
20
+ * Options getter
21
+ *
22
+ * @return array
23
+ */
24
+ public function toOptionArray()
25
+ {
26
+ return array(
27
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Grid View')),
28
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('List View')),
29
+ );
30
+ }
31
+
32
+ /**
33
+ * Get options in "key-value" format
34
+ *
35
+ * @return array
36
+ */
37
+ public function toArray()
38
+ {
39
+ return array(
40
+ 0 => Mage::helper('adminhtml')->__('Grid View'),
41
+ 1 => Mage::helper('adminhtml')->__('List View'),
42
+ );
43
+ }
44
+ }
app/code/local/Inic/Faq/controllers/Adminhtml/Faq/CategoryController.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Adminhtml_Faq_CategoryController extends Mage_Adminhtml_Controller_Action
18
+ {
19
+ /**
20
+ * Initialization of current view - add's breadcrumps and the current menu status
21
+ *
22
+ * @return Inic_Faq_AdminController
23
+ */
24
+ protected function _initAction()
25
+ {
26
+ $this->_usedModuleName = 'faq';
27
+
28
+ $this->loadLayout()
29
+ ->_setActiveMenu('cms/faq')
30
+ ->_addBreadcrumb($this->__('CMS'), $this->__('CMS'))
31
+ ->_addBreadcrumb($this->__('FAQ'), $this->__('FAQ'));
32
+
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Displays the FAQ overview grid.
38
+ *
39
+ */
40
+ public function indexAction()
41
+ {
42
+ $this->_initAction()
43
+ ->_addContent($this->getLayout()->createBlock('faq/adminhtml_category'))
44
+ ->renderLayout();
45
+ }
46
+
47
+ /**
48
+ * Displays the new FAQ item form
49
+ */
50
+ public function newAction()
51
+ {
52
+ $this->_forward('edit');
53
+ }
54
+
55
+ /**
56
+ * Displays the new FAQ item form or the edit FAQ item form.
57
+ */
58
+ public function editAction()
59
+ {
60
+ $id = $this->getRequest()->getParam('category_id');
61
+ $model = Mage::getModel('faq/category');
62
+
63
+ // if current id given -> try to load and edit current FAQ category
64
+ if ($id) {
65
+ $model->load($id);
66
+ if (!$model->getId()) {
67
+ Mage::getSingleton('adminhtml/session')->addError(
68
+ Mage::helper('faq')->__('This FAQ category no longer exists')
69
+ );
70
+ $this->_redirect('*/*/');
71
+ return;
72
+ }
73
+ }
74
+
75
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
76
+ if (!empty($data)) {
77
+ $model->setData($data);
78
+ }
79
+
80
+ Mage::register('faq_category', $model);
81
+
82
+ $this->_initAction()
83
+ ->_addBreadcrumb(
84
+ $id
85
+ ? Mage::helper('faq')->__('Edit FAQ Category')
86
+ : Mage::helper('faq')->__('New FAQ Category'),
87
+ $id
88
+ ? Mage::helper('faq')->__('Edit FAQ Category')
89
+ : Mage::helper('faq')->__('New FAQ Category')
90
+ )
91
+ ->_addContent(
92
+ $this->getLayout()
93
+ ->createBlock('faq/adminhtml_category_edit')
94
+ ->setData('action', $this->getUrl('*/*/save'))
95
+ )
96
+ ->_addLeft($this->getLayout()->createBlock('faq/adminhtml_category_edit_tabs'));
97
+
98
+ $this->renderLayout();
99
+ }
100
+
101
+ /**
102
+ * Action that does the actual saving process and redirects back to overview
103
+ */
104
+ public function saveAction()
105
+ {
106
+ // check if data sent
107
+ if ($data = $this->getRequest()->getPost()) {
108
+
109
+ // init model and set data
110
+ $model = Mage::getModel('faq/category');
111
+ $model->setData($data);
112
+
113
+ // try to save it
114
+ try {
115
+ // save the data
116
+ $model->save();
117
+
118
+ // display success message
119
+ Mage::getSingleton('adminhtml/session')->addSuccess(
120
+ Mage::helper('faq')->__('FAQ Category was successfully saved')
121
+ );
122
+ // clear previously saved data from session
123
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
124
+ // check if 'Save and Continue'
125
+ if ($this->getRequest()->getParam('back')) {
126
+ $this->_redirect('*/*/edit', array (
127
+ 'category_id' => $model->getId() ));
128
+ return;
129
+ }
130
+ }
131
+ catch (Exception $e) {
132
+ // display error message
133
+ Mage::getSingleton('adminhtml/session')->addException($e, $e->getMessage());
134
+ // save data in session
135
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
136
+ // redirect to edit form
137
+ $this->_redirect('*/*/edit', array (
138
+ 'category_id' => $this->getRequest()->getParam('category_id') ));
139
+ return;
140
+ }
141
+ }
142
+ $this->_redirect('*/*/');
143
+ }
144
+
145
+ /**
146
+ * Action that does the actual saving process and redirects back to overview
147
+ */
148
+ public function deleteAction()
149
+ {
150
+ // check if we know what should be deleted
151
+ if ($id = $this->getRequest()->getParam('category_id')) {
152
+ try {
153
+ // init model and delete
154
+ $model = Mage::getModel('faq/category');
155
+ $model->load($id);
156
+ $model->delete();
157
+
158
+ // display success message
159
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('faq')->__('FAQ Category was successfully deleted'));
160
+
161
+ // go to grid
162
+ $this->_redirect('*/*/');
163
+ return;
164
+
165
+ }
166
+ catch (Exception $e) {
167
+ // display error message
168
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
169
+
170
+ // go back to edit form
171
+ $this->_redirect('*/*/edit', array (
172
+ 'category_id' => $id ));
173
+ return;
174
+ }
175
+ }
176
+
177
+ // display error message
178
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Unable to find a FAQ Category to delete'));
179
+
180
+ // go to grid
181
+ $this->_redirect('*/*/');
182
+ }
183
+
184
+ /**
185
+ * Simple access control
186
+ *
187
+ * @return boolean True if user is allowed to edit FAQ
188
+ */
189
+ protected function _isAllowed()
190
+ {
191
+ return Mage::getSingleton('admin/session')->isAllowed('admin/cms/faq');
192
+ }
193
+ }
app/code/local/Inic/Faq/controllers/Adminhtml/FaqController.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_Adminhtml_FaqController extends Mage_Adminhtml_Controller_Action
18
+ {
19
+ /**
20
+ * Initialization of current view - add's breadcrumps and the current menu status
21
+ *
22
+ * @return Inic_Faq_AdminController
23
+ */
24
+ protected function _initAction()
25
+ {
26
+ $this->_usedModuleName = 'faq';
27
+
28
+ $this->loadLayout()
29
+ ->_setActiveMenu('cms/faq')
30
+ ->_addBreadcrumb($this->__('CMS'), $this->__('CMS'))
31
+ ->_addBreadcrumb($this->__('FAQ'), $this->__('FAQ'));
32
+
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Displays the FAQ overview grid.
38
+ *
39
+ */
40
+ public function indexAction()
41
+ {
42
+ $this->_initAction()
43
+ ->_addContent($this->getLayout()->createBlock('faq/adminhtml_item'))
44
+ ->renderLayout();
45
+ }
46
+
47
+ /**
48
+ * Displays the new FAQ item form
49
+ */
50
+ public function newAction()
51
+ {
52
+ $this->_forward('edit');
53
+ }
54
+
55
+ /**
56
+ * Displays the new FAQ item form or the edit FAQ item form.
57
+ */
58
+ public function editAction()
59
+ {
60
+ $id = $this->getRequest()->getParam('faq_id');
61
+ $model = Mage::getModel('faq/faq');
62
+
63
+ // if current id given -> try to load and edit current FAQ item
64
+ if ($id) {
65
+ $model->load($id);
66
+ if (!$model->getId()) {
67
+ Mage::getSingleton('adminhtml/session')->addError(
68
+ Mage::helper('faq')->__('This FAQ item no longer exists')
69
+ );
70
+ $this->_redirect('*/*/');
71
+ return;
72
+ }
73
+ }
74
+
75
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
76
+ if (!empty($data)) {
77
+ $model->setData($data);
78
+ }
79
+
80
+ Mage::register('faq', $model);
81
+
82
+ $this->_initAction()
83
+ ->_addBreadcrumb(
84
+ $id
85
+ ? Mage::helper('faq')->__('Edit FAQ Item')
86
+ : Mage::helper('faq')->__('New FAQ Item'),
87
+ $id
88
+ ? Mage::helper('faq')->__('Edit FAQ Item')
89
+ : Mage::helper('faq')->__('New FAQ Item')
90
+ )
91
+ ->_addContent(
92
+ $this->getLayout()
93
+ ->createBlock('faq/adminhtml_item_edit')
94
+ ->setData('action', $this->getUrl('adminhtml/faq/save'))
95
+ )
96
+ ->_addLeft($this->getLayout()->createBlock('faq/adminhtml_item_edit_tabs'));
97
+
98
+ $this->renderLayout();
99
+ }
100
+
101
+ /**
102
+ * Action that does the actual saving process and redirects back to overview
103
+ */
104
+ public function saveAction()
105
+ {
106
+ // check if data sent
107
+ if ($data = $this->getRequest()->getPost()) {
108
+
109
+ // init model and set data
110
+ $model = Mage::getModel('faq/faq');
111
+ $model->setData($data);
112
+
113
+ // try to save it
114
+ try {
115
+ // save the data
116
+ $model->save();
117
+
118
+ // display success message
119
+ Mage::getSingleton('adminhtml/session')->addSuccess(
120
+ Mage::helper('faq')->__('FAQ Item was successfully saved')
121
+ );
122
+ // clear previously saved data from session
123
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
124
+ // check if 'Save and Continue'
125
+ if ($this->getRequest()->getParam('back')) {
126
+ $this->_redirect('*/*/edit', array (
127
+ 'faq_id' => $model->getId() ));
128
+ return;
129
+ }
130
+ // go to grid
131
+ $this->_redirect('*/*/');
132
+ return;
133
+
134
+ }
135
+ catch (Exception $e) {
136
+ // display error message
137
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
138
+ // save data in session
139
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
140
+ // redirect to edit form
141
+ $this->_redirect('*/*/edit', array (
142
+ 'faq_id' => $this->getRequest()->getParam('faq_id') ));
143
+ return;
144
+ }
145
+ }
146
+ $this->_redirect('*/*/');
147
+ }
148
+
149
+
150
+ /**
151
+ * Simple access control
152
+ *
153
+ * @return boolean True if user is allowed to edit FAQ
154
+ */
155
+ protected function _isAllowed()
156
+ {
157
+ return Mage::getSingleton('admin/session')->isAllowed('admin/cms/faq');
158
+ }
159
+
160
+ /**
161
+ * Action that does the actual saving process and redirects back to overview
162
+ */
163
+ public function deleteAction()
164
+ {
165
+ // check if we know what should be deleted
166
+ if ($id = $this->getRequest()->getParam('faq_id')) {
167
+ try {
168
+
169
+ // init model and delete
170
+ $model = Mage::getModel('faq/faq');
171
+ $model->load($id);
172
+ $model->delete();
173
+
174
+ // display success message
175
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('faq')->__('FAQ Entry was successfully deleted'));
176
+
177
+ // go to grid
178
+ $this->_redirect('*/*/');
179
+ return;
180
+
181
+ }
182
+ catch (Exception $e) {
183
+
184
+ // display error message
185
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
186
+
187
+ // go back to edit form
188
+ $this->_redirect('*/*/edit', array (
189
+ 'faq_id' => $id ));
190
+ return;
191
+ }
192
+ }
193
+
194
+ // display error message
195
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faq')->__('Unable to find a FAQ entry to delete'));
196
+
197
+ // go to grid
198
+ $this->_redirect('*/*/');
199
+ }
200
+ }
app/code/local/Inic/Faq/controllers/IndexController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Inic
14
+ * @package Inic_Faq
15
+ * @author Inic
16
+ */
17
+ class Inic_Faq_IndexController extends Mage_Core_Controller_Front_Action
18
+ {
19
+ /**
20
+ * Displays the FAQ list.
21
+ */
22
+ public function indexAction()
23
+ {
24
+ $this->loadLayout()->renderLayout();
25
+ }
26
+
27
+ /**
28
+ * Displays the current FAQ's detail view
29
+ */
30
+ public function showAction()
31
+ {
32
+ $this->loadLayout()->renderLayout();
33
+ }
34
+
35
+
36
+ /**
37
+ * Displays the current Category's FAQ list view
38
+ */
39
+ public function categoryshowAction()
40
+ {
41
+ $this->loadLayout()->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * Displays the current Category's FAQ list view
46
+ */
47
+ public function resultAction()
48
+ {
49
+ $this->loadLayout()->renderLayout();
50
+ }
51
+ }
app/code/local/Inic/Faq/etc/adminhtml.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <cms>
5
+ <children>
6
+ <faq translate="title" module="faq">
7
+ <title>FAQ</title>
8
+ <sort_order>60</sort_order>
9
+ <children>
10
+ <item translate="title" module="faq">
11
+ <title>Manage Items</title>
12
+ <action>adminhtml/faq</action>
13
+ </item>
14
+ <category translate="title" module="faq">
15
+ <title>Manage Categories</title>
16
+ <action>adminhtml/faq_category</action>
17
+ </category>
18
+ </children>
19
+ </faq>
20
+ </children>
21
+ </cms>
22
+ </menu>
23
+ <!--
24
+ <acl>
25
+ <resources>
26
+ <admin>
27
+ <children>
28
+ <cms>
29
+ <children>
30
+ <faq translate="title" module="inic_faq">
31
+ <title>Faq</title>
32
+ <sort_order>50</sort_order>
33
+ </faq>
34
+ </children>
35
+ </cms>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ -->
41
+
42
+
43
+ <acl>
44
+ <resources>
45
+ <admin>
46
+ <children>
47
+ <system>
48
+ <children>
49
+ <config>
50
+ <children>
51
+ <faq_section translate="title">
52
+ <title>FAQ</title>
53
+ <sort_order>200</sort_order>
54
+ </faq_section>
55
+ </children>
56
+ </config>
57
+ </children>
58
+ </system>
59
+ </children>
60
+ </admin>
61
+ </resources>
62
+ </acl>
63
+ </config>
app/code/local/Inic/Faq/etc/config.xml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Inic_Faq>
5
+ <version>1.1.2</version>
6
+ </Inic_Faq>
7
+ </modules>
8
+
9
+ <admin>
10
+ <routers>
11
+ <adminhtml>
12
+ <args>
13
+ <modules>
14
+ <Inic_Faq before="Mage_Adminhtml">Inic_Faq_Adminhtml</Inic_Faq>
15
+ </modules>
16
+ </args>
17
+ </adminhtml>
18
+ </routers>
19
+ </admin>
20
+
21
+ <frontend>
22
+ <routers>
23
+ <faq>
24
+ <use>standard</use>
25
+ <args>
26
+ <module>Inic_Faq</module>
27
+ <frontName>faq</frontName>
28
+ </args>
29
+ </faq>
30
+ </routers>
31
+ <translate>
32
+ <modules>
33
+ <Inic_Faq>
34
+ <files>
35
+ <default>Inic_Faq.csv</default>
36
+ </files>
37
+ </Inic_Faq>
38
+ </modules>
39
+ </translate>
40
+ <layout>
41
+ <updates>
42
+ <faq>
43
+ <file>faq.xml</file>
44
+ </faq>
45
+ </updates>
46
+ </layout>
47
+ </frontend>
48
+
49
+ <global>
50
+ <helpers>
51
+ <faq>
52
+ <class>Inic_Faq_Helper</class>
53
+ </faq>
54
+ </helpers>
55
+
56
+ <blocks>
57
+ <faq>
58
+ <class>Inic_Faq_Block</class>
59
+ </faq>
60
+ </blocks>
61
+
62
+ <models>
63
+ <faq>
64
+ <class>Inic_Faq_Model</class>
65
+ <resourceModel>faq_mysql4</resourceModel>
66
+ </faq>
67
+ <faq_mysql4>
68
+ <class>Inic_Faq_Model_Mysql4</class>
69
+ <entities>
70
+ <category>
71
+ <table>faq_category</table>
72
+ </category>
73
+ <category_item>
74
+ <table>faq_category_item</table>
75
+ </category_item>
76
+ <category_store>
77
+ <table>faq_category_store</table>
78
+ </category_store>
79
+ <faq>
80
+ <table>faq</table>
81
+ </faq>
82
+ <faq_store>
83
+ <table>faq_store</table>
84
+ </faq_store>
85
+ </entities>
86
+ </faq_mysql4>
87
+ </models>
88
+
89
+ <resources>
90
+ <faq_setup>
91
+ <setup>
92
+ <module>Inic_Faq</module>
93
+ </setup>
94
+ <connection>
95
+ <use>core_setup</use>
96
+ </connection>
97
+ </faq_setup>
98
+ <faq_write>
99
+ <connection>
100
+ <use>core_write</use>
101
+ </connection>
102
+ </faq_write>
103
+ <faq_read>
104
+ <connection>
105
+ <use>core_read</use>
106
+ </connection>
107
+ </faq_read>
108
+ </resources>
109
+ </global>
110
+
111
+ <adminhtml>
112
+ <translate>
113
+ <modules>
114
+ <Inic_Faq>
115
+ <files>
116
+ <default>Inic_Faq.csv</default>
117
+ </files>
118
+ </Inic_Faq>
119
+ </modules>
120
+ </translate>
121
+ </adminhtml>
122
+ <install>
123
+ <translate>
124
+ <modules>
125
+ <Inic_Faq>
126
+ <files>
127
+ <default>Inic_Faq.csv</default>
128
+ </files>
129
+ </Inic_Faq>
130
+ </modules>
131
+ </translate>
132
+ </install>
133
+ </config>
app/code/local/Inic/Faq/etc/system.xml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <tabs>
4
+ <faq_tab translate="label">
5
+ <label>Faq Settings</label>
6
+ <sort_order>200</sort_order>
7
+ </faq_tab>
8
+ </tabs>
9
+ <sections>
10
+ <faq_section translate="label">
11
+ <label>Faq</label>
12
+ <sort_order>200</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ <tab>faq_tab</tab>
17
+ <groups>
18
+ <general translate="label">
19
+ <label>FAQ Configuration</label>
20
+ <sort_order>600</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <fields>
23
+ <frequent_enable translate="label">
24
+ <label>Show Frequently Questions</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
+ <sort_order>10</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ </frequent_enable>
30
+ </fields>
31
+ <fields>
32
+ <no_most_frequent_que translate="label">
33
+ <label>Number of Frequently Questions</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>20</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ </no_most_frequent_que>
38
+ </fields>
39
+ <fields>
40
+ <no_of_cat_que translate="label">
41
+ <label>Number of category Questions</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>30</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ </no_of_cat_que>
46
+ </fields>
47
+ <fields>
48
+ <view_style translate="label">
49
+ <label>Display Settings</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>faq/system_config_source_view</source_model>
52
+ <sort_order>40</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ </view_style>
55
+ </fields>
56
+ <fields>
57
+ <search_enable translate="label">
58
+ <label>Show Search</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>10</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ </search_enable>
64
+ </fields>
65
+ </general>
66
+ </groups>
67
+ </faq_section>
68
+ </sections>
69
+ </config>
app/code/local/Inic/Faq/sql/faq_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ $installer->run("
15
+ -- DROP TABLE IF EXISTS {$this->getTable('faq/faq')};
16
+ CREATE TABLE IF NOT EXISTS {$this->getTable('faq/faq')} (
17
+ `faq_id` int(10) unsigned NOT NULL auto_increment,
18
+ `question` tinytext NOT NULL default '',
19
+ `answer` text NOT NULL default '',
20
+ `creation_time` datetime default NULL,
21
+ `update_time` datetime default NULL,
22
+ `is_active` tinyint(1) NOT NULL default '1',
23
+ `is_most_frequent` tinyint(1) NOT NULL default '1',
24
+ PRIMARY KEY (`faq_id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items' AUTO_INCREMENT=1 ;
26
+
27
+ -- DROP TABLE IF EXISTS {$this->getTable('faq/faq_store')};
28
+ CREATE TABLE `{$this->getTable('faq/faq_store')}` (
29
+ `faq_id` int(10) unsigned NOT NULL,
30
+ `store_id` smallint(5) unsigned NOT NULL,
31
+ PRIMARY KEY (`faq_id`,`store_id`),
32
+ CONSTRAINT `FK_FAQ_FAQ_STORE_FAQ` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE,
33
+ CONSTRAINT `FK_FAQ_FAQ_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items to Stores';
35
+ ");
36
+
37
+ $installer->endSetup();
app/code/local/Inic/Faq/sql/faq_setup/mysql4-install-1.0.7.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ $installer->run("
15
+ -- DROP TABLE IF EXISTS {$this->getTable('faq/faq')};
16
+ CREATE TABLE IF NOT EXISTS {$this->getTable('faq/faq')} (
17
+ `faq_id` int(10) unsigned NOT NULL auto_increment,
18
+ `question` tinytext NOT NULL default '',
19
+ `answer` text NOT NULL default '',
20
+ `creation_time` datetime NOT NULL,
21
+ `update_time` datetime NOT NULL,
22
+ `is_active` tinyint(1) NOT NULL default '1',
23
+ `is_most_frequent` tinyint(1) NOT NULL default '1',
24
+ PRIMARY KEY (`faq_id`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items' AUTO_INCREMENT=1 ;
26
+
27
+ -- DROP TABLE IF EXISTS `{$this->getTable('faq/faq_store')}`;
28
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('faq/faq_store')}` (
29
+ `faq_id` int(10) unsigned NOT NULL,
30
+ `store_id` smallint(5) unsigned NOT NULL,
31
+ PRIMARY KEY (`faq_id`,`store_id`),
32
+ CONSTRAINT `FK_FAQ_FAQ_STORE_FAQ` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE,
33
+ CONSTRAINT `FK_FAQ_FAQ_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items to Stores';
35
+
36
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('faq/category')}` (
37
+ `category_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
38
+ `parent_id` INT(10) UNSIGNED NULL,
39
+ `category_name` VARCHAR(255) NOT NULL,
40
+ `creation_time` DATETIME NOT NULL,
41
+ `update_time` DATETIME NOT NULL,
42
+ `is_active` TINYINT(1) NOT NULL DEFAULT 1,
43
+ PRIMARY KEY (`category_id`),
44
+ CONSTRAINT `FK_FAQ_CATEGORY_PARENT_ID` FOREIGN KEY (`parent_id`) REFERENCES `{$this->getTable('faq/category')}` (`category_id`) ON DELETE SET NULL
45
+ ) ENGINE=InnoDB COMMENT='FAQ Categories';
46
+
47
+ -- DROP TABLE IF EXISTS `{$this->getTable('faq/category_item')}`;
48
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('faq/category_item')}` (
49
+ `category_id` INT(10) UNSIGNED NOT NULL,
50
+ `faq_id` INT(10) UNSIGNED NOT NULL,
51
+ PRIMARY KEY (`category_id`,`faq_id`),
52
+ CONSTRAINT `FK_FAQ_CATEGORY_ITEM_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
53
+ CONSTRAINT `FK_FAQ_CATEGORY_ITEM_ITEM` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE
54
+ ) ENGINE=InnoDB COMMENT='FAQ Items to Cateories';
55
+
56
+ -- DROP TABLE IF EXISTS `{$this->getTable('faq/category_store')}`;
57
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('faq/category_store')}` (
58
+ `category_id` INT(10) UNSIGNED NOT NULL,
59
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL,
60
+ PRIMARY KEY (`category_id`,`store_id`),
61
+ CONSTRAINT `FK_FAQ_CATEGORY_STORE_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
62
+ CONSTRAINT `FK_FAQ_CATEGORY_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
63
+ ) ENGINE=InnoDB COMMENT='FAQ Categories to Stores';
64
+
65
+ ");
66
+
67
+ $installer->endSetup();
app/code/local/Inic/Faq/sql/faq_setup/mysql4-upgrade-1.0.6-1.0.7.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Inic
6
+ * @package Inic_Faq
7
+ * @copyright Copyright (c) 2013 Indianic
8
+ */
9
+
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ $installer->run("
15
+
16
+ ALTER TABLE `{$this->getTable('faq/faq')}`
17
+ MODIFY COLUMN `creation_time` DATETIME NOT NULL;
18
+ ALTER TABLE `{$this->getTable('faq/faq')}`
19
+ MODIFY COLUMN `update_time` DATETIME NOT NULL;
20
+
21
+ CREATE TABLE `{$this->getTable('faq/category')}` (
22
+ `category_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
23
+ `parent_id` INT(10) UNSIGNED NULL,
24
+ `category_name` VARCHAR(255) NOT NULL,
25
+ `creation_time` DATETIME NOT NULL,
26
+ `update_time` DATETIME NOT NULL,
27
+ `is_active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
28
+ PRIMARY KEY (`category_id`),
29
+ CONSTRAINT `FK_FAQ_CATEGORY_PARENT_ID` FOREIGN KEY (`parent_id`) REFERENCES `{$this->getTable('faq/category')}` (`category_id`) ON DELETE SET NULL
30
+ ) ENGINE=InnoDB COMMENT='FAQ Categories';
31
+
32
+ -- DROP TABLE IF EXISTS `{$this->getTable('faq/category_item')}`;
33
+ CREATE TABLE `{$this->getTable('faq/category_item')}` (
34
+ `category_id` INT(10) UNSIGNED NOT NULL,
35
+ `faq_id` INT(10) UNSIGNED NOT NULL,
36
+ PRIMARY KEY (`category_id`,`faq_id`),
37
+ CONSTRAINT `FK_FAQ_CATEGORY_ITEM_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
38
+ CONSTRAINT `FK_FAQ_CATEGORY_ITEM_ITEM` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE
39
+ ) ENGINE=InnoDB COMMENT='FAQ Items to Cateories';
40
+
41
+ -- DROP TABLE IF EXISTS `{$this->getTable('faq/category_store')}`;
42
+ CREATE TABLE `{$this->getTable('faq/category_store')}` (
43
+ `category_id` INT(10) UNSIGNED NOT NULL,
44
+ `store_id` SMALLINT(5) UNSIGNED NOT NULL,
45
+ PRIMARY KEY (`category_id`,`store_id`),
46
+ CONSTRAINT `FK_FAQ_CATEGORY_STORE_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
47
+ CONSTRAINT `FK_FAQ_CATEGORY_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
48
+ ) ENGINE=InnoDB COMMENT='FAQ Categories to Stores';
49
+
50
+ ");
51
+
52
+ $installer->endSetup();
app/design/frontend/base/default/layout/faq.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category design_default
23
+ * @package Mage
24
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <layout version="0.1.0">
29
+ <default translate="label" module="page">
30
+ <reference name="top.links">
31
+ <action method="addLink" translate="label title" module="customer"><label>Faq</label><url>faq</url><title>Faq</title><prepare>true</prepare><urlParams/><position>200</position><liParams/><aParams/></action>
32
+ </reference>
33
+ </default>
34
+ <faq_index_index>
35
+ <reference name="head">
36
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq.css</name><params/></action>
37
+ <action method="addItem"><type>skin_js</type><name>js/faq/faq.js</name><params/></action>
38
+ </reference>
39
+ <reference name="root">
40
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
41
+ </reference>
42
+ <reference name="content">
43
+ <block type="faq/frontend_list" name="faq_list" template="faq/list.phtml">
44
+ <block type="faq/frontend_faqSearch_search" name="search_form" as="search_form" template="faq/search/search.phtml"/>
45
+ </block>
46
+ </reference>
47
+ </faq_index_index>
48
+
49
+ <faq_index_show>
50
+ <reference name="head">
51
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq.css</name><params/></action>
52
+ <action method="addItem"><type>skin_js</type><name>js/faq/faq.js</name><params/></action>
53
+ </reference>
54
+ <reference name="root">
55
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
56
+ </reference>
57
+ <reference name="content">
58
+ <block type="faq/frontend_detail" name="faq_detail" template="faq/detail.phtml"/>
59
+ </reference>
60
+ </faq_index_show>
61
+
62
+ <faq_index_categoryshow>
63
+ <reference name="head">
64
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq.css</name><params/></action>
65
+ <action method="addItem"><type>skin_js</type><name>js/faq/faq.js</name><params/></action>
66
+ </reference>
67
+ <reference name="root">
68
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
69
+ </reference>
70
+ <reference name="content">
71
+ <block type="faq/frontend_category" name="faq_category" template="faq/categoty.phtml">
72
+ <block type="faq/frontend_faqSearch_search" name="cat_search_form" as="cat_search_form" template="faq/search/search.phtml"/>
73
+ </block>
74
+ </reference>
75
+ </faq_index_categoryshow>
76
+
77
+ <faq_index_result>
78
+ <reference name="head">
79
+ <action method="addItem"><type>skin_css</type><name>css/faq/faq.css</name><params/></action>
80
+ <action method="addItem"><type>skin_js</type><name>js/faq/faq.js</name><params/></action>
81
+ </reference>
82
+ <reference name="root">
83
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
84
+ </reference>
85
+ <reference name="content">
86
+ <block type="faq/frontend_faqSearch_result" name="faq_search_result" template="faq/search/result.phtml"/>
87
+ </reference>
88
+ </faq_index_result>
89
+ </layout>
app/design/frontend/base/default/template/faq/categoty.phtml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_faqCategory = $this->getCategory() ?>
2
+ <div class="calegory-faq-list">
3
+ <?php if ($_faqCategory): ?>
4
+ <div class="page-title" style="overflow: visible;">
5
+ <h1><?php echo $this->htmlEscape($_faqCategory->getName()) ?></h1>
6
+ </div>
7
+ <div class="expand" id="expand-collaps"><a href="javascript:void(0)" onclick="expand(this)"><?php echo $this->__('Expand All'); ?></a></div>
8
+ <?php //Search Area ?>
9
+ <?php echo $this->getChildHtml('cat_search_form'); ?>
10
+
11
+ <div class="faq-detail">
12
+ <?php if(Mage::helper('faq')->getQuestionView()=="list"): ?>
13
+ <?php foreach ($this->getcatFaqCollection() as $item) : ?>
14
+ <table class="faq-listdata-table">
15
+ <tbody>
16
+ <tr class="faq-question">
17
+ <td width="5%"><span class="label important"><?php echo $this->__('Q') ?></span></td>
18
+ <td>
19
+ <strong> <?php echo $this->htmlEscape($item->getQuestion()); ?><strong>
20
+ </td>
21
+ </tr>
22
+ <tr class="faq-answer" style="display:none;">
23
+ <td><span class="label success"><?php echo $this->__('A') ?></span></td>
24
+ <td>
25
+ <?php echo $item->getAnswer(); ?>
26
+ </td>
27
+ </tr>
28
+ </tbody>
29
+ </table>
30
+ <?php endforeach; ?>
31
+ <?php else: ?>
32
+ <div class="faq-list">
33
+ <?php //If Grid View ?>
34
+ <?php $i=0; ?>
35
+ <?php $Collection=$this->getcatFaqCollection(); ?>
36
+ <?php
37
+ $collectionCount=count($Collection);
38
+ $_columnCount=intval($collectionCount/2);
39
+ ?>
40
+ <div style="width:100%;" class="faq-grid-list">
41
+ <?php foreach ($Collection as $item) : ?>
42
+ <?php if ($i++==$_columnCount || $i==1): ?>
43
+ <div class="faq-griddata-table">
44
+ <?php endif; ?>
45
+ <table>
46
+ <tbody>
47
+ <tr class="faq-question">
48
+ <td width="5%"><span class="label important"><?php echo $this->__('Q') ?></span></td>
49
+ <td>
50
+ <strong> <?php echo $this->htmlEscape($item->getQuestion()); ?><strong>
51
+ </td>
52
+ </tr>
53
+ <tr class="faq-answer" style="display:none;">
54
+ <td><span class="label success"><?php echo $this->__('A') ?></span></td>
55
+ <td>
56
+ <?php echo $item->getAnswer(); ?>
57
+ </td>
58
+ </tr>
59
+ </tbody>
60
+ </table>
61
+ <?php if ($i==$_columnCount || $i==$collectionCount): ?>
62
+ </div>
63
+ <?php endif; ?>
64
+ <?php endforeach; ?>
65
+ </div>
66
+ </div>
67
+ <?php endif; ?>
68
+ </div>
69
+ <p class="bk-link"><a href="<?php echo Mage :: app()->getStore()->getUrl('faq') ?>" title="<?php echo $this->__('Back to the FAQ overview') ?>"><?php echo $this->__('Back to the FAQ overview') ?></a></p>
70
+ </div>
71
+ <?php else: ?>
72
+ <div class="page-title">
73
+ <h1><?php echo $this->__('Error') ?></h1>
74
+ </div>
75
+
76
+ <p><?php echo $this->__('The requested FAQ Category item could not be found!') ?></p>
77
+ <?php endif; ?>
78
+ <script type="text/javascript">
79
+ $$('.faq-question').each(function(element) {
80
+ element.observe('click', function(){
81
+ this.next().toggle();
82
+ });
83
+ })
84
+ </script>
app/design/frontend/base/default/template/faq/detail.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_faq = $this->getFaq() ?>
2
+
3
+ <?php if ($_faq): ?>
4
+ <div class="page-title" style="overflow: visible;">
5
+ <h1><?php echo $this->htmlEscape($_faq->getQuestion()) ?></h1>
6
+ </div>
7
+
8
+ <div class="faq-detail">
9
+ <p class="faq-date">
10
+ <?php echo Mage :: getModel('core/date')->date('d.m.Y', $_faq->getPublicationTime()); ?>
11
+ </p>
12
+
13
+ <?php $_content = $_faq->getAnswer(); ?>
14
+ <?php if (!empty($_content)): ?>
15
+ <div class="faq-content">
16
+ <?php foreach (explode("\n", $_content) as $paragraph): ?>
17
+ <p><?php echo $paragraph ?></p>
18
+ <?php endforeach; ?>
19
+ </div>
20
+ <?php endif; ?>
21
+
22
+ <p><a href="<?php echo Mage :: app()->getStore()->getUrl('faq') ?>" title="<?php echo $this->__('Back to the FAQ overview') ?>"><?php echo $this->__('Back to the FAQ overview') ?></a></p>
23
+ </div>
24
+ <?php else: ?>
25
+ <div class="page-title">
26
+ <h1><?php echo $this->__('Error') ?></h1>
27
+ </div>
28
+
29
+ <p><?php echo $this->__('The requested FAQ item could not be found!') ?></p>
30
+ <?php endif; ?>
app/design/frontend/base/default/template/faq/list(2).phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design_default
22
+ * @package Inic
23
+ * @copyright Copyright (c) 2013 Indianic
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /* @var $this Inic_Faq_Block_Frontend_List */
27
+ ?>
28
+ <div class="page-title">
29
+ <h1><?php echo $this->__('Frequently asked questions'); ?></h1>
30
+ </div>
31
+
32
+ <?php if ($this->hasFaq()): ?>
33
+ <?php if($this->hasFrequent()): ?>
34
+ <h2><?php echo $this->__('Most Frequently Asked Questions'); ?></h2>
35
+ <dl class="faq-items">
36
+ <?php foreach ($this->getFrequentFaqCollection() as $faqItem): ?>
37
+ <dt>
38
+ <a href="#faq-item-<?php echo $faqItem->getId() ?>">
39
+ <?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
40
+ </a>
41
+ </dt>
42
+ <dd>
43
+ <?php echo $faqItem->getAnswer(); ?>
44
+ </dd>
45
+ <?php endforeach; ?>
46
+ </dl>
47
+ <?php endif; ?>
48
+
49
+
50
+ <h2><?php echo $this->__('Questions'); ?></h2>
51
+ <?php if ($this->getCategoryCollection()) : ?>
52
+ <dl class="faq-list">
53
+ <?php foreach ($this->getCategoryCollection() as $category) : ?>
54
+ <dt><b><?php echo $this->htmlEscape($category->getName()); ?></b></dt>
55
+ <dd>
56
+ <ul class="faq-list">
57
+ <?php foreach ($this->getItemCollectionByCategory($category) as $item) : ?>
58
+ <li>
59
+ <a href="#faq-item-<?php echo $item->getId() ?>">
60
+ <?php echo $this->htmlEscape($item->getQuestion()); ?>
61
+ </a>
62
+ </li>
63
+ <li>
64
+ <?php echo $item->getAnswer(); ?>
65
+ </li>
66
+ <?php endforeach; ?>
67
+ <?php $collectionCount=$this->getItemCollectionByCategoryCount($category); ?>
68
+ <?php if($collectionCount): ?>
69
+ <li>
70
+ <a href="<?php echo $this->getCategoryUrl($category) ?>" style="float:right;"><?php echo $this->__('more'); ?></a>
71
+ </li>
72
+ <?php endif; ?>
73
+ </ul>
74
+ </dd>
75
+ <?php endforeach; ?>
76
+ </dl>
77
+ <?php else : ?>
78
+ <ul class="faq-list">
79
+ <?php foreach ($this->getFaqCollection() as $faqItem): ?>
80
+ <li>
81
+ <a href="#faq-item-<?php echo $faqItem->getId() ?>">
82
+ <?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
83
+ </a>
84
+ </li>
85
+ <li>
86
+ <?php echo $faqItem->getAnswer(); ?>
87
+ </li>
88
+ <?php endforeach; ?>
89
+ </ul>
90
+ <?php endif; ?>
91
+
92
+ <?php else: ?>
93
+ <p class="faq-items"><?php echo $this->__('There are no FAQ items at the moment.') ?></p>
94
+ <?php endif; ?>
app/design/frontend/base/default/template/faq/list.phtml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design_default
22
+ * @package Inic
23
+ * @copyright Copyright (c) 2013 Indianic
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /* @var $this Inic_Faq_Block_Frontend_List */
27
+ ?>
28
+
29
+ <div class="page-title">
30
+ <h2><?php echo $this->__('Frequently Asked Questions'); ?></h2>
31
+ </div>
32
+ <?php if ($this->hasFaq()): ?>
33
+ <div class="expand" id="expand-collaps"><a href="javascript:void(0)" onclick="expand(this)"><?php echo $this->__('Expand All'); ?></a></div>
34
+ <?php if($this->hasFrequent()): ?>
35
+ <div class="faq-frequent-container">
36
+ <h2><?php echo $this->__('Most Frequently Asked Questions'); ?></h2>
37
+ <?php foreach ($this->getFrequentFaqCollection() as $faqItem): ?>
38
+ <table class="faq-listdata-table">
39
+ <?php //echo $this->getQuestionView() ?>
40
+ <tbody>
41
+ <tr class="faq-question">
42
+ <td width="5%"><span class="label important"><?php echo $this->__('Q') ?></span></td>
43
+ <td>
44
+ <strong><?php echo $this->htmlEscape($faqItem->getQuestion()) ?><strong>
45
+ </td>
46
+ </tr>
47
+ <tr class="faq-answer" style="display:none;">
48
+ <td><span class="label success"><?php echo $this->__('A') ?></span></td>
49
+ <td>
50
+ <?php echo $faqItem->getAnswer(); ?>
51
+ </td>
52
+ </tr>
53
+ </tbody>
54
+ </table>
55
+ <?php endforeach; ?>
56
+ </div>
57
+ <?php endif; ?>
58
+ <?php //Search Area ?>
59
+ <?php echo $this->getChildHtml('search_form'); ?>
60
+
61
+ <div class="faq-container">
62
+ <h2><?php echo $this->__('FAQ Topics'); ?></h2>
63
+ <?php if ($this->getCategoryCollection()) : ?>
64
+ <dl class="faq-list">
65
+ <?php foreach ($this->getCategoryCollection() as $category) : ?>
66
+ <?php $catQues=$this->getItemCollectionByCategory($category); ?>
67
+ <?php if(count($catQues) > 0): ?>
68
+ <div>
69
+ <dt><h3><a class="catname" href="<?php echo $this->getCategoryUrl($category) ?>"><?php echo $this->htmlEscape($category->getName()); ?></a></h3></dt>
70
+ <dd>
71
+ <?php //If List View ?>
72
+ <?php if(Mage::helper('faq')->getQuestionView()=="list"): ?>
73
+ <?php foreach ($catQues as $item) : ?>
74
+ <table class="faq-listdata-table">
75
+ <tbody>
76
+ <tr class="faq-question">
77
+ <td width="5%"><span class="label important"><?php echo $this->__('Q') ?></span></td>
78
+ <td>
79
+ <strong> <?php echo $this->htmlEscape($item->getQuestion()); ?><strong>
80
+ </td>
81
+ </tr>
82
+ <tr class="faq-answer" style="display:none;">
83
+ <td><span class="label success"><?php echo $this->__('A') ?></span></td>
84
+ <td>
85
+ <?php echo $item->getAnswer(); ?>
86
+ </td>
87
+ </tr>
88
+ </tbody>
89
+ </table>
90
+ <?php endforeach; ?>
91
+ <?php else: ?>
92
+ <?php //If Grid View ?>
93
+ <?php $i=0; ?>
94
+ <?php $Collection=$catQues; ?>
95
+ <?php
96
+ $collectionCount=count($Collection);
97
+ $_columnCount=intval($collectionCount/2);
98
+ ?>
99
+ <div style="width:100%;" class="faq-grid-list">
100
+ <?php foreach ($Collection as $item) : ?>
101
+ <?php if ($i++==$_columnCount || $i==1): ?>
102
+ <div class="faq-griddata-table">
103
+ <?php endif; ?>
104
+ <table>
105
+ <tbody>
106
+ <tr class="faq-question">
107
+ <td width="5%"><span class="label important"><?php echo $this->__('Q') ?></span></td>
108
+ <td>
109
+ <strong> <?php echo $this->htmlEscape($item->getQuestion()); ?><strong>
110
+ </td>
111
+ </tr>
112
+ <tr class="faq-answer" style="display:none;">
113
+ <td><span class="label success"><?php echo $this->__('A') ?></span></td>
114
+ <td>
115
+ <?php echo $item->getAnswer(); ?>
116
+ </td>
117
+ </tr>
118
+ </tbody>
119
+ </table>
120
+ <?php if ($i==$_columnCount || $i==$collectionCount): ?>
121
+ </div>
122
+ <?php endif; ?>
123
+ <?php endforeach; ?>
124
+ </div>
125
+ <?php endif; ?>
126
+ <?php $collectionCount=$this->getItemCollectionByCategoryCount($category); ?>
127
+ <?php if($collectionCount): ?>
128
+ <div style="clear:both;">
129
+ <a href="<?php echo $this->getCategoryUrl($category) ?>" style="float:right;"><?php echo $this->__('more'); ?></a>
130
+ </div>
131
+ <?php endif; ?>
132
+ </dd>
133
+ </div>
134
+ <?php endif; ?>
135
+ <?php endforeach; ?>
136
+ </dl>
137
+ <?php else : ?>
138
+ <ul class="faq-list">
139
+ <?php foreach ($this->getFaqCollection() as $faqItem): ?>
140
+ <li>
141
+ <a href="#faq-item-<?php echo $faqItem->getId() ?>">
142
+ <?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
143
+ </a>
144
+ </li>
145
+ <li>
146
+ <?php echo $faqItem->getAnswer(); ?>
147
+ </li>
148
+ <?php endforeach; ?>
149
+ </ul>
150
+ <?php endif; ?>
151
+ </div>
152
+ <?php else: ?>
153
+ <p class="faq-items"><?php echo $this->__('There are no FAQ items at the moment.') ?></p>
154
+ <?php endif; ?>
155
+ <script type="text/javascript">
156
+ $$('.faq-question').each(function(element) {
157
+ element.observe('click', function(){
158
+ this.next().toggle();
159
+ });
160
+ })
161
+ </script>
app/design/frontend/base/default/template/faq/search/result.phtml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_faqCategory = $this->getSearch() ?>
2
+ <?php
3
+ $flg=false;
4
+ $keyword=$this->getRequest()->getParam('keyword');
5
+ $category="";
6
+ if($this->getRequest()->getParam('cat_id')){
7
+ $id=$this->getRequest()->getParam('cat_id');
8
+ $category=Mage::getModel('faq/category')->load($id);
9
+ $flg=true;
10
+ }
11
+ ?>
12
+ <div class="calegory-faq-list">
13
+ <?php if ($_faqCategory): ?>
14
+ <div class="page-title" style="overflow: visible;">
15
+ <?php if($id): ?>
16
+ <h1><?php echo $this->__('Search Result For - "%s" from category "%s"',$keyword,$category->getName()); ?></h1>
17
+ <?php else: ?>
18
+ <h1><?php echo $this->__('Search Result For : "%s"',$keyword); ?></h1>
19
+ <?php endif; ?>
20
+ </div>
21
+
22
+ <div class="faq-detail">
23
+ <?php foreach ($_faqCategory as $item) : ?>
24
+ <table class="faq-listdata-table">
25
+ <tbody>
26
+ <tr class="faq-question">
27
+ <td width="5%"><span class="label important"><?php echo $this->__('Q') ?></span></td>
28
+ <td>
29
+ <strong> <?php echo $this->htmlEscape($item->getQuestion()); ?><strong>
30
+ </td>
31
+ </tr>
32
+ <tr class="faq-answer" style="display:none;">
33
+ <td><span class="label success"><?php echo $this->__('A') ?></span></td>
34
+ <td>
35
+ <?php echo $item->getAnswer(); ?>
36
+ </td>
37
+ </tr>
38
+ </tbody>
39
+ </table>
40
+ <?php endforeach; ?>
41
+ </div>
42
+ <p>
43
+ <a href="<?php if($flg): ?><?php echo $this->getUrl('faq/index/categoryshow',array('_secure'=>true,'cat_id'=>$id)) ?><?php else: ?><?php echo Mage :: app()->getStore()->getUrl('faq') ?><?php endif; ?>" title="<?php echo $this->__('Back') ?>"><?php echo $this->__('Back') ?></a>
44
+ </p>
45
+ </div>
46
+ <?php else: ?>
47
+ <div class="page-title">
48
+ <h1><?php echo $this->__('Error') ?></h1>
49
+ </div>
50
+
51
+ <p><?php echo $this->__('The no FAQ item could not be found for search string!') ?></p>
52
+ <?php endif; ?>
53
+ <script type="text/javascript">
54
+ $$('.faq-question').each(function(element) {
55
+ element.observe('click', function(){
56
+ this.next().toggle();
57
+ });
58
+ })
59
+ </script>
app/design/frontend/base/default/template/faq/search/search.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php $id = intval($this->getRequest()->getParam('cat_id')); ?>
3
+ <?php if($this->isSearchEnabled()): ?>
4
+ <div class="faq">
5
+ <form name="faqsearch" action="<?php echo $this->getSearchUrl() ?>" method="get">
6
+ <div id="searchform">
7
+ <label for="keyword"><?php echo $this->__('Search FAQ'); ?></label>
8
+ <input type="text" onfocus="this.value='';" maxlength="30" size="30" id="keyword" name="keyword">
9
+ <?php if ($id): ?>
10
+ <input type="hidden" name="cat_id" id="cat_id" value="<?php echo $id; ?>"/>
11
+ <?php endif; ?>
12
+ <button type="submit" class="btnSearch" title="<?php echo $this->__('GO');?>"></button>
13
+ </div>
14
+ </form>
15
+ </div>
16
+ <?php endif; ?>
app/etc/modules/Inic_Faq.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Inic_Faq>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Inic_Faq>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>inic_faq</name>
4
+ <version>1.1.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension allows the user to create the faq question and their categories.</summary>
10
+ <description>- This extension allows the user to create the faq question and their categories.&#xD;
11
+ - Allow to set the gird or list view on frontend.&#xD;
12
+ - You can set the questions as the most frequently ask questions.&#xD;
13
+ - Have configuration settings that allow to show/hide frequently ask questions.</description>
14
+ <notes>This extension allows the user to create the faq question and their categories.</notes>
15
+ <authors><author><name>bejoy balan</name><user>bmca4u</user><email>bmca4u@gmail.com</email></author></authors>
16
+ <date>2013-06-12</date>
17
+ <time>06:20:39</time>
18
+ <contents><target name="magelocal"><dir name="Inic"><dir name="Faq"><dir name="Block"><dir name="Adminhtml"><dir name="Category"><dir name="Edit"><file name="Form.php" hash="1565463e9373b4810beeb1f3ebf85ad4"/><dir name="Tab"><file name="Main.php" hash="d323226467086408db62b8cf1ab9deb2"/></dir><file name="Tabs.php" hash="f628c7c1c5a3262eba24ef6371789c9f"/></dir><file name="Edit.php" hash="43184dbc88660cf366e65daf88f7ad84"/><file name="Grid.php" hash="df850cac1895690e9ca2ed4458e4e8bb"/></dir><file name="Category.php" hash="6e530cf0006701fea820760eb05507b6"/><dir name="Form_"><dir name="Edit"><dir name="Renderer"><file name="Label.php" hash="9d71468d7b7d728ea0407e6043468fae"/></dir></dir></dir><dir name="Item"><dir name="Edit"><file name="Form.php" hash="a28340f01594898277019fa465ab25c0"/><dir name="Tab"><file name="Main.php" hash="533b56e09dd83d8b09b2ddfd2eb5df68"/></dir><file name="Tabs.php" hash="d16c4ed9085b1621e57b62b351c40fbe"/></dir><file name="Edit.php" hash="00074f16986ac40b52091c88358c627b"/><file name="Grid.php" hash="8b80cec312871f3c2d9e1bd2759f3090"/></dir><file name="Item.php" hash="0ca3cce6235d990af1934f034194ae78"/></dir><dir name="Frontend"><file name="Category.php" hash="65f740c1eebb588feccc25bf3c645fe3"/><file name="Detail.php" hash="578280e4e25723fa66346e1f4ec3950a"/><dir name="FaqSearch"><file name="Result.php" hash="b01a89659230f0c3571f2198a8b5246e"/><file name="Search.php" hash="847fc5080ed8efacfd49ef9ccd2cf5bf"/></dir><file name="List.php" hash="1ec290553f7e77ce531a7d5656aa7952"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Faq"><file name="CategoryController.php" hash="93ddd13375bb404963b68b919e4886bd"/></dir><file name="FaqController.php" hash="28de26f82936c5a8fb41f0fef1d371e9"/></dir><file name="IndexController.php" hash="f8f0724405086edb37e5b82134cc232b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="48f0e931787461a326ee80effbb5ea3e"/><file name="config.xml" hash="54cc5359c24841143d481a1dd3ac7de2"/><file name="system.xml" hash="796de1365ab3f8746edc399e30226a62"/></dir><dir name="Helper"><file name="Data.php" hash="cb910cc95b9ca17887b81db0c84f320c"/></dir><dir name="Model"><file name="Category.php" hash="76e90b0d41f2b1072bc7b218ad93703b"/><file name="Faq.php" hash="a343d1e09850bab571617089ef86fc14"/><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="4302d86bdae9b7e0a7b228a0c50da71f"/></dir><file name="Category.php" hash="0f6cb88b69eff537857ee0de991bf00d"/><dir name="Faq"><file name="Collection.php" hash="f7043e3ed81363dca7083bc2e360ac0e"/></dir><file name="Faq.php" hash="7b34ae72a182f427ee6f11dbb2e00d19"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="View.php" hash="b72c180084212d870be4dd2c840ab1c7"/></dir></dir></dir></dir><dir name="sql"><dir name="faq_setup"><file name="mysql4-install-0.1.0.php" hash="e40ffc8498343af1808bc37d060a1bde"/><file name="mysql4-install-1.0.7.php" hash="d906165a2d976a6b269995ca9d51d221"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="31c535beec84b59a718aac6de0d0eb15"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Inic_Faq.xml" hash="6e20d3392792573c752ee3a0b4c0f83a"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="faq"><file name="faq.css" hash="e817d938be8f4f25627fb4bce1e8b95f"/></dir></dir><dir name="images"><dir name="faq"><file name="faq_search_bar.png" hash="2f9360b3aaab98850694b7e4bb795179"/><file name="minus.png" hash="568c3964d6361fc065f61c9a7dd1cfde"/><file name="plus.png" hash="06a20e393a6aac4ae0bfb59b453f7a18"/><file name="search.gif" hash="798952b8b1ddd7c2f8d3d1ba11a1599c"/></dir></dir><dir name="js"><dir name="faq"><file name="faq.js" hash="9fa39d036f2d0bbd4fc6a18af6738562"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="faq.xml" hash="156bd9df3158e66e212bd87f6ebb8041"/></dir><dir name="template"><dir name="faq"><file name="categoty.phtml" hash="563be74a1a302bc5e961adef443c1292"/><file name="detail.phtml" hash="71e0180427e6b92f6a728b496366bf58"/><file name="list(2).phtml" hash="b3f670a65f3423f584310d5a3e51a63c"/><file name="list.phtml" hash="ae30ee0da33769063f1951c5f03ec341"/><dir name="search"><file name="result.phtml" hash="ac6ec1ca7ffd0944d2e5ad28a837a796"/><file name="search.phtml" hash="33ecd97803bff7a14e93e6a10a4ec026"/></dir></dir></dir></dir></dir></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
21
+ </package>
skin/frontend/base/default/css/faq/faq.css ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * MageSupport.com
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the EULA that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.magesupport.com/license/
9
+ *
10
+ * @package Inic_Faq
11
+ * @copyright Copyright (c) 2013 Inic
12
+ * @license http://www.magesupport.com/license/
13
+ */
14
+ .page-title{
15
+ margin-top: 30px;
16
+ overflow: visible;
17
+ }
18
+ h2{
19
+ border-bottom: 1px solid #DDDDDD;
20
+ margin-bottom: 15px;
21
+ }
22
+
23
+ table tbody tr:first-child td:first-child {
24
+ border-radius: 4px 0 0 0;
25
+ }
26
+ table td {
27
+ vertical-align: top;
28
+ }
29
+ table th, table td {
30
+ line-height: 18px;
31
+ padding: 10px 10px 9px;
32
+ text-align: left;
33
+ }
34
+ .label.important {
35
+ background-color: #C43C35;
36
+ }
37
+ .label {
38
+ background-color: #008800;
39
+ border-radius: 3px 3px 3px 3px;
40
+ color: #FFFFFF;
41
+ font-size: 9.75px;
42
+ font-weight: bold;
43
+ padding: 1px 3px 2px;
44
+ text-transform: uppercase;
45
+ white-space: nowrap;
46
+ }
47
+
48
+ .faq-container{
49
+ width: 100%;
50
+ }
51
+ .faq-frequent-container{
52
+ width: 100%;
53
+ }
54
+ .faq-griddata-table{width: 47%;float:left;}
55
+ .faq-listdata-table{
56
+ width: 100%;
57
+ }
58
+ .faq-listdata-table{
59
+ border: 1px solid #DDDDDD;
60
+ border-collapse: separate;
61
+ border-radius: 4px 4px 4px 4px;
62
+ font-size: 13px;
63
+ margin-bottom: 18px;
64
+ padding: 0;
65
+ }
66
+ .faq-griddata-table th + th, .faq-griddata-table td + td ,table.faq-listdata-table th + th, table.faq-listdata-table td + td{
67
+ border-left: 1px solid #DDDDDD;
68
+ }
69
+ .faq-griddata-table tr + tr td ,table.faq-listdata-table tr + tr td {
70
+ border-top: 1px solid #DDDDDD;
71
+ }
72
+ .faq-detail table tbody tr td:first-child{
73
+ margin-right: 10px;
74
+ }
75
+ .faq-list .faq-griddata-table{
76
+ margin-right: 10px;
77
+ }
78
+ .faq-griddata-table table{
79
+ border: 1px solid #DDDDDD;
80
+ border-collapse: separate;
81
+ border-radius: 4px 4px 4px 4px;
82
+ font-size: 13px;
83
+ margin-bottom: 18px;
84
+ padding: 0;
85
+ }
86
+ .faq-question{
87
+ cursor: pointer;
88
+ }
89
+
90
+ .catname{
91
+ cursor: pointer;
92
+ text-decoration: none;
93
+ color: #2F2F2F;
94
+ }
95
+
96
+ .bk-link{
97
+ clear: both;
98
+ }
99
+
100
+ .expand, .collaps{
101
+ float:right;
102
+ }
103
+ .expand a{background: url("../../images/faq/plus.png") no-repeat left center; padding-left:20px; display:block;}
104
+
105
+ .collaps a{background: url("../../images/faq/minus.png") no-repeat left center; padding-left:20px; display:block;}
106
+
107
+ /*Search Area*/
108
+ .faq #searchform {
109
+ background: url("../../images/faq/faq_search_bar.png") no-repeat scroll left top #F5F5F5;
110
+ height: 21px;
111
+ margin: 30px;
112
+ padding: 10px 10px 10px 30px;
113
+ }
114
+
115
+ .faq #searchform label {
116
+ float: left;
117
+ font-size: 18px;
118
+ font-weight: bold;
119
+ }
120
+
121
+ .faq #searchform #keyword {
122
+ float: left;
123
+ margin-left: 10px;
124
+ }
125
+
126
+
127
+ .faq #searchform .btnSearch {
128
+ background: url("../../images/faq/search.gif") no-repeat scroll left top transparent;
129
+ border: 0 none;
130
+ display: inline;
131
+ float: left;
132
+ height: 25px;
133
+ margin: 0 0 0 5px;
134
+ width: 25px;
135
+ }
136
+
137
+ /*Search Ends*/
skin/frontend/base/default/images/faq/faq_search_bar.png ADDED
Binary file
skin/frontend/base/default/images/faq/minus.png ADDED
Binary file
skin/frontend/base/default/images/faq/plus.png ADDED
Binary file
skin/frontend/base/default/images/faq/search.gif ADDED
Binary file
skin/frontend/base/default/js/faq/faq.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Academic Free License (AFL 3.0)
7
+ * that is bundled with this package in the file LICENSE_AFL.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/afl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
17
+ * versions in the future. If you wish to customize Magento for your
18
+ * needs please refer to http://www.magentocommerce.com for more information.
19
+ *
20
+ * @category design
21
+ * @package base_default
22
+ * @copyright Copyright (c) 2013 Inic
23
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
+ */
25
+ function setAllQuesTr(){
26
+ var parent_detail = $$(".faq-grid-list");
27
+ for(var x=0;x<parent_detail.length;x++)
28
+ {
29
+ var prd_detail = parent_detail[x].getElementsByClassName("faq-question");
30
+ var height=0;
31
+ for(var i=0;i<prd_detail.length;i++){
32
+ if(parseInt(height)<parseInt(prd_detail[i].clientHeight)) {
33
+ height = prd_detail[i].clientHeight;
34
+ }
35
+ }
36
+ for(i=0;i<prd_detail.length;i++){
37
+ if(height!=0){
38
+ prd_detail[i].style.height=height+"px";
39
+ }
40
+ }
41
+ }
42
+ }
43
+ function addLoadEvent(func) {
44
+ var oldonload = window.onload;
45
+ if (typeof window.onload != 'function') {
46
+ window.onload = func;
47
+ } else {
48
+ window.onload = function() {
49
+ if (oldonload) {
50
+ oldonload();
51
+ }
52
+ func();
53
+ }
54
+ }
55
+ }
56
+
57
+ function expand(linkele){
58
+ if(linkele.innerHTML=="Expand All"){
59
+ linkele.innerHTML="Collaps All";
60
+ $('expand-collaps').addClassName("collaps");
61
+ $('expand-collaps').removeClassName("expand");
62
+ }else{
63
+ linkele.innerHTML="Expand All";
64
+ $('expand-collaps').addClassName("expand");
65
+ $('expand-collaps').removeClassName("collaps");
66
+ }
67
+
68
+ $$('.faq-question').each(function(element) {
69
+ element.next().toggle();
70
+ })
71
+ }
72
+ addLoadEvent(setAllQuesTr);