|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
/* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* |
|
9
|
|
|
* This program is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @package RSSFit - Extendable XML news feed generator |
|
18
|
|
|
* @author NS Tai (aka tuff) <http://www.brandycoke.com> |
|
19
|
|
|
* @author XOOPS Development Team |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
use Xmf\Request; |
|
23
|
|
|
use XoopsModules\Rssfit\{ |
|
24
|
|
|
MiscHandler |
|
25
|
|
|
}; |
|
26
|
|
|
|
|
27
|
|
|
/** @var MiscHandler $miscHandler */ |
|
28
|
|
|
|
|
29
|
|
|
if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) { |
|
30
|
|
|
redirect_header('index.php'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$intr = $miscHandler->getObjects2(new \Criteria('misc_category', 'intro')); |
|
34
|
|
|
if ($intr) { |
|
35
|
|
|
$intro = $intr[0]; |
|
36
|
|
|
unset($intr); |
|
37
|
|
|
} else { |
|
38
|
|
|
$intro = $miscHandler->create(); |
|
39
|
|
|
} |
|
40
|
|
|
switch ($op) { |
|
41
|
|
|
default: |
|
42
|
|
|
$title = new \XoopsFormText(_AM_RSSFIT_EDIT_INTRO_TITLE, 'title', 50, 255, $intro->getVar('misc_title', 'e')); |
|
43
|
|
|
$title->setDescription(_AM_RSSFIT_EDIT_INTRO_TITLE_DESC); |
|
44
|
|
|
|
|
45
|
|
|
$setting = $intro->getVar('misc_setting'); |
|
46
|
|
|
$contentTray = new \XoopsFormElementTray(_AM_RSSFIT_EDIT_INTRO_TEXT, '<br>'); |
|
47
|
|
|
$contentTray->setDescription(_AM_RSSFIT_EDIT_INTRO_TEXT_DESC . _AM_RSSFIT_EDIT_INTRO_TEXT_DESC_SUB); |
|
48
|
|
|
$contentTray->addElement(new \XoopsFormDhtmlTextArea('', 'content', $intro->getVar('misc_content', 'e'), 15, 60)); |
|
49
|
|
|
$dohtml = new \XoopsFormCheckBox('', 'dohtml', $setting['dohtml'] ?? ''); |
|
50
|
|
|
$dohtml->addOption('1', _AM_RSSFIT_DO_HTML); |
|
51
|
|
|
$contentTray->addElement($dohtml); |
|
52
|
|
|
$dobr = new \XoopsFormCheckBox('', 'dobr', $setting['dobr'] ?? ''); |
|
53
|
|
|
$dobr->addOption('1', _AM_RSSFIT_DO_BR); |
|
54
|
|
|
$contentTray->addElement($dobr); |
|
55
|
|
|
|
|
56
|
|
|
$sub = new \XoopsFormTextArea(_AM_RSSFIT_EDIT_INTRO_SUB, 'sub', htmlspecialchars($setting['sub'] ?? '', ENT_QUOTES | ENT_HTML5)); |
|
57
|
|
|
$sub->setDescription(_AM_RSSFIT_EDIT_INTRO_SUB_DESC); |
|
58
|
|
|
|
|
59
|
|
|
$form = new \XoopsThemeForm(_AM_RSSFIT_EDIT_INTRO, 'editintro', RSSFIT_ADMIN_URL); |
|
|
|
|
|
|
60
|
|
|
$form->addElement($title); |
|
61
|
|
|
$form->addElement($contentTray); |
|
62
|
|
|
$form->addElement($sub); |
|
63
|
|
|
$form->addElement($saveCancelTray); |
|
64
|
|
|
$form->addElement($hiddenDo); |
|
65
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
66
|
|
|
$form->display(); |
|
67
|
|
|
break; |
|
68
|
|
|
case 'save': |
|
69
|
|
|
$intro->setVar('misc_category', 'intro'); |
|
70
|
|
|
$intro->setVar('misc_title', trim($_POST['title'])); |
|
71
|
|
|
$intro->setVar('misc_content', $_POST['content']); |
|
72
|
|
|
$setting = [ |
|
73
|
|
|
'dohtml' => isset($_POST['dohtml']) ? 1 : 0, |
|
74
|
|
|
'dobr' => isset($_POST['dobr']) ? 1 : 0, |
|
75
|
|
|
'sub' => isset($_POST['sub']) ? trim($_POST['sub']) : '', |
|
76
|
|
|
]; |
|
77
|
|
|
$intro->setVar('misc_setting', $setting); |
|
78
|
|
|
if (false !== $miscHandler->insert($intro)) { |
|
79
|
|
|
redirect_header(RSSFIT_ADMIN_URL . '?do=' . $do, 0, _AM_RSSFIT_DBUPDATED); |
|
80
|
|
|
} else { |
|
81
|
|
|
echo $intro->getHtmlErrors(); |
|
82
|
|
|
} |
|
83
|
|
|
break; |
|
84
|
|
|
} |
|
85
|
|
|
|