/** * Loads all available plugins from the specified folder. * @param string $folder Name of the folder to load plugins from. This is a sub-folder of the 'sloodle/plugin' folder. It will only load files which are directly contained inside it. * @return bool True if successful, or false if it fails. (It will only report failure if the folder does not exist, or there is an error accessing it.) */ function load_plugins($folder) { if (empty($folder)) { return false; } // Get a list of all the files in the specified folder $pluginFolder = SLOODLE_DIRROOT . '/plugin/' . $folder; $files = sloodle_get_files($pluginFolder, true); if (!$files) { return false; } if (count($files) == 0) { return true; } // Start by including the relevant base class files, if they are available @(include_once SLOODLE_DIRROOT . '/plugin/_base.php'); @(include_once $pluginFolder . '/_base.php'); // Go through each filename foreach ($files as $file) { // Include the specified file include_once $pluginFolder . '/' . $file; } // Build a complete list of plugin class names $this->plugin_class_names = array(); $allclasses = get_declared_classes(); foreach ($allclasses as $c) { // Attempt to get the plugin ID. // If this operation fails, then the class is not a SLOODLE plugin. $pluginid = @call_user_func(array($c, 'sloodle_get_plugin_id')); if (empty($pluginid)) { continue; } // Attempt to get the plugin category $plugincat = @call_user_func(array($c, 'get_category')); if (empty($plugincat)) { $plugincat = ''; } // Store the class name $this->plugin_class_names[strtolower($plugincat)][strtolower($pluginid)] = $c; } return true; }
/** * This file brings all of the Sloodle module classes together. * It also provides functionality to create and load different module types. * * @package sloodle * @copyright Copyright (c) 2008 Sloodle (various contributors) * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3 * * @contributor Peter R. Bloomfield */ /** Base module. */ require_once SLOODLE_LIBROOT . '/modules/module_base.php'; require_once SLOODLE_LIBROOT . '/general.php'; // Now we will go through every file in the "lib/modules" folder which starts "module_", and include it. $MODULESPATH = SLOODLE_LIBROOT . '/modules'; $modulefiles = sloodle_get_files($MODULESPATH, true); // Go through each file if (is_array($modulefiles)) { foreach ($modulefiles as $mf) { // Does this filename start with "module_" and end with ".php"? if (strcasecmp(substr($mf, 0, 7), 'module_') == 0 && strcasecmp(substr($mf, -4), '.php') == 0) { // Yes - include it include_once $MODULESPATH . '/' . $mf; } } } // We will store an associative array of module types to module class names // e.g. { 'chat'=>'SloodleModuleChat', 'distributor'=>'SloodleModuleDistributor', ...} global $SLOODLE_MODULE_CLASS; $SLOODLE_MODULE_CLASS = array(); // Go through each declared class