Update of /cvsroot/php-blog/jBlog
In directory sc8-pr-cvs1:/tmp/cvs-serv9373
Modified Files:
jBlog_plugin_api.php
Log Message:
Glue to enable third-party plugins.
Third-party plugins are uploaded into a sub-dir of the plugins dir.
Eg: if I have a plugin named chewmyshoe:
% ls jBlog/plugins/chewmyshoe/
chewmyshoe.php mydatafile.txt etc.txt etc.txt
chewmyshoe.php MUST include the definition of a class named chewmyshoe
that extends the jblog_plugin class.
Index: jBlog_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_plugin_api.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- jBlog_plugin_api.php 11 Mar 2003 01:41:07 -0000 1.8
+++ jBlog_plugin_api.php 11 Mar 2003 01:52:26 -0000 1.9
@@ -76,6 +76,9 @@
/* built-in classes first */
$cls = get_declared_classes();
foreach ($cls as $class_name) {
+ if (strncmp($class_name, 'jblog_', 6)) {
+ continue;
+ }
$p = get_parent_class($class_name);
while ($p != 'jblog_plugin' && $p !== false) {
$p = get_parent_class($p);
@@ -116,8 +119,15 @@
$class_name = substr($name, 1);
} else {
/* plugin from the plugins/ dir */
+ if (!class_exists($name)) {
- return false;
+ include $jBlog['jBlogPath'] . 'plugins/' . $name . '/' . $name . '.php';
+
+ if (!class_exists($name)) {
+ return false;
+ }
+ }
+ $class_name = $name;
}
$p =& new $class_name($instance_id);
|