Version Notes
First version
Download this release
Release Info
Developer | Tarun Vishnoi |
Extension | tv_faq_new |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/TV/Faq/Block/Adminhtml/Category.php +41 -0
- app/code/local/TV/Faq/Block/Adminhtml/Category/Edit.php +74 -0
- app/code/local/TV/Faq/Block/Adminhtml/Category/Edit/Form.php +31 -0
- app/code/local/TV/Faq/Block/Adminhtml/Category/Edit/Tab/Form.php +78 -0
- app/code/local/TV/Faq/Block/Adminhtml/Category/Edit/Tabs.php +50 -0
- app/code/local/TV/Faq/Block/Adminhtml/Category/Grid.php +163 -0
- app/code/local/TV/Faq/Block/Adminhtml/Item.php +41 -0
- app/code/local/TV/Faq/Block/Adminhtml/Item/Edit.php +88 -0
- app/code/local/TV/Faq/Block/Adminhtml/Item/Edit/Form.php +31 -0
- app/code/local/TV/Faq/Block/Adminhtml/Item/Edit/Tab/Form.php +138 -0
- app/code/local/TV/Faq/Block/Adminhtml/Item/Edit/Tabs.php +50 -0
- app/code/local/TV/Faq/Block/Adminhtml/Item/Grid.php +151 -0
- app/code/local/TV/Faq/Block/Frontend/Detail.php +232 -0
- app/code/local/TV/Faq/Block/Frontend/List.php +140 -0
- app/code/local/TV/Faq/Helper/Data.php +27 -0
- app/code/local/TV/Faq/Helper/Jumplist.php +93 -0
- app/code/local/TV/Faq/Helper/JumplistItem.php +136 -0
- app/code/local/TV/Faq/Model/Category.php +40 -0
- app/code/local/TV/Faq/Model/Faq.php +22 -0
- app/code/local/TV/Faq/Model/Mysql4/Category.php +103 -0
- app/code/local/TV/Faq/Model/Mysql4/Category/Collection.php +105 -0
- app/code/local/TV/Faq/Model/Mysql4/Faq.php +140 -0
- app/code/local/TV/Faq/Model/Mysql4/Faq/Collection.php +132 -0
- app/code/local/TV/Faq/Wysiwyg/Images/Content.php +161 -0
- app/code/local/TV/Faq/Wysiwyg/Images/Content/Files.php +155 -0
- app/code/local/TV/Faq/Wysiwyg/Images/Content/Newfolder.php +37 -0
- app/code/local/TV/Faq/Wysiwyg/Images/Content/Uploader.php +71 -0
- app/code/local/TV/Faq/Wysiwyg/Images/Tree.php +99 -0
- app/code/local/TV/Faq/controllers/Adminhtml/Faq/CategoryController.php +189 -0
- app/code/local/TV/Faq/controllers/Adminhtml/FaqController.php +191 -0
- app/code/local/TV/Faq/controllers/IndexController.php +31 -0
- app/code/local/TV/Faq/etc/adminhtml.xml +46 -0
- app/code/local/TV/Faq/etc/config.xml +142 -0
- app/code/local/TV/Faq/sql/faq_setup/mysql4-install-0.1.0.php +34 -0
- app/code/local/TV/Faq/sql/faq_setup/mysql4-install-1.0.7.php +64 -0
- app/code/local/TV/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/etc/modules/TV_Faq.xml +9 -0
- package.xml +18 -0
app/code/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 = 'tv_faq';
|
21 |
+
$this->_controller = 'adminhtml_category';
|
22 |
+
$this->_headerText = Mage::helper('tv_faq')->__('Manage FAQ Categories');
|
23 |
+
$this->_addButtonLabel = Mage::helper('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 = 'tv_faq';
|
22 |
+
$this->_controller = 'adminhtml_category';
|
23 |
+
|
24 |
+
parent::__construct();
|
25 |
+
|
26 |
+
$this->_updateButton('save', 'label', Mage::helper('tv_faq')->__('Save FAQ Category'));
|
27 |
+
$this->_updateButton('delete', 'label', Mage::helper('tv_faq')->__('Delete FAQ Category'));
|
28 |
+
|
29 |
+
$this->_addButton('saveandcontinue', array (
|
30 |
+
'label' => Mage::helper('tv_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('tv_faq')->__("Edit FAQ Category '%s'", $this->htmlEscape(Mage::registry('faq_category')->getCategoryName()));
|
50 |
+
}
|
51 |
+
else {
|
52 |
+
return Mage::helper('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_Faq_Block_Adminhtml_Category_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Preperation of current form
|
17 |
+
*
|
18 |
+
* @return TV_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_Faq_Block_Adminhtml_Category_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Preparation of current form
|
17 |
+
*
|
18 |
+
* @return TV_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('tv_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('tv_faq')->__('Category Name'),
|
40 |
+
'title' => Mage::helper('tv_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('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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('tv_faq')->__('Category Information'));
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Prepares the page layout
|
29 |
+
*
|
30 |
+
* Adds the tabs to the left tab menu.
|
31 |
+
*
|
32 |
+
* @return TV_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('tv_faq')->__('General information'),
|
42 |
+
'title' => Mage::helper('tv_faq')->__('General information'),
|
43 |
+
'content' => $this->getLayout()->createBlock('tv_faq/adminhtml_category_edit_tab_form')->toHtml(),
|
44 |
+
'active' => true,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
return $return;
|
49 |
+
}
|
50 |
+
}
|
app/code/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 TV_Faq_Block_Admin_Grid Self
|
33 |
+
*/
|
34 |
+
protected function _prepareCollection()
|
35 |
+
{
|
36 |
+
$collection = Mage::getResourceModel('tv_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 TV_Faq_Block_Admin_Grid Self
|
45 |
+
*/
|
46 |
+
protected function _prepareColumns()
|
47 |
+
{
|
48 |
+
$this->addColumn('category_id', array (
|
49 |
+
'header' => Mage::helper('tv_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('tv_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('tv_faq')->__('Action'),
|
90 |
+
'width' => '50px',
|
91 |
+
'type' => 'action',
|
92 |
+
'getter' => 'getId',
|
93 |
+
'actions' => array (
|
94 |
+
array (
|
95 |
+
'caption' => Mage::helper('tv_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 TV_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 = 'tv_faq';
|
21 |
+
$this->_controller = 'adminhtml_item';
|
22 |
+
$this->_headerText = Mage::helper('tv_faq')->__('Manage FAQ Items');
|
23 |
+
$this->_addButtonLabel = Mage::helper('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 = 'tv_faq';
|
23 |
+
$this->_controller = 'adminhtml_item';
|
24 |
+
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
$this->_updateButton('save', 'label', Mage::helper('tv_faq')->__('Save FAQ item'));
|
28 |
+
$this->_updateButton('delete', 'label', Mage::helper('tv_faq')->__('Delete FAQ item'));
|
29 |
+
|
30 |
+
$this->_addButton('saveandcontinue', array (
|
31 |
+
'label' => Mage::helper('tv_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('tv_faq')->__("Edit FAQ item '%s'", $this->htmlEscape(Mage::registry('faq')->getQuestion()));
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
return Mage::helper('tv_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/local/TV/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 TV_Faq_Block_Adminhtml_Item_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Preperation of current form
|
17 |
+
*
|
18 |
+
* @return TV_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 TV_Faq_Block_Admin_Edit
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Preparation of current form
|
26 |
+
*
|
27 |
+
* @return TV_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('tv_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('tv_faq')->__('FAQ item question'),
|
72 |
+
'title' => Mage::helper('tv_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('tv_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('tv_faq')->__('Category'),
|
107 |
+
'title' => Mage::helper('tv_faq')->__('Category'),
|
108 |
+
'name' => 'categories[]',
|
109 |
+
'required' => false,
|
110 |
+
'values' => Mage::getResourceSingleton('tv_faq/category_collection')->toOptionArray(),
|
111 |
+
)
|
112 |
+
);
|
113 |
+
|
114 |
+
$fieldset->addField('answer', 'editor',
|
115 |
+
array (
|
116 |
+
'name' => 'answer',
|
117 |
+
'label' => Mage::helper('tv_faq')->__('Content'),
|
118 |
+
'title' => Mage::helper('tv_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('tv_faq')->__('HTML answer'),
|
126 |
+
'title' => Mage::helper('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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('tv_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 TV_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('tv_faq')->__('General information'),
|
42 |
+
'title' => Mage::helper('tv_faq')->__('General information'),
|
43 |
+
'content' => $this->getLayout()->createBlock('tv_faq/adminhtml_item_edit_tab_form')->toHtml(),
|
44 |
+
'active' => true,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
return $return;
|
49 |
+
}
|
50 |
+
}
|
app/code/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 TV_Faq_Block_Admin_Grid Self
|
33 |
+
*/
|
34 |
+
protected function _prepareCollection()
|
35 |
+
{
|
36 |
+
//TODO: add full name logic
|
37 |
+
$collection = Mage::getResourceModel('tv_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 TV_Faq_Block_Admin_Grid Self
|
47 |
+
*/
|
48 |
+
protected function _prepareColumns()
|
49 |
+
{
|
50 |
+
$this->addColumn('faq_id', array (
|
51 |
+
'header' => Mage::helper('tv_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('tv_faq')->__('Question'),
|
72 |
+
'index' => 'question' ));
|
73 |
+
|
74 |
+
$this->addColumn('is_active',
|
75 |
+
array (
|
76 |
+
'header' => Mage::helper('tv_faq')->__('Status'),
|
77 |
+
'index' => 'is_active',
|
78 |
+
'type' => 'options',
|
79 |
+
'width' => '70px',
|
80 |
+
'options' => array (
|
81 |
+
0 => Mage::helper('tv_faq')->__('No'),
|
82 |
+
1 => Mage::helper('tv_faq')->__('Yes') ) ));
|
83 |
+
|
84 |
+
$this->addColumn('action',
|
85 |
+
array (
|
86 |
+
'header' => Mage::helper('tv_faq')->__('Action'),
|
87 |
+
'width' => '50px',
|
88 |
+
'type' => 'action',
|
89 |
+
'getter' => 'getId',
|
90 |
+
'actions' => array (
|
91 |
+
array (
|
92 |
+
'caption' => Mage::helper('tv_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 TV_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 TV_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('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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 TV_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('tv_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 TV_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('tv_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 TV_Faq_Model_Category $category
|
69 |
+
* @return TV_Faq_Model_Mysql4_Faq_Collection
|
70 |
+
*/
|
71 |
+
public function getItemCollectionByCategory(TV_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('tv_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/local/TV/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.abc.com
|
11 |
+
* Email: honeyvishnoi@gmail.com
|
12 |
+
*/
|
13 |
+
class TV_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/local/TV/Faq/Helper/Jumplist.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|