📄 main.php
字号:
for ($j = 0; $j < $btcount; $j++) { $last_imported = $btemplates[$j]->getVar('tpl_lastimported'); $last_imported_f = ($last_imported > 0) ? formatTimestamp($last_imported, 'l') : ''; $last_modified = $btemplates[$j]->getVar('tpl_lastmodified'); if ($j % 2 == 0) { $class = 'even'; } else { $class = 'odd'; } echo '<tr class="'.$class.'"><td class="head"><span style="font-weight:bold;">'.$btemplates[$j]->getVar('tpl_file').'</span><br /><br /><span style="font-weight:normal;">'.$btemplates[$j]->getVar('tpl_desc').'</span></td><td>'.formatTimestamp($last_modified, 'l').'</td>'; $filename = $btemplates[$j]->getVar('tpl_file'); $physical_file = XOOPS_THEME_PATH.'/'.$tplset.'/templates/'.$moddir.'/blocks/'.$filename; if ($tplset != 'default') { if (file_exists($physical_file)) { $mtime = filemtime($physical_file); if ($last_imported < $mtime) { if ($mtime > $last_modified) { $bg = '#ff9999'; } elseif($mtime > $last_imported) { $bg = '#99ff99'; } echo '<td style="background-color:'.$bg.';">'.$last_imported_f.' [<a href="admin.php?fct=tplsets&tplset='.$tplset.'&op=importtpl&moddir='.$moddir.'&id='.$btemplates[$j]->getVar('tpl_id').'">'._MD_IMPORT.'</a>]'; } else { echo '<td>'.$last_imported_f; } } else { echo '<td>'.$last_imported_f; } echo '</td><td>[<a href="admin.php?fct=tplsets&op=edittpl&id='.$btemplates[$j]->getVar('tpl_id').'">'._EDIT.'</a>] [<a href="admin.php?fct=tplsets&op=deletetpl&id='.$btemplates[$j]->getVar('tpl_id').'">'._DELETE.'</a>] [<a href="admin.php?fct=tplsets&op=downloadtpl&id='.$btemplates[$j]->getVar('tpl_id').'">'._MD_DOWNLOAD.'</a>]</td><td align="right"><input type="file" name="'.$filename.'" id="'.$filename.'" /><input type="hidden" name="xoops_upload_file[]" id="xoops_upload_file[]" value="'.$filename.'" /><input type="hidden" name="old_template['.$filename.']" value="'.$btemplates[$j]->getVar('tpl_id').'" /></td>'; } else { echo '<td>[<a href="admin.php?fct=tplsets&op=edittpl&id='.$btemplates[$j]->getVar('tpl_id').'">'._MD_VIEW.'</a>] [<a href="admin.php?fct=tplsets&op=downloadtpl&id='.$btemplates[$j]->getVar('tpl_id').'">'._MD_DOWNLOAD.'</a>]</td>'; } echo '</tr>'."\n"; $binst_files[] = $filename; } if ($tplset != 'default') { include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; $bnotinst_files = array_diff(XoopsLists::getFileListAsArray(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/templates/blocks/'), $binst_files); foreach ($bnotinst_files as $nfile) { if ($nfile != 'index.html') { echo '<tr style="background-color:#FFFF99;"><td style="background-color:#FFFF99; padding: 5px;">'.$nfile.'</td><td style="background-color:#FFFF99; padding: 5px;"> </td><td style="background-color:#FFFF99; padding: 5px;">'; $physical_file = XOOPS_THEME_PATH.'/'.$tplset.'/templates/'.$moddir.'/blocks/'.$nfile; if (file_exists($physical_file)) { echo '[<a href="admin.php?fct=tplsets&moddir='.$moddir.'&tplset='.$tplset.'&op=importtpl&file='.urlencode($nfile).'">'._MD_IMPORT.'</a>]'; } else { echo ' '; } echo '</td><td style="background-color:#FFFF99; padding: 5px;">[<a href="admin.php?fct=tplsets&moddir='.$moddir.'&tplset='.$tplset.'&op=generatetpl&type=block&file='.urlencode($nfile).'">'._MD_GENERATE.'</a>]</td><td style="background-color:#FFFF99; padding: 5px; text-align: right"><input type="file" name="'.$nfile.'" id="'.$nfile.'" /><input type="hidden" name="xoops_upload_file[]" id="xoops_upload_file[]" value="'.$nfile.'" /></td></tr>'."\n"; } } } 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" />'.$GLOBALS['xoopsSecurity']->getTokenHTML().'<input type="hidden" name="moddir" value="'.$moddir.'" /><input type="hidden" name="tplset" value="'.$tplset.'" /><input type="submit" value="'._MD_UPLOAD.'" /></div></form>'; } 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[] = 'Selected template (ID: $id) does not exist'; } 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 | !$GLOBALS['xoopsSecurity']->check()) { redirect_header('admin.php?fct=tplsets', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id, true); $err = array(); if (!is_object($tplfile)) { $err[] = 'Selected template (ID: $id) does not exist'; } else { if ($tplfile->getVar('tpl_tplset') != 'default') { $tplfile->setVar('tpl_source', $html); $tplfile->setVar('tpl_lastmodified', time()); if (!$tpltpl_handler->insert($tplfile)) { $err[] = 'Could not insert template file to the database.'; } 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[] = 'Default template files cannot be edited.'; } } 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 | !$GLOBALS['xoopsSecurity']->check()) { redirect_header('admin.php?fct=tplsets', 1, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tplfile =& $tpltpl_handler->get($id); $err = array(); if (!is_object($tplfile)) { $err[] = 'Selected template (ID: $id) does not exist'; } 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[] = 'Default template files cannot be deleted.'; } } 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': if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('admin.php?fct=tplsets', 1, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); } $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[] = 'Deleting template files...'; for ($i = 0; $i < $tcount; $i++) { if (!$tpltpl_handler->delete($templates[$i])) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not delete template <b>'.$templates[$i]->getVar('tpl_file').'</b>. ID: <b>'.$templates[$i]->getVar('tpl_id').'</b></span>'; } else { $msgs[] = ' Template <b>'.$templates[$i]->getVar('tpl_file').'</b> deleted. 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;">ERROR: 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[] = 'Deleting image set data...'; for ($i = 0; $i < $scount; $i++) { if (!$imageset_handler->unlinktplset($imagesets[$i]->getVar('imgset_id'), $tplset)) { $msgs[] = ' <span style="color:#ff0000;">ERROR: Could not remove link between <b>'.$imagesets[$i]->getVar('imgset_name').'</b> (ID: <b>'.$imagesets[$i]->getVar('imgset_id').'</b>) and '.$tplset.' from the database.</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;">ERROR: Could not delete image set <b>'.$imagesets[$i]->getVar('imgset_name').'</b> (ID: <b>'.$imagesets[$i]->getVar('imgset_id').'</b>) from the database.</span>'; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -