+
+ /**
+ * Retrieve plugins metadata from *.meta (INI) files into an array.
+ * Metadata contains:
+ * - plugin description [description]
+ * - parameters split with ';' [parameters]
+ *
+ * Respects plugins order from settings.
+ *
+ * @return array plugins metadata.
+ */
+ public function getPluginsMeta()
+ {
+ $metaData = array();
+ $dirs = glob(self::$PLUGINS_PATH . '/*', GLOB_ONLYDIR | GLOB_MARK);
+
+ // Browse all plugin directories.
+ foreach ($dirs as $pluginDir) {
+ $plugin = basename($pluginDir);
+ $metaFile = $pluginDir . $plugin . '.' . self::$META_EXT;
+ if (!is_file($metaFile) || !is_readable($metaFile)) {
+ continue;
+ }
+
+ $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']);
+ } else {
+ $params = array();
+ }
+ $metaData[$plugin]['parameters'] = array();
+ foreach ($params as $param) {
+ if (empty($param)) {
+ continue;
+ }
+
+ $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;
+ }