diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/PageBuilder.php | 3 | ||||
-rw-r--r-- | application/PluginManager.php | 25 |
2 files changed, 25 insertions, 3 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 42932f32..32c7f9f1 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php | |||
@@ -77,9 +77,6 @@ class PageBuilder | |||
77 | $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false)); | 77 | $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false)); |
78 | $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false)); | 78 | $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false)); |
79 | $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); | 79 | $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); |
80 | if (!empty($GLOBALS['plugin_errors'])) { | ||
81 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); | ||
82 | } | ||
83 | $this->tpl->assign('token', getToken($this->conf)); | 80 | $this->tpl->assign('token', getToken($this->conf)); |
84 | // To be removed with a proper theme configuration. | 81 | // To be removed with a proper theme configuration. |
85 | $this->tpl->assign('conf', $this->conf); | 82 | $this->tpl->assign('conf', $this->conf); |
diff --git a/application/PluginManager.php b/application/PluginManager.php index 1e132a7f..59ece4fa 100644 --- a/application/PluginManager.php +++ b/application/PluginManager.php | |||
@@ -25,6 +25,11 @@ class PluginManager | |||
25 | protected $conf; | 25 | protected $conf; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * @var array List of plugin errors. | ||
29 | */ | ||
30 | protected $errors; | ||
31 | |||
32 | /** | ||
28 | * Plugins subdirectory. | 33 | * Plugins subdirectory. |
29 | * @var string $PLUGINS_PATH | 34 | * @var string $PLUGINS_PATH |
30 | */ | 35 | */ |
@@ -44,6 +49,7 @@ class PluginManager | |||
44 | public function __construct(&$conf) | 49 | public function __construct(&$conf) |
45 | { | 50 | { |
46 | $this->conf = $conf; | 51 | $this->conf = $conf; |
52 | $this->errors = array(); | ||
47 | } | 53 | } |
48 | 54 | ||
49 | /** | 55 | /** |
@@ -106,6 +112,7 @@ class PluginManager | |||
106 | 112 | ||
107 | /** | 113 | /** |
108 | * Load a single plugin from its files. | 114 | * Load a single plugin from its files. |
115 | * Call the init function if it exists, and collect errors. | ||
109 | * Add them in $loadedPlugins if successful. | 116 | * Add them in $loadedPlugins if successful. |
110 | * | 117 | * |
111 | * @param string $dir plugin's directory. | 118 | * @param string $dir plugin's directory. |
@@ -128,6 +135,14 @@ class PluginManager | |||
128 | $conf = $this->conf; | 135 | $conf = $this->conf; |
129 | include_once $pluginFilePath; | 136 | include_once $pluginFilePath; |
130 | 137 | ||
138 | $initFunction = $pluginName . '_init'; | ||
139 | if (function_exists($initFunction)) { | ||
140 | $errors = call_user_func($initFunction, $this->conf); | ||
141 | if (!empty($errors)) { | ||
142 | $this->errors = array_merge($this->errors, $errors); | ||
143 | } | ||
144 | } | ||
145 | |||
131 | $this->loadedPlugins[] = $pluginName; | 146 | $this->loadedPlugins[] = $pluginName; |
132 | } | 147 | } |
133 | 148 | ||
@@ -195,6 +210,16 @@ class PluginManager | |||
195 | 210 | ||
196 | return $metaData; | 211 | return $metaData; |
197 | } | 212 | } |
213 | |||
214 | /** | ||
215 | * Return the list of encountered errors. | ||
216 | * | ||
217 | * @return array List of errors (empty array if none exists). | ||
218 | */ | ||
219 | public function getErrors() | ||
220 | { | ||
221 | return $this->errors; | ||
222 | } | ||
198 | } | 223 | } |
199 | 224 | ||
200 | /** | 225 | /** |