XoopsModules25x /
about
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 (http://xoops.org) |
||
| 14 | * @license GNU GPL 2 or later (http://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 | defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
||
| 22 | |||
| 23 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 24 | $abtHelper = Xmf\Module\Helper::getHelper($moduleDirName); |
||
| 25 | |||
| 26 | include_once __DIR__ . '/functions.render.php'; |
||
| 27 | //include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
|
0 ignored issues
–
show
|
|||
| 28 | $page_handler = $abtHelper->getHandler('page'); |
||
| 29 | |||
| 30 | $pageType = isset($_REQUEST['type']) ? Xmf\Request::getInt('type', 0) : $page_obj->getVar('page_type'); |
||
| 31 | $format = empty($format) ? 'e' : $format; |
||
| 32 | |||
| 33 | $menu_status = $page_obj->isNew() ? 1 : $page_obj->getVar('page_menu_status'); |
||
| 34 | $list_status = $page_obj->isNew() ? 1 : $page_obj->getVar('page_status'); |
||
| 35 | $page_blank = $page_obj->isNew() ? 0 : $page_obj->getVar('page_blank'); |
||
| 36 | $title = $page_obj->isNew() ? _AM_ABOUT_PAGE_INSERT : _AM_ABOUT_EDIT; |
||
| 37 | |||
| 38 | $form = new XoopsThemeForm($title, 'form', 'admin.page.php', 'post', true); |
||
| 39 | $form->setExtra("enctype=\"multipart/form-data\""); |
||
| 40 | |||
| 41 | if (AboutConstants::PAGE_TYPE_PAGE == $pageType) { |
||
| 42 | $form->addElement(new XoopsFormText(_AM_ABOUT_PAGE_TITLE, 'page_title', 60, 255, $page_obj->getVar('page_title', $format)), true); |
||
| 43 | |||
| 44 | $menu = new XoopsFormElementTray(_AM_ABOUT_PAGE_MENU_LIST); |
||
| 45 | $menu->addElement(new XoopsFormRadioYN('', 'page_menu_status', $menu_status)); |
||
| 46 | $menu->addElement(new XoopsFormText(_AM_ABOUT_PAGE_MENU_TITLE . ':', 'page_menu_title', 30, 255, $page_obj->getVar('page_menu_title', $format))); |
||
| 47 | $menu->addElement(new XoopsFormLabel('', _AM_ABOUT_PAGE_LINK_MENU)); |
||
| 48 | $form->addElement($menu, true); |
||
| 49 | |||
| 50 | $editorTray = new XoopsFormElementTray(_AM_ABOUT_PAGE_TEXT, '<br>'); |
||
| 51 | if (class_exists('XoopsFormEditor')) { |
||
| 52 | $options['name'] = 'page_text'; |
||
| 53 | $options['value'] = $page_obj->getVar('page_text'); |
||
| 54 | $options['rows'] = 25; |
||
| 55 | $options['cols'] = '100%'; |
||
| 56 | $options['width'] = '100%'; |
||
| 57 | $options['height'] = '400px'; |
||
| 58 | $pageEditor = new XoopsFormEditor('', $xoopsModuleConfig['editorAdmin'], $options, $nohtml = false, $onfailure = 'textarea'); |
||
| 59 | $editorTray->addElement($pageEditor); |
||
| 60 | } else { |
||
| 61 | $pageEditor = new XoopsFormDhtmlTextArea('', 'page_text', $page_obj->getVar('page_text'), '100%', '100%'); |
||
| 62 | $editorTray->addElement($pageEditor); |
||
| 63 | } |
||
| 64 | $form->addElement($editorTray); |
||
| 65 | |||
| 66 | // Template set |
||
| 67 | $templates = about_getTemplateList('page'); |
||
| 68 | if (count($templates) > 0) { |
||
| 69 | $template_select = new XoopsFormSelect(_AM_ABOUT_TEMPLATE_SELECT, 'page_tpl', $page_obj->getVar('page_tpl')); |
||
| 70 | $template_select->addOptionArray($templates); |
||
| 71 | $form->addElement($template_select); |
||
| 72 | } |
||
| 73 | } else { |
||
| 74 | $form->addElement(new XoopsFormText(_AM_ABOUT_PAGE_MENU_TITLE . ':', 'page_menu_title', 60, 255, $page_obj->getVar('page_menu_title', $format))); |
||
| 75 | $form->addElement(new XoopsFormHidden('page_menu_status', $menu_status)); |
||
| 76 | $form->addElement(new XoopsFormText(_AM_ABOUT_PAGE_LINK_TEXT, 'page_text', 60, 255, $page_obj->isNew() ? XOOPS_PROT . $page_obj->getVar('page_text', $format) : $page_obj->getVar('page_text', $format)), true); |
||
| 77 | } |
||
| 78 | |||
| 79 | // Get list of possible parent pages |
||
| 80 | $page_list = $page_handler->getTrees(0, '--'); |
||
| 81 | if (!$page_obj->isNew()) { |
||
| 82 | $child_list = $page_handler->getTrees($page_obj->getVar('page_id')); |
||
| 83 | $page_list = array_diff_key($page_list, $child_list); // remove this class' children from 'parent' list |
||
| 84 | unset($page_list[$page_obj->getVar('page_id')]); // remove this id from 'parent' list |
||
| 85 | } |
||
| 86 | $page_options = array(); |
||
| 87 | if ($page_list) { |
||
| 88 | foreach ($page_list as $id => $page) { |
||
| 89 | $page_options[$id] = $page['prefix'] . $page['page_menu_title']; |
||
| 90 | } |
||
| 91 | } |
||
| 92 | |||
| 93 | $page_select = new XoopsFormSelect(_AM_ABOUT_PAGE_HIGHER, 'page_pid', $page_obj->getVar('page_pid')); |
||
| 94 | $page_select->addOption(0, _NONE); |
||
| 95 | $page_select->addOptionArray($page_options); |
||
| 96 | $form->addElement($page_select); |
||
| 97 | |||
| 98 | $image_tray = new XoopsFormElementTray(_AM_ABOUT_PAGE_IMAGE); |
||
| 99 | $image_uploader = new XoopsFormFile('', 'userfile', 500000); |
||
| 100 | $image_tray->addElement($image_uploader); |
||
| 101 | $page_image = $page_obj->getVar('page_image'); |
||
| 102 | if (!empty($page_image) && file_exists(XOOPS_ROOT_PATH . '/uploads/' . $xoopsModule->dirname() . '/' . $page_image)) { |
||
| 103 | $image_tray->addElement(new XoopsFormLabel('', "<div style=\"padding: 8px;\"><img src=\"" . XOOPS_URL . '/uploads/' . $xoopsModule->dirname() . '/' . $page_image . "\"></div>")); |
||
| 104 | $delete_check = new XoopsFormCheckBox('', 'delete_image'); |
||
| 105 | $delete_check->addOption(1, _DELETE); |
||
| 106 | $image_tray->addElement($delete_check); |
||
| 107 | } |
||
| 108 | $form->addElement($image_tray); |
||
| 109 | |||
| 110 | $form->addElement(new XoopsFormRadioYN(_AM_ABOUT_PAGE_LINK_BLANK, 'page_blank', $page_blank)); |
||
| 111 | $form->addElement(new XoopsFormRadioYN(_AM_ABOUT_PAGE_STATUS, 'page_status', $list_status, $yes = _AM_ABOUT_PAGE_SUB, $no = _AM_ABOUT_PAGE_DRAFT)); |
||
| 112 | |||
| 113 | $form->addElement(new XoopsFormHidden('id', $page_obj->getVar('page_id'))); |
||
| 114 | $form->addElement(new XoopsFormHidden('page_type', $pageType)); |
||
| 115 | $form->addElement(new XoopsFormHidden('op', 'save')); |
||
| 116 | //$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 117 | $form->addElement(new XoopsFormButtonTray('submit', _SUBMIT, 'submit')); |
||
| 118 | |||
| 119 | |||
| 120 | return $form; |
||
| 121 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.