Faqs - Version 1.1.0

Version Notes

Download Latest Version!

Download this release

Release Info

Developer Magento Core Team
Extension Faqs
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

app/code/local/Mage/Faqs/Block/Adminhtml/Faqs.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Faqs_Block_Adminhtml_Faqs extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_faqs';
7
+ $this->_blockGroup = 'faqs';
8
+ $this->_headerText = Mage::helper('faqs')->__('Faqs Management');
9
+ $this->_addButtonLabel = Mage::helper('faqs')->__('Add Faq');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Mage/Faqs/Block/Adminhtml/Faqs/Edit.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Block_Adminhtml_Faqs_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'faqs';
11
+ $this->_controller = 'adminhtml_faqs';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('faqs')->__('Save Faq'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('faqs')->__('Delete Faq'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ <!--function applyFCKEditor() {
24
+ var editable_areas = 'content';
25
+ editable_areas.split(',').each(function(dom_id) {
26
+ if($(dom_id)) {
27
+ var loopCheck = 0;
28
+ while($(dom_id).hasClassName('required-entry') && loopCheck < 10) {
29
+ $(dom_id).removeClassName('required-entry');
30
+ loopCheck += 1;
31
+ }
32
+
33
+ var fck = new FCKeditor(dom_id);
34
+
35
+ fck.Config['CustomConfigurationsPath'] = '".Mage::getBaseUrl('js')."fontis/fckeditor/fontis_custom_config.php';
36
+ fck.Config['SkinPath'] = 'skins/office2003/';
37
+ fck.BasePath = '".Mage::getBaseUrl('js')."fontis/fckeditor/';
38
+ fck.Width = '640';
39
+ fck.Height = '450';
40
+ fck.ToolbarSet = 'Default';
41
+ fck.ReplaceTextarea();
42
+ }
43
+ });
44
+ }
45
+
46
+ if ($('edit_form')) {
47
+ varienGlobalEvents.attachEventHandler('showTab', applyFCKEditor);
48
+ } else {
49
+ applyFCKEditor();
50
+ }-->
51
+
52
+ function saveAndContinueEdit(){
53
+ editForm.submit($('edit_form').action+'back/edit/');
54
+ }
55
+ ";
56
+ }
57
+
58
+ public function getHeaderText()
59
+ {
60
+ if( Mage::registry('faqs_data') && Mage::registry('faqs_data')->getId() ) {
61
+ return Mage::helper('faqs')->__("Edit Faq '%s'", $this->htmlEscape(Mage::registry('faqs_data')->getTitle()));
62
+ } else {
63
+ return Mage::helper('faqs')->__('Add Faq');
64
+ }
65
+ }
66
+ }
app/code/local/Mage/Faqs/Block/Adminhtml/Faqs/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Block_Adminhtml_Faqs_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Mage/Faqs/Block/Adminhtml/Faqs/Edit/Tab/Form.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Block_Adminhtml_Faqs_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('faqs_form', array('legend'=>Mage::helper('faqs')->__('Faq information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('faqs')->__('Question ?'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('status', 'select', array(
19
+ 'label' => Mage::helper('faqs')->__('Status'),
20
+ 'name' => 'status',
21
+ 'values' => array(
22
+ array(
23
+ 'value' => 1,
24
+ 'label' => Mage::helper('faqs')->__('Enabled'),
25
+ ),
26
+
27
+ array(
28
+ 'value' => 0,
29
+ 'label' => Mage::helper('faqs')->__('Disabled'),
30
+ ),
31
+ ),
32
+ ));
33
+
34
+ $fieldset->addField('content', 'editor', array(
35
+ 'name' => 'content',
36
+ 'label' => Mage::helper('faqs')->__('Answar'),
37
+ 'title' => Mage::helper('faqs')->__('Answar'),
38
+ 'style' => 'width:700px; height:500px;',
39
+ 'wysiwyg' => false,
40
+ 'required' => true,
41
+ ));
42
+
43
+ if ( Mage::getSingleton('adminhtml/session')->getFaqsData() )
44
+ {
45
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getFaqsData());
46
+ Mage::getSingleton('adminhtml/session')->setFaqsData(null);
47
+ } elseif ( Mage::registry('faqs_data') ) {
48
+ $form->setValues(Mage::registry('faqs_data')->getData());
49
+ }
50
+ return parent::_prepareForm();
51
+ }
52
+ }
app/code/local/Mage/Faqs/Block/Adminhtml/Faqs/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Block_Adminhtml_Faqs_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('faqs_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('faqs')->__('Faqs Management'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('faqs')->__('Faq Information'),
18
+ 'title' => Mage::helper('faqs')->__('Faq Information'),
19
+ 'content' => $this->getLayout()->createBlock('faqs/adminhtml_faqs_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Mage/Faqs/Block/Adminhtml/Faqs/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Block_Adminhtml_Faqs_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('faqsGrid');
9
+ $this->setDefaultSort('faqs_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('faqs/faqs')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('faqs_id', array(
24
+ 'header' => Mage::helper('faqs')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'faqs_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('faqs')->__('Question'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('faqs')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('faqs')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('faqs')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('faqs')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('faqs')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('faqs')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('faqs_id');
84
+ $this->getMassactionBlock()->setFormFieldName('faqs');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('faqs')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('faqs')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('faqs/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('faqs')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('faqs')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/local/Mage/Faqs/Block/Faqs.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Faqs_Block_Faqs extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getFaqs()
10
+ {
11
+ if (!$this->hasData('faqs')) {
12
+ $this->setData('faqs', Mage::registry('faqs'));
13
+ }
14
+ return $this->getData('faqs');
15
+
16
+ }
17
+ }
app/code/local/Mage/Faqs/Helper/Data.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ const XML_PATH_LIST_PAGE_TITLE = 'faqs/list/page_title';
6
+
7
+ public function getListPageTitle()
8
+ {
9
+ return Mage::getStoreConfig(self::XML_PATH_LIST_PAGE_TITLE);
10
+ }
11
+ }
12
+
13
+ ?>
app/code/local/Mage/Faqs/Model/Faqs.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Model_Faqs extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faqs/faqs');
9
+ }
10
+ }
app/code/local/Mage/Faqs/Model/Mysql4/Faqs.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Model_Mysql4_Faqs extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the faqs_id refers to the key field in your database table.
8
+ $this->_init('faqs/faqs', 'faqs_id');
9
+ }
10
+ }
app/code/local/Mage/Faqs/Model/Mysql4/Faqs/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Model_Mysql4_Faqs_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('faqs/faqs');
9
+ }
10
+ }
app/code/local/Mage/Faqs/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('faqs')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('faqs')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Mage/Faqs/controllers/Adminhtml/FaqsController.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Faqs_Adminhtml_FaqsController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('faqs/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Faqs Management'), Mage::helper('adminhtml')->__('Faqs Management'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('faqs/faqs')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('faqs_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('faqs/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Faqs Manager'), Mage::helper('adminhtml')->__('Faqs Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Faqs Manager'), Mage::helper('adminhtml')->__('Faqs Manager'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('faqs/adminhtml_faqs_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('faqs/adminhtml_faqs_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faqs')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+ if ($data = $this->getRequest()->getPost()) {
55
+
56
+ $model = Mage::getModel('faqs/faqs');
57
+ $model->setData($data)
58
+ ->setId($this->getRequest()->getParam('id'));
59
+
60
+ try {
61
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
62
+ $model->setCreatedTime(now())
63
+ ->setUpdateTime(now());
64
+ } else {
65
+ $model->setUpdateTime(now());
66
+ }
67
+
68
+ $model->save();
69
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('faqs')->__('Item was successfully saved'));
70
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
71
+
72
+ if ($this->getRequest()->getParam('back')) {
73
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
74
+ return;
75
+ }
76
+ $this->_redirect('*/*/');
77
+ return;
78
+ } catch (Exception $e) {
79
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
80
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
81
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
82
+ return;
83
+ }
84
+ }
85
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('faqs')->__('Unable to find item to save'));
86
+ $this->_redirect('*/*/');
87
+ }
88
+
89
+ public function deleteAction() {
90
+ if( $this->getRequest()->getParam('id') > 0 ) {
91
+ try {
92
+ $model = Mage::getModel('faqs/faqs');
93
+
94
+ $model->setId($this->getRequest()->getParam('id'))
95
+ ->delete();
96
+
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
98
+ $this->_redirect('*/*/');
99
+ } catch (Exception $e) {
100
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
101
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
102
+ }
103
+ }
104
+ $this->_redirect('*/*/');
105
+ }
106
+
107
+ public function massDeleteAction() {
108
+ $faqsIds = $this->getRequest()->getParam('faqs');
109
+ if(!is_array($faqsIds)) {
110
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
111
+ } else {
112
+ try {
113
+ foreach ($faqsIds as $faqsId) {
114
+ $faqs = Mage::getModel('faqs/faqs')->load($faqsId);
115
+ $faqs->delete();
116
+ }
117
+ Mage::getSingleton('adminhtml/session')->addSuccess(
118
+ Mage::helper('adminhtml')->__(
119
+ 'Total of %d record(s) were successfully deleted', count($faqsIds)
120
+ )
121
+ );
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ }
125
+ }
126
+ $this->_redirect('*/*/index');
127
+ }
128
+
129
+ public function massStatusAction()
130
+ {
131
+ $faqsIds = $this->getRequest()->getParam('faqs');
132
+ if(!is_array($faqsIds)) {
133
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
134
+ } else {
135
+ try {
136
+ foreach ($faqsIds as $faqsId) {
137
+ $faqs = Mage::getSingleton('faqs/faqs')
138
+ ->load($faqsId)
139
+ ->setStatus($this->getRequest()->getParam('status'))
140
+ ->setIsMassupdate(true)
141
+ ->save();
142
+ }
143
+ $this->_getSession()->addSuccess(
144
+ $this->__('Total of %d record(s) were successfully updated', count($faqsIds))
145
+ );
146
+ } catch (Exception $e) {
147
+ $this->_getSession()->addError($e->getMessage());
148
+ }
149
+ }
150
+ $this->_redirect('*/*/index');
151
+ }
152
+
153
+ public function exportCsvAction()
154
+ {
155
+ $fileName = 'faqs.csv';
156
+ $content = $this->getLayout()->createBlock('faqs/adminhtml_faqs_grid')
157
+ ->getCsv();
158
+
159
+ $this->_sendUploadResponse($fileName, $content);
160
+ }
161
+
162
+ public function exportXmlAction()
163
+ {
164
+ $fileName = 'faqs.xml';
165
+ $content = $this->getLayout()->createBlock('faqs/adminhtml_faqs_grid')
166
+ ->getXml();
167
+
168
+ $this->_sendUploadResponse($fileName, $content);
169
+ }
170
+
171
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
172
+ {
173
+ $response = $this->getResponse();
174
+ $response->setHeader('HTTP/1.1 200 OK','');
175
+ $response->setHeader('Pragma', 'public', true);
176
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
177
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
178
+ $response->setHeader('Last-Modified', date('r'));
179
+ $response->setHeader('Accept-Ranges', 'bytes');
180
+ $response->setHeader('Content-Length', strlen($content));
181
+ $response->setHeader('Content-type', $contentType);
182
+ $response->setBody($content);
183
+ $response->sendResponse();
184
+ die;
185
+ }
186
+ }
app/code/local/Mage/Faqs/controllers/IndexController.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Faqs_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+
10
+ }
11
+ }
app/code/local/Mage/Faqs/etc/config.xml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Mage
5
+ * @package Mage_Faqs
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Mage_Faqs>
13
+ <version>0.1.0</version>
14
+ </Mage_Faqs>
15
+ </modules>
16
+ <frontend>
17
+ <routers>
18
+ <faqs>
19
+ <use>standard</use>
20
+ <args>
21
+ <module>Mage_Faqs</module>
22
+ <frontName>faqs</frontName>
23
+ </args>
24
+ </faqs>
25
+ </routers>
26
+ <layout>
27
+ <updates>
28
+ <faqs>
29
+ <file>faqs.xml</file>
30
+ </faqs>
31
+ </updates>
32
+ </layout>
33
+ </frontend>
34
+ <admin>
35
+ <routers>
36
+ <faqs>
37
+ <use>admin</use>
38
+ <args>
39
+ <module>Mage_Faqs</module>
40
+ <frontName>faqs</frontName>
41
+ </args>
42
+ </faqs>
43
+ </routers>
44
+ </admin>
45
+ <adminhtml>
46
+ <menu>
47
+ <cms>
48
+ <children>
49
+ <Mage_Faqs>
50
+ <title>Faq's Management</title>
51
+ <action>faqs/adminhtml_faqs</action>
52
+ </Mage_Faqs>
53
+ </children>
54
+ </cms>
55
+ </menu>
56
+
57
+ <layout>
58
+ <updates>
59
+ <faqs>
60
+ <file>faqs.xml</file>
61
+ </faqs>
62
+ </updates>
63
+ </layout>
64
+ </adminhtml>
65
+ <global>
66
+ <models>
67
+ <faqs>
68
+ <class>Mage_Faqs_Model</class>
69
+ <resourceModel>faqs_mysql4</resourceModel>
70
+ </faqs>
71
+ <faqs_mysql4>
72
+ <class>Mage_Faqs_Model_Mysql4</class>
73
+ <entities>
74
+ <faqs>
75
+ <table>faqs</table>
76
+ </faqs>
77
+ </entities>
78
+ </faqs_mysql4>
79
+ </models>
80
+ <resources>
81
+ <faqs_setup>
82
+ <setup>
83
+ <module>Mage_Faqs</module>
84
+ </setup>
85
+ <connection>
86
+ <use>core_setup</use>
87
+ </connection>
88
+ </faqs_setup>
89
+ <faqs_write>
90
+ <connection>
91
+ <use>core_write</use>
92
+ </connection>
93
+ </faqs_write>
94
+ <faqs_read>
95
+ <connection>
96
+ <use>core_read</use>
97
+ </connection>
98
+ </faqs_read>
99
+ </resources>
100
+ <blocks>
101
+ <faqs>
102
+ <class>Mage_Faqs_Block</class>
103
+ </faqs>
104
+ </blocks>
105
+ <helpers>
106
+ <faqs>
107
+ <class>Mage_Faqs_Helper</class>
108
+ </faqs>
109
+ </helpers>
110
+ </global>
111
+ </config>
app/code/local/Mage/Faqs/sql/faqs_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('faqs')};
10
+ CREATE TABLE {$this->getTable('faqs')} (
11
+ `faqs_id` int(11) unsigned NOT NULL auto_increment,
12
+ `title` varchar(255) NOT NULL default '',
13
+ `filename` varchar(255) NOT NULL default '',
14
+ `content` text NOT NULL default '',
15
+ `status` smallint(6) NOT NULL default '0',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`faqs_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/faqs.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <faqs_adminhtml_faqs_index>
4
+ <reference name="content">
5
+ <block type="faqs/adminhtml_faqs" name="faqs" />
6
+ </reference>
7
+ </faqs_adminhtml_faqs_index>
8
+ </layout>
app/design/frontend/default/default/layout/faqs.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <!--
5
+ <reference name="right">
6
+ <block type="snews/block" name="snews.block" as="newsBlock" template="scalena/news/block.phtml"/>
7
+ </reference>
8
+ -->
9
+ </default>
10
+ <faqs_index_index>
11
+
12
+ <reference name="head">
13
+ <action method="addItem"><type>js</type><name>jquery/accordian.pack.js</name></action>
14
+ <action method="addCss"><stylesheet>css/accordian.css</stylesheet></action>
15
+ </reference>
16
+
17
+
18
+ <reference name="root">
19
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
20
+ </reference>
21
+ <reference name="content">
22
+ <block type="faqs/faqs" name="faqs" template="faqs/faqs.phtml" />
23
+ </reference>
24
+ <reference name="head">
25
+ <action method="setTitle"><title>FAQ's</title></action>
26
+ </reference>
27
+ </faqs_index_index>
28
+ </layout>
app/design/frontend/default/default/template/faqs/faqs.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This fle is used to Display Faqs on front end!
4
+ Created by Kamran Rafiq Malik
5
+ Dated : March 20,2010
6
+ */
7
+ ?>
8
+
9
+ <?php
10
+
11
+ $resource = Mage::getSingleton('core/resource');
12
+ $read= $resource->getConnection('core_read');
13
+ $faqsTable = $resource->getTableName('faqs');
14
+
15
+ $select = $read->select()
16
+ ->from($faqsTable,array('faqs_id','title','content','status'))
17
+ ->where('status',1)
18
+ ->order('created_time DESC') ;
19
+ $faqs = $read->fetchAll($select);
20
+
21
+
22
+ ?>
23
+ <?php $j = 160;?>
24
+ <br />
25
+ <div id="basic-accordian">
26
+ <?php $i=0; foreach ($faqs as $_faqs): ?>
27
+ <div id="testcat_<?php echo $j ?>-header" class="accordion_headings"><?php echo $_faqs["title"]; ?></div>
28
+ <div id="testcat_<?php echo $j ?>-content">
29
+ <div class="accordion_child">
30
+ <div id="CatDIV_<?php echo $j ?>">
31
+ <?php echo $_faqs["content"]; ?>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <?php $j++;?>
36
+ <?php endforeach; ?>
37
+ </div>
38
+ <script type="text/javascript">
39
+ window.onload = function(){ new Accordian('basic-accordian',5,'header_highlight'); };
40
+ </script>
app/etc/modules/Mage_Faqs.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Mage
5
+ * @package Mage_Faqs
6
+ * @author ModuleCreator
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Mage_Faqs>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </Mage_Faqs>
16
+ </modules>
17
+ </config>
js/jquery/accordian.pack.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ //by dezinerfolio.com
2
+ eval((function(){a=" {3document5ByIdOgvv=8E!&&E!K32}o=E;E;v=parseInt(2E=o;3vdheight=vHpx}Oofvgvv=v/d.h;dDv;dfilterKalpha(D+v*100H)Obz>0z#-1:z-v90E;%eE;z<x(x-z)#+1:v+z9x%Accordians,fl=5sByTagName(diva=[]d=S;QQ,Q)=={a.push}}xL((hc=h0,hc6==hcMc+;c;coverflowKhidden;c.h=g(cc.s=(s=8)?7:s;h.f=f;h.c=a;h.match4fHH))x=h}hC=(Rj=0;j<F.c;j++n=F.c[j];n=n0,ndMn6nMn+;s=dJt4sH)Rp=0;p<s;p++s[p]=KGsJce(p,1d=s.join( break}}clearn.tQ==FPg(n,0@ed+K GP@b}}}}})(S)}x!LxC()}}",b=49;while(b>=0)a=a.replace(new RegExp("#%2345689@CDEFGHJKLMOPQRS".charAt(b),"g"),("\\\042\044.style.displayfunctionInterval(.className.length.indexOf(-)(d)if(-content).id){.style.=none{d=;z=g;x=d.h;(d,;for(i=0;i<l;i++);}else{('+n+')',9)}.substr(=blockv=Math.round(/d.sv=(v<1)?zcleard.t)}} d.offsetHeightreturn (new RegExp(.getElement+-header=undefined;ofv)gn.t=set'.onclickopacity=dthis+d.f+.spli==null=(} n=dfor(l[i]".split(""))[b--]);return a})())
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Faqs</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>FAQ is a Magento useful extension used to manage FAQ (Frequently Asked Question).</summary>
10
+ <description>FAQ is a Magento useful extension used to manage FAQ (Frequently Asked Question).</description>
11
+ <notes>Download Latest Version!</notes>
12
+ <authors><author><name>Kamran Rafiq Malik</name><user>auto-converted</user><email>kamran.malik@unitedsol.net</email></author></authors>
13
+ <date>2010-04-21</date>
14
+ <time>12:16:03</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="faqs.xml" hash="cdf98802c33b040866e96e702aece174"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="faqs.xml" hash="4f7a67defa2c2c2beae8a96b69df770e"/></dir><dir name="template"><dir name="faqs"><file name="faqs.phtml" hash="88f71a4a83e200d62bafb910ea526f9d"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="accordian.css" hash="ca1e80b8b1aadb4eda09b64e29980eff"/></dir><dir name="images"><file name="accordion_a.gif" hash="e7ee541a6cf2923c690276eb88ca2b1e"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="jquery"><file name="accordian.pack.js" hash="33ce5a3782f151f232f0e2f1ab165e37"/></dir></dir></target><target name="magelocal"><dir name="Mage"><dir name="Faqs"><dir name="Block"><dir name="Adminhtml"><dir name="Faqs"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="1ae5b5a24644b39a3fb6ea88ff28d7e7"/></dir><file name="Form.php" hash="15425ffc154f9989da09fe53d409b175"/><file name="Tabs.php" hash="5cca8d26a49f3c18831c030457a6795c"/></dir><file name="Edit.php" hash="f17bea01ab862942db7bae28ca76dae7"/><file name="Grid.php" hash="fe85f4378b95b398f998cfa65fb7db51"/></dir><file name="Faqs.php" hash="db8a6d6f4eed62e5b8b71aca68ddd432"/></dir><file name="Faqs.php" hash="35b941414f09d0fa2c4844bd2cdd2e24"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FaqsController.php" hash="125a527726990f7392370e4bf388a302"/></dir><file name="IndexController.php" hash="d3003aa4d129eba0670c6e5b81059179"/></dir><dir name="etc"><file name="config.xml" hash="73ef21938fbb72328725d791c32a1cd0"/></dir><dir name="Helper"><file name="Data.php" hash="0888b7b9235e4dca060d65e5aa714788"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Faqs"><file name="Collection.php" hash="5ba072f98eeb5d3c7f20087e31706e0b"/></dir><file name="Faqs.php" hash="acca5c06cffa764d49aef1d099b253e6"/></dir><file name="Faqs.php" hash="55267216790b25fa0c2ba895d0a51658"/><file name="Status.php" hash="a16d8e04937a755243ecfe51191c9d46"/></dir><dir name="sql"><dir name="faqs_setup"><file name="mysql4-install-0.1.0.php" hash="ae1a34e1ff4325e75da7b20d5ac6dede"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Faqs.xml" hash="a5827bdf5efdca314c85e200f4af3fe4"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/frontend/default/default/css/accordian.css ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "utf-8";
2
+ /* CSS Document */
3
+ #basic-accordian{
4
+ font-family: Arial, Helvetica, sans-serif;
5
+ font-size: 11px;
6
+ width:607px;
7
+ position:relative;
8
+ z-index:2;
9
+ }
10
+
11
+ .accordion_headings{
12
+ padding:5px 5px 5px 25px;
13
+ background: url(../images/accordion_a.gif) no-repeat;
14
+ color:#fff;
15
+ border:1px solid #fff;
16
+ cursor:pointer;
17
+ font-weight:bold;
18
+ }
19
+ .accordion_headings:hover{
20
+ background-position: left -25px;
21
+ }
22
+
23
+ #basic-accordian .header_highlight{
24
+ color: #222;
25
+ background-position: left -50px;
26
+ cursor: text;
27
+ }
28
+ .accordion_child{
29
+ padding:15px;
30
+ }
skin/frontend/default/default/images/accordion_a.gif ADDED
Binary file