|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace XoopsModules\Adslight\Form; |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
You may not change or alter any portion of this comment or credits |
|
9
|
|
|
of supporting developers from this source code or any supporting source code |
|
10
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
*/ |
|
16
|
|
|
/** |
|
17
|
|
|
* Module: Adslight |
|
18
|
|
|
* |
|
19
|
|
|
* @category Module |
|
20
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
|
21
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
22
|
|
|
* @license GPL 2.0 or later |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use Xmf\Request; |
|
26
|
|
|
use XoopsModules\Adslight; |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
require_once \dirname(dirname(__DIR__)) . '/include/common.php'; |
|
30
|
|
|
|
|
31
|
|
|
$moduleDirName = basename(dirname(__DIR__, 2)); |
|
32
|
|
|
//$helper = Adslight\Helper::getInstance(); |
|
33
|
|
|
$permHelper = new \Xmf\Module\Helper\Permission(); |
|
34
|
|
|
|
|
35
|
|
|
xoops_load('XoopsFormLoader'); |
|
36
|
|
|
/** |
|
37
|
|
|
* Class RepliesForm |
|
38
|
|
|
*/ |
|
39
|
|
|
class RepliesForm extends \XoopsThemeForm |
|
40
|
|
|
{ |
|
41
|
|
|
public $targetObject; |
|
42
|
|
|
public $helper; |
|
43
|
|
|
/** |
|
44
|
|
|
* Constructor |
|
45
|
|
|
* |
|
46
|
|
|
* @param $target |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct($target) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->helper = $target->helper; |
|
51
|
|
|
$this->targetObject = $target; |
|
52
|
|
|
|
|
53
|
|
|
$title = $this->targetObject->isNew() ? sprintf(AM_ADSLIGHT_REPLIES_ADD) : sprintf(AM_ADSLIGHT_REPLIES_EDIT); |
|
54
|
|
|
parent::__construct($title, 'form', xoops_getenv('SCRIPT_NAME'),'post', true); |
|
55
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
//include ID field, it's needed so the module knows if it is a new form or an edited form |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
$hidden = new \XoopsFormHidden('r_lid', $this->targetObject->getVar('r_lid')); |
|
63
|
|
|
$this->addElement($hidden); |
|
64
|
|
|
unset($hidden); |
|
65
|
|
|
|
|
66
|
|
|
// R_lid |
|
67
|
|
|
$this->addElement(new \XoopsFormLabel(AM_ADSLIGHT_REPLIES_R_LID, $this->targetObject->getVar('r_lid'), 'r_lid' )); |
|
68
|
|
|
// Lid |
|
69
|
|
|
//$listingHandler = $this->helper->getHandler('Listing'); |
|
70
|
|
|
//$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
71
|
|
|
/** @var \XoopsPersistableObjectHandler $listingHandler */ |
|
72
|
|
|
$listingHandler = $this->helper->getHandler('Listing'); |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
$listing_id_select = new \XoopsFormSelect(AM_ADSLIGHT_REPLIES_LID, 'lid', $this->targetObject->getVar('lid')); |
|
76
|
|
|
$listing_id_select->addOptionArray($listingHandler->getList()); |
|
77
|
|
|
$this->addElement($listing_id_select, false); |
|
78
|
|
|
// Title |
|
79
|
|
|
$this->addElement(new \XoopsFormText(AM_ADSLIGHT_REPLIES_TITLE, 'title', 50, 255, $this->targetObject->getVar('title')), false); |
|
80
|
|
|
// Date |
|
81
|
|
|
$this->addElement(new \XoopsFormTextDateSelect(AM_ADSLIGHT_REPLIES_DATE, 'date', 0, formatTimestamp($this->targetObject->getVar('date'), 's'))); |
|
|
|
|
|
|
82
|
|
|
// Submitter |
|
83
|
|
|
$this->addElement(new \XoopsFormSelectUser(AM_ADSLIGHT_REPLIES_SUBMITTER, 'submitter', false, $this->targetObject->getVar('submitter'), 1, false), false); |
|
84
|
|
|
// Message |
|
85
|
|
|
if (class_exists('XoopsFormEditor')) { |
|
86
|
|
|
$editorOptions = []; |
|
87
|
|
|
$editorOptions['name'] = 'message'; |
|
88
|
|
|
$editorOptions['value'] = $this->targetObject->getVar('message', 'e'); |
|
89
|
|
|
$editorOptions['rows'] = 5; |
|
90
|
|
|
$editorOptions['cols'] = 40; |
|
91
|
|
|
$editorOptions['width'] = '100%'; |
|
92
|
|
|
$editorOptions['height'] = '400px'; |
|
93
|
|
|
//$editorOptions['editor'] = xoops_getModuleOption('adslight_editor', 'adslight'); |
|
94
|
|
|
//$this->addElement( new \XoopsFormEditor(AM_ADSLIGHT_REPLIES_MESSAGE, 'message', $editorOptions), false ); |
|
95
|
|
|
if ($this->helper->isUserAdmin()) { |
|
96
|
|
|
$descEditor = new \XoopsFormEditor(AM_ADSLIGHT_REPLIES_MESSAGE, $this->helper->getConfig('adslightEditorAdmin'), $editorOptions, $nohtml = false, $onfailure = 'textarea'); |
|
97
|
|
|
} else { |
|
98
|
|
|
$descEditor = new \XoopsFormEditor(AM_ADSLIGHT_REPLIES_MESSAGE, $this->helper->getConfig('adslightEditorUser'), $editorOptions, $nohtml = false, $onfailure = 'textarea'); |
|
99
|
|
|
} |
|
100
|
|
|
} else { |
|
101
|
|
|
$descEditor = new \XoopsFormDhtmlTextArea(AM_ADSLIGHT_REPLIES_MESSAGE, 'description', $this->targetObject->getVar('description', 'e'), 5, 50); |
|
102
|
|
|
} |
|
103
|
|
|
$this->addElement($descEditor); |
|
104
|
|
|
// Tele |
|
105
|
|
|
$this->addElement(new \XoopsFormText(AM_ADSLIGHT_REPLIES_TELE, 'tele', 50, 255, $this->targetObject->getVar('tele')), false); |
|
106
|
|
|
// Email |
|
107
|
|
|
$this->addElement(new \XoopsFormText(AM_ADSLIGHT_REPLIES_EMAIL, 'email', 50, 255, $this->targetObject->getVar('email')), false); |
|
108
|
|
|
// R_usid |
|
109
|
|
|
$this->addElement(new \XoopsFormSelectUser(AM_ADSLIGHT_REPLIES_R_USID, 'r_usid', false, $this->targetObject->getVar('r_usid'), 1, false), false); |
|
110
|
|
|
|
|
111
|
|
|
$this->addElement(new \XoopsFormHidden('op', 'save')); |
|
112
|
|
|
$this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|