Flagbit_Faq - Version 1.1.2

Version Notes

* Initial Release

Download this release

Release Info

Developer Magento Core Team
Extension Flagbit_Faq
Version 1.1.2
Comparing to
See all releases


Code changes from version 1.0.6 to 1.1.2

Files changed (40) hide show
  1. app/code/community/Flagbit/Faq/Block/Admin/Edit.php +0 -64
  2. app/code/community/Flagbit/Faq/Block/Admin/Edit/Form.php +0 -36
  3. app/code/community/Flagbit/Faq/Block/Admin/Edit/Tab/Main.php +0 -115
  4. app/code/community/Flagbit/Faq/Block/Admin/Edit/Tabs.php +0 -51
  5. app/code/community/Flagbit/Faq/Block/Admin/List.php +0 -45
  6. app/code/community/Flagbit/Faq/Block/Admin/List/Grid.php +0 -163
  7. app/code/community/Flagbit/Faq/Block/Adminhtml/Category.php +45 -0
  8. app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Edit.php +78 -0
  9. app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Edit/Form.php +35 -0
  10. app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Edit/Tab/Main.php +82 -0
  11. app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Edit/Tabs.php +54 -0
  12. app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Grid.php +167 -0
  13. app/code/community/Flagbit/Faq/Block/Adminhtml/Item.php +45 -0
  14. app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Edit.php +79 -0
  15. app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Edit/Form.php +35 -0
  16. app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Edit/Tab/Main.php +125 -0
  17. app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Edit/Tabs.php +54 -0
  18. app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Grid.php +155 -0
  19. app/code/community/Flagbit/Faq/Block/Frontend/Detail.php +1 -1
  20. app/code/community/Flagbit/Faq/Block/Frontend/List.php +40 -14
  21. app/code/community/Flagbit/Faq/Helper/Data.php +11 -12
  22. app/code/community/Flagbit/Faq/Model/Category.php +42 -0
  23. app/code/community/Flagbit/Faq/Model/Faq.php +10 -13
  24. app/code/community/Flagbit/Faq/Model/Mysql4/Category.php +107 -0
  25. app/code/community/Flagbit/Faq/Model/Mysql4/Category/Collection.php +109 -0
  26. app/code/community/Flagbit/Faq/Model/Mysql4/Faq.php +40 -22
  27. app/code/community/Flagbit/Faq/Model/Mysql4/Faq/Collection.php +117 -96
  28. app/code/community/Flagbit/Faq/controllers/Adminhtml/Faq/CategoryController.php +193 -0
  29. app/code/community/Flagbit/Faq/controllers/{AdminController.php → Adminhtml/FaqController.php} +41 -53
  30. app/code/community/Flagbit/Faq/controllers/IndexController.php +6 -9
  31. app/code/community/Flagbit/Faq/etc/adminhtml.xml +12 -3
  32. app/code/community/Flagbit/Faq/etc/config.xml +28 -26
  33. app/code/community/Flagbit/Faq/sql/faq_setup/mysql4-install-0.1.0.php +5 -7
  34. app/code/community/Flagbit/Faq/sql/faq_setup/mysql4-install-1.0.7.php +67 -0
  35. app/code/community/Flagbit/Faq/sql/faq_setup/mysql4-upgrade-1.0.6-1.0.7.php +52 -0
  36. app/design/frontend/base/default/layout/faq.xml +2 -10
  37. app/design/frontend/base/default/template/faq/list.phtml +26 -8
  38. app/locale/de_DE/Flagbit_Faq.csv +18 -1
  39. app/locale/nl_NL/Flagbit_Faq.csv +56 -0
  40. package.xml +5 -5
app/code/community/Flagbit/Faq/Block/Admin/Edit.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- /**
3
- * FAQ for Magento
4
- *
5
- * @category Flagbit
6
- * @package Flagbit_Faq
7
- * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
- */
9
-
10
- /**
11
- * FAQ for Magento
12
- *
13
- * @category Flagbit
14
- * @package Flagbit_Faq
15
- * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
- */
17
- class Flagbit_Faq_Block_Admin_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->_controller = 'admin';
27
- $this->_blockGroup = 'faq';
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
- return $this->getUrl('*/faq/save');
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Flagbit/Faq/Block/Admin/Edit/Form.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * FAQ for Magento
4
- *
5
- * @category Flagbit
6
- * @package Flagbit_Faq
7
- * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
- */
9
-
10
- /**
11
- * FAQ for Magento
12
- *
13
- * @category Flagbit
14
- * @package Flagbit_Faq
15
- * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
- */
17
- class Flagbit_Faq_Block_Admin_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
18
-
19
- /**
20
- * Preperation of current form
21
- *
22
- * @return Flagbit_Faq_Block_Admin_Edit_Form Self
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
-
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Flagbit/Faq/Block/Admin/Edit/Tab/Main.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
- /**
3
- * FAQ for Magento
4
- *
5
- * @category Flagbit
6
- * @package Flagbit_Faq
7
- * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
- */
9
-
10
- /**
11
- * FAQ for Magento
12
- *
13
- * @category Flagbit
14
- * @package Flagbit_Faq
15
- * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
- */
17
- class Flagbit_Faq_Block_Admin_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form {
18
-
19
-
20
- /**
21
- * Prepares the page layout
22
- *
23
- * Loads the WYSIWYG editor on demand if enabled.
24
- *
25
- * @return Flagbit_Faq_Block_Admin_Edit
26
- */
27
- protected function _prepareLayout() {
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 Flagbit_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')->__('Page 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('answer', 'editor',
92
- array (
93
- 'name' => 'answer',
94
- 'label' => Mage :: helper('faq')->__('Content'),
95
- 'title' => Mage :: helper('faq')->__('Content'),
96
- 'style' => 'height:36em;',
97
- 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
98
- 'required' => true ));
99
-
100
- $fieldset->addField('answer_html', 'select',
101
- array (
102
- 'label' => Mage :: helper('faq')->__('HTML answer'),
103
- 'title' => Mage :: helper('faq')->__('HTML answer'),
104
- 'name' => 'answer_html',
105
- 'required' => true,
106
- 'options' => array (
107
- '1' => Mage :: helper('faq')->__('Enabled'),
108
- '0' => Mage :: helper('faq')->__('Disabled') ) ));
109
-
110
- $form->setValues($model->getData());
111
- $this->setForm($form);
112
-
113
- return parent :: _prepareForm();
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Flagbit/Faq/Block/Admin/Edit/Tabs.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
- /**
3
- * FAQ for Magento
4
- *
5
- * @category Flagbit
6
- * @package Flagbit_Faq
7
- * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
- */
9
-
10
- /**
11
- * FAQ for Magento
12
- *
13
- * @category Flagbit
14
- * @package Flagbit_Faq
15
- * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
- */
17
- class Flagbit_Faq_Block_Admin_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('qaq_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 Flagbit_Faq_Block_Admin_Edit
37
- */
38
- protected function _prepareLayout()
39
- {
40
- $return = parent::_prepareLayout();
41
-
42
- $this->addTab('main_section',
43
- array (
44
- 'label' => Mage :: helper('faq')->__('General information'),
45
- 'title' => Mage :: helper('faq')->__('General information'),
46
- 'content' => $this->getLayout()->createBlock('faq/admin_edit_tab_main')->toHtml(),
47
- 'active' => true ));
48
-
49
- return $return;
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Flagbit/Faq/Block/Admin/List.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * FAQ for Magento
4
- *
5
- * @category Flagbit
6
- * @package Flagbit_Faq
7
- * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
- */
9
-
10
- /**
11
- * FAQ for Magento
12
- *
13
- * @category Flagbit
14
- * @package Flagbit_Faq
15
- * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
- */
17
-
18
- class Flagbit_Faq_Block_Admin_List extends Mage_Adminhtml_Block_Widget_Grid_Container {
19
-
20
- /**
21
- * Constructor for FAQ Admin Block
22
- *
23
- */
24
- public function __construct() {
25
-
26
- $this->_controller = 'admin_list';
27
- $this->_blockGroup = 'faq';
28
- $this->_headerText = Mage :: helper('faq')->__('FAQ');
29
- $this->_addButtonLabel = Mage :: helper('sales')->__('Add new FAQ item');
30
-
31
- parent :: __construct();
32
-
33
- }
34
-
35
-
36
- /**
37
- * Standard grid function for new elements
38
- *
39
- * @return string URL to add element page
40
- */
41
- public function getCreateUrl() {
42
-
43
- return $this->getUrl('adminhtml/faq/new');
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Flagbit/Faq/Block/Admin/List/Grid.php DELETED
@@ -1,163 +0,0 @@
1
- <?php
2
- /**
3
- * FAQ for Magento
4
- *
5
- * @category Flagbit
6
- * @package Flagbit_Faq
7
- * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
- */
9
-
10
- /**
11
- * FAQ for Magento
12
- *
13
- * @category Flagbit
14
- * @package Flagbit_Faq
15
- * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
- */
17
- class Flagbit_Faq_Block_Admin_List_Grid extends Mage_Adminhtml_Block_Widget_Grid {
18
-
19
-
20
- /**
21
- * Constructor of Grid
22
- *
23
- */
24
- public function __construct() {
25
-
26
- parent :: __construct();
27
- $this->setId('faq_grid');
28
- $this->setUseAjax(false);
29
- $this->setDefaultSort('creation_time');
30
- $this->setDefaultDir('DESC');
31
- $this->setSaveParametersInSession(true);
32
- }
33
-
34
-
35
- /**
36
- * Preparation of the data that is displayed by the grid.
37
- *
38
- * @return Flagbit_Faq_Block_Admin_Grid Self
39
- */
40
- protected function _prepareCollection() {
41
-
42
- //TODO: add full name logic
43
- $collection = Mage :: getResourceModel('faq/faq_collection');
44
- $this->setCollection($collection);
45
- #Mage::Log($collection->getData());
46
- return parent :: _prepareCollection();
47
- }
48
-
49
-
50
- /**
51
- * Preparation of the requested columns of the grid
52
- *
53
- * @return Flagbit_Faq_Block_Admin_Grid Self
54
- */
55
- protected function _prepareColumns() {
56
-
57
- $this->addColumn('faq_id', array (
58
- 'header' => Mage :: helper('faq')->__('FAQ #'),
59
- 'width' => '80px',
60
- 'type' => 'text',
61
- 'index' => 'faq_id' ));
62
-
63
- if (!Mage :: app()->isSingleStoreMode()) {
64
- $this->addColumn('store_id',
65
- array (
66
- 'header' => Mage :: helper('cms')->__('Store view'),
67
- 'index' => 'store_id',
68
- 'type' => 'store',
69
- 'store_all' => true,
70
- 'store_view' => true,
71
- 'sortable' => false,
72
- 'filter_condition_callback' => array (
73
- $this,
74
- '_filterStoreCondition' ) ));
75
- }
76
-
77
- $this->addColumn('question', array (
78
- 'header' => Mage :: helper('faq')->__('Question'),
79
- 'index' => 'question' ));
80
-
81
- $this->addColumn('is_active',
82
- array (
83
- 'header' => Mage :: helper('faq')->__('Active'),
84
- 'index' => 'is_active',
85
- 'type' => 'options',
86
- 'width' => '70px',
87
- 'options' => array (
88
- 0 => Mage :: helper('faq')->__('No'),
89
- 1 => Mage :: helper('faq')->__('Yes') ) ));
90
-
91
- $this->addColumn('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' => 'adminhtml/faq/edit' ),
102
- 'field' => 'faq_id' ) ),
103
- 'filter' => false,
104
- 'sortable' => false,
105
- 'index' => 'stores',
106
- 'is_system' => true ));
107
-
108
- return parent :: _prepareColumns();
109
- }
110
-
111
-
112
- /**
113
- * Helper function to do after load modifications
114
- *
115
- */
116
- protected function _afterLoadCollection() {
117
-
118
- $this->getCollection()->walk('afterLoad');
119
- parent :: _afterLoadCollection();
120
- }
121
-
122
-
123
- /**
124
- * Helper function to add store filter condition
125
- *
126
- * @param Mage_Core_Model_Mysql4_Collection_Abstract $collection Data collection
127
- * @param Mage_Adminhtml_Block_Widget_Grid_Column $column Column information to be filtered
128
- */
129
- protected function _filterStoreCondition($collection, $column) {
130
-
131
- if (!$value = $column->getFilter()->getValue()) {
132
- return;
133
- }
134
-
135
- $this->getCollection()->addStoreFilter($value);
136
- }
137
-
138
-
139
- /**
140
- * Helper function to reveive on row click url
141
- *
142
- * @param Flagbit_Faq_Model_Faq $row Current rows dataset
143
- * @return string URL for current row's onclick event
144
- */
145
- public function getRowUrl($row) {
146
-
147
- return $this->getUrl('adminhtml/faq/edit', array (
148
- 'faq_id' => $row->getFaqId() ));
149
- }
150
-
151
-
152
- /**
153
- * Helper function to receive grid functionality urls for current grid
154
- *
155
- * @return string Requested URL
156
- */
157
- public function getGridUrl() {
158
-
159
- return $this->getUrl('adminhtml/faq/index', array (
160
- '_current' => true ));
161
- }
162
-
163
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Flagbit/Faq/Block/Adminhtml/Category.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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 = 'flagbit_faq';
25
+ $this->_controller = 'adminhtml_category';
26
+ $this->_headerText = Mage::helper('flagbit_faq')->__('Manage FAQ Categories');
27
+ $this->_addButtonLabel = Mage::helper('flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Category/Edit.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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 = 'flagbit_faq';
26
+ $this->_controller = 'adminhtml_category';
27
+
28
+ parent::__construct();
29
+
30
+ $this->_updateButton('save', 'label', Mage::helper('flagbit_faq')->__('Save FAQ Category'));
31
+ $this->_updateButton('delete', 'label', Mage::helper('flagbit_faq')->__('Delete FAQ Category'));
32
+
33
+ $this->_addButton('saveandcontinue', array (
34
+ 'label' => Mage::helper('flagbit_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('flagbit_faq')->__("Edit FAQ Category '%s'", $this->htmlEscape(Mage::registry('faq_category')->getCategoryName()));
54
+ }
55
+ else {
56
+ return Mage::helper('flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Category/Edit/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_Faq_Block_Adminhtml_Category_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Preperation of current form
21
+ *
22
+ * @return Flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Category/Edit/Tab/Main.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_Faq_Block_Adminhtml_Category_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Preparation of current form
21
+ *
22
+ * @return Flagbit_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('flagbit_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
+ $fieldset->addField('category_name', 'text', array (
42
+ 'name' => 'category_name',
43
+ 'label' => Mage::helper('flagbit_faq')->__('Category Name'),
44
+ 'title' => Mage::helper('flagbit_faq')->__('Category Name'),
45
+ 'required' => true,
46
+ ));
47
+
48
+ /**
49
+ * Check is single store mode
50
+ */
51
+ if (!Mage::app()->isSingleStoreMode()) {
52
+ $fieldset->addField('store_id', 'multiselect',
53
+ array (
54
+ 'name' => 'stores[]',
55
+ 'label' => Mage::helper('cms')->__('Store view'),
56
+ 'title' => Mage::helper('cms')->__('Store view'),
57
+ 'required' => true,
58
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ));
59
+ }
60
+ else {
61
+ $fieldset->addField('store_id', 'hidden', array (
62
+ 'name' => 'stores[]',
63
+ 'value' => Mage::app()->getStore(true)->getId() ));
64
+ $model->setStoreId(Mage::app()->getStore(true)->getId());
65
+ }
66
+
67
+ $fieldset->addField('is_active', 'select',
68
+ array (
69
+ 'label' => Mage::helper('cms')->__('Status'),
70
+ 'title' => Mage::helper('flagbit_faq')->__('Category Status'),
71
+ 'name' => 'is_active',
72
+ 'required' => true,
73
+ 'options' => array (
74
+ '1' => Mage::helper('cms')->__('Enabled'),
75
+ '0' => Mage::helper('cms')->__('Disabled') ) ));
76
+
77
+ $form->setValues($model->getData());
78
+ $this->setForm($form);
79
+
80
+ return parent::_prepareForm();
81
+ }
82
+ }
app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Edit/Tabs.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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('flagbit_faq')->__('Category Information'));
29
+ }
30
+
31
+ /**
32
+ * Prepares the page layout
33
+ *
34
+ * Adds the tabs to the left tab menu.
35
+ *
36
+ * @return Flagbit_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('flagbit_faq')->__('General information'),
46
+ 'title' => Mage::helper('flagbit_faq')->__('General information'),
47
+ 'content' => $this->getLayout()->createBlock('flagbit_faq/adminhtml_category_edit_tab_main')->toHtml(),
48
+ 'active' => true,
49
+ )
50
+ );
51
+
52
+ return $return;
53
+ }
54
+ }
app/code/community/Flagbit/Faq/Block/Adminhtml/Category/Grid.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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 Flagbit_Faq_Block_Admin_Grid Self
37
+ */
38
+ protected function _prepareCollection()
39
+ {
40
+ $collection = Mage::getResourceModel('flagbit_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 Flagbit_Faq_Block_Admin_Grid Self
49
+ */
50
+ protected function _prepareColumns()
51
+ {
52
+ $this->addColumn('category_id', array (
53
+ 'header' => Mage::helper('flagbit_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('cms')->__('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('flagbit_faq')->__('Category Name'),
76
+ 'index' => 'category_name',
77
+ )
78
+ );
79
+
80
+ $this->addColumn('is_active',
81
+ array (
82
+ 'header' => Mage::helper('cms')->__('Active'),
83
+ 'index' => 'is_active',
84
+ 'type' => 'options',
85
+ 'width' => '70px',
86
+ 'options' => array (
87
+ 0 => Mage::helper('cms')->__('No'),
88
+ 1 => Mage::helper('cms')->__('Yes') ) ));
89
+
90
+ $this->addColumn(
91
+ 'action',
92
+ array (
93
+ 'header' => Mage::helper('flagbit_faq')->__('Action'),
94
+ 'width' => '50px',
95
+ 'type' => 'action',
96
+ 'getter' => 'getId',
97
+ 'actions' => array (
98
+ array (
99
+ 'caption' => Mage::helper('flagbit_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 Flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Item.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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 = 'flagbit_faq';
25
+ $this->_controller = 'adminhtml_item';
26
+ $this->_headerText = Mage::helper('flagbit_faq')->__('Manage FAQ Items');
27
+ $this->_addButtonLabel = Mage::helper('flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Item/Edit.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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 = 'flagbit_faq';
27
+ $this->_controller = 'adminhtml_item';
28
+
29
+ parent::__construct();
30
+
31
+ $this->_updateButton('save', 'label', Mage::helper('flagbit_faq')->__('Save FAQ item'));
32
+ $this->_updateButton('delete', 'label', Mage::helper('flagbit_faq')->__('Delete FAQ item'));
33
+
34
+ $this->_addButton('saveandcontinue', array (
35
+ 'label' => Mage::helper('flagbit_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('flagbit_faq')->__("Edit FAQ item '%s'", $this->htmlEscape(Mage::registry('faq')->getQuestion()));
55
+ }
56
+ else {
57
+ return Mage::helper('flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Item/Edit/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_Faq_Block_Adminhtml_Item_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
18
+ {
19
+ /**
20
+ * Preperation of current form
21
+ *
22
+ * @return Flagbit_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/community/Flagbit/Faq/Block/Adminhtml/Item/Edit/Tab/Main.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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 Flagbit_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 Flagbit_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('flagbit_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('flagbit_faq')->__('FAQ item question'),
59
+ 'title' => Mage::helper('flagbit_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('cms')->__('Store view'),
70
+ 'title' => Mage::helper('cms')->__('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('cms')->__('Status'),
84
+ 'title' => Mage::helper('flagbit_faq')->__('Item status'),
85
+ 'name' => 'is_active',
86
+ 'required' => true,
87
+ 'options' => array (
88
+ '1' => Mage::helper('cms')->__('Enabled'),
89
+ '0' => Mage::helper('cms')->__('Disabled') ) ));
90
+
91
+ $fieldset->addField('category_id', 'multiselect',
92
+ array (
93
+ 'label' => Mage::helper('flagbit_faq')->__('Category'),
94
+ 'title' => Mage::helper('flagbit_faq')->__('Category'),
95
+ 'name' => 'categories[]',
96
+ 'required' => false,
97
+ 'values' => Mage::getResourceSingleton('flagbit_faq/category_collection')->toOptionArray(),
98
+ )
99
+ );
100
+
101
+ $fieldset->addField('answer', 'editor',
102
+ array (
103
+ 'name' => 'answer',
104
+ 'label' => Mage::helper('flagbit_faq')->__('Content'),
105
+ 'title' => Mage::helper('flagbit_faq')->__('Content'),
106
+ 'style' => 'height:36em;',
107
+ 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
108
+ 'required' => true ));
109
+
110
+ $fieldset->addField('answer_html', 'select',
111
+ array (
112
+ 'label' => Mage::helper('flagbit_faq')->__('HTML answer'),
113
+ 'title' => Mage::helper('flagbit_faq')->__('HTML answer'),
114
+ 'name' => 'answer_html',
115
+ 'required' => true,
116
+ 'options' => array (
117
+ '1' => Mage::helper('cms')->__('Enabled'),
118
+ '0' => Mage::helper('cms')->__('Disabled') ) ));
119
+
120
+ $form->setValues($model->getData());
121
+ $this->setForm($form);
122
+
123
+ return parent::_prepareForm();
124
+ }
125
+ }
app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Edit/Tabs.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FAQ for Magento
4
+ *
5
+ * @category Flagbit
6
+ * @package Flagbit_Faq
7
+ * @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG <magento@flagbit.de>
8
+ */
9
+
10
+ /**
11
+ * FAQ for Magento
12
+ *
13
+ * @category Flagbit
14
+ * @package Flagbit_Faq
15
+ * @author Flagbit GmbH & Co. KG <magento@flagbit.de>
16
+ */
17
+ class Flagbit_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('flagbit_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 Flagbit_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('flagbit_faq')->__('General information'),
46
+ 'title' => Mage::helper('flagbit_faq')->__('General information'),
47
+ 'content' => $this->getLayout()->createBlock('flagbit_faq/adminhtml_item_edit_tab_main')->toHtml(),
48
+ 'active' => true,
49
+ )
50
+ );
51
+
52
+ return $return;
53
+ }
54
+ }
app/code/community/Flagbit/Faq/Block/Adminhtml/Item/Grid.php ADDED
@@ -0,0 +1,155 @@