Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[发布] 修改插件在首页的显示次序与颜色及風格加入排序功能

[复制链接]
e_zailai 发表于 2006-4-13 13:54:49 | 显示全部楼层 |阅读模式
修改插件在首页的显示次序与颜色及風格加入排序功能

//------------------------------------------------------------------------------------------//

    前台显示 就可自订显示次序位置
   修改文件 ( 修改前请先备份以下档案 )
   admin/styles.inc.php
   admin/plugins.inc.php
   include/cache.func.php
    如修改上传后有问题 可即時將三份備份上傳恢復正常
修改上传后到后台更新缓存

//------------------------------------------------------------------------------------------//


演示:http://bbs.rosesky.name/


1、后台升级数据库


  1. ALTER TABLE `cdb_styles` ADD `orderid` MEDIUMINT( 8 ) DEFAULT '0' NOT NULL  ;
  2. ALTER TABLE `cdb_plugins` ADD `orderid` MEDIUMINT( 8 ) DEFAULT '0' NOT NULL  ;
  3. ALTER TABLE `cdb_plugins` ADD `pcolor` varchar(12) DEFAULT '';
复制代码

-----------------------------------------------------------------------------------------------------


2、admin/styles.inc.php

查找
  1. if($action == 'styles' && $export) {
  2.         $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'");
复制代码


改为:
  1. if($action == 'styles' && $export) {
  2.         $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");
复制代码


-----------------------------------------------------------------------------------------------------

查找
  1.                 $styleselect = '';
  2.                 $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");
  3.                 while($styleinfo = $db->fetch_array($query)) {
  4.                         $styleselect .= "<tr align="center"><td bgcolor="".ALTBG1.""><input type="checkbox" name="delete[]" value="$styleinfo[styleid]"></td>\n".
  5.                                 "<td bgcolor="".ALTBG2.""><input type="text" name="namenew[$styleinfo[styleid]]"
复制代码
---------------------------
查找
  1. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%"
复制代码


改为
  1. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%"
复制代码


查找
  1. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%" align="center" class="tableborder">
  2. <tr class="header" align="center">
  3. <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form)"><?=$lang['del']?></td>
复制代码

改为
  1. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
  2. <tr class="header" align="center">
  3. <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form)"><?=$lang['del']?></td>
  4. <td width="3%">排序<td>
复制代码


查找
  1. <tr align="center"><td bgcolor="<?=ALTBG1?>"><?=$lang['add_new']?></td>
复制代码


下面加入
  1. <td bgcolor="<?=ALTBG2?>"><input type='text' name="neworderid" size="2"></td>
复制代码


查找
  1. <td colspan="6" bgcolor="<?=ALTBG2?>"> </td>
复制代码


改为
  1. <td colspan="5" bgcolor="<?=ALTBG2?>"> </td>
复制代码


查找
  1. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%"
复制代码


改为
  1. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%"
复制代码


====================================================

再找


  1.               if(is_array($namenew)) {
  2.                         foreach($namenew as $id => $val) {
  3.                                 $db->query("UPDATE {$tablepre}styles SET name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
  4.                         }
  5.                 }
复制代码


改为:
  1.                 if(is_array($namenew)) {
  2.                         foreach($namenew as $id => $val) {
  3.                                 $db->query("UPDATE {$tablepre}styles SET orderid='$orderidnew[$id]', name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
  4.                         }
  5.                 }
复制代码

===================================================

再找


  1.                if($newname) {
  2.                         $db->query("INSERT INTO {$tablepre}styles (name, templateid) VALUES ('$newname', '1')");
  3.                         $styleidnew = $db->insert_id();
  4.                         foreach($predefinedvars as $variable) {
  5.                                 $db->query("INSERT INTO {$tablepre}stylevars (styleid, variable)
  6.                                         VALUES ('$styleidnew', '$variable')");
  7.                         }
  8.                 }
复制代码


改为:


  1.                 if($newname) {
  2.                         $db->query("INSERT INTO {$tablepre}styles (orderid, name, templateid) VALUES ('$neworderid', '$newname', '1')");
  3.                         $styleidnew = $db->insert_id();
  4.                         foreach($predefinedvars as $variable) {
  5.                                 $db->query("INSERT INTO {$tablepre}stylevars (styleid, variable)
  6.                                         VALUES ('$styleidnew', '$variable')");
  7.                         }
  8.                 }

  9.                 updatecache('styles');
  10.                 updatecache('settings');
复制代码

======================================================

  注意:有以下两行的人,便不用再加入

                updatecache('styles');
                updatecache('settings');

======================================================
3、admin/plugins.inc.php 找


  1. if($action == 'plugins') {

  2.         if(!$edit && !$identifier) {

  3.                 $plugins = '';
  4.                 $query = $db->query("SELECT p.*, pv.pluginvarid FROM {$tablepre}plugins p
  5.                         LEFT JOIN {$tablepre}pluginvars pv USING(pluginid)
  6.                         GROUP BY p.pluginid
  7.                         ORDER BY p.available DESC, p.pluginid");
复制代码


改为:
  1. if($action == 'plugins') {

  2.         if(!$edit && !$identifier) {

  3.                 $plugins = '';
  4.                 $query = $db->query("SELECT p.*, pv.pluginvarid FROM {$tablepre}plugins p
  5.                         LEFT JOIN {$tablepre}pluginvars pv USING(pluginid)
  6.                         GROUP BY p.pluginid
  7.                          ORDER BY orderid ASC, p.pluginid");
复制代码

====================================================

再找


  1. } elseif($action == 'pluginsconfig') {

  2.         if(!submitcheck('configsubmit') && !submitcheck('importsubmit')) {

  3.                 $plugins = '';
  4.                 $query = $db->query("SELECT * FROM {$tablepre}plugins");
  5.                 while($plugin = $db->fetch_array($query)) {
  6.                         $plugins .= "<tr align="center"><td bgcolor="".ALTBG1.""><input type="checkbox" name="delete[]" value="$plugin[pluginid]"></td>\n".
  7.                                 "<td bgcolor="".ALTBG2.""><b>$plugin[name]</b></td>\n".
  8.                                 "<td bgcolor="".ALTBG1."">$plugin[identifier]</td>\n".
  9.                                 "<td bgcolor="".ALTBG2."">$plugin[description]</td>\n".
  10.                                 "<td bgcolor="".ALTBG1."">$plugin[directory]</td>\n".
  11.                                 "<td bgcolor="".ALTBG2.""><input type="checkbox" name="availablenew[$plugin[pluginid]]" value="1" ".(!$plugin['name'] || !$plugin['identifier'] ? 'disabled' : ($plugin['available'] ? 'checked' : ''))."></td>\n".
  12.                                 "<td bgcolor="".ALTBG1.""><a href="admincp.php?action=pluginsconfig&export=$plugin[pluginid]">[$lang[download]]</a></td>\n".
  13.                                 "<td bgcolor="".ALTBG2.""><a href="admincp.php?action=pluginsedit&pluginid=$plugin[pluginid]">[$lang[detail]]</a></td></tr>\n";
  14.                 }

  15. ?>
  16. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="98%" align="center" class="tableborder">
  17. <tr class="header"><td><?=$lang['tips']?></td></tr>
  18. <tr bgcolor="<?=ALTBG1?>"><td>
  19. <br><?=$lang['plugins_config_tips']?>
  20. </td></tr></table><br><br>

  21. <form method="post" action="admincp.php?action=pluginsconfig">
  22. <input type="hidden" name="formhash" value="<?=FORMHASH?>">
  23. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="98%" align="center" class="tableborder">
  24. <tr class="header" align="center">
  25. <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form, 'delete')"><?=$lang['del']?></td>
  26. <td width="15%"><?=$lang['plugins_name']?></td>
  27. <td width="10%"><?=$lang['plugins_identifier']?></td>
  28. <td width="31%"><?=$lang['description']?></td>
  29. <td width="15%"><?=$lang['plugins_directory']?></td>
  30. <td width="8%"><?=$lang['available']?></td>
  31. <td width="8%"><?=$lang['export']?></td>
  32. <td width="8%"><?=$lang['edit']?></td></tr>
  33. <?=$plugins?>
  34. <tr><td colspan="7" class="singleborder"> </td></tr>
  35. <tr align="center" class="altbg1"><td><?=$lang['add_new']?></td>
  36. <td><input type='text' name="newname" size="12"></td>
  37. <td><input type='text' name="newidentifier" size="8"></td>
  38. <td colspan="6"> </td>
  39. </tr></table><br>
  40. <center><input type="submit" name="configsubmit" value="<?=$lang['submit']?>"></center></form>

  41. <br><form method="post" action="admincp.php?action=pluginsconfig">
  42. <input type="hidden" name="formhash" value="<?=FORMHASH?>">
  43. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="98%" align="center" class="tableborder">
  44. <tr class="header"><td><?=$lang['plugins_import']?></td></tr>
  45. <tr><td bgcolor="<?=ALTBG1?>" align="center"><textarea  name="plugindata" cols="80" rows="8"></textarea><br>
  46. <input type="checkbox" name="ignoreversion" value="1"> <?=$lang['plugins_import_ignore_version']?></td></tr>
  47. </table><br><center><input type="submit" name="importsubmit" value="<?=$lang['submit']?>"></center></form>
复制代码

改为:


  1. } elseif($action == 'pluginsconfig') {

  2.         if(!submitcheck('configsubmit') && !submitcheck('importsubmit')) {

  3.                 $plugins = '';
  4.                 $query = $db->query("SELECT * FROM {$tablepre}plugins ORDER BY orderid ASC");
  5.                 while($plugin = $db->fetch_array($query)) {
  6.                         $plugins .= "<tr align="center"><td bgcolor="".ALTBG2.""><input type="checkbox" name="delete[]" value="$plugin[pluginid]"></td>\n".
  7.                                 "<td bgcolor="".ALTBG1.""><input type="text" size="2" name="orderidnew[$plugin[pluginid]]" value="$plugin[orderid]">\n".
  8.                                 "<td bgcolor="".ALTBG2.""><b>$plugin[name]</b></td>\n".
  9.                                 "<td bgcolor="".ALTBG1."">$plugin[identifier]</td>\n".
  10.                                 "<td bgcolor="".ALTBG2."">$plugin[description]</td>\n".
  11.                                 "<td bgcolor="".ALTBG1."">$plugin[directory]</td>\n".
  12.                                 "<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".
  13.                                 "<td bgcolor="".ALTBG2.""><input type="checkbox" name="availablenew[$plugin[pluginid]]" value="1" ".(!$plugin['name'] || !$plugin['identifier'] ? 'disabled' : ($plugin['available'] ? 'checked' : ''))."></td>\n".
  14.                                 "<td bgcolor="".ALTBG1.""><a href="admincp.php?action=pluginsconfig&export=$plugin[pluginid]">[$lang[download]]</a></td>\n".
  15.                                 "<td bgcolor="".ALTBG2.""><a href="admincp.php?action=pluginsedit&pluginid=$plugin[pluginid]">[$lang[detail]]</a></td></tr>\n";
  16.                 }

  17. ?>
  18. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
  19. <tr class="header"><td><?=$lang['tips']?></td></tr>
  20. <tr bgcolor="<?=ALTBG1?>"><td>
  21. <?=$lang['plugins_config_tips']?>
  22. </td></tr></table>

  23. <form method="post" action="admincp.php?action=pluginsconfig">
  24. <input type="hidden" name="formhash" value="<?=FORMHASH?>">
  25. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
  26. <tr class="header" align="center">
  27. <td width="48"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form, 'delete')"><?=$lang['del']?></td>
  28. <---百分数可自行调整--->
  29. <td width="3%">排序</td>   
  30. <td width="15%"><?=$lang['plugins_name']?></td>
  31. <td width="15%"><?=$lang['plugins_identifier']?></td>
  32. <td width="20%"><?=$lang['description']?></td>
  33. <td width="20%"><?=$lang['plugins_directory']?></td>
  34. <td width="10%">颜色</td>
  35. <td width="6%"><?=$lang['available']?></td>
  36. <td width="7%"><?=$lang['export']?></td>
  37. <td width="7%"><?=$lang['edit']?></td></tr>
  38. <---百分数可自行调整--->
  39. <?=$plugins?>
  40. <tr><td colspan="9" class="singleborder"> </td></tr>
  41. <tr align="center" class="altbg1"><td><?=$lang['add_new']?></td>
  42. <td><input type='text' name="neworderid" size="2"></td>
  43. <td><input type='text' name="newname" size="12"></td>
  44. <td><input type='text' name="newidentifier" size="8"></td>
  45. <td colspan="6"> </td>
  46. </tr></table><br>
  47. <center><input type="submit" name="configsubmit" value="<?=$lang['submit']?>"></center></form>

  48. <form method="post" action="admincp.php?action=pluginsconfig">
  49. <input type="hidden" name="formhash" value="<?=FORMHASH?>">
  50. <table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="97%" align="center" class="tableborder">
  51. <tr class="header"><td><?=$lang['plugins_import']?></td></tr>
  52. <tr><td bgcolor="<?=ALTBG1?>" align="center"><textarea  name="plugindata" rows="8" style="width:90%"></textarea><br>
  53. <input type="checkbox" name="ignoreversion" value="1" checked> <?=$lang['plugins_import_ignore_version']?></td></tr>
  54. </table><br><center><input type="submit" name="importsubmit" value="<?=$lang['submit']?>"></center></form>
复制代码

=======================================================
查找:

  1. $db->query("UPDATE {$tablepre}plugins SET available='$available' WHERE pluginid='$id'");
  2.                         }
  3.                 }
复制代码


改为

  1. $db->query("UPDATE {$tablepre}plugins SET available='$available', pcolor='$pcolornew[$id]' WHERE pluginid='$id'");
  2.                 if(is_array($orderidnew)) {
  3.                         foreach($orderidnew as $ids => $orderid) {
  4.                                 $db->query("UPDATE {$tablepre}plugins SET orderid='$orderid' WHERE pluginid='$ids'");
  5.                         }
  6.                 }
复制代码


=====================================================
查找:

  1. $db->query("INSERT INTO {$tablepre}plugins (name, identifier, available) VALUES ('".dhtmlspecialchars(trim($newname))."', '$newidentifier', '0')");
  2.                 }
复制代码


改为:

  1. $db->query("INSERT INTO {$tablepre}plugins (orderid, name, identifier, available) VALUES ('$neworderid', '".dhtmlspecialchars(trim($newname))."', '$newidentifier', '0')");
  2.                 }
复制代码


=====================================================4、include/cache.func.php
查找:
  1.                 $query = $db->query("SELECT s.*, t.directory AS tpldir FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON s.templateid=t.templateid");
复制代码



改为:
  1.                $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");
复制代码

====================================================
查找:
  1.                 $query = $db->query("SELECT pluginid, available, adminid, name, identifier, datatables, directory, copyright, modules FROM {$tablepre}plugins");
复制代码



改为:
  1.                 $query = $db->query("SELECT pluginid, available, adminid, name, identifier, datatables, directory, copyright, modules, orderid FROM {$tablepre}plugins ORDER BY orderid ASC");
复制代码

=======================================================

查找:
  1.                                 $query = $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'");
复制代码



改为:
  1.                                 $query = $db->query("SELECT styleid, name, orderid FROM {$tablepre}styles WHERE available='1' ORDER BY orderid ASC");
复制代码

===========================================================

查找:
  1.                         $query = $db->query("SELECT available, name, identifier, directory, datatables, modules FROM {$tablepre}plugins");
复制代码



改为:
  1.                        $query = $db->query("SELECT available, name, identifier, directory, datatables, modules, orderid, pcolor FROM {$tablepre}plugins ORDER BY orderid ASC");
复制代码

===========================================================

查找:
  1. case 1:
  2.                                                                         $data['plugins']['links'][$plugin['identifier']][$module['name']] = array('adminid' => $module['adminid'], 'url' => "<a href="$module[url]">$module[menu]</a>");
  3.                                                                         break;
  4.                                                                 case 2:
  5.                                                                         $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']);
  6.                                                                         break;
复制代码


改为:
  1.                                                         case 1:
  2.                                   $plugin['url'] = $plugin['pcolor'] ? "<a href="$module[url]"><font color=".$plugin['pcolor'].">$module[menu]</font></a>" : "<a href="$module[url]">$module[menu]</a>";
  3.                                   $data['plugins']['links'][$plugin['identifier']][$module['name']] = array('adminid' => $module['adminid'], 'url' => $plugin['url']);
  4.                                   break;
  5.                             case 2:
  6.                                   $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 编辑 ]
good2002 发表于 2006-4-14 09:06:17 | 显示全部楼层
沙发~
回复

使用道具 举报

jimmyjimmyqqq 发表于 2006-4-14 13:47:20 | 显示全部楼层
板凳!
回复

使用道具 举报

doitcn 发表于 2006-4-14 22:27:32 | 显示全部楼层
Parse error: parse error, unexpected T_ELSEIF in /bbs/admin/plugins.inc.php on line 312

哪里出错了?
回复

使用道具 举报

doitcn 发表于 2006-4-16 16:42:30 | 显示全部楼层
有成功的吗?
回复

使用道具 举报

kisslbz 发表于 2006-4-16 16:47:00 | 显示全部楼层
谁切张图上来
回复

使用道具 举报

goau 发表于 2006-4-16 22:35:11 | 显示全部楼层
留位
回复

使用道具 举报

晨轩寒 发表于 2006-7-25 08:42:19 | 显示全部楼层
这个支持4.1吗?
回复

使用道具 举报

5872216 发表于 2006-7-25 08:51:34 | 显示全部楼层
占据 9楼拉.还是顶一下!
回复

使用道具 举报

 楼主| e_zailai 发表于 2007-1-1 09:05:59 | 显示全部楼层
路过,顶一下!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-9-22 10:05 , Processed in 0.107013 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表