1<?php 2/** 3 * Utilities for handling plugins 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9// plugin related constants 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11 12/** 13 * Original plugin functions, remain for backwards compatibility 14 */ 15function plugin_list($type='',$all=false) { 16 global $plugin_controller; 17 return $plugin_controller->getList($type,$all); 18} 19function plugin_load($type,$name,$new=false,$disabled=false) { 20 global $plugin_controller; 21 return $plugin_controller->load($type,$name,$new,$disabled); 22} 23function plugin_isdisabled($plugin) { 24 global $plugin_controller; 25 return $plugin_controller->isdisabled($plugin); 26} 27function plugin_enable($plugin) { 28 global $plugin_controller; 29 return $plugin_controller->enable($plugin); 30} 31function plugin_disable($plugin) { 32 global $plugin_controller; 33 return $plugin_controller->disable($plugin); 34} 35function plugin_directory($plugin) { 36 global $plugin_controller; 37 return $plugin_controller->get_directory($plugin); 38} 39function plugin_getcascade() { 40 global $plugin_controller; 41 return $plugin_controller->getCascade(); 42} 43/** 44 * return a list (name & type) of all the component plugins that make up this plugin 45 * 46 */ 47function get_plugin_components($plugin) { 48 global $plugin_types; 49 static $plugins; 50 if(empty($plugins[$plugin])) { 51 $components = array(); 52 $path = DOKU_PLUGIN.plugin_directory($plugin).'/'; 53 54 foreach ($plugin_types as $type) { 55 if (@file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; } 56 57 if ($dh = @opendir($path.$type.'/')) { 58 while (false !== ($cp = readdir($dh))) { 59 if ($cp == '.' || $cp == '..' || strtolower(substr($cp,-4)) != '.php') continue; 60 61 $components[] = array('name'=>$plugin.'_'.substr($cp, 0, -4), 'type'=>$type); 62 } 63 closedir($dh); 64 } 65 } 66 $plugins[$plugin] = $components; 67 } 68 return $plugins[$plugin]; 69} 70