Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15613
Modified Files:
Tag: branch-smarty
NEWS serendipity_admin_plugins.inc.php
serendipity_plugin_api.php
Log Message:
- New plugin manager
- Give some of the plugin longer descriptions
- Allow plugins to set 'stackable' directive to false which will prevent it from being installed more than once - Still 'beta'
- MFH plugin config redirection fix
Index: serendipity_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_plugin_api.php,v
retrieving revision 1.23.2.7
retrieving revision 1.23.2.8
diff -u -d -r1.23.2.7 -r1.23.2.8
--- serendipity_plugin_api.php 17 Oct 2004 20:06:50 -0000 1.23.2.7
+++ serendipity_plugin_api.php 28 Oct 2004 20:17:10 -0000 1.23.2.8
@@ -211,6 +211,19 @@
return $classes;
}
+ function get_installed_plugins($filter = '*') {
+ $plugins = serendipity_plugin_api::enum_plugins($filter);
+ $res = array();
+ foreach ( (array)$plugins as $plugin ) {
+ list($class_name) = explode(':', $plugin['name']);
+ if ($class_name{0} == '@') {
+ $class_name = substr($class_name, 1);
+ }
+ $res[] = $class_name;
+ }
+ return $res;
+ }
+
/* Retrieves a list of plugin instances */
function enum_plugins($filter = '*', $negate = false)
{
Index: serendipity_admin_plugins.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_plugins.inc.php,v
retrieving revision 1.44.2.2
retrieving revision 1.44.2.3
diff -u -d -r1.44.2.2 -r1.44.2.3
--- serendipity_admin_plugins.inc.php 9 Oct 2004 19:04:40 -0000 1.44.2.2
+++ serendipity_admin_plugins.inc.php 28 Oct 2004 20:17:10 -0000 1.44.2.3
@@ -19,85 +19,21 @@
function show_plugins($event_only = false)
{
global $serendipity;
-
- /* list of classes for creating instances (standard plugins) */
- $classes = serendipity_plugin_api::enum_plugin_classes($event_only);
-?>
-<form action="?serendipity[adminModule]=plugins" method="post">
-<?php
- $event_only_uri = '';
- if ($event_only) {
- $event_only_uri = '&serendipity[event_plugin]=true';
-?>
- <input type="hidden" name="serendipity[event_plugin]" value="true" />
-<?php
- }
-?>
- <table cellspacing="0" align="center">
- <tr>
- <td colspan="2">
-<?php
- $errorstack = array();
- $pluginstack = array();
- foreach ($classes as $class_name) {
- $plugin =& serendipity_plugin_api::load_plugin($class_name);
- if (is_object($plugin)) {
- /* query for its name, description and configuration data */
- $bag = new serendipity_property_bag;
- $plugin->introspect($bag);
-
- $name = $bag->get('name');
- $desc = $bag->get('description');
-
- $pluginstack[] = array('class_name' => $class_name,
- 'name' => $name,
- 'desc' => $desc);
- } else {
- $errorstack[] = $class_name;
- }
- }
- usort($pluginstack, 'serendipity_pluginListSort');
- foreach($errorstack as $e_idx => $e_name) {
- echo ERROR . ': ' . $e_name . '<br />';
- }
-?>
- <select name="serendipity[plugin_to_add]">
- <option value="0">[ <?php echo SELECT_A_PLUGIN_TO_ADD; ?> ]</option>
-<?php
- foreach ($pluginstack as $plug) {
-?>
- <option value="<?php echo $plug['class_name']; ?>"><?php echo $plug['name'] . ' - ' . $plug['desc']; ?></option>
-<?php
- }
?>
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <input type="checkbox" name="serendipity[all_authors]" value="true" checked="checked" id="all_authors" />
- <label for="all_authors"><?php echo ALL_AUTHORS; ?></label>
- </td>
- <td align="right">
- <input name="NEW" value="<?php echo ADD_PLUGIN; ?>" type="submit" />
- </td>
- </tr>
- </table>
- <br />
-
+ <form action="?serendipity[adminModule]=plugins" method="post">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
- <th> </th>
- <th><?php echo TITLE; ?></th>
- <th><?php echo PERMISSIONS; ?></th>
+ <td> </td>
+ <td><strong><?php echo TITLE; ?></strong></td>
+ <td><strong><?php echo PERMISSIONS; ?></strong></td>
<?php
if (!$event_only) {
?>
- <th colspan="3"><?php echo PLACEMENT; ?></th>
+ <td colspan="3" align="center"><strong><?php echo PLACEMENT; ?></strong></td>
<?php
} else {
?>
- <th colspan="2"> </th>
+ <td colspan="2"> </dd>
<?php } ?>
</tr>
<?php
@@ -535,6 +471,82 @@
</div>
</form>
<?php
+
+} elseif ( $serendipity['GET']['adminAction'] == 'addnew' ) {
+?>
+<?php if ( $serendipity['GET']['type'] == 'event' ) { ?>
+ <h2><?php echo EVENT_PLUGINS ?></h2>
+<?php } else { ?>
+ <h2><?php echo SIDEBAR_PLUGINS ?></h2>
+<?php } ?>
+<?php echo SELECT_A_PLUGIN_TO_ADD; ?>
+<br />
+<br />
+<table cellspacing="0" cellpadding="0" border="0" width="100%">
+ <tr>
+ <td><strong>Plugin</strong></td>
+ <td width="100" align="center"><strong>Action</strong></td>
+ </tr>
+<?php
+ $plugins = serendipity_plugin_api::get_installed_plugins();
+
+ $errorstack = $pluginstack = array();
+ $classes = serendipity_plugin_api::enum_plugin_classes(($serendipity['GET']['type'] == 'event'));
+ foreach ($classes as $class_name) {
+ $plugin =& serendipity_plugin_api::load_plugin($class_name);
+ if (is_object($plugin)) {
+ $bag = new serendipity_property_bag;
+ $plugin->introspect($bag);
+ $pluginstack[] = array('plugin_class' => $class_name,
+ 'class_name' => get_class($plugin),
+ 'name' => $bag->get('name'),
+ 'desc' => $bag->get('description'),
+ 'installable' => !($bag->get('stackable') === false && in_array($class_name, $plugins) && ($plugin->serendipity_owner == $serendipity['authorid'] || $plugin->serendipity_owner == 0)),
+ 'author' => $bag->get('author'),
+ 'version' => $bag->get('version'),
+ 'website' => $bag->get('website'));
+ } else {
+ $errorstack[] = $class_name;
+ }
+ }
+ usort($pluginstack, 'serendipity_pluginListSort');
+ foreach($errorstack as $e_idx => $e_name) {
+ echo ERROR . ': ' . $e_name . '<br />';
+ }
+?>
+<?php
+ foreach ($pluginstack as $plug) {
+ $jsLine = " onmouseout=\"document.getElementById('serendipity_plugin_". $plug['class_name'] ."').className='';\"";
+ $jsLine .= " onmouseover=\"document.getElementById('serendipity_plugin_". $plug['class_name'] ."').className='serendipity_admin_list_item_uneven';\"";
+?>
+ <tr id="serendipity_plugin_<?php echo $plug['class_name']; ?>">
+ <td colspan="2" <?php echo $jsLine ?>>
+ <table width="100%" cellpadding="3" cellspacing="0" border="0">
+ <tr>
+ <td><strong><?php echo $plug['name'] ?></strong></td>
+ <td width="100" align="center" valign="middle" rowspan="3">
+ <?php if ( $plug['installable'] == true ) { ?>
+ <a href="?serendipity[adminModule]=plugins&serendipity[install_plugin]=<?php echo $plug['plugin_class'] ?>"><?php echo INSTALL ?></a>
+ <?php } else { ?>
+ <span style="color: #cccccc"><?php echo ALREADY_INSTALLED ?></span>
+ <?php } ?>
+ </td>
+ </tr>
+ <tr>
+ <td style="padding-left: 10px"><?php echo $plug['desc'] ?></td>
+ </tr>
+ <tr>
+ <td style="padding-left: 10px; font-size: x-small"><?php echo AUTHOR ?>: <?php echo (!empty($plug['author']) ? $plug['author'] : UNKNOWN) ?>, <?php echo VERSION ?>: <?php echo (!empty($plug['version']) ? $plug['version'] : NA) ?></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+<?php
+ }
+?>
+</table>
+
+<?php
} else {
/* show general plugin list */
@@ -552,17 +564,13 @@
}
}
- if (isset($_POST['NEW']) && $_POST['serendipity']['plugin_to_add'] != '0') {
+ if (isset($serendipity['GET']['install_plugin'])) {
$authorid = $serendipity['authorid'];
- if (isset($_POST['serendipity']['all_authors']) && $_POST['serendipity']['all_authors'] == 'true') {
+ if ($serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) {
$authorid = '0';
}
- if (isset($_POST['serendipity']['event_plugin'])) {
- $inst = serendipity_plugin_api::create_plugin_instance($_POST['serendipity']['plugin_to_add'], null, 'event', $authorid);
- } else {
- $inst = serendipity_plugin_api::create_plugin_instance($_POST['serendipity']['plugin_to_add'], null, 'right', $authorid);
- }
+ $inst = serendipity_plugin_api::create_plugin_instance($serendipity['GET']['install_plugin'], null, (serendipity_plugin_api::is_event_plugin($serendipity['GET']['install_plugin']) ? 'event': 'right'), $authorid);
/* Load the new plugin */
$plugin = &serendipity_plugin_api::load_plugin($inst);
@@ -571,7 +579,7 @@
/* Only play with the plugin if there is something to play with */
if ($bag->is_set('configuration')) {
- echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $inst . '\';</script>';
+ echo '<script type="text/javascript">location.href = \'' . $serendipity['baseurl'] . '?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $inst . '\';</script>';
die();
}
}
@@ -586,10 +594,17 @@
}
}
- echo '<h2>' . SIDEBAR_PLUGINS . '</h2>';
+ echo BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS . '<br /><br />';
+
+ echo '<h3>' . SIDEBAR_PLUGINS . '</h3>';
+ echo '<a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew">'. sprintf(CLICK_HERE_TO_INSTALL_PLUGIN, SIDEBAR_PLUGIN) .'</a>';
+
show_plugins(false);
- echo '<h2>' . EVENT_PLUGINS . '</h2>';
+ echo '<br /><br />';
+
+ echo '<h3>' . EVENT_PLUGINS . '</h3>';
+ echo '<a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[type]=event">'. sprintf(CLICK_HERE_TO_INSTALL_PLUGIN, EVENT_PLUGIN) .'</a>';
show_plugins(true);
}
/* vim: set sts=4 ts=4 expandtab : */
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.214.2.40
retrieving revision 1.214.2.41
diff -u -d -r1.214.2.40 -r1.214.2.41
--- NEWS 27 Oct 2004 14:11:15 -0000 1.214.2.40
+++ NEWS 28 Oct 2004 20:17:08 -0000 1.214.2.41
@@ -3,6 +3,8 @@
Version 0.8 ()
------------------------------------------------------------------------
+ * New plugin manager (tomsommer)
+
* Karma plugin works with enabled entryproperties plugin and can
be configured to only show Hit-statistics for an entry without
the voting ability (garvinhicking)
|