/** * Returns plugin config by its module merged with specifig package * config. Package type is read from module config. * * @param string $module * @return array */ function getPluginsConfigByType($module) { if (isset($GLOBALS['_MAX']['CONF'][$module])) { // Make sure config is always read from ini file unset($GLOBALS['_MAX']['CONF'][$module]); } $conf = MAX_Plugin::getConfig($module); $aConfig = MAX_Plugin::getConfig($module, $conf['type']); if (is_array($aConfig)) { $conf = array_merge($conf, $aConfig); } return $conf; }
/** * A factory method, for including and instantiating a plugin, based on the * information in that plugin's configuration file(s), given a module (and * optional information about the plugin's configuration options). * * @static * @param string $module The plugin module name (i.e. /plugins/module directory). * @param string $configKey Optional configuration key name, which stores the * details of the plugin package name. Default is 'type'. * @param string $omit An optional setting, where if the value retrieved from the * configuration file for the $configKey is this, then it is * known that the plugin module is not been configured, or * is set to use no package. Default is 'none'. * @return mixed The instantiated plugin object, null if configured to return * no plugin, or false on error. */ function &factoryPluginByModuleConfig($module, $configKey = 'type', $omit = 'none') { // Read the module configuration file $conf = MAX_Plugin::getConfig($module); // Get the $configKey value from this configuration, // and convert into the package/plugin name if (!isset($conf[$configKey])) { return false; } else { $packageName = explode(':', $conf[$configKey]); if (count($packageName) > 1) { $package = $packageName[0]; $name = $packageName[1]; } else { $package = $conf[$configKey]; $name = null; } } // Ensure that only real, valid packages/plugins are instantiated if ($package == $omit) { $r = null; return $r; } // Instantiate the plugin, if possible if (!empty($module) && !empty($package)) { return MAX_Plugin::factory($module, $package, $name); } // Error return false; }
/** * Method for reading the specific plugin config file * * @param bool $processSections If true the configuration data is returned * as one dimension array * @param bool $commonPackageConfig If true read the global plugin.conf.php file * for specific package * * @return array Configuration array * */ function getConfig($processSections = false, $commonPackageConfig = true) { $name = $commonPackageConfig ? null : $this->name; return MAX_Plugin::getConfig($this->module, $this->package, $name, $processSections); }