📄 main.php
字号:
}
}
}
echo '</table>';
if ($tplset != 'default') {
echo '<div style="text-align: right; margin-top: 5px;"><input type="hidden" name="fct" value="tplsets" /><input type="hidden" name="op" value="update" /><input type="hidden" name="moddir" value="'.$moddir.'" /><input type="hidden" name="tplset" value="'.$tplset.'" /><input type="submit" value="'._MD_UPLOAD.'" /></div></form>';
//echo '<table class="outer" width="70%"><tr><td style="width: 30px; background-color:#ff9999;"> </td><td>'._MD_FILENEWER.'</td></tr><tr><td style="width: 30px; background-color:#99ff99;"> </td><td>'._MD_FILEIMPORT.'</td></tr><tr><td style="width: 30px; background-color:#ffff99;"> </td><td>'._MD_FILEGENER.'</td></tr></table>';
}
xoops_cp_footer();
break;
case 'edittpl':
if ($id <= 0) {
redirect_header('admin.php?fct=tplsets', 1);
}
$tpltpl_handler =& xoops_gethandler('tplfile');
$tplfile =& $tpltpl_handler->get($id, true);
if (is_object($tplfile)) {
$tplset = $tplfile->getVar('tpl_tplset');
$tform = array('tpl_tplset' => $tplset, 'tpl_id' => $id, 'tpl_file' => $tplfile->getVar('tpl_file'), 'tpl_desc' => $tplfile->getVar('tpl_desc'), 'tpl_lastmodified' => $tplfile->getVar('tpl_lastmodified'), 'tpl_source' => $tplfile->getVar('tpl_source', 'E'), 'tpl_module' => $tplfile->getVar('tpl_module'));
include_once XOOPS_ROOT_PATH.'/modules/system/admin/tplsets/tplform.php';
xoops_cp_header();
echo '<a href="admin.php?fct=tplsets">'. _MD_TPLMAIN .'</a> <span style="font-weight:bold;">»»</span> <a href="./admin.php?fct=tplsets&op=listtpl&moddir='.$tplfile->getVar('tpl_module').'&tplset='.$tplset.'">'.$tplset.'</a> <span style="font-weight:bold;">»»</span> '._MD_EDITTEMPLATE.'<br /><br />';
$form->display();
xoops_cp_footer();
exit();
} else {
$err[] = '所选模板 (ID: $id) 不存在';
}
xoops_cp_header();
xoops_error($err);
echo '<br /><a href="admin.php?fct=tplsets">'._MD_AM_BTOTADMIN.'</a>';
xoops_cp_footer();
break;
case 'edittpl_go':
if ($id <= 0) {
redirect_header('admin.php?fct=tplsets', 1);
}
$tpltpl_handler =& xoops_gethandler('tplfile');
$tplfile =& $tpltpl_handler->get($id, true);
$err = array();
if (!is_object($tplfile)) {
$err[] = '所选模板 (ID: $id) 不存在';
} else {
if ($tplfile->getVar('tpl_tplset') != 'default') {
$tplfile->setVar('tpl_source', $html);
$tplfile->setVar('tpl_lastmodified', time());
if (!$tpltpl_handler->insert($tplfile)) {
$err[] = '无法将模板文件插入到数据库.';
} else {
include_once XOOPS_ROOT_PATH.'/class/template.php';
$xoopsTpl = new XoopsTpl();
if ($xoopsTpl->is_cached('db:'.$tplfile->getVar('tpl_file'))) {
if (!$xoopsTpl->clear_cache('db:'.$tplfile->getVar('tpl_file'))) {
}
}
if ($tplfile->getVar('tpl_tplset') == $xoopsConfig['template_set']) {
xoops_template_touch($id);
}
}
} else {
$err[] = '默认模板不能修改.';
}
}
if (count($err) == 0) {
if (!empty($moddir)) {
redirect_header('admin.php?fct=tplsets&op=edittpl&id='.$tplfile->getVar('tpl_id'), 2, _MD_AM_DBUPDATED);
} elseif (isset($redirect)) {
redirect_header('admin.php?fct=tplsets&tplset='.$tplfile->getVar('tpl_tplset').'&op='.trim($redirect), 2, _MD_AM_DBUPDATED);
} else {
redirect_header('admin.php?fct=tplsets', 2, _MD_AM_DBUPDATED);
}
}
xoops_cp_header();
xoops_error($err);
echo '<br /><a href="admin.php?fct=tplsets">'._MD_AM_BTOTADMIN.'</a>';
xoops_cp_footer();
break;
case 'deletetpl':
xoops_cp_header();
xoops_confirm(array('id' => $id, 'op' => 'deletetpl_go', 'fct' => 'tplsets'), 'admin.php', _MD_RUSUREDELTPL, _YES);
xoops_cp_footer();
break;
case 'deletetpl_go':
if ($id <= 0) {
redirect_header('admin.php?fct=tplsets', 1);
}
$tpltpl_handler =& xoops_gethandler('tplfile');
$tplfile =& $tpltpl_handler->get($id);
$err = array();
if (!is_object($tplfile)) {
$err[] = '所选模板 (ID: $id) 不存在';
} else {
if ($tplfile->getVar('tpl_tplset') != 'default') {
if (!$tpltpl_handler->delete($tplfile)) {
$err[] = 'Could not delete '.$tplfile->getVar('tpl_file').' from the database.';
} else {
// need to compile default xoops template
if ($tplfile->getVar('tpl_tplset') == $xoopsConfig['template_set']) {
$defaulttpl =& $tpltpl_handler->find('default', $tplfile->getVar('tpl_type'), $tplfile->getVar('tpl_refid'), null, $tplfile->getVar('tpl_file'));
if (count($defaulttpl) > 0) {
include_once XOOPS_ROOT_PATH.'/class/template.php';
xoops_template_touch($defaulttpl[0]->getVar('tpl_id'), true);
}
}
}
} else {
$err[] = '默认模板不可修改.';
}
}
if (count($err) == 0) {
redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$tplfile->getVar('tpl_module').'&tplset='.urlencode($tplfile->getVar('tpl_tplset')), 2, _MD_AM_DBUPDATED);
}
xoops_cp_header();
xoops_error($err);
echo '<br /><a href="admin.php?fct=tplsets">'._MD_AM_BTOTADMIN.'</a>';
xoops_cp_footer();
break;
case 'delete':
xoops_cp_header();
xoops_confirm(array('tplset' => $tplset, 'op' => 'delete_go', 'fct' => 'tplsets'), 'admin.php', _MD_RUSUREDELTH, _YES);
xoops_cp_footer();
break;
case 'delete_go':
$msgs = array();
if ($tplset != 'default' && $tplset != $xoopsConfig['template_set']) {
$tpltpl_handler =& xoops_gethandler('tplfile');
$templates =& $tpltpl_handler->getObjects(new Criteria('tpl_tplset', $tplset));
$tcount = count($templates);
if ($tcount > 0) {
$msgs[] = '正在删除模板文件...';
for ($i = 0; $i < $tcount; $i++) {
if (!$tpltpl_handler->delete($templates[$i])) {
$msgs[] = ' <span style="color:#ff0000;">错误: 无法删除模板 <b>'.$templates[$i]->getVar('tpl_file').'</b>. ID: <b>'.$templates[$i]->getVar('tpl_id').'</b></span>';
} else {
$msgs[] = ' 模板 <b>'.$templates[$i]->getVar('tpl_file').'</b> 删除完毕. ID: <b>'.$templates[$i]->getVar('tpl_id').'</b>';
}
}
}
/*
$image_handler =& xoops_gethandler('imagesetimg');
$imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $tplset));
$icount = count($imagefiles);
if ($icount > 0) {
$msgs[] = 'Deleting image files...';
for ($i = 0; $i < $icount; $i++) {
if (!$image_handler->delete($imagefiles[$i])) {
$msgs[] = ' <span style="color:#ff0000;">错误: Could not remove file <b>'.$imagefiles[$i]->getVar('imgsetimg_file').'</b> from the database (ID: <b>'.$imagefiles[$i]->getVar('imgsetimg_id').'</b>)</span>';
} else {
$msgs[] = ' File <b>'.$imagefiles[$i]->getVar('imgsetimg_file').'</b> deleted from the database (ID: <b>'.$imagefiles[$i]->getVar('imgsetimg_id').'</b>)</span>';
}
}
}
$imageset_handler =& xoops_gethandler('imageset');
$imagesets =& $imageset_handler->getObjects(new Criteria('tplset_name', $tplset));
$scount = count($imagesets);
if ($scount > 0) {
$msgs[] = '删除图片集数据...';
for ($i = 0; $i < $scount; $i++) {
if (!$imageset_handler->unlinktplset($imagesets[$i]->getVar('imgset_id'), $tplset)) {
$msgs[] = ' <span style="color:#ff0000;">错误: 无法删除数据库中 <b>'.$imagesets[$i]->getVar('imgset_name').'</b> (ID: <b>'.$imagesets[$i]->getVar('imgset_id').'</b>) 和 '.$tplset.' 之间的对应连接.</span>';
} else {
$msgs[] = ' Link between <b>'.$imagesets[$i]->getVar('imgset_name').'</b> (ID: <b>'.$imagesets[$i]->getVar('imgset_id').'</b>) and <b>'.$tplset.'</b> removed from the database.</span>';
}
if (!$imageset_handler->delete($imagesets[$i])) {
$msgs[] = ' <span style="color:#ff0000;">错误: 无法从数据库中删除 图片集 <b>'.$imagesets[$i]->getVar('imgset_name').'</b> (ID: <b>'.$imagesets[$i]->getVar('imgset_id').'</b>).</span>';
} else {
$msgs[] = ' 图片集<b>'.$imagesets[$i]->getVar('imgset_name').'</b> (ID: <b>'.$imagesets[$i]->getVar('imgset_id').'</b>) 已从数据库中删除.</span>';
}
}
}
*/
$tplset_handler =& xoops_gethandler('tplset');
$tplsets =& $tplset_handler->getObjects(new Criteria('tplset_name', $tplset));
if (count($tplsets) > 0 && is_object($tplsets[0])) {
$msgs[] = '正在删除模板数据...';
if (!$tplset_handler->delete($tplsets[0])) {
$msgs[] = ' <span style="color:#ff0000;">错误: 模板'.$tplset.'无法删除.</span>';
} else {
$msgs[] = ' 模板数据已从数据库中删除.';
}
}
} else {
$msgs[] = '<span style="color:#ff0000;">错误: 默认模板不能删除</span>';
}
xoops_cp_header();
foreach ($msgs as $msg) {
echo '<code>'.$msg.'</code><br />';
}
echo '<br /><a href="admin.php?fct=tplsets">'._MD_AM_BTOTADMIN.'</a>';
xoops_cp_footer();
break;
case 'clone':
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
$form = new XoopsThemeForm(_MD_CLONETHEME, 'template_form', 'admin.php');
$form->addElement(new XoopsFormLabel(_MD_THEMENAME, $tplset));
$form->addElement(new XoopsFormText(_MD_NEWNAME, 'newtheme', 30, 50), true);
$form->addElement(new XoopsFormHidden('tplset', $tplset));
$form->addElement(new XoopsFormHidden('op', 'clone_go'));
$form->addElement(new XoopsFormHidden('fct', 'tplsets'));
$form->addElement(new XoopsFormButton('', 'tpl_button', _SUBMIT, 'submit'));
xoops_cp_header();
echo '<a href="admin.php?fct=tplsets">'. _MD_TPLMAIN .'</a> <span style="font-weight:bold;">»»</span> '._MD_CLONETHEME.'<br /><br />';
$form->display();
xoops_cp_footer();
break;
case 'clone_go':
$msgs = array();
$tplset = trim($tplset);
$newtheme = trim($newtheme);
$tpltpl_handler =& xoops_gethandler('tplfile');
xoops_cp_header();
if ($tplset == $newtheme) {
xoops_error('模板必须重新命名.');
} elseif ($tpltpl_handler->getCount(new Criteria('tpl_tplset', $newtheme)) > 0) {
xoops_error('模板<b>'.$newtheme.'</b>已存在.');
} else {
$tplset_handler =& xoops_gethandler('tplset');
$tplsetobj =& $tplset_handler->create();
$tplsetobj->setVar('tplset_name', $newtheme);
$tplsetobj->setVar('tplset_created', time());
if (!$tplset_handler->insert($tplsetobj)) {
$msgs[] = '<span style="color:#ff0000;">错误: 无法创建模板<b>'.$newtheme.'</b>.</span><br />';
} else {
$tplsetid = $tplsetobj->getVar('tplset_id');
$templates =& $tpltpl_handler->getObjects(new Criteria('tpl_tplset', $tplset), true);
$tcount = count($templates);
if ($tcount > 0) {
$msgs[] = '正在复制模板文件...';
for ($i = 0; $i < $tcount; $i++) {
$newtpl =& $templates[$i]->xoopsClone();
$newtpl->setVar('tpl_tplset', $newtheme);
$newtpl->setVar('tpl_id', 0);
$newtpl->setVar('tpl_lastimported', 0);
$newtpl->setVar('tpl_lastmodified', time());
if (!$tpltpl_handler->insert($newtpl)) {
$msgs[] = ' <span style="color:#ff0000;">错误: 复制模板<b>'.$templates[$i]->getVar('tpl_file').'</b>失败. ID: <b>'.$templates[$i]->getVar('tpl_id').'</b></span>';
} else {
$msgs[] = ' 模板<b>'.$templates[$i]->getVar('tpl_file').'</b>复制完毕. ID: <b>'.$newtpl->getVar('tpl_id').'</b>';
}
unset($newtpl);
}
/*
$imageset_handler =& xoops_gethandler('imageset');
$orig_imgset =& $imageset_handler->getObjects(new Criteria('tplset_name', $tplset));
$msgs[] = '正在复制图形文件...';
$imgsetcount = count($orig_imgset);
for ($i = 0; $i < $imgsetcount; $i++) {
if ($orig_imgset[$i]->getVar('imgset_refid') == 0) {
$new_imgset =& $orig_imgset[$i]->xoopsClone();
$new_imgset->setVar('imgset_id', 0);
$new_imgset->setVar('imgset_name', $newtheme);
if (!$imageset_handler->insert($new_imgset)) {
$msgs[] = ' <span style="color:#ff0000;">错误: 拷贝模板图片集数据出错.</span>';
} else {
$new_imgsetid = $new_imgset->getVar('imgset_id');
$msgs[] = ' 模板图片集数据复制完毕. (Name: <b>'.$newtheme.'</b> ID: <b>'.$new_imgsetid.'</b>)</span>';
$image_handler = xoops_gethandler('imagesetimg');
$orig_images =& $image_handler->getByImageset($orig_imgset[$i]->getVar('imgset_id'));
$imgcount = count($orig_images);
for ($j = 0; $j < $imgcount; $j++) {
$new_image =& $orig_images[$j]->xoopsClone();
$new_image->setVar('imgsetimg_id', 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -