Version Notes
Stable Version of Magento Accordion Faq
Download this release
Release Info
Developer | Hire Magento Inc. |
Extension | magento_accordion_faq |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/HM/Faq/Block/Adminhtml/Category.php +41 -0
- app/code/community/HM/Faq/Block/Adminhtml/Category/Edit.php +74 -0
- app/code/community/HM/Faq/Block/Adminhtml/Category/Edit/Form.php +31 -0
- app/code/community/HM/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php +78 -0
- app/code/community/HM/Faq/Block/Adminhtml/Category/Edit/Tabs.php +50 -0
- app/code/community/HM/Faq/Block/Adminhtml/Category/Grid.php +163 -0
- app/code/community/HM/Faq/Block/Adminhtml/Item.php +41 -0
- app/code/community/HM/Faq/Block/Adminhtml/Item/Edit.php +88 -0
- app/code/community/HM/Faq/Block/Adminhtml/Item/Edit/Form.php +31 -0
- app/code/community/HM/Faq/Block/Adminhtml/Item/Edit/Tab/Form.php +138 -0
- app/code/community/HM/Faq/Block/Adminhtml/Item/Edit/Tabs.php +50 -0
- app/code/community/HM/Faq/Block/Adminhtml/Item/Grid.php +151 -0
- app/code/community/HM/Faq/Block/Frontend/Detail.php +232 -0
- app/code/community/HM/Faq/Block/Frontend/List.php +140 -0
- app/code/community/HM/Faq/Helper/Data.php +27 -0
- app/code/community/HM/Faq/Helper/Jumplist.php +93 -0
- app/code/community/HM/Faq/Helper/JumplistItem.php +136 -0
- app/code/community/HM/Faq/Model/Category.php +40 -0
- app/code/community/HM/Faq/Model/Faq.php +22 -0
- app/code/community/HM/Faq/Model/Mysql4/Category.php +103 -0
- app/code/community/HM/Faq/Model/Mysql4/Category/Collection.php +105 -0
- app/code/community/HM/Faq/Model/Mysql4/Faq.php +140 -0
- app/code/community/HM/Faq/Model/Mysql4/Faq/Collection.php +132 -0
- app/code/community/HM/Faq/Wysiwyg/Images/Content.php +161 -0
- app/code/community/HM/Faq/Wysiwyg/Images/Content/Files.php +155 -0
- app/code/community/HM/Faq/Wysiwyg/Images/Content/Newfolder.php +37 -0
- app/code/community/HM/Faq/Wysiwyg/Images/Content/Uploader.php +71 -0
- app/code/community/HM/Faq/Wysiwyg/Images/Tree.php +99 -0
- app/code/community/HM/Faq/controllers/Adminhtml/Faq/CategoryController.php +189 -0
- app/code/community/HM/Faq/controllers/Adminhtml/FaqController.php +191 -0
- app/code/community/HM/Faq/controllers/IndexController.php +31 -0
- app/code/community/HM/Faq/etc/adminhtml.xml +46 -0
- app/code/community/HM/Faq/etc/config.xml +142 -0
- app/code/community/HM/Faq/sql/faq_setup/mysql4-install-0.1.0.php +34 -0
- app/code/community/HM/Faq/sql/faq_setup/mysql4-install-1.0.7.php +64 -0
- app/code/community/HM/Faq/sql/faq_setup/mysql4-upgrade-1.0.6-1.0.7.php +49 -0
- app/design/adminhtml/default/default/layout/faq.xml +30 -0
- app/design/frontend/base/default/layout/faq.xml +17 -0
- app/design/frontend/base/default/template/faq/detail.phtml +34 -0
- app/design/frontend/base/default/template/faq/list.phtml +83 -0
- app/etc/modules/HM_Faq.xml +9 -0
- package.xml +18 -0
- skin/frontend/base/default/css/hm/style.css +21 -0
- skin/frontend/base/default/css/hm/toggle-minus.png +0 -0
- skin/frontend/base/default/css/hm/toggle-plus.png +0 -0
app/code/community/HM/Faq/Block/Adminhtml/Category.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Category extends Mage_Adminhtml_Block_Widget_Grid_Container
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor for FAQ Adminhtml Block
|
17 |
+
*/
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
$this->_blockGroup = 'hm_faq';
|
21 |
+
$this->_controller = 'adminhtml_category';
|
22 |
+
$this->_headerText = Mage::helper('hm_faq')->__('Manage FAQ Categories');
|
23 |
+
$this->_addButtonLabel = Mage::helper('hm_faq')->__('Add New FAQ Category');
|
24 |
+
|
25 |
+
parent::__construct();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns the CSS class for the header
|
30 |
+
*
|
31 |
+
* Usually 'icon-head' and a more precise class is returned. We return
|
32 |
+
* only an empty string to avoid spacing on the left of the header as we
|
33 |
+
* don't have an icon.
|
34 |
+
*
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function getHeaderCssClass()
|
38 |
+
{
|
39 |
+
return '';
|
40 |
+
}
|
41 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Category/Edit.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Category_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor for the FAQ edit form
|
17 |
+
*/
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
$this->_objectId = 'category_id';
|
21 |
+
$this->_blockGroup = 'hm_faq';
|
22 |
+
$this->_controller = 'adminhtml_category';
|
23 |
+
|
24 |
+
parent::__construct();
|
25 |
+
|
26 |
+
$this->_updateButton('save', 'label', Mage::helper('hm_faq')->__('Save FAQ Category'));
|
27 |
+
$this->_updateButton('delete', 'label', Mage::helper('hm_faq')->__('Delete FAQ Category'));
|
28 |
+
|
29 |
+
$this->_addButton('saveandcontinue', array (
|
30 |
+
'label' => Mage::helper('hm_faq')->__('Save and continue edit'),
|
31 |
+
'onclick' => 'saveAndContinueEdit()',
|
32 |
+
'class' => 'save' ), -100);
|
33 |
+
|
34 |
+
$this->_formScripts[] = "
|
35 |
+
function saveAndContinueEdit(){
|
36 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
37 |
+
}
|
38 |
+
";
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Helper function to edit the header of the current form
|
43 |
+
*
|
44 |
+
* @return string Returns an "edit" or "new" text depending on the type of modifications.
|
45 |
+
*/
|
46 |
+
public function getHeaderText()
|
47 |
+
{
|
48 |
+
if (Mage::registry('faq_category')->getFaqId()) {
|
49 |
+
return Mage::helper('hm_faq')->__("Edit FAQ Category '%s'", $this->htmlEscape(Mage::registry('faq_category')->getCategoryName()));
|
50 |
+
}
|
51 |
+
else {
|
52 |
+
return Mage::helper('hm_faq')->__('New FAQ Category');
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getFormActionUrl()
|
57 |
+
{
|
58 |
+
return $this->getUrl('*/*/save');
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Returns the CSS class for the header
|
63 |
+
*
|
64 |
+
* Usually 'icon-head' and a more precise class is returned. We return
|
65 |
+
* only an empty string to avoid spacing on the left of the header as we
|
66 |
+
* don't have an icon.
|
67 |
+
*
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
public function getHeaderCssClass()
|
71 |
+
{
|
72 |
+
return '';
|
73 |
+
}
|
74 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Category/Edit/Form.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Category_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Preperation of current form
|
17 |
+
*
|
18 |
+
* @return HM_Faq_Block_Adminhtml_Category_Edit_Form
|
19 |
+
*/
|
20 |
+
protected function _prepareForm()
|
21 |
+
{
|
22 |
+
$form = new Varien_Data_Form(array (
|
23 |
+
'id' => 'edit_form',
|
24 |
+
'action' => $this->getData('action'),
|
25 |
+
'method' => 'post',
|
26 |
+
'enctype' => 'multipart/form-data' ));
|
27 |
+
$form->setUseContainer(true);
|
28 |
+
$this->setForm($form);
|
29 |
+
return parent::_prepareForm();
|
30 |
+
}
|
31 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Category_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Preparation of current form
|
17 |
+
*
|
18 |
+
* @return HM_Faq_Block_Adminhtml_Category_Edit_Tab_Main
|
19 |
+
*/
|
20 |
+
protected function _prepareForm()
|
21 |
+
{
|
22 |
+
$model = Mage::registry('faq_category');
|
23 |
+
|
24 |
+
$form = new Varien_Data_Form();
|
25 |
+
$form->setHtmlIdPrefix('faq_');
|
26 |
+
|
27 |
+
$fieldset = $form->addFieldset('base_fieldset', array (
|
28 |
+
'legend' => Mage::helper('hm_faq')->__('General information'),
|
29 |
+
'class' => 'fieldset-wide' ));
|
30 |
+
|
31 |
+
if ($model->getCategoryId()) {
|
32 |
+
$fieldset->addField('category_id', 'hidden', array (
|
33 |
+
'name' => 'category_id'
|
34 |
+
));
|
35 |
+
}
|
36 |
+
|
37 |
+
$fieldset->addField('category_name', 'text', array (
|
38 |
+
'name' => 'category_name',
|
39 |
+
'label' => Mage::helper('hm_faq')->__('Category Name'),
|
40 |
+
'title' => Mage::helper('hm_faq')->__('Category Name'),
|
41 |
+
'required' => true,
|
42 |
+
));
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Check is single store mode
|
46 |
+
*/
|
47 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
48 |
+
$fieldset->addField('store_id', 'multiselect',
|
49 |
+
array (
|
50 |
+
'name' => 'stores[]',
|
51 |
+
'label' => Mage::helper('cms')->__('Store view'),
|
52 |
+
'title' => Mage::helper('cms')->__('Store view'),
|
53 |
+
'required' => true,
|
54 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ));
|
55 |
+
}
|
56 |
+
else {
|
57 |
+
$fieldset->addField('store_id', 'hidden', array (
|
58 |
+
'name' => 'stores[]',
|
59 |
+
'value' => Mage::app()->getStore(true)->getId() ));
|
60 |
+
$model->setStoreId(Mage::app()->getStore(true)->getId());
|
61 |
+
}
|
62 |
+
|
63 |
+
$fieldset->addField('is_active', 'select',
|
64 |
+
array (
|
65 |
+
'label' => Mage::helper('cms')->__('Status'),
|
66 |
+
'title' => Mage::helper('hm_faq')->__('Category Status'),
|
67 |
+
'name' => 'is_active',
|
68 |
+
'required' => true,
|
69 |
+
'options' => array (
|
70 |
+
'1' => Mage::helper('cms')->__('Enabled'),
|
71 |
+
'0' => Mage::helper('cms')->__('Disabled') ) ));
|
72 |
+
|
73 |
+
$form->setValues($model->getData());
|
74 |
+
$this->setForm($form);
|
75 |
+
|
76 |
+
return parent::_prepareForm();
|
77 |
+
}
|
78 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Category/Edit/Tabs.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Category_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructs current object
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
$this->setId('faq_tabs');
|
23 |
+
$this->setDestElementId('edit_form');
|
24 |
+
$this->setTitle(Mage::helper('hm_faq')->__('Category Information'));
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Prepares the page layout
|
29 |
+
*
|
30 |
+
* Adds the tabs to the left tab menu.
|
31 |
+
*
|
32 |
+
* @return HM_Faq_Block_Adminhtml_Category_Edit_Tabs
|
33 |
+
*/
|
34 |
+
protected function _prepareLayout()
|
35 |
+
{
|
36 |
+
$return = parent::_prepareLayout();
|
37 |
+
|
38 |
+
$this->addTab(
|
39 |
+
'main_section',
|
40 |
+
array(
|
41 |
+
'label' => Mage::helper('hm_faq')->__('General information'),
|
42 |
+
'title' => Mage::helper('hm_faq')->__('General information'),
|
43 |
+
'content' => $this->getLayout()->createBlock('hm_faq/adminhtml_category_edit_tab_form')->toHtml(),
|
44 |
+
'active' => true,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
return $return;
|
49 |
+
}
|
50 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Category/Grid.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Category_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor of Grid
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
$this->setId('faq_grid');
|
23 |
+
$this->setUseAjax(false);
|
24 |
+
$this->setDefaultSort('creation_time');
|
25 |
+
$this->setDefaultDir('DESC');
|
26 |
+
$this->setSaveParametersInSession(true);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Preparation of the data that is displayed by the grid.
|
31 |
+
*
|
32 |
+
* @return HM_Faq_Block_Admin_Grid Self
|
33 |
+
*/
|
34 |
+
protected function _prepareCollection()
|
35 |
+
{
|
36 |
+
$collection = Mage::getResourceModel('hm_faq/category_collection');
|
37 |
+
$this->setCollection($collection);
|
38 |
+
return parent::_prepareCollection();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Preparation of the requested columns of the grid
|
43 |
+
*
|
44 |
+
* @return HM_Faq_Block_Admin_Grid Self
|
45 |
+
*/
|
46 |
+
protected function _prepareColumns()
|
47 |
+
{
|
48 |
+
$this->addColumn('category_id', array (
|
49 |
+
'header' => Mage::helper('hm_faq')->__('Category #'),
|
50 |
+
'width' => '80px',
|
51 |
+
'type' => 'text',
|
52 |
+
'index' => 'category_id' ));
|
53 |
+
|
54 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
55 |
+
$this->addColumn('store_id',
|
56 |
+
array (
|
57 |
+
'header' => Mage::helper('cms')->__('Store view'),
|
58 |
+
'index' => 'store_id',
|
59 |
+
'type' => 'store',
|
60 |
+
'store_all' => true,
|
61 |
+
'store_view' => true,
|
62 |
+
'sortable' => false,
|
63 |
+
'filter_condition_callback' => array (
|
64 |
+
$this,
|
65 |
+
'_filterStoreCondition' ) ));
|
66 |
+
}
|
67 |
+
|
68 |
+
$this->addColumn(
|
69 |
+
'category_name',
|
70 |
+
array(
|
71 |
+
'header' => Mage::helper('hm_faq')->__('Category Name'),
|
72 |
+
'index' => 'category_name',
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->addColumn('is_active',
|
77 |
+
array (
|
78 |
+
'header' => Mage::helper('cms')->__('Active'),
|
79 |
+
'index' => 'is_active',
|
80 |
+
'type' => 'options',
|
81 |
+
'width' => '70px',
|
82 |
+
'options' => array (
|
83 |
+
0 => Mage::helper('cms')->__('No'),
|
84 |
+
1 => Mage::helper('cms')->__('Yes') ) ));
|
85 |
+
|
86 |
+
$this->addColumn(
|
87 |
+
'action',
|
88 |
+
array (
|
89 |
+
'header' => Mage::helper('hm_faq')->__('Action'),
|
90 |
+
'width' => '50px',
|
91 |
+
'type' => 'action',
|
92 |
+
'getter' => 'getId',
|
93 |
+
'actions' => array (
|
94 |
+
array (
|
95 |
+
'caption' => Mage::helper('hm_faq')->__('Edit'),
|
96 |
+
'url' => array (
|
97 |
+
'base' => '*/*/edit'
|
98 |
+
),
|
99 |
+
'field' => 'category_id'
|
100 |
+
),
|
101 |
+
),
|
102 |
+
'filter' => false,
|
103 |
+
'sortable' => false,
|
104 |
+
'index' => 'stores',
|
105 |
+
'is_system' => true,
|
106 |
+
)
|
107 |
+
);
|
108 |
+
|
109 |
+
return parent::_prepareColumns();
|
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 |
+
* Helper function to add store filter condition
|
124 |
+
*
|
125 |
+
* @param Mage_Core_Model_Mysql4_Collection_Abstract $collection Data collection
|
126 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column Column information to be filtered
|
127 |
+
*/
|
128 |
+
protected function _filterStoreCondition($collection, $column)
|
129 |
+
{
|
130 |
+
if (!$value = $column->getFilter()->getValue()) {
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
$this->getCollection()->addStoreFilter($value);
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Helper function to reveive on row click url
|
139 |
+
*
|
140 |
+
* @param HM_Faq_Model_Faq $row Current rows dataset
|
141 |
+
* @return string URL for current row's onclick event
|
142 |
+
*/
|
143 |
+
public function getRowUrl($row)
|
144 |
+
{
|
145 |
+
return $this->getUrl('*/*/edit', array (
|
146 |
+
'category_id' => $row->getCategoryId() ));
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Helper function to receive grid functionality urls for current grid
|
151 |
+
*
|
152 |
+
* @return string Requested URL
|
153 |
+
*/
|
154 |
+
public function getGridUrl()
|
155 |
+
{
|
156 |
+
return $this->getUrl(
|
157 |
+
'*/*/',
|
158 |
+
array (
|
159 |
+
'_current' => true,
|
160 |
+
)
|
161 |
+
);
|
162 |
+
}
|
163 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Item.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Item extends Mage_Adminhtml_Block_Widget_Grid_Container
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor for FAQ Adminhtml Block
|
17 |
+
*/
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
$this->_blockGroup = 'hm_faq';
|
21 |
+
$this->_controller = 'adminhtml_item';
|
22 |
+
$this->_headerText = Mage::helper('hm_faq')->__('Manage FAQ Items');
|
23 |
+
$this->_addButtonLabel = Mage::helper('hm_faq')->__('Add New FAQ Item');
|
24 |
+
|
25 |
+
parent::__construct();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Returns the CSS class for the header
|
30 |
+
*
|
31 |
+
* Usually 'icon-head' and a more precise class is returned. We return
|
32 |
+
* only an empty string to avoid spacing on the left of the header as we
|
33 |
+
* don't have an icon.
|
34 |
+
*
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function getHeaderCssClass()
|
38 |
+
{
|
39 |
+
return '';
|
40 |
+
}
|
41 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Item/Edit.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Item_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor for the FAQ edit form
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
$this->_objectId = 'faq_id';
|
22 |
+
$this->_blockGroup = 'hm_faq';
|
23 |
+
$this->_controller = 'adminhtml_item';
|
24 |
+
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
$this->_updateButton('save', 'label', Mage::helper('hm_faq')->__('Save FAQ item'));
|
28 |
+
$this->_updateButton('delete', 'label', Mage::helper('hm_faq')->__('Delete FAQ item'));
|
29 |
+
|
30 |
+
$this->_addButton('saveandcontinue', array (
|
31 |
+
'label' => Mage::helper('hm_faq')->__('Save and continue edit'),
|
32 |
+
'onclick' => 'saveAndContinueEdit()',
|
33 |
+
'class' => 'save' ), -100);
|
34 |
+
|
35 |
+
$this->_formScripts[] = "
|
36 |
+
function toggleEditor() {
|
37 |
+
if (tinyMCE.getInstanceById('block_content') == null) {
|
38 |
+
tinyMCE.execCommand('mceAddControl', false, 'block_content');
|
39 |
+
} else {
|
40 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'block_content');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
function saveAndContinueEdit(){
|
44 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
45 |
+
}
|
46 |
+
";
|
47 |
+
}
|
48 |
+
protected function _prepareLayout() {
|
49 |
+
parent::_prepareLayout();
|
50 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
51 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Helper function to edit the header of the current form
|
57 |
+
*
|
58 |
+
* @return string Returns an "edit" or "new" text depending on the type of modifications.
|
59 |
+
*/
|
60 |
+
public function getHeaderText()
|
61 |
+
{
|
62 |
+
if (Mage::registry('faq')->getFaqId()) {
|
63 |
+
return Mage::helper('hm_faq')->__("Edit FAQ item '%s'", $this->htmlEscape(Mage::registry('faq')->getQuestion()));
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
return Mage::helper('hm_faq')->__('New FAQ item');
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
public function getFormActionUrl()
|
71 |
+
{
|
72 |
+
return $this->getUrl('*/faq/save');
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Returns the CSS class for the header
|
77 |
+
*
|
78 |
+
* Usually 'icon-head' and a more precise class is returned. We return
|
79 |
+
* only an empty string to avoid spacing on the left of the header as we
|
80 |
+
* don't have an icon.
|
81 |
+
*
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function getHeaderCssClass()
|
85 |
+
{
|
86 |
+
return '';
|
87 |
+
}
|
88 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Item/Edit/Form.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Item_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Preperation of current form
|
17 |
+
*
|
18 |
+
* @return HM_Faq_Block_Adminhtml_Item_Edit_Form
|
19 |
+
*/
|
20 |
+
protected function _prepareForm()
|
21 |
+
{
|
22 |
+
$form = new Varien_Data_Form(array (
|
23 |
+
'id' => 'edit_form',
|
24 |
+
'action' => $this->getData('action'),
|
25 |
+
'method' => 'post',
|
26 |
+
'enctype' => 'multipart/form-data' ));
|
27 |
+
$form->setUseContainer(true);
|
28 |
+
$this->setForm($form);
|
29 |
+
return parent::_prepareForm();
|
30 |
+
}
|
31 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Item/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Item_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Prepares the page layout
|
17 |
+
*
|
18 |
+
* Loads the WYSIWYG editor on demand if enabled.
|
19 |
+
*
|
20 |
+
* @return HM_Faq_Block_Admin_Edit
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Preparation of current form
|
26 |
+
*
|
27 |
+
* @return HM_Faq_Block_Admin_Edit_Tab_Main Self
|
28 |
+
*/
|
29 |
+
protected function _prepareForm()
|
30 |
+
{
|
31 |
+
$model = Mage::registry('faq');
|
32 |
+
|
33 |
+
$form = new Varien_Data_Form();
|
34 |
+
$form->setHtmlIdPrefix('faq_');
|
35 |
+
$wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
|
36 |
+
|
37 |
+
array('tab_id' => 'form_section')
|
38 |
+
|
39 |
+
);
|
40 |
+
|
41 |
+
$wysiwygConfig["files_browser_window_url"] = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index');
|
42 |
+
|
43 |
+
$wysiwygConfig["directives_url"] = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive');
|
44 |
+
|
45 |
+
$wysiwygConfig["directives_url_quoted"] = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive');
|
46 |
+
|
47 |
+
$wysiwygConfig["widget_window_url"] = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/widget/index');
|
48 |
+
|
49 |
+
$wysiwygConfig["files_browser_window_width"] = (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width');
|
50 |
+
|
51 |
+
$wysiwygConfig["files_browser_window_height"] = (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height');
|
52 |
+
|
53 |
+
$plugins = $wysiwygConfig->getData("plugins");
|
54 |
+
|
55 |
+
$plugins[0]["options"]["url"] = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/system_variable/wysiwygPlugin');
|
56 |
+
|
57 |
+
$plugins[0]["options"]["onclick"]["subject"] = "MagentovariablePlugin.loadChooser('".Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/system_variable/wysiwygPlugin')."', '{{html_id}}');";
|
58 |
+
|
59 |
+
$plugins = $wysiwygConfig->setData("plugins",$plugins);
|
60 |
+
$fieldset = $form->addFieldset('base_fieldset', array (
|
61 |
+
'legend' => Mage::helper('hm_faq')->__('General information'),
|
62 |
+
'class' => 'fieldset-wide' ));
|
63 |
+
|
64 |
+
if ($model->getFaqId()) {
|
65 |
+
$fieldset->addField('faq_id', 'hidden', array (
|
66 |
+
'name' => 'faq_id' ));
|
67 |
+
}
|
68 |
+
|
69 |
+
$fieldset->addField('question', 'text', array (
|
70 |
+
'name' => 'question',
|
71 |
+
'label' => Mage::helper('hm_faq')->__('FAQ item question'),
|
72 |
+
'title' => Mage::helper('hm_faq')->__('FAQ item question'),
|
73 |
+
'required' => true ));
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Check is single store mode
|
77 |
+
*/
|
78 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
79 |
+
$fieldset->addField('store_id', 'multiselect',
|
80 |
+
array (
|
81 |
+
'name' => 'stores[]',
|
82 |
+
'label' => Mage::helper('cms')->__('Store view'),
|
83 |
+
'title' => Mage::helper('cms')->__('Store view'),
|
84 |
+
'required' => true,
|
85 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true) ));
|
86 |
+
}
|
87 |
+
else {
|
88 |
+
$fieldset->addField('store_id', 'hidden', array (
|
89 |
+
'name' => 'stores[]',
|
90 |
+
'value' => Mage::app()->getStore(true)->getId() ));
|
91 |
+
$model->setStoreId(Mage::app()->getStore(true)->getId());
|
92 |
+
}
|
93 |
+
|
94 |
+
$fieldset->addField('is_active', 'select',
|
95 |
+
array (
|
96 |
+
'label' => Mage::helper('cms')->__('Status'),
|
97 |
+
'title' => Mage::helper('hm_faq')->__('Item status'),
|
98 |
+
'name' => 'is_active',
|
99 |
+
'required' => true,
|
100 |
+
'options' => array (
|
101 |
+
'1' => Mage::helper('cms')->__('Enabled'),
|
102 |
+
'0' => Mage::helper('cms')->__('Disabled') ) ));
|
103 |
+
|
104 |
+
/*$fieldset->addField('category_id', 'multiselect',
|
105 |
+
array (
|
106 |
+
'label' => Mage::helper('hm_faq')->__('Category'),
|
107 |
+
'title' => Mage::helper('hm_faq')->__('Category'),
|
108 |
+
'name' => 'categories[]',
|
109 |
+
'required' => false,
|
110 |
+
'values' => Mage::getResourceSingleton('hm_faq/category_collection')->toOptionArray(),
|
111 |
+
)
|
112 |
+
);*/
|
113 |
+
|
114 |
+
$fieldset->addField('answer', 'editor',
|
115 |
+
array (
|
116 |
+
'name' => 'answer',
|
117 |
+
'label' => Mage::helper('hm_faq')->__('Content'),
|
118 |
+
'title' => Mage::helper('hm_faq')->__('Content'),
|
119 |
+
'style' => 'height:36em;',
|
120 |
+
'config' => $wysiwygConfig,
|
121 |
+
'required' => true ));
|
122 |
+
|
123 |
+
$fieldset->addField('answer_html', 'select',
|
124 |
+
array (
|
125 |
+
'label' => Mage::helper('hm_faq')->__('HTML answer'),
|
126 |
+
'title' => Mage::helper('hm_faq')->__('HTML answer'),
|
127 |
+
'name' => 'answer_html',
|
128 |
+
'required' => true,
|
129 |
+
'options' => array (
|
130 |
+
'1' => Mage::helper('cms')->__('Enabled'),
|
131 |
+
'0' => Mage::helper('cms')->__('Disabled') ) ));
|
132 |
+
|
133 |
+
$form->setValues($model->getData());
|
134 |
+
$this->setForm($form);
|
135 |
+
|
136 |
+
return parent::_prepareForm();
|
137 |
+
}
|
138 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Item/Edit/Tabs.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Item_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructs current object
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
$this->setId('faq_tabs');
|
23 |
+
$this->setDestElementId('edit_form');
|
24 |
+
$this->setTitle(Mage::helper('hm_faq')->__('FAQ item information'));
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Prepares the page layout
|
29 |
+
*
|
30 |
+
* Adds the tabs to the left tab menu.
|
31 |
+
*
|
32 |
+
* @return HM_Faq_Block_Admin_Edit
|
33 |
+
*/
|
34 |
+
protected function _prepareLayout()
|
35 |
+
{
|
36 |
+
$return = parent::_prepareLayout();
|
37 |
+
|
38 |
+
$this->addTab(
|
39 |
+
'main_section',
|
40 |
+
array(
|
41 |
+
'label' => Mage::helper('hm_faq')->__('General information'),
|
42 |
+
'title' => Mage::helper('hm_faq')->__('General information'),
|
43 |
+
'content' => $this->getLayout()->createBlock('hm_faq/adminhtml_item_edit_tab_form')->toHtml(),
|
44 |
+
'active' => true,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
return $return;
|
49 |
+
}
|
50 |
+
}
|
app/code/community/HM/Faq/Block/Adminhtml/Item/Grid.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Adminhtml_Item_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor of Grid
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct();
|
22 |
+
$this->setId('faq_grid');
|
23 |
+
$this->setUseAjax(false);
|
24 |
+
$this->setDefaultSort('creation_time');
|
25 |
+
$this->setDefaultDir('DESC');
|
26 |
+
$this->setSaveParametersInSession(true);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Preparation of the data that is displayed by the grid.
|
31 |
+
*
|
32 |
+
* @return HM_Faq_Block_Admin_Grid Self
|
33 |
+
*/
|
34 |
+
protected function _prepareCollection()
|
35 |
+
{
|
36 |
+
//TODO: add full name logic
|
37 |
+
$collection = Mage::getResourceModel('hm_faq/faq_collection');
|
38 |
+
$this->setCollection($collection);
|
39 |
+
#Mage::Log($collection->getData());
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Preparation of the requested columns of the grid
|
45 |
+
*
|
46 |
+
* @return HM_Faq_Block_Admin_Grid Self
|
47 |
+
*/
|
48 |
+
protected function _prepareColumns()
|
49 |
+
{
|
50 |
+
$this->addColumn('faq_id', array (
|
51 |
+
'header' => Mage::helper('hm_faq')->__('FAQ #'),
|
52 |
+
'width' => '80px',
|
53 |
+
'type' => 'text',
|
54 |
+
'index' => 'faq_id' ));
|
55 |
+
|
56 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
57 |
+
$this->addColumn('store_id',
|
58 |
+
array (
|
59 |
+
'header' => Mage::helper('cms')->__('Store view'),
|
60 |
+
'index' => 'store_id',
|
61 |
+
'type' => 'store',
|
62 |
+
'store_all' => true,
|
63 |
+
'store_view' => true,
|
64 |
+
'sortable' => false,
|
65 |
+
'filter_condition_callback' => array (
|
66 |
+
$this,
|
67 |
+
'_filterStoreCondition' ) ));
|
68 |
+
}
|
69 |
+
|
70 |
+
$this->addColumn('question', array (
|
71 |
+
'header' => Mage::helper('hm_faq')->__('Question'),
|
72 |
+
'index' => 'question' ));
|
73 |
+
|
74 |
+
$this->addColumn('is_active',
|
75 |
+
array (
|
76 |
+
'header' => Mage::helper('hm_faq')->__('Status'),
|
77 |
+
'index' => 'is_active',
|
78 |
+
'type' => 'options',
|
79 |
+
'width' => '70px',
|
80 |
+
'options' => array (
|
81 |
+
0 => Mage::helper('hm_faq')->__('No'),
|
82 |
+
1 => Mage::helper('hm_faq')->__('Yes') ) ));
|
83 |
+
|
84 |
+
$this->addColumn('action',
|
85 |
+
array (
|
86 |
+
'header' => Mage::helper('hm_faq')->__('Action'),
|
87 |
+
'width' => '50px',
|
88 |
+
'type' => 'action',
|
89 |
+
'getter' => 'getId',
|
90 |
+
'actions' => array (
|
91 |
+
array (
|
92 |
+
'caption' => Mage::helper('hm_faq')->__('Edit'),
|
93 |
+
'url' => array (
|
94 |
+
'base' => 'adminhtml/faq/edit' ),
|
95 |
+
'field' => 'faq_id' ) ),
|
96 |
+
'filter' => false,
|
97 |
+
'sortable' => false,
|
98 |
+
'index' => 'stores',
|
99 |
+
'is_system' => true ));
|
100 |
+
|
101 |
+
return parent::_prepareColumns();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Helper function to do after load modifications
|
106 |
+
*
|
107 |
+
*/
|
108 |
+
protected function _afterLoadCollection()
|
109 |
+
{
|
110 |
+
$this->getCollection()->walk('afterLoad');
|
111 |
+
parent::_afterLoadCollection();
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Helper function to add store filter condition
|
116 |
+
*
|
117 |
+
* @param Mage_Core_Model_Mysql4_Collection_Abstract $collection Data collection
|
118 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column Column information to be filtered
|
119 |
+
*/
|
120 |
+
protected function _filterStoreCondition($collection, $column)
|
121 |
+
{
|
122 |
+
if (!$value = $column->getFilter()->getValue()) {
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
$this->getCollection()->addStoreFilter($value);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Helper function to reveive on row click url
|
131 |
+
*
|
132 |
+
* @param HM_Faq_Model_Faq $row Current rows dataset
|
133 |
+
* @return string URL for current row's onclick event
|
134 |
+
*/
|
135 |
+
public function getRowUrl($row)
|
136 |
+
{
|
137 |
+
return $this->getUrl('adminhtml/faq/edit', array (
|
138 |
+
'faq_id' => $row->getFaqId() ));
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Helper function to receive grid functionality urls for current grid
|
143 |
+
*
|
144 |
+
* @return string Requested URL
|
145 |
+
*/
|
146 |
+
public function getGridUrl()
|
147 |
+
{
|
148 |
+
return $this->getUrl('adminhtml/faq/index', array (
|
149 |
+
'_current' => true ));
|
150 |
+
}
|
151 |
+
}
|
app/code/community/HM/Faq/Block/Frontend/Detail.php
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Frontend_Detail extends Mage_Core_Block_Template {
|
14 |
+
|
15 |
+
protected $_faq;
|
16 |
+
protected $_images;
|
17 |
+
|
18 |
+
|
19 |
+
protected function _prepareLayout()
|
20 |
+
{
|
21 |
+
$faq = $this->getFaq();
|
22 |
+
|
23 |
+
if ($faq !== false && $head = $this->getLayout()->getBlock('head')) {
|
24 |
+
$head->setTitle($this->htmlEscape($faq->getQuestion()) . ' - ' . $head->getTitle());
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Function to gather the current faq item
|
30 |
+
*
|
31 |
+
* @return HM_Faq_Model_Faq The current faq item
|
32 |
+
*/
|
33 |
+
public function getFaq() {
|
34 |
+
if (!$this->_faq) {
|
35 |
+
$id = intval($this->getRequest()->getParam('faq'));
|
36 |
+
try {
|
37 |
+
$this->_faq = Mage :: getModel('hm_faq/faq')->load($id);
|
38 |
+
|
39 |
+
if ($this->_faq->getIsActive() != 1){
|
40 |
+
Mage::throwException('Faq Item is not active');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
catch (Exception $e) {
|
44 |
+
$this->_faq = false;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->_faq;
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Extracting available images
|
54 |
+
*
|
55 |
+
* @param string $thumbSize dimensions of thumbnail image (either number of width pixels or {width]x{height}
|
56 |
+
* @param string $imageSize dimensions of detail image (either number of width pixels or {width]x{height}
|
57 |
+
* @return unknown
|
58 |
+
*/
|
59 |
+
public function getImages($thumbSize = null, $imageSize = null) {
|
60 |
+
if (!$faq = $this->getFaq()) {
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
// read images from dataset
|
65 |
+
$images = $faq->getImage();
|
66 |
+
$result = array();
|
67 |
+
|
68 |
+
// if we have found images - process them
|
69 |
+
if (is_array($images) && !empty($images)) {
|
70 |
+
|
71 |
+
// get media model
|
72 |
+
$mediaConfig = Mage :: getSingleton('faq/faq_media_config');
|
73 |
+
$mediaModel = Mage :: getSingleton('media/image')->setConfig($mediaConfig);
|
74 |
+
|
75 |
+
// iterate through images
|
76 |
+
foreach ($images as $image) {
|
77 |
+
|
78 |
+
// only go on if the image can be found
|
79 |
+
if (file_exists(Mage::getBaseDir('media') . DS . 'faq' . DS . $image)) {
|
80 |
+
|
81 |
+
// gather needed information
|
82 |
+
$newImage = array(
|
83 |
+
'original' => $image,
|
84 |
+
'galleryUrl' => $this->getGalleryUrl($image)
|
85 |
+
);
|
86 |
+
|
87 |
+
if ($thumbSize) {
|
88 |
+
$newImage['src'] = $mediaModel->getSpecialLink($image, $thumbSize);
|
89 |
+
}
|
90 |
+
|
91 |
+
if ($imageSize) {
|
92 |
+
$newImage['href'] = $mediaModel->getSpecialLink($image, $imageSize);
|
93 |
+
$newImage['width'] = intval($imageSize);
|
94 |
+
}
|
95 |
+
else {
|
96 |
+
$newImage['href'] = Mage::getBaseUrl('media') . '/faq/' . $image;
|
97 |
+
$newImage['width'] = $mediaModel->setFileName($image)->getDimensions()->getWidth();
|
98 |
+
}
|
99 |
+
|
100 |
+
$result[] = $newImage;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
return $result;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Get gallery link for given image
|
111 |
+
*
|
112 |
+
* @param string $image File name
|
113 |
+
* @return string URL to gallery
|
114 |
+
*/
|
115 |
+
public function getGalleryUrl($image) {
|
116 |
+
$params = array('faq' => $this->getFaq()->getFaqId() . '_' . urlencode(str_replace(array(' ', 'ä', 'ö', 'ü', 'ß'), array('_', 'ae', 'oe', 'ue', 'ss'), (strtolower($this->getFaq()->getQuestion())))));
|
117 |
+
if ($image) {
|
118 |
+
$params['image'] = $image;
|
119 |
+
return $this->getUrl('*/*/gallery', $params);
|
120 |
+
}
|
121 |
+
return $this->getUrl('*/*/gallery', $params);
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Get gallery images for current gallery view
|
127 |
+
*
|
128 |
+
* @param string $type needed Image information type ('previous', 'current' or 'next') - if not given the function returns all of them.
|
129 |
+
* @return array Requested image information
|
130 |
+
*/
|
131 |
+
public function getGalleryImages($type = null) {
|
132 |
+
|
133 |
+
// only do processing once (since parameters don't change during gallery view)
|
134 |
+
if (!$this->_images) {
|
135 |
+
|
136 |
+
// get images and parameters
|
137 |
+
$currentParam = $this->getRequest()->getParam('image');
|
138 |
+
$images = $this->getImages();
|
139 |
+
|
140 |
+
// initialization
|
141 |
+
$result = array(
|
142 |
+
'previous' => NULL,
|
143 |
+
'current' => NULL,
|
144 |
+
'next' => NULL
|
145 |
+
);
|
146 |
+
|
147 |
+
// if we have images -> process them
|
148 |
+
if (is_array($images) && !empty($images)) {
|
149 |
+
$previousImage = null;
|
150 |
+
|
151 |
+
foreach ($images as $image) {
|
152 |
+
|
153 |
+
// if we found the requested pic -> save it
|
154 |
+
// if the requested pic was not found the first pic of the collection is used
|
155 |
+
if ($image['original'] == $currentParam || !$result['current']) {
|
156 |
+
$result['current'] = $image;
|
157 |
+
|
158 |
+
// save the previous image to get back to it
|
159 |
+
$result['previous'] = $previousImage;
|
160 |
+
|
161 |
+
if ($image['original'] == $currentParam) {
|
162 |
+
$current = true;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
// save next image for pagination
|
166 |
+
elseif ($result['current']) {
|
167 |
+
$result['next'] = $image;
|
168 |
+
|
169 |
+
// if we found the requested image -> break
|
170 |
+
if ($current) {
|
171 |
+
break;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
// save current image as previous image for further processing
|
176 |
+
$previousImage = $image;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
// save results in class variable
|
181 |
+
$this->_images = $result;
|
182 |
+
}
|
183 |
+
|
184 |
+
// if the requested type is given - return the image
|
185 |
+
if ($type) {
|
186 |
+
return (isset($this->_images[$type]) ? $this->_images[$type] : false);
|
187 |
+
}
|
188 |
+
|
189 |
+
// if no type given -> return all the three images
|
190 |
+
return $this->_images;
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Gets the current image
|
196 |
+
*
|
197 |
+
* @return array Image information
|
198 |
+
*/
|
199 |
+
public function getCurrentImage() {
|
200 |
+
return $this->getGalleryImages('current');
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Gets the previous image
|
206 |
+
*
|
207 |
+
* @return array Image information
|
208 |
+
*/
|
209 |
+
public function getPreviousImage() {
|
210 |
+
return $this->getGalleryImages('previous');
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Gets the next image
|
216 |
+
*
|
217 |
+
* @return array Image information
|
218 |
+
*/
|
219 |
+
public function getNextImage() {
|
220 |
+
return $this->getGalleryImages('next');
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Returns the current image's width
|
225 |
+
*
|
226 |
+
* @return int Width of current image
|
227 |
+
*/
|
228 |
+
public function getImageWidth() {
|
229 |
+
$current = $this->getCurrentImage();
|
230 |
+
return $current['width'];
|
231 |
+
}
|
232 |
+
}
|
app/code/community/HM/Faq/Block/Frontend/List.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Block_Frontend_List extends Mage_Core_Block_Template
|
14 |
+
{
|
15 |
+
protected $_faqCollection;
|
16 |
+
|
17 |
+
protected function _prepareLayout()
|
18 |
+
{
|
19 |
+
if ($head = $this->getLayout()->getBlock('head')) {
|
20 |
+
$head->setTitle($this->htmlEscape($this->__('Frequently Asked Questions')) . ' - ' . $head->getTitle());
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Returns collection of current FAQ entries
|
26 |
+
*
|
27 |
+
* @param int $pageSize
|
28 |
+
* @return HM_Faq_Model_Mysql_Faq_Collection collection of current FAQ entries
|
29 |
+
*/
|
30 |
+
public function getFaqCollection($pageSize = null)
|
31 |
+
{
|
32 |
+
if (!$this->_faqCollection || (intval($pageSize) > 0
|
33 |
+
&& $this->_faqCollection->getSize() != intval($pageSize))
|
34 |
+
) {
|
35 |
+
$this->_faqCollection = Mage :: getModel('hm_faq/faq')
|
36 |
+
->getCollection()
|
37 |
+
->addStoreFilter(Mage :: app()->getStore())
|
38 |
+
->addIsActiveFilter();
|
39 |
+
|
40 |
+
if (isset($pageSize) && intval($pageSize) && intval($pageSize) > 0) {
|
41 |
+
$this->_faqCollection->setPageSize(intval($pageSize));
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
return $this->_faqCollection;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Returns all active categories
|
50 |
+
*
|
51 |
+
* @return HM_Faq_Model_Mysql4_Category_Collection
|
52 |
+
*/
|
53 |
+
public function getCategoryCollection()
|
54 |
+
{
|
55 |
+
$categories = $this->getData('category_collection');
|
56 |
+
if (is_null($categories)) {
|
57 |
+
$categories = Mage::getResourceSingleton('hm_faq/category_collection')
|
58 |
+
->addStoreFilter(Mage::app()->getStore())
|
59 |
+
->addIsActiveFilter();
|
60 |
+
$this->setData('category_collection', $categories);
|
61 |
+
}
|
62 |
+
return $categories;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Returns the item collection for the given category
|
67 |
+
*
|
68 |
+
* @param HM_Faq_Model_Category $category
|
69 |
+
* @return HM_Faq_Model_Mysql4_Faq_Collection
|
70 |
+
*/
|
71 |
+
public function getItemCollectionByCategory(HM_Faq_Model_Category $category)
|
72 |
+
{
|
73 |
+
return $category->getItemCollection()->addIsActiveFilter()->addStoreFilter(Mage::app()->getStore());
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Simple helper function to determine, whether there are FAQ entries or not.
|
78 |
+
*
|
79 |
+
* @return boolean True, if FAQ are given.
|
80 |
+
*/
|
81 |
+
public function hasFaq()
|
82 |
+
{
|
83 |
+
return $this->getFaqCollection()->getSize() > 0;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getIntro($faqItem)
|
87 |
+
{
|
88 |
+
$_intro = strip_tags($faqItem->getContent());
|
89 |
+
$_intro = mb_substr($_intro, 0, mb_strpos($_intro, "\n"));
|
90 |
+
|
91 |
+
$length = 100 - mb_strlen($faqItem->getQuestion());
|
92 |
+
if ($length < 0) {
|
93 |
+
return '';
|
94 |
+
}
|
95 |
+
if (mb_strlen($_intro) > $length) {
|
96 |
+
$_intro = mb_substr($_intro, 0, $length);
|
97 |
+
$_intro = mb_substr($_intro, 0, mb_strrpos($_intro, ' ')).'...';
|
98 |
+
}
|
99 |
+
|
100 |
+
return $_intro;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns
|
105 |
+
*
|
106 |
+
* @return array
|
107 |
+
*/
|
108 |
+
public function getFaqJumplist()
|
109 |
+
{
|
110 |
+
if(is_null($this->_faqJumplist))
|
111 |
+
{
|
112 |
+
$this->_faqJumplist = Mage::helper('hm_faq/jumplist');
|
113 |
+
$this->_faqJumplist->setFaqItems($this->getFaqCollection());
|
114 |
+
}
|
115 |
+
return $this->_faqJumplist;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Simple helper function to determine, whether we should display a jumplist or not.
|
120 |
+
*
|
121 |
+
* @return boolean True if the jumplist should be displayed
|
122 |
+
*/
|
123 |
+
public function hasFaqJumplist() {
|
124 |
+
// TODO add configuration option to enable/disable jumplist
|
125 |
+
return count($this->getFaqJumplist()) > 0;
|
126 |
+
}
|
127 |
+
|
128 |
+
public function encodeQuestionForUrl($question)
|
129 |
+
{
|
130 |
+
return urlencode(
|
131 |
+
trim(
|
132 |
+
str_replace(
|
133 |
+
array(' ', 'ä', 'ö', 'ü', 'ß', '.', '/', ';', ':', '=', '?', '__'),
|
134 |
+
array('_', 'ae', 'oe', 'ue', 'ss', '_', '', '', '', '', '', '_'),
|
135 |
+
strtolower($question)
|
136 |
+
), ' _'
|
137 |
+
)
|
138 |
+
);
|
139 |
+
}
|
140 |
+
}
|
app/code/community/HM/Faq/Helper/Data.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Helper_Data extends Mage_Core_Helper_Abstract
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Returns config data
|
17 |
+
*
|
18 |
+
* @param string $field Requested field
|
19 |
+
* @return array config Configuration information
|
20 |
+
*/
|
21 |
+
public function getConfigData($field)
|
22 |
+
{
|
23 |
+
$path = 'faq/config/' . $field;
|
24 |
+
$config = Mage::getStoreConfig($path, Mage::app()->getStore());
|
25 |
+
return $config;
|
26 |
+
}
|
27 |
+
}
|
app/code/community/HM/Faq/Helper/Jumplist.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Helper_Jumplist extends Mage_Core_Helper_Abstract implements Countable, Iterator
|
14 |
+
{
|
15 |
+
protected $items = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The "garbage can" for items not fitting in the default range
|
19 |
+
*
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
const KEY_OTHER = 'other';
|
23 |
+
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
// TODO make init range configurable
|
27 |
+
// create items from A (65) to Z (90)
|
28 |
+
for($ord = 65; $ord <= 90; $ord++)
|
29 |
+
{
|
30 |
+
$chr = chr($ord);
|
31 |
+
$this->items[$chr] = new HM_Faq_Helper_JumplistItem($chr);
|
32 |
+
}
|
33 |
+
|
34 |
+
// TODO make configurable if KEY_OTHER is appended or prepended
|
35 |
+
$this->items[self::KEY_OTHER] = new HM_Faq_Helper_JumplistItem(self::KEY_OTHER);
|
36 |
+
}
|
37 |
+
|
38 |
+
public function setFaqItems(HM_Faq_Model_Mysql4_Faq_Collection $items)
|
39 |
+
{
|
40 |
+
foreach($items as $item)
|
41 |
+
{
|
42 |
+
$key = strtoupper(substr($item->getQuestion(), 0, 1));
|
43 |
+
if(!array_key_exists($key, $this->items))
|
44 |
+
{
|
45 |
+
$key = self::KEY_OTHER;
|
46 |
+
}
|
47 |
+
$this->items[$key]->addFaqItem($item);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @see ArrayIterator::current()
|
53 |
+
*/
|
54 |
+
public function current() {
|
55 |
+
return current($this->items);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @see ArrayIterator::key()
|
60 |
+
*/
|
61 |
+
public function key() {
|
62 |
+
return key($this->items);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @see ArrayIterator::next()
|
67 |
+
*/
|
68 |
+
public function next() {
|
69 |
+
return next($this->items);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @see ArrayIterator::rewind()
|
74 |
+
*/
|
75 |
+
public function rewind() {
|
76 |
+
return reset($this->items);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @see ArrayIterator::valid()
|
81 |
+
*/
|
82 |
+
public function valid() {
|
83 |
+
return array_key_exists($this->key(), $this->items);
|
84 |
+
}
|
85 |
+
/**
|
86 |
+
* @see Countable::count()
|
87 |
+
*/
|
88 |
+
public function count() {
|
89 |
+
return count($this->items);
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
}
|
app/code/community/HM/Faq/Helper/JumplistItem.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Helper_JumplistItem extends Mage_Core_Helper_Abstract implements Countable, Iterator
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
protected $label;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var array
|
22 |
+
*/
|
23 |
+
protected $faqItems = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* The constructor
|
27 |
+
*
|
28 |
+
* @param string $label
|
29 |
+
* @param array $faqItems
|
30 |
+
*/
|
31 |
+
public function __construct($label = null, $faqItems = null)
|
32 |
+
{
|
33 |
+
$this->setLabel($label);
|
34 |
+
if(!is_null($faqItems))
|
35 |
+
{
|
36 |
+
$this->setFaqItems($faqItems);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
public function getFaqItems()
|
44 |
+
{
|
45 |
+
return $this->faqItems;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @param array $faqItems
|
50 |
+
*/
|
51 |
+
public function setFaqItems(array $faqItems)
|
52 |
+
{
|
53 |
+
$this->faqItems = $faqItems;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function addFaqItem($item)
|
57 |
+
{
|
58 |
+
$this->faqItems[] = $item;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getLabel()
|
65 |
+
{
|
66 |
+
return $this->label;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param string $label
|
71 |
+
*/
|
72 |
+
public function setLabel($label)
|
73 |
+
{
|
74 |
+
$this->label = (string) $label;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Count elements of the jumplist
|
79 |
+
*
|
80 |
+
* @return int
|
81 |
+
*/
|
82 |
+
public function count()
|
83 |
+
{
|
84 |
+
return count($this->faqItems);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Returns the current element
|
89 |
+
*
|
90 |
+
* @return mixed
|
91 |
+
*/
|
92 |
+
public function current()
|
93 |
+
{
|
94 |
+
return current($this->faqItems);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Returns the key of the current element
|
99 |
+
*
|
100 |
+
* @return scalar
|
101 |
+
*/
|
102 |
+
public function key()
|
103 |
+
{
|
104 |
+
return key($this->faqItems);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Move forward to the next element
|
109 |
+
*
|
110 |
+
* @return void
|
111 |
+
*/
|
112 |
+
public function next()
|
113 |
+
{
|
114 |
+
next($this->faqItems);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Rewind the Iterator to the first element
|
119 |
+
*
|
120 |
+
* @void
|
121 |
+
*/
|
122 |
+
public function rewind()
|
123 |
+
{
|
124 |
+
reset($this->faqItems);
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Checks if current position is valid
|
129 |
+
*
|
130 |
+
* @return boolean
|
131 |
+
*/
|
132 |
+
public function valid()
|
133 |
+
{
|
134 |
+
return array_key_exists($this->key(), $this->faqItems);
|
135 |
+
}
|
136 |
+
}
|
app/code/community/HM/Faq/Model/Category.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
*
|
5 |
+
|
6 |
+
* @copyright Copyright (c) 2010 HM GmbH & Co. KG <magento@hm.de>
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Category Model for FAQ Items
|
11 |
+
*
|
12 |
+
* Website: www.hiremagento.com
|
13 |
+
* Email: hiremagento@gmail.com
|
14 |
+
*/
|
15 |
+
class HM_Faq_Model_Category extends Mage_Core_Model_Abstract
|
16 |
+
{
|
17 |
+
/**
|
18 |
+
* Constructor
|
19 |
+
*/
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('hm_faq/category');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getName()
|
26 |
+
{
|
27 |
+
return $this->getCategoryName();
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getItemCollection()
|
31 |
+
{
|
32 |
+
$collection = $this->getData('item_collection');
|
33 |
+
if (is_null($collection)) {
|
34 |
+
$collection = Mage::getSingleton('hm_faq/faq')->getCollection()
|
35 |
+
->addCategoryFilter($this);
|
36 |
+
$this->setData('item_collection', $collection);
|
37 |
+
}
|
38 |
+
return $collection;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/HM/Faq/Model/Faq.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Model_Faq extends Mage_Core_Model_Abstract
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->_init('hm_faq/faq');
|
21 |
+
}
|
22 |
+
}
|
app/code/community/HM/Faq/Model/Mysql4/Category.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Category Resource Model for FAQ Items
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Constructor
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
$this->_init('hm_faq/category', 'category_id');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Retrieve select object for load object data
|
25 |
+
*
|
26 |
+
* @param string $field
|
27 |
+
* @param mixed $value
|
28 |
+
* @return Zend_Db_Select
|
29 |
+
*/
|
30 |
+
protected function _getLoadSelect($field, $value, $object)
|
31 |
+
{
|
32 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
33 |
+
|
34 |
+
if ($object->getStoreId()) {
|
35 |
+
$select->join(
|
36 |
+
array('nns' => $this->getTable('hm_faq/category_store')),
|
37 |
+
$this->getMainTable() . '.item_id = `nns`.category_id'
|
38 |
+
)->where('is_active=1 AND `nns`.store_id in (0, ?) ',
|
39 |
+
$object->getStoreId())->order('creation_time DESC')->limit(1);
|
40 |
+
}
|
41 |
+
return $select;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Sets the creation and update timestamps
|
46 |
+
*
|
47 |
+
* @param Mage_Core_Model_Abstract $object Current faq category
|
48 |
+
* @return HM_Faq_Model_Mysql4_Category
|
49 |
+
*/
|
50 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object)
|
51 |
+
{
|
52 |
+
if (!$object->getId()) {
|
53 |
+
$object->setCreationTime(Mage::getSingleton('core/date')->gmtDate());
|
54 |
+
}
|
55 |
+
$object->setUpdateTime(Mage::getSingleton('core/date')->gmtDate());
|
56 |
+
|
57 |
+
return parent::_beforeSave($object);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Assign page to store views
|
62 |
+
*
|
63 |
+
* @param Mage_Core_Model_Abstract $object
|
64 |
+
*/
|
65 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
66 |
+
{
|
67 |
+
$condition = $this->_getWriteAdapter()->quoteInto('category_id = ?', $object->getId());
|
68 |
+
$this->_getWriteAdapter()->delete($this->getTable('hm_faq/category_store'), $condition);
|
69 |
+
|
70 |
+
foreach ((array) $object->getData('stores') as $store) {
|
71 |
+
$storeArray = array ();
|
72 |
+
$storeArray['category_id'] = $object->getId();
|
73 |
+
$storeArray['store_id'] = $store;
|
74 |
+
$this->_getWriteAdapter()->insert(
|
75 |
+
$this->getTable('hm_faq/category_store'), $storeArray
|
76 |
+
);
|
77 |
+
}
|
78 |
+
|
79 |
+
return parent::_afterSave($object);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Do store processing after loading
|
84 |
+
*
|
85 |
+
* @param Mage_Core_Model_Abstract $object Current faq item
|
86 |
+
*/
|
87 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
88 |
+
{
|
89 |
+
$select = $this->_getReadAdapter()->select()->from(
|
90 |
+
$this->getTable('hm_faq/category_store')
|
91 |
+
)->where('category_id = ?', $object->getId());
|
92 |
+
|
93 |
+
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
|
94 |
+
$storesArray = array ();
|
95 |
+
foreach ($data as $row) {
|
96 |
+
$storesArray[] = $row['store_id'];
|
97 |
+
}
|
98 |
+
$object->setData('store_id', $storesArray);
|
99 |
+
}
|
100 |
+
|
101 |
+
return parent::_afterLoad($object);
|
102 |
+
}
|
103 |
+
}
|
app/code/community/HM/Faq/Model/Mysql4/Category/Collection.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
14 |
+
{
|
15 |
+
protected $_previewFlag;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructor
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('hm_faq/category');
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Add Filter by store
|
28 |
+
*
|
29 |
+
* @param int|Mage_Core_Model_Store $store Store to be filtered
|
30 |
+
* @return HM_Faq_Model_Mysql4_Category_Collection
|
31 |
+
*/
|
32 |
+
public function addStoreFilter($store)
|
33 |
+
{
|
34 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
35 |
+
$store = array($store->getId());
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->getSelect()->join(
|
39 |
+
array('store_table' => $this->getTable('hm_faq/category_store')),
|
40 |
+
'main_table.category_id = store_table.category_id',
|
41 |
+
array ()
|
42 |
+
)->where('store_table.store_id in (?)', array (
|
43 |
+
0,
|
44 |
+
$store
|
45 |
+
))->group('main_table.category_id');
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* After load processing - adds store information to the datasets
|
53 |
+
*
|
54 |
+
*/
|
55 |
+
protected function _afterLoad()
|
56 |
+
{
|
57 |
+
if ($this->_previewFlag) {
|
58 |
+
$items = $this->getColumnValues('faq_id');
|
59 |
+
if (count($items)) {
|
60 |
+
$select = $this->getConnection()->select()->from(
|
61 |
+
$this->getTable('hm_faq/category_store')
|
62 |
+
)->where(
|
63 |
+
$this->getTable('hm_faq/category_store') . '.category_id IN (?)',
|
64 |
+
$items
|
65 |
+
);
|
66 |
+
if ($result = $this->getConnection()->fetchPairs($select)) {
|
67 |
+
foreach ($this as $item) {
|
68 |
+
if (!isset($result[$item->getData('category_id')])) {
|
69 |
+
continue;
|
70 |
+
}
|
71 |
+
if ($result[$item->getData('category_id')] == 0) {
|
72 |
+
$stores = Mage::app()->getStores(false, true);
|
73 |
+
$storeId = current($stores)->getId();
|
74 |
+
$storeCode = key($stores);
|
75 |
+
}
|
76 |
+
else {
|
77 |
+
$storeId = $result[$item->getData('category_id')];
|
78 |
+
$storeCode = Mage::app()->getStore($storeId)->getCode();
|
79 |
+
}
|
80 |
+
$item->setData('_first_store_id', $storeId);
|
81 |
+
$item->setData('store_code', $storeCode);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
parent::_afterLoad();
|
88 |
+
}
|
89 |
+
|
90 |
+
protected function _toOptionArray($valueField = 'category_id', $labelField = 'category_name', $additional = array())
|
91 |
+
{
|
92 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function _toOptionHash($valueField = 'category_id', $labelField='category_name')
|
96 |
+
{
|
97 |
+
return parent::_toOptionHash($valueField, $labelField);
|
98 |
+
}
|
99 |
+
|
100 |
+
public function addIsActiveFilter()
|
101 |
+
{
|
102 |
+
$this->addFilter('is_active', 1);
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
}
|
app/code/community/HM/Faq/Model/Mysql4/Faq.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Model_Mysql4_Faq extends Mage_Core_Model_Mysql4_Abstract {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
protected function _construct() {
|
21 |
+
|
22 |
+
$this->_init('hm_faq/faq', 'faq_id');
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Retrieve select object for load object data
|
28 |
+
*
|
29 |
+
* @param string $field
|
30 |
+
* @param mixed $value
|
31 |
+
* @return Zend_Db_Select
|
32 |
+
*/
|
33 |
+
protected function _getLoadSelect($field, $value, $object) {
|
34 |
+
|
35 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
36 |
+
|
37 |
+
if ($object->getStoreId()) {
|
38 |
+
$select->join(
|
39 |
+
array('nns' => $this->getTable('hm_faq/faq_store')),
|
40 |
+
$this->getMainTable() . '.item_id = `nns`.faq_id'
|
41 |
+
)->where('is_active=1 AND `nns`.store_id in (0, ?) ',
|
42 |
+
$object->getStoreId())->order('creation_time DESC')->limit(1);
|
43 |
+
}
|
44 |
+
|
45 |
+
return $select;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Some processing prior to saving to database - processes the given images
|
51 |
+
* and the store configuration
|
52 |
+
*
|
53 |
+
* @param Mage_Core_Model_Abstract $object Current faq item
|
54 |
+
*/
|
55 |
+
protected function _beforeSave(Mage_Core_Model_Abstract $object) {
|
56 |
+
|
57 |
+
if (!$object->getId()) {
|
58 |
+
$object->setCreationTime(Mage :: getSingleton('core/date')->gmtDate());
|
59 |
+
}
|
60 |
+
|
61 |
+
$object->setPublicationTime(
|
62 |
+
Mage::app()->getLocale()->date($object->getPublicationTime(),
|
63 |
+
Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
64 |
+
null, false)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)
|
65 |
+
);
|
66 |
+
|
67 |
+
$object->setUpdateTime(Mage :: getSingleton('core/date')->gmtDate());
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Assign page to store views
|
73 |
+
*
|
74 |
+
* @param Mage_Core_Model_Abstract $object
|
75 |
+
*/
|
76 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
77 |
+
{
|
78 |
+
$condition = $this->_getWriteAdapter()->quoteInto('faq_id = ?', $object->getId());
|
79 |
+
|
80 |
+
// process faq item to store relation
|
81 |
+
$this->_getWriteAdapter()->delete($this->getTable('hm_faq/faq_store'), $condition);
|
82 |
+
foreach ((array) $object->getData('stores') as $store) {
|
83 |
+
$storeArray = array ();
|
84 |
+
$storeArray['faq_id'] = $object->getId();
|
85 |
+
$storeArray['store_id'] = $store;
|
86 |
+
$this->_getWriteAdapter()->insert(
|
87 |
+
$this->getTable('hm_faq/faq_store'), $storeArray
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
// process faq item to category relation
|
92 |
+
$this->_getWriteAdapter()->delete($this->getTable('hm_faq/category_item'), $condition);
|
93 |
+
foreach ((array) $object->getData('categories') as $categoryId) {
|
94 |
+
$categoryArray = array ();
|
95 |
+
$categoryArray['faq_id'] = $object->getId();
|
96 |
+
$categoryArray['category_id'] = $categoryId;
|
97 |
+
$this->_getWriteAdapter()->insert(
|
98 |
+
$this->getTable('hm_faq/category_item'), $categoryArray
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
return parent::_afterSave($object);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Do store and category processing after loading
|
107 |
+
*
|
108 |
+
* @param Mage_Core_Model_Abstract $object Current faq item
|
109 |
+
*/
|
110 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
111 |
+
{
|
112 |
+
// process faq item to store relation
|
113 |
+
$select = $this->_getReadAdapter()->select()->from(
|
114 |
+
$this->getTable('hm_faq/faq_store')
|
115 |
+
)->where('faq_id = ?', $object->getId());
|
116 |
+
|
117 |
+
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
|
118 |
+
$storesArray = array ();
|
119 |
+
foreach ($data as $row) {
|
120 |
+
$storesArray[] = $row['store_id'];
|
121 |
+
}
|
122 |
+
$object->setData('store_id', $storesArray);
|
123 |
+
}
|
124 |
+
|
125 |
+
// process faq item to category relation
|
126 |
+
$select = $this->_getReadAdapter()->select()->from(
|
127 |
+
$this->getTable('hm_faq/category_item')
|
128 |
+
)->where('faq_id = ?', $object->getId());
|
129 |
+
|
130 |
+
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
|
131 |
+
$categoryArray = array ();
|
132 |
+
foreach ($data as $row) {
|
133 |
+
$categoryArray[] = $row['category_id'];
|
134 |
+
}
|
135 |
+
$object->setData('category_id', $categoryArray);
|
136 |
+
}
|
137 |
+
|
138 |
+
return parent::_afterLoad($object);
|
139 |
+
}
|
140 |
+
}
|
app/code/community/HM/Faq/Model/Mysql4/Faq/Collection.php
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Model_Mysql4_Faq_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
14 |
+
{
|
15 |
+
protected $_previewFlag;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructor
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('hm_faq/faq')
|
24 |
+
->setOrder('question', 'ASC');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Creates an options array for grid filter functionality
|
29 |
+
*
|
30 |
+
* @return array Options array
|
31 |
+
*/
|
32 |
+
public function toOptionArray()
|
33 |
+
{
|
34 |
+
return $this->_toOptionArray('faq_id', 'question');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function addIsActiveFilter()
|
38 |
+
{
|
39 |
+
$this->addFilter('is_active', 1);
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Add Filter by category
|
45 |
+
*
|
46 |
+
* @param int|HM_Faq_Model_Category $category Category to be filtered
|
47 |
+
* @return HM_Faq_Model_Mysql4_Category_Collection
|
48 |
+
*/
|
49 |
+
public function addCategoryFilter($category)
|
50 |
+
{
|
51 |
+
if ($category instanceof HM_Faq_Model_Category) {
|
52 |
+
$category = array($category->getId());
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->getSelect()->join(
|
56 |
+
array('category_table' => $this->getTable('hm_faq/category_item')),
|
57 |
+
'main_table.faq_id = category_table.faq_id',
|
58 |
+
array ()
|
59 |
+
)->where('category_table.category_id in (?)', array (
|
60 |
+
0,
|
61 |
+
$category
|
62 |
+
))->group('main_table.faq_id');
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Add Filter by store
|
69 |
+
*
|
70 |
+
* @param int|Mage_Core_Model_Store $store Store to be filtered
|
71 |
+
* @return HM_Faq_Model_Mysql4_Faq_Collection Self
|
72 |
+
*/
|
73 |
+
public function addStoreFilter($store)
|
74 |
+
{
|
75 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
76 |
+
$store = array (
|
77 |
+
$store->getId()
|
78 |
+
);
|
79 |
+
}
|
80 |
+
|
81 |
+
$this->getSelect()->join(
|
82 |
+
array('store_table' => $this->getTable('hm_faq/faq_store')),
|
83 |
+
'main_table.faq_id = store_table.faq_id',
|
84 |
+
array ()
|
85 |
+
)->where('store_table.store_id in (?)', array (
|
86 |
+
0,
|
87 |
+
$store
|
88 |
+
))->group('main_table.faq_id');
|
89 |
+
|
90 |
+
return $this;
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* After load processing - adds store information to the datasets
|
96 |
+
*
|
97 |
+
*/
|
98 |
+
protected function _afterLoad()
|
99 |
+
{
|
100 |
+
if ($this->_previewFlag) {
|
101 |
+
$items = $this->getColumnValues('faq_id');
|
102 |
+
if (count($items)) {
|
103 |
+
$select = $this->getConnection()->select()->from(
|
104 |
+
$this->getTable('hm_faq/faq_store')
|
105 |
+
)->where(
|
106 |
+
$this->getTable('hm_faq/faq_store') . '.faq_id IN (?)',
|
107 |
+
$items
|
108 |
+
);
|
109 |
+
if ($result = $this->getConnection()->fetchPairs($select)) {
|
110 |
+
foreach ($this as $item) {
|
111 |
+
if (!isset($result[$item->getData('faq_id')])) {
|
112 |
+
continue;
|
113 |
+
}
|
114 |
+
if ($result[$item->getData('faq_id')] == 0) {
|
115 |
+
$stores = Mage::app()->getStores(false, true);
|
116 |
+
$storeId = current($stores)->getId();
|
117 |
+
$storeCode = key($stores);
|
118 |
+
}
|
119 |
+
else {
|
120 |
+
$storeId = $result[$item->getData('faq_id')];
|
121 |
+
$storeCode = Mage::app()->getStore($storeId)->getCode();
|
122 |
+
}
|
123 |
+
$item->setData('_first_store_id', $storeId);
|
124 |
+
$item->setData('store_code', $storeCode);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
parent::_afterLoad();
|
131 |
+
}
|
132 |
+
}
|
app/code/community/HM/Faq/Wysiwyg/Images/Content.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Wysiwyg Images content block
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content extends Mage_Adminhtml_Block_Widget_Container
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Block construction
|
38 |
+
*/
|
39 |
+
public function __construct()
|
40 |
+
{
|
41 |
+
parent::__construct();
|
42 |
+
$this->_headerText = $this->helper('cms')->__('Media Storage');
|
43 |
+
$this->_removeButton('back')->_removeButton('edit');
|
44 |
+
$this->_addButton('newfolder', array(
|
45 |
+
'class' => 'save',
|
46 |
+
'label' => $this->helper('cms')->__('Create Folder...'),
|
47 |
+
'type' => 'button',
|
48 |
+
'onclick' => 'MediabrowserInstance.newFolder();'
|
49 |
+
));
|
50 |
+
|
51 |
+
$this->_addButton('delete_folder', array(
|
52 |
+
'class' => 'delete no-display',
|
53 |
+
'label' => $this->helper('cms')->__('Delete Folder'),
|
54 |
+
'type' => 'button',
|
55 |
+
'onclick' => 'MediabrowserInstance.deleteFolder();',
|
56 |
+
'id' => 'button_delete_folder'
|
57 |
+
));
|
58 |
+
|
59 |
+
$this->_addButton('delete_files', array(
|
60 |
+
'class' => 'delete no-display',
|
61 |
+
'label' => $this->helper('cms')->__('Delete File'),
|
62 |
+
'type' => 'button',
|
63 |
+
'onclick' => 'MediabrowserInstance.deleteFiles();',
|
64 |
+
'id' => 'button_delete_files'
|
65 |
+
));
|
66 |
+
|
67 |
+
$this->_addButton('insert_files', array(
|
68 |
+
'class' => 'save no-display',
|
69 |
+
'label' => $this->helper('cms')->__('Insert File'),
|
70 |
+
'type' => 'button',
|
71 |
+
'onclick' => 'MediabrowserInstance.insert();',
|
72 |
+
'id' => 'button_insert_files'
|
73 |
+
));
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Files action source URL
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getContentsUrl()
|
82 |
+
{
|
83 |
+
return $this->getUrl('*/*/contents', array('type' => $this->getRequest()->getParam('type')));
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Javascript setup object for filebrowser instance
|
88 |
+
*
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
+
public function getFilebrowserSetupObject()
|
92 |
+
{
|
93 |
+
$setupObject = new Varien_Object();
|
94 |
+
|
95 |
+
$setupObject->setData(array(
|
96 |
+
'newFolderPrompt' => $this->helper('cms')->__('New Folder Name:'),
|
97 |
+
'deleteFolderConfirmationMessage' => $this->helper('cms')->__('Are you sure you want to delete current folder?'),
|
98 |
+
'deleteFileConfirmationMessage' => $this->helper('cms')->__('Are you sure you want to delete the selected file?'),
|
99 |
+
'targetElementId' => $this->getTargetElementId(),
|
100 |
+
'contentsUrl' => $this->getContentsUrl(),
|
101 |
+
'onInsertUrl' => $this->getOnInsertUrl(),
|
102 |
+
'newFolderUrl' => $this->getNewfolderUrl(),
|
103 |
+
'deleteFolderUrl' => $this->getDeletefolderUrl(),
|
104 |
+
'deleteFilesUrl' => $this->getDeleteFilesUrl(),
|
105 |
+
'headerText' => $this->getHeaderText()
|
106 |
+
));
|
107 |
+
|
108 |
+
return Mage::helper('core')->jsonEncode($setupObject);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* New directory action target URL
|
113 |
+
*
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public function getNewfolderUrl()
|
117 |
+
{
|
118 |
+
return $this->getUrl('*/*/newFolder');
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Delete directory action target URL
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
protected function getDeletefolderUrl()
|
127 |
+
{
|
128 |
+
return $this->getUrl('*/*/deleteFolder');
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Description goes here...
|
133 |
+
*
|
134 |
+
* @param none
|
135 |
+
* @return void
|
136 |
+
*/
|
137 |
+
public function getDeleteFilesUrl()
|
138 |
+
{
|
139 |
+
return $this->getUrl('*/*/deleteFiles');
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* New directory action target URL
|
144 |
+
*
|
145 |
+
* @return string
|
146 |
+
*/
|
147 |
+
public function getOnInsertUrl()
|
148 |
+
{
|
149 |
+
return $this->getUrl('*/*/onInsert');
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Target element ID getter
|
154 |
+
*
|
155 |
+
* @return string
|
156 |
+
*/
|
157 |
+
public function getTargetElementId()
|
158 |
+
{
|
159 |
+
return $this->getRequest()->getParam('target_element_id');
|
160 |
+
}
|
161 |
+
}
|
app/code/community/HM/Faq/Wysiwyg/Images/Content/Files.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Directory contents block for Wysiwyg Images
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Files extends Mage_Adminhtml_Block_Template
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* Files collection object
|
38 |
+
*
|
39 |
+
* @var Varien_Data_Collection_Filesystem
|
40 |
+
*/
|
41 |
+
protected $_filesCollection;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Prepared Files collection for current directory
|
45 |
+
*
|
46 |
+
* @return Varien_Data_Collection_Filesystem
|
47 |
+
*/
|
48 |
+
public function getFiles()
|
49 |
+
{
|
50 |
+
if (! $this->_filesCollection) {
|
51 |
+
$this->_filesCollection = Mage::getSingleton('cms/wysiwyg_images_storage')->getFilesCollection(Mage::helper('cms/wysiwyg_images')->getCurrentPath(), $this->_getMediaType());
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this->_filesCollection;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Files collection count getter
|
60 |
+
*
|
61 |
+
* @return int
|
62 |
+
*/
|
63 |
+
public function getFilesCount()
|
64 |
+
{
|
65 |
+
return $this->getFiles()->count();
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* File idetifier getter
|
70 |
+
*
|
71 |
+
* @param Varien_Object $file
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function getFileId(Varien_Object $file)
|
75 |
+
{
|
76 |
+
return $file->getId();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* File thumb URL getter
|
81 |
+
*
|
82 |
+
* @param Varien_Object $file
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getFileThumbUrl(Varien_Object $file)
|
86 |
+
{
|
87 |
+
return $file->getThumbUrl();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* File name URL getter
|
92 |
+
*
|
93 |
+
* @param Varien_Object $file
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function getFileName(Varien_Object $file)
|
97 |
+
{
|
98 |
+
return $file->getName();
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Image file width getter
|
103 |
+
*
|
104 |
+
* @param Varien_Object $file
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
+
public function getFileWidth(Varien_Object $file)
|
108 |
+
{
|
109 |
+
return $file->getWidth();
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Image file height getter
|
114 |
+
*
|
115 |
+
* @param Varien_Object $file
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
public function getFileHeight(Varien_Object $file)
|
119 |
+
{
|
120 |
+
return $file->getHeight();
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* File short name getter
|
125 |
+
*
|
126 |
+
* @param Varien_Object $file
|
127 |
+
* @return string
|
128 |
+
*/
|
129 |
+
public function getFileShortName(Varien_Object $file)
|
130 |
+
{
|
131 |
+
return $file->getShortName();
|
132 |
+
}
|
133 |
+
|
134 |
+
public function getImagesWidth()
|
135 |
+
{
|
136 |
+
return Mage::getSingleton('cms/wysiwyg_images_storage')->getConfigData('resize_width');
|
137 |
+
}
|
138 |
+
|
139 |
+
public function getImagesHeight()
|
140 |
+
{
|
141 |
+
return Mage::getSingleton('cms/wysiwyg_images_storage')->getConfigData('resize_height');
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Return current media type based on request or data
|
146 |
+
* @return string
|
147 |
+
*/
|
148 |
+
protected function _getMediaType()
|
149 |
+
{
|
150 |
+
if ($this->hasData('media_type')) {
|
151 |
+
return $this->_getData('media_type');
|
152 |
+
}
|
153 |
+
return $this->getRequest()->getParam('type');
|
154 |
+
}
|
155 |
+
}
|
app/code/community/HM/Faq/Wysiwyg/Images/Content/Newfolder.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* New directory block for Wysiwyg Images
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Newfolder extends Mage_Adminhtml_Block_Template
|
35 |
+
{
|
36 |
+
|
37 |
+
}
|
app/code/community/HM/Faq/Wysiwyg/Images/Content/Uploader.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Uploader block for Wysiwyg Images
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Uploader extends Mage_Adminhtml_Block_Media_Uploader
|
35 |
+
{
|
36 |
+
public function __construct()
|
37 |
+
{
|
38 |
+
parent::__construct();
|
39 |
+
$params = $this->getConfig()->getParams();
|
40 |
+
$type = $this->_getMediaType();
|
41 |
+
$allowed = Mage::getSingleton('cms/wysiwyg_images_storage')->getAllowedExtensions($type);
|
42 |
+
$labels = array();
|
43 |
+
$files = array();
|
44 |
+
foreach ($allowed as $ext) {
|
45 |
+
$labels[] = '.' . $ext;
|
46 |
+
$files[] = '*.' . $ext;
|
47 |
+
}
|
48 |
+
$this->getConfig()
|
49 |
+
->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload', array('type' => $type)))
|
50 |
+
->setParams($params)
|
51 |
+
->setFileField('image')
|
52 |
+
->setFilters(array(
|
53 |
+
'images' => array(
|
54 |
+
'label' => $this->helper('cms')->__('Images (%s)', implode(', ', $labels)),
|
55 |
+
'files' => $files
|
56 |
+
)
|
57 |
+
));
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Return current media type based on request or data
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
protected function _getMediaType()
|
65 |
+
{
|
66 |
+
if ($this->hasData('media_type')) {
|
67 |
+
return $this->_getData('media_type');
|
68 |
+
}
|
69 |
+
return $this->getRequest()->getParam('type');
|
70 |
+
}
|
71 |
+
}
|
app/code/community/HM/Faq/Wysiwyg/Images/Tree.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-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 Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Directoty tree renderer for Cms Wysiwyg Images
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Tree extends Mage_Adminhtml_Block_Template
|
35 |
+
{
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Json tree builder
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getTreeJson()
|
43 |
+
{
|
44 |
+
$helper = Mage::helper('cms/wysiwyg_images');
|
45 |
+
$storageRoot = $helper->getStorageRoot();
|
46 |
+
$collection = Mage::registry('storage')->getDirsCollection($helper->getCurrentPath());
|
47 |
+
$jsonArray = array();
|
48 |
+
foreach ($collection as $item) {
|
49 |
+
$jsonArray[] = array(
|
50 |
+
'text' => $helper->getShortFilename($item->getBasename(), 20),
|
51 |
+
'id' => $helper->convertPathToId($item->getFilename()),
|
52 |
+
'cls' => 'folder'
|
53 |
+
);
|
54 |
+
}
|
55 |
+
return Zend_Json::encode($jsonArray);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Json source URL
|
60 |
+
*
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getTreeLoaderUrl()
|
64 |
+
{
|
65 |
+
return $this->getUrl('*/*/treeJson');
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Root node name of tree
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function getRootNodeName()
|
74 |
+
{
|
75 |
+
return $this->helper('cms')->__('Storage Root');
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Return tree node full path based on current path
|
80 |
+
*
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function getTreeCurrentPath()
|
84 |
+
{
|
85 |
+
$treePath = '/root';
|
86 |
+
if ($path = Mage::registry('storage')->getSession()->getCurrentPath()) {
|
87 |
+
$helper = Mage::helper('cms/wysiwyg_images');
|
88 |
+
$path = str_replace($helper->getStorageRoot(), '', $path);
|
89 |
+
$relative = '';
|
90 |
+
foreach (explode(DS, $path) as $dirName) {
|
91 |
+
if ($dirName) {
|
92 |
+
$relative .= DS . $dirName;
|
93 |
+
$treePath .= '/' . $helper->idEncode($relative);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
return $treePath;
|
98 |
+
}
|
99 |
+
}
|
app/code/community/HM/Faq/controllers/Adminhtml/Faq/CategoryController.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
* Website: www.hiremagento.com
|
11 |
+
* Email: hiremagento@gmail.com
|
12 |
+
*/
|
13 |
+
class HM_Faq_Adminhtml_Faq_CategoryController extends Mage_Adminhtml_Controller_Action
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Initialization of current view - add's breadcrumps and the current menu status
|
17 |
+
*
|
18 |
+
* @return HM_Faq_AdminController
|
19 |
+
*/
|
20 |
+
protected function _initAction()
|
21 |
+
{
|
22 |
+
$this->_usedModuleName = 'hm_faq';
|
23 |
+
|
24 |
+
$this->loadLayout()
|
25 |
+
->_setActiveMenu('cms/faq')
|
26 |
+
->_addBreadcrumb($this->__('CMS'), $this->__('CMS'))
|
27 |
+
->_addBreadcrumb($this->__('FAQ'), $this->__('FAQ'));
|
28 |
+
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Displays the FAQ overview grid.
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
public function indexAction()
|
37 |
+
{
|
38 |
+
$this->_initAction()
|
39 |
+
->_addContent($this->getLayout()->createBlock('hm_faq/adminhtml_category'))
|
40 |
+
->renderLayout();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Displays the new FAQ item form
|
45 |
+
*/
|
46 |
+
public function newAction()
|
47 |
+
{
|
48 |
+
$this->_forward('edit');
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Displays the new FAQ item form or the edit FAQ item form.
|
53 |
+
*/
|
54 |
+
public function editAction()
|
55 |
+
{
|
56 |
+
$id = $this->getRequest()->getParam('category_id');
|
57 |
+
$model = Mage::getModel('hm_faq/category');
|
58 |
+
|
59 |
+
// if current id given -> try to load and edit current FAQ category
|
60 |
+
if ($id) {
|
61 |
+
$model->load($id);
|
62 |
+
if (!$model->getId()) {
|
63 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
64 |
+
Mage::helper('hm_faq')->__('This FAQ category no longer exists')
|
65 |
+
);
|
66 |
+
$this->_redirect('*/*/');
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
72 |
+
if (!empty($data)) {
|
73 |
+
$model->setData($data);
|
74 |
+
}
|
75 |
+
|
76 |
+
Mage::register('faq_category', $model);
|
77 |
+
|
78 |
+
$this->_initAction()
|
79 |
+
->_addBreadcrumb(
|
80 |
+
$id
|
81 |
+
? Mage::helper('hm_faq')->__('Edit FAQ Category')
|
82 |
+
: Mage::helper('hm_faq')->__('New FAQ Category'),
|
83 |
+
$id
|
84 |
+
? Mage::helper('hm_faq')->__('Edit FAQ Category')
|
85 |
+
: Mage::helper('hm_faq')->__('New FAQ Category')
|
86 |
+
)
|
87 |
+
->_addContent(
|
88 |
+
$this->getLayout()
|
89 |
+
->createBlock('hm_faq/adminhtml_category_edit')
|
90 |
+
->setData('action', $this->getUrl('*/*/save'))
|
91 |
+
)
|
92 |
+
->_addLeft($this->getLayout()->createBlock('hm_faq/adminhtml_category_edit_tabs'));
|
93 |
+
|
94 |
+
$this->renderLayout();
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Action that does the actual saving process and redirects back to overview
|
99 |
+
*/
|
100 |
+
public function saveAction()
|
101 |
+
{
|
102 |
+
// check if data sent
|
103 |
+
if ($data = $this->getRequest()->getPost()) {
|
104 |
+
|
105 |
+
// init model and set data
|
106 |
+
$model = Mage::getModel('hm_faq/category');
|
107 |
+
$model->setData($data);
|
108 |
+
|
109 |
+
// try to save it
|
110 |
+
try {
|
111 |
+
// save the data
|
112 |
+
$model->save();
|
113 |
+
|
114 |
+
// display success message
|
115 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
116 |
+
Mage::helper('hm_faq')->__('FAQ Category was successfully saved')
|
117 |
+
);
|
118 |
+
// clear previously saved data from session
|
119 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
120 |
+
// check if 'Save and Continue'
|
121 |
+
if ($this->getRequest()->getParam('back')) {
|
122 |
+
$this->_redirect('*/*/edit', array (
|
123 |
+
'category_id' => $model->getId() ));
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
catch (Exception $e) {
|
128 |
+
// display error message
|
129 |
+
Mage::getSingleton('adminhtml/session')->addException($e, $e->getMessage());
|
130 |
+
// save data in session
|
131 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
132 |
+
// redirect to edit form
|
133 |
+
$this->_redirect('*/*/edit', array (
|
134 |
+
'category_id' => $this->getRequest()->getParam('category_id') ));
|
135 |
+
return;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
$this->_redirect('*/*/');
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Action that does the actual saving process and redirects back to overview
|
143 |
+
*/
|
144 |
+
public function deleteAction()
|
145 |
+
{
|
146 |
+
// check if we know what should be deleted
|
147 |
+
if ($id = $this->getRequest()->getParam('category_id')) {
|
148 |
+
try {
|
149 |
+
// init model and delete
|
150 |
+
$model = Mage::getModel('hm_faq/category');
|
151 |
+
$model->load($id);
|
152 |
+
$model->delete();
|
153 |
+
|
154 |
+
// display success message
|
155 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('hm_faq')->__('FAQ Category was successfully deleted'));
|
156 |
+
|
157 |
+
// go to grid
|
158 |
+
$this->_redirect('*/*/');
|
159 |
+
return;
|
160 |
+
|
161 |
+
}
|
162 |
+
catch (Exception $e) {
|
163 |
+
// display error message
|
164 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
165 |
+
|
166 |
+
// go back to edit form
|
167 |
+
$this->_redirect('*/*/edit', array (
|
168 |
+
'category_id' => $id ));
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
// display error message
|
174 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('hm_faq')->__('Unable to find a FAQ Category to delete'));
|
175 |
+
|
176 |
+
// go to grid
|
177 |
+
$this->_redirect('*/*/');
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Simple access control
|
182 |
+
*
|
183 |
+
* @return boolean True if user is allowed to edit FAQ
|
184 |
+
*/
|
185 |
+
protected function _isAllowed()
|
186 |
+
{
|
187 |
+
return Mage::getSingleton('admin/session')->isAllowed('admin/cms/faq');
|
188 |
+
}
|
189 |
+
}
|
app/code/community/HM/Faq/controllers/Adminhtml/FaqController.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
*
|
5 |
+
* Website: www.hiremagento.com
|
6 |
+
* Email: hiremagento@gmail.com
|
7 |
+
*/
|
8 |
+
class HM_Faq_Adminhtml_FaqController extends Mage_Adminhtml_Controller_Action
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Initialization of current view - add's breadcrumps and the current menu status
|
12 |
+
*
|
13 |
+
* @return HM_Faq_AdminController
|
14 |
+
*/
|
15 |
+
protected function _initAction()
|
16 |
+
{
|
17 |
+
$this->_usedModuleName = 'hm_faq';
|
18 |
+
|
19 |
+
$this->loadLayout()
|
20 |
+
->_addBreadcrumb($this->__('CMS'), $this->__('CMS'))
|
21 |
+
->_addBreadcrumb($this->__('FAQ'), $this->__('FAQ'));
|
22 |
+
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Displays the FAQ overview grid.
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
public function indexAction()
|
31 |
+
{
|
32 |
+
$this->_initAction()
|
33 |
+
->_addContent($this->getLayout()->createBlock('hm_faq/adminhtml_item'))
|
34 |
+
->renderLayout();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Displays the new FAQ item form
|
39 |
+
*/
|
40 |
+
public function newAction()
|
41 |
+
{
|
42 |
+
$this->_forward('edit');
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Displays the new FAQ item form or the edit FAQ item form.
|
47 |
+
*/
|
48 |
+
public function editAction()
|
49 |
+
{
|
50 |
+
$id = $this->getRequest()->getParam('faq_id');
|
51 |
+
$model = Mage::getModel('hm_faq/faq');
|
52 |
+
|
53 |
+
// if current id given -> try to load and edit current FAQ item
|
54 |
+
if ($id) {
|
55 |
+
$model->load($id);
|
56 |
+
if (!$model->getId()) {
|
57 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
58 |
+
Mage::helper('hm_faq')->__('This FAQ item no longer exists')
|
59 |
+
);
|
60 |
+
$this->_redirect('*/*/');
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
66 |
+
if (!empty($data)) {
|
67 |
+
$model->setData($data);
|
68 |
+
}
|
69 |
+
|
70 |
+
Mage::register('faq', $model);
|
71 |
+
|
72 |
+
$this->_initAction()
|
73 |
+
->_addBreadcrumb(
|
74 |
+
$id
|
75 |
+
? Mage::helper('hm_faq')->__('Edit FAQ Item')
|
76 |
+
: Mage::helper('hm_faq')->__('New FAQ Item'),
|
77 |
+
$id
|
78 |
+
? Mage::helper('hm_faq')->__('Edit FAQ Item')
|
79 |
+
: Mage::helper('hm_faq')->__('New FAQ Item')
|
80 |
+
)
|
81 |
+
->_addContent(
|
82 |
+
$this->getLayout()
|
83 |
+
->createBlock('hm_faq/adminhtml_item_edit')
|
84 |
+
->setData('action', $this->getUrl('adminhtml/faq/save'))
|
85 |
+
)
|
86 |
+
->_addLeft($this->getLayout()->createBlock('hm_faq/adminhtml_item_edit_tabs'));
|
87 |
+
|
88 |
+
$this->renderLayout();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Action that does the actual saving process and redirects back to overview
|
93 |
+
*/
|
94 |
+
public function saveAction()
|
95 |
+
{
|
96 |
+
// check if data sent
|
97 |
+
if ($data = $this->getRequest()->getPost()) {
|
98 |
+
|
99 |
+
// init model and set data
|
100 |
+
$model = Mage::getModel('hm_faq/faq');
|
101 |
+
$model->setCreationTime(Mage::getSingleton('core/date')->gmtDate());
|
102 |
+
$model->setData($data);
|
103 |
+
|
104 |
+
// try to save it
|
105 |
+
try {
|
106 |
+
// save the data
|
107 |
+
$model->save();
|
108 |
+
|
109 |
+
// display success message
|
110 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
111 |
+
Mage::helper('cms')->__('FAQ Item was successfully saved')
|
112 |
+
);
|
113 |
+
// clear previously saved data from session
|
114 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
115 |
+
// check if 'Save and Continue'
|
116 |
+
if ($this->getRequest()->getParam('back')) {
|
117 |
+
$this->_redirect('*/*/edit', array (
|
118 |
+
'faq_id' => $model->getId() ));
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
// go to grid
|
122 |
+
$this->_redirect('*/*/');
|
123 |
+
return;
|
124 |
+
|
125 |
+
}
|
126 |
+
catch (Exception $e) {
|
127 |
+
// display error message
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
// save data in session
|
130 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
131 |
+
// redirect to edit form
|
132 |
+
$this->_redirect('*/*/edit', array (
|
133 |
+
'faq_id' => $this->getRequest()->getParam('faq_id') ));
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
$this->_redirect('*/*/');
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Simple access control
|
143 |
+
*
|
144 |
+
* @return boolean True if user is allowed to edit FAQ
|
145 |
+
*/
|
146 |
+
protected function _isAllowed()
|
147 |
+
{
|
148 |
+
return Mage::getSingleton('admin/session')->isAllowed('admin/cms/faq');
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Action that does the actual saving process and redirects back to overview
|
153 |
+
*/
|
154 |
+
public function deleteAction()
|
155 |
+
{
|
156 |
+
// check if we know what should be deleted
|
157 |
+
if ($id = $this->getRequest()->getParam('faq_id')) {
|
158 |
+
try {
|
159 |
+
|
160 |
+
// init model and delete
|
161 |
+
$model = Mage::getModel('hm_faq/faq');
|
162 |
+
$model->load($id);
|
163 |
+
$model->delete();
|
164 |
+
|
165 |
+
// display success message
|
166 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('FAQ Entry was successfully deleted'));
|
167 |
+
|
168 |
+
// go to grid
|
169 |
+
$this->_redirect('*/*/');
|
170 |
+
return;
|
171 |
+
|
172 |
+
}
|
173 |
+
catch (Exception $e) {
|
174 |
+
|
175 |
+
// display error message
|
176 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
177 |
+
|
178 |
+
// go back to edit form
|
179 |
+
$this->_redirect('*/*/edit', array (
|
180 |
+
'faq_id' => $id ));
|
181 |
+
return;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
// display error message
|
186 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('Unable to find a FAQ entry to delete'));
|
187 |
+
|
188 |
+
// go to grid
|
189 |
+
$this->_redirect('*/*/');
|
190 |
+
}
|
191 |
+
}
|
app/code/community/HM/Faq/controllers/IndexController.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* FAQ accordion for Magento
|
9 |
+
*
|
10 |
+
|
11 |
+
* Website: www.hiremagento.com
|
12 |
+
* Email: hiremagento@gmail.com
|
13 |
+
*/
|
14 |
+
class HM_Faq_IndexController extends Mage_Core_Controller_Front_Action
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Displays the FAQ list.
|
18 |
+
*/
|
19 |
+
public function indexAction()
|
20 |
+
{
|
21 |
+
$this->loadLayout()->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Displays the current FAQ's detail view
|
26 |
+
*/
|
27 |
+
public function showAction()
|
28 |
+
{
|
29 |
+
$this->loadLayout()->renderLayout();
|
30 |
+
}
|
31 |
+
}
|
app/code/community/HM/Faq/etc/adminhtml.xml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<cms>
|
5 |
+
<children>
|
6 |
+
<faq translate="title" module="hm_faq">
|
7 |
+
<title>FAQ</title>
|
8 |
+
<sort_order>60</sort_order>
|
9 |
+
<children>
|
10 |
+
<item translate="titl" module="hm_faq">
|
11 |
+
<title>Manage Items</title>
|
12 |
+
<action>adminhtml/faq</action>
|
13 |
+
</item>
|
14 |
+
<category translate="titl" module="hm_faq">
|
15 |
+
<title>Manage Categories</title>
|
16 |
+
<action>adminhtml/faq_category</action>
|
17 |
+
</category>
|
18 |
+
</children>
|
19 |
+
</faq>
|
20 |
+
</children>
|
21 |
+
</cms>
|
22 |
+
</menu>
|
23 |
+
<acl>
|
24 |
+
<resources>
|
25 |
+
<admin>
|
26 |
+
<children>
|
27 |
+
<cms>
|
28 |
+
<children>
|
29 |
+
<faq translate="title" module="hm_faq">
|
30 |
+
<title>Faq</title>
|
31 |
+
<sort_order>50</sort_order>
|
32 |
+
</faq>
|
33 |
+
</children>
|
34 |
+
</cms>
|
35 |
+
</children>
|
36 |
+
</admin>
|
37 |
+
</resources>
|
38 |
+
</acl>
|
39 |
+
<layout>
|
40 |
+
<updates>
|
41 |
+
<faq>
|
42 |
+
<file>faq.xml</file>
|
43 |
+
</faq>
|
44 |
+
</updates>
|
45 |
+
</layout>
|
46 |
+
</config>
|
app/code/community/HM/Faq/etc/config.xml
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<HM_Faq>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>1.1.2</version>
|
8 |
+
</HM_Faq>
|
9 |
+
</modules>
|
10 |
+
|
11 |
+
<admin>
|
12 |
+
<routers>
|
13 |
+
<adminhtml>
|
14 |
+
<args>
|
15 |
+
<modules>
|
16 |
+
<HM_Faq before="Mage_Adminhtml">HM_Faq_Adminhtml</HM_Faq>
|
17 |
+
</modules>
|
18 |
+
</args>
|
19 |
+
</adminhtml>
|
20 |
+
</routers>
|
21 |
+
</admin>
|
22 |
+
|
23 |
+
<frontend>
|
24 |
+
<routers>
|
25 |
+
<faq>
|
26 |
+
<use>standard</use>
|
27 |
+
<args>
|
28 |
+
<module>HM_Faq</module>
|
29 |
+
<frontName>faq</frontName>
|
30 |
+
</args>
|
31 |
+
</faq>
|
32 |
+
</routers>
|
33 |
+
<translate>
|
34 |
+
<modules>
|
35 |
+
<HM_Faq>
|
36 |
+
<files>
|
37 |
+
<default>HM_Faq.csv</default>
|
38 |
+
</files>
|
39 |
+
</HM_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 |
+
<hm_faq>
|
54 |
+
<class>HM_Faq_Helper</class>
|
55 |
+
</hm_faq>
|
56 |
+
</helpers>
|
57 |
+
|
58 |
+
<blocks>
|
59 |
+
<hm_faq>
|
60 |
+
<class>HM_Faq_Block</class>
|
61 |
+
</hm_faq>
|
62 |
+
</blocks>
|
63 |
+
|
64 |
+
<models>
|
65 |
+
<hm_faq>
|
66 |
+
<class>HM_Faq_Model</class>
|
67 |
+
<resourceModel>hm_faq_mysql4</resourceModel>
|
68 |
+
</hm_faq>
|
69 |
+
<hm_faq_mysql4>
|
70 |
+
<class>HM_Faq_Model_Mysql4</class>
|
71 |
+
<entities>
|
72 |
+
<category>
|
73 |
+
<table>faq_category</table>
|
74 |
+
</category>
|
75 |
+
<category_item>
|
76 |
+
<table>faq_category_item</table>
|
77 |
+
</category_item>
|
78 |
+
<category_store>
|
79 |
+
<table>faq_category_store</table>
|
80 |
+
</category_store>
|
81 |
+
<faq>
|
82 |
+
<table>faq</table>
|
83 |
+
</faq>
|
84 |
+
<faq_store>
|
85 |
+
<table>faq_store</table>
|
86 |
+
</faq_store>
|
87 |
+
</entities>
|
88 |
+
</hm_faq_mysql4>
|
89 |
+
</models>
|
90 |
+
|
91 |
+
<resources>
|
92 |
+
<faq_setup>
|
93 |
+
<setup>
|
94 |
+
<module>HM_Faq</module>
|
95 |
+
</setup>
|
96 |
+
<connection>
|
97 |
+
<use>core_setup</use>
|
98 |
+
</connection>
|
99 |
+
</faq_setup>
|
100 |
+
<faq_write>
|
101 |
+
<connection>
|
102 |
+
<use>core_write</use>
|
103 |
+
</connection>
|
104 |
+
</faq_write>
|
105 |
+
<faq_read>
|
106 |
+
<connection>
|
107 |
+
<use>core_read</use>
|
108 |
+
</connection>
|
109 |
+
</faq_read>
|
110 |
+
</resources>
|
111 |
+
</global>
|
112 |
+
|
113 |
+
<adminhtml>
|
114 |
+
<translate>
|
115 |
+
<modules>
|
116 |
+
<HM_Faq>
|
117 |
+
<files>
|
118 |
+
<default>HM_Faq.csv</default>
|
119 |
+
</files>
|
120 |
+
</HM_Faq>
|
121 |
+
</modules>
|
122 |
+
</translate>
|
123 |
+
<layout>
|
124 |
+
<updates>
|
125 |
+
<faq>
|
126 |
+
<file>faq.xml</file>
|
127 |
+
</faq>
|
128 |
+
</updates>
|
129 |
+
</layout>
|
130 |
+
</adminhtml>
|
131 |
+
<install>
|
132 |
+
<translate>
|
133 |
+
<modules>
|
134 |
+
<HM_Faq>
|
135 |
+
<files>
|
136 |
+
<default>HM_Faq.csv</default>
|
137 |
+
</files>
|
138 |
+
</HM_Faq>
|
139 |
+
</modules>
|
140 |
+
</translate>
|
141 |
+
</install>
|
142 |
+
</config>
|
app/code/community/HM/Faq/sql/faq_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
$installer = $this;
|
8 |
+
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
$installer->run("
|
12 |
+
-- DROP TABLE IF EXISTS {$this->getTable('hm_faq/faq')};
|
13 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('hm_faq/faq')} (
|
14 |
+
`faq_id` int(10) unsigned NOT NULL auto_increment,
|
15 |
+
`question` tinytext NOT NULL default '',
|
16 |
+
`answer` text NOT NULL default '',
|
17 |
+
`answer_html` tinyint(1) NOT NULL default '1',
|
18 |
+
`creation_time` datetime default NULL,
|
19 |
+
`update_time` datetime default NULL,
|
20 |
+
`is_active` tinyint(1) NOT NULL default '1',
|
21 |
+
PRIMARY KEY (`faq_id`)
|
22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items' AUTO_INCREMENT=1 ;
|
23 |
+
|
24 |
+
-- DROP TABLE IF EXISTS {$this->getTable('hm_faq/faq_store')};
|
25 |
+
CREATE TABLE `{$this->getTable('hm_faq/faq_store')}` (
|
26 |
+
`faq_id` int(10) unsigned NOT NULL,
|
27 |
+
`store_id` smallint(5) unsigned NOT NULL,
|
28 |
+
PRIMARY KEY (`faq_id`,`store_id`),
|
29 |
+
CONSTRAINT `FK_FAQ_FAQ_STORE_FAQ` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('hm_faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
30 |
+
CONSTRAINT `FK_FAQ_FAQ_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
31 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items to Stores';
|
32 |
+
");
|
33 |
+
|
34 |
+
$installer->endSetup();
|
app/code/community/HM/Faq/sql/faq_setup/mysql4-install-1.0.7.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
$installer = $this;
|
8 |
+
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
$installer->run("
|
12 |
+
-- DROP TABLE IF EXISTS {$this->getTable('hm_faq/faq')};
|
13 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('hm_faq/faq')} (
|
14 |
+
`faq_id` int(10) unsigned NOT NULL auto_increment,
|
15 |
+
`question` tinytext NOT NULL default '',
|
16 |
+
`answer` text NOT NULL default '',
|
17 |
+
`answer_html` tinyint(1) NOT NULL default '1',
|
18 |
+
`creation_time` datetime NOT NULL,
|
19 |
+
`update_time` datetime NOT NULL,
|
20 |
+
`is_active` tinyint(1) NOT NULL default '1',
|
21 |
+
PRIMARY KEY (`faq_id`)
|
22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items' AUTO_INCREMENT=1 ;
|
23 |
+
|
24 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('hm_faq/faq_store')}`;
|
25 |
+
CREATE TABLE `{$this->getTable('hm_faq/faq_store')}` (
|
26 |
+
`faq_id` int(10) unsigned NOT NULL,
|
27 |
+
`store_id` smallint(5) unsigned NOT NULL,
|
28 |
+
PRIMARY KEY (`faq_id`,`store_id`),
|
29 |
+
CONSTRAINT `FK_FAQ_FAQ_STORE_FAQ` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('hm_faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
30 |
+
CONSTRAINT `FK_FAQ_FAQ_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
31 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='FAQ items to Stores';
|
32 |
+
|
33 |
+
CREATE TABLE `{$this->getTable('hm_faq/category')}` (
|
34 |
+
`category_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
35 |
+
`parent_id` INT(10) UNSIGNED NULL,
|
36 |
+
`category_name` VARCHAR(255) NOT NULL,
|
37 |
+
`creation_time` DATETIME NOT NULL,
|
38 |
+
`update_time` DATETIME NOT NULL,
|
39 |
+
`is_active` TINYINT(1) NOT NULL DEFAULT 1,
|
40 |
+
PRIMARY KEY (`category_id`),
|
41 |
+
CONSTRAINT `FK_FAQ_CATEGORY_PARENT_ID` FOREIGN KEY (`parent_id`) REFERENCES `{$this->getTable('hm_faq/category')}` (`category_id`) ON DELETE SET NULL
|
42 |
+
) ENGINE=InnoDB COMMENT='FAQ Categories';
|
43 |
+
|
44 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('hm_faq/category_item')}`;
|
45 |
+
CREATE TABLE `{$this->getTable('hm_faq/category_item')}` (
|
46 |
+
`category_id` INT(10) UNSIGNED NOT NULL,
|
47 |
+
`faq_id` INT(10) UNSIGNED NOT NULL,
|
48 |
+
PRIMARY KEY (`category_id`,`faq_id`),
|
49 |
+
CONSTRAINT `FK_FAQ_CATEGORY_ITEM_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('hm_faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
50 |
+
CONSTRAINT `FK_FAQ_CATEGORY_ITEM_ITEM` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('hm_faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
51 |
+
) ENGINE=InnoDB COMMENT='FAQ Items to Cateories';
|
52 |
+
|
53 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('hm_faq/category_store')}`;
|
54 |
+
CREATE TABLE `{$this->getTable('hm_faq/category_store')}` (
|
55 |
+
`category_id` INT(10) UNSIGNED NOT NULL,
|
56 |
+
`store_id` SMALLINT(5) UNSIGNED NOT NULL,
|
57 |
+
PRIMARY KEY (`category_id`,`store_id`),
|
58 |
+
CONSTRAINT `FK_FAQ_CATEGORY_STORE_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('hm_faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
59 |
+
CONSTRAINT `FK_FAQ_CATEGORY_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
60 |
+
) ENGINE=InnoDB COMMENT='FAQ Categories to Stores';
|
61 |
+
|
62 |
+
");
|
63 |
+
|
64 |
+
$installer->endSetup();
|
app/code/community/HM/Faq/sql/faq_setup/mysql4-upgrade-1.0.6-1.0.7.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FAQ accordion for Magento
|
4 |
+
|
5 |
+
*/
|
6 |
+
|
7 |
+
$installer = $this;
|
8 |
+
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
$installer->run("
|
12 |
+
|
13 |
+
ALTER TABLE `{$this->getTable('hm_faq/faq')}`
|
14 |
+
MODIFY COLUMN `creation_time` DATETIME NOT NULL;
|
15 |
+
ALTER TABLE `{$this->getTable('hm_faq/faq')}`
|
16 |
+
MODIFY COLUMN `update_time` DATETIME NOT NULL;
|
17 |
+
|
18 |
+
CREATE TABLE `{$this->getTable('hm_faq/category')}` (
|
19 |
+
`category_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
20 |
+
`parent_id` INT(10) UNSIGNED NULL,
|
21 |
+
`category_name` VARCHAR(255) NOT NULL,
|
22 |
+
`creation_time` DATETIME NOT NULL,
|
23 |
+
`update_time` DATETIME NOT NULL,
|
24 |
+
`is_active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
|
25 |
+
PRIMARY KEY (`category_id`),
|
26 |
+
CONSTRAINT `FK_FAQ_CATEGORY_PARENT_ID` FOREIGN KEY (`parent_id`) REFERENCES `{$this->getTable('hm_faq/category')}` (`category_id`) ON DELETE SET NULL
|
27 |
+
) ENGINE=InnoDB COMMENT='FAQ Categories';
|
28 |
+
|
29 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('hm_faq/category_item')}`;
|
30 |
+
CREATE TABLE `{$this->getTable('hm_faq/category_item')}` (
|
31 |
+
`category_id` INT(10) UNSIGNED NOT NULL,
|
32 |
+
`faq_id` INT(10) UNSIGNED NOT NULL,
|
33 |
+
PRIMARY KEY (`category_id`,`faq_id`),
|
34 |
+
CONSTRAINT `FK_FAQ_CATEGORY_ITEM_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('hm_faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
35 |
+
CONSTRAINT `FK_FAQ_CATEGORY_ITEM_ITEM` FOREIGN KEY (`faq_id`) REFERENCES `{$this->getTable('hm_faq/faq')}` (`faq_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
36 |
+
) ENGINE=InnoDB COMMENT='FAQ Items to Cateories';
|
37 |
+
|
38 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('hm_faq/category_store')}`;
|
39 |
+
CREATE TABLE `{$this->getTable('hm_faq/category_store')}` (
|
40 |
+
`category_id` INT(10) UNSIGNED NOT NULL,
|
41 |
+
`store_id` SMALLINT(5) UNSIGNED NOT NULL,
|
42 |
+
PRIMARY KEY (`category_id`,`store_id`),
|
43 |
+
CONSTRAINT `FK_FAQ_CATEGORY_STORE_CATEGORY` FOREIGN KEY (`category_id`) REFERENCES `{$this->getTable('hm_faq/category')}` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE,
|
44 |
+
CONSTRAINT `FK_FAQ_CATEGORY_STORE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core/store')}` (`store_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
45 |
+
) ENGINE=InnoDB COMMENT='FAQ Categories to Stores';
|
46 |
+
|
47 |
+
");
|
48 |
+
|
49 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/faq.xml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="setCanLoadExtJs"><flag>1</flag></action>
|
6 |
+
<action method="setCanLoadTinyMce"><flag>1</flag></action>
|
7 |
+
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
|
8 |
+
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
|
9 |
+
<action method="addJs"><script>lib/flex.js</script></action>
|
10 |
+
<action method="addJs"><script>lib/FABridge.js</script></action>
|
11 |
+
<action method="addJs"><script>mage/adminhtml/flexuploader.js</script></action>
|
12 |
+
<action method="addJs"><script>mage/adminhtml/browser.js</script></action>
|
13 |
+
<action method="addJs"><script>prototype/window.js</script></action>
|
14 |
+
<action method="addJs"><script>prototype/prototype.js</script></action>
|
15 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
16 |
+
<action method="addCss">
|
17 |
+
<name>lib/prototype/windows/themes/magento.css</name>
|
18 |
+
</action>
|
19 |
+
</reference>
|
20 |
+
</default>
|
21 |
+
<faq_adminhtml_faq_index>
|
22 |
+
<reference name="content">
|
23 |
+
<block type="faq/adminhtml_faq" name="faq" />
|
24 |
+
</reference>
|
25 |
+
</faq_adminhtml_faq_index>
|
26 |
+
<faq_adminhtml_faq_edit>
|
27 |
+
<update handle="editor"/>
|
28 |
+
</faq_adminhtml_faq_edit>
|
29 |
+
|
30 |
+
</layout>
|
app/design/frontend/base/default/layout/faq.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<faq_index_index>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addCss"><stylesheet>css/hm/style.css</stylesheet></action>
|
6 |
+
</reference>
|
7 |
+
<reference name="content">
|
8 |
+
<block type="hm_faq/frontend_list" name="faq_list" template="faq/list.phtml"/>
|
9 |
+
</reference>
|
10 |
+
</faq_index_index>
|
11 |
+
|
12 |
+
<faq_index_show>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="hm_faq/frontend_detail" name="faq_detail" template="faq/detail.phtml"/>
|
15 |
+
</reference>
|
16 |
+
</faq_index_show>
|
17 |
+
</layout>
|
app/design/frontend/base/default/template/faq/detail.phtml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $_faq = $this->getFaq() ?>
|
2 |
+
|
3 |
+
<?php if ($_faq): ?>
|
4 |
+
<div class="page-title">
|
5 |
+
<h1><?php echo $this->htmlEscape($_faq->getQuestion()) ?></h1>
|
6 |
+
</div>
|
7 |
+
|
8 |
+
<div class="faq-detail">
|
9 |
+
<p class="faq-date">
|
10 |
+
<?php echo Mage :: getModel('core/date')->date('d.m.Y', $_faq->getPublicationTime()); ?>
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<?php $_content = $_faq->getAnswerHtml() ? $_faq->getAnswer() : $this->htmlEscape($_faq->getAnswer()) ?>
|
14 |
+
<?php if (!empty($_content)): ?>
|
15 |
+
<div class="faq-content">
|
16 |
+
<?php if ($_faq->getAnswerHtml()): ?>
|
17 |
+
<?php echo $_content ?>
|
18 |
+
<?php else: ?>
|
19 |
+
<?php foreach (explode("\n", $_content) as $paragraph): ?>
|
20 |
+
<p><?php echo $paragraph ?></p>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
<?php endif; ?>
|
23 |
+
</div>
|
24 |
+
<?php endif; ?>
|
25 |
+
|
26 |
+
<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>
|
27 |
+
</div>
|
28 |
+
<?php else: ?>
|
29 |
+
<div class="page-title">
|
30 |
+
<h1><?php echo $this->__('Error') ?></h1>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
<p><?php echo $this->__('The requested FAQ item could not be found!') ?></p>
|
34 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/faq/list.phtml
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* FAQ accordion for Magento
|
22 |
+
*
|
23 |
+
* Website: www.hiremagento.com
|
24 |
+
* Email: hiremagento@gmail.com
|
25 |
+
*
|
26 |
+
/* @var $this HM_Faq_Block_Frontend_List */
|
27 |
+
?>
|
28 |
+
<div class="page-title">
|
29 |
+
<h1><?php echo $this->__('FAQ List'); ?></h1>
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<?php if ($this->hasFaq()): ?>
|
33 |
+
<?php if ($this->getCategoryCollection()) : ?>
|
34 |
+
<dl class="faq-list">
|
35 |
+
<?php foreach ($this->getCategoryCollection() as $category) : ?>
|
36 |
+
<dt><?php echo $this->htmlEscape($category->getName()); ?></dt><dd><ul class="faq-list">
|
37 |
+
<?php foreach ($this->getItemCollectionByCategory($category) as $item) : ?>
|
38 |
+
<li>
|
39 |
+
<a href="#faq-item-<?php echo $item->getId() ?>">
|
40 |
+
<?php echo $this->htmlEscape($item->getQuestion()); ?>
|
41 |
+
</a>
|
42 |
+
</li>
|
43 |
+
<?php endforeach; ?>
|
44 |
+
</ul></dd>
|
45 |
+
<?php endforeach; ?>
|
46 |
+
</dl>
|
47 |
+
<?php else : ?>
|
48 |
+
<ul class="faq-list">
|
49 |
+
<?php foreach ($this->getFaqCollection() as $faqItem): ?>
|
50 |
+
<li>
|
51 |
+
<a href="#faq-item-<?php echo $faqItem->getId() ?>">
|
52 |
+
<?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
|
53 |
+
</a>
|
54 |
+
</li>
|
55 |
+
<?php endforeach; ?>
|
56 |
+
</ul>
|
57 |
+
<?php endif; ?>
|
58 |
+
|
59 |
+
<dl class="faq-items">
|
60 |
+
<?php foreach ($this->getFaqCollection() as $faqItem): ?>
|
61 |
+
<dt id="faq-que-<?php echo $faqItem->getId() ?>" onclick="slide('faq-que-<?php echo $faqItem->getId() ?>','faq-ans-<?php echo $faqItem->getId() ?>')">
|
62 |
+
<?php echo $this->htmlEscape($faqItem->getQuestion()) ?>
|
63 |
+
</dt>
|
64 |
+
<dd id="faq-ans-<?php echo $faqItem->getId() ?>" style="display:none;">
|
65 |
+
<?php $_process = Mage::helper('cms')->getBlockTemplateProcessor();?>
|
66 |
+
<?php echo $_process->filter($faqItem->getAnswer()); ?>
|
67 |
+
</dd>
|
68 |
+
<?php endforeach; ?>
|
69 |
+
</dl>
|
70 |
+
<?php else: ?>
|
71 |
+
<p class="faq-items"><?php echo $this->__('There are no FAQ items at the moment.') ?></p>
|
72 |
+
<?php endif; ?>
|
73 |
+
<script type="text/javascript">
|
74 |
+
function slide(element1, element2){
|
75 |
+
new Effect.toggle(element2,'Slide', {duration:1});
|
76 |
+
if( $(element1).hasClassName("active") ){
|
77 |
+
$(element1).removeClassName("active");
|
78 |
+
}
|
79 |
+
else{
|
80 |
+
$(element1).addClassName("active");
|
81 |
+
}
|
82 |
+
}
|
83 |
+
</script>
|
app/etc/modules/HM_Faq.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<HM_Faq>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</HM_Faq>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>magento_accordion_faq</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Magento Accordion Faq</summary>
|
10 |
+
<description>Magento Accordion Faq</description>
|
11 |
+
<notes>Stable Version of Magento Accordion Faq</notes>
|
12 |
+
<authors><author><name>Hire Magento Inc.</name><user>hiremagento</user><email>hiremagento@gmail.com</email></author></authors>
|
13 |
+
<date>2013-08-20</date>
|
14 |
+
<time>11:55:15</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="HM"><dir name="Faq"><dir name="Block"><dir name="Adminhtml"><dir name="Category"><dir name="Edit"><file name="Form.php" hash="bfeb12cd51f039b7d17d3178126e13b5"/><dir name="Tab"><file name="Form.php" hash="0e18cf5e53c92496496aa543c4b3c33d"/></dir><file name="Tabs.php" hash="f5d53b141b7fabbf8b6b46b641491cae"/></dir><file name="Edit.php" hash="a105ecf6224ea4d2dd87b70e083227c0"/><file name="Grid.php" hash="145e26fde3ff29e41ffccd0ec544498b"/></dir><file name="Category.php" hash="94e0bc906723e85417ff1ba8c135169e"/><dir name="Item"><dir name="Edit"><file name="Form.php" hash="5abf62f104cec05835b8690324fe290f"/><dir name="Tab"><file name="Form.php" hash="d652b1e798c5764e426ac1e1d4ad71e1"/></dir><file name="Tabs.php" hash="e708526f0c52dadd411921f8795dd246"/></dir><file name="Edit.php" hash="4232437c14c9a6ffcefd215ea74d69eb"/><file name="Grid.php" hash="c8f9cb4847d7eb5c3bc9b22d2b3414c5"/></dir><file name="Item.php" hash="b705a9e683a52ca2144333df9bc76200"/></dir><dir name="Frontend"><file name="Detail.php" hash="d67bc6b88010e2428b05dcfe651f6026"/><file name="List.php" hash="906ee21d1fc72427671fd2d062c1f14a"/></dir></dir><dir name="Helper"><file name="Data.php" hash="2b8f58fc5f0e382793b148d7b36ac1f4"/><file name="Jumplist.php" hash="48e8f2e2e9481fb6a883077ccc19489a"/><file name="JumplistItem.php" hash="9a1f68810a756241d36c7c5e6f8dadaa"/></dir><dir name="Model"><file name="Category.php" hash="a5eaea85e0b5ec92fd0f5b98b2ae86e4"/><file name="Faq.php" hash="74284aa34f82ee791369d9de2f6e3132"/><dir name="Mysql4"><dir name="Category"><file name="Collection.php" hash="5643a880fec9001fa50f342e1cb089fc"/></dir><file name="Category.php" hash="0ad7d5ab36f8c8d508592f7a30864560"/><dir name="Faq"><file name="Collection.php" hash="dd96a25a5fe69a70a2c529d7958c8d2a"/></dir><file name="Faq.php" hash="f400f18f21d1919730686fed02feb7c1"/></dir></dir><dir name="Wysiwyg"><dir name="Images"><dir name="Content"><file name="Files.php" hash="96ba466e162a5b304e05581a1b9981c2"/><file name="Newfolder.php" hash="e53addca9a2a2a705e97bd493c57833c"/><file name="Uploader.php" hash="d46965540d2986ff74f9c2c030f2dbb4"/></dir><file name="Content.php" hash="fa97cc6ae723a62eeb137dcb23851225"/><file name="Tree.php" hash="6de3fa85978962413118cfc15b5f8f82"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Faq"><file name="CategoryController.php" hash="40932927037a648090ec1c941c4bbc52"/></dir><file name="FaqController.php" hash="6948796f9939311aef4d23f8d1b4ec9f"/></dir><file name="IndexController.php" hash="bcba63b42874747f284052ad693ac66a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="54048e7bea8a7c41eabd69a88098265a"/><file name="config.xml" hash="af12788c6d962d2efec1c23701214323"/></dir><dir name="sql"><dir name="faq_setup"><file name="mysql4-install-0.1.0.php" hash="9566beaa5c5c204ee4fc44d3b7e38d59"/><file name="mysql4-install-1.0.7.php" hash="9f5f1d5d39df31cdaf1c0e9a5a93dd58"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="671fc7a9ed7dd64927cdd61d5eaa04ef"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="faq.xml" hash="d6d4c73235f8fec0b08f545f178db4eb"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="faq.xml" hash="98649c71ad4a3c69183385335bbaea1d"/></dir><dir name="template"><dir name="faq"><file name="detail.phtml" hash="945c73c968c7c980c1acc4bed4a4cc4a"/><file name="list.phtml" hash="637d85d44469da012d4bd29173910d51"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HM_Faq.xml" hash="6d252f05f5bb64e905daf797d6238b6e"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="hm"><file name="style.css" hash="c9ac6f68292f8c3d725a42c6713dfb18"/><file name="toggle-minus.png" hash="31d75504726b3f09a9e7af2115fb58c9"/><file name="toggle-plus.png" hash="c8b91476d2cf1c55b6e2010c02a96074"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.4</min><max>1.7</max></package><extension><name>gd</name><min>2.0.28</min><max>3.0</max></extension></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/base/default/css/hm/style.css
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dl.faq-items dt {
|
2 |
+
text-transform: none;
|
3 |
+
margin-bottom: 10px;
|
4 |
+
font-size: 16px;
|
5 |
+
padding: 8px 8px 8px 30px;
|
6 |
+
background-image: url('toggle-plus.png');
|
7 |
+
background-position: 10px center;
|
8 |
+
background-repeat: no-repeat;
|
9 |
+
color: #333;
|
10 |
+
cursor:pointer;
|
11 |
+
background-color: #cfcfcf;
|
12 |
+
border-radius:4px;
|
13 |
+
}
|
14 |
+
dl.faq-items dt:hover {
|
15 |
+
color: #0489B7;
|
16 |
+
}
|
17 |
+
dl.faq-items dt.active{
|
18 |
+
background-image: url('toggle-minus.png') !important;
|
19 |
+
background-position: 10px center;
|
20 |
+
background-repeat: no-repeat;
|
21 |
+
}
|
skin/frontend/base/default/css/hm/toggle-minus.png
ADDED
Binary file
|
skin/frontend/base/default/css/hm/toggle-plus.png
ADDED
Binary file
|