diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-07-26 14:43:10 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-26 14:43:10 +0200 |
commit | 9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9 (patch) | |
tree | 9bfc3c9b185eb0c185d23146d44d42dd6685a4da /application/front/controller/admin | |
parent | bc583903adfd768f115fae438e4d9ed1043682d9 (diff) | |
download | Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.tar.gz Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.tar.zst Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.zip |
New basePath: fix officiel plugin paths and vintage template
Diffstat (limited to 'application/front/controller/admin')
3 files changed, 7 insertions, 52 deletions
diff --git a/application/front/controller/admin/ManageShaareController.php b/application/front/controller/admin/ManageShaareController.php index 3aa48423..33e1188e 100644 --- a/application/front/controller/admin/ManageShaareController.php +++ b/application/front/controller/admin/ManageShaareController.php | |||
@@ -152,7 +152,7 @@ class ManageShaareController extends ShaarliAdminController | |||
152 | // To preserve backward compatibility with 3rd parties, plugins still use arrays | 152 | // To preserve backward compatibility with 3rd parties, plugins still use arrays |
153 | $formatter = $this->container->formatterFactory->getFormatter('raw'); | 153 | $formatter = $this->container->formatterFactory->getFormatter('raw'); |
154 | $data = $formatter->format($bookmark); | 154 | $data = $formatter->format($bookmark); |
155 | $data = $this->executeHooks('save_link', $data); | 155 | $this->executePageHooks('save_link', $data); |
156 | 156 | ||
157 | $bookmark->fromArray($data); | 157 | $bookmark->fromArray($data); |
158 | $this->container->bookmarkService->set($bookmark); | 158 | $this->container->bookmarkService->set($bookmark); |
@@ -211,7 +211,7 @@ class ManageShaareController extends ShaarliAdminController | |||
211 | } | 211 | } |
212 | 212 | ||
213 | $data = $formatter->format($bookmark); | 213 | $data = $formatter->format($bookmark); |
214 | $this->container->pluginManager->executeHooks('delete_link', $data); | 214 | $this->executePageHooks('delete_link', $data); |
215 | $this->container->bookmarkService->remove($bookmark, false); | 215 | $this->container->bookmarkService->remove($bookmark, false); |
216 | ++ $count; | 216 | ++ $count; |
217 | } | 217 | } |
@@ -283,7 +283,7 @@ class ManageShaareController extends ShaarliAdminController | |||
283 | 283 | ||
284 | // To preserve backward compatibility with 3rd parties, plugins still use arrays | 284 | // To preserve backward compatibility with 3rd parties, plugins still use arrays |
285 | $data = $formatter->format($bookmark); | 285 | $data = $formatter->format($bookmark); |
286 | $this->container->pluginManager->executeHooks('save_link', $data); | 286 | $this->executePageHooks('save_link', $data); |
287 | $bookmark->fromArray($data); | 287 | $bookmark->fromArray($data); |
288 | 288 | ||
289 | $this->container->bookmarkService->set($bookmark, false); | 289 | $this->container->bookmarkService->set($bookmark, false); |
@@ -325,7 +325,7 @@ class ManageShaareController extends ShaarliAdminController | |||
325 | 325 | ||
326 | // To preserve backward compatibility with 3rd parties, plugins still use arrays | 326 | // To preserve backward compatibility with 3rd parties, plugins still use arrays |
327 | $data = $formatter->format($bookmark); | 327 | $data = $formatter->format($bookmark); |
328 | $this->container->pluginManager->executeHooks('save_link', $data); | 328 | $this->executePageHooks('save_link', $data); |
329 | $bookmark->fromArray($data); | 329 | $bookmark->fromArray($data); |
330 | 330 | ||
331 | $this->container->bookmarkService->set($bookmark); | 331 | $this->container->bookmarkService->set($bookmark); |
@@ -354,7 +354,7 @@ class ManageShaareController extends ShaarliAdminController | |||
354 | 'default_private_links' => $this->container->conf->get('privacy.default_private_links', false), | 354 | 'default_private_links' => $this->container->conf->get('privacy.default_private_links', false), |
355 | ]; | 355 | ]; |
356 | 356 | ||
357 | $data = $this->executeHooks('render_editlink', $data); | 357 | $this->executePageHooks('render_editlink', $data, TemplatePage::EDIT_LINK); |
358 | 358 | ||
359 | foreach ($data as $key => $value) { | 359 | foreach ($data as $key => $value) { |
360 | $this->assignView($key, $value); | 360 | $this->assignView($key, $value); |
@@ -368,19 +368,4 @@ class ManageShaareController extends ShaarliAdminController | |||
368 | 368 | ||
369 | return $response->write($this->render(TemplatePage::EDIT_LINK)); | 369 | return $response->write($this->render(TemplatePage::EDIT_LINK)); |
370 | } | 370 | } |
371 | |||
372 | /** | ||
373 | * @param mixed[] $data Variables passed to the template engine | ||
374 | * | ||
375 | * @return mixed[] Template data after active plugins render_picwall hook execution. | ||
376 | */ | ||
377 | protected function executeHooks(string $hook, array $data): array | ||
378 | { | ||
379 | $this->container->pluginManager->executeHooks( | ||
380 | $hook, | ||
381 | $data | ||
382 | ); | ||
383 | |||
384 | return $data; | ||
385 | } | ||
386 | } | 371 | } |
diff --git a/application/front/controller/admin/PluginsController.php b/application/front/controller/admin/PluginsController.php index 1eb7e635..0e09116e 100644 --- a/application/front/controller/admin/PluginsController.php +++ b/application/front/controller/admin/PluginsController.php | |||
@@ -58,7 +58,7 @@ class PluginsController extends ShaarliAdminController | |||
58 | try { | 58 | try { |
59 | $parameters = $request->getParams() ?? []; | 59 | $parameters = $request->getParams() ?? []; |
60 | 60 | ||
61 | $this->executeHooks($parameters); | 61 | $this->executePageHooks('save_plugin_parameters', $parameters); |
62 | 62 | ||
63 | if (isset($parameters['parameters_form'])) { | 63 | if (isset($parameters['parameters_form'])) { |
64 | unset($parameters['parameters_form']); | 64 | unset($parameters['parameters_form']); |
@@ -81,19 +81,4 @@ class PluginsController extends ShaarliAdminController | |||
81 | 81 | ||
82 | return $this->redirect($response, '/admin/plugins'); | 82 | return $this->redirect($response, '/admin/plugins'); |
83 | } | 83 | } |
84 | |||
85 | /** | ||
86 | * @param mixed[] $data Variables passed to the template engine | ||
87 | * | ||
88 | * @return mixed[] Template data after active plugins render_picwall hook execution. | ||
89 | */ | ||
90 | protected function executeHooks(array $data): array | ||
91 | { | ||
92 | $this->container->pluginManager->executeHooks( | ||
93 | 'save_plugin_parameters', | ||
94 | $data | ||
95 | ); | ||
96 | |||
97 | return $data; | ||
98 | } | ||
99 | } | 84 | } |
diff --git a/application/front/controller/admin/ToolsController.php b/application/front/controller/admin/ToolsController.php index a476e898..a87f20d2 100644 --- a/application/front/controller/admin/ToolsController.php +++ b/application/front/controller/admin/ToolsController.php | |||
@@ -22,7 +22,7 @@ class ToolsController extends ShaarliAdminController | |||
22 | 'sslenabled' => is_https($this->container->environment), | 22 | 'sslenabled' => is_https($this->container->environment), |
23 | ]; | 23 | ]; |
24 | 24 | ||
25 | $data = $this->executeHooks($data); | 25 | $this->executePageHooks('render_tools', $data, TemplatePage::TOOLS); |
26 | 26 | ||
27 | foreach ($data as $key => $value) { | 27 | foreach ($data as $key => $value) { |
28 | $this->assignView($key, $value); | 28 | $this->assignView($key, $value); |
@@ -32,19 +32,4 @@ class ToolsController extends ShaarliAdminController | |||
32 | 32 | ||
33 | return $response->write($this->render(TemplatePage::TOOLS)); | 33 | return $response->write($this->render(TemplatePage::TOOLS)); |
34 | } | 34 | } |
35 | |||
36 | /** | ||
37 | * @param mixed[] $data Variables passed to the template engine | ||
38 | * | ||
39 | * @return mixed[] Template data after active plugins render_picwall hook execution. | ||
40 | */ | ||
41 | protected function executeHooks(array $data): array | ||
42 | { | ||
43 | $this->container->pluginManager->executeHooks( | ||
44 | 'render_tools', | ||
45 | $data | ||
46 | ); | ||
47 | |||
48 | return $data; | ||
49 | } | ||
50 | } | 35 | } |