Version Notes
* Initial Release
Download this release
Release Info
Developer | Magento Core Team |
Extension | Flagbit_Faq |
Version | 1.0.4 |
Comparing to | |
See all releases |
Version 1.0.4
- app/code/community/Flagbit/Faq/Block/Admin/Edit.php +64 -0
- app/code/community/Flagbit/Faq/Block/Admin/Edit/Form.php +36 -0
- app/code/community/Flagbit/Faq/Block/Admin/Edit/Tab/Main.php +115 -0
- app/code/community/Flagbit/Faq/Block/Admin/Edit/Tabs.php +51 -0
- app/code/community/Flagbit/Faq/Block/Admin/List.php +45 -0
- app/code/community/Flagbit/Faq/Block/Admin/List/Grid.php +163 -0
- app/code/community/Flagbit/Faq/Block/Frontend/Detail.php +236 -0
- app/code/community/Flagbit/Faq/Block/Frontend/list.php +118 -0
- app/code/community/Flagbit/Faq/Helper/Data.php +32 -0
- app/code/community/Flagbit/Faq/Helper/Jumplist.php +97 -0
- app/code/community/Flagbit/Faq/Helper/JumplistItem.php +140 -0
- app/code/community/Flagbit/Faq/Model/Faq.php +29 -0
- app/code/community/Flagbit/Faq/Model/Mysql4/Faq.php +126 -0
- app/code/community/Flagbit/Faq/Model/Mysql4/Faq/Collection.php +115 -0
- app/code/community/Flagbit/Faq/controllers/AdminController.php +212 -0
- app/code/community/Flagbit/Faq/controllers/IndexController.php +37 -0
- app/code/community/Flagbit/Faq/etc/config.xml +133 -0
- app/code/community/Flagbit/Faq/sql/faq_setup/mysql4-install-0.1.0.php +39 -0
- app/design/frontend/base/default/layout/faq.xml +48 -0
- app/design/frontend/base/default/template/faq/detail.phtml +29 -0
- app/design/frontend/base/default/template/faq/list.phtml +56 -0
- app/etc/modules/Flagbit_Faq.xml +9 -0
- app/locale/de_DE/Flagbit_Faq.csv +38 -0
- package.xml +18 -0
app/code/community/Flagbit/Faq/Block/Admin/Edit.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
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 |
+
|
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
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Frontend/Detail.php
ADDED
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_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 Flagbit_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 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Extracting available images
|
58 |
+
*
|
59 |
+
* @param string $thumbSize dimensions of thumbnail image (either number of width pixels or {width]x{height}
|
60 |
+
* @param string $imageSize dimensions of detail image (either number of width pixels or {width]x{height}
|
61 |
+
* @return unknown
|
62 |
+
*/
|
63 |
+
public function getImages($thumbSize = null, $imageSize = null) {
|
64 |
+
if (!$faq = $this->getFaq()) {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
|
68 |
+
// read images from dataset
|
69 |
+
$images = $faq->getImage();
|
70 |
+
$result = array();
|
71 |
+
|
72 |
+
// if we have found images - process them
|
73 |
+
if (is_array($images) && !empty($images)) {
|
74 |
+
|
75 |
+
// get media model
|
76 |
+
$mediaConfig = Mage :: getSingleton('faq/faq_media_config');
|
77 |
+
$mediaModel = Mage :: getSingleton('media/image')->setConfig($mediaConfig);
|
78 |
+
|
79 |
+
// iterate through images
|
80 |
+
foreach ($images as $image) {
|
81 |
+
|
82 |
+
// only go on if the image can be found
|
83 |
+
if (file_exists(Mage::getBaseDir('media') . DS . 'faq' . DS . $image)) {
|
84 |
+
|
85 |
+
// gather needed information
|
86 |
+
$newImage = array(
|
87 |
+
'original' => $image,
|
88 |
+
'galleryUrl' => $this->getGalleryUrl($image)
|
89 |
+
);
|
90 |
+
|
91 |
+
if ($thumbSize) {
|
92 |
+
$newImage['src'] = $mediaModel->getSpecialLink($image, $thumbSize);
|
93 |
+
}
|
94 |
+
|
95 |
+
if ($imageSize) {
|
96 |
+
$newImage['href'] = $mediaModel->getSpecialLink($image, $imageSize);
|
97 |
+
$newImage['width'] = intval($imageSize);
|
98 |
+
}
|
99 |
+
else {
|
100 |
+
$newImage['href'] = Mage::getBaseUrl('media') . '/faq/' . $image;
|
101 |
+
$newImage['width'] = $mediaModel->setFileName($image)->getDimensions()->getWidth();
|
102 |
+
}
|
103 |
+
|
104 |
+
$result[] = $newImage;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
return $result;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get gallery link for given image
|
115 |
+
*
|
116 |
+
* @param string $image File name
|
117 |
+
* @return string URL to gallery
|
118 |
+
*/
|
119 |
+
public function getGalleryUrl($image) {
|
120 |
+
$params = array('faq' => $this->getFaq()->getFaqId() . '_' . urlencode(str_replace(array(' ', 'ä', 'ö', 'ü', 'ß'), array('_', 'ae', 'oe', 'ue', 'ss'), (strtolower($this->getFaq()->getQuestion())))));
|
121 |
+
if ($image) {
|
122 |
+
$params['image'] = $image;
|
123 |
+
return $this->getUrl('*/*/gallery', $params);
|
124 |
+
}
|
125 |
+
return $this->getUrl('*/*/gallery', $params);
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Get gallery images for current gallery view
|
131 |
+
*
|
132 |
+
* @param string $type needed Image information type ('previous', 'current' or 'next') - if not given the function returns all of them.
|
133 |
+
* @return array Requested image information
|
134 |
+
*/
|
135 |
+
public function getGalleryImages($type = null) {
|
136 |
+
|
137 |
+
// only do processing once (since parameters don't change during gallery view)
|
138 |
+
if (!$this->_images) {
|
139 |
+
|
140 |
+
// get images and parameters
|
141 |
+
$currentParam = $this->getRequest()->getParam('image');
|
142 |
+
$images = $this->getImages();
|
143 |
+
|
144 |
+
// initialization
|
145 |
+
$result = array(
|
146 |
+
'previous' => NULL,
|
147 |
+
'current' => NULL,
|
148 |
+
'next' => NULL
|
149 |
+
);
|
150 |
+
|
151 |
+
// if we have images -> process them
|
152 |
+
if (is_array($images) && !empty($images)) {
|
153 |
+
$previousImage = null;
|
154 |
+
|
155 |
+
foreach ($images as $image) {
|
156 |
+
|
157 |
+
// if we found the requested pic -> save it
|
158 |
+
// if the requested pic was not found the first pic of the collection is used
|
159 |
+
if ($image['original'] == $currentParam || !$result['current']) {
|
160 |
+
$result['current'] = $image;
|
161 |
+
|
162 |
+
// save the previous image to get back to it
|
163 |
+
$result['previous'] = $previousImage;
|
164 |
+
|
165 |
+
if ($image['original'] == $currentParam) {
|
166 |
+
$current = true;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
// save next image for pagination
|
170 |
+
elseif ($result['current']) {
|
171 |
+
$result['next'] = $image;
|
172 |
+
|
173 |
+
// if we found the requested image -> break
|
174 |
+
if ($current) {
|
175 |
+
break;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
// save current image as previous image for further processing
|
180 |
+
$previousImage = $image;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
// save results in class variable
|
185 |
+
$this->_images = $result;
|
186 |
+
}
|
187 |
+
|
188 |
+
// if the requested type is given - return the image
|
189 |
+
if ($type) {
|
190 |
+
return (isset($this->_images[$type]) ? $this->_images[$type] : false);
|
191 |
+
}
|
192 |
+
|
193 |
+
// if no type given -> return all the three images
|
194 |
+
return $this->_images;
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Gets the current image
|
200 |
+
*
|
201 |
+
* @return array Image information
|
202 |
+
*/
|
203 |
+
public function getCurrentImage() {
|
204 |
+
return $this->getGalleryImages('current');
|
205 |
+
}
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Gets the previous image
|
210 |
+
*
|
211 |
+
* @return array Image information
|
212 |
+
*/
|
213 |
+
public function getPreviousImage() {
|
214 |
+
return $this->getGalleryImages('previous');
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Gets the next image
|
220 |
+
*
|
221 |
+
* @return array Image information
|
222 |
+
*/
|
223 |
+
public function getNextImage() {
|
224 |
+
return $this->getGalleryImages('next');
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Returns the current image's width
|
229 |
+
*
|
230 |
+
* @return int Width of current image
|
231 |
+
*/
|
232 |
+
public function getImageWidth() {
|
233 |
+
$current = $this->getCurrentImage();
|
234 |
+
return $current['width'];
|
235 |
+
}
|
236 |
+
}
|
app/code/community/Flagbit/Faq/Block/Frontend/list.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Frontend_List extends Mage_Core_Block_Template {
|
18 |
+
|
19 |
+
protected $_faqCollection;
|
20 |
+
|
21 |
+
protected function _prepareLayout()
|
22 |
+
{
|
23 |
+
if ($head = $this->getLayout()->getBlock('head')) {
|
24 |
+
$head->setTitle($this->htmlEscape($this->__('Frequently Asked Questions')) . ' - ' . $head->getTitle());
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns collection of current FAQ entries
|
30 |
+
*
|
31 |
+
* @param int $pageSize
|
32 |
+
* @return Flagbit_Faq_Model_Mysql_Faq_Collection collection of current FAQ entries
|
33 |
+
*/
|
34 |
+
public function getFaqCollection($pageSize = null) {
|
35 |
+
if (!$this->_faqCollection || (intval($pageSize) > 0
|
36 |
+
&& $this->_faqCollection->getSize() != intval($pageSize))
|
37 |
+
) {
|
38 |
+
$this->_faqCollection = Mage :: getModel('faq/faq')
|
39 |
+
->getCollection()
|
40 |
+
->addStoreFilter(Mage :: app()->getStore())
|
41 |
+
->addIsActiveFilter();
|
42 |
+
|
43 |
+
if (isset($pageSize) && intval($pageSize) && intval($pageSize) > 0) {
|
44 |
+
$this->_faqCollection->setPageSize(intval($pageSize));
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->_faqCollection;
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Simple helper function to determine, whether there are FAQ entries or not.
|
54 |
+
*
|
55 |
+
* @return boolean True, if FAQ are given.
|
56 |
+
*/
|
57 |
+
public function hasFaq() {
|
58 |
+
return $this->getFaqCollection()->getSize() > 0;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
public function getIntro($faqItem) {
|
63 |
+
$_intro = strip_tags($faqItem->getContent());
|
64 |
+
$_intro = mb_substr($_intro, 0, mb_strpos($_intro, "\n"));
|
65 |
+
|
66 |
+
$length = 100 - mb_strlen($faqItem->getQuestion());
|
67 |
+
if ($length < 0) {
|
68 |
+
return '';
|
69 |
+
}
|
70 |
+
if (mb_strlen($_intro) > $length) {
|
71 |
+
$_intro = mb_substr($_intro, 0, $length);
|
72 |
+
$_intro = mb_substr($_intro, 0, mb_strrpos($_intro, ' ')).'...';
|
73 |
+
}
|
74 |
+
|
75 |
+
return $_intro;
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Returns
|
81 |
+
*
|
82 |
+
* @return array
|
83 |
+
*/
|
84 |
+
public function getFaqJumplist()
|
85 |
+
{
|
86 |
+
if(is_null($this->_faqJumplist))
|
87 |
+
{
|
88 |
+
$this->_faqJumplist = Mage::helper('faq/jumplist');
|
89 |
+
$this->_faqJumplist->setFaqItems($this->getFaqCollection());
|
90 |
+
}
|
91 |
+
return $this->_faqJumplist;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Simple helper function to determine, whether we should display a jumplist or not.
|
97 |
+
*
|
98 |
+
* @return boolean True if the jumplist should be displayed
|
99 |
+
*/
|
100 |
+
public function hasFaqJumplist() {
|
101 |
+
// TODO add configuration option to enable/disable jumplist
|
102 |
+
return count($this->getFaqJumplist()) > 0;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
public function encodeQuestionForUrl($question) {
|
108 |
+
return urlencode(
|
109 |
+
trim(
|
110 |
+
str_replace(
|
111 |
+
array(' ', 'ä', 'ö', 'ü', 'ß', '.', '/', ';', ':', '=', '?', '__'),
|
112 |
+
array('_', 'ae', 'oe', 'ue', 'ss', '_', '', '', '', '', '', '_'),
|
113 |
+
strtolower($question)
|
114 |
+
), ' _'
|
115 |
+
)
|
116 |
+
);
|
117 |
+
}
|
118 |
+
}
|
app/code/community/Flagbit/Faq/Helper/Data.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Helper_Data extends Mage_Core_Helper_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Returns config data
|
22 |
+
*
|
23 |
+
* @param string $field Requested field
|
24 |
+
* @return array config Configuration information
|
25 |
+
*/
|
26 |
+
public function getConfigData($field)
|
27 |
+
{
|
28 |
+
$path = 'faq/config/'.$field;
|
29 |
+
$config = Mage::getStoreConfig($path, Mage::app()->getStore());
|
30 |
+
return $config;
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Flagbit/Faq/Helper/Jumplist.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Helper_Jumplist extends Mage_Core_Helper_Abstract implements Countable, Iterator
|
18 |
+
{
|
19 |
+
protected $items = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* The "garbage can" for items not fitting in the default range
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
const KEY_OTHER = 'other';
|
27 |
+
|
28 |
+
public function __construct()
|
29 |
+
{
|
30 |
+
// TODO make init range configurable
|
31 |
+
// create items from A (65) to Z (90)
|
32 |
+
for($ord = 65; $ord <= 90; $ord++)
|
33 |
+
{
|
34 |
+
$chr = chr($ord);
|
35 |
+
$this->items[$chr] = new Flagbit_Faq_Helper_JumplistItem($chr);
|
36 |
+
}
|
37 |
+
|
38 |
+
// TODO make configurable if KEY_OTHER is appended or prepended
|
39 |
+
$this->items[self::KEY_OTHER] = new Flagbit_Faq_Helper_JumplistItem(self::KEY_OTHER);
|
40 |
+
}
|
41 |
+
|
42 |
+
public function setFaqItems(Flagbit_Faq_Model_Mysql4_Faq_Collection $items)
|
43 |
+
{
|
44 |
+
foreach($items as $item)
|
45 |
+
{
|
46 |
+
$key = strtoupper(substr($item->getQuestion(), 0, 1));
|
47 |
+
if(!array_key_exists($key, $this->items))
|
48 |
+
{
|
49 |
+
$key = self::KEY_OTHER;
|
50 |
+
}
|
51 |
+
$this->items[$key]->addFaqItem($item);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @see ArrayIterator::current()
|
57 |
+
*/
|
58 |
+
public function current() {
|
59 |
+
return current($this->items);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @see ArrayIterator::key()
|
64 |
+
*/
|
65 |
+
public function key() {
|
66 |
+
return key($this->items);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @see ArrayIterator::next()
|
71 |
+
*/
|
72 |
+
public function next() {
|
73 |
+
return next($this->items);
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @see ArrayIterator::rewind()
|
78 |
+
*/
|
79 |
+
public function rewind() {
|
80 |
+
return reset($this->items);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @see ArrayIterator::valid()
|
85 |
+
*/
|
86 |
+
public function valid() {
|
87 |
+
return array_key_exists($this->key(), $this->items);
|
88 |
+
}
|
89 |
+
/**
|
90 |
+
* @see Countable::count()
|
91 |
+
*/
|
92 |
+
public function count() {
|
93 |
+
return count($this->items);
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
}
|
app/code/community/Flagbit/Faq/Helper/JumplistItem.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Helper_JumplistItem extends Mage_Core_Helper_Abstract implements Countable, Iterator
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
protected $label;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
protected $faqItems = array();
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The constructor
|
31 |
+
*
|
32 |
+
* @param string $label
|
33 |
+
* @param array $faqItems
|
34 |
+
*/
|
35 |
+
public function __construct($label = null, $faqItems = null)
|
36 |
+
{
|
37 |
+
$this->setLabel($label);
|
38 |
+
if(!is_null($faqItems))
|
39 |
+
{
|
40 |
+
$this->setFaqItems($faqItems);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function getFaqItems()
|
48 |
+
{
|
49 |
+
return $this->faqItems;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param array $faqItems
|
54 |
+
*/
|
55 |
+
public function setFaqItems(array $faqItems)
|
56 |
+
{
|
57 |
+
$this->faqItems = $faqItems;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function addFaqItem($item)
|
61 |
+
{
|
62 |
+
$this->faqItems[] = $item;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
public function getLabel()
|
69 |
+
{
|
70 |
+
return $this->label;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param string $label
|
75 |
+
*/
|
76 |
+
public function setLabel($label)
|
77 |
+
{
|
78 |
+
$this->label = (string) $label;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Count elements of the jumplist
|
83 |
+
*
|
84 |
+
* @return int
|
85 |
+
*/
|
86 |
+
public function count()
|
87 |
+
{
|
88 |
+
return count($this->faqItems);
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Returns the current element
|
93 |
+
*
|
94 |
+
* @return mixed
|
95 |
+
*/
|
96 |
+
public function current()
|
97 |
+
{
|
98 |
+
return current($this->faqItems);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Returns the key of the current element
|
103 |
+
*
|
104 |
+
* @return scalar
|
105 |
+
*/
|
106 |
+
public function key()
|
107 |
+
{
|
108 |
+
return key($this->faqItems);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Move forward to the next element
|
113 |
+
*
|
114 |
+
* @return void
|
115 |
+
*/
|
116 |
+
public function next()
|
117 |
+
{
|
118 |
+
next($this->faqItems);
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Rewind the Iterator to the first element
|
123 |
+
*
|
124 |
+
* @void
|
125 |
+
*/
|
126 |
+
public function rewind()
|
127 |
+
{
|
128 |
+
reset($this->faqItems);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Checks if current position is valid
|
133 |
+
*
|
134 |
+
* @return boolean
|
135 |
+
*/
|
136 |
+
public function valid()
|
137 |
+
{
|
138 |
+
return array_key_exists($this->key(), $this->faqItems);
|
139 |
+
}
|
140 |
+
}
|
app/code/community/Flagbit/Faq/Model/Faq.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Model_Faq extends Mage_Core_Model_Abstract {
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Constructor
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
protected function _construct() {
|
25 |
+
|
26 |
+
$this->_init('faq/faq');
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/community/Flagbit/Faq/Model/Mysql4/Faq.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_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 |
+
return $select;
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Some processing prior to saving to database - processes the given images
|
54 |
+
* and the store configuration
|
55 |
+
*
|
56 |
+
* @param Mage_Core_Model_Abstract $object Current faq item
|
57 |
+
*/
|
58 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object) {
|
59 |
+
|
60 |
+
if (!$object->getId()) {
|
61 |
+
$object->setCreationTime(Mage :: getSingleton('core/date')->gmtDate());
|
62 |
+
}
|
63 |
+
|
64 |
+
$object->setPublicationTime(
|
65 |
+
Mage::app()->getLocale()->date($object->getPublicationTime(),
|
66 |
+
Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
67 |
+
null, false)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
68 |
+
);
|
69 |
+
|
70 |
+
$object->setUpdateTime(Mage :: getSingleton('core/date')->gmtDate());
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Assign page to store views
|
76 |
+
*
|
77 |
+
* @param Mage_Core_Model_Abstract $object
|
78 |
+
*/
|
79 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object) {
|
80 |
+
|
81 |
+
$condition = $this->_getWriteAdapter()->quoteInto('faq_id = ?', $object->getId());
|
82 |
+
$this->_getWriteAdapter()->delete($this->getTable('faq/faq_store'), $condition);
|
83 |
+
|
84 |
+
foreach ((array) $object->getData('stores') as $store) {
|
85 |
+
$storeArray = array ();
|
86 |
+
$storeArray['faq_id'] = $object->getId();
|
87 |
+
$storeArray['store_id'] = $store;
|
88 |
+
$this->_getWriteAdapter()->insert(
|
89 |
+
$this->getTable('faq/faq_store'), $storeArray
|
90 |
+
);
|
91 |
+
}
|
92 |
+
|
93 |
+
return parent :: _afterSave($object);
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Do some processing after loading (stores and images)
|
99 |
+
*
|
100 |
+
* @param Mage_Core_Model_Abstract $object Current faq item
|
101 |
+
*/
|
102 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object) {
|
103 |
+
|
104 |
+
$select = $this->_getReadAdapter()->select()->from(
|
105 |
+
$this->getTable('faq/faq_store')
|
106 |
+
)->where('faq_id = ?', $object->getId());
|
107 |
+
|
108 |
+
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
|
109 |
+
$storesArray = array ();
|
110 |
+
foreach ($data as $row) {
|
111 |
+
$storesArray[] = $row['store_id'];
|
112 |
+
}
|
113 |
+
$object->setData('store_id', $storesArray);
|
114 |
+
}
|
115 |
+
|
116 |
+
$images = trim($object->getData('image'));
|
117 |
+
if ($images && !empty($images)) {
|
118 |
+
$object->setData('image', explode(',', $images));
|
119 |
+
}
|
120 |
+
else {
|
121 |
+
$object->setData('image', null);
|
122 |
+
}
|
123 |
+
|
124 |
+
return parent :: _afterLoad($object);
|
125 |
+
}
|
126 |
+
}
|
app/code/community/Flagbit/Faq/Model/Mysql4/Faq/Collection.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Model_Mysql4_Faq_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
18 |
+
|
19 |
+
protected $_previewFlag;
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Constructor
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
protected function _construct() {
|
27 |
+
|
28 |
+
$this->_init('faq/faq')
|
29 |
+
->setOrder('question', 'ASC');
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Creates an options array for grid filter functionality
|
35 |
+
*
|
36 |
+
* @return array Options array
|
37 |
+
*/
|
38 |
+
public function toOptionArray() {
|
39 |
+
|
40 |
+
return $this->_toOptionArray('faq_id', 'question');
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
public function addIsActiveFilter(){
|
45 |
+
$this->addFilter('is_active', 1);
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add Filter by store
|
53 |
+
*
|
54 |
+
* @param int|Mage_Core_Model_Store $store Store to be filtered
|
55 |
+
* @return Flagbit_Faq_Model_Mysql4_Faq_Collection Self
|
56 |
+
*/
|
57 |
+
public function addStoreFilter($store) {
|
58 |
+
|
59 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
60 |
+
$store = array (
|
61 |
+
$store->getId() );
|
62 |
+
}
|
63 |
+
|
64 |
+
$this->getSelect()->join(
|
65 |
+
array('store_table' => $this->getTable('faq/faq_store')),
|
66 |
+
'main_table.faq_id = store_table.faq_id',
|
67 |
+
array ()
|
68 |
+
)->where('store_table.store_id in (?)', array (
|
69 |
+
0,
|
70 |
+
$store
|
71 |
+
))->group('main_table.faq_id');
|
72 |
+
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* After load processing - adds store information to the datasets
|
79 |
+
*
|
80 |
+
*/
|
81 |
+
protected function _afterLoad() {
|
82 |
+
|
83 |
+
if ($this->_previewFlag) {
|
84 |
+
$items = $this->getColumnValues('faq_id');
|
85 |
+
if (count($items)) {
|
86 |
+
$select = $this->getConnection()->select()->from(
|
87 |
+
$this->getTable('faq/faq_store')
|
88 |
+
)->where(
|
89 |
+
$this->getTable('faq/faq_store') . '.faq_id IN (?)',
|
90 |
+
$items
|
91 |
+
);
|
92 |
+
if ($result = $this->getConnection()->fetchPairs($select)) {
|
93 |
+
foreach ($this as $item) {
|
94 |
+
if (!isset($result[$item->getData('faq_id')])) {
|
95 |
+
continue;
|
96 |
+
}
|
97 |
+
if ($result[$item->getData('faq_id')] == 0) {
|
98 |
+
$stores = Mage :: app()->getStores(false, true);
|
99 |
+
$storeId = current($stores)->getId();
|
100 |
+
$storeCode = key($stores);
|
101 |
+
}
|
102 |
+
else {
|
103 |
+
$storeId = $result[$item->getData('faq_id')];
|
104 |
+
$storeCode = Mage :: app()->getStore($storeId)->getCode();
|
105 |
+
}
|
106 |
+
$item->setData('_first_store_id', $storeId);
|
107 |
+
$item->setData('store_code', $storeCode);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
parent :: _afterLoad();
|
114 |
+
}
|
115 |
+
}
|
app/code/community/Flagbit/Faq/controllers/AdminController.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_AdminController extends Mage_Adminhtml_Controller_Action {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initialization of current view - add's breadcrumps and the current menu status
|
22 |
+
*
|
23 |
+
* @return Flagbit_Faq_AdminController
|
24 |
+
*/
|
25 |
+
protected function _initAction() {
|
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 |
+
/**
|
38 |
+
* Displays the FAQ overview grid.
|
39 |
+
*
|
40 |
+
*/
|
41 |
+
public function indexAction() {
|
42 |
+
|
43 |
+
$this->_initAction()
|
44 |
+
->_addContent($this->getLayout()->createBlock('faq/admin_list'))
|
45 |
+
->renderLayout();
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Displays the new FAQ item form
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
public function newAction() {
|
54 |
+
|
55 |
+
$this->_forward('edit');
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Displays the new FAQ item form or the edit FAQ item form.
|
61 |
+
*
|
62 |
+
*/
|
63 |
+
public function editAction() {
|
64 |
+
|
65 |
+
$id = $this->getRequest()->getParam('faq_id');
|
66 |
+
$model = Mage :: getModel('faq/faq');
|
67 |
+
|
68 |
+
// if current id given -> try to load and edit current FAQ item
|
69 |
+
if ($id) {
|
70 |
+
$model->load($id);
|
71 |
+
if (!$model->getId()) {
|
72 |
+
Mage :: getSingleton('adminhtml/session')->addError(
|
73 |
+
Mage :: helper('faq')->__('This FAQ item no longer exists')
|
74 |
+
);
|
75 |
+
$this->_redirect('*/*/');
|
76 |
+
return;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
$data = Mage :: getSingleton('adminhtml/session')->getFormData(true);
|
81 |
+
if (!empty($data)) {
|
82 |
+
$model->setData($data);
|
83 |
+
}
|
84 |
+
|
85 |
+
Mage :: register('faq', $model);
|
86 |
+
|
87 |
+
$this->_initAction()
|
88 |
+
->_addBreadcrumb(
|
89 |
+
$id
|
90 |
+
? Mage :: helper('faq')->__('Edit FAQ Item')
|
91 |
+
: Mage :: helper('faq')->__('New FAQ Item'),
|
92 |
+
$id
|
93 |
+
? Mage :: helper('faq')->__('Edit FAQ Item')
|
94 |
+
: Mage :: helper('faq')->__('New FAQ Item')
|
95 |
+
)
|
96 |
+
->_addContent(
|
97 |
+
$this->getLayout()
|
98 |
+
->createBlock('faq/admin_edit')
|
99 |
+
->setData('action', $this->getUrl('adminhtml/faq/save'))
|
100 |
+
)
|
101 |
+
->_addLeft($this->getLayout()->createBlock('faq/admin_edit_tabs'));
|
102 |
+
|
103 |
+
$this->renderLayout();
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Action that does the actual saving process and redirects back to overview
|
109 |
+
*
|
110 |
+
*/
|
111 |
+
public function saveAction() {
|
112 |
+
|
113 |
+
// check if data sent
|
114 |
+
if ($data = $this->getRequest()->getPost()) {
|
115 |
+
|
116 |
+
// init model and set data
|
117 |
+
$model = Mage :: getModel('faq/faq');
|
118 |
+
$model->setData($data);
|
119 |
+
|
120 |
+
// try to save it
|
121 |
+
try {
|
122 |
+
// save the data
|
123 |
+
$model->save();
|
124 |
+
|
125 |
+
// display success message
|
126 |
+
Mage :: getSingleton('adminhtml/session')->addSuccess(
|
127 |
+
Mage :: helper('cms')->__('FAQ Item was successfully saved')
|
128 |
+
);
|
129 |
+
// clear previously saved data from session
|
130 |
+
Mage :: getSingleton('adminhtml/session')->setFormData(false);
|
131 |
+
// check if 'Save and Continue'
|
132 |
+
if ($this->getRequest()->getParam('back')) {
|
133 |
+
$this->_redirect('*/*/edit', array (
|
134 |
+
'faq_id' => $model->getId() ));
|
135 |
+
return;
|
136 |
+
}
|
137 |
+
// go to grid
|
138 |
+
$this->_redirect('*/*/');
|
139 |
+
return;
|
140 |
+
|
141 |
+
}
|
142 |
+
catch (Exception $e) {
|
143 |
+
// display error message
|
144 |
+
Mage :: getSingleton('adminhtml/session')->addError($e->getMessage());
|
145 |
+
// save data in session
|
146 |
+
Mage :: getSingleton('adminhtml/session')->setFormData($data);
|
147 |
+
// redirect to edit form
|
148 |
+
$this->_redirect('*/*/edit', array (
|
149 |
+
'faq_id' => $this->getRequest()->getParam('faq_id') ));
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
$this->_redirect('*/*/');
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Simple access control
|
159 |
+
*
|
160 |
+
* @return boolean True if user is allowed to edit FAQ
|
161 |
+
*/
|
162 |
+
protected function _isAllowed() {
|
163 |
+
|
164 |
+
return Mage :: getSingleton('admin/session')->isAllowed('admin/cms/faq');
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Action that does the actual saving process and redirects back to overview
|
170 |
+
*
|
171 |
+
*/
|
172 |
+
public function deleteAction() {
|
173 |
+
|
174 |
+
// check if we know what should be deleted
|
175 |
+
if ($id = $this->getRequest()->getParam('faq_id')) {
|
176 |
+
try {
|
177 |
+
|
178 |
+
// init model and delete
|
179 |
+
$model = Mage :: getModel('faq/faq');
|
180 |
+
$model->load($id);
|
181 |
+
$model->delete();
|
182 |
+
|
183 |
+
// display success message
|
184 |
+
Mage :: getSingleton('adminhtml/session')->addSuccess(Mage :: helper('cms')->__('FAQ Entry was successfully deleted'));
|
185 |
+
|
186 |
+
// go to grid
|
187 |
+
$this->_redirect('*/*/');
|
188 |
+
return;
|
189 |
+
|
190 |
+
}
|
191 |
+
catch (Exception $e) {
|
192 |
+
|
193 |
+
// display error message
|
194 |
+
Mage :: getSingleton('adminhtml/session')->addError($e->getMessage());
|
195 |
+
|
196 |
+
// go back to edit form
|
197 |
+
$this->_redirect('*/*/edit', array (
|
198 |
+
'faq_id' => $id ));
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
// display error message
|
204 |
+
Mage :: getSingleton('adminhtml/session')->addError(Mage :: helper('cms')->__('Unable to find a FAQ entry to delete'));
|
205 |
+
|
206 |
+
// go to grid
|
207 |
+
$this->_redirect('*/*/');
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
|
212 |
+
}
|
app/code/community/Flagbit/Faq/controllers/IndexController.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_IndexController extends Mage_Core_Controller_Front_Action {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Displays the FAQ list.
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
public function indexAction() {
|
24 |
+
|
25 |
+
$this->loadLayout()->renderLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Displays the current FAQ's detail view
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function showAction() {
|
33 |
+
|
34 |
+
$this->loadLayout()->renderLayout();
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/Flagbit/Faq/etc/config.xml
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Flagbit_Faq>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>1.0.4</version>
|
8 |
+
</Flagbit_Faq>
|
9 |
+
</modules>
|
10 |
+
|
11 |
+
<admin>
|
12 |
+
<routers>
|
13 |
+
<faq>
|
14 |
+
<use>admin</use>
|
15 |
+
<args>
|
16 |
+
<module>Flagbit_Faq</module>
|
17 |
+
<frontName>faq</frontName>
|
18 |
+
</args>
|
19 |
+
</faq>
|
20 |
+
</routers>
|
21 |
+
</admin>
|
22 |
+
|
23 |
+
<frontend>
|
24 |
+
<routers>
|
25 |
+
<faq>
|
26 |
+
<use>standard</use>
|
27 |
+
<args>
|
28 |
+
<module>Flagbit_Faq</module>
|
29 |
+
<frontName>faq</frontName>
|
30 |
+
</args>
|
31 |
+
</faq>
|
32 |
+
</routers>
|
33 |
+
<translate>
|
34 |
+
<modules>
|
35 |
+
<Flagbit_Faq>
|
36 |
+
<files>
|
37 |
+
<default>Flagbit_Faq.csv</default>
|
38 |
+
</files>
|
39 |
+
</Flagbit_Faq>
|
40 |
+
</modules>
|
41 |
+
</translate>
|
42 |
+
<layout>
|
43 |
+
<updates>
|
44 |
+
<faq>
|
45 |
+
<file>faq.xml</file>
|
46 |
+
</faq>
|
47 |
+
</updates>
|
48 |
+
</layout>
|
49 |
+
</frontend>
|
50 |
+
|
51 |
+
<global>
|
52 |
+
<helpers>
|
53 |
+
<faq>
|
54 |
+
<class>Flagbit_Faq_Helper</class>
|
55 |
+
</faq>
|
56 |
+
</helpers>
|
57 |
+
|
58 |
+
<blocks>
|
59 |
+
<faq>
|
60 |
+
<class>Flagbit_Faq_Block</class>
|
61 |
+
</faq>
|
62 |
+
</blocks>
|
63 |
+
|
64 |
+
<models>
|
65 |
+
<faq>
|
66 |
+
<class>Flagbit_Faq_Model</class>
|
67 |
+
<resourceModel>faq_mysql4</resourceModel>
|
68 |
+
</faq>
|
69 |
+
<faq_mysql4>
|
70 |
+
<class>Flagbit_Faq_Model_Mysql4</class>
|
71 |
+
<entities>
|
72 |
+
<faq>
|
73 |
+
<table>faq</table>
|
74 |
+
</faq>
|
75 |
+
<faq_store>
|
76 |
+
<table>faq_store</table>
|
77 |
+
</faq_store>
|
78 |
+
</entities>
|
79 |
+
</faq_mysql4>
|
80 |
+
</models>
|
81 |
+
|
82 |
+
<resources>
|
83 |
+
<faq_setup>
|
84 |
+
<setup>
|
85 |
+
<module>Flagbit_Faq</module>
|
86 |
+
</setup>
|
87 |
+
<connection>
|
88 |
+
<use>core_setup</use>
|
89 |
+
</connection>
|
90 |
+
</faq_setup>
|
91 |
+
<faq_write>
|
92 |
+
<connection>
|
93 |
+
<use>core_write</use>
|
94 |
+
</connection>
|
95 |
+
</faq_write>
|
96 |
+
<faq_read>
|
97 |
+
<connection>
|
98 |
+
<use>core_read</use>
|
99 |
+
</connection>
|
100 |
+
</faq_read>
|
101 |
+
</resources>
|
102 |
+
|
103 |
+
<rewrite>
|
104 |
+
<Flagbit_Faq>
|
105 |
+
<from><![CDATA[#^/{adminhtml}/faq/#]]></from>
|
106 |
+
<to>/faq/admin/</to>
|
107 |
+
</Flagbit_Faq>
|
108 |
+
</rewrite>
|
109 |
+
</global>
|
110 |
+
|
111 |
+
<adminhtml>
|
112 |
+
<translate>
|
113 |
+
<modules>
|
114 |
+
<Flagbit_Faq>
|
115 |
+
<files>
|
116 |
+
<default>Flagbit_Faq.csv</default>
|
117 |
+
</files>
|
118 |
+
</Flagbit_Faq>
|
119 |
+
</modules>
|
120 |
+
</translate>
|
121 |
+
</adminhtml>
|
122 |
+
<install>
|
123 |
+
<translate>
|
124 |
+
<modules>
|
125 |
+
<Flagbit_Faq>
|
126 |
+
<files>
|
127 |
+
<default>Flagbit_Faq.csv</default>
|
128 |
+
</files>
|
129 |
+
</Flagbit_Faq>
|
130 |
+
</modules>
|
131 |
+
</translate>
|
132 |
+
</install>
|
133 |
+
</config>
|
app/code/community/Flagbit/Faq/sql/faq_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$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 |
+
`answer_html` tinyint(1) NOT NULL default '1',
|
21 |
+
`creation_time` datetime default NULL,
|
22 |
+
`update_time` datetime default NULL,
|
23 |
+
`is_active` 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();
|
38 |
+
|
39 |
+
?>
|
app/design/frontend/base/default/layout/faq.xml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
30 |
+
<faq_index_index>
|
31 |
+
<reference name="root">
|
32 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
33 |
+
</reference>
|
34 |
+
<reference name="content">
|
35 |
+
<block type="faq/frontend_list" name="faq_list" template="faq/list.phtml"/>
|
36 |
+
</reference>
|
37 |
+
</faq_index_index>
|
38 |
+
|
39 |
+
<faq_index_show>
|
40 |
+
<reference name="root">
|
41 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
42 |
+
</reference>
|
43 |
+
<reference name="content">
|
44 |
+
<block type="faq/frontend_detail" name="faq_detail" template="faq/detail.phtml"/>
|
45 |
+
</reference>
|
46 |
+
</faq_index_show>
|
47 |
+
|
48 |
+
</layout>
|
app/design/frontend/base/default/template/faq/detail.phtml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $_faq = $this->getFaq() ?>
|
2 |
+
|
3 |
+
<div class="faq-detail">
|
4 |
+
<?php if ($_faq): ?>
|
5 |
+
<h1><?php echo $this->htmlEscape($_faq->getQuestion()) ?></h1>
|
6 |
+
|
7 |
+
<p class="faq-date">
|
8 |
+
<?php echo Mage :: getModel('core/date')->date('d.m.Y', $_faq->getPublicationTime()); ?>
|
9 |
+
</p>
|
10 |
+
|
11 |
+
<?php $_content = $_faq->getAnswerHtml() ? $_faq->getAnswer() : $this->htmlEscape($_faq->getAnswer()) ?>
|
12 |
+
<?php if (!empty($_content)): ?>
|
13 |
+
<div class="faq-content">
|
14 |
+
<?php if ($_faq->getAnswerHtml()): ?>
|
15 |
+
<?php echo $_content ?>
|
16 |
+
<?php else: ?>
|
17 |
+
<?php foreach (explode("\n", $_content) as $paragraph): ?>
|
18 |
+
<p><?php echo $paragraph ?></p>
|
19 |
+
<?php endforeach; ?>
|
20 |
+
<?php endif; ?>
|
21 |
+
</div>
|
22 |
+
<?php endif; ?>
|
23 |
+
|
24 |
+
<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>
|
25 |
+
<?php else: ?>
|
26 |
+
<h1><?php echo $this->__('Error') ?></h1>
|
27 |
+
<p><?php echo $this->__('The requested FAQ item could not be found!') ?></p>
|
28 |
+
<?php endif; ?>
|
29 |
+
</div>
|
app/design/frontend/base/default/template/faq/list.phtml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Flagbit
|
23 |
+
* @copyright Copyright (c) 2009 Flagbit GmbH & Co. KG (http://www.flagbit.de)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="content-box">
|
28 |
+
<div class="content-box-content">
|
29 |
+
<h1><?php echo $this->__('FAQ overview'); ?></h1>
|
30 |
+
|
31 |
+
<?php if ($this->hasFaq()): ?>
|
32 |
+
<ul class="faq-list">
|
33 |
+
<?php foreach ($this->getFaqCollection() as $faqItem): ?>
|
34 |
+
<li>
|
35 |
+
<a href="#faq-item-<?php echo $faqItem->getId() ?>">
|
36 |
+
<?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
|
37 |
+
</a>
|
38 |
+
</li>
|
39 |
+
<?php endforeach; ?>
|
40 |
+
</ul>
|
41 |
+
<dl class="faq-items">
|
42 |
+
<?php foreach ($this->getFaqCollection() as $faqItem): ?>
|
43 |
+
<dt id="faq-item-<?php echo $faqItem->getId() ?>">
|
44 |
+
<?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
|
45 |
+
</dt>
|
46 |
+
<dd>
|
47 |
+
<?php echo ($faqItem->getAnswerHtml() ? $faqItem->getAnswer() : '<p>' . implode('</p><p>', explode("\n", $this->htmlEscape($faqItem->getAnswer()))) . '</p>') ?>
|
48 |
+
</dd>
|
49 |
+
<?php endforeach; ?>
|
50 |
+
</dl>
|
51 |
+
<?php else: ?>
|
52 |
+
<p class="faq-items"><?php echo $this->__('There are no FAQ items at the moment.') ?></p>
|
53 |
+
<?php endif; ?>
|
54 |
+
</div>
|
55 |
+
<div class="content-box-footer"></div>
|
56 |
+
</div>
|
app/etc/modules/Flagbit_Faq.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Flagbit_Faq>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Flagbit_Faq>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/de_DE/Flagbit_Faq.csv
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Action","Aktion"
|
2 |
+
"Active","Aktiv"
|
3 |
+
"Add new FAQ item","Neuen FAQ-Eintrag anlegen"
|
4 |
+
"Answer","Antwort"
|
5 |
+
"Back to the FAQ overview", "Zurück zur FAQ-Übersicht"
|
6 |
+
"Content","Inhalt"
|
7 |
+
"Delete FAQ item","FAQ-Eintrag löschen"
|
8 |
+
"Disabled","Deaktiviert"
|
9 |
+
"Display all FAQ items","Alle FAQ-Einträge anzeigen"
|
10 |
+
"Edit","Bearbeiten"
|
11 |
+
"Edit FAQ item '%s'","FAQ-Eintrag '%s' bearbeiten"
|
12 |
+
"Enabled","Aktiviert"
|
13 |
+
"FAQ Item was successfully saved","FAQ-Eintrag wurde erfolgreich gespeichert"
|
14 |
+
"FAQ","FAQ"
|
15 |
+
"FAQ #","Lfd. Nr."
|
16 |
+
"FAQ item information","FAQ-Eintragsinformationen"
|
17 |
+
"FAQ item question","Frage des FAQ-Eintrags"
|
18 |
+
"FAQ overview","FAQ-Übersicht"
|
19 |
+
"General information","Allgemeine Informationen"
|
20 |
+
"HTML answer","HTML Antwort"
|
21 |
+
"Images","Bilder"
|
22 |
+
"New FAQ item","Neuer FAQ-Eintrag"
|
23 |
+
"No","Nein"
|
24 |
+
"of %s pages","von %d Seiten"
|
25 |
+
"Page","Seite"
|
26 |
+
"Page status","Seitenstatus"
|
27 |
+
"per page","pro Seite"
|
28 |
+
"Publication date","Veröffentlichungsdatum"
|
29 |
+
"Published on","Veröffentlichungsdatum"
|
30 |
+
"Save and continue edit","Speichern und weiter bearbeiten"
|
31 |
+
"Save FAQ item","FAQ-Eintrag speichern"
|
32 |
+
"Status","Status"
|
33 |
+
"Store view","StoreView"
|
34 |
+
"There are no FAQ items at the moment.","Zur Zeit sind keine FAQ-Einträge verfügbar."
|
35 |
+
"Question","Frage"
|
36 |
+
"Total %d records found","Insgesamt %s Datensätze gefunden"
|
37 |
+
"View","Zeige"
|
38 |
+
"Yes","Ja"
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Flagbit_Faq</name>
|
4 |
+
<version>1.0.4</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>A FAQ module.</summary>
|
10 |
+
<description>A FAQ module.</description>
|
11 |
+
<notes>* Initial Release</notes>
|
12 |
+
<authors><author><name>Flagbit GmbH </name><user>auto-converted</user><email>magento@flagbit.de</email></author></authors>
|
13 |
+
<date>2010-06-17</date>
|
14 |
+
<time>13:27:32</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Flagbit"><dir name="Faq"><dir name="Block"><dir name="Admin"><dir name="Edit"><dir name="Tab"><file name="Main.php" hash="ec7b6f503fec43e0929f324884bcffff"/></dir><file name="Form.php" hash="164c6bc7663b0f1c107f912e461fe92d"/><file name="Tabs.php" hash="394e0b7b146aa0cb36000d846e163548"/></dir><dir name="List"><file name="Grid.php" hash="714aea6372f00a80cadc20859d2cad48"/></dir><file name="Edit.php" hash="41630762b789d7006ee7d9e53cfbef87"/><file name="List.php" hash="a3c461f3afef73be3e62e75cf6f1abfe"/></dir><dir name="Frontend"><file name="Detail.php" hash="a89de3dd01574b44c056aff952bfb03d"/><file name="list.php" hash="df3fadfe1ffa13c2ccc34d1f03881ac8"/></dir></dir><dir name="controllers"><file name="AdminController.php" hash="375f4c22c589a53abfbc5a217ef81c58"/><file name="IndexController.php" hash="8853a81a89aff92db99a4611d54854bd"/></dir><dir name="etc"><file name="config.xml" hash="9e9f41bc66c17188e56e85ce89f97710"/></dir><dir name="Helper"><file name="Data.php" hash="109f9cf7f512c3c677c9c0be21513eae"/><file name="Jumplist.php" hash="df7c4f69b3d71e889860cba0d2a75eb4"/><file name="JumplistItem.php" hash="73f7308bd6a910bda62423b185deb55c"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Faq"><file name="Collection.php" hash="1040f4805227c98df7be62e9eac6b721"/></dir><file name="Faq.php" hash="609b78aacd0d22eba19ede9411a98f64"/></dir><file name="Faq.php" hash="7fee688354c76e062307a909adc68b98"/></dir><dir name="sql"><dir name="faq_setup"><file name="mysql4-install-0.1.0.php" hash="887d39b5a8f4d0e3aa646c1bafcee9c6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Flagbit_Faq.xml" hash="b1bc7346cc6d7d269be61274c8a9a2ce"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="faq.xml" hash="0ef2e195efb5ec6c96d20b579cb35a3d"/></dir><dir name="template"><dir name="faq"><file name="detail.phtml" hash="163e2815894ae749848a462b31a60f21"/><file name="list.phtml" hash="77be2805973d5ee6b97c92838ae9523d"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Flagbit_Faq.csv" hash="e569564c615509a4ee5bdfb844ec27d6"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|