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
|
|
|
FeedHandler, |
25
|
|
|
Utility |
26
|
|
|
}; |
27
|
|
|
|
28
|
|
|
/** @var FeedHandler $feedHandler */ |
29
|
|
|
|
30
|
|
|
if (!preg_match('#/rssfit/admin/#', $_SERVER['SCRIPT_NAME'])) { |
31
|
|
|
redirect_header('index.php'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
switch ($op) { |
35
|
|
|
default: |
36
|
|
|
$elements = $feedHandler->miscHandler->getObjects2(new \Criteria('misc_category', 'channel'), '*', 'title'); |
37
|
|
|
$img = $feedHandler->miscHandler->getObjects2(new \Criteria('misc_category', 'channelimg'), '*', 'title'); |
38
|
|
|
if (!empty($elements) && !empty($img)) { |
39
|
|
|
$form = new \XoopsThemeForm(_AM_RSSFIT_EDIT_CHANNEL, 'editchannel', RSSFIT_ADMIN_URL); |
|
|
|
|
40
|
|
|
$form->addElement(new \XoopsFormLabel('', '<b>' . _AM_RSSFIT_EDIT_CHANNEL_REQUIRED . '</b> ' . Utility::genSpecMoreInfo('req', $feedHandler))); |
41
|
|
|
$form->addElement(new \XoopsFormText('title', 'ele[' . $elements['title']->getVar('misc_id') . ']', 50, 255, $elements['title']->getVar('misc_content', 'e')), true); |
42
|
|
|
$form->addElement(new \XoopsFormText('link', 'ele[' . $elements['link']->getVar('misc_id') . ']', 50, 255, $elements['link']->getVar('misc_content', 'e')), true); |
43
|
|
|
$form->addElement(new \XoopsFormTextArea('description', 'ele[' . $elements['description']->getVar('misc_id') . ']', $elements['description']->getVar('misc_content', 'e')), true); |
44
|
|
|
|
45
|
|
|
$form->addElement(new \XoopsFormLabel('', '<b>' . _AM_RSSFIT_EDIT_CHANNEL_OPTIONAL . '</b> ' . Utility::genSpecMoreInfo('opt', $feedHandler))); |
46
|
|
|
$form->addElement(new \XoopsFormText('copyright', 'ele[' . $elements['copyright']->getVar('misc_id') . ']', 50, 255, $elements['copyright']->getVar('misc_content', 'e'))); |
47
|
|
|
$form->addElement(new \XoopsFormText('managingEditor', 'ele[' . $elements['managingEditor']->getVar('misc_id') . ']', 50, 255, $elements['managingEditor']->getVar('misc_content', 'e'))); |
48
|
|
|
$form->addElement(new \XoopsFormText('webMaster', 'ele[' . $elements['webMaster']->getVar('misc_id') . ']', 50, 255, $elements['webMaster']->getVar('misc_content', 'e'))); |
49
|
|
|
$form->addElement(new \XoopsFormText('category', 'ele[' . $elements['category']->getVar('misc_id') . ']', 50, 255, $elements['category']->getVar('misc_content', 'e'))); |
50
|
|
|
$form->addElement(new \XoopsFormText('generator', 'ele[' . $elements['generator']->getVar('misc_id') . ']', 50, 255, $elements['generator']->getVar('misc_content', 'e'))); |
51
|
|
|
$form->addElement(new \XoopsFormText('docs', 'ele[' . $elements['docs']->getVar('misc_id') . ']', 50, 255, $elements['docs']->getVar('misc_content', 'e'))); |
52
|
|
|
|
53
|
|
|
$form->addElement(new \XoopsFormLabel('', '<b>' . _AM_RSSFIT_EDIT_CHANNEL_IMAGE . '</b> ' . Utility::genSpecMoreInfo('img', $feedHandler))); |
54
|
|
|
$form->addElement(new \XoopsFormText('url', 'ele[' . $img['url']->getVar('misc_id') . ']', 50, 255, $img['url']->getVar('misc_content', 'e'))); |
55
|
|
|
$form->addElement(new \XoopsFormText('link', 'ele[' . $img['link']->getVar('misc_id') . ']', 50, 255, $img['link']->getVar('misc_content', 'e'))); |
56
|
|
|
$form->addElement(new \XoopsFormText('title', 'ele[' . $img['title']->getVar('misc_id') . ']', 50, 255, $img['title']->getVar('misc_content', 'e'))); |
57
|
|
|
|
58
|
|
|
$form->addElement($saveCancelTray); |
59
|
|
|
$form->addElement($hiddenDo); |
60
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
61
|
|
|
$form->display(); |
62
|
|
|
} else { |
63
|
|
|
echo '<p>' . _AM_RSSFIT_DB_RECORD_MISSING . '</p>'; |
64
|
|
|
} |
65
|
|
|
break; |
66
|
|
|
case 'save': |
67
|
|
|
$ele = Request::getArray('ele', null, 'POST'); |
68
|
|
|
$ids = array_keys($ele); |
69
|
|
|
$errors = []; |
70
|
|
|
foreach ($ids as $i) { |
71
|
|
|
$criteria = new \Criteria('misc_id', $i); |
72
|
|
|
$fields = ['misc_content' => trim($ele[$i])]; |
73
|
|
|
$err = $feedHandler->miscHandler->modifyObjects($criteria, $fields, false); |
74
|
|
|
if ($err) { |
75
|
|
|
$errors[] = $err; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
if (count($errors) > 0) { |
79
|
|
|
foreach ($errors as $e) { |
80
|
|
|
echo $e . "<br><br>\n"; |
81
|
|
|
} |
82
|
|
|
} else { |
83
|
|
|
redirect_header(RSSFIT_ADMIN_URL . '?do=' . $do, 0, _AM_RSSFIT_DBUPDATED); |
84
|
|
|
} |
85
|
|
|
break; |
86
|
|
|
} |
87
|
|
|
|