📄 main.php
字号:
<?php
// $Id: main.php 694 2006-09-04 11:33:22Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu) //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
exit("Access Denied");
} else {
$op = 'list';
if (isset($_POST)) {
foreach ( $_POST as $k => $v ) {
${$k} = $v;
}
}
if (isset($_GET['op'])) {
$op = trim($_GET['op']);
}
if (isset($_GET['confcat_id'])) {
$confcat_id = intval($_GET['confcat_id']);
}
if ($op == 'list') {
$confcat_handler =& xoops_gethandler('configcategory');
$confcats = $confcat_handler->getObjects();
$catcount = count($confcats);
xoops_cp_header();
echo '<h4 style="text-align:left">'._MD_AM_SITEPREF.'</h4><ul>';
for ($i = 0; $i < $catcount; $i++) {
echo '<li>'.constant($confcats[$i]->getVar('confcat_name')).' [<a href="admin.php?fct=preferences&op=show&confcat_id='.$confcats[$i]->getVar('confcat_id').'">'._EDIT.'</a>]</li>';
}
echo '</ul>';
xoops_cp_footer();
exit();
}
if ($op == 'show') {
if (empty($confcat_id)) {
$confcat_id = 1;
}
$confcat_handler =& xoops_gethandler('configcategory');
$confcat =& $confcat_handler->get($confcat_id);
if (!is_object($confcat)) {
redirect_header('admin.php?fct=preferences', 1);
}
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
$form = new XoopsThemeForm(constant($confcat->getVar('confcat_name')), 'pref_form', 'admin.php?fct=preferences', 'post', true);
$config_handler =& xoops_gethandler('config');
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('conf_modid', 0));
$criteria->add(new Criteria('conf_catid', $confcat_id));
$config =& $config_handler->getConfigs($criteria);
$confcount = count($config);
for ($i = 0; $i < $confcount; $i++) {
$title = (!defined($config[$i]->getVar('conf_desc')) || constant($config[$i]->getVar('conf_desc')) == '') ? constant($config[$i]->getVar('conf_title')) : constant($config[$i]->getVar('conf_title')).'<br /><br /><span style="font-weight:normal;">'.constant($config[$i]->getVar('conf_desc')).'</span>';
switch ($config[$i]->getVar('conf_formtype')) {
case 'textarea':
$myts =& MyTextSanitizer::getInstance();
if ($config[$i]->getVar('conf_valuetype') == 'array') {
// this is exceptional.. only when value type is arrayneed a smarter way for this
$ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50);
} else {
$ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50);
}
break;
case 'select':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
$opcount = count($options);
for ($j = 0; $j < $opcount; $j++) {
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
$ele->addOption($optval, $optkey);
}
break;
case 'select_multi':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
$options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
$opcount = count($options);
for ($j = 0; $j < $opcount; $j++) {
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
$ele->addOption($optval, $optkey);
}
break;
case 'yesno':
$ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
break;
case 'theme':
case 'theme_multi':
$ele = ($config[$i]->getVar('conf_formtype') != 'theme_multi') ? new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()) : new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
require_once XOOPS_ROOT_PATH."/class/xoopslists.php";
$dirlist = XoopsLists::getThemesList();
if (!empty($dirlist)) {
asort($dirlist);
$ele->addOptionArray($dirlist);
}
//$themeset_handler =& xoops_gethandler('themeset');
//$themesetlist =& $themeset_handler->getList();
//asort($themesetlist);
//foreach ($themesetlist as $key => $name) {
// $ele->addOption($key, $name.' ('._MD_AM_THEMESET.')');
//}
// old theme value is used to determine whether to update cache or not. kind of dirty way
$form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
break;
case 'tplset':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$tplset_handler =& xoops_gethandler('tplset');
$tplsetlist =& $tplset_handler->getList();
asort($tplsetlist);
foreach ($tplsetlist as $key => $name) {
$ele->addOption($key, $name);
}
// old theme value is used to determine whether to update cache or not. kind of dirty way
$form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
break;
case 'timezone':
$ele = new XoopsFormSelectTimezone($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
break;
case 'language':
$ele = new XoopsFormSelectLang($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
break;
case 'startpage':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
$moduleslist =& $module_handler->getList($criteria, true);
$moduleslist['--'] = _MD_AM_NONE;
$ele->addOptionArray($moduleslist);
break;
case 'group':
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
break;
case 'group_multi':
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
break;
// RMV-NOTIFY - added 'user' and 'user_multi'
case 'user':
$ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false);
break;
case 'user_multi':
$ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
break;
case 'module_cache':
$module_handler =& xoops_gethandler('module');
$modules =& $module_handler->getObjects(new Criteria('hasmain', 1), true);
$currrent_val = $config[$i]->getConfValueForOutput();
$cache_options = array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK);
if (count($modules) > 0) {
$ele = new XoopsFormElementTray($title, '<br />');
foreach (array_keys($modules) as $mid) {
$c_val = isset($currrent_val[$mid]) ? intval($currrent_val[$mid]) : null;
$selform = new XoopsFormSelect($modules[$mid]->getVar('name'), $config[$i]->getVar('conf_name')."[$mid]", $c_val);
$selform->addOptionArray($cache_options);
$ele->addElement($selform);
unset($selform);
}
} else {
$ele = new XoopsFormLabel($title, _MD_AM_NOMODULE);
}
break;
case 'site_cache':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$ele->addOptionArray(array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK));
break;
case 'password':
$myts =& MyTextSanitizer::getInstance();
$ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
break;
case 'color':
$myts =& MyTextSanitizer::getInstance();
$ele = new XoopsFormColorPicker($title, $config[$i]->getVar('conf_name'), 9, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
break;
case 'hidden':
$myts =& MyTextSanitizer::getInstance();
$ele = new XoopsFormHidden( $config[$i]->getVar('conf_name'), $myts->htmlspecialchars( $config[$i]->getConfValueForOutput() ) );
break;
case 'textbox':
default:
$myts =& MyTextSanitizer::getInstance();
$ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput()));
break;
}
$hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id'));
$form->addElement($ele);
$form->addElement($hidden);
unset($ele);
unset($hidden);
}
$form->addElement(new XoopsFormHidden('op', 'save'));
$form->addElement(new XoopsFormButton('', 'button', _GO, 'submit'));
xoops_cp_header();
echo '<a href="admin.php?fct=preferences">'. _MD_AM_PREFMAIN .'</a> <span style="font-weight:bold;">»»</span> '.constant($confcat->getVar('confcat_name')).'<br /><br />';
$form->display();
xoops_cp_footer();
exit();
}
if ($op == 'showmod') {
$config_handler =& xoops_gethandler('config');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -