1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Xhttperror; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* **************************************************************************** |
7
|
|
|
* - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
8
|
|
|
* **************************************************************************** |
9
|
|
|
* XHTTPERROR - MODULE FOR XOOPS |
10
|
|
|
* Copyright (c) 2007 - 2012 |
11
|
|
|
* Rota Lucio ( http://luciorota.altervista.org/xoops/ ) |
12
|
|
|
* |
13
|
|
|
* You may not change or alter any portion of this comment or credits |
14
|
|
|
* of supporting developers from this source code or any supporting |
15
|
|
|
* source code which is considered copyrighted (c) material of the |
16
|
|
|
* original comment or credit authors. |
17
|
|
|
* |
18
|
|
|
* This program is distributed in the hope that it will be useful, |
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21
|
|
|
* GNU General Public License for more details. |
22
|
|
|
* --------------------------------------------------------------------------- |
23
|
|
|
* @copyright Rota Lucio ( http://luciorota.altervista.org/xoops/ ) |
24
|
|
|
* @license GNU General Public License v3.0 |
25
|
|
|
* @package xhttperror |
26
|
|
|
* @author Rota Lucio ( [email protected] ) |
27
|
|
|
* |
28
|
|
|
* $Rev$: Revision of last commit |
29
|
|
|
* $Author$: Author of last commit |
30
|
|
|
* $Date$: Date of last commit |
31
|
|
|
* **************************************************************************** |
32
|
|
|
*/ |
33
|
|
|
|
34
|
|
|
\define('XHTTPERR_REDIRECT_NO', 0); |
35
|
|
|
\define('XHTTPERR_REDIRECT_URI', 1); |
36
|
|
|
\define('XHTTPERR_REDIRECT_PREVIOUS', 2); |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Class Error |
40
|
|
|
* @package XoopsModules\Xhttperror |
41
|
|
|
*/ |
42
|
|
|
class Error extends \XoopsObject |
43
|
|
|
{ |
44
|
|
|
// constructor |
45
|
|
|
public function __construct() |
46
|
|
|
{ |
47
|
|
|
parent::__construct(); |
48
|
|
|
$this->initVar('error_id', \XOBJ_DTYPE_INT, null, false, 5); |
49
|
|
|
$this->initVar('error_title', \XOBJ_DTYPE_TXTBOX, null, true); |
50
|
|
|
$this->initVar('error_statuscode', \XOBJ_DTYPE_TXTBOX, '000', true); |
51
|
|
|
$this->initVar('error_text', \XOBJ_DTYPE_TXTAREA, null, false, ''); |
|
|
|
|
52
|
|
|
$this->initVar('error_text_html', \XOBJ_DTYPE_INT, true, false); // default: true |
53
|
|
|
$this->initVar('error_text_smiley', \XOBJ_DTYPE_INT, true, false); // default: true |
54
|
|
|
$this->initVar('error_text_breaks', \XOBJ_DTYPE_INT, false, false); // default: false |
55
|
|
|
$this->initVar('error_showme', \XOBJ_DTYPE_INT, true, false); // default: true |
56
|
|
|
$this->initVar('error_redirect', \XOBJ_DTYPE_INT, \XHTTPERR_REDIRECT_NO, false); // default: XHTTPERR_REDIRECT_NO |
57
|
|
|
$this->initVar('error_redirect_time', \XOBJ_DTYPE_INT, 3, false); // default: 3 seconds |
58
|
|
|
$this->initVar('error_redirect_message', \XOBJ_DTYPE_TXTBOX, '', false); // IN PROGRESS |
59
|
|
|
$this->initVar('error_redirect_uri', \XOBJ_DTYPE_URL, XOOPS_URL, false); // default XOOPS_URL |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param bool $action |
64
|
|
|
* @return \XoopsThemeForm |
65
|
|
|
*/ |
66
|
|
|
public function getForm($action = false) |
67
|
|
|
{ |
68
|
|
|
global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
69
|
|
|
|
70
|
|
|
if (false === $action) { |
71
|
|
|
$action = $_SERVER['REQUEST_URI']; |
72
|
|
|
} |
73
|
|
|
$title = $this->isNew() ? \sprintf(\_AM_XHTTPERR_ERROR_ADD) : \sprintf(\_AM_XHTTPERR_ERROR_EDIT); |
74
|
|
|
|
75
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
76
|
|
|
|
77
|
|
|
$formObj = new \XoopsThemeForm($title, 'form_error', $action, 'post', true); |
78
|
|
|
$formObj->setExtra('enctype="multipart/form-data"'); |
79
|
|
|
|
80
|
|
|
// Title |
81
|
|
|
$errorTitle = new \XoopsFormText(\_AM_XHTTPERR_ERROR_TITLE, 'error_title', 40, 255, $this->getVar('error_title')); |
|
|
|
|
82
|
|
|
$errorTitle->setDescription(\_AM_XHTTPERR_ERROR_TITLE_DESC); |
83
|
|
|
$formObj->addElement($errorTitle, true); |
84
|
|
|
unset($errorTitle); |
85
|
|
|
// Error number |
86
|
|
|
if ($this->isNew()) { |
87
|
|
|
$errorStatuscode = new \XoopsFormText(\_AM_XHTTPERR_ERROR_STATUSCODE, 'error_statuscode', 3, 3, $this->getVar('error_statuscode')); |
88
|
|
|
} else { |
89
|
|
|
$errorStatuscode = new \XoopsFormLabel(\_AM_XHTTPERR_ERROR_STATUSCODE, $this->getVar('error_statuscode')); |
|
|
|
|
90
|
|
|
} |
91
|
|
|
$formObj->addElement($errorStatuscode, true); |
92
|
|
|
unset($errorStatuscode); |
93
|
|
|
// Text |
94
|
|
|
$editor_configs = []; |
95
|
|
|
$editor_configs['name'] = 'error_text'; |
96
|
|
|
$editor_configs['value'] = $this->getVar('error_text', 'e'); |
97
|
|
|
$editor_configs['rows'] = 10; |
98
|
|
|
$editor_configs['cols'] = 50; |
99
|
|
|
$editor_configs['width'] = '100%'; |
100
|
|
|
$editor_configs['height'] = '100px'; |
101
|
|
|
$editor_configs['editor'] = $GLOBALS['xoopsModuleConfig']['text_editor']; |
102
|
|
|
$errorText = new \XoopsFormEditor(\_AM_XHTTPERR_ERROR_TEXT, 'error_text', $editor_configs); |
103
|
|
|
$errorText->setDescription(\_AM_XHTTPERR_ERROR_TEXT_DESC); |
104
|
|
|
$formObj->addElement($errorText); |
105
|
|
|
// Text options |
106
|
|
|
$errorTextOptions = new \XoopsFormElementTray(\_AM_XHTTPERR_ERROR_TEXT_OPTIONS, '|', ''); |
107
|
|
|
$errorTextOptions->addElement(new \XoopsFormRadioYN(\_AM_XHTTPERR_ERROR_TEXT_HTML, 'error_text_html', $this->getVar('error_text_html'), _YES, _NO)); |
|
|
|
|
108
|
|
|
$errorTextOptions->addElement(new \XoopsFormRadioYN(\_AM_XHTTPERR_ERROR_TEXT_SMILEY, 'error_text_smiley', $this->getVar('error_text_smiley'), _YES, _NO)); |
109
|
|
|
$errorTextOptions->addElement(new \XoopsFormRadioYN(\_AM_XHTTPERR_ERROR_TEXT_BREAKS, 'error_text_breaks', $this->getVar('error_text_breaks'), _YES, _NO)); |
110
|
|
|
$errorTextOptions->setDescription(\_AM_XHTTPERR_ERROR_TEXT_OPTIONS_DESC); |
111
|
|
|
$formObj->addElement($errorTextOptions); |
112
|
|
|
unset($errorTextOptions); |
113
|
|
|
// Showme |
114
|
|
|
$errorShowme = new \XoopsFormRadioYN(\_AM_XHTTPERR_ERROR_STATUS, 'error_showme', $this->getVar('error_showme'), _YES, _NO); |
115
|
|
|
$errorShowme->setDescription(\_AM_XHTTPERR_ERROR_STATUS_DESC); |
116
|
|
|
$formObj->addElement($errorShowme); |
117
|
|
|
unset($errorShowme); |
118
|
|
|
|
119
|
|
|
$formObj->addElement(new \XoopsFormLabel(_AM_XHTTPERR_ERROR_REDIRECT_OPTIONS, '', '')); |
120
|
|
|
// Redirect |
121
|
|
|
$errorRedirect = new \XoopsFormSelect(\_AM_XHTTPERR_ERROR_REDIRECT, 'error_redirect', $this->getVar('error_redirect'), 1, false); |
122
|
|
|
$errorRedirect->addOption(\XHTTPERR_REDIRECT_NO, \_AM_XHTTPERR_ERROR_REDIRECT_OPTION_NO); |
123
|
|
|
$errorRedirect->addOption(\XHTTPERR_REDIRECT_URI, \_AM_XHTTPERR_ERROR_REDIRECT_OPTION_URI); |
124
|
|
|
$errorRedirect->addOption(\XHTTPERR_REDIRECT_PREVIOUS, \_AM_XHTTPERR_ERROR_REDIRECT_OPTION_PREVIOUS); |
125
|
|
|
//$errorRedirect = new \XoopsFormRadioYN(, _YES, _NO); |
126
|
|
|
$errorRedirect->setDescription(\_AM_XHTTPERR_ERROR_REDIRECT_DESC); |
127
|
|
|
$formObj->addElement($errorRedirect); |
128
|
|
|
unset($errorRedirect); |
129
|
|
|
// Redirect time |
130
|
|
|
$errorRedirectTime = new \XoopsFormText(\_AM_XHTTPERR_ERROR_REDIRECT_TIME, 'error_redirect_time', 2, 2, $this->getVar('error_redirect_time')); |
131
|
|
|
$errorRedirectTime->setDescription(\_AM_XHTTPERR_ERROR_REDIRECT_TIME_DESC); |
132
|
|
|
$formObj->addElement($errorRedirectTime); |
133
|
|
|
unset($errorRedirectTime); |
134
|
|
|
/* IN PROGRESS |
135
|
|
|
// Redirect message |
136
|
|
|
$errorRedirectMessage = new \XoopsFormText(_AM_XHTTPERR_ERROR_REDIRECT_MESSAGE, 'error_redirect_message', 40, 255, $this->getVar('error_redirect_message')); |
137
|
|
|
$errorRedirectMessage->setDescription(_AM_XHTTPERR_ERROR_REDIRECT_MESSAGE_DESC); |
138
|
|
|
$formObj->addElement($errorRedirectMessage, true); |
139
|
|
|
unset($errorRedirectMessage); |
140
|
|
|
*/ |
141
|
|
|
// Redirect uri |
142
|
|
|
$errorRedirectUri = new \XoopsFormText(\_AM_XHTTPERR_ERROR_REDIRECT_URI, 'error_redirect_uri', 40, 255, $this->getVar('error_redirect_uri')); |
143
|
|
|
$errorRedirectUri->setDescription(\_AM_XHTTPERR_ERROR_REDIRECT_URI_DESC); |
144
|
|
|
$formObj->addElement($errorRedirectUri); |
145
|
|
|
unset($errorRedirectUri); |
146
|
|
|
|
147
|
|
|
// Captcha |
148
|
|
|
\xoops_load('xoopscaptcha'); |
149
|
|
|
$formObj->addElement(new \XoopsFormCaptcha(), true); |
150
|
|
|
// Hidden Fields |
151
|
|
|
$formObj->addElement(new \XoopsFormHidden('op', 'save_error')); |
152
|
|
|
if ($this->isNew()) { |
153
|
|
|
// NOP |
154
|
|
|
} else { |
155
|
|
|
$formObj->addElement(new \XoopsFormHidden('error_id', $this->getVar('error_id'))); |
|
|
|
|
156
|
|
|
} |
157
|
|
|
// Submit button |
158
|
|
|
$buttonTray = new \XoopsFormElementTray(\_AM_XHTTPERR_ACTION, '', ''); |
159
|
|
|
$buttonTray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
160
|
|
|
$buttonTray->addElement(new \XoopsFormButton('', 'reset', _RESET, 'reset')); |
161
|
|
|
$cancel_button = new \XoopsFormButton('', 'cancel', _CANCEL, 'button'); |
162
|
|
|
$cancel_button->setExtra("onclick='javascript:history.back();'"); |
163
|
|
|
$buttonTray->addElement($cancel_button); |
164
|
|
|
$formObj->addElement($buttonTray); |
165
|
|
|
|
166
|
|
|
return $formObj; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|