📄 main.php
字号:
}
$msgs .= '<br /><span style="font-size:smaller;">'.$mod->getVar('name').'</span><br /><br />'._MD_AM_RUSUREUNINS;
xoops_cp_header();
xoops_confirm(array('module' => $module, 'op' => 'uninstall_ok', 'fct' => 'modulesadmin'), 'admin.php', $msgs, _YES);
xoops_cp_footer();
exit();
}
if ($op == 'uninstall_ok') {
$ret = array();
$ret[] = xoops_module_uninstall($module);
$contents = xoops_module_get_admin_menu();
if (!xoops_module_write_admin_menu($contents)) {
$ret[] = "<p>"._MD_AM_FAILWRITE."</p>";
}
xoops_cp_header();
if (count($ret) > 0) {
foreach ($ret as $msg) {
if ($msg != '') {
echo $msg;
}
}
}
echo "<a href='admin.php?fct=modulesadmin'>"._MD_AM_BTOMADMIN."</a>";
xoops_cp_footer();
exit();
}
if ($op == 'update') {
$module_handler =& xoops_gethandler('module');
$mod =& $module_handler->getByDirname($module);
if ($mod->getInfo('image') != false && trim($mod->getInfo('image')) != '') {
$msgs ='<img src="'.XOOPS_URL.'/modules/'.$mod->getVar('dirname').'/'.trim($mod->getInfo('image')).'" alt="" />';
}
$msgs .= '<br /><span style="font-size:smaller;">'.$mod->getVar('name').'</span><br /><br />'._MD_AM_RUSUREUPD;
xoops_cp_header();
xoops_confirm(array('dirname' => $module, 'op' => 'update_ok', 'fct' => 'modulesadmin'), 'admin.php', $msgs, _MD_AM_UPDATE);
xoops_cp_footer();
exit();
}
if ($op == 'update_ok') {
$dirname = trim($dirname);
$module_handler =& xoops_gethandler('module');
$module =& $module_handler->getByDirname($dirname);
// Save current version for use in the update function
$prev_version = $module->getVar('version');
include_once XOOPS_ROOT_PATH.'/class/template.php';
xoops_template_clear_module_cache($module->getVar('mid'));
// we dont want to change the module name set by admin
$temp_name = $module->getVar('name');
$module->loadInfoAsVar($dirname);
$module->setVar('name', $temp_name);
xoops_cp_header();
if (!$module_handler->insert($module)) {
echo '<p>Could not update '.$module->getVar('name').'</p>';
echo "<br /><a href='admin.php?fct=modulesadmin'>"._MD_AM_BTOMADMIN."</a>";
} else {
$newmid = $module->getVar('mid');
$msgs = array();
$msgs[] = 'Module data updated.';
$tplfile_handler =& xoops_gethandler('tplfile');
$deltpl =& $tplfile_handler->find('default', 'module', $module->getVar('mid'));
$delng = array();
if (is_array($deltpl)) {
$xoopsTpl = new XoopsTpl();
// clear cache files
$xoopsTpl->clear_cache(null, 'mod_'.$dirname);
// delete template file entry in db
$dcount = count($deltpl);
for ($i = 0; $i < $dcount; $i++) {
if (!$tplfile_handler->delete($deltpl[$i])) {
$delng[] = $deltpl[$i]->getVar('tpl_file');
}
}
}
$templates = $module->getInfo('templates');
if ($templates != false) {
$msgs[] = 'Updating templates...';
foreach ($templates as $tpl) {
$tpl['file'] = trim($tpl['file']);
if (!in_array($tpl['file'], $delng)) {
$tpldata =& xoops_module_gettemplate($dirname, $tpl['file']);
$tplfile =& $tplfile_handler->create();
$tplfile->setVar('tpl_refid', $newmid);
$tplfile->setVar('tpl_lastimported', 0);
$tplfile->setVar('tpl_lastmodified', time());
if (preg_match("/\.css$/i", $tpl['file'])) {
$tplfile->setVar('tpl_type', 'css');
} else {
$tplfile->setVar('tpl_type', 'module');
}
$tplfile->setVar('tpl_source', $tpldata, true);
$tplfile->setVar('tpl_module', $dirname);
$tplfile->setVar('tpl_tplset', 'default');
$tplfile->setVar('tpl_file', $tpl['file'], true);
$tplfile->setVar('tpl_desc', $tpl['description'], true);
if (!$tplfile_handler->insert($tplfile)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not insert template <b>'.$tpl['file'].'</b> to the database.</span>';
} else {
$newid = $tplfile->getVar('tpl_id');
$msgs[] = ' Template <b>'.$tpl['file'].'</b> inserted to the database.';
if ($xoopsConfig['template_set'] == 'default') {
if (!xoops_template_touch($newid)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not recompile template <b>'.$tpl['file'].'</b>.</span>';
} else {
$msgs[] = ' <span>Template <b>'.$tpl['file'].'</b> recompiled.</span>';
}
}
}
unset($tpldata);
} else {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete old template <b>'.$tpl['file'].'</b>. Aborting update of this file.</span>';
}
}
}
$contents = xoops_module_get_admin_menu();
if (!xoops_module_write_admin_menu($contents)) {
$msgs[] = '<p><span style="color:#ff0000;">'._MD_AM_FAILWRITE.'</span></p>';
}
$blocks = $module->getInfo('blocks');
$msgs[] = 'Rebuilding blocks...';
if ($blocks != false) {
$showfuncs = array();
$funcfiles = array();
foreach ($blocks as $i => $block) {
if (isset($block['show_func']) && $block['show_func'] != '' && isset($block['file']) && $block['file'] != '') {
$editfunc = isset($block['edit_func']) ? $block['edit_func'] : '';
$showfuncs[] = $block['show_func'];
$funcfiles[] = $block['file'];
$template = '';
if ((isset($block['template']) && trim($block['template']) != '')) {
$content =& xoops_module_gettemplate($dirname, $block['template'], true);
}
if (!$content) {
$content = '';
} else {
$template = $block['template'];
}
$options = '';
if (!empty($block['options'])) {
$options = $block['options'];
}
$sql = "SELECT bid, name FROM ".$xoopsDB->prefix('newblocks')." WHERE mid=".$module->getVar('mid')." AND func_num=".$i." AND show_func='".addslashes($block['show_func'])."' AND func_file='".addslashes($block['file'])."'";
$fresult = $xoopsDB->query($sql);
$fcount = 0;
while ($fblock = $xoopsDB->fetchArray($fresult)) {
$fcount++;
$sql = "UPDATE ".$xoopsDB->prefix("newblocks")." SET name='".addslashes($block['name'])."', edit_func='".addslashes($editfunc)."', content='', template='".$template."', last_modified=".time()." WHERE bid=".$fblock['bid'];
$result = $xoopsDB->query($sql);
if (!$result) {
$msgs[] = ' ERROR: Could not update '.$fblock['name'];
} else {
$msgs[] = ' Block <b>'.$fblock['name'].'</b> updated. Block ID: <b>'.$fblock['bid'].'</b>';
if ($template != '') {
$tplfile =& $tplfile_handler->find('default', 'block', $fblock['bid']);
if (count($tplfile) == 0) {
$tplfile_new =& $tplfile_handler->create();
$tplfile_new->setVar('tpl_module', $dirname);
$tplfile_new->setVar('tpl_refid', $fblock['bid']);
$tplfile_new->setVar('tpl_tplset', 'default');
$tplfile_new->setVar('tpl_file', $block['template'], true);
$tplfile_new->setVar('tpl_type', 'block');
}
else {
$tplfile_new = $tplfile[0];
}
$tplfile_new->setVar('tpl_source', $content, true);
$tplfile_new->setVar('tpl_desc', $block['description'], true);
$tplfile_new->setVar('tpl_lastmodified', time());
$tplfile_new->setVar('tpl_lastimported', 0);
if (!$tplfile_handler->insert($tplfile_new)) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not update template <b>'.$block['template'].'</b>.</span>';
} else {
$msgs[] = ' Template <b>'.$block['template'].'</b> updated.';
if ($xoopsConfig['template_set'] == 'default') {
if (!xoops_template_touch($tplfile_new->getVar('tpl_id'))) {
$msgs[] = ' <span style="color:#ff0000;">ERROR: Could not recompile template <b>'.$block['template'].'</b>.</span>';
} else {
$msgs[] = ' Template <b>'.$block['template'].'</b> recompiled.';
}
}
}
}
}
}
if ($fcount == 0) {
$newbid = $xoopsDB->genId($xoopsDB->prefix('newblocks').'_bid_seq');
$block_name = addslashes($block['name']);
$sql = "INSERT INTO ".$xoopsDB->prefix("newblocks")." (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES (".$newbid.", ".$module->getVar('mid').", ".$i.",'".addslashes($options)."','".$block_name."', '".$block_name."', '', 0, 0, 0, 'M', 1, '".addslashes($dirname)."', '".addslashes($block['file'])."', '".addslashes($block['show_func'])."', '".addslashes($editfunc)."', '".$template."', ".time().")";
$result = $xoopsDB->query($sql);
if (!$result) {
$msgs[] = ' ERROR: Could not create '.$block['name'];echo $sql;
} else {
if (empty($newbid)) {
$newbid = $xoopsDB->getInsertId();
}
if ($module->getInfo('hasMain')) {
$groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
} else {
$groups = array(XOOPS_GROUP_ADMIN);
}
$gperm_handler =& xoops_gethandler('groupperm');
foreach ($groups as $mygroup) {
$bperm =& $gperm_handler->create();
$bperm->setVar('gperm_groupid', $mygroup);
$bperm->setVar('gperm_itemid', $newbid);
$bperm->setVar('gperm_name', 'block_read');
$bperm->setVar('gperm_modid', 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -