1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Module: SmartFAQ |
5
|
|
|
* Author: The SmartFactory <www.smartfactory.ca> |
6
|
|
|
* Licence: GNU |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use XoopsModules\Smartfaq; |
10
|
|
|
use XoopsModules\Smartfaq\Constants; |
11
|
|
|
|
12
|
|
|
/** @var Smartfaq\Helper $helper */ |
13
|
|
|
$helper = Smartfaq\Helper::getInstance(); |
14
|
|
|
|
15
|
|
|
global $_POST; |
16
|
|
|
|
17
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; |
18
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
19
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
20
|
|
|
//require_once __DIR__ . '/functions.php'; |
21
|
|
|
|
22
|
|
|
$mytree = new Smartfaq\Tree($xoopsDB->prefix('smartfaq_categories'), 'categoryid', 'parentid'); |
23
|
|
|
//$form = new \XoopsThemeForm(_MD_SF_SUBMITANSWER, "form", xoops_getenv('SCRIPT_NAME'), 'post', true); |
24
|
|
|
$form = new \XoopsThemeForm(_MD_SF_SUBMITANSWER, 'form', ''); |
25
|
|
|
// faq QUESTION |
26
|
|
|
$form->addElement(new \XoopsFormLabel(_MD_SF_QUESTION, $faqObj->question()), false); |
27
|
|
|
// ANSWER |
28
|
|
|
//$form->addElement(new \XoopsFormDhtmlTextArea(_MD_SF_ANSWER_FAQ, 'answer', '', 15, 60), true); |
29
|
|
|
|
30
|
|
|
$editorTray = new \XoopsFormElementTray(_MD_SF_ANSWER_FAQ, '<br>'); |
31
|
|
|
if (class_exists('XoopsFormEditor')) { |
32
|
|
|
$options['name'] = 'answer'; |
33
|
|
|
$options['value'] = ''; |
34
|
|
|
$options['rows'] = 5; |
35
|
|
|
$options['cols'] = '100%'; |
36
|
|
|
$options['width'] = '100%'; |
37
|
|
|
$options['height'] = '200px'; |
38
|
|
|
$answerEditor = new \XoopsFormEditor('', $helper->getConfig('form_editorOptionsUser'), $options, $nohtml = false, $onfailure = 'textarea'); |
39
|
|
|
$editorTray->addElement($answerEditor, true); |
40
|
|
|
} else { |
41
|
|
|
$answerEditor = new \XoopsFormDhtmlTextArea(_MD_SF_ANSWER_FAQ, 'answer', '', '100%', '100%'); |
|
|
|
|
42
|
|
|
$editorTray->addElement($answerEditor, true); |
43
|
|
|
} |
44
|
|
|
$form->addElement($editorTray); |
45
|
|
|
|
46
|
|
|
// NOTIFY ON PUBLISH |
47
|
|
|
if (is_object($xoopsUser)) { |
48
|
|
|
$notify_checkbox = new \XoopsFormCheckBox('', 'notifypub', 1); |
49
|
|
|
$notify_checkbox->addOption(1, _MD_SF_NOTIFY); |
50
|
|
|
$form->addElement($notify_checkbox); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if ((Constants::SF_STATUS_PUBLISHED == $faqObj->status()) || (Constants::SF_STATUS_NEW_ANSWER == $faqObj->status())) { |
54
|
|
|
$answerObj = $faqObj->answer(); |
55
|
|
|
$form->addElement(new \XoopsFormLabel(_MD_SF_ORIGINAL_ANSWER, $answerObj->answer()), false); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$form->addElement(new \XoopsFormHidden('faqid', $faqObj->faqid())); |
59
|
|
|
|
60
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
61
|
|
|
$hidden = new \XoopsFormHidden('op', 'post'); |
62
|
|
|
$buttonTray->addElement($hidden); |
63
|
|
|
|
64
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
65
|
|
|
$hidden = new \XoopsFormHidden('op', 'post'); |
66
|
|
|
$buttonTray->addElement($hidden); |
67
|
|
|
$buttonTray->addElement(new \XoopsFormButton('', 'post', _MD_SF_SUBMITANSWER, 'submit')); |
68
|
|
|
$form->addElement($buttonTray); |
69
|
|
|
|
70
|
|
|
$form->assign($xoopsTpl); |
71
|
|
|
|
72
|
|
|
unset($hidden); |
73
|
|
|
|