Commit 67a13bc6 authored by lindonb's avatar lindonb

[ENH] PluginModule: add common parameters, use module description for module...

[ENH] PluginModule: add common parameters, use module description for module parameter description and change it when user selects another module, list module parameters first after the module name. TODO: see if individual module cache files could be used and add semi-common parameters.
parent 4b2ac935
......@@ -1321,21 +1321,25 @@ function build_plugin_form( type, index, pageName, pluginArgs, bodyContent, sele
//For PluginModule, add selected module parameters to the plugin edit form
if (type == 'module') {
//tiki_module_params is a global variable set by tiki-jsmodule.php which is loaded by tiki-setup.php
if (typeof tiki_module_params != 'undefined') {
//user has not change the module selection since opening the form
if (typeof selectedMod == 'undefined') {
//pick up the parameters of the saved module parameter
if (typeof pluginArgs.module != 'undefined') {
$.extend(meta.params, tiki_module_params[pluginArgs.module]);
//otherwise pick up the parameters of the first module option since that will be selected automatically
} else {
$.extend(meta.params, tiki_module_params[meta.params.module.options[0].value]);
}
//user has selected another module while the form was open - pick up parameters for the selected module
//isolate the module parameter object so it will be shown first in the form
var onlymod = {"params":{"module": meta.params.module}};
//user has not changed the module selection since opening the form
if (typeof selectedMod == 'undefined') {
//pick up the parameters of the saved module parameter
if (typeof pluginArgs.module != 'undefined') {
//this orders the module parameter first, module related parameters second, other PluginModule parameters besides module last
meta.params = $.extend(onlymod.params, tiki_module_params[pluginArgs.module].params, meta.params);
//Use the module description
meta.params.module.description = tiki_module_params[pluginArgs.module].description;
//otherwise pick up the parameters of the first module option since that will be selected automatically
} else {
$.extend(meta.params, tiki_module_params[selectedMod]);
meta.params = $.extend(onlymod.params, tiki_module_params[meta.params.module.options[0].value].params, meta.params);
meta.params.module.description = tiki_module_params[meta.params.module.options[0].value].description;
}
//user has selected another module while the form was open - pick up parameters for the selected module
} else {
meta.params = $.extend(onlymod.params, tiki_module_params[selectedMod].params, meta.params);
meta.params.module.description = tiki_module_params[selectedMod].description;
}
}
......
......@@ -29,7 +29,6 @@ function wikiplugin_module_info()
'documentation' => 'PluginModule',
'description' => tra('Display a module'),
'prefs' => array( 'wikiplugin_module' ),
'validate' => 'all',
'icon' => 'img/icons/module.png',
'extraparams' =>true,
'tags' => array( 'basic' ),
......@@ -41,18 +40,67 @@ function wikiplugin_module_info()
'default' => '',
'options' => $modules_options,
),
'notitle' =>array(
'required' => false,
'name' => tra('No Title'),
'description' => tra('Select Yes (y) to hide the title (default is to show the title)'),
'options' => array(
array('text' => '', 'value' => ''),
array('text' => tra('Yes'), 'value' => 'y'),
array('text' => tra('No'), 'value' => 'n'),
),
'advanced' => true,
),
'title' => array(
'name' => tra('Module Title'),
'description' => tra('Title to display at the top of the box, assuming No Title is not set to Yes (y).'),
'filter' => 'striptags',
'advanced' => true,
),
'float' => array(
'required' => false,
'name' => tra('Float'),
'description' => tra('Align the module to the left or right on the page allowing other elements to align against it'),
'default' => 'nofloat',
'default' => '',
'advanced' => true,
'options' => array(
array('text' => 'No Float', 'value' => ''),
array('text' => '', 'value' => ''),
array('text' => 'No Float', 'value' => 'nofloat'),
array('text' => tra('Left'), 'value' => 'left'),
array('text' => tra('Right'), 'value' => 'right')
)
),
'max' => array(
'required' => false,
'name' => tra('Max'),
'description' => tra('Number of rows (default: 10)'),
'default' => 10,
'advanced' => true,
),
'np' => array(
'required' => false,
'name' => tra('Parse'),
'description' => tra('Parse wiki syntax.') . ' ' . tra('Default:') . ' ' . tra('No'),
'default' => '1',
'options' => array(
array('text' => '', 'value' => ''),
array('text' => tra('Yes'), 'value' => '0'),
array('text' => tra('No'), 'value' => '1'),
),
'advanced' => true,
),
'nobox' => array(
'name' => tra('No Box'),
'description' => 'y|n '.tra('Show only the content with no box surrounding it.'),
'section' => 'appearance',
'filter' => 'alpha',
'advanced' => true,
'options' => array(
array('text' => '', 'value' => ''),
array('text' => tra('Yes'), 'value' => 'y'),
array('text' => tra('No'), 'value' => 'n')
)
),
'decoration' => array(
'required' => false,
'name' => tra('Decoration'),
......@@ -68,6 +116,7 @@ function wikiplugin_module_info()
'required' => false,
'name' => tra('Flip'),
'description' => tra('Add ability to show/hide the content of the module (default is the site admin setting for modules)'),
'section' => 'appearance',
'options' => array(
array('text' => '', 'value' => ''),
array('text' => tra('Yes'), 'value' => '1'),
......@@ -75,42 +124,121 @@ function wikiplugin_module_info()
),
'advanced' => true,
),
'max' => array(
'required' => false,
'name' => tra('Max'),
'description' => tra('Number of rows (default: 10)'),
'default' => 10,
'advanced' => true,
),
'np' => array(
'bgcolor' => array(
'required' => false,
'name' => tra('Parse'),
'description' => tra('Parse wiki syntax.') . ' ' . tra('Default:') . ' ' . tra('No'),
'default' => '1',
'options' => array(
array('text' => '', 'value' => ''),
array('text' => tra('Yes'), 'value' => '0'),
array('text' => tra('No'), 'value' => '1'),
),
'name' => tra('Title Background'),
'description' => tra('Override the background color for the title (if the title is shown). The value can be a color name (ex: bgcolor=blue) or a hexadecimal value (ex: bgcolor=#FFEBCD)'),
'default' => '',
'filter' => 'striptags',
'advanced' => true,
),
'notitle' =>array(
'required' => false,
'name' => tra('Title'),
'description' => tra('Show/hide module title (default is to show the title)'),
'options' => array(
array('text' => '', 'value' => ''),
array('text' => tra('Show title'), 'value' => 'n'),
array('text' => tra('Hide title'), 'value' => 'y')
)
),
'module_style' => array(
'required' => false,
'name' => tra('Module Style'),
'description' => tra('Inline CSS for the containing DIV element, e.g. "max-width:80%"'),
'filter' => 'striptags',
'default' => '',
'advanced' => true,
),
'style' => array(
'name' => tra('Style'),
'description' => tra('CSS styling for the module data itself.'),
'filter' => 'striptags',
'section' => 'appearance',
'advanced' => true,
),
'topclass' => array(
'name' => tra('Containing Class'),
'description' => tra('Custom CSS class around.'),
'filter' => 'striptags',
'section' => 'appearance',
'advanced' => true,
),
'class' => array(
'name' => tra('Class'),
'description' => tra('Custom CSS class.'),
'section' => 'appearance',
'filter' => 'striptags',
'advanced' => true,
),
'category' => array(
'name' => tra('Category'),
'description' => tra('Module displayed depending on category. Multiple category ids or names can be separated by semi-colons.'),
'section' => 'visibility',
'separator' => ';',
'filter' => 'alnum',
'advanced' => true,
),
'nocategory' => array(
'name' => tra('No Category'),
'description' => tra('Module hidden depending on category. Multiple category ids or names can be separated by semi-colons. This takes precedence over the category parameter above.'),
'section' => 'visibility',
'separator' => ';',
'filter' => 'alnum',
'advanced' => true,
),
'perspective' => array(
'name' => tra('Perspective'),
'description' => tra('Only display the module if in one of the listed perspective IDs. Semi-colon separated.'),
'separator' => ';',
'filter' => 'digits',
'section' => 'visibility',
'advanced' => true,
),
'lang' => array(
'name' => tra('Language'),
'description' => tra('Module only applicable for the specified languages. Languages are defined as two character language codes. Multiple values can be separated by semi-colons.'),
'separator' => ';',
'filter' => 'lang',
'section' => 'visibility',
'advanced' => true,
),
'section' => array(
'name' => tra('Section'),
'description' => tra('Module only applicable for the specified sections. Multiple values can be separated by semi-colons.'),
'separator' => ';',
'filter' => 'striptags',
'section' => 'visibility',
'advanced' => true,
),
'page' => array(
'name' => tra('Page Filter'),
'description' => tra('Module only applicable on the specified page names. Multiple values can be separated by semi-colons.'),
'separator' => ';',
'filter' => 'pagename',
'section' => 'visibility',
'advanced' => true,
),
'nopage' => array(
'name' => tra('No Page'),
'description' => tra('Module not applicable on the specified page names. Multiple values can be separated by semi-colons.'),
'separator' => ';',
'filter' => 'pagename',
'section' => 'visibility',
'advanced' => true,
),
'theme' => array(
'name' => tra('Theme'),
'description' => tra('Module enabled or disabled depending on the theme file name (e.g. "thenews.css"). Specified themes can be either included or excluded. Theme names prefixed by "!" are in the exclusion list. Multiple values can be separated by semi-colons.'),
'separator' => ';',
'filter' => 'themename',
'section' => 'visibility',
'advanced' => true,
),
'creator' => array(
'name' => tra('Creator'),
'description' => tra('Module only available based on the relationship of the user with the wiki page. Either only creators (y) or only non-creators (n) will see the module.'),
'filter' => 'alpha',
'section' => 'visibility',
'advanced' => true,
),
'contributor' => array(
'name' => tra('Contributor'),
'description' => tra('Module only available based on the relationship of the user with the wiki page. Either only contributors (y) or only non-contributors (n) will see the module.'),
'filter' => 'alpha',
'section' => 'visibility',
'advanced' => true,
),
)
);
}
......
......@@ -44,10 +44,8 @@ foreach ( $mods as $mod ):
} else {
$info = false;
}
if (count($info['params']) < 1)
continue;
?>
tiki_module_params.<?php echo $mod ?> = <?php echo json_encode($info['params']) ?>;
tiki_module_params.<?php echo $mod ?> = <?php echo json_encode($info) ?>;
<?php endforeach;
$content = ob_get_contents();
file_put_contents($cache, $content);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment