*/
protected $conf;
+ /**
+ * @var array List of plugin errors.
+ */
+ protected $errors;
+
/**
* Plugins subdirectory.
* @var string $PLUGINS_PATH
public function __construct(&$conf)
{
$this->conf = $conf;
+ $this->errors = array();
}
/**
/**
* Load a single plugin from its files.
+ * Call the init function if it exists, and collect errors.
* Add them in $loadedPlugins if successful.
*
* @param string $dir plugin's directory.
$conf = $this->conf;
include_once $pluginFilePath;
+ $initFunction = $pluginName . '_init';
+ if (function_exists($initFunction)) {
+ $errors = call_user_func($initFunction, $this->conf);
+ if (!empty($errors)) {
+ $this->errors = array_merge($this->errors, $errors);
+ }
+ }
+
$this->loadedPlugins[] = $pluginName;
}
$metaData[$plugin] = parse_ini_file($metaFile);
$metaData[$plugin]['order'] = array_search($plugin, $this->authorizedPlugins);
+ if (isset($metaData[$plugin]['description'])) {
+ $metaData[$plugin]['description'] = t($metaData[$plugin]['description']);
+ }
// Read parameters and format them into an array.
if (isset($metaData[$plugin]['parameters'])) {
$params = explode(';', $metaData[$plugin]['parameters']);
continue;
}
- $metaData[$plugin]['parameters'][$param] = '';
+ $metaData[$plugin]['parameters'][$param]['value'] = '';
+ // Optional parameter description in parameter.PARAM_NAME=
+ if (isset($metaData[$plugin]['parameter.'. $param])) {
+ $metaData[$plugin]['parameters'][$param]['desc'] = t($metaData[$plugin]['parameter.'. $param]);
+ }
}
}
return $metaData;
}
+
+ /**
+ * Return the list of encountered errors.
+ *
+ * @return array List of errors (empty array if none exists).
+ */
+ public function getErrors()
+ {
+ return $this->errors;
+ }
}
/**
*/
public function __construct($pluginName)
{
- $this->message = 'Plugin "'. $pluginName .'" files not found.';
+ $this->message = sprintf(t('Plugin "%s" files not found.'), $pluginName);
}
-}
\ No newline at end of file
+}