summaryrefslogtreecommitdiff
path: root/inc/pluginutils.php
diff options
context:
space:
mode:
authorchris <chris@teacherscpd.co.uk>2005-08-02 21:14:21 +0200
committerchris <chris@teacherscpd.co.uk>2005-08-02 21:14:21 +0200
commit7fb56887dbc7ed17ea8cab3e1330622ebd83e5c6 (patch)
tree03593e6c32a6c266d89af21593abde6beb6a2425 /inc/pluginutils.php
parent4b8edb9d27253137965d9c07ac1b0abe1af3bc31 (diff)
downloadrpg-7fb56887dbc7ed17ea8cab3e1330622ebd83e5c6.tar.gz
rpg-7fb56887dbc7ed17ea8cab3e1330622ebd83e5c6.tar.bz2
support for plugin subfolders added - plugins/[name]/[type]/[file].php
darcs-hash:20050802191421-50fdc-abf82fcb52dfabd74b7119f2e6a53ea590bb1d90.gz
Diffstat (limited to 'inc/pluginutils.php')
-rw-r--r--inc/pluginutils.php61
1 files changed, 38 insertions, 23 deletions
diff --git a/inc/pluginutils.php b/inc/pluginutils.php
index 0cc03e0c1..ded2c7a36 100644
--- a/inc/pluginutils.php
+++ b/inc/pluginutils.php
@@ -13,19 +13,19 @@ function plugin_printCSSJS(){
$plugins = plugin_list();
foreach ($plugins as $p){
$dir = "lib/plugins/$p/";
- if(@file_exists(DOKU_INC.$dir.'style.css')){
- print ' <link rel="stylesheet" type="text/css" href="'.DOKU_BASE.$dir.'style.css" />'."\n";
+ if(@file_exists(DOKU_INC.$dir.'style.css')){
+ print ' <link rel="stylesheet" type="text/css" href="'.DOKU_BASE.$dir.'style.css" />'."\n";
}
- if(@file_exists(DOKU_INC.$dir.'screen.css')){
- print ' <link rel="stylesheet" media="screen" type="text/css" href="'.DOKU_BASE.$dir.'screen.css" />'."\n";
+ if(@file_exists(DOKU_INC.$dir.'screen.css')){
+ print ' <link rel="stylesheet" media="screen" type="text/css" href="'.DOKU_BASE.$dir.'screen.css" />'."\n";
}
- if(@file_exists(DOKU_INC.$dir.'print.css')){
- print ' <link rel="stylesheet" media="print" type="text/css" href="'.DOKU_BASE.$dir.'print.css" />'."\n";
+ if(@file_exists(DOKU_INC.$dir.'print.css')){
+ print ' <link rel="stylesheet" media="print" type="text/css" href="'.DOKU_BASE.$dir.'print.css" />'."\n";
}
- if(@file_exists(DOKU_INC.$dir.'script.js')){
+ if(@file_exists(DOKU_INC.$dir.'script.js')){
print ' <script type="text/javascript" language="javascript" charset="utf-8" src="'.DOKU_BASE.$dir.'script.js"></script>'."\n";
}
- }
+ }
}
/**
@@ -38,12 +38,22 @@ function plugin_printCSSJS(){
function plugin_list($type=''){
$plugins = array();
if ($dh = opendir(DOKU_PLUGIN)) {
- while (false !== ($file = readdir($dh))) {
- if ($file == '.' || $file == '..') continue;
- if (is_file(DOKU_PLUGIN.$file)) continue;
+ while (false !== ($plugin = readdir($dh))) {
+ if ($plugin == '.' || $plugin == '..') continue;
+ if (is_file(DOKU_PLUGIN.$plugin)) continue;
- if ($type=='' || @file_exists(DOKU_PLUGIN.$file.'/'.$type.'.php')){
- $plugins[] = $file;
+ if ($type=='' || @file_exists(DOKU_PLUGIN."$plugin/$type.php")){
+ $plugins[] = $plugin;
+ } else {
+ if ($dp = @opendir(DOKU_PLUGIN."$plugin/$type/")) {
+ while (false !== ($component = readdir($dp))) {
+ if ($component == '.' || $component == '..' || strtolower(substr($component, -4)) != ".php") continue;
+ if (is_file(DOKU_PLUGIN."$plugin/$type/$component")) {
+ $plugins[] = $plugin.'_'.substr($component, 0, -4);
+ }
+ }
+ }
+ closedir($dp);
}
}
closedir($dh);
@@ -56,28 +66,33 @@ function plugin_list($type=''){
*
* @author Andreas Gohr <andi@splitbrain.org>
*
- * @param $type string type of plugin to load
- * @param $name string name of the plugin to load
+ * @param $type string type of plugin to load
+ * @param $name string name of the plugin to load
* @return object the plugin object or null on failure
*/
function &plugin_load($type,$name){
//we keep all loaded plugins available in global scope for reuse
global $DOKU_PLUGINS;
- //plugin already loaded?
- if($DOKU_PLUGINS[$type][$name] != null){
- return $DOKU_PLUGINS[$type][$name];
- }
+ //plugin already loaded?
+ if($DOKU_PLUGINS[$type][$name] != null){
+ return $DOKU_PLUGINS[$type][$name];
+ }
//try to load the wanted plugin file
- if(!include_once(DOKU_PLUGIN.$name.'/'.$type.'.php')){
- return null;
+ if(!@include_once(DOKU_PLUGIN."$name/$type.php")){
+ list($plugin, $component) = preg_split("/_/",$name, 2);
+ if (!$component || !@include_once(DOKU_PLUGIN."$plugin/$type/$component.php")) {
+ return null;
+ }
}
+ global $plugin_investigate_pluginorder;
+ if (!isset($plugin_investigate_pluginorder)) $plugin_investigate_pluginorder = array();
+ $plugin_investigate_pluginorder[] = $name;
+
//construct class and instanciate
$class = $type.'_plugin_'.$name;
$DOKU_PLUGINS[$type][$name] = new $class;
return $DOKU_PLUGINS[$type][$name];
}
-
-