Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23061
Modified Files:
NEWS serendipity_plugin_api.php serendipity.css.php
serendipity_config.inc.php
Log Message:
Bundled plugins, Template chooser
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- NEWS 28 Feb 2004 18:18:00 -0000 1.81
+++ NEWS 3 Mar 2004 08:17:59 -0000 1.82
@@ -2,6 +2,8 @@
Version 0.5.1 ()
------------------------------------
+ * Added plugin to switch themes on the frontend (Evan Nemerson, garvinhicking)
+ * Allow (multiple) dependencies for plugin API to allow pairing of event/sidebar plugins (garvinhicking)
* Redesigned the plugin manager (tomsommer)
* Added RFE #827945 - Allow for custom selection of calendar beginning on week (tomsommer)
* Markup can be applied individually from a list of available transformations: BBCode, Wiki, Textile, s9y markup, Emoticons, nl2br. Multiple transformations are possible. (Colin Viebrock, garvinhicking)
Index: serendipity_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_plugin_api.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- serendipity_plugin_api.php 26 Feb 2004 11:37:42 -0000 1.12
+++ serendipity_plugin_api.php 3 Mar 2004 08:17:59 -0000 1.13
@@ -72,13 +72,27 @@
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}plugins (name, sort_order, placement) values ('$key', $nextidx, '$default_placement')");
+ /* Check for multiple dependencies */
+ $plugin =& serendipity_plugin_api::load_plugin($key);
+ $bag = new serendipity_property_bag;
+ $plugin->introspect($bag);
+ $plugin->register_dependencies(false);
+
return $key;
}
function remove_plugin_instance($plugin_instance_id)
{
global $serendipity;
+
+ $plugin =& serendipity_plugin_api::load_plugin($plugin_instance_id);
+ $bag = new serendipity_property_bag;
+ $plugin->introspect($bag);
+
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}plugins where name='$plugin_instance_id'");
+
+ $plugin->register_dependencies(true);
+
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}config where name LIKE '$plugin_instance_id/%'");
}
@@ -318,6 +332,22 @@
return true;
}
+
+ function exists($instance_id) {
+ global $serendipity;
+
+ if (!strstr($instance_id, ':')) {
+ $instance_id .= ':';
+ }
+
+ $existing = serendipity_db_query("SELECT name FROM {$serendipity['dbPrefix']}plugins WHERE name LIKE '%$instance_id%'");
+
+ if (is_array($existing) && !empty($existing[0][0])) {
+ return $existing[0][0];
+ }
+
+ return false;
+ }
}
/* holds a bunch of properties; you can have multiple
@@ -448,6 +478,49 @@
// serendipity_plugin_api::remove_plugin_value($this->instance, array('title', 'description'));
return true;
}
+
+ function register_dependencies($remove = false)
+ {
+ global $serendipity;
+
+ if (is_array($this->dependencies)) {
+
+ if ($remove) {
+ $dependencies = @explode(';', $this->get_config('dependencies'));
+ $modes = @explode(';', $this->get_config('dependency_modes'));
+
+ if (!empty($dependencies) && is_array($dependencies)) {
+ foreach($dependencies AS $idx => $dependency) {
+ if ($modes[$idx] == 'remove' && serendipity_plugin_api::exists($dependency)) {
+ serendipity_plugin_api::remove_plugin_instance($dependency);
+ }
+ }
+ }
+ } else {
+ $keys = array();
+ $modes = array();
+ foreach($this->dependencies AS $dependency => $mode) {
+ $exists = serendipity_plugin_api::exists($dependency);
+ if (!$exists) {
+ if (strncmp($dependency, 'serendipity_event_', 19)) {
+ $keys[] = serendipity_plugin_api::create_plugin_instance($dependency, null, 'event');
+ } else {
+ $keys[] = serendipity_plugin_api::create_plugin_instance($dependency);
+ }
+ } else {
+ $keys[] = $exists;
+ }
+
+ $modes[] = $mode;
+ }
+
+ $this->set_config('dependencies', implode(';', $keys));
+ $this->set_config('dependency_modes', implode(';', $modes));
+ }
+ }
+
+ return true;
+ }
}
class serendipity_event extends serendipity_plugin {
Index: serendipity.css.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity.css.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- serendipity.css.php 2 Mar 2004 17:35:24 -0000 1.23
+++ serendipity.css.php 3 Mar 2004 08:17:59 -0000 1.24
@@ -1,5 +1,6 @@
<?php # $Id$
+session_start();
include_once('compat.php');
/* This is a small hack to allow CSS display during installations and upgrades */
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- serendipity_config.inc.php 2 Mar 2004 17:35:24 -0000 1.55
+++ serendipity_config.inc.php 3 Mar 2004 08:17:59 -0000 1.56
@@ -150,5 +150,7 @@
/* Default mail headers */
$serendipity['mailheaders'] = 'X-Mailer: Serendipity/'. $serendipity['version'] . "\n"
. 'X-Engine: PHP/'. phpversion();
+
+serendipity_plugin_api::hook_event('frontend_configure', $serendipity);
/* vim: set sts=4 ts=4 expandtab : */
?>
|