├── Block
├── Adminhtml
│ ├── Faq.php
│ ├── Faq
│ │ ├── Edit.php
│ │ └── Edit
│ │ │ ├── Form.php
│ │ │ ├── Tab
│ │ │ ├── Content.php
│ │ │ ├── General.php
│ │ │ ├── SearchEngineOptimisation.php
│ │ │ └── Websites.php
│ │ │ └── Tabs.php
│ ├── Faqcat.php
│ └── Faqcat
│ │ ├── Edit.php
│ │ └── Edit
│ │ ├── Form.php
│ │ ├── Tab
│ │ ├── General.php
│ │ ├── QuestionInCategory.php
│ │ ├── SearchEngineOptimisation.php
│ │ └── Websites.php
│ │ └── Tabs.php
├── Category
│ ├── Category.php
│ └── CategorySidebar.php
├── Faq
│ └── Faq.php
├── Links
│ └── Link.php
├── Question
│ └── Question.php
└── Search
│ ├── Search.php
│ └── SearchForm.php
├── Controller
├── Adminhtml
│ ├── Faq
│ │ ├── Delete.php
│ │ ├── Edit.php
│ │ ├── Index.php
│ │ ├── MassDelete.php
│ │ ├── MassDisable.php
│ │ ├── MassEnable.php
│ │ ├── NewAction.php
│ │ └── Save.php
│ └── Faqcat
│ │ ├── Delete.php
│ │ ├── Edit.php
│ │ ├── Index.php
│ │ ├── MassDelete.php
│ │ ├── MassDisable.php
│ │ ├── MassEnable.php
│ │ ├── NewAction.php
│ │ ├── Question.php
│ │ └── Save.php
├── Category
│ └── View.php
├── Faq
│ └── View.php
├── Question
│ ├── Ajax.php
│ └── View.php
└── Search
│ └── Index.php
├── Helper
├── Category.php
├── Config.php
└── Question.php
├── Model
├── Config
│ └── Source
│ │ ├── Admin
│ │ └── User.php
│ │ ├── Category.php
│ │ ├── IsActive.php
│ │ ├── Urlkey.php
│ │ └── Yesno.php
├── Faq.php
├── Faqcat.php
└── ResourceModel
│ ├── Faq.php
│ ├── Faq
│ ├── Collection.php
│ └── Grid
│ │ └── Collection.php
│ ├── Faqcat.php
│ └── Faqcat
│ ├── Collection.php
│ └── Grid
│ └── Collection.php
├── README.md
├── Screenshot
├── FAQ-details.png
├── FAQ-manager.png
├── edit-FAQ.png
├── edit-category.png
├── faq-category-list.png
├── faq-category.png
├── faq-page.png
├── icon
│ ├── account.png
│ ├── faq.png
│ ├── membership.png
│ ├── payment.png
│ ├── returns.png
│ ├── reward.png
│ └── shipping.png
├── linking-to-faq-page.png
└── menu.png
├── Setup
├── InstallData.php
└── InstallSchema.php
├── Ui
└── Component
│ └── Listing
│ └── Column
│ ├── FaqActions.php
│ ├── FaqcatActions.php
│ └── Thumbnail.php
├── composer.json
├── etc
├── acl.xml
├── adminhtml
│ ├── menu.xml
│ └── routes.xml
├── di.xml
├── frontend
│ └── routes.xml
└── module.xml
├── registration.php
└── view
├── adminhtml
├── layout
│ ├── phpcuong_faq_edit.xml
│ ├── phpcuong_faq_index.xml
│ ├── phpcuong_faq_new.xml
│ ├── phpcuong_faqcat_edit.xml
│ ├── phpcuong_faqcat_index.xml
│ ├── phpcuong_faqcat_new.xml
│ └── phpcuong_faqcat_question.xml
├── templates
│ └── footer
│ │ ├── copyright.phtml
│ │ ├── report.phtml
│ │ └── version.phtml
├── ui_component
│ ├── faq_listing.xml
│ └── faqcat_listing.xml
└── web
│ └── css
│ └── source
│ └── _module.less
├── base
└── web
│ ├── css
│ └── faq-extension
│ │ ├── Read Me.txt
│ │ ├── demo-files
│ │ ├── demo.css
│ │ └── demo.js
│ │ ├── demo.html
│ │ ├── fonts
│ │ ├── faq-extension.eot
│ │ ├── faq-extension.svg
│ │ ├── faq-extension.ttf
│ │ └── faq-extension.woff
│ │ ├── ie7
│ │ ├── ie7.css
│ │ └── ie7.js
│ │ ├── selection.json
│ │ └── style.css
│ └── images
│ └── faq81x81.png
└── frontend
├── layout
├── default.xml
├── faq_category_view.xml
├── faq_faq_view.xml
├── faq_question_view.xml
└── faq_search_index.xml
├── templates
├── category
│ ├── categorySidebar.phtml
│ └── view.phtml
├── faq
│ ├── form.phtml
│ └── view.phtml
├── question
│ └── view.phtml
└── search
│ └── result.phtml
└── web
├── css
├── bootstrap.css
└── source
│ └── _module.less
├── images
└── faq81x81.png
├── js
├── js-category.js
└── js-question.js
└── requirejs-config.js
/Block/Adminhtml/Faq.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 17:41:57
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-17 04:38:20
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml;
12 |
13 | /**
14 | * Adminhtml cms blocks content block
15 | */
16 | class Faq extends \Magento\Backend\Block\Widget\Grid\Container
17 | {
18 | /**
19 | * @return void
20 | */
21 | protected function _construct()
22 | {
23 | $this->_blockGroup = 'PHPCuong_Faq';
24 | $this->_controller = 'Adminhtml_Faq';
25 | $this->_headerText = __('FAQs Manager');
26 | $this->_addButtonLabel = __('Add New FAQ');
27 | parent::_construct();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 17:41:25
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:19:37
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq;
12 |
13 | use Magento\Backend\Block\Widget\Form\Container;
14 |
15 | class Edit extends Container
16 | {
17 | /**
18 | * Core registry
19 | *
20 | * @var \Magento\Framework\Registry
21 | */
22 | protected $_coreRegistry = null;
23 |
24 | /**
25 | * @param \Magento\Backend\Block\Widget\Context $context
26 | * @param \Magento\Framework\Registry $registry
27 | * @param array $data
28 | */
29 | public function __construct(
30 | \Magento\Backend\Block\Widget\Context $context,
31 | \Magento\Framework\Registry $registry,
32 | array $data = []
33 | ) {
34 | $this->_coreRegistry = $registry;
35 | parent::__construct($context, $data);
36 | }
37 |
38 | /**
39 | * Department edit block
40 | *
41 | * @return void
42 | */
43 | protected function _construct()
44 | {
45 | $this->_objectId = 'phpcuong_faq_id';
46 | $this->_blockGroup = 'PHPCuong_Faq';
47 | $this->_controller = 'adminhtml_faq';
48 | parent::_construct();
49 | }
50 |
51 | /**
52 | * Prepare layout.
53 | * Adding save_and_continue button
54 | *
55 | * @return $this
56 | */
57 | protected function _preparelayout()
58 | {
59 | if ($this->_isAllowedAction('PHPCuong_Faq::faq_create') || $this->_isAllowedAction('PHPCuong_Faq::faq_edit')) {
60 | $this->buttonList->update('save', 'label', __('Save FAQ'));
61 | $this->buttonList->add(
62 | 'saveandcontinue',
63 | [
64 | 'label' => __('Save and Continue Edit'),
65 | 'class' => 'save',
66 | 'data_attribute' => [
67 | 'mage-init' => [
68 | 'button' => [
69 | 'event' => 'saveAndContinueEdit',
70 | 'target' => '#edit_form'
71 | ],
72 | ],
73 | ]
74 | ],
75 | -100
76 | );
77 |
78 | $faq = $this->_coreRegistry->registry('phpcuong_faq');
79 | if (!empty($faq)) {
80 | if ($faq->getFaqId() && $this->_isAllowedAction('PHPCuong_Faq::faq_delete')) {
81 | $this->buttonList->add(
82 | 'delete',
83 | [
84 | 'label' => __('Delete'),
85 | 'class' => 'delete',
86 | 'onclick' => 'deleteConfirm("Are you sure you want to delete this FAQ?", "'.$this->getDeleteUrl().'")'
87 | ],
88 | -100
89 | );
90 | }
91 | }
92 | } else {
93 | $this->removeButton('save');
94 | }
95 | return parent::_prepareLayout();
96 | }
97 |
98 | /**
99 | * Check permission for passed action
100 | *
101 | * @param string $resourceId
102 | * @return bool
103 | */
104 | protected function _isAllowedAction($resourceId)
105 | {
106 | return $this->_authorization->isAllowed($resourceId);
107 | }
108 |
109 | /**
110 | * Retrieve delete Url.
111 | *
112 | * @return string
113 | */
114 | public function getDeleteUrl()
115 | {
116 | return $this->getUrl(
117 | '*/*/delete',
118 | [
119 | '_current' => true,
120 | 'id' => $this->getRequest()->getParam('faq_id')
121 | ]
122 | );
123 | }
124 |
125 | /**
126 | * Getter of url for "Save and Continue" button
127 | * tab_id will be replaced by desired by JS later
128 | *
129 | * @return string
130 | */
131 | protected function _getSaveAndContinueUrl()
132 | {
133 | return $this->getUrl(
134 | '*/*/save',
135 | [
136 | '_current' => true,
137 | 'back' => 'edit',
138 | 'active_tab' => ''
139 | ]
140 | );
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit/Form.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 17:46:49
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:26:41
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit;
12 |
13 | use \Magento\Backend\Block\Widget\Form\Generic;
14 |
15 | class Form extends Generic
16 | {
17 | /**
18 | * Initialize theme form
19 | *
20 | * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Form|\Magento\Backend\Block\Widget\Form
21 | */
22 | protected function _prepareForm()
23 | {
24 | /** @var \Magento\Framework\Data\Form $form */
25 | $form = $this->_formFactory->create(
26 | [
27 | 'data' => [
28 | 'id' => 'edit_form',
29 | 'action' => $this->getData('action'),
30 | 'method' => 'post'
31 | ]
32 | ]
33 | );
34 |
35 | $form->setUseContainer(true);
36 | $this->setForm($form);
37 | return parent::_prepareForm();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit/Tab/Content.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 01:38:53
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-11 14:36:05
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit\Tab;
12 |
13 | class Content extends \Magento\Backend\Block\Widget\Form\Generic implements
14 | \Magento\Backend\Block\Widget\Tab\TabInterface
15 | {
16 | /**
17 | * Wysiwyg config
18 | *
19 | * @var \Magento\Cms\Model\Wysiwyg\Config
20 | */
21 | protected $_wysiwygConfig;
22 |
23 | /**
24 | * Core registry
25 | *
26 | * @var \Magento\Framework\Registry
27 | */
28 | protected $_coreRegistry;
29 |
30 | /**
31 | * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
32 | * @param \Magento\Backend\Block\Template\Context $context
33 | * @param \Magento\Framework\Registry $registry
34 | * @param \Magento\Framework\Data\FormFactory $formFactory
35 | * @param array $data
36 | */
37 | public function __construct(
38 | \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
39 | \Magento\Backend\Block\Template\Context $context,
40 | \Magento\Framework\Registry $registry,
41 | \Magento\Framework\Data\FormFactory $formFactory,
42 | array $data = []
43 | ) {
44 | $this->_wysiwygConfig = $wysiwygConfig;
45 | parent::__construct($context, $registry, $formFactory, $data);
46 | }
47 |
48 | /**
49 | * @return void
50 | */
51 | protected function _construct()
52 | {
53 | parent::_construct();
54 | $this->setActive(true);
55 | }
56 |
57 | /**
58 | * Prepare label for tab
59 | *
60 | * @return \Magento\Framework\Phrase
61 | */
62 | public function getTabLabel()
63 | {
64 | return __('Answer');
65 | }
66 |
67 | /**
68 | * Prepare title for tab
69 | *
70 | * @return \Magento\Framework\Phrase
71 | */
72 | public function getTabTitle()
73 | {
74 | return $this->getTabLabel();
75 | }
76 |
77 | /**
78 | * Returns status flag about this tab can be showen or not
79 | *
80 | * @return true
81 | */
82 | public function canShowTab()
83 | {
84 | return true;
85 | }
86 |
87 | /**
88 | * Returns status flag about this tab hidden or not
89 | *
90 | * @return true
91 | */
92 | public function isHidden()
93 | {
94 | return false;
95 | }
96 |
97 | /**
98 | * Prepare form before rendering HTML
99 | *
100 | * @return $this
101 | */
102 | protected function _prepareForm()
103 | {
104 | /** @var \Magento\Framework\Data\Form $form */
105 | $form = $this->_formFactory->create();
106 |
107 | $fieldset = $form->addFieldset(
108 | 'base_fieldset',
109 | ['legend' => __('Answer')]
110 | );
111 |
112 | $this->_addElementTypes($fieldset);
113 |
114 | $fieldset->addField(
115 | 'content',
116 | 'editor',
117 | [
118 | 'name' => 'content',
119 | 'label' => __('Answer'),
120 | 'title' => __('Answer'),
121 | 'required' => true,
122 | 'config' => $this->_wysiwygConfig->getConfig()
123 | ]
124 | );
125 |
126 | $formData = $this->_coreRegistry->registry('phpcuong_faq');
127 | if ($formData) {
128 | $form->setValues($formData->getData());
129 | }
130 |
131 | $this->setForm($form);
132 |
133 | return parent::_prepareForm();
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit/Tab/General.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 00:18:36
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:23:33
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit\Tab;
12 |
13 | class General extends \Magento\Backend\Block\Widget\Form\Generic implements
14 | \Magento\Backend\Block\Widget\Tab\TabInterface
15 | {
16 | /**
17 | * Active or InActive
18 | *
19 | * @var \PHPCuong\Faq\Model\Config\Source\IsActive
20 | */
21 | protected $_status;
22 |
23 | /**
24 | * Yes or No
25 | *
26 | * @var \PHPCuong\Faq\Model\Config\Source\Yesno
27 | */
28 | protected $_yesNo;
29 |
30 | /**
31 | * Category
32 | *
33 | * @var \PHPCuong\Faq\Model\Config\Source\Category
34 | */
35 | protected $_category;
36 |
37 | /**
38 | * Core registry
39 | *
40 | * @var \Magento\Framework\Registry
41 | */
42 | protected $_coreRegistry;
43 |
44 | /**
45 | * @param \PHPCuong\Faq\Model\Config\Source\Category $category
46 | * @param \PHPCuong\Faq\Model\Config\Source\Yesno $yesNo
47 | * @param \PHPCuong\Faq\Model\Config\Source\IsActive $status
48 | * @param \Magento\Backend\Block\Template\Context $context
49 | * @param \Magento\Framework\Registry $registry
50 | * @param \Magento\Framework\Data\FormFactory $formFactory
51 | * @param array $data
52 | */
53 | public function __construct(
54 | \PHPCuong\Faq\Model\Config\Source\Category $category,
55 | \PHPCuong\Faq\Model\Config\Source\Yesno $yesNo,
56 | \PHPCuong\Faq\Model\Config\Source\IsActive $status,
57 | \Magento\Backend\Block\Template\Context $context,
58 | \Magento\Framework\Registry $registry,
59 | \Magento\Framework\Data\FormFactory $formFactory,
60 | array $data = []
61 | ) {
62 | $this->_category = $category;
63 | $this->_yesNo = $yesNo;
64 | $this->_status = $status;
65 | parent::__construct($context, $registry, $formFactory, $data);
66 | }
67 |
68 | /**
69 | * @return void
70 | */
71 | protected function _construct()
72 | {
73 | parent::_construct();
74 | $this->setActive(true);
75 | }
76 |
77 | /**
78 | * Prepare label for tab
79 | *
80 | * @return \Magento\Framework\Phrase
81 | */
82 | public function getTabLabel()
83 | {
84 | return __('General Information');
85 | }
86 |
87 | /**
88 | * Prepare title for tab
89 | *
90 | * @return \Magento\Framework\Phrase
91 | */
92 | public function getTabTitle()
93 | {
94 | return $this->getTabLabel();
95 | }
96 |
97 | /**
98 | * Returns status flag about this tab can be showen or not
99 | *
100 | * @return true
101 | */
102 | public function canShowTab()
103 | {
104 | return true;
105 | }
106 |
107 | /**
108 | * Returns status flag about this tab hidden or not
109 | *
110 | * @return true
111 | */
112 | public function isHidden()
113 | {
114 | return false;
115 | }
116 |
117 | /**
118 | * Prepare form before rendering HTML
119 | *
120 | * @return $this
121 | */
122 | protected function _prepareForm()
123 | {
124 | /** @var \Magento\Framework\Data\Form $form */
125 | $form = $this->_formFactory->create();
126 |
127 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information')]);
128 |
129 | $this->_addElementTypes($fieldset);
130 |
131 | $fieldset->addField(
132 | 'is_active',
133 | 'select',
134 | [
135 | 'name' => 'is_active',
136 | 'label' => __('Status'),
137 | 'title' => __('Status'),
138 | 'required' => true,
139 | 'values' => $this->_status->getStatusOptions()
140 | ]
141 | );
142 |
143 | $fieldset->addField(
144 | 'title',
145 | 'text',
146 | [
147 | 'name' => 'title',
148 | 'label' => __('Title'),
149 | 'title' => __('Title'),
150 | 'required' => true
151 | ]
152 | );
153 |
154 | $fieldset->addField(
155 | 'most_frequently',
156 | 'select',
157 | [
158 | 'name' => 'most_frequently',
159 | 'label' => __('Most frequently'),
160 | 'title' => __('Most frequently'),
161 | 'values' => $this->_yesNo->getYesnoOptions()
162 | ]
163 | );
164 |
165 | $fieldset->addField(
166 | 'category_id',
167 | 'select',
168 | [
169 | 'name' => 'category_id',
170 | 'label' => __('Category'),
171 | 'title' => __('Category'),
172 | 'values' => $this->_category->getCategoryOptions(),
173 | 'required' => true
174 | ]
175 | );
176 |
177 | $fieldset->addField(
178 | 'sort_order',
179 | 'text',
180 | [
181 | 'name' => 'sort_order',
182 | 'label' => __('Sort Order'),
183 | 'title' => __('Sort Order'),
184 | 'size' => '10'
185 | ]
186 | );
187 |
188 | $formData = $this->_coreRegistry->registry('phpcuong_faq');
189 | if ($formData) {
190 | if ($formData->getFaqId()) {
191 | $fieldset->addField(
192 | 'faq_id',
193 | 'hidden',
194 | ['name' => 'faq_id']
195 | );
196 | }
197 | if ($formData->getIsActive() == null) {
198 | $formData->setIsActive('1');
199 | }
200 | $form->setValues($formData->getData());
201 | }
202 |
203 | $this->setForm($form);
204 |
205 | return parent::_prepareForm();
206 | }
207 | }
208 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit/Tab/SearchEngineOptimisation.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 01:32:56
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:24:33
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit\Tab;
12 |
13 | class SearchEngineOptimisation extends \Magento\Backend\Block\Widget\Form\Generic implements
14 | \Magento\Backend\Block\Widget\Tab\TabInterface
15 | {
16 | /**
17 | * Core registry
18 | *
19 | * @var \Magento\Framework\Registry
20 | */
21 | protected $_coreRegistry;
22 |
23 | /**
24 | * @param \Magento\Backend\Block\Template\Context $context
25 | * @param \Magento\Framework\Registry $registry
26 | * @param \Magento\Framework\Data\FormFactory $formFactory
27 | * @param array $data
28 | */
29 | public function __construct(
30 | \Magento\Backend\Block\Template\Context $context,
31 | \Magento\Framework\Registry $registry,
32 | \Magento\Framework\Data\FormFactory $formFactory,
33 | array $data = []
34 | ) {
35 | parent::__construct($context, $registry, $formFactory, $data);
36 | }
37 |
38 | /**
39 | * @return void
40 | */
41 | protected function _construct()
42 | {
43 | parent::_construct();
44 | $this->setActive(true);
45 | }
46 |
47 | /**
48 | * Prepare label for tab
49 | *
50 | * @return \Magento\Framework\Phrase
51 | */
52 | public function getTabLabel()
53 | {
54 | return __('Search Engine Optimisation');
55 | }
56 |
57 | /**
58 | * Prepare title for tab
59 | *
60 | * @return \Magento\Framework\Phrase
61 | */
62 | public function getTabTitle()
63 | {
64 | return $this->getTabLabel();
65 | }
66 |
67 | /**
68 | * Returns status flag about this tab can be showen or not
69 | *
70 | * @return true
71 | */
72 | public function canShowTab()
73 | {
74 | return true;
75 | }
76 |
77 | /**
78 | * Returns status flag about this tab hidden or not
79 | *
80 | * @return true
81 | */
82 | public function isHidden()
83 | {
84 | return false;
85 | }
86 |
87 | /**
88 | * Prepare form before rendering HTML
89 | *
90 | * @return $this
91 | */
92 | protected function _prepareForm()
93 | {
94 | /** @var \Magento\Framework\Data\Form $form */
95 | $form = $this->_formFactory->create();
96 |
97 | $fieldset = $form->addFieldset(
98 | 'base_fieldset',
99 | ['legend' => __('Search Engine Optimisation')]
100 | );
101 |
102 | $this->_addElementTypes($fieldset);
103 |
104 | $fieldset->addField(
105 | 'identifier',
106 | 'text',
107 | [
108 | 'name' => 'identifier',
109 | 'label' => __('URL Key'),
110 | 'title' => __('URL Key')
111 | ]
112 | );
113 |
114 | $fieldset->addField(
115 | 'meta_keywords',
116 | 'textarea',
117 | [
118 | 'name' => 'meta_keywords',
119 | 'label' => __('Meta Keywords'),
120 | 'title' => __('Meta Keywords'),
121 | 'cols' => '15',
122 | 'row' => '2'
123 | ]
124 | );
125 |
126 | $fieldset->addField(
127 | 'meta_description',
128 | 'textarea',
129 | [
130 | 'name' => 'meta_description',
131 | 'label' => __('Meta Description'),
132 | 'title' => __('Meta Description'),
133 | 'cols' => '15',
134 | 'row' => '2'
135 | ]
136 | );
137 |
138 | $formData = $this->_coreRegistry->registry('phpcuong_faq');
139 | if ($formData) {
140 | $form->setValues($formData->getData());
141 | }
142 |
143 | $this->setForm($form);
144 |
145 | return parent::_prepareForm();
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit/Tab/Websites.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 01:11:17
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:25:43
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit\Tab;
12 |
13 | use Magento\Store\Model\Store;
14 |
15 | class Websites extends \Magento\Backend\Block\Widget\Form\Generic implements
16 | \Magento\Backend\Block\Widget\Tab\TabInterface
17 | {
18 | /**
19 | * Core registry
20 | *
21 | * @var \Magento\Framework\Registry
22 | */
23 | protected $_coreRegistry;
24 |
25 | /**
26 | * @var \Magento\Store\Model\System\Store
27 | */
28 | protected $_systemStore;
29 |
30 | /**
31 | * @param \Magento\Store\Model\System\Store $systemStore
32 | * @param \Magento\Backend\Block\Template\Context $context
33 | * @param \Magento\Framework\Registry $registry
34 | * @param \Magento\Framework\Data\FormFactory $formFactory
35 | * @param array $data
36 | */
37 | public function __construct(
38 | \Magento\Store\Model\System\Store $systemStore,
39 | \Magento\Backend\Block\Template\Context $context,
40 | \Magento\Framework\Registry $registry,
41 | \Magento\Framework\Data\FormFactory $formFactory,
42 | array $data = []
43 | ) {
44 | $this->_systemStore = $systemStore;
45 | parent::__construct($context, $registry, $formFactory, $data);
46 | }
47 |
48 | /**
49 | * @return void
50 | */
51 | protected function _construct()
52 | {
53 | parent::_construct();
54 | $this->setActive(true);
55 | }
56 |
57 | /**
58 | * Prepare label for tab
59 | *
60 | * @return \Magento\Framework\Phrase
61 | */
62 | public function getTabLabel()
63 | {
64 | return __('FAQ in Websites');
65 | }
66 |
67 | /**
68 | * Prepare title for tab
69 | *
70 | * @return \Magento\Framework\Phrase
71 | */
72 | public function getTabTitle()
73 | {
74 | return $this->getTabLabel();
75 | }
76 |
77 | /**
78 | * Returns status flag about this tab can be showen or not
79 | *
80 | * @return true
81 | */
82 | public function canShowTab()
83 | {
84 | return true;
85 | }
86 |
87 | /**
88 | * Returns status flag about this tab hidden or not
89 | *
90 | * @return true
91 | */
92 | public function isHidden()
93 | {
94 | return false;
95 | }
96 |
97 | /**
98 | * Prepare form before rendering HTML
99 | *
100 | * @return $this
101 | */
102 | protected function _prepareForm()
103 | {
104 | /** @var \Magento\Framework\Data\Form $form */
105 | $form = $this->_formFactory->create();
106 |
107 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('FAQ in Websites')]);
108 |
109 | $this->_addElementTypes($fieldset);
110 |
111 | $formData = $this->_coreRegistry->registry('phpcuong_faq');
112 |
113 | $field = $fieldset->addField(
114 | 'stores',
115 | 'multiselect',
116 | [
117 | 'label' => __('Stores View'),
118 | 'title' => __('Stores View'),
119 | 'required' => true,
120 | 'name' => 'stores[]',
121 | 'values' => $this->_systemStore->getStoreValuesForForm(false, true)
122 | ]
123 | );
124 |
125 | $renderer = $this->getLayout()->createBlock(
126 | 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'
127 | );
128 |
129 | $field->setRenderer($renderer);
130 |
131 | $formData->setSelectStores($formData->getStores());
132 |
133 | if ($formData) {
134 | if ($formData->getStores() == null) {
135 | $formData->setStores([Store::DEFAULT_STORE_ID]);
136 | }
137 | $form->setValues($formData->getData());
138 | }
139 |
140 | $this->setForm($form);
141 |
142 | return parent::_prepareForm();
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faq/Edit/Tabs.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 00:14:40
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-19 21:29:23
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faq\Edit;
12 |
13 | class Tabs extends \Magento\Backend\Block\Widget\Tabs
14 | {
15 | /**
16 | * Internal constructor
17 | *
18 | * @return void
19 | */
20 | protected function _construct()
21 | {
22 | parent::_construct();
23 | $this->setId('faq_tabs');
24 | $this->setDestElementId('edit_form');
25 | $this->setTitle(__('Question Information'));
26 | }
27 |
28 | protected function _beforeToHtml()
29 | {
30 | $this->setActiveTab('general_section');
31 | return parent::_beforeToHtml();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:20:49
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-19 23:21:27
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml;
12 |
13 | /**
14 | * Adminhtml cms blocks content block
15 | */
16 | class Faqcat extends \Magento\Backend\Block\Widget\Grid\Container
17 | {
18 | /**
19 | * @return void
20 | */
21 | protected function _construct()
22 | {
23 | $this->_blockGroup = 'PHPCuong_Faqcat';
24 | $this->_controller = 'Adminhtml_Faqcat';
25 | $this->_headerText = __('FAQ Categories Manager');
26 | $this->_addButtonLabel = __('Add New Category');
27 | parent::_construct();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:21:42
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:14:14
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat;
12 |
13 | use Magento\Backend\Block\Widget\Form\Container;
14 |
15 | class Edit extends Container
16 | {
17 | /**
18 | * Core registry
19 | *
20 | * @var \Magento\Framework\Registry
21 | */
22 | protected $_coreRegistry = null;
23 |
24 | /**
25 | * @param \Magento\Backend\Block\Widget\Context $context
26 | * @param \Magento\Framework\Registry $registry
27 | * @param array $data
28 | */
29 | public function __construct(
30 | \Magento\Backend\Block\Widget\Context $context,
31 | \Magento\Framework\Registry $registry,
32 | array $data = []
33 | ) {
34 | $this->_coreRegistry = $registry;
35 | parent::__construct($context, $data);
36 | }
37 |
38 | /**
39 | * Department edit block
40 | *
41 | * @return void
42 | */
43 | protected function _construct()
44 | {
45 | $this->_objectId = 'phpcuong_faqcat_id';
46 | $this->_blockGroup = 'PHPCuong_Faq';
47 | $this->_controller = 'adminhtml_faqcat';
48 | parent::_construct();
49 | }
50 |
51 | /**
52 | * Prepare layout.
53 | * Adding save_and_continue button
54 | *
55 | * @return $this
56 | */
57 | protected function _preparelayout()
58 | {
59 | if ($this->_isAllowedAction('PHPCuong_Faq::category_create') || $this->_isAllowedAction('PHPCuong_Faq::category_edit')) {
60 | $this->buttonList->update('save', 'label', __('Save Category'));
61 | $this->buttonList->add(
62 | 'saveandcontinue',
63 | [
64 | 'label' => __('Save and Continue Edit'),
65 | 'class' => 'save',
66 | 'data_attribute' => [
67 | 'mage-init' => [
68 | 'button' => [
69 | 'event' => 'saveAndContinueEdit',
70 | 'target' => '#edit_form'
71 | ],
72 | ],
73 | ]
74 | ],
75 | -100
76 | );
77 |
78 | $faqCat = $this->_coreRegistry->registry('phpcuong_faqcat');
79 | if (!empty($faqCat)) {
80 | if ($faqCat->getCategoryId() && $this->_isAllowedAction('PHPCuong_Faq::category_delete')) {
81 | $this->buttonList->add(
82 | 'delete',
83 | [
84 | 'label' => __('Delete'),
85 | 'class' => 'delete',
86 | 'onclick' => 'deleteConfirm("Are you sure you want to delete this Category?", "'.$this->getDeleteUrl().'")'
87 | ],
88 | -100
89 | );
90 | }
91 | }
92 | } else {
93 | $this->removeButton('save');
94 | }
95 | return parent::_prepareLayout();
96 | }
97 |
98 | /**
99 | * Check permission for passed action
100 | *
101 | * @param string $resourceId
102 | * @return bool
103 | */
104 | protected function _isAllowedAction($resourceId)
105 | {
106 | return $this->_authorization->isAllowed($resourceId);
107 | }
108 |
109 | /**
110 | * Retrieve delete Url.
111 | *
112 | * @return string
113 | */
114 | public function getDeleteUrl()
115 | {
116 | return $this->getUrl(
117 | '*/*/delete',
118 | [
119 | '_current' => true,
120 | 'id' => $this->getRequest()->getParam('category_id')
121 | ]
122 | );
123 | }
124 |
125 | /**
126 | * Getter of url for "Save and Continue" button
127 | * tab_id will be replaced by desired by JS later
128 | *
129 | * @return string
130 | */
131 | protected function _getSaveAndContinueUrl()
132 | {
133 | return $this->getUrl(
134 | '*/*/save',
135 | [
136 | '_current' => true,
137 | 'back' => 'edit',
138 | 'active_tab' => ''
139 | ]
140 | );
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit/Form.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:28:33
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:31:13
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit;
12 |
13 | use \Magento\Backend\Block\Widget\Form\Generic;
14 |
15 | class Form extends Generic
16 | {
17 | /**
18 | * Initialize theme form
19 | *
20 | * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Form|\Magento\Backend\Block\Widget\Form
21 | */
22 | protected function _prepareForm()
23 | {
24 | /** @var \Magento\Framework\Data\Form $form */
25 | $form = $this->_formFactory->create(
26 | [
27 | 'data' => [
28 | 'id' => 'edit_form',
29 | 'action' => $this->getData('action'),
30 | 'method' => 'post',
31 | 'enctype' => 'multipart/form-data'
32 | ],
33 | ]
34 | );
35 |
36 | $form->setUseContainer(true);
37 |
38 | $this->setForm($form);
39 |
40 | return parent::_prepareForm();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit/Tab/General.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:30:17
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-28 00:03:44
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab;
12 |
13 | class General extends \Magento\Backend\Block\Widget\Form\Generic implements
14 | \Magento\Backend\Block\Widget\Tab\TabInterface
15 | {
16 | /**
17 | * Active or InActive
18 | *
19 | * @var \PHPCuong\Faq\Model\Config\Source\IsActive
20 | */
21 | protected $_status;
22 |
23 | /**
24 | * Yes or No
25 | *
26 | * @var \PHPCuong\Faq\Model\Config\Source\Yesno
27 | */
28 | protected $_yesNo;
29 |
30 | /**
31 | * Core registry
32 | *
33 | * @var \Magento\Framework\Registry
34 | */
35 | protected $_coreRegistry;
36 |
37 | /**
38 | * @param \PHPCuong\Faq\Model\Config\Source\Yesno $yesNo
39 | * @param \PHPCuong\Faq\Model\Config\Source\IsActive $status
40 | * @param \Magento\Backend\Block\Template\Context $context
41 | * @param \Magento\Framework\Registry $registry
42 | * @param \Magento\Framework\Data\FormFactory $formFactory
43 | * @param array $data
44 | */
45 | public function __construct(
46 | \PHPCuong\Faq\Model\Config\Source\Yesno $yesNo,
47 | \PHPCuong\Faq\Model\Config\Source\IsActive $status,
48 | \Magento\Backend\Block\Template\Context $context,
49 | \Magento\Framework\Registry $registry,
50 | \Magento\Framework\Data\FormFactory $formFactory,
51 | array $data = []
52 | ) {
53 | $this->_yesNo = $yesNo;
54 | $this->_status = $status;
55 | parent::__construct($context, $registry, $formFactory, $data);
56 | }
57 |
58 | /**
59 | * @return void
60 | */
61 | protected function _construct()
62 | {
63 | parent::_construct();
64 | $this->setActive(true);
65 | }
66 |
67 | /**
68 | * Prepare label for tab
69 | *
70 | * @return \Magento\Framework\Phrase
71 | */
72 | public function getTabLabel()
73 | {
74 | return __('General Information');
75 | }
76 |
77 | /**
78 | * Prepare title for tab
79 | *
80 | * @return \Magento\Framework\Phrase
81 | */
82 | public function getTabTitle()
83 | {
84 | return $this->getTabLabel();
85 | }
86 |
87 | /**
88 | * Returns status flag about this tab can be showen or not
89 | *
90 | * @return true
91 | */
92 | public function canShowTab()
93 | {
94 | return true;
95 | }
96 |
97 | /**
98 | * Returns status flag about this tab hidden or not
99 | *
100 | * @return true
101 | */
102 | public function isHidden()
103 | {
104 | return false;
105 | }
106 |
107 | /**
108 | * Prepare form before rendering HTML
109 | *
110 | * @return $this
111 | */
112 | protected function _prepareForm()
113 | {
114 | /** @var \Magento\Framework\Data\Form $form */
115 | $form = $this->_formFactory->create();
116 |
117 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information')]);
118 |
119 | $this->_addElementTypes($fieldset);
120 |
121 | $fieldset->addField(
122 | 'is_active',
123 | 'select',
124 | [
125 | 'name' => 'faqcat_is_active',
126 | 'label' => __('Status'),
127 | 'title' => __('Status'),
128 | 'required' => true,
129 | 'values' => $this->_status->getStatusOptions()
130 | ]
131 | );
132 |
133 | $fieldset->addField(
134 | 'title',
135 | 'text',
136 | [
137 | 'name' => 'faqcat_title',
138 | 'label' => __('Title'),
139 | 'title' => __('Title'),
140 | 'required' => true
141 | ]
142 | );
143 |
144 | $fieldset->addField(
145 | 'image',
146 | 'image',
147 | [
148 | 'name' => 'image',
149 | 'label' => __('Category icon'),
150 | 'title' => __('Category icon'),
151 | 'note' => __('Allow image type: jpg, jpeg, gif, png')
152 | ]
153 | );
154 |
155 | $fieldset->addField(
156 | 'sort_order',
157 | 'text',
158 | [
159 | 'name' => 'sort_order',
160 | 'label' => __('Sort Order'),
161 | 'title' => __('Sort Order'),
162 | 'size' => '10'
163 | ]
164 | );
165 |
166 | $formData = $this->_coreRegistry->registry('phpcuong_faqcat');
167 | if ($formData) {
168 | if ($formData->getCategoryId()) {
169 | $fieldset->addField(
170 | 'category_id',
171 | 'hidden',
172 | ['name' => 'category_id']
173 | );
174 | }
175 | if ($formData->getIsActive() == null) {
176 | $formData->setIsActive('1');
177 | }
178 | $form->setValues($formData->getData());
179 | }
180 |
181 | $this->setForm($form);
182 |
183 | return parent::_prepareForm();
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit/Tab/QuestionInCategory.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-27 06:54:56
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:19:12
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab;
12 |
13 | class QuestionInCategory extends \Magento\Backend\Block\Widget\Grid\Extended
14 | {
15 | /**
16 | * Active or InActive
17 | *
18 | * @var \PHPCuong\Faq\Model\Config\Source\IsActive
19 | */
20 | protected $_status;
21 |
22 | /**
23 | * @var \PHPCuong\Faq\Model\Faq
24 | */
25 | protected $_faqModel;
26 |
27 | /**
28 | * @var array
29 | */
30 | protected $_optionLocales;
31 |
32 | public function __construct(
33 | \Magento\Backend\Block\Template\Context $context,
34 | \Magento\Backend\Helper\Data $backendHelper,
35 | \PHPCuong\Faq\Model\Faq $faqModel,
36 | \Magento\Framework\Registry $coreRegistry,
37 | \PHPCuong\Faq\Model\Config\Source\IsActive $status,
38 | array $data = []
39 | ) {
40 | $this->_faqModel = $faqModel;
41 | $this->_coreRegistry = $coreRegistry;
42 | $this->_status = $status;
43 | parent::__construct($context, $backendHelper, $data);
44 | }
45 |
46 | /**
47 | * @return void
48 | */
49 | protected function _construct()
50 | {
51 | parent::_construct();
52 | $this->setId('region_tab_grid');
53 | $this->setDefaultSort('faq_id');
54 | $this->setDefaultDir('DESC');
55 | $this->setUseAjax(true);
56 | }
57 |
58 | /**
59 | * @return Grid
60 | */
61 | protected function _prepareCollection()
62 | {
63 | $collection = $this->_faqModel->getCollection();
64 | if ($category_id = $this->getRequest()->getParam('category_id')) {
65 | $collection->getSelect()->join(['fcat' => 'phpcuong_faq_category_id'], 'main_table.faq_id = fcat.faq_id', ['category_id'])->where('fcat.category_id =?', (int) $category_id);
66 | }
67 | $this->setCollection($collection);
68 | return parent::_prepareCollection();
69 | }
70 |
71 | /**
72 | * @return Extended
73 | */
74 | protected function _prepareColumns()
75 | {
76 | $this->addColumn(
77 | 'title',
78 | [
79 | 'header' => __('Title'),
80 | 'index' => 'title',
81 | 'type' => 'text'
82 | ]
83 | );
84 |
85 | $this->addColumn(
86 | 'is_active',
87 | [
88 | 'header' => __('Status'),
89 | 'index' => 'is_active',
90 | 'type' => 'options',
91 | 'options' => $this->_status->getStatusOptions(1)
92 | ]
93 | );
94 |
95 | $this->addColumn(
96 | 'edit',
97 | [
98 | 'header' => __('Action'),
99 | 'type' => 'action',
100 | 'getter' => 'getFaqId',
101 | 'actions' => [
102 | [
103 | 'caption' => __('Edit'),
104 | 'url' => [
105 | 'base' => '*/faq/edit'
106 | ],
107 | 'field' => 'faq_id'
108 | ]
109 | ],
110 | 'filter' => false,
111 | 'sortable' => false,
112 | 'header_css_class' => 'col-action',
113 | 'column_css_class' => 'col-action'
114 | ]
115 | );
116 |
117 | return parent::_prepareColumns();
118 | }
119 |
120 | /**
121 | * @return string
122 | */
123 | public function getGridUrl()
124 | {
125 | return $this->getUrl('*/faqcat/question', ['_current' => true]);
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit/Tab/SearchEngineOptimisation.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:32:26
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:29:54
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab;
12 |
13 | class SearchEngineOptimisation extends \Magento\Backend\Block\Widget\Form\Generic implements
14 | \Magento\Backend\Block\Widget\Tab\TabInterface
15 | {
16 | /**
17 | * Core registry
18 | *
19 | * @var \Magento\Framework\Registry
20 | */
21 | protected $_coreRegistry;
22 |
23 | /**
24 | * @param \Magento\Backend\Block\Template\Context $context
25 | * @param \Magento\Framework\Registry $registry
26 | * @param \Magento\Framework\Data\FormFactory $formFactory
27 | * @param array $data
28 | */
29 | public function __construct(
30 | \Magento\Backend\Block\Template\Context $context,
31 | \Magento\Framework\Registry $registry,
32 | \Magento\Framework\Data\FormFactory $formFactory,
33 | array $data = []
34 | ) {
35 | parent::__construct($context, $registry, $formFactory, $data);
36 | }
37 |
38 | /**
39 | * @return void
40 | */
41 | protected function _construct()
42 | {
43 | parent::_construct();
44 | $this->setActive(true);
45 | }
46 |
47 | /**
48 | * Prepare label for tab
49 | *
50 | * @return \Magento\Framework\Phrase
51 | */
52 | public function getTabLabel()
53 | {
54 | return __('Search Engine Optimisation');
55 | }
56 |
57 | /**
58 | * Prepare title for tab
59 | *
60 | * @return \Magento\Framework\Phrase
61 | */
62 | public function getTabTitle()
63 | {
64 | return $this->getTabLabel();
65 | }
66 |
67 | /**
68 | * Returns status flag about this tab can be showen or not
69 | *
70 | * @return true
71 | */
72 | public function canShowTab()
73 | {
74 | return true;
75 | }
76 |
77 | /**
78 | * Returns status flag about this tab hidden or not
79 | *
80 | * @return true
81 | */
82 | public function isHidden()
83 | {
84 | return false;
85 | }
86 |
87 | /**
88 | * Prepare form before rendering HTML
89 | *
90 | * @return $this
91 | */
92 | protected function _prepareForm()
93 | {
94 | /** @var \Magento\Framework\Data\Form $form */
95 | $form = $this->_formFactory->create();
96 |
97 | $fieldset = $form->addFieldset(
98 | 'base_fieldset',
99 | ['legend' => __('Search Engine Optimisation')]
100 | );
101 |
102 | $this->_addElementTypes($fieldset);
103 |
104 | $fieldset->addField(
105 | 'identifier',
106 | 'text',
107 | [
108 | 'name' => 'identifier',
109 | 'label' => __('URL Key'),
110 | 'title' => __('URL Key')
111 | ]
112 | );
113 |
114 | $fieldset->addField(
115 | 'meta_keywords',
116 | 'textarea',
117 | [
118 | 'name' => 'meta_keywords',
119 | 'label' => __('Meta Keywords'),
120 | 'title' => __('Meta Keywords'),
121 | 'cols' => '15',
122 | 'row' => '2'
123 | ]
124 | );
125 |
126 | $fieldset->addField(
127 | 'meta_description',
128 | 'textarea',
129 | [
130 | 'name' => 'meta_description',
131 | 'label' => __('Meta Description'),
132 | 'title' => __('Meta Description'),
133 | 'cols' => '15',
134 | 'row' => '2'
135 | ]
136 | );
137 |
138 | $formData = $this->_coreRegistry->registry('phpcuong_faqcat');
139 | if ($formData) {
140 | $form->setValues($formData->getData());
141 | }
142 |
143 | $this->setForm($form);
144 |
145 | return parent::_prepareForm();
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit/Tab/Websites.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:54:01
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 15:30:44
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab;
12 |
13 | use Magento\Store\Model\Store;
14 |
15 | class Websites extends \Magento\Backend\Block\Widget\Form\Generic implements
16 | \Magento\Backend\Block\Widget\Tab\TabInterface
17 | {
18 | /**
19 | * Core registry
20 | *
21 | * @var \Magento\Framework\Registry
22 | */
23 | protected $_coreRegistry;
24 |
25 | /**
26 | * @var \Magento\Store\Model\System\Store
27 | */
28 | protected $_systemStore;
29 |
30 | /**
31 | * @param \Magento\Store\Model\System\Store $systemStore
32 | * @param \Magento\Backend\Block\Template\Context $context
33 | * @param \Magento\Framework\Registry $registry
34 | * @param \Magento\Framework\Data\FormFactory $formFactory
35 | * @param array $data
36 | */
37 | public function __construct(
38 | \Magento\Store\Model\System\Store $systemStore,
39 | \Magento\Backend\Block\Template\Context $context,
40 | \Magento\Framework\Registry $registry,
41 | \Magento\Framework\Data\FormFactory $formFactory,
42 | array $data = []
43 | ) {
44 | $this->_systemStore = $systemStore;
45 | parent::__construct($context, $registry, $formFactory, $data);
46 | }
47 |
48 | /**
49 | * @return void
50 | */
51 | protected function _construct()
52 | {
53 | parent::_construct();
54 | $this->setActive(true);
55 | }
56 |
57 | /**
58 | * Prepare label for tab
59 | *
60 | * @return \Magento\Framework\Phrase
61 | */
62 | public function getTabLabel()
63 | {
64 | return __('FAQ Category in Websites');
65 | }
66 |
67 | /**
68 | * Prepare title for tab
69 | *
70 | * @return \Magento\Framework\Phrase
71 | */
72 | public function getTabTitle()
73 | {
74 | return $this->getTabLabel();
75 | }
76 |
77 | /**
78 | * Returns status flag about this tab can be showen or not
79 | *
80 | * @return true
81 | */
82 | public function canShowTab()
83 | {
84 | return true;
85 | }
86 |
87 | /**
88 | * Returns status flag about this tab hidden or not
89 | *
90 | * @return true
91 | */
92 | public function isHidden()
93 | {
94 | return false;
95 | }
96 |
97 | /**
98 | * Prepare form before rendering HTML
99 | *
100 | * @return $this
101 | */
102 | protected function _prepareForm()
103 | {
104 | /** @var \Magento\Framework\Data\Form $form */
105 | $form = $this->_formFactory->create();
106 |
107 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('FAQ Category in Websites')]);
108 |
109 | $this->_addElementTypes($fieldset);
110 |
111 | $formData = $this->_coreRegistry->registry('phpcuong_faqcat');
112 |
113 | $field = $fieldset->addField(
114 | 'stores',
115 | 'multiselect',
116 | [
117 | 'label' => __('Stores View'),
118 | 'title' => __('Stores View'),
119 | 'required' => true,
120 | 'name' => 'stores[]',
121 | 'values' => $this->_systemStore->getStoreValuesForForm(false, true)
122 | ]
123 | );
124 |
125 | $renderer = $this->getLayout()->createBlock(
126 | 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element'
127 | );
128 |
129 | $field->setRenderer($renderer);
130 |
131 | $formData->setSelectStores($formData->getStores());
132 |
133 | if ($formData) {
134 | if ($formData->getStores() == null) {
135 | $formData->setStores([Store::DEFAULT_STORE_ID]);
136 | }
137 | $form->setValues($formData->getData());
138 | }
139 |
140 | $this->setForm($form);
141 |
142 | return parent::_prepareForm();
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Faqcat/Edit/Tabs.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:29:27
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:17:48
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit;
12 |
13 | class Tabs extends \Magento\Backend\Block\Widget\Tabs
14 | {
15 | /**
16 | * Internal constructor
17 | *
18 | * @return void
19 | */
20 | protected function _construct()
21 | {
22 | parent::_construct();
23 | $this->setId('faqcat_tabs');
24 | $this->setDestElementId('edit_form');
25 | $this->setTitle(__('Category Information'));
26 | }
27 |
28 | protected function _beforeToHtml()
29 | {
30 | $this->setActiveTab('general_section');
31 | return parent::_beforeToHtml();
32 | }
33 |
34 | /**
35 | * Prepare Layout
36 | *
37 | * @return $this
38 | */
39 | protected function _prepareLayout()
40 | {
41 | $this->addTab(
42 | 'general_section',
43 | [
44 | 'label' => __('General Information'),
45 | 'content' => $this->getLayout()->createBlock('PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab\General')->toHtml()
46 | ]
47 | );
48 |
49 | $this->addTab(
50 | 'optimisation_section',
51 | [
52 | 'label' => __('Search Engine Optimisation'),
53 | 'content' => $this->getLayout()->createBlock('PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab\SearchEngineOptimisation')->toHtml()
54 | ]
55 | );
56 |
57 | $this->addTab(
58 | 'websites_section',
59 | [
60 | 'label' => __('FAQ Category in Websites'),
61 | 'content' => $this->getLayout()->createBlock('PHPCuong\Faq\Block\Adminhtml\Faqcat\Edit\Tab\Websites')->toHtml()
62 | ]
63 | );
64 |
65 | if ($this->getRequest()->getParam('category_id')) {
66 | $this->addTab('question_section', ['label' => __('FAQs in Category'), 'url' => $this->getUrl('*/faqcat/question', ['_current' => true]), 'class' => 'ajax']);
67 | }
68 | return parent::_prepareLayout();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Block/Category/CategorySidebar.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-20 23:46:21
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-06 07:59:25
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Category;
12 |
13 | use Magento\Framework\View\Element\Template\Context;
14 | use PHPCuong\Faq\Helper\Category as CategoryHelper;
15 | use PHPCuong\Faq\Model\ResourceModel\Faq;
16 | use PHPCuong\Faq\Helper\Config as ConfigHelper;
17 |
18 | class CategorySidebar extends \Magento\Framework\View\Element\Template
19 | {
20 | /**
21 | *
22 | * @var \PHPCuong\Faq\Helper\Category
23 | */
24 | protected $_categoryHelper;
25 |
26 | /**
27 | * @var array
28 | */
29 | protected $_faqCategoriesList;
30 |
31 | /**
32 | * @var \PHPCuong\Faq\Helper\Config
33 | */
34 | protected $_configHelper;
35 |
36 | /**
37 | * @param Context $context
38 | * @param CategoryHelper $categoryHelper
39 | * @param ConfigHelper $configHelper
40 | */
41 | public function __construct(
42 | Context $context,
43 | CategoryHelper $categoryHelper,
44 | ConfigHelper $configHelper
45 | ) {
46 | $this->_categoryHelper = $categoryHelper;
47 | $this->_configHelper = $configHelper;
48 | parent::__construct($context);
49 | }
50 |
51 | /**
52 | *
53 | * @return parent
54 | */
55 | protected function _prepareLayout()
56 | {
57 | $this->_faqCategoriesList = $this->_categoryHelper->getCategoriesList();
58 | return parent::_prepareLayout();
59 | }
60 |
61 | /**
62 | * Get List of Categories
63 | *
64 | * @return array|null
65 | */
66 | public function getFaqCategoriesList()
67 | {
68 | return $this->_faqCategoriesList;
69 | }
70 |
71 | /**
72 | * Get URL of the category
73 | *
74 | * @param $identifier
75 | * @return array|null
76 | */
77 | public function getFaqCategoryFullPath($identifier)
78 | {
79 | return $this->_configHelper->getFaqCategoryFullPath($identifier);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Block/Links/Link.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-24 00:42:40
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 16:22:52
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Links;
12 |
13 | class Link extends \Magento\Framework\View\Element\Html\Link
14 | {
15 | /**
16 | * @var \PHPCuong\Faq\Helper\Config
17 | */
18 | protected $_configHelper;
19 |
20 | /**
21 | *
22 | * @param \Magento\Framework\View\Element\Template\Context $context
23 | * @param \PHPCuong\Faq\Helper\Config $configHelper
24 | * @param array $data
25 | */
26 | public function __construct(
27 | \Magento\Framework\View\Element\Template\Context $context,
28 | \PHPCuong\Faq\Helper\Config $configHelper,
29 | array $data = []
30 | ) {
31 | $this->_configHelper = $configHelper;
32 | parent::__construct($context, $data);
33 | }
34 |
35 | /**
36 | * Prepare url using passed id path and return it
37 | * or return false if path was not found in url rewrites.
38 | *
39 | * @throws \RuntimeException
40 | * @return string|false
41 | * @SuppressWarnings(PHPMD.NPathComplexity)
42 | */
43 | public function getHref()
44 | {
45 | return $this->_configHelper->getFaqPage();
46 | }
47 |
48 | /**
49 | * Return label
50 | *
51 | * @return string
52 | */
53 | public function getLabel()
54 | {
55 | return __('Frequently Asked Questions');
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Block/Search/SearchForm.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-27 15:42:40
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-28 18:18:55
9 | */
10 |
11 | namespace PHPCuong\Faq\Block\Search;
12 |
13 | class SearchForm extends \Magento\Framework\View\Element\Template
14 | {
15 | /**
16 | * Returns action url for search form
17 | *
18 | * @return string
19 | */
20 | public function getFormAction()
21 | {
22 | return $this->_storeManager->getStore()->getUrl('faq/search/', [
23 | '_secure' => $this->_storeManager->getStore()->isCurrentlySecure()]);
24 | }
25 |
26 | /**
27 | * Get Text search from url
28 | *
29 | * @return string
30 | */
31 | public function getTextSearch()
32 | {
33 | return ($this->getRequest()->getParam('s')) ? $this->escapeHtml($this->getRequest()->getParam('s')) : '';
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/Delete.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-18 02:25:15
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:11:37
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | use PHPCuong\Faq\Model\ResourceModel\Faq;
14 |
15 | class Delete extends \Magento\Backend\App\Action
16 | {
17 | /**
18 | * Authorization level of a basic admin session
19 | *
20 | * @see _isAllowed()
21 | */
22 | const ADMIN_RESOURCE = 'PHPCuong_Faq::faq_delete';
23 |
24 | /**
25 | * Delete Question
26 | *
27 | * @return \Magento\Framework\View\Result\PageFactory
28 | */
29 | public function execute()
30 | {
31 | // check if we know what should be deleted
32 | $faq_id = $this->getRequest()->getParam('faq_id');
33 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
34 | $resultRedirect = $this->resultRedirectFactory->create();
35 | if ($faq_id && (int) $faq_id > 0) {
36 | $title = '';
37 | try {
38 | // init model and delete
39 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faq');
40 | $model->load($faq_id);
41 | if ($model->getFaqId()) {
42 | $title = $model->getTitle();
43 |
44 | $model->delete();
45 |
46 | $this->messageManager->addSuccess(__('The "'.$title.'" FAQ has been deleted.'));
47 | return $resultRedirect->setPath('*/*/');
48 | }
49 | } catch (\Exception $e) {
50 | // display error message
51 | $this->messageManager->addError($e->getMessage());
52 | // go back to edit form
53 | return $resultRedirect->setPath('*/*/edit', ['faq_id' => $faq_id]);
54 | }
55 | }
56 | // display error message
57 | $this->messageManager->addError(__('FAQ to delete was not found.'));
58 | // go to grid
59 | return $resultRedirect->setPath('*/*/');
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/Edit.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 17:33:52
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:02:53
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | use Magento\Backend\App\Action;
14 |
15 | class Edit extends \Magento\Backend\App\Action
16 | {
17 | /**
18 | * Authorization level of a basic admin session
19 | *
20 | * @see _isAllowed()
21 | */
22 | const ADMIN_RESOURCE = 'PHPCuong_Faq::faq_edit';
23 |
24 | /**
25 | * Core registry
26 | *
27 | * @var \Magento\Framework\Registry
28 | */
29 | protected $_coreRegistry;
30 |
31 | /**
32 | * @var \Magento\Framework\View\Result\PageFactory
33 | */
34 | protected $resultPageFactory;
35 |
36 | /**
37 | * @param Action\Context $context
38 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
39 | * @param \Magento\Framework\Registry $registry
40 | */
41 | public function __construct(
42 | Action\Context $context,
43 | \Magento\Framework\View\Result\PageFactory $resultPageFactory,
44 | \Magento\Framework\Registry $registry
45 | ) {
46 | $this->resultPageFactory = $resultPageFactory;
47 | $this->_coreRegistry = $registry;
48 | parent::__construct($context);
49 | }
50 |
51 | /**
52 | * Init actions
53 | *
54 | * @return \Magento\Backend\Model\View\Result\Page
55 | */
56 | protected function _initAction()
57 | {
58 | // load layout, set active menu
59 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
60 | $resultPage = $this->resultPageFactory->create();
61 | $resultPage->setActiveMenu('PHPCuong_Faq::faqs');
62 | return $resultPage;
63 | }
64 |
65 | /**
66 | * Edit Question page
67 | *
68 | * @return \Magento\Backend\Model\View\Result\Page
69 | * @SuppressWarnings(PHPMD.NPathComplexity)
70 | */
71 | public function execute()
72 | {
73 | // Get ID and create model
74 | $id = $this->getRequest()->getParam('faq_id');
75 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faq');
76 | $model->setData([]);
77 | // Initial checking
78 | if ($id && (int) $id > 0) {
79 | $model->load($id);
80 | if (!$model->getFaqId()) {
81 | $this->messageManager->addError(__('This FAQ no longer exists.'));
82 | /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
83 | $resultRedirect = $this->resultRedirectFactory->create();
84 | return $resultRedirect->setPath('*/*/');
85 | }
86 | $title = $model->getTitle();
87 | }
88 |
89 | $formData = $this->_objectManager->get('Magento\Backend\Model\Session')->getFormData(true);
90 | if (!empty($formData)) {
91 | $model->setData($formData);
92 | }
93 |
94 | $this->_coreRegistry->register('phpcuong_faq', $model);
95 |
96 | // Build edit form
97 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
98 | $resultPage = $this->_initAction();
99 | $resultPage->addBreadcrumb(
100 | $id ? __('Edit FAQ') : __('New FAQ'),
101 | $id ? __('Edit FAQ') : __('New FAQ')
102 | );
103 | $resultPage->getConfig()->getTitle()->prepend(__('FAQs Manager'));
104 | $resultPage->getConfig()->getTitle()
105 | ->prepend($id ? 'Edit: '.$title.' ('.$id.')' : __('New FAQ'));
106 |
107 | return $resultPage;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/Index.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 01:57:35
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-06 07:51:01
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | class Index extends \Magento\Backend\App\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\PageFactory
17 | */
18 | protected $resultPageFactory;
19 |
20 | /**
21 | * @param \Magento\Backend\App\Action\Context $context
22 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
23 | */
24 | public function __construct(
25 | \Magento\Backend\App\Action\Context $context,
26 | \Magento\Framework\View\Result\PageFactory $resultPageFactory
27 | ) {
28 | $this->resultPageFactory = $resultPageFactory;
29 | parent::__construct($context);
30 | }
31 | /**
32 | * FAQs Manager Page
33 | *
34 | * @return \Magento\Framework\View\Result\PageFactory
35 | */
36 | public function execute()
37 | {
38 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
39 | $resultPage = $this->resultPageFactory->create();
40 |
41 | $resultPage->addBreadcrumb(
42 | 'FAQs Manager',
43 | 'FAQs Manager'
44 | );
45 | $resultPage->getConfig()->getTitle()->prepend(__('FAQs'));
46 | $resultPage->getConfig()->getTitle()
47 | ->prepend('FAQs Manager');
48 | return $resultPage;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/MassDelete.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-18 02:30:05
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-27 04:59:36
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | use Magento\Framework\Controller\ResultFactory;
14 | use Magento\Backend\App\Action\Context;
15 | use Magento\Ui\Component\MassAction\Filter;
16 | use PHPCuong\Faq\Model\ResourceModel\Faq\CollectionFactory;
17 | use PHPCuong\Faq\Model\ResourceModel\Faq;
18 |
19 | class MassDelete extends \Magento\Backend\App\Action
20 | {
21 | /**
22 | * Authorization level of a basic admin session
23 | *
24 | * @see _isAllowed()
25 | */
26 | const ADMIN_RESOURCE = 'PHPCuong_Faq::faq_delete';
27 |
28 | /**
29 | * @var Filter
30 | */
31 | protected $filter;
32 |
33 | /**
34 | * @var CollectionFactory
35 | */
36 | protected $collectionFactory;
37 |
38 | /**
39 | * @param Context $context
40 | * @param Filter $filter
41 | * @param CollectionFactory $collectionFactory
42 | */
43 | public function __construct(
44 | Context $context,
45 | Filter $filter,
46 | CollectionFactory $collectionFactory
47 | ) {
48 | $this->filter = $filter;
49 | $this->collectionFactory = $collectionFactory;
50 | parent::__construct($context);
51 | }
52 |
53 | /**
54 | * Execute action
55 | *
56 | * @return \Magento\Backend\Model\View\Result\Redirect
57 | * @throws \Magento\Framework\Exception\LocalizedException|\Exception
58 | */
59 | public function execute()
60 | {
61 | $collection = $this->filter->getCollection($this->collectionFactory->create());
62 | $collectionSize = $collection->getSize();
63 |
64 | foreach ($collection as $page) {
65 | $page->delete();
66 | }
67 |
68 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize));
69 |
70 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
71 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
72 | return $resultRedirect->setPath('*/*/');
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/MassDisable.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-18 02:42:26
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:06:38
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | use Magento\Framework\Controller\ResultFactory;
14 | use Magento\Backend\App\Action\Context;
15 | use Magento\Ui\Component\MassAction\Filter;
16 | use PHPCuong\Faq\Model\ResourceModel\Faq\CollectionFactory;
17 |
18 | class MassDisable extends \Magento\Backend\App\Action
19 | {
20 | /**
21 | * Authorization level of a basic admin session
22 | *
23 | * @see _isAllowed()
24 | */
25 | const ADMIN_RESOURCE = 'PHPCuong_Faq::faq_edit';
26 |
27 | /**
28 | * @var Filter
29 | */
30 | protected $filter;
31 |
32 | /**
33 | * @var CollectionFactory
34 | */
35 | protected $collectionFactory;
36 |
37 | /**
38 | * @param Context $context
39 | * @param Filter $filter
40 | * @param CollectionFactory $collectionFactory
41 | */
42 | public function __construct(
43 | Context $context,
44 | Filter $filter,
45 | CollectionFactory $collectionFactory
46 | ) {
47 | $this->filter = $filter;
48 | $this->collectionFactory = $collectionFactory;
49 | parent::__construct($context);
50 | }
51 |
52 | /**
53 | * Execute action
54 | *
55 | * @return \Magento\Backend\Model\View\Result\Redirect
56 | * @throws \Magento\Framework\Exception\LocalizedException|\Exception
57 | */
58 | public function execute()
59 | {
60 | $collection = $this->filter->getCollection($this->collectionFactory->create());
61 |
62 | foreach ($collection as $item) {
63 | $item->setIsActive(0);
64 | $item->save();
65 | }
66 |
67 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been deactivated.', $collection->getSize()));
68 |
69 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
70 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
71 | return $resultRedirect->setPath('*/*/');
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/MassEnable.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-18 03:00:47
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:07:20
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | use Magento\Framework\Controller\ResultFactory;
14 | use Magento\Backend\App\Action\Context;
15 | use Magento\Ui\Component\MassAction\Filter;
16 | use PHPCuong\Faq\Model\ResourceModel\Faq\CollectionFactory;
17 |
18 | class MassEnable extends \Magento\Backend\App\Action
19 | {
20 | /**
21 | * Authorization level of a basic admin session
22 | *
23 | * @see _isAllowed()
24 | */
25 | const ADMIN_RESOURCE = 'PHPCuong_Faq::faq_edit';
26 |
27 | /**
28 | * @var Filter
29 | */
30 | protected $filter;
31 |
32 | /**
33 | * @var CollectionFactory
34 | */
35 | protected $collectionFactory;
36 |
37 | /**
38 | * @param Context $context
39 | * @param Filter $filter
40 | * @param CollectionFactory $collectionFactory
41 | */
42 | public function __construct(
43 | Context $context,
44 | Filter $filter,
45 | CollectionFactory $collectionFactory
46 | ) {
47 | $this->filter = $filter;
48 | $this->collectionFactory = $collectionFactory;
49 | parent::__construct($context);
50 | }
51 |
52 | /**
53 | * Execute action
54 | *
55 | * @return \Magento\Backend\Model\View\Result\Redirect
56 | * @throws \Magento\Framework\Exception\LocalizedException|\Exception
57 | */
58 | public function execute()
59 | {
60 | $collection = $this->filter->getCollection($this->collectionFactory->create());
61 |
62 | foreach ($collection as $item) {
63 | $item->setIsActive(1);
64 | $item->save();
65 | }
66 |
67 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been activated.', $collection->getSize()));
68 |
69 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
70 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
71 | return $resultRedirect->setPath('*/*/');
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/NewAction.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 17:34:02
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-19 23:16:48
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | class NewAction extends \Magento\Backend\App\Action
14 | {
15 | /**
16 | * Authorization level of a basic admin session
17 | *
18 | * @see _isAllowed()
19 | */
20 | const ADMIN_RESOURCE = 'PHPCuong_Faq::faq_create';
21 |
22 | /**
23 | * @var \Magento\Backend\Model\View\Result\Forward
24 | */
25 | protected $resultForwardFactory;
26 |
27 | /**
28 | * @param \Magento\Backend\App\Action\Context $context
29 | * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
30 | */
31 | public function __construct(
32 | \Magento\Backend\App\Action\Context $context,
33 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
34 | ) {
35 | $this->resultForwardFactory = $resultForwardFactory;
36 | parent::__construct($context);
37 | }
38 |
39 | /**
40 | * Forward to edit
41 | *
42 | * @return \Magento\Backend\Model\View\Result\Forward
43 | */
44 | public function execute()
45 | {
46 | /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */
47 | $resultForward = $this->resultForwardFactory->create();
48 | return $resultForward->forward('edit');
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faq/Save.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 05:09:06
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:10:48
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faq;
12 |
13 | use Magento\Backend\App\Action\Context;
14 | use Magento\Framework\Exception\LocalizedException;
15 | use Magento\TestFramework\Inspection\Exception;
16 |
17 | class Save extends \Magento\Backend\App\Action
18 | {
19 | /**
20 | * Core registry
21 | *
22 | * @var \Magento\Framework\Registry
23 | */
24 | protected $_coreRegistry;
25 |
26 | /**
27 | * @param Context $context
28 | * @param \Magento\Framework\Registry $coreRegistry
29 | */
30 | public function __construct(
31 | Context $context,
32 | \Magento\Framework\Registry $coreRegistry
33 | ) {
34 | $this->_coreRegistry = $coreRegistry;
35 | parent::__construct($context);
36 | }
37 |
38 | /**
39 | * Save action
40 | *
41 | * @SuppressWarnings(PHPMD.CyclomaticComplexity)
42 | * @return \Magento\Framework\Controller\ResultInterface
43 | */
44 | public function execute()
45 | {
46 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
47 | $resultRedirect = $this->resultRedirectFactory->create();
48 |
49 | $data = $this->getRequest()->getPostValue();
50 | if ($data) {
51 | $id = $this->getRequest()->getParam('faq_id');
52 |
53 | /** @var \PHPCuong\Faq\Model\Faq $model */
54 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faq')->load($id);
55 | if (!$model->getFaqId() && $id) {
56 | $this->messageManager->addError(__('This FAQ no longer exists.'));
57 | return $resultRedirect->setPath('*/*/');
58 | }
59 |
60 | $model->setData($data);
61 |
62 | $this->_eventManager->dispatch(
63 | 'faq_faq_prepare_save',
64 | ['faq' => $model, 'request' => $this->getRequest()]
65 | );
66 |
67 | try {
68 | $model->save();
69 | $this->messageManager->addSuccess(__('You saved the FAQ.'));
70 |
71 | if ($this->getRequest()->getParam('back')) {
72 | return $resultRedirect->setPath('*/*/edit', ['faq_id' => $model->getFaqId()]);
73 | }
74 | return $resultRedirect->setPath('*/*/');
75 | } catch (LocalizedException $e) {
76 | $this->messageManager->addError($e->getMessage());
77 | } catch (\Exception $e) {
78 | $this->messageManager->addException($e, __('Something went wrong while saving the FAQ.'));
79 | // $this->messageManager->addError($e->getMessage());
80 | }
81 |
82 | $this->_getSession()->setFormData($data);
83 | if ($this->getRequest()->getParam('faq_id')) {
84 | return $resultRedirect->setPath('*/*/edit', ['faq_id' => $this->getRequest()->getParam('faq_id')]);
85 | }
86 | return $resultRedirect->setPath('*/*/new');
87 | }
88 | return $resultRedirect->setPath('*/*/');
89 | }
90 |
91 | /**
92 | * Check if admin has permissions to visit related pages.
93 | *
94 | * @return bool
95 | */
96 | protected function _isAllowed()
97 | {
98 | if ($this->_authorization->isAllowed('PHPCuong_Faq::faq_edit') || $this->_authorization->isAllowed('PHPCuong_Faq::faq_create')) {
99 | return true;
100 | }
101 | return false;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/Delete.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-20 01:57:49
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:10:28
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | use PHPCuong\Faq\Model\ResourceModel\Faqcat;
14 |
15 | class Delete extends \Magento\Backend\App\Action
16 | {
17 | /**
18 | * Authorization level of a basic admin session
19 | *
20 | * @see _isAllowed()
21 | */
22 | const ADMIN_RESOURCE = 'PHPCuong_Faq::category_delete';
23 |
24 | /**
25 | * Delete FAQ Category
26 | *
27 | * @return \Magento\Framework\View\Result\PageFactory
28 | */
29 | public function execute()
30 | {
31 | // check if we know what should be deleted
32 | $category_id = $this->getRequest()->getParam('category_id');
33 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
34 | $resultRedirect = $this->resultRedirectFactory->create();
35 | if ($category_id && (int) $category_id > 0) {
36 | $title = '';
37 | try {
38 | // init model and delete
39 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faqcat');
40 | $category = $model->load($category_id);
41 |
42 | if ($category->getCategoryId()) {
43 | $title = $model->getTitle();
44 |
45 | $model->delete();
46 |
47 | $this->messageManager->addSuccess(__('The "'.$title.'" Category has been deleted.'));
48 |
49 | return $resultRedirect->setPath('*/*/');
50 | }
51 | } catch (\Exception $e) {
52 | // display error message
53 | $this->messageManager->addError($e->getMessage());
54 | // go back to edit form
55 | return $resultRedirect->setPath('*/*/edit', ['category_id' => $category_id]);
56 | }
57 | }
58 | // display error message
59 | $this->messageManager->addError(__('Category to delete was not found.'));
60 | // go to grid
61 | return $resultRedirect->setPath('*/*/');
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/Edit.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:12:25
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:10:18
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | use Magento\Backend\App\Action;
14 |
15 | class Edit extends \Magento\Backend\App\Action
16 | {
17 | /**
18 | * Authorization level of a basic admin session
19 | *
20 | * @see _isAllowed()
21 | */
22 | const ADMIN_RESOURCE = 'PHPCuong_Faq::category_edit';
23 |
24 | /**
25 | * Core registry
26 | *
27 | * @var \Magento\Framework\Registry
28 | */
29 | protected $_coreRegistry;
30 |
31 | /**
32 | * @var \Magento\Framework\View\Result\PageFactory
33 | */
34 | protected $resultPageFactory;
35 |
36 | /**
37 | * @param Action\Context $context
38 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
39 | * @param \Magento\Framework\Registry $registry
40 | */
41 | public function __construct(
42 | Action\Context $context,
43 | \Magento\Framework\View\Result\PageFactory $resultPageFactory,
44 | \Magento\Framework\Registry $registry
45 | ) {
46 | $this->resultPageFactory = $resultPageFactory;
47 | $this->_coreRegistry = $registry;
48 | parent::__construct($context);
49 | }
50 |
51 | /**
52 | * Init actions
53 | *
54 | * @return \Magento\Backend\Model\View\Result\Page
55 | */
56 | protected function _initAction()
57 | {
58 | // load layout, set active menu
59 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
60 | $resultPage = $this->resultPageFactory->create();
61 | $resultPage->setActiveMenu('PHPCuong_Faq::faqs');
62 | return $resultPage;
63 | }
64 |
65 | /**
66 | * Edit FAQ Category page
67 | *
68 | * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
69 | * @SuppressWarnings(PHPMD.NPathComplexity)
70 | */
71 | public function execute()
72 | {
73 | // Get ID and create model
74 | $id = $this->getRequest()->getParam('category_id');
75 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faqcat');
76 | $model->setData([]);
77 | // Initial checking
78 | if ($id && (int) $id > 0) {
79 | $model->load($id);
80 | if (!$model->getCategoryId()) {
81 | $this->messageManager->addError(__('This Category no longer exists.'));
82 | /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
83 | $resultRedirect = $this->resultRedirectFactory->create();
84 | return $resultRedirect->setPath('*/*/');
85 | }
86 | $title = $model->getTitle();
87 | }
88 |
89 | $FormData = $this->_objectManager->get('Magento\Backend\Model\Session')->getFormData(true);
90 | if (!empty($FormData)) {
91 | $model->setData($FormData);
92 | }
93 |
94 | $this->_coreRegistry->register('phpcuong_faqcat', $model);
95 |
96 | // Build edit form
97 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
98 | $resultPage = $this->_initAction();
99 | $resultPage->addBreadcrumb(
100 | $id ? __('Edit Category') : __('New Category'),
101 | $id ? __('Edit Category') : __('New Category')
102 | );
103 | $resultPage->getConfig()->getTitle()->prepend(__('FAQ Categories Manager'));
104 | $resultPage->getConfig()->getTitle()
105 | ->prepend($id ? 'Edit: '.$title.' ('.$id.')' : __('New Category'));
106 |
107 | return $resultPage;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/Index.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 22:01:13
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-06 08:06:53
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | class Index extends \Magento\Backend\App\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\PageFactory
17 | */
18 | protected $resultPageFactory;
19 |
20 | /**
21 | * @param \Magento\Backend\App\Action\Context $context
22 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
23 | */
24 | public function __construct(
25 | \Magento\Backend\App\Action\Context $context,
26 | \Magento\Framework\View\Result\PageFactory $resultPageFactory
27 | ) {
28 | $this->resultPageFactory = $resultPageFactory;
29 | parent::__construct($context);
30 | }
31 | /**
32 | * FAQ Categories Manager Page
33 | *
34 | * @return \Magento\Framework\View\Result\PageFactory
35 | */
36 | public function execute()
37 | {
38 | /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
39 | $resultPage = $this->resultPageFactory->create();
40 |
41 | $resultPage->addBreadcrumb(
42 | 'FAQ Categories Manager',
43 | 'FAQ Categories Manager'
44 | );
45 | $resultPage->getConfig()->getTitle()->prepend(__('FAQs'));
46 | $resultPage->getConfig()->getTitle()
47 | ->prepend('FAQ Categories Manager');
48 | return $resultPage;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/MassDelete.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-20 02:17:36
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-27 05:04:24
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | use Magento\Framework\Controller\ResultFactory;
14 | use Magento\Backend\App\Action\Context;
15 | use Magento\Ui\Component\MassAction\Filter;
16 | use PHPCuong\Faq\Model\ResourceModel\Faqcat\CollectionFactory;
17 | use PHPCuong\Faq\Model\ResourceModel\Faqcat;
18 |
19 | class MassDelete extends \Magento\Backend\App\Action
20 | {
21 | /**
22 | * Authorization level of a basic admin session
23 | *
24 | * @see _isAllowed()
25 | */
26 | const ADMIN_RESOURCE = 'PHPCuong_Faq::category_delete';
27 |
28 | /**
29 | * @var Filter
30 | */
31 | protected $filter;
32 |
33 | /**
34 | * @var CollectionFactory
35 | */
36 | protected $collectionFactory;
37 |
38 | /**
39 | * @param Context $context
40 | * @param Filter $filter
41 | * @param CollectionFactory $collectionFactory
42 | */
43 | public function __construct(
44 | Context $context,
45 | Filter $filter,
46 | CollectionFactory $collectionFactory
47 | ) {
48 | $this->filter = $filter;
49 | $this->collectionFactory = $collectionFactory;
50 | parent::__construct($context);
51 | }
52 |
53 | /**
54 | * Execute action
55 | *
56 | * @return \Magento\Backend\Model\View\Result\Redirect
57 | * @throws \Magento\Framework\Exception\LocalizedException|\Exception
58 | */
59 | public function execute()
60 | {
61 | $collection = $this->filter->getCollection($this->collectionFactory->create());
62 | $collectionSize = $collection->getSize();
63 |
64 | foreach ($collection as $page) {
65 | $page->delete();
66 | }
67 |
68 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize));
69 |
70 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
71 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
72 | return $resultRedirect->setPath('*/*/');
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/MassDisable.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-20 02:03:16
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:11:50
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | use Magento\Framework\Controller\ResultFactory;
14 | use Magento\Backend\App\Action\Context;
15 | use Magento\Ui\Component\MassAction\Filter;
16 | use PHPCuong\Faq\Model\ResourceModel\Faqcat\CollectionFactory;
17 |
18 | class MassDisable extends \Magento\Backend\App\Action
19 | {
20 | /**
21 | * Authorization level of a basic admin session
22 | *
23 | * @see _isAllowed()
24 | */
25 | const ADMIN_RESOURCE = 'PHPCuong_Faq::category_edit';
26 |
27 | /**
28 | * @var Filter
29 | */
30 | protected $filter;
31 |
32 | /**
33 | * @var CollectionFactory
34 | */
35 | protected $collectionFactory;
36 |
37 | /**
38 | * @param Context $context
39 | * @param Filter $filter
40 | * @param CollectionFactory $collectionFactory
41 | */
42 | public function __construct(
43 | Context $context,
44 | Filter $filter,
45 | CollectionFactory $collectionFactory
46 | ) {
47 | $this->filter = $filter;
48 | $this->collectionFactory = $collectionFactory;
49 | parent::__construct($context);
50 | }
51 |
52 | /**
53 | * Execute action
54 | *
55 | * @return \Magento\Backend\Model\View\Result\Redirect
56 | * @throws \Magento\Framework\Exception\LocalizedException|\Exception
57 | */
58 | public function execute()
59 | {
60 | $collection = $this->filter->getCollection($this->collectionFactory->create());
61 |
62 | foreach ($collection as $item) {
63 | $item->setIsActive(0);
64 | $item->save();
65 | }
66 |
67 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been deactivated.', $collection->getSize()));
68 |
69 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
70 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
71 | return $resultRedirect->setPath('*/*/');
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/MassEnable.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-20 02:02:54
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:12:18
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | use Magento\Framework\Controller\ResultFactory;
14 | use Magento\Backend\App\Action\Context;
15 | use Magento\Ui\Component\MassAction\Filter;
16 | use PHPCuong\Faq\Model\ResourceModel\Faqcat\CollectionFactory;
17 |
18 | class MassEnable extends \Magento\Backend\App\Action
19 | {
20 | /**
21 | * Authorization level of a basic admin session
22 | *
23 | * @see _isAllowed()
24 | */
25 | const ADMIN_RESOURCE = 'PHPCuong_Faq::category_edit';
26 |
27 | /**
28 | * @var Filter
29 | */
30 | protected $filter;
31 |
32 | /**
33 | * @var CollectionFactory
34 | */
35 | protected $collectionFactory;
36 |
37 | /**
38 | * @param Context $context
39 | * @param Filter $filter
40 | * @param CollectionFactory $collectionFactory
41 | */
42 | public function __construct(
43 | Context $context,
44 | Filter $filter,
45 | CollectionFactory $collectionFactory
46 | ) {
47 | $this->filter = $filter;
48 | $this->collectionFactory = $collectionFactory;
49 | parent::__construct($context);
50 | }
51 |
52 | /**
53 | * Execute action
54 | *
55 | * @return \Magento\Backend\Model\View\Result\Redirect
56 | * @throws \Magento\Framework\Exception\LocalizedException|\Exception
57 | */
58 | public function execute()
59 | {
60 | $collection = $this->filter->getCollection($this->collectionFactory->create());
61 |
62 | foreach ($collection as $item) {
63 | $item->setIsActive(1);
64 | $item->save();
65 | }
66 |
67 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been activated.', $collection->getSize()));
68 |
69 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
70 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
71 | return $resultRedirect->setPath('*/*/');
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/NewAction.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 23:12:34
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-19 23:17:17
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | class NewAction extends \Magento\Backend\App\Action
14 | {
15 | /**
16 | * Authorization level of a basic admin session
17 | *
18 | * @see _isAllowed()
19 | */
20 | const ADMIN_RESOURCE = 'PHPCuong_Faq::category_create';
21 |
22 | /**
23 | * @var \Magento\Backend\Model\View\Result\Forward
24 | */
25 | protected $resultForwardFactory;
26 |
27 | /**
28 | * @param \Magento\Backend\App\Action\Context $context
29 | * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
30 | */
31 | public function __construct(
32 | \Magento\Backend\App\Action\Context $context,
33 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
34 | ) {
35 | $this->resultForwardFactory = $resultForwardFactory;
36 | parent::__construct($context);
37 | }
38 |
39 | /**
40 | * Forward to edit
41 | *
42 | * @return \Magento\Backend\Model\View\Result\Forward
43 | */
44 | public function execute()
45 | {
46 | /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */
47 | $resultForward = $this->resultForwardFactory->create();
48 | return $resultForward->forward('edit');
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Faqcat/Question.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-27 05:41:48
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-27 06:54:01
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Adminhtml\Faqcat;
12 |
13 | class Question extends \Magento\Backend\App\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\LayoutFactory
17 | */
18 | protected $resultLayoutFactory;
19 |
20 | public function __construct(
21 | \Magento\Backend\App\Action\Context $context,
22 | \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
23 | ) {
24 | parent::__construct($context);
25 | $this->resultLayoutFactory = $resultLayoutFactory;
26 | }
27 |
28 | /**
29 | * @return \Magento\Framework\View\Result\PageFactory
30 | */
31 | public function execute()
32 | {
33 | $resultLayout = $this->resultLayoutFactory->create();
34 | return $resultLayout;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Controller/Category/View.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-21 16:15:56
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-28 19:30:54
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Category;
12 |
13 | class View extends \Magento\Framework\App\Action\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\PageFactory
17 | */
18 | protected $_resultPageFactory;
19 |
20 | /**
21 | * @var \Magento\Framework\Controller\Result\ForwardFactory
22 | */
23 | protected $_resultForwardFactory;
24 |
25 | /**
26 | * @var \PHPCuong\Faq\Model\ResourceModel\Faqcat
27 | */
28 | protected $_faqCatResourceModel;
29 |
30 | /**
31 | * @param Action\Context $context
32 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
33 | * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
34 | * @param \PHPCuong\Faq\Model\ResourceModel\Faqcat $faqCatResourceModel
35 | */
36 | public function __construct(
37 | \Magento\Framework\App\Action\Context $context,
38 | \Magento\Framework\View\Result\PageFactory $resultPageFactory,
39 | \PHPCuong\Faq\Model\ResourceModel\Faqcat $faqCatResourceModel,
40 | \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
41 | ) {
42 | $this->_faqCatResourceModel = $faqCatResourceModel;
43 | $this->_resultForwardFactory = $resultForwardFactory;
44 | $this->_resultPageFactory = $resultPageFactory;
45 | return parent::__construct($context);
46 | }
47 |
48 | /**
49 | * View action
50 | *
51 | * @return \Magento\Framework\View\Result\PageFactory|\Magento\Framework\Controller\Result\ForwardFactory
52 | * @SuppressWarnings(PHPMD.NPathComplexity)
53 | */
54 | public function execute()
55 | {
56 | $id = $this->getRequest()->getParam('category_id');
57 | $textSearch = $this->getRequest()->getParam('s');
58 | if ($category = $this->_faqCatResourceModel->getFaqCategoryStore($id, $textSearch)) {
59 | $resultPage = $this->_resultPageFactory->create();
60 |
61 | $resultPage->getConfig()->getTitle()->set(__('FAQs'));
62 |
63 | $resultPage->getConfig()->getTitle()->prepend(__($category['title']));
64 |
65 | return $resultPage;
66 | }
67 | $resultForward = $this->_resultForwardFactory->create();
68 | return $resultForward->forward('noroute');
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Controller/Faq/View.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-23 16:58:08
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-27 16:30:33
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Faq;
12 |
13 | class View extends \Magento\Framework\App\Action\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\PageFactory
17 | */
18 | protected $_resultPageFactory;
19 |
20 | /**
21 | * @param \Magento\Framework\App\Action\Context $context
22 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
23 | */
24 | public function __construct(
25 | \Magento\Framework\App\Action\Context $context,
26 | \Magento\Framework\View\Result\PageFactory $resultPageFactory
27 | ) {
28 | $this->_resultPageFactory = $resultPageFactory;
29 | return parent::__construct($context);
30 | }
31 |
32 | /**
33 | * View action
34 | *
35 | * @return \Magento\Framework\View\Result\PageFactory
36 | * @SuppressWarnings(PHPMD.NPathComplexity)
37 | */
38 | public function execute()
39 | {
40 | $resultPage = $this->_resultPageFactory->create();
41 | return $resultPage;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Controller/Question/Ajax.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-21 03:06:06
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:06:09
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Question;
12 |
13 | class Ajax extends \Magento\Framework\App\Action\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\Controller\Result\JsonFactory
17 | */
18 | protected $_resultJsonFactory;
19 |
20 | /**
21 | * @var \Magento\Framework\Controller\Result\ForwardFactory
22 | */
23 | protected $_resultForwardFactory;
24 |
25 | /**
26 | * @var \PHPCuong\Faq\Model\ResourceModel\Faq
27 | */
28 | protected $_faqResourceModel;
29 |
30 | /**
31 | * @param Action\Context $context
32 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
33 | @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
34 | */
35 | public function __construct(
36 | \Magento\Framework\App\Action\Context $context,
37 | \PHPCuong\Faq\Model\ResourceModel\Faq $faqResourceModel,
38 | \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
39 | \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
40 | ) {
41 | $this->_faqResourceModel = $faqResourceModel;
42 | $this->_resultJsonFactory = $resultJsonFactory;
43 | $this->_resultForwardFactory = $resultForwardFactory;
44 | return parent::__construct($context);
45 | }
46 |
47 | /**
48 | * Ajax action
49 | *
50 | * @return \Magento\Framework\Controller\Result\JsonFactory|\Magento\Framework\Controller\Result\ForwardFactory
51 | * @SuppressWarnings(PHPMD.NPathComplexity)
52 | */
53 | public function execute()
54 | {
55 | $result = $this->_resultJsonFactory->create();
56 | if ($this->getRequest()->isAjax()) {
57 | $type = $this->getRequest()->getParam('type');
58 | $faq_id = (int) $this->getRequest()->getParam('faq_id');
59 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faq');
60 | $model->load($faq_id);
61 | if ($model->getFaqId()) {
62 | if ($type == '1') {
63 | $model->setLiked($model->getLiked() + 1);
64 | } elseif ($type == '0') {
65 | $model->setDisliked($model->getDisliked() + 1);
66 | }
67 | $model->save();
68 | }
69 | return $result->setData(['status' => 'success']);
70 | }
71 | $resultForward = $this->_resultForwardFactory->create();
72 | return $resultForward->forward('noroute');
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Controller/Question/View.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 17:27:27
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:07:27
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Question;
12 |
13 | class View extends \Magento\Framework\App\Action\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\PageFactory
17 | */
18 | protected $_resultPageFactory;
19 |
20 | /**
21 | * @var \Magento\Framework\Controller\Result\ForwardFactory
22 | */
23 | protected $_resultForwardFactory;
24 |
25 | /**
26 | * @var \PHPCuong\Faq\Model\ResourceModel\Faq
27 | */
28 | protected $_faqResourceModel;
29 |
30 | /**
31 | * @param Action\Context $context
32 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
33 | * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
34 | */
35 | public function __construct(
36 | \Magento\Framework\App\Action\Context $context,
37 | \Magento\Framework\View\Result\PageFactory $resultPageFactory,
38 | \PHPCuong\Faq\Model\ResourceModel\Faq $faqResourceModel,
39 | \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
40 | ) {
41 | $this->_faqResourceModel = $faqResourceModel;
42 | $this->_resultForwardFactory = $resultForwardFactory;
43 | $this->_resultPageFactory = $resultPageFactory;
44 | return parent::__construct($context);
45 | }
46 |
47 | /**
48 | * View action
49 | *
50 | * @return \Magento\Framework\View\Result\PageFactory|\Magento\Framework\Controller\Result\ForwardFactory
51 | * @SuppressWarnings(PHPMD.NPathComplexity)
52 | */
53 | public function execute()
54 | {
55 | $id = $this->getRequest()->getParam('faq_id');
56 | $model = $this->_objectManager->create('PHPCuong\Faq\Model\Faq');
57 | if ($id && (int) $id > 0 && $this->_faqResourceModel->getFaqStore($id)) {
58 | $faq = $model->load($id);
59 | $this->_faqResourceModel->getConnection()->update($this->_faqResourceModel->getTable('phpcuong_faq'), ['viewed' => $faq->getViewed()+1], ['faq_id = ?' => (int) $id]);
60 | return $this->_resultPageFactory->create();
61 | }
62 | $resultForward = $this->_resultForwardFactory->create();
63 | return $resultForward->forward('noroute');
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Controller/Search/Index.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-27 16:25:49
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-27 16:31:09
9 | */
10 |
11 | namespace PHPCuong\Faq\Controller\Search;
12 |
13 | class Index extends \Magento\Framework\App\Action\Action
14 | {
15 | /**
16 | * @var \Magento\Framework\View\Result\PageFactory
17 | */
18 | protected $_resultPageFactory;
19 |
20 | /**
21 | * @param \Magento\Framework\App\Action\Context $context
22 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
23 | */
24 | public function __construct(
25 | \Magento\Framework\App\Action\Context $context,
26 | \Magento\Framework\View\Result\PageFactory $resultPageFactory
27 | ) {
28 | $this->_resultPageFactory = $resultPageFactory;
29 | return parent::__construct($context);
30 | }
31 |
32 | /**
33 | * Index action
34 | *
35 | * @return \Magento\Framework\View\Result\PageFactory
36 | * @SuppressWarnings(PHPMD.NPathComplexity)
37 | */
38 | public function execute()
39 | {
40 | $resultPage = $this->_resultPageFactory->create();
41 | return $resultPage;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Helper/Category.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-20 23:49:42
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:04:25
9 | */
10 |
11 | namespace PHPCuong\Faq\Helper;
12 |
13 | /**
14 | * Category Helper
15 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16 | * @SuppressWarnings(PHPMD.CyclomaticComplexity)
17 | * @SuppressWarnings(PHPMD.NPathComplexity)
18 | */
19 | class Category extends \Magento\Framework\App\Helper\AbstractHelper
20 | {
21 | /**
22 | * @var \PHPCuong\Faq\Model\ResourceModel\Faqcat
23 | */
24 | protected $_faqCatResourceModel;
25 |
26 | /**
27 | * Store manager
28 | *
29 | * @var StoreManagerInterface
30 | */
31 | protected $_storeManager;
32 |
33 | /**
34 | * Constructor
35 | *
36 | * @param \Magento\Framework\App\Helper\Context $context
37 | * @param \PHPCuong\Faq\Model\ResourceModel\Faqcat $faqCatResourceModel
38 | * @param \Magento\Store\Model\StoreManagerInterface $storeManager
39 | * @SuppressWarnings(PHPMD.ExcessiveParameterList)
40 | */
41 | public function __construct(
42 | \Magento\Framework\App\Helper\Context $context,
43 | \PHPCuong\Faq\Model\ResourceModel\Faqcat $faqCatResourceModel,
44 | \Magento\Store\Model\StoreManagerInterface $storeManager
45 | ) {
46 | $this->_faqCatResourceModel = $faqCatResourceModel;
47 | $this->_storeManager = $storeManager;
48 | parent::__construct($context);
49 | }
50 |
51 | /**
52 | * Get the list of categories
53 | *
54 | * @return array|null
55 | */
56 | public function getCategoriesList()
57 | {
58 | return $this->_faqCatResourceModel->getCategoriesList();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Helper/Config.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-23 23:54:46
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-28 17:21:02
9 | */
10 |
11 | namespace PHPCuong\Faq\Helper;
12 |
13 | use Magento\Store\Model\StoreManagerInterface;
14 | use PHPCuong\Faq\Model\ResourceModel\Faq as FaqResourceModel;
15 | use Magento\Framework\App\Filesystem\DirectoryList;
16 |
17 | /**
18 | * Config Helper
19 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20 | * @SuppressWarnings(PHPMD.CyclomaticComplexity)
21 | * @SuppressWarnings(PHPMD.NPathComplexity)
22 | */
23 | class Config
24 | {
25 | /**
26 | * Store manager
27 | *
28 | * @var \Magento\Store\Model\StoreManagerInterface
29 | */
30 | protected $_storeManager;
31 |
32 | /**
33 | * Constructor
34 | *
35 | * @param StoreManagerInterface $storeManager
36 | * @SuppressWarnings(PHPMD.ExcessiveParameterList)
37 | */
38 | public function __construct(
39 | StoreManagerInterface $storeManager
40 | ) {
41 | $this->_storeManager = $storeManager;
42 | }
43 |
44 | /**
45 | * Get URL of the category
46 | *
47 | * @param $identifier
48 | * @return string|null
49 | */
50 | public function getFaqCategoryFullPath($identifier)
51 | {
52 | return $this->_storeManager->getStore()->getBaseUrl().FaqResourceModel::FAQ_CATEGORY_PATH.'/'.$identifier.FaqResourceModel::FAQ_DOT_HTML;
53 | }
54 |
55 | /**
56 | * Get URL of the files in pub/media folder
57 | *
58 | * @param $path
59 | * @return string
60 | */
61 | public function getFileBaseUrl($path)
62 | {
63 | return '/'.DirectoryList::PUB.'/'.DirectoryList::MEDIA.'/'.$path;
64 | }
65 |
66 | /**
67 | * Get URL of the category
68 | *
69 | * @param $identifier
70 | * @return string
71 | */
72 | public function getFaqFullPath($identifier)
73 | {
74 | return $this->_storeManager->getStore()->getBaseUrl().FaqResourceModel::FAQ_QUESTION_PATH.'/'.$identifier.FaqResourceModel::FAQ_DOT_HTML;
75 | }
76 |
77 | /**
78 | * Get URL of the FAQ page
79 | *
80 | * @return string
81 | */
82 | public function getFaqPage()
83 | {
84 | return $this->_storeManager->getStore()->getBaseUrl().FaqResourceModel::FAQ_REQUEST_PATH;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/Helper/Question.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 17:35:37
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:03:18
9 | */
10 |
11 | namespace PHPCuong\Faq\Helper;
12 |
13 | /**
14 | * Question Helper
15 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16 | * @SuppressWarnings(PHPMD.CyclomaticComplexity)
17 | * @SuppressWarnings(PHPMD.NPathComplexity)
18 | */
19 | class Question extends \Magento\Framework\App\Helper\AbstractHelper
20 | {
21 | /**
22 | * @var \PHPCuong\Faq\Model\ResourceModel\Faq
23 | */
24 | protected $_faqResourceModel;
25 |
26 | protected $_faqData;
27 |
28 | /**
29 | * @var \Magento\User\Model\UserFactory
30 | */
31 | protected $_userFactory;
32 |
33 | /**
34 | * Constructor
35 | *
36 | * @param \Magento\Framework\App\Helper\Context $context
37 | * @param \PHPCuong\Faq\Model\ResourceModel\Faq $faqResourceModel
38 | * @param \Magento\User\Model\UserFactory $userFactory
39 | * @SuppressWarnings(PHPMD.ExcessiveParameterList)
40 | */
41 | public function __construct(
42 | \Magento\Framework\App\Helper\Context $context,
43 | \PHPCuong\Faq\Model\ResourceModel\Faq $faqResourceModel,
44 | \Magento\User\Model\UserFactory $userFactory
45 | ) {
46 | $this->_faqResourceModel = $faqResourceModel;
47 | $this->_userFactory = $userFactory;
48 | parent::__construct($context);
49 | }
50 |
51 | /**
52 | * Get the full name of author, who created the question
53 | *
54 | * @return string|null
55 | */
56 | public function getFullName()
57 | {
58 | $user_id = ($this->_faqData['user_id'] != null) ? $this->_faqData['user_id'] : '';
59 | $admin_user = $this->_userFactory->create()->load($user_id);
60 | if ($admin_user->getUserId()) {
61 | return trim($admin_user->getFirstname().' '.$admin_user->getLastname());
62 | }
63 | return '';
64 | }
65 |
66 | /**
67 | * Set value for the $_faqData param
68 | *
69 | * @param $faq_id
70 | * @return $this
71 | */
72 | public function getFaq($faq_id)
73 | {
74 | $this->_faqData = $this->_faqResourceModel->getFaqStore($faq_id);
75 | return $this;
76 | }
77 |
78 | /**
79 | * Get the ID of Question
80 | *
81 | * @return string
82 | */
83 | public function getFaqId()
84 | {
85 | if (!empty($this->_faqData['faq_id'])) {
86 | return $this->_faqData['faq_id'];
87 | }
88 | return '';
89 | }
90 |
91 | /**
92 | * Get the Title of Question
93 | *
94 | * @return string
95 | */
96 | public function getTitle()
97 | {
98 | if (!empty($this->_faqData['title'])) {
99 | return $this->_faqData['title'];
100 | }
101 | return '';
102 | }
103 |
104 | /**
105 | * Get the Meta Keywords of Question
106 | *
107 | * @return string
108 | */
109 | public function getMetaKeywords()
110 | {
111 | if (!empty($this->_faqData['meta_keywords'])) {
112 | return $this->_faqData['meta_keywords'];
113 | }
114 | return '';
115 | }
116 |
117 | /**
118 | * Get the Meta Description of Question
119 | *
120 | * @return string
121 | */
122 | public function getMetaDescription()
123 | {
124 | if (!empty($this->_faqData['meta_description'])) {
125 | return $this->_faqData['meta_description'];
126 | }
127 | return '';
128 | }
129 |
130 | /**
131 | * Get the Content of Question
132 | *
133 | * @return string
134 | */
135 | public function getContent()
136 | {
137 | if (!empty($this->_faqData['content'])) {
138 | return $this->_faqData['content'];
139 | }
140 | return '';
141 | }
142 |
143 | /**
144 | * Get the Creation Time of Question
145 | *
146 | * @return string
147 | */
148 | public function getCreationTime()
149 | {
150 | if (!empty($this->_faqData['creation_time'])) {
151 | $date = new \DateTime($this->_faqData['creation_time']);
152 | return $date->format('M d, Y H:i:s A');
153 | }
154 | return '';
155 | }
156 |
157 | /**
158 | * Get the View number of Question
159 | *
160 | * @return string
161 | */
162 | public function getViewed()
163 | {
164 | if (!empty($this->_faqData['viewed'])) {
165 | return $this->_faqData['viewed'];
166 | }
167 | return '';
168 | }
169 |
170 | /**
171 | * Get the Category via $faq_id
172 | *
173 | * @param $faq_id
174 | * @return $this
175 | */
176 | public function getFaqCategory($faq_id)
177 | {
178 | $this->_faqData = $this->_faqResourceModel->getFaqCategory($faq_id);
179 | return $this;
180 | }
181 |
182 | /**
183 | * Get the Identifier of Category
184 | *
185 | * @return string
186 | */
187 | public function getCategoryIndentifier()
188 | {
189 | if (!empty($this->_faqData['identifier'])) {
190 | return $this->_faqData['identifier'];
191 | }
192 | return '';
193 | }
194 |
195 | /**
196 | * Get the ID of Category
197 | *
198 | * @return string
199 | */
200 | public function getCategoryId()
201 | {
202 | if (!empty($this->_faqData['category_id'])) {
203 | return $this->_faqData['category_id'];
204 | }
205 | return '';
206 | }
207 |
208 | /**
209 | * Get the related question via $faq_id and $category_id
210 | *
211 | * @param $faq_id, $category_id
212 | * @return array|null
213 | */
214 | public function getRelatedQuestion($faq_id = null, $category_id = null)
215 | {
216 | return $this->_faqResourceModel->getRelatedQuestion($faq_id, $category_id);
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/Model/Config/Source/Admin/User.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 04:43:54
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:42:16
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\Config\Source\Admin;
12 |
13 | class User implements \Magento\Framework\Option\ArrayInterface
14 | {
15 | /**
16 | *
17 | * @var \Magento\User\Model\UserFactory
18 | */
19 | protected $userFactory;
20 |
21 | /**
22 | *
23 | * @param \Magento\User\Model\UserFactory $userFactory
24 | */
25 | public function __construct(
26 | \Magento\User\Model\UserFactory $userFactory
27 | ) {
28 | $this->userFactory = $userFactory;
29 | }
30 |
31 | /**
32 | * Options getter
33 | *
34 | * @return array
35 | */
36 | public function toOptionArray()
37 | {
38 | $admin_user = $this->userFactory->create()->getCollection()->load()->getData();
39 | foreach ($admin_user as $value) {
40 | $results[] = [
41 | 'value' => $value['user_id'],
42 | 'label' => trim($value['firstname'].' '.$value['lastname'])
43 | ];
44 | }
45 | return $results;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Model/Config/Source/Category.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 16:34:52
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:42:08
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\Config\Source;
12 |
13 | class Category implements \Magento\Framework\Option\ArrayInterface
14 | {
15 | /**
16 | *
17 | * @var \PHPCuong\Faq\Model\Faqcat
18 | */
19 | protected $_faqCategory;
20 |
21 | /**
22 | *
23 | * @param \PHPCuong\Faq\Model\Faqcat $faqCat
24 | */
25 | public function __construct(
26 | \PHPCuong\Faq\Model\Faqcat $faqCat
27 | ) {
28 | $this->_faqCategory = $faqCat;
29 | }
30 |
31 | /**
32 | * Get the list of active categories
33 | *
34 | * @return array|null;
35 | */
36 | protected function getCategoriesActive()
37 | {
38 | return $this->_faqCategory->getCollection()
39 | ->addFieldToFilter('is_active', '1')
40 | ->load()
41 | ->getData();
42 | }
43 |
44 | /**
45 | * Get the list of categories
46 | *
47 | * @return array|null;
48 | */
49 | protected function getAllCategories()
50 | {
51 | return $this->_faqCategory->getCollection()->load()->getData();
52 | }
53 |
54 | /**
55 | * Options getter
56 | *
57 | * @return array
58 | */
59 | public function toOptionArray()
60 | {
61 | $model = $this->getAllCategories();
62 | $results = [];
63 | $results[] = [
64 | 'value' => '0',
65 | 'label' => 'All Categories'
66 | ];
67 | foreach ($model as $value) {
68 | $results[] = [
69 | 'value' => $value['category_id'],
70 | 'label' => $value['title']
71 | ];
72 | }
73 | return $results;
74 | }
75 |
76 | /**
77 | * Options getter
78 | *
79 | * @return array
80 | */
81 | public function getCategoryOptions()
82 | {
83 | $model = $this->getCategoriesActive();
84 |
85 | $options = [
86 | '' => '-- Select a category --'
87 | ];
88 |
89 | foreach ($model as $value) {
90 | $arg = [
91 | $value['category_id'] => $value['title']
92 | ];
93 | $options = $options + $arg;
94 | }
95 |
96 | $this->_options = $options;
97 | return $this->_options;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Model/Config/Source/IsActive.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 04:12:46
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-27 08:14:19
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\Config\Source;
12 |
13 | class IsActive implements \Magento\Framework\Option\ArrayInterface
14 | {
15 | const STATUS_ENABLED = 1;
16 |
17 | const STATUS_DISABLED = 0;
18 |
19 | /**
20 | * Options getter
21 | *
22 | * @return array
23 | */
24 | public function toOptionArray()
25 | {
26 | return [
27 | ['value' => 1, 'label' => __('Active')],
28 | ['value' => 0, 'label' => __('InActive')]
29 | ];
30 | }
31 |
32 | /**
33 | * Options getter
34 | *
35 | * @return array
36 | */
37 | public function getStatusOptions($flag = false)
38 | {
39 | $options = [];
40 |
41 | if ($flag) {
42 | $options[''] = '-- Status --';
43 | }
44 |
45 | $options[self::STATUS_DISABLED] = __('InActive');
46 | $options[self::STATUS_ENABLED] = __('Active');
47 |
48 | $this->_options = $options;
49 | return $this->_options;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Model/Config/Source/Urlkey.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 23:04:58
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:02:19
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\Config\Source;
12 |
13 | class Urlkey
14 | {
15 | /**
16 | * Generate identifier from the string
17 | *
18 | * @param $string
19 | * @return string
20 | */
21 | public function generateIdentifier($string)
22 | {
23 | $string = $this->replaceVietnameseLetters(trim($string));
24 |
25 | $string = strtolower($string);
26 |
27 | while (stristr($string, '-')) {
28 | $string = str_replace('-', ' ', $string);
29 | }
30 |
31 | while (stristr($string, ' ')) {
32 | $string = str_replace(' ', ' ', $string);
33 | }
34 |
35 | $filter = new \Zend\I18n\Filter\Alnum(true);
36 |
37 | $string = $filter->filter($string);
38 |
39 | $string = str_replace(' ', '-', $string);
40 |
41 | while (stristr($string, '--')) {
42 | $string = str_replace('--', '-', $string);
43 | }
44 |
45 | return $string;
46 | }
47 |
48 | /**
49 | * Replace Vietnamese letters to latin letters
50 | *
51 | * @param $string
52 | * @return string
53 | */
54 | public function replaceVietnameseLetters($string)
55 | {
56 | $vietnamese = ["à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ","è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ","ì","í","ị","ỉ","ĩ","ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ","ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ","ỳ","ý","ỵ","ỷ","ỹ","đ","À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă","Ằ","Ắ","Ặ","Ẳ","Ẵ","È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ","Ì","Í","Ị","Ỉ","Ĩ","Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ","Ờ","Ớ","Ợ","Ở","Ỡ","Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ","Ỳ","Ý","Ỵ","Ỷ","Ỹ","Đ"];
57 |
58 | $english = ["a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","a","e","e","e","e","e","e","e","e","e","e","e","i","i","i","i","i","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","u","u","u","u","u","u","u","u","u","u","u","y","y","y","y","y","d","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","E","E","E","E","E","E","E","E","E","E","E","I","I","I","I","I","O","O","O","O","O","O","O","O","O","O","O","O","O","O","O","O","O","U","U","U","U","U","U","U","U","U","U","U","Y","Y","Y","Y","Y","D"];
59 |
60 | return str_replace($vietnamese, $english, $string);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Model/Config/Source/Yesno.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-17 02:25:42
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:41:48
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\Config\Source;
12 |
13 | class Yesno implements \Magento\Framework\Option\ArrayInterface
14 | {
15 | /**
16 | * Options getter
17 | *
18 | * @return array
19 | */
20 | public function toOptionArray()
21 | {
22 | return [];
23 | }
24 |
25 | /**
26 | * Options getter
27 | *
28 | * @return array
29 | */
30 | public function getYesnoOptions()
31 | {
32 | $options = [
33 | '1' => __('Yes'),
34 | '0' => __('No'),
35 | ];
36 |
37 | $this->_options = $options;
38 | return $this->_options;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Model/Faq.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 02:01:39
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-11 13:42:36
9 | */
10 |
11 | namespace PHPCuong\Faq\Model;
12 |
13 | class Faq extends \Magento\Framework\Model\AbstractModel
14 | {
15 | /**
16 | * Cache tag
17 | *
18 | * @var string
19 | */
20 | const CACHE_TAG = 'phpcuong_faq';
21 |
22 | /**
23 | * Initialize resource model
24 | *
25 | * @return void
26 | */
27 | protected function _construct()
28 | {
29 | $this->_init('PHPCuong\Faq\Model\ResourceModel\Faq');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Model/Faqcat.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 22:02:46
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 20:40:46
9 | */
10 |
11 | namespace PHPCuong\Faq\Model;
12 |
13 | class Faqcat extends \Magento\Framework\Model\AbstractModel
14 | {
15 | /**
16 | * Cache tag
17 | *
18 | * @var string
19 | */
20 | const CACHE_TAG = 'phpcuong_faq_category';
21 |
22 | /**
23 | * Initialize resource model
24 | *
25 | * @return void
26 | */
27 | protected function _construct()
28 | {
29 | $this->_init('PHPCuong\Faq\Model\ResourceModel\Faqcat');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Faq/Collection.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 02:04:31
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 17:57:36
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\ResourceModel\Faq;
12 |
13 | class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
14 | {
15 | /**
16 | * @var string
17 | */
18 | protected $_idFieldName = 'faq_id';
19 |
20 | /**
21 | * Define resource model.
22 | */
23 | protected function _construct()
24 | {
25 | $this->_init('PHPCuong\Faq\Model\Faq', 'PHPCuong\Faq\Model\ResourceModel\Faq');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Faq/Grid/Collection.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 02:06:33
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-22 02:59:22
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\ResourceModel\Faq\Grid;
12 |
13 | class Collection extends \PHPCuong\Faq\Model\ResourceModel\Faq\Collection implements \Magento\Framework\Api\Search\SearchResultInterface
14 | {
15 | /**
16 | * Aggregations
17 | *
18 | * @var \Magento\Framework\Search\AggregationInterface
19 | */
20 | protected $_aggregations;
21 |
22 | /**
23 | * constructor
24 | *
25 | * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
26 | * @param \Psr\Log\LoggerInterface $logger
27 | * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
28 | * @param \Magento\Framework\Event\ManagerInterface $eventManager
29 | * @param $mainTable
30 | * @param $eventPrefix
31 | * @param $eventObject
32 | * @param $resourceModel
33 | * @param $model
34 | * @param $connection
35 | * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
36 | */
37 | public function __construct(
38 | \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
39 | \Psr\Log\LoggerInterface $logger,
40 | \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
41 | \Magento\Framework\Event\ManagerInterface $eventManager,
42 | $mainTable = 'phpcuong_faq',
43 | $eventPrefix,
44 | $eventObject,
45 | $resourceModel,
46 | $model = 'Magento\Framework\View\Element\UiComponent\DataProvider\Document',
47 | \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
48 | \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
49 | ) {
50 | parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
51 | $this->_eventPrefix = $eventPrefix;
52 | $this->_eventObject = $eventObject;
53 | $this->_init($model, $resourceModel);
54 | $this->setMainTable($mainTable);
55 | }
56 |
57 |
58 | /**
59 | * @return \Magento\Framework\Search\AggregationInterface
60 | */
61 | public function getAggregations()
62 | {
63 | return $this->_aggregations;
64 | }
65 |
66 | /**
67 | * @param \Magento\Framework\Search\AggregationInterface $aggregations
68 | * @return $this
69 | */
70 | public function setAggregations($aggregations)
71 | {
72 | $this->_aggregations = $aggregations;
73 | }
74 |
75 |
76 | /**
77 | * Retrieve all ids for collection
78 | * Backward compatibility with EAV collection
79 | *
80 | * @param int $limit
81 | * @param int $offset
82 | * @return array
83 | */
84 | public function getAllIds($limit = null, $offset = null)
85 | {
86 | return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
87 | }
88 |
89 | /**
90 | * Get search criteria.
91 | *
92 | * @return \Magento\Framework\Api\SearchCriteriaInterface|null
93 | */
94 | public function getSearchCriteria()
95 | {
96 | return null;
97 | }
98 |
99 | /**
100 | * Set search criteria.
101 | *
102 | * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
103 | * @return $this
104 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
105 | */
106 | public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
107 | {
108 | return $this;
109 | }
110 |
111 | /**
112 | * Get total count.
113 | *
114 | * @return int
115 | */
116 | public function getTotalCount()
117 | {
118 | return $this->getSize();
119 | }
120 |
121 | /**
122 | * Set total count.
123 | *
124 | * @param int $totalCount
125 | * @return $this
126 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
127 | */
128 | public function setTotalCount($totalCount)
129 | {
130 | return $this;
131 | }
132 |
133 | /**
134 | * Set items list.
135 | *
136 | * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
137 | * @return $this
138 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
139 | */
140 | public function setItems(array $items = null)
141 | {
142 | return $this;
143 | }
144 |
145 | /**
146 | * Join faq_store relation table and faq_category relation table
147 | *
148 | * @inheritdoc
149 | */
150 | protected function _renderFiltersBefore()
151 | {
152 | $this->getSelect()->joinLeft(
153 | ['faq_store' => $this->getTable('phpcuong_faq_store')],
154 | 'main_table.faq_id = faq_store.faq_id',
155 | ['store_id']
156 | );
157 | $this->getSelect()->joinLeft(
158 | ['faq_category_id' => $this->getTable('phpcuong_faq_category_id')],
159 | 'main_table.faq_id = faq_category_id.faq_id',
160 | ['category_id']
161 | );
162 | $this->getSelect()->group(
163 | 'main_table.faq_id'
164 | );
165 | parent::_renderFiltersBefore();
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Faqcat/Collection.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 22:06:29
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2016-12-24 18:07:24
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\ResourceModel\Faqcat;
12 |
13 | class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
14 | {
15 | /**
16 | * @var string
17 | */
18 | protected $_idFieldName = 'category_id';
19 |
20 | /**
21 | * Define resource model.
22 | */
23 | protected function _construct()
24 | {
25 | $this->_init('PHPCuong\Faq\Model\Faqcat', 'PHPCuong\Faq\Model\ResourceModel\Faqcat');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Faqcat/Grid/Collection.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-19 22:07:42
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-11-22 02:59:06
9 | */
10 |
11 | namespace PHPCuong\Faq\Model\ResourceModel\Faqcat\Grid;
12 |
13 | class Collection extends \PHPCuong\Faq\Model\ResourceModel\Faqcat\Collection implements \Magento\Framework\Api\Search\SearchResultInterface
14 | {
15 | /**
16 | * Aggregations
17 | *
18 | * @var \Magento\Framework\Search\AggregationInterface
19 | */
20 | protected $_aggregations;
21 |
22 | /**
23 | * constructor
24 | *
25 | * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
26 | * @param \Psr\Log\LoggerInterface $logger
27 | * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
28 | * @param \Magento\Framework\Event\ManagerInterface $eventManager
29 | * @param $mainTable
30 | * @param $eventPrefix
31 | * @param $eventObject
32 | * @param $resourceModel
33 | * @param $model
34 | * @param $connection
35 | * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
36 | */
37 | public function __construct(
38 | \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
39 | \Psr\Log\LoggerInterface $logger,
40 | \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
41 | \Magento\Framework\Event\ManagerInterface $eventManager,
42 | $mainTable = 'phpcuong_faq_category',
43 | $eventPrefix,
44 | $eventObject,
45 | $resourceModel,
46 | $model = 'Magento\Framework\View\Element\UiComponent\DataProvider\Document',
47 | \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
48 | \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
49 | ) {
50 | parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
51 | $this->_eventPrefix = $eventPrefix;
52 | $this->_eventObject = $eventObject;
53 | $this->_init($model, $resourceModel);
54 | $this->setMainTable($mainTable);
55 | }
56 |
57 |
58 | /**
59 | * @return \Magento\Framework\Search\AggregationInterface
60 | */
61 | public function getAggregations()
62 | {
63 | return $this->_aggregations;
64 | }
65 |
66 | /**
67 | * @param \Magento\Framework\Search\AggregationInterface $aggregations
68 | * @return $this
69 | */
70 | public function setAggregations($aggregations)
71 | {
72 | $this->_aggregations = $aggregations;
73 | }
74 |
75 |
76 | /**
77 | * Retrieve all ids for collection
78 | * Backward compatibility with EAV collection
79 | *
80 | * @param int $limit
81 | * @param int $offset
82 | * @return array
83 | */
84 | public function getAllIds($limit = null, $offset = null)
85 | {
86 | return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
87 | }
88 |
89 | /**
90 | * Get search criteria.
91 | *
92 | * @return \Magento\Framework\Api\SearchCriteriaInterface|null
93 | */
94 | public function getSearchCriteria()
95 | {
96 | return null;
97 | }
98 |
99 | /**
100 | * Set search criteria.
101 | *
102 | * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
103 | * @return $this
104 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
105 | */
106 | public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
107 | {
108 | return $this;
109 | }
110 |
111 | /**
112 | * Get total count.
113 | *
114 | * @return int
115 | */
116 | public function getTotalCount()
117 | {
118 | return $this->getSize();
119 | }
120 |
121 | /**
122 | * Set total count.
123 | *
124 | * @param int $totalCount
125 | * @return $this
126 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
127 | */
128 | public function setTotalCount($totalCount)
129 | {
130 | return $this;
131 | }
132 |
133 | /**
134 | * Set items list.
135 | *
136 | * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
137 | * @return $this
138 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
139 | */
140 | public function setItems(array $items = null)
141 | {
142 | return $this;
143 | }
144 |
145 | /**
146 | * Join faq_category_store relation table
147 | *
148 | * @inheritdoc
149 | */
150 | protected function _renderFiltersBefore()
151 | {
152 | $this->getSelect()->joinLeft(
153 | ['fcs' => $this->getTable('phpcuong_faq_category_store')],
154 | 'main_table.category_id = fcs.category_id',
155 | ['store_id']
156 | );
157 | $this->getSelect()->group(
158 | 'main_table.category_id'
159 | );
160 | parent::_renderFiltersBefore();
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magento 2 FAQ Extension Free
2 | This is an awesome module, Admin can create unlimited, update, delete FAQs and FAQ categories free. The interface is easy to use. This extension is the best FAQ extension for your bussiness.
3 |
4 | In the business, times equals money while there are always thousands of questions in a customer’s mind both before and after purchasing. Thus, the faster answers, the happier customers, the more successful business.
5 |
6 | Purchase this professional extension here https://www.giaphugroup.com/magento-2-professional-faqs-extension.html
7 |
8 | ## Features of this extension:
9 |
10 | ### Frontend:
11 | - Advanced Search for FAQs
12 | - Filter the FAQs via Category
13 | - The page detail about FAQ
14 | - Vote on the FAQ page
15 | - URL rewrite standard for SEO
16 | - Display FAQs via multi stores
17 |
18 | ### Backend:
19 | - Add unlimited FAQs and FAQ categories
20 | - Update, delete FAQs and FAQ categories
21 |
22 | ## Introduction installation:
23 |
24 | ### 1 - Installation Magento 2 FAQ extension
25 | #### Manual Installation
26 | Install FAQ extension for Magento2
27 | * Download the extension
28 | * Unzip the file
29 | * Create a folder {Magento root}/app/code/PHPCuong/Faq
30 | * Copy the content from the unzip folder
31 |
32 |
33 | ##### Using Composer
34 |
35 | ```
36 | composer require php-cuong/magento2-faqs-extensions
37 |
38 | ```
39 |
40 | ### 2 - Enable FAQ extension
41 | * php bin/magento module:enable PHPCuong_Faq
42 | * php bin/magento setup:upgrade
43 | * php bin/magento cache:clean
44 | * php bin/magento setup:static-content:deploy
45 |
46 | ### 3 - See results
47 | Log into your Magento admin, goto FAQs -> Manage FAQs, goto FAQs -> Manage FAQs Categories
48 |
49 | ## Magento 2 Tutorial Videos
50 | https://www.youtube.com/watch?v=akcaOBrLTzM&list=PL98CDCbI3TNvPczWSOnpaMoyxVISLVzYQ
51 |
52 | ## ScreenShot
53 | 
54 | 
55 | 
56 | 
57 | 
58 | 
59 | 
60 | 
61 | 
62 |
63 | ## Purchase
64 | Purchase this professional extension here https://www.giaphugroup.com/magento-2-professional-faqs-extension.html
65 |
--------------------------------------------------------------------------------
/Screenshot/FAQ-details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/FAQ-details.png
--------------------------------------------------------------------------------
/Screenshot/FAQ-manager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/FAQ-manager.png
--------------------------------------------------------------------------------
/Screenshot/edit-FAQ.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/edit-FAQ.png
--------------------------------------------------------------------------------
/Screenshot/edit-category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/edit-category.png
--------------------------------------------------------------------------------
/Screenshot/faq-category-list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/faq-category-list.png
--------------------------------------------------------------------------------
/Screenshot/faq-category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/faq-category.png
--------------------------------------------------------------------------------
/Screenshot/faq-page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/faq-page.png
--------------------------------------------------------------------------------
/Screenshot/icon/account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/account.png
--------------------------------------------------------------------------------
/Screenshot/icon/faq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/faq.png
--------------------------------------------------------------------------------
/Screenshot/icon/membership.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/membership.png
--------------------------------------------------------------------------------
/Screenshot/icon/payment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/payment.png
--------------------------------------------------------------------------------
/Screenshot/icon/returns.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/returns.png
--------------------------------------------------------------------------------
/Screenshot/icon/reward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/reward.png
--------------------------------------------------------------------------------
/Screenshot/icon/shipping.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/icon/shipping.png
--------------------------------------------------------------------------------
/Screenshot/linking-to-faq-page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/linking-to-faq-page.png
--------------------------------------------------------------------------------
/Screenshot/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/Screenshot/menu.png
--------------------------------------------------------------------------------
/Setup/InstallData.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-23 18:31:24
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 09:24:09
9 | */
10 |
11 | namespace PHPCuong\Faq\Setup;
12 |
13 | use Magento\Framework\Setup\InstallDataInterface;
14 | use Magento\Framework\Setup\ModuleContextInterface;
15 | use Magento\Framework\Setup\ModuleDataSetupInterface;
16 | use PHPCuong\Faq\Model\ResourceModel\Faq as FAQ;
17 | use Magento\Store\Model\StoreManagerInterface;
18 |
19 | /**
20 | * Install Data
21 | */
22 | class InstallData implements InstallDataInterface
23 | {
24 | /**
25 | * @var Magento\Store\Model\StoreManagerInterface
26 | */
27 | protected $_storeManager;
28 |
29 | /**
30 | * Construct
31 | *
32 | * @param StoreManagerInterface $storeManager
33 | */
34 | public function __construct(
35 | StoreManagerInterface $storeManager
36 | ) {
37 | $this->_storeManager = $storeManager;
38 | }
39 |
40 | /**
41 | * {@inheritdoc}
42 | *
43 | * @param ModuleDataSetupInterface $setup
44 | * @param ModuleContextInterface $context
45 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
46 | */
47 | public function install(
48 | ModuleDataSetupInterface $setup,
49 | ModuleContextInterface $context
50 | ) {
51 | $setup->startSetup();
52 |
53 | $value = [
54 | 'entity_type' => 'faq-faq',
55 | 'entity_id' => '1',
56 | 'request_path' => FAQ::FAQ_REQUEST_PATH,
57 | 'target_path' => FAQ::FAQ_TARGET_PATH,
58 | 'is_autogenerated' => '1'
59 | ];
60 |
61 | $stores = $this->_storeManager->getStores(true, true);
62 | foreach ($stores as $store) {
63 | if ($store->getData()['store_id'] > 0) {
64 | $value['store_id'] = $store->getData()['store_id'];
65 | $setup->getConnection()->insertOnDuplicate(
66 | $setup->getTable('url_rewrite'),
67 | $value
68 | );
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Ui/Component/Listing/Column/FaqActions.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 02:09:30
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 08:44:04
9 | */
10 |
11 | namespace PHPCuong\Faq\Ui\Component\Listing\Column;
12 |
13 | use \PHPCuong\Faq\Model\ResourceModel\Faq as faqResourceModel;
14 |
15 | class FaqActions extends \Magento\Ui\Component\Listing\Columns\Column
16 | {
17 | /**
18 | * Url path to edit
19 | *
20 | * @var string
21 | */
22 | const FAQ_URL_PATH_EDIT = 'phpcuong/faq/edit';
23 |
24 | /**
25 | * Url path to delete
26 | *
27 | * @var string
28 | */
29 | const FAQ_URL_PATH_DELETE = 'phpcuong/faq/delete';
30 |
31 | /**
32 | * URL builder
33 | *
34 | * @var \Magento\Framework\UrlInterface
35 | */
36 | protected $_urlBuilder;
37 |
38 | /**
39 | * @var \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder
40 | */
41 | protected $_actionUrlBuilder;
42 |
43 | /**
44 | * constructor
45 | *
46 | * @param \Magento\Framework\UrlInterface $urlBuilder
47 | * @param \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder $actionUrlBuilder
48 | * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
49 | * @param \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory
50 | * @param array $components
51 | * @param array $data
52 | */
53 | public function __construct(
54 | \Magento\Framework\UrlInterface $urlBuilder,
55 | \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder $actionUrlBuilder,
56 | \Magento\Framework\View\Element\UiComponent\ContextInterface $context,
57 | \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
58 | array $components = [],
59 | array $data = []
60 | ) {
61 | $this->_urlBuilder = $urlBuilder;
62 | $this->_actionUrlBuilder = $actionUrlBuilder;
63 | parent::__construct($context, $uiComponentFactory, $components, $data);
64 | }
65 |
66 | /**
67 | * Prepare Data Source
68 | *
69 | * @param array $dataSource
70 | * @return array
71 | */
72 | public function prepareDataSource(array $dataSource)
73 | {
74 | if (isset($dataSource['data']['items'])) {
75 | foreach ($dataSource['data']['items'] as & $item) {
76 | $name = $this->getData('name');
77 | if (isset($item['faq_id'])) {
78 | $item[$name]['edit'] = [
79 | 'href' => $this->_urlBuilder->getUrl(self::FAQ_URL_PATH_EDIT, ['faq_id' => $item['faq_id']]),
80 | 'label' => __('Edit')
81 | ];
82 | $item[$name]['delete'] = [
83 | 'href' => $this->_urlBuilder->getUrl(self::FAQ_URL_PATH_DELETE, ['faq_id' => $item['faq_id']]),
84 | 'label' => __('Delete'),
85 | 'confirm' => [
86 | 'title' => __('Delete "${ $.$data.title }"'),
87 | 'message' => __('Are you sure you wan\'t to delete this question?')
88 | ]
89 | ];
90 | }
91 |
92 | if (isset($item['identifier'])) {
93 | $item[$name]['preview'] = [
94 | 'href' => $this->_actionUrlBuilder->getUrl(faqResourceModel::FAQ_QUESTION_PATH.'/'.$item['identifier'].faqResourceModel::FAQ_DOT_HTML, isset($item['store_id']) ? $item['store_id'] : null, null),
95 | 'label' => __('View')
96 | ];
97 | }
98 | }
99 | }
100 | return $dataSource;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Ui/Component/Listing/Column/FaqcatActions.php:
--------------------------------------------------------------------------------
1 |
6 | * @Date 2016-12-16 02:11:40
7 | * @Last modified by: nquangcuong
8 | * @Last Modified time: 2017-01-05 08:45:02
9 | */
10 |
11 | namespace PHPCuong\Faq\Ui\Component\Listing\Column;
12 |
13 | use \PHPCuong\Faq\Model\ResourceModel\Faq as faqResourceModel;
14 |
15 | class FaqcatActions extends \Magento\Ui\Component\Listing\Columns\Column
16 | {
17 | /**
18 | * Url path to edit
19 | *
20 | * @var string
21 | */
22 | const FAQ_CATEGORY_URL_PATH_EDIT = 'phpcuong/faqcat/edit';
23 |
24 | /**
25 | * Url path to delete
26 | *
27 | * @var string
28 | */
29 | const FAQ_CATEGORY_URL_PATH_DELETE = 'phpcuong/faqcat/delete';
30 |
31 | /**
32 | * URL builder
33 | *
34 | * @var \Magento\Framework\UrlInterface
35 | */
36 | protected $urlBuilder;
37 |
38 | /**
39 | * @var \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder
40 | */
41 | protected $actionUrlBuilder;
42 |
43 | /**
44 | * constructor
45 | *
46 | * @param \Magento\Framework\UrlInterface $urlBuilder
47 | * @param \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder $actionUrlBuilder
48 | * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
49 | * @param \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory
50 | * @param array $components
51 | * @param array $data
52 | */
53 | public function __construct(
54 | \Magento\Framework\UrlInterface $urlBuilder,
55 | \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder $actionUrlBuilder,
56 | \Magento\Framework\View\Element\UiComponent\ContextInterface $context,
57 | \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
58 | array $components = [],
59 | array $data = []
60 | ) {
61 | $this->urlBuilder = $urlBuilder;
62 | $this->actionUrlBuilder = $actionUrlBuilder;
63 | parent::__construct($context, $uiComponentFactory, $components, $data);
64 | }
65 |
66 | /**
67 | * Prepare Data Source
68 | *
69 | * @param array $dataSource
70 | * @return array
71 | */
72 | public function prepareDataSource(array $dataSource)
73 | {
74 | if (isset($dataSource['data']['items'])) {
75 | foreach ($dataSource['data']['items'] as & $item) {
76 | $name = $this->getData('name');
77 | if (isset($item['category_id'])) {
78 | $item[$name]['edit'] = [
79 | 'href' => $this->urlBuilder->getUrl(self::FAQ_CATEGORY_URL_PATH_EDIT, ['category_id' => $item['category_id']]),
80 | 'label' => __('Edit')
81 | ];
82 | $item[$name]['delete'] = [
83 | 'href' => $this->urlBuilder->getUrl(self::FAQ_CATEGORY_URL_PATH_DELETE, ['category_id' => $item['category_id']]),
84 | 'label' => __('Delete'),
85 | 'confirm' => [
86 | 'title' => __('Delete "${ $.$data.title }"'),
87 | 'message' => __('Are you sure you wan\'t to delete this category?')
88 | ]
89 | ];
90 | }
91 |
92 | if (isset($item['identifier'])) {
93 | $item[$name]['preview'] = [
94 | 'href' => $this->actionUrlBuilder->getUrl(faqResourceModel::FAQ_CATEGORY_PATH.'/'.$item['identifier'].faqResourceModel::FAQ_DOT_HTML, isset($item['store_id']) ? $item['store_id'] : null, null),
95 | 'label' => __('View')
96 | ];
97 | }
98 | }
99 | }
100 | return $dataSource;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Ui/Component/Listing/Column/Thumbnail.php:
--------------------------------------------------------------------------------
1 | storeManager = $storeManager;
45 | $this->viewFileUrl = $viewFileUrl;
46 | }
47 |
48 | /**
49 | * Prepare Data Source
50 | *
51 | * @param array $dataSource
52 | * @return array
53 | */
54 | public function prepareDataSource(array $dataSource)
55 | {
56 | if (isset($dataSource['data']['items'])) {
57 | $fieldName = $this->getData('name');
58 | foreach ($dataSource['data']['items'] as & $item) {
59 | $faqCat = new \Magento\Framework\DataObject($item);
60 | $picture_url = !empty($faqCat['image']) ? $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'/'.$faqCat['image'] : $this->viewFileUrl->getUrl('PHPCuong_Faq::images/faq81x81.png');
61 | $item[$fieldName . '_src'] = $picture_url;
62 | $item[$fieldName . '_orig_src'] = $picture_url;
63 | $item[$fieldName . '_alt'] = __('The FAQ Category Thumbnail');
64 | }
65 | }
66 | return $dataSource;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "php-cuong/magento2-faqs-extensions",
3 | "description":"Magento2 FAQ Extension Free",
4 | "keywords": [
5 | "magento 2",
6 | "FAQs",
7 | "FAQs categories",
8 | "FAQ Extension",
9 | "FAQ Extension Free",
10 | "FAQ Module"
11 | ],
12 | "require": {
13 | "php": "~5.6.0|7.0.2|7.0.4|~7.0.6|~7.1.0",
14 | "magento/module-backend": "100.0.*|100.1.*|100.2.*",
15 | "magento/framework": "100.0.*|100.1.*|101.0.*"
16 | },
17 | "type": "magento2-module",
18 | "version": "2.1.7.1",
19 | "license": [
20 | "OSL-3.0",
21 | "AFL-3.0"
22 | ],
23 | "authors": [
24 | {
25 | "name": "Cuong NQ",
26 | "email": "bestearnmoney87@gmail.com",
27 | "role": "Developer"
28 | }
29 | ],
30 | "autoload": {
31 | "files": [
32 | "registration.php"
33 | ],
34 | "psr-4": {
35 | "PHPCuong\\Faq\\": ""
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/etc/acl.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
2 | = /* @escapeNotVerified */ base64_decode('RkFRcyBFeHRlbnNpb24=') ?> 3 | = /* @escapeNotVerified */ base64_decode('Mi4xLjcuMQ=='); ?> 4 |
5 | -------------------------------------------------------------------------------- /view/adminhtml/web/css/source/_module.less: -------------------------------------------------------------------------------- 1 | @import '../faq-extension/style.css'; 2 | 3 | .admin__menu .item-faqs.level-0>a:before { 4 | content: "\e900"; 5 | font-family: 'faq-extension'; 6 | } 7 | -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/Read Me.txt: -------------------------------------------------------------------------------- 1 | Open *demo.html* to see a list of all the glyphs in your font along with their codes/ligatures. 2 | 3 | To use the generated font in desktop programs, you can install the TTF font. In order to copy the character associated with each icon, refer to the text box at the bottom right corner of each glyph in demo.html. The character inside this text box may be invisible; but it can still be copied. See this guide for more info: https://icomoon.io/#docs/local-fonts 4 | 5 | You won't need any of the files located under the *demo-files* directory when including the generated font in your own projects. 6 | 7 | You can import *selection.json* back to the IcoMoon app using the *Import Icons* button (or via Main Menu → Manage Projects) to retrieve your icon selection. 8 | -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/demo-files/demo.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 0; 3 | margin: 0; 4 | font-family: sans-serif; 5 | font-size: 1em; 6 | line-height: 1.5; 7 | color: #555; 8 | background: #fff; 9 | } 10 | h1 { 11 | font-size: 1.5em; 12 | font-weight: normal; 13 | } 14 | small { 15 | font-size: .66666667em; 16 | } 17 | a { 18 | color: #e74c3c; 19 | text-decoration: none; 20 | } 21 | a:hover, a:focus { 22 | box-shadow: 0 1px #e74c3c; 23 | } 24 | .bshadow0, input { 25 | box-shadow: inset 0 -2px #e7e7e7; 26 | } 27 | input:hover { 28 | box-shadow: inset 0 -2px #ccc; 29 | } 30 | input, fieldset { 31 | font-family: sans-serif; 32 | font-size: 1em; 33 | margin: 0; 34 | padding: 0; 35 | border: 0; 36 | } 37 | input { 38 | color: inherit; 39 | line-height: 1.5; 40 | height: 1.5em; 41 | padding: .25em 0; 42 | } 43 | input:focus { 44 | outline: none; 45 | box-shadow: inset 0 -2px #449fdb; 46 | } 47 | .glyph { 48 | font-size: 16px; 49 | width: 15em; 50 | padding-bottom: 1em; 51 | margin-right: 4em; 52 | margin-bottom: 1em; 53 | float: left; 54 | overflow: hidden; 55 | } 56 | .liga { 57 | width: 80%; 58 | width: calc(100% - 2.5em); 59 | } 60 | .talign-right { 61 | text-align: right; 62 | } 63 | .talign-center { 64 | text-align: center; 65 | } 66 | .bgc1 { 67 | background: #f1f1f1; 68 | } 69 | .fgc1 { 70 | color: #999; 71 | } 72 | .fgc0 { 73 | color: #000; 74 | } 75 | p { 76 | margin-top: 1em; 77 | margin-bottom: 1em; 78 | } 79 | .mvm { 80 | margin-top: .75em; 81 | margin-bottom: .75em; 82 | } 83 | .mtn { 84 | margin-top: 0; 85 | } 86 | .mtl, .mal { 87 | margin-top: 1.5em; 88 | } 89 | .mbl, .mal { 90 | margin-bottom: 1.5em; 91 | } 92 | .mal, .mhl { 93 | margin-left: 1.5em; 94 | margin-right: 1.5em; 95 | } 96 | .mhmm { 97 | margin-left: 1em; 98 | margin-right: 1em; 99 | } 100 | .mls { 101 | margin-left: .25em; 102 | } 103 | .ptl { 104 | padding-top: 1.5em; 105 | } 106 | .pbs, .pvs { 107 | padding-bottom: .25em; 108 | } 109 | .pvs, .pts { 110 | padding-top: .25em; 111 | } 112 | .unit { 113 | float: left; 114 | } 115 | .unitRight { 116 | float: right; 117 | } 118 | .size1of2 { 119 | width: 50%; 120 | } 121 | .size1of1 { 122 | width: 100%; 123 | } 124 | .clearfix:before, .clearfix:after { 125 | content: " "; 126 | display: table; 127 | } 128 | .clearfix:after { 129 | clear: both; 130 | } 131 | .hidden-true { 132 | display: none; 133 | } 134 | .textbox0 { 135 | width: 3em; 136 | background: #f1f1f1; 137 | padding: .25em .5em; 138 | line-height: 1.5; 139 | height: 1.5em; 140 | } 141 | #testDrive { 142 | display: block; 143 | padding-top: 24px; 144 | line-height: 1.5; 145 | } 146 | .fs0 { 147 | font-size: 16px; 148 | } 149 | .fs1 { 150 | font-size: 24px; 151 | } 152 | .fs2 { 153 | font-size: 32px; 154 | } 155 | .fs3 { 156 | font-size: 32px; 157 | } 158 | 159 | -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/demo-files/demo.js: -------------------------------------------------------------------------------- 1 | if (!('boxShadow' in document.body.style)) { 2 | document.body.setAttribute('class', 'noBoxShadow'); 3 | } 4 | 5 | document.body.addEventListener("click", function(e) { 6 | var target = e.target; 7 | if (target.tagName === "INPUT" && 8 | target.getAttribute('class').indexOf('liga') === -1) { 9 | target.select(); 10 | } 11 | }); 12 | 13 | (function() { 14 | var fontSize = document.getElementById('fontSize'), 15 | testDrive = document.getElementById('testDrive'), 16 | testText = document.getElementById('testText'); 17 | function updateTest() { 18 | testDrive.innerHTML = testText.value || String.fromCharCode(160); 19 | if (window.icomoonLiga) { 20 | window.icomoonLiga(testDrive); 21 | } 22 | } 23 | function updateSize() { 24 | testDrive.style.fontSize = fontSize.value + 'px'; 25 | } 26 | fontSize.addEventListener('change', updateSize, false); 27 | testText.addEventListener('input', updateTest, false); 28 | testText.addEventListener('change', updateTest, false); 29 | updateSize(); 30 | }()); 31 | -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/fonts/faq-extension.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/view/base/web/css/faq-extension/fonts/faq-extension.eot -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/fonts/faq-extension.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/view/base/web/css/faq-extension/fonts/faq-extension.ttf -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/fonts/faq-extension.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/view/base/web/css/faq-extension/fonts/faq-extension.woff -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/ie7/ie7.css: -------------------------------------------------------------------------------- 1 | .faq-iconkeyboard_arrow_right { 2 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 3 | } 4 | .faq-iconicon-gpg { 5 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 6 | } 7 | .faq-iconfaq-icon { 8 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 9 | } 10 | .faq-iconcalendar { 11 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 12 | } 13 | .faq-iconuser { 14 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 15 | } 16 | .faq-iconeye { 17 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 18 | } 19 | .faq-iconhappy { 20 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 21 | } 22 | .faq-iconangry { 23 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 24 | } 25 | .faq-iconplus { 26 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 27 | } 28 | .faq-iconminus { 29 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 30 | } 31 | .faq-iconsearch { 32 | *zoom: expression(this.runtimeStyle['zoom'] = '1', this.innerHTML = ''); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/ie7/ie7.js: -------------------------------------------------------------------------------- 1 | /* To avoid CSS expressions while still supporting IE 7 and IE 6, use this script */ 2 | /* The script tag referencing this file must be placed before the ending body tag. */ 3 | 4 | /* Use conditional comments in order to target IE 7 and older: 5 | 6 | 7 | 8 | */ 9 | 10 | (function() { 11 | function addIcon(el, entity) { 12 | var html = el.innerHTML; 13 | el.innerHTML = '' + entity + '' + html; 14 | } 15 | var icons = { 16 | 'faq-iconkeyboard_arrow_right': '', 17 | 'faq-iconicon-gpg': '', 18 | 'faq-iconfaq-icon': '', 19 | 'faq-iconcalendar': '', 20 | 'faq-iconuser': '', 21 | 'faq-iconeye': '', 22 | 'faq-iconhappy': '', 23 | 'faq-iconangry': '', 24 | 'faq-iconplus': '', 25 | 'faq-iconminus': '', 26 | 'faq-iconsearch': '', 27 | '0': 0 28 | }, 29 | els = document.getElementsByTagName('*'), 30 | i, c, el; 31 | for (i = 0; ; i += 1) { 32 | el = els[i]; 33 | if(!el) { 34 | break; 35 | } 36 | c = el.className; 37 | c = c.match(/faq-icon[^\s'"]+/); 38 | if (c && icons[c[0]]) { 39 | addIcon(el, icons[c[0]]); 40 | } 41 | } 42 | }()); 43 | -------------------------------------------------------------------------------- /view/base/web/css/faq-extension/style.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'faq-extension'; 3 | src: url('fonts/faq-extension.eot?uvajb2'); 4 | src: url('fonts/faq-extension.eot?uvajb2#iefix') format('embedded-opentype'), 5 | url('fonts/faq-extension.ttf?uvajb2') format('truetype'), 6 | url('fonts/faq-extension.woff?uvajb2') format('woff'), 7 | url('fonts/faq-extension.svg?uvajb2#faq-extension') format('svg'); 8 | font-weight: normal; 9 | font-style: normal; 10 | } 11 | 12 | [class^="faq-icon"], [class*=" faq-icon"] { 13 | /* use !important to prevent issues with browser extensions that change fonts */ 14 | font-family: 'faq-extension' !important; 15 | speak: none; 16 | font-style: normal; 17 | font-weight: normal; 18 | font-variant: normal; 19 | text-transform: none; 20 | line-height: 1; 21 | 22 | /* Better Font Rendering =========== */ 23 | -webkit-font-smoothing: antialiased; 24 | -moz-osx-font-smoothing: grayscale; 25 | } 26 | 27 | .faq-iconkeyboard_arrow_right:before { 28 | content: "\e902"; 29 | } 30 | .faq-iconicon-gpg:before { 31 | content: "\e901"; 32 | } 33 | .faq-iconfaq-icon:before { 34 | content: "\e900"; 35 | color: #fff; 36 | } 37 | .faq-iconcalendar:before { 38 | content: "\e953"; 39 | } 40 | .faq-iconuser:before { 41 | content: "\e971"; 42 | } 43 | .faq-iconeye:before { 44 | content: "\e9ce"; 45 | } 46 | .faq-iconhappy:before { 47 | content: "\e9df"; 48 | } 49 | .faq-iconangry:before { 50 | content: "\e9ed"; 51 | } 52 | .faq-iconplus:before { 53 | content: "\ea0a"; 54 | } 55 | .faq-iconminus:before { 56 | content: "\ea0b"; 57 | } 58 | .faq-iconsearch:before { 59 | content: "\e986"; 60 | } 61 | -------------------------------------------------------------------------------- /view/base/web/images/faq81x81.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php-cuong/magento2-faqs-extensions/1479463d3ac99f52e08eadc30adceee73599cb54/view/base/web/images/faq81x81.png -------------------------------------------------------------------------------- /view/frontend/layout/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 |