Merge pull request #619 from ArthurHoaro/plugins/param-desc

Add a description to plugin parameters
This commit is contained in:
VirtualTam 2016-08-13 14:48:51 +02:00 committed by GitHub
commit 8758bb0ac8
8 changed files with 37 additions and 18 deletions

View file

@ -185,7 +185,11 @@ public function getPluginsMeta()
continue; 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];
}
} }
} }

View file

@ -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[<plugin_name>]['parameters']['param_name'] = <value>. * @param mixed $plugins Plugins array:
* $plugins[<plugin_name>]['parameters'][<param_name>] = [
* 'value' => <value>,
* 'desc' => <description>
* ]
* @param mixed $conf Plugins configuration. * @param mixed $conf Plugins configuration.
* *
* @return mixed Updated $plugins array. * @return mixed Updated $plugins array.
@ -97,7 +101,7 @@ function load_plugin_parameter_values($plugins, $conf)
foreach ($plugin['parameters'] as $key => $param) { foreach ($plugin['parameters'] as $key => $param) {
if (!empty($conf[$key])) { if (!empty($conf[$key])) {
$out[$name]['parameters'][$key] = $conf[$key]; $out[$name]['parameters'][$key]['value'] = $conf[$key];
} }
} }
} }

View file

@ -1156,7 +1156,7 @@ ul.errors {
} }
#pluginsadmin .plugin_parameter { #pluginsadmin .plugin_parameter {
padding: 5px 0; padding: 10px 0;
border-width: 1px 0; border-width: 1px 0;
border-style: solid; border-style: solid;
border-color: #c0c0c0; border-color: #c0c0c0;
@ -1164,7 +1164,7 @@ ul.errors {
#pluginsadmin .float_label { #pluginsadmin .float_label {
float: left; float: left;
width: 20%; width: 40%;
} }
#pluginsadmin a { #pluginsadmin a {

View file

@ -1,2 +1,4 @@
description="For each link, add a Wallabag icon to save it in your instance." description="For each link, add a Wallabag icon to save it in your instance."
parameters="WALLABAG_URL;WALLABAG_VERSION" parameters="WALLABAG_URL;WALLABAG_VERSION"
parameter.WALLABAG_URL="Wallabag API URL"
parameter.WALLABAG_VERSION="Wallabag API version (1 or 2)"

View file

@ -79,8 +79,14 @@ public function testGetPluginsMeta()
$this->pluginManager->load(array(self::$pluginName)); $this->pluginManager->load(array(self::$pluginName));
$expectedParameters = array( $expectedParameters = array(
'pop' => '', 'pop' => array(
'hip' => '', 'value' => '',
'desc' => 'pop description',
),
'hip' => array(
'value' => '',
'desc' => '',
),
); );
$meta = $this->pluginManager->getPluginsMeta(); $meta = $this->pluginManager->getPluginsMeta();
$this->assertEquals('test plugin', $meta[self::$pluginName]['description']); $this->assertEquals('test plugin', $meta[self::$pluginName]['description']);

View file

@ -101,9 +101,9 @@ public function testLoadPluginParameterValues()
$plugins = array( $plugins = array(
'plugin_name' => array( 'plugin_name' => array(
'parameters' => array( 'parameters' => array(
'param1' => true, 'param1' => array('value' => true),
'param2' => false, 'param2' => array('value' => false),
'param3' => '', 'param3' => array('value' => ''),
) )
) )
); );
@ -114,8 +114,8 @@ public function testLoadPluginParameterValues()
); );
$result = load_plugin_parameter_values($plugins, $parameters); $result = load_plugin_parameter_values($plugins, $parameters);
$this->assertEquals('value1', $result['plugin_name']['parameters']['param1']); $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']);
$this->assertEquals('value2', $result['plugin_name']['parameters']['param2']); $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']['value']);
$this->assertEquals('', $result['plugin_name']['parameters']['param3']); $this->assertEquals('', $result['plugin_name']['parameters']['param3']['value']);
} }
} }

View file

@ -1,2 +1,4 @@
description="test plugin" description="test plugin"
parameters="pop;hip" parameters="pop;hip"
parameter.pop="pop description"
parameter.hip=

View file

@ -104,11 +104,12 @@ <h2>{function="str_replace('_', ' ', $key)"}</h2>
<div class="plugin_parameter"> <div class="plugin_parameter">
<div class="float_label"> <div class="float_label">
<label for="{$key}"> <label for="{$key}">
<code>{$key}</code> <code>{$key}</code><br>
{$value.desc}
</label> </label>
</div> </div>
<div class="float_input"> <div class="float_input">
<input name="{$key}" value="{$value}" id="{$key}"/> <input name="{$key}" value="{$value.value}" id="{$key}"/>
</div> </div>
</div> </div>
{/loop} {/loop}