diff options
author | VirtualTam <virtualtam@flibidi.net> | 2016-08-13 14:48:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-13 14:48:51 +0200 |
commit | 8758bb0ac8cb68d32122009dbcb977d2f0fad2b0 (patch) | |
tree | 586fe98bd463424e152232cb66bee0465e7c74b5 | |
parent | eec3666ba60b20f1db054102ccbd618d3bb79594 (diff) | |
parent | 876533e86801246bef893e7124ce044ebf33239f (diff) | |
download | Shaarli-8758bb0ac8cb68d32122009dbcb977d2f0fad2b0.tar.gz Shaarli-8758bb0ac8cb68d32122009dbcb977d2f0fad2b0.tar.zst Shaarli-8758bb0ac8cb68d32122009dbcb977d2f0fad2b0.zip |
Merge pull request #619 from ArthurHoaro/plugins/param-desc
Add a description to plugin parameters
-rw-r--r-- | application/PluginManager.php | 6 | ||||
-rw-r--r-- | application/config/ConfigPlugin.php | 10 | ||||
-rw-r--r-- | inc/shaarli.css | 4 | ||||
-rw-r--r-- | plugins/wallabag/wallabag.meta | 4 | ||||
-rw-r--r-- | tests/PluginManagerTest.php | 10 | ||||
-rw-r--r-- | tests/config/ConfigPluginTest.php | 12 | ||||
-rw-r--r-- | tests/plugins/test/test.meta | 4 | ||||
-rw-r--r-- | tpl/pluginsadmin.html | 5 |
8 files changed, 37 insertions, 18 deletions
diff --git a/application/PluginManager.php b/application/PluginManager.php index 1afc8d5c..1e132a7f 100644 --- a/application/PluginManager.php +++ b/application/PluginManager.php | |||
@@ -185,7 +185,11 @@ class PluginManager | |||
185 | continue; | 185 | continue; |
186 | } | 186 | } |
187 | 187 | ||
188 | $metaData[$plugin]['parameters'][$param] = ''; | 188 | $metaData[$plugin]['parameters'][$param]['value'] = ''; |
189 | // Optional parameter description in parameter.PARAM_NAME= | ||
190 | if (isset($metaData[$plugin]['parameter.'. $param])) { | ||
191 | $metaData[$plugin]['parameters'][$param]['desc'] = $metaData[$plugin]['parameter.'. $param]; | ||
192 | } | ||
189 | } | 193 | } |
190 | } | 194 | } |
191 | 195 | ||
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) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Affect plugin parameters values into plugins array. | 83 | * Affect plugin parameters values from the ConfigManager into plugins array. |
84 | * | 84 | * |
85 | * @param mixed $plugins Plugins array ($plugins[<plugin_name>]['parameters']['param_name'] = <value>. | 85 | * @param mixed $plugins Plugins array: |
86 | * $plugins[<plugin_name>]['parameters'][<param_name>] = [ | ||
87 | * 'value' => <value>, | ||
88 | * 'desc' => <description> | ||
89 | * ] | ||
86 | * @param mixed $conf Plugins configuration. | 90 | * @param mixed $conf Plugins configuration. |
87 | * | 91 | * |
88 | * @return mixed Updated $plugins array. | 92 | * @return mixed Updated $plugins array. |
@@ -97,7 +101,7 @@ function load_plugin_parameter_values($plugins, $conf) | |||
97 | 101 | ||
98 | foreach ($plugin['parameters'] as $key => $param) { | 102 | foreach ($plugin['parameters'] as $key => $param) { |
99 | if (!empty($conf[$key])) { | 103 | if (!empty($conf[$key])) { |
100 | $out[$name]['parameters'][$key] = $conf[$key]; | 104 | $out[$name]['parameters'][$key]['value'] = $conf[$key]; |
101 | } | 105 | } |
102 | } | 106 | } |
103 | } | 107 | } |
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 { | |||
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | #pluginsadmin .plugin_parameter { | 1158 | #pluginsadmin .plugin_parameter { |
1159 | padding: 5px 0; | 1159 | padding: 10px 0; |
1160 | border-width: 1px 0; | 1160 | border-width: 1px 0; |
1161 | border-style: solid; | 1161 | border-style: solid; |
1162 | border-color: #c0c0c0; | 1162 | border-color: #c0c0c0; |
@@ -1164,7 +1164,7 @@ ul.errors { | |||
1164 | 1164 | ||
1165 | #pluginsadmin .float_label { | 1165 | #pluginsadmin .float_label { |
1166 | float: left; | 1166 | float: left; |
1167 | width: 20%; | 1167 | width: 40%; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | #pluginsadmin a { | 1170 | #pluginsadmin a { |
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 @@ | |||
1 | description="For each link, add a Wallabag icon to save it in your instance." | 1 | description="For each link, add a Wallabag icon to save it in your instance." |
2 | parameters="WALLABAG_URL;WALLABAG_VERSION" \ No newline at end of file | 2 | parameters="WALLABAG_URL;WALLABAG_VERSION" |
3 | parameter.WALLABAG_URL="Wallabag API URL" | ||
4 | parameter.WALLABAG_VERSION="Wallabag API version (1 or 2)" \ No newline at end of file | ||
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index c7511051..ddf48185 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php | |||
@@ -79,8 +79,14 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase | |||
79 | $this->pluginManager->load(array(self::$pluginName)); | 79 | $this->pluginManager->load(array(self::$pluginName)); |
80 | 80 | ||
81 | $expectedParameters = array( | 81 | $expectedParameters = array( |
82 | 'pop' => '', | 82 | 'pop' => array( |
83 | 'hip' => '', | 83 | 'value' => '', |
84 | 'desc' => 'pop description', | ||
85 | ), | ||
86 | 'hip' => array( | ||
87 | 'value' => '', | ||
88 | 'desc' => '', | ||
89 | ), | ||
84 | ); | 90 | ); |
85 | $meta = $this->pluginManager->getPluginsMeta(); | 91 | $meta = $this->pluginManager->getPluginsMeta(); |
86 | $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); | 92 | $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 @@ class ConfigPluginTest extends PHPUnit_Framework_TestCase | |||
101 | $plugins = array( | 101 | $plugins = array( |
102 | 'plugin_name' => array( | 102 | 'plugin_name' => array( |
103 | 'parameters' => array( | 103 | 'parameters' => array( |
104 | 'param1' => true, | 104 | 'param1' => array('value' => true), |
105 | 'param2' => false, | 105 | 'param2' => array('value' => false), |
106 | 'param3' => '', | 106 | 'param3' => array('value' => ''), |
107 | ) | 107 | ) |
108 | ) | 108 | ) |
109 | ); | 109 | ); |
@@ -114,8 +114,8 @@ class ConfigPluginTest extends PHPUnit_Framework_TestCase | |||
114 | ); | 114 | ); |
115 | 115 | ||
116 | $result = load_plugin_parameter_values($plugins, $parameters); | 116 | $result = load_plugin_parameter_values($plugins, $parameters); |
117 | $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']); | 117 | $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']); |
118 | $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']); | 118 | $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']['value']); |
119 | $this->assertEquals('', $result['plugin_name']['parameters']['param3']); | 119 | $this->assertEquals('', $result['plugin_name']['parameters']['param3']['value']); |
120 | } | 120 | } |
121 | } | 121 | } |
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 @@ | |||
1 | description="test plugin" | 1 | description="test plugin" |
2 | parameters="pop;hip" \ No newline at end of file | 2 | parameters="pop;hip" |
3 | parameter.pop="pop description" | ||
4 | parameter.hip= \ No newline at end of file | ||
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 @@ | |||
104 | <div class="plugin_parameter"> | 104 | <div class="plugin_parameter"> |
105 | <div class="float_label"> | 105 | <div class="float_label"> |
106 | <label for="{$key}"> | 106 | <label for="{$key}"> |
107 | <code>{$key}</code> | 107 | <code>{$key}</code><br> |
108 | {$value.desc} | ||
108 | </label> | 109 | </label> |
109 | </div> | 110 | </div> |
110 | <div class="float_input"> | 111 | <div class="float_input"> |
111 | <input name="{$key}" value="{$value}" id="{$key}"/> | 112 | <input name="{$key}" value="{$value.value}" id="{$key}"/> |
112 | </div> | 113 | </div> |
113 | </div> | 114 | </div> |
114 | {/loop} | 115 | {/loop} |