修改插件在首页的显示次序与颜色及風格加入排序功能
//------------------------------------------------------------------------------------------//
前台显示 就可自订显示次序位置
修改文件 ( 修改前请先备份以下档案 )
admin/styles.inc.php
admin/plugins.inc.php
include/cache.func.php
如修改上传后有问题 可即時將三份備份上傳恢復正常
修改上传后到后台更新缓存
//------------------------------------------------------------------------------------------//
演示:http://bbs.rosesky.name/
1、后台升级数据库
- ALTER TABLE `cdb_styles` ADD `orderid` MEDIUMINT( 8 ) DEFAULT '0' NOT NULL ;
- ALTER TABLE `cdb_plugins` ADD `orderid` MEDIUMINT( 8 ) DEFAULT '0' NOT NULL ;
- ALTER TABLE `cdb_plugins` ADD `pcolor` varchar(12) DEFAULT '';
复制代码
-----------------------------------------------------------------------------------------------------
2、admin/styles.inc.php
查找
- if($action == 'styles' && $export) {
- $query = $db->query("SELECT s.name, s.templateid, t.name AS tplname, t.directory, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid WHERE styleid='$export'");
复制代码
改为:
- if($action == 'styles' && $export) {
- $query = $db->query("SELECT s.name, s.templateid, s.orderid, t.name AS tplname, t.directory, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid WHERE styleid='$export' ORDER BY s.orderid ASC");
复制代码
-----------------------------------------------------------------------------------------------------
查找
- $styleselect = '';
- $query = $db->query("SELECT s.styleid, s.available, s.name, t.name AS tplname, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid");
- while($styleinfo = $db->fetch_array($query)) {
- $styleselect .= "<tr align="center"><td bgcolor="".ALTBG1.""><input type="checkbox" name="delete[]" value="$styleinfo[styleid]"></td>\n".
- "<td bgcolor="".ALTBG2.""><input type="text" name="namenew[$styleinfo[styleid]]"
复制代码 ---------------------------
查找
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%"
复制代码
改为
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%"
复制代码
查找
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%" align="center" class="tableborder">
- <tr class="header" align="center">
- <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form)"><?=$lang['del']?></td>
复制代码
改为
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
- <tr class="header" align="center">
- <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form)"><?=$lang['del']?></td>
- <td width="3%">排序<td>
复制代码
查找
- <tr align="center"><td bgcolor="<?=ALTBG1?>"><?=$lang['add_new']?></td>
复制代码
下面加入
- <td bgcolor="<?=ALTBG2?>"><input type='text' name="neworderid" size="2"></td>
复制代码
查找
- <td colspan="6" bgcolor="<?=ALTBG2?>"> </td>
复制代码
改为
- <td colspan="5" bgcolor="<?=ALTBG2?>"> </td>
复制代码
查找
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%"
复制代码
改为
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%"
复制代码
====================================================
再找
- if(is_array($namenew)) {
- foreach($namenew as $id => $val) {
- $db->query("UPDATE {$tablepre}styles SET name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
- }
- }
复制代码
改为:
- if(is_array($namenew)) {
- foreach($namenew as $id => $val) {
- $db->query("UPDATE {$tablepre}styles SET orderid='$orderidnew[$id]', name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
- }
- }
复制代码
===================================================
再找
- if($newname) {
- $db->query("INSERT INTO {$tablepre}styles (name, templateid) VALUES ('$newname', '1')");
- $styleidnew = $db->insert_id();
- foreach($predefinedvars as $variable) {
- $db->query("INSERT INTO {$tablepre}stylevars (styleid, variable)
- VALUES ('$styleidnew', '$variable')");
- }
- }
复制代码
改为:
- if($newname) {
- $db->query("INSERT INTO {$tablepre}styles (orderid, name, templateid) VALUES ('$neworderid', '$newname', '1')");
- $styleidnew = $db->insert_id();
- foreach($predefinedvars as $variable) {
- $db->query("INSERT INTO {$tablepre}stylevars (styleid, variable)
- VALUES ('$styleidnew', '$variable')");
- }
- }
- updatecache('styles');
- updatecache('settings');
复制代码
======================================================
注意:有以下两行的人,便不用再加入
updatecache('styles');
updatecache('settings');
======================================================
3、admin/plugins.inc.php 找
- if($action == 'plugins') {
- if(!$edit && !$identifier) {
- $plugins = '';
- $query = $db->query("SELECT p.*, pv.pluginvarid FROM {$tablepre}plugins p
- LEFT JOIN {$tablepre}pluginvars pv USING(pluginid)
- GROUP BY p.pluginid
- ORDER BY p.available DESC, p.pluginid");
复制代码
改为:
- if($action == 'plugins') {
- if(!$edit && !$identifier) {
- $plugins = '';
- $query = $db->query("SELECT p.*, pv.pluginvarid FROM {$tablepre}plugins p
- LEFT JOIN {$tablepre}pluginvars pv USING(pluginid)
- GROUP BY p.pluginid
- ORDER BY orderid ASC, p.pluginid");
复制代码
====================================================
再找
- } elseif($action == 'pluginsconfig') {
- if(!submitcheck('configsubmit') && !submitcheck('importsubmit')) {
- $plugins = '';
- $query = $db->query("SELECT * FROM {$tablepre}plugins");
- while($plugin = $db->fetch_array($query)) {
- $plugins .= "<tr align="center"><td bgcolor="".ALTBG1.""><input type="checkbox" name="delete[]" value="$plugin[pluginid]"></td>\n".
- "<td bgcolor="".ALTBG2.""><b>$plugin[name]</b></td>\n".
- "<td bgcolor="".ALTBG1."">$plugin[identifier]</td>\n".
- "<td bgcolor="".ALTBG2."">$plugin[description]</td>\n".
- "<td bgcolor="".ALTBG1."">$plugin[directory]</td>\n".
- "<td bgcolor="".ALTBG2.""><input type="checkbox" name="availablenew[$plugin[pluginid]]" value="1" ".(!$plugin['name'] || !$plugin['identifier'] ? 'disabled' : ($plugin['available'] ? 'checked' : ''))."></td>\n".
- "<td bgcolor="".ALTBG1.""><a href="admincp.php?action=pluginsconfig&export=$plugin[pluginid]">[$lang[download]]</a></td>\n".
- "<td bgcolor="".ALTBG2.""><a href="admincp.php?action=pluginsedit&pluginid=$plugin[pluginid]">[$lang[detail]]</a></td></tr>\n";
- }
- ?>
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="98%" align="center" class="tableborder">
- <tr class="header"><td><?=$lang['tips']?></td></tr>
- <tr bgcolor="<?=ALTBG1?>"><td>
- <br><?=$lang['plugins_config_tips']?>
- </td></tr></table><br><br>
- <form method="post" action="admincp.php?action=pluginsconfig">
- <input type="hidden" name="formhash" value="<?=FORMHASH?>">
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="98%" align="center" class="tableborder">
- <tr class="header" align="center">
- <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form, 'delete')"><?=$lang['del']?></td>
- <td width="15%"><?=$lang['plugins_name']?></td>
- <td width="10%"><?=$lang['plugins_identifier']?></td>
- <td width="31%"><?=$lang['description']?></td>
- <td width="15%"><?=$lang['plugins_directory']?></td>
- <td width="8%"><?=$lang['available']?></td>
- <td width="8%"><?=$lang['export']?></td>
- <td width="8%"><?=$lang['edit']?></td></tr>
- <?=$plugins?>
- <tr><td colspan="7" class="singleborder"> </td></tr>
- <tr align="center" class="altbg1"><td><?=$lang['add_new']?></td>
- <td><input type='text' name="newname" size="12"></td>
- <td><input type='text' name="newidentifier" size="8"></td>
- <td colspan="6"> </td>
- </tr></table><br>
- <center><input type="submit" name="configsubmit" value="<?=$lang['submit']?>"></center></form>
- <br><form method="post" action="admincp.php?action=pluginsconfig">
- <input type="hidden" name="formhash" value="<?=FORMHASH?>">
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="98%" align="center" class="tableborder">
- <tr class="header"><td><?=$lang['plugins_import']?></td></tr>
- <tr><td bgcolor="<?=ALTBG1?>" align="center"><textarea name="plugindata" cols="80" rows="8"></textarea><br>
- <input type="checkbox" name="ignoreversion" value="1"> <?=$lang['plugins_import_ignore_version']?></td></tr>
- </table><br><center><input type="submit" name="importsubmit" value="<?=$lang['submit']?>"></center></form>
复制代码
改为:
- } elseif($action == 'pluginsconfig') {
- if(!submitcheck('configsubmit') && !submitcheck('importsubmit')) {
- $plugins = '';
- $query = $db->query("SELECT * FROM {$tablepre}plugins ORDER BY orderid ASC");
- while($plugin = $db->fetch_array($query)) {
- $plugins .= "<tr align="center"><td bgcolor="".ALTBG2.""><input type="checkbox" name="delete[]" value="$plugin[pluginid]"></td>\n".
- "<td bgcolor="".ALTBG1.""><input type="text" size="2" name="orderidnew[$plugin[pluginid]]" value="$plugin[orderid]">\n".
- "<td bgcolor="".ALTBG2.""><b>$plugin[name]</b></td>\n".
- "<td bgcolor="".ALTBG1."">$plugin[identifier]</td>\n".
- "<td bgcolor="".ALTBG2."">$plugin[description]</td>\n".
- "<td bgcolor="".ALTBG1."">$plugin[directory]</td>\n".
- "<td bgcolor="".ALTBG2.""><input size=8 type="text" value="$plugin[pcolor]" name="pcolornew[$plugin[pluginid]]" onchange="this.style.color=this.value" style='color: $plugin[pcolor]'></td>\n".
- "<td bgcolor="".ALTBG2.""><input type="checkbox" name="availablenew[$plugin[pluginid]]" value="1" ".(!$plugin['name'] || !$plugin['identifier'] ? 'disabled' : ($plugin['available'] ? 'checked' : ''))."></td>\n".
- "<td bgcolor="".ALTBG1.""><a href="admincp.php?action=pluginsconfig&export=$plugin[pluginid]">[$lang[download]]</a></td>\n".
- "<td bgcolor="".ALTBG2.""><a href="admincp.php?action=pluginsedit&pluginid=$plugin[pluginid]">[$lang[detail]]</a></td></tr>\n";
- }
- ?>
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
- <tr class="header"><td><?=$lang['tips']?></td></tr>
- <tr bgcolor="<?=ALTBG1?>"><td>
- <?=$lang['plugins_config_tips']?>
- </td></tr></table>
- <form method="post" action="admincp.php?action=pluginsconfig">
- <input type="hidden" name="formhash" value="<?=FORMHASH?>">
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
- <tr class="header" align="center">
- <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form, 'delete')"><?=$lang['del']?></td>
- <---百分数可自行调整--->
- <td width="3%">排序</td>
- <td width="15%"><?=$lang['plugins_name']?></td>
- <td width="15%"><?=$lang['plugins_identifier']?></td>
- <td width="20%"><?=$lang['description']?></td>
- <td width="20%"><?=$lang['plugins_directory']?></td>
- <td width="10%">颜色</td>
- <td width="6%"><?=$lang['available']?></td>
- <td width="7%"><?=$lang['export']?></td>
- <td width="7%"><?=$lang['edit']?></td></tr>
- <---百分数可自行调整--->
- <?=$plugins?>
- <tr><td colspan="9" class="singleborder"> </td></tr>
- <tr align="center" class="altbg1"><td><?=$lang['add_new']?></td>
- <td><input type='text' name="neworderid" size="2"></td>
- <td><input type='text' name="newname" size="12"></td>
- <td><input type='text' name="newidentifier" size="8"></td>
- <td colspan="6"> </td>
- </tr></table><br>
- <center><input type="submit" name="configsubmit" value="<?=$lang['submit']?>"></center></form>
- <form method="post" action="admincp.php?action=pluginsconfig">
- <input type="hidden" name="formhash" value="<?=FORMHASH?>">
- <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
- <tr class="header"><td><?=$lang['plugins_import']?></td></tr>
- <tr><td bgcolor="<?=ALTBG1?>" align="center"><textarea name="plugindata" rows="8" style="width:90%"></textarea><br>
- <input type="checkbox" name="ignoreversion" value="1" checked> <?=$lang['plugins_import_ignore_version']?></td></tr>
- </table><br><center><input type="submit" name="importsubmit" value="<?=$lang['submit']?>"></center></form>
复制代码
=======================================================
查找:
- $db->query("UPDATE {$tablepre}plugins SET available='$available' WHERE pluginid='$id'");
- }
- }
复制代码
改为
- $db->query("UPDATE {$tablepre}plugins SET available='$available', pcolor='$pcolornew[$id]' WHERE pluginid='$id'");
- if(is_array($orderidnew)) {
- foreach($orderidnew as $ids => $orderid) {
- $db->query("UPDATE {$tablepre}plugins SET orderid='$orderid' WHERE pluginid='$ids'");
- }
- }
复制代码
=====================================================
查找:
- $db->query("INSERT INTO {$tablepre}plugins (name, identifier, available) VALUES ('".dhtmlspecialchars(trim($newname))."', '$newidentifier', '0')");
- }
复制代码
改为:
- $db->query("INSERT INTO {$tablepre}plugins (orderid, name, identifier, available) VALUES ('$neworderid', '".dhtmlspecialchars(trim($newname))."', '$newidentifier', '0')");
- }
复制代码
=====================================================4、include/cache.func.php
查找:
- $query = $db->query("SELECT s.*, t.directory AS tpldir FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON s.templateid=t.templateid");
复制代码
改为:
- $query = $db->query("SELECT s.*, t.directory AS tpldir FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON s.templateid=t.templateid ORDER BY s.orderid ASC");
复制代码
====================================================
查找:
- $query = $db->query("SELECT pluginid, available, adminid, name, identifier, datatables, directory, copyright, modules FROM {$tablepre}plugins");
复制代码
改为:
- $query = $db->query("SELECT pluginid, available, adminid, name, identifier, datatables, directory, copyright, modules, orderid FROM {$tablepre}plugins ORDER BY orderid ASC");
复制代码
=======================================================
查找:
- $query = $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'");
复制代码
改为:
- $query = $db->query("SELECT styleid, name, orderid FROM {$tablepre}styles WHERE available='1' ORDER BY orderid ASC");
复制代码
===========================================================
查找:
- $query = $db->query("SELECT available, name, identifier, directory, datatables, modules FROM {$tablepre}plugins");
复制代码
改为:
- $query = $db->query("SELECT available, name, identifier, directory, datatables, modules, orderid, pcolor FROM {$tablepre}plugins ORDER BY orderid ASC");
复制代码
===========================================================
查找:
- case 1:
- $data['plugins']['links'][$plugin['identifier']][$module['name']] = array('adminid' => $module['adminid'], 'url' => "<a href="$module[url]">$module[menu]</a>");
- break;
- case 2:
- $data['plugins']['links'][$plugin['identifier']][$module['name']] = array('adminid' => $module['adminid'], 'url' => "<a href="plugin.php?identifier=$plugin[identifier]&module=$module[name]">$module[menu]</a>", 'directory' => $plugin['directory']);
- break;
复制代码
改为:
- case 1:
- $plugin['url'] = $plugin['pcolor'] ? "<a href="$module[url]"><font color=".$plugin['pcolor'].">$module[menu]</font></a>" : "<a href="$module[url]">$module[menu]</a>";
- $data['plugins']['links'][$plugin['identifier']][$module['name']] = array('adminid' => $module['adminid'], 'url' => $plugin['url']);
- break;
- case 2:
- $plugin['url'] = $plugin['pcolor'] ? "<a href="plugin.php?identifier=$plugin[identifier]&module=$module[name]"><font color=".$plugin['pcolor'].">$module[menu]</font></a>" : "<a href="plugin.php?identifier=$plugin[identifier]&module=$module[name]">$module[menu]</a>";
复制代码
=====================================================================
完工..上传后到后台更新缓存!
[ 本帖最后由 e_zailai 于 2006-5-9 00:42 编辑 ] |