From 15170b516429341ae8e1a9ad2111be5ef90bf6aa Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 2 Aug 2016 11:02:20 +0200 Subject: [PATCH 1/3] Parse plugin parameters description with the PluginManager Plugin parameter can contain a description in their meta file under the key: parameter.="" --- application/PluginManager.php | 6 +++++- application/config/ConfigPlugin.php | 10 +++++++--- tests/PluginManagerTest.php | 10 ++++++++-- tests/config/ConfigPluginTest.php | 12 ++++++------ tests/plugins/test/test.meta | 4 +++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/application/PluginManager.php b/application/PluginManager.php index dca7e63e..07bc1da9 100644 --- a/application/PluginManager.php +++ b/application/PluginManager.php @@ -185,7 +185,11 @@ public function getPluginsMeta() 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'] = $metaData[$plugin]['parameter.'. $param]; + } } } diff --git a/application/config/ConfigPlugin.php b/application/config/ConfigPlugin.php index 047d2b03..cb0b6fce 100644 --- a/application/config/ConfigPlugin.php +++ b/application/config/ConfigPlugin.php @@ -80,9 +80,13 @@ function validate_plugin_order($formData) } /** - * Affect plugin parameters values into plugins array. + * Affect plugin parameters values from the ConfigManager into plugins array. * - * @param mixed $plugins Plugins array ($plugins[]['parameters']['param_name'] = . + * @param mixed $plugins Plugins array: + * $plugins[]['parameters'][] = [ + * 'value' => , + * 'desc' => + * ] * @param mixed $conf Plugins configuration. * * @return mixed Updated $plugins array. @@ -97,7 +101,7 @@ function load_plugin_parameter_values($plugins, $conf) foreach ($plugin['parameters'] as $key => $param) { if (!empty($conf[$key])) { - $out[$name]['parameters'][$key] = $conf[$key]; + $out[$name]['parameters'][$key]['value'] = $conf[$key]; } } } diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 61efce68..f4826e2e 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -79,8 +79,14 @@ public function testGetPluginsMeta() $this->pluginManager->load(array(self::$pluginName)); $expectedParameters = array( - 'pop' => '', - 'hip' => '', + 'pop' => array( + 'value' => '', + 'desc' => 'pop description', + ), + 'hip' => array( + 'value' => '', + 'desc' => '', + ), ); $meta = $this->pluginManager->getPluginsMeta(); $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); diff --git a/tests/config/ConfigPluginTest.php b/tests/config/ConfigPluginTest.php index 716631b0..3b37cd79 100644 --- a/tests/config/ConfigPluginTest.php +++ b/tests/config/ConfigPluginTest.php @@ -101,9 +101,9 @@ public function testLoadPluginParameterValues() $plugins = array( 'plugin_name' => array( 'parameters' => array( - 'param1' => true, - 'param2' => false, - 'param3' => '', + 'param1' => array('value' => true), + 'param2' => array('value' => false), + 'param3' => array('value' => ''), ) ) ); @@ -114,8 +114,8 @@ public function testLoadPluginParameterValues() ); $result = load_plugin_parameter_values($plugins, $parameters); - $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']); - $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']); - $this->assertEquals('', $result['plugin_name']['parameters']['param3']); + $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']); + $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']['value']); + $this->assertEquals('', $result['plugin_name']['parameters']['param3']['value']); } } diff --git a/tests/plugins/test/test.meta b/tests/plugins/test/test.meta index ab999ed4..26f243f0 100644 --- a/tests/plugins/test/test.meta +++ b/tests/plugins/test/test.meta @@ -1,2 +1,4 @@ description="test plugin" -parameters="pop;hip" \ No newline at end of file +parameters="pop;hip" +parameter.pop="pop description" +parameter.hip= \ No newline at end of file From 1442afe3cf928815916d73e2b7ff8f176b3a0af1 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 2 Aug 2016 11:03:55 +0200 Subject: [PATCH 2/3] Plugin parameter description: Update the templates to display them --- inc/shaarli.css | 4 ++-- tpl/pluginsadmin.html | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/inc/shaarli.css b/inc/shaarli.css index 305afddc..5808320c 100644 --- a/inc/shaarli.css +++ b/inc/shaarli.css @@ -1156,7 +1156,7 @@ ul.errors { } #pluginsadmin .plugin_parameter { - padding: 5px 0; + padding: 10px 0; border-width: 1px 0; border-style: solid; border-color: #c0c0c0; @@ -1164,7 +1164,7 @@ ul.errors { #pluginsadmin .float_label { float: left; - width: 20%; + width: 40%; } #pluginsadmin a { diff --git a/tpl/pluginsadmin.html b/tpl/pluginsadmin.html index 5ddcf061..966360ea 100644 --- a/tpl/pluginsadmin.html +++ b/tpl/pluginsadmin.html @@ -104,11 +104,12 @@

{function="str_replace('_', ' ', $key)"}

- +
{/loop} From 876533e86801246bef893e7124ce044ebf33239f Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 2 Aug 2016 11:04:49 +0200 Subject: [PATCH 3/3] Add a description to wallabag plugin parameters --- plugins/wallabag/wallabag.meta | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/wallabag/wallabag.meta b/plugins/wallabag/wallabag.meta index 26e1ea63..9c93f81c 100644 --- a/plugins/wallabag/wallabag.meta +++ b/plugins/wallabag/wallabag.meta @@ -1,2 +1,4 @@ description="For each link, add a Wallabag icon to save it in your instance." -parameters="WALLABAG_URL;WALLABAG_VERSION" \ No newline at end of file +parameters="WALLABAG_URL;WALLABAG_VERSION" +parameter.WALLABAG_URL="Wallabag API URL" +parameter.WALLABAG_VERSION="Wallabag API version (1 or 2)" \ No newline at end of file