|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* About |
|
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
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright The XOOPS Co.Ltd. http://www.xoops.com.cn |
|
13
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
14
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
15
|
|
|
* @package about |
|
16
|
|
|
* @since 1.0.0 |
|
17
|
|
|
* @author Mengjue Shao <[email protected]> |
|
18
|
|
|
* @author Susheng Yang <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use Xmf\Request; |
|
22
|
|
|
use XoopsModules\About; |
|
23
|
|
|
use XoopsModules\About\Constants; |
|
24
|
|
|
use XoopsModules\About\Utility; |
|
25
|
|
|
use XoopsModules\About\PageHandler; |
|
26
|
|
|
/** @var Helper $helper */ |
|
27
|
|
|
/** @var PageHandler $pageHandler */ |
|
28
|
|
|
|
|
29
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
|
30
|
|
|
|
|
31
|
|
|
//require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
32
|
|
|
|
|
33
|
|
|
$pageType = isset($_REQUEST['type']) ? Request::getInt('type', 0) : $pageObj->getVar('page_type'); |
|
34
|
|
|
$format = empty($format) ? 'e' : $format; |
|
35
|
|
|
|
|
36
|
|
|
$menu_status = $pageObj->isNew() ? 1 : $pageObj->getVar('page_menu_status'); |
|
37
|
|
|
$list_status = $pageObj->isNew() ? 1 : $pageObj->getVar('page_status'); |
|
38
|
|
|
$page_blank = $pageObj->isNew() ? 0 : $pageObj->getVar('page_blank'); |
|
39
|
|
|
|
|
40
|
|
|
$title = $pageObj->isNew() ? _AM_ABOUT_PAGE_INSERT : _AM_ABOUT_EDIT; |
|
41
|
|
|
|
|
42
|
|
|
$form = new \XoopsThemeForm($title, 'form', 'admin.page.php', 'post', true); |
|
43
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
44
|
|
|
|
|
45
|
|
|
if (Constants::PAGE_TYPE_PAGE == $pageType) { |
|
46
|
|
|
$form->addElement(new \XoopsFormText(_AM_ABOUT_PAGE_TITLE, 'page_title', 60, 255, $pageObj->getVar('page_title', $format)), true); |
|
47
|
|
|
$menu = new \XoopsFormElementTray(_AM_ABOUT_PAGE_MENU_LIST); |
|
48
|
|
|
|
|
49
|
|
|
$menu->addElement(new \XoopsFormRadioYN('', 'page_menu_status', $menu_status)); |
|
50
|
|
|
$menu->addElement(new \XoopsFormText(_AM_ABOUT_PAGE_MENU_TITLE . ':', 'page_menu_title', 30, 255, $pageObj->getVar('page_menu_title', $format))); |
|
51
|
|
|
$menu->addElement(new \XoopsFormLabel('', _AM_ABOUT_PAGE_LINK_MENU)); |
|
52
|
|
|
$form->addElement($menu, true); |
|
53
|
|
|
|
|
54
|
|
|
$editorTray = new \XoopsFormElementTray(_AM_ABOUT_PAGE_TEXT, '<br>'); |
|
55
|
|
|
if (class_exists('XoopsFormEditor')) { |
|
56
|
|
|
$options['name'] = 'page_text'; |
|
57
|
|
|
$options['value'] = $pageObj->getVar('page_text'); |
|
58
|
|
|
$options['rows'] = 25; |
|
59
|
|
|
$options['cols'] = '100%'; |
|
60
|
|
|
$options['width'] = '100%'; |
|
61
|
|
|
$options['height'] = '400px'; |
|
62
|
|
|
$pageEditor = new \XoopsFormEditor('', $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); |
|
63
|
|
|
$editorTray->addElement($pageEditor); |
|
64
|
|
|
} else { |
|
65
|
|
|
$pageEditor = new \XoopsFormDhtmlTextArea('', 'page_text', $pageObj->getVar('page_text'), '100%', '100%'); |
|
|
|
|
|
|
66
|
|
|
$editorTray->addElement($pageEditor); |
|
67
|
|
|
} |
|
68
|
|
|
$form->addElement($editorTray); |
|
69
|
|
|
|
|
70
|
|
|
// Template set |
|
71
|
|
|
$templates = Utility::getTemplateList('page'); |
|
72
|
|
|
if ($templates && is_array($templates)) { |
|
|
|
|
|
|
73
|
|
|
$template_select = new \XoopsFormSelect(_AM_ABOUT_TEMPLATE_SELECT, 'page_tpl', $pageObj->getVar('page_tpl')); |
|
74
|
|
|
$template_select->addOptionArray($templates); |
|
75
|
|
|
$form->addElement($template_select); |
|
76
|
|
|
} |
|
77
|
|
|
} else { |
|
78
|
|
|
$form->addElement(new \XoopsFormText(_AM_ABOUT_PAGE_MENU_TITLE . ':', 'page_menu_title', 60, 255, $pageObj->getVar('page_menu_title', $format))); |
|
79
|
|
|
$form->addElement(new \XoopsFormHidden('page_menu_status', $menu_status)); |
|
80
|
|
|
$form->addElement(new \XoopsFormText(_AM_ABOUT_PAGE_LINK_TEXT, 'page_text', 60, 255, $pageObj->isNew() ? XOOPS_URL . $pageObj->getVar('page_text', $format) : $pageObj->getVar('page_text', $format)), true); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// Get list of possible parent pages |
|
84
|
|
|
$page_list = $pageHandler->getTrees(0, '--'); |
|
85
|
|
|
if (!$pageObj->isNew()) { |
|
86
|
|
|
$child_list = $pageHandler->getTrees($pageObj->getVar('page_id')); |
|
87
|
|
|
$page_list = array_diff_key($page_list, $child_list); // remove this class' children from 'parent' list |
|
88
|
|
|
unset($page_list[$pageObj->getVar('page_id')]); // remove this id from 'parent' list |
|
89
|
|
|
} |
|
90
|
|
|
$page_options = []; |
|
91
|
|
|
if ($page_list) { |
|
92
|
|
|
foreach ($page_list as $id => $page) { |
|
93
|
|
|
$page_options[$id] = $page['prefix'] . $page['page_menu_title']; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
$page_select = new \XoopsFormSelect(_AM_ABOUT_PAGE_HIGHER, 'page_pid', $pageObj->getVar('page_pid')); |
|
97
|
|
|
$page_select->addOption(0, _NONE); |
|
98
|
|
|
$page_select->addOptionArray($page_options); |
|
99
|
|
|
$form->addElement($page_select); |
|
100
|
|
|
|
|
101
|
|
|
$image_tray = new \XoopsFormElementTray(_AM_ABOUT_PAGE_IMAGE); |
|
102
|
|
|
$image_uploader = new \XoopsFormFile('', 'userfile', 500000); |
|
103
|
|
|
$image_tray->addElement($image_uploader); |
|
104
|
|
|
$pageImage = $pageObj->getVar('page_image'); |
|
105
|
|
|
if (!empty($pageImage) && file_exists(XOOPS_ROOT_PATH . '/uploads/' . $xoopsModule->dirname() . '/' . $pageImage)) { |
|
106
|
|
|
$image_tray->addElement(new \XoopsFormLabel('', '<div style="padding: 8px;"><img src="' . XOOPS_URL . '/uploads/' . $xoopsModule->dirname() . '/' . $pageImage . '"></div>')); |
|
107
|
|
|
$delete_check = new \XoopsFormCheckBox('', 'delete_image'); |
|
108
|
|
|
$delete_check->addOption(1, _DELETE); |
|
109
|
|
|
$image_tray->addElement($delete_check); |
|
110
|
|
|
} |
|
111
|
|
|
$form->addElement($image_tray); |
|
112
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_ABOUT_PAGE_LINK_BLANK, 'page_blank', $page_blank)); |
|
113
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_ABOUT_PAGE_STATUS, 'page_status', $list_status, $yes = _AM_ABOUT_PAGE_SUB, $no = _AM_ABOUT_PAGE_DRAFT)); |
|
114
|
|
|
|
|
115
|
|
|
$form->addElement(new \XoopsFormHidden('id', $pageObj->getVar('page_id'))); |
|
116
|
|
|
$form->addElement(new \XoopsFormHidden('page_type', $pageType)); |
|
117
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
118
|
|
|
//$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
119
|
|
|
$form->addElement(new \XoopsFormButtonTray('submit', _SUBMIT, 'submit')); |
|
120
|
|
|
|
|
121
|
|
|
return $form; |
|
122
|
|
|
|