|
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
|
|
|
|
|
25
|
|
|
if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) { |
|
26
|
|
|
redirect_header('index.php'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
$intr = $miscHandler->getObjects2(new \Criteria('misc_category', 'sticky')); |
|
30
|
|
|
if ($intr) { |
|
31
|
|
|
$sticky = $intr[0]; |
|
32
|
|
|
unset($intr); |
|
33
|
|
|
} else { |
|
34
|
|
|
$sticky = $miscHandler->create(); |
|
35
|
|
|
} |
|
36
|
|
|
switch ($op) { |
|
37
|
|
|
default: |
|
38
|
|
|
$setting = $sticky->getVar('misc_setting'); |
|
39
|
|
|
$title = new \XoopsFormText(_AM_RSSFIT_STICKY_TITLE, 'title', 50, 255, $sticky->getVar('misc_title', 'e')); |
|
40
|
|
|
$title->setDescription(_AM_RSSFIT_EDIT_INTRO_TITLE_DESC); |
|
41
|
|
|
|
|
42
|
|
|
$contentTray = new \XoopsFormElementTray(_AM_RSSFIT_STICKY_CONTENT, '<br>'); |
|
43
|
|
|
$contentTray->setDescription(_AM_RSSFIT_EDIT_INTRO_TEXT_DESC); |
|
44
|
|
|
$content = new \XoopsFormTextArea('', 'content', $sticky->getVar('misc_content', 'e'), 10); |
|
45
|
|
|
$contentTray->addElement($content); |
|
46
|
|
|
$dohtml = new \XoopsFormCheckBox('', 'dohtml', $setting['dohtml']); |
|
47
|
|
|
$dohtml->addOption('1', _AM_RSSFIT_DO_HTML); |
|
48
|
|
|
$contentTray->addElement($dohtml); |
|
49
|
|
|
$dobr = new \XoopsFormCheckBox('', 'dobr', $setting['dobr']); |
|
50
|
|
|
$dobr->addOption('1', _AM_RSSFIT_DO_BR); |
|
51
|
|
|
$contentTray->addElement($dobr); |
|
52
|
|
|
|
|
53
|
|
|
$link = new \XoopsFormText(_AM_RSSFIT_STICKY_LINK, 'link', 50, 255, htmlspecialchars($setting['link'] ?? '', ENT_QUOTES | ENT_HTML5)); |
|
54
|
|
|
|
|
55
|
|
|
$applyto = $feedHandler->feedSelectBox(_AM_RSSFIT_STICKY_APPLYTO, $setting['feeds'] ?? null, 10); |
|
56
|
|
|
|
|
57
|
|
|
$form = new \XoopsThemeForm(_AM_RSSFIT_STICKY_EDIT, 'editsticky', RSSFIT_ADMIN_URL); |
|
|
|
|
|
|
58
|
|
|
$form->addElement($title); |
|
59
|
|
|
$form->addElement($contentTray); |
|
60
|
|
|
$form->addElement($link); |
|
61
|
|
|
$form->addElement($applyto); |
|
62
|
|
|
$form->addElement($saveCancelTray); |
|
63
|
|
|
$form->addElement($hiddenDo); |
|
64
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
65
|
|
|
$form->display(); |
|
66
|
|
|
break; |
|
67
|
|
|
case 'save': |
|
68
|
|
|
$sticky->setVar('misc_category', 'sticky'); |
|
69
|
|
|
$sticky->setVar('misc_title', trim($_POST['title'])); |
|
70
|
|
|
$sticky->setVar('misc_content', $_POST['content']); |
|
71
|
|
|
if (!isset($_POST['feeds']) || count($_POST['feeds']) < 1 || in_array(0, $_POST['feeds'])) { |
|
72
|
|
|
$feeds = ['0' => 0]; |
|
73
|
|
|
} else { |
|
74
|
|
|
$feeds = $_POST['feeds']; |
|
75
|
|
|
} |
|
76
|
|
|
$setting = [ |
|
77
|
|
|
'dohtml' => isset($_POST['dohtml']) ? 1 : 0, |
|
78
|
|
|
'dobr' => isset($_POST['dobr']) ? 1 : 0, |
|
79
|
|
|
'feeds' => $feeds, |
|
80
|
|
|
'link' => isset($_POST['link']) ? trim($_POST['link']) : '', |
|
81
|
|
|
]; |
|
82
|
|
|
$sticky->setVar('misc_setting', $setting, true); |
|
83
|
|
|
if (false !== $miscHandler->insert($sticky)) { |
|
84
|
|
|
redirect_header(RSSFIT_ADMIN_URL . '?do=' . $do, 0, _AM_RSSFIT_DBUPDATED); |
|
85
|
|
|
} else { |
|
86
|
|
|
echo $sticky->getHtmlErrors(); |
|
87
|
|
|
} |
|
88
|
|
|
break; |
|
89
|
|
|
} |
|
90
|
|
|
|