aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/config/ConfigPlugin.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-07-26 14:43:10 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-26 14:43:10 +0200
commit9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9 (patch)
tree9bfc3c9b185eb0c185d23146d44d42dd6685a4da /application/config/ConfigPlugin.php
parentbc583903adfd768f115fae438e4d9ed1043682d9 (diff)
downloadShaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.tar.gz
Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.tar.zst
Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.zip
New basePath: fix officiel plugin paths and vintage template
Diffstat (limited to 'application/config/ConfigPlugin.php')
-rw-r--r--application/config/ConfigPlugin.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/application/config/ConfigPlugin.php b/application/config/ConfigPlugin.php
index dbb24937..ea8dfbda 100644
--- a/application/config/ConfigPlugin.php
+++ b/application/config/ConfigPlugin.php
@@ -1,6 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Config\Exception\PluginConfigOrderException; 3use Shaarli\Config\Exception\PluginConfigOrderException;
4use Shaarli\Plugin\PluginManager;
4 5
5/** 6/**
6 * Plugin configuration helper functions. 7 * Plugin configuration helper functions.
@@ -19,6 +20,20 @@ use Shaarli\Config\Exception\PluginConfigOrderException;
19 */ 20 */
20function save_plugin_config($formData) 21function save_plugin_config($formData)
21{ 22{
23 // We can only save existing plugins
24 $directories = str_replace(
25 PluginManager::$PLUGINS_PATH . '/',
26 '',
27 glob(PluginManager::$PLUGINS_PATH . '/*')
28 );
29 $formData = array_filter(
30 $formData,
31 function ($value, string $key) use ($directories) {
32 return startsWith($key, 'order') || in_array($key, $directories);
33 },
34 ARRAY_FILTER_USE_BOTH
35 );
36
22 // Make sure there are no duplicates in orders. 37 // Make sure there are no duplicates in orders.
23 if (!validate_plugin_order($formData)) { 38 if (!validate_plugin_order($formData)) {
24 throw new PluginConfigOrderException(); 39 throw new PluginConfigOrderException();
@@ -69,7 +84,7 @@ function validate_plugin_order($formData)
69 $orders = array(); 84 $orders = array();
70 foreach ($formData as $key => $value) { 85 foreach ($formData as $key => $value) {
71 // No duplicate order allowed. 86 // No duplicate order allowed.
72 if (in_array($value, $orders)) { 87 if (in_array($value, $orders, true)) {
73 return false; 88 return false;
74 } 89 }
75 90