Update of /cvsroot/php-blog/jBlog
In directory sc8-pr-cvs1:/tmp/cvs-serv4009
Modified Files:
jBlog_admin_plugins.inc.php
Log Message:
Provide ability to change the sort_order of plugins
Index: jBlog_admin_plugins.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_admin_plugins.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- jBlog_admin_plugins.inc.php 13 Mar 2003 12:44:39 -0000 1.5
+++ jBlog_admin_plugins.inc.php 15 Mar 2003 08:39:29 -0000 1.6
@@ -5,6 +5,37 @@
include_once "jBlog_plugin_api.php";
include_once "jBlog_sidebar_items.php";
+if (isset($_GET['jBlog']['plugin_to_move']) && isset($_GET['submit'])) {
+ $plugins = jblog_plugin_api::enum_plugins();
+ /* Renumber the sort order to be certain that one actually exists
+ Also look for the one we're going to move */
+ $idx_to_move = -1;
+ for($idx=0; $idx<count($plugins); $idx++) {
+ $plugins[$idx]['sort_order'] = $idx;
+ if ($plugins[$idx]['name'] == $_GET['jBlog']['plugin_to_move'])
+ $idx_to_move = $idx;
+ }
+ /* If idx_to_move is still -1 then we never found it (shouldn't happen under normal conditions)
+ Also make sure the swaping idx is around */
+ if ($idx_to_move >= 0 && (($_GET['submit'] == 'move down' && $idx_to_move < (count($plugins)-1)) || ($_GET['submit'] == 'move up' && $idx_to_move > 0))) {
+ /* Swap the one were moving with the one that's in the spot we're moving to */
+ $tmp = $plugins[$idx_to_move]['sort_order'];
+ $plugins[$idx_to_move]['sort_order'] = (int)$plugins[$idx_to_move+($_GET['submit'] == 'move down' ? 1 : -1)]['sort_order'];
+ $plugins[$idx_to_move+($_GET['submit'] == 'move down' ? 1 : -1)]['sort_order'] = (int)$tmp;
+
+ /* Update table */
+ foreach($plugins as $plugin) {
+ $key = jBlog_db_escape_string($plugin['name']);
+ jBlog_db_query("UPDATE $jBlog[dbPrefix]plugins SET sort_order=$plugin[sort_order] WHERE name='$key'");
+ }
+ }
+
+ /* TODO: Moving The first Right oriented plugin up,
+ or the last left oriented plugin down
+ should not be displayed to the user as an option.
+ It's a behavior which really has no meaning. */
+}
+
if (isset($_GET['jBlog']['plugin_to_conf'])) {
/* configure a specific instance */
@@ -28,6 +59,7 @@
}
}
+
?>
<form method="POST" name="jBlogPluginConfigure">
@@ -157,6 +189,7 @@
}
$sort_order = 0;
+$sort_idx = 0;
foreach ($plugins as $plugin_data) {
$plugin =& jblog_plugin_api::load_plugin($plugin_data['name']);
@@ -186,7 +219,20 @@
$title = "<a href=\"$url\">$title</a>";
}
- echo "<tr><td><input type=\"checkbox\" name=\"jBlog[plugin_to_remove][]\" value=\"$plugin_data[name]\"></td><td>$title</td><td>$name</td><td>$desc</td><td>$place</td></tr>\n";
+ if ($sort_idx == 0)
+ $moveup = " ";
+ else
+ $moveup = "<a href=\"?jBlog[adminModule]=plugins&submit=move+up&jBlog[plugin_to_move]=$key\">UP</a>";
+
+ if ($sort_idx == (count($plugins)-1))
+ $movedown = "";
+ else
+ $movedown = "<a href=\"?jBlog[adminModule]=plugins&submit=move+down&jBlog[plugin_to_move]=$key\">DOWN</a>";
+
+
+ echo "<tr><td><input type=\"checkbox\" name=\"jBlog[plugin_to_remove][]\" value=\"$plugin_data[name]\"></td><td>$title</td><td>$name</td><td>$desc</td><td>$place $moveup $movedown</td></tr>\n";
+
+ $sort_idx++;
}
?>
</table>
|