コード例 #1
0
 function load_child_plugins($data, $index, $parent_id, $level)
 {
     $parent_id = $parent_id === NULL ? "NULL" : $parent_id;
     // load this plugin
     $plugin = $data[$parent_id];
     // require plugin class
     $plugin_path = ROOT_PATH . 'plugins/' . $plugin->getName() . '/plugin.php';
     if (file_exists($plugin_path)) {
         require_once $plugin_path;
         // init plugin class
         $className = $plugin->getClassName();
         $pluginClass = new $className();
     } else {
         $pluginClass = new DatawrapperPlugin($plugin->getName());
     }
     // but before we load the required libraries
     foreach ($pluginClass->getRequiredLibraries() as $lib) {
         require_once ROOT_PATH . 'plugins/' . $plugin->getName() . '/' . $lib;
     }
     $pluginClass->init();
     if (isset($index[$parent_id])) {
         foreach ($index[$parent_id] as $id) {
             load_child_plugins($data, $index, $id, $level + 1);
         }
     }
 }
コード例 #2
0
 function load_plugin($plugin)
 {
     $plugin_path = ROOT_PATH . 'plugins/' . $plugin->getName() . '/plugin.php';
     if (file_exists($plugin_path)) {
         require $plugin_path;
         // init plugin class
         $className = $plugin->getClassName();
         $pluginClass = new $className();
     } else {
         $pluginClass = new DatawrapperPlugin($plugin->getName());
     }
     // but before we load the libraries required by this lib
     foreach ($pluginClass->getRequiredLibraries() as $lib) {
         require_once ROOT_PATH . 'plugins/' . $plugin->getName() . '/' . $lib;
     }
     $pluginClass->init();
     return $pluginClass;
 }