Commit 8b56c23d authored by Robert Lyon's avatar Robert Lyon
Browse files

Adding the sortorder as plugin config option (bug 1233896)



Requires upgrading the plugin to work on administration page
then one can set the sort order on Extensions -> file/folder ->
configuration
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>

Change-Id: I24cda8e7361fc57f66bb391b3cf533c904ba2c38
parent 8f95f681
......@@ -15,3 +15,5 @@ $string['title'] = 'Folder';
$string['description'] = 'A single folder from your files area (see Content -> Files)';
$string['defaulttitledescription'] = 'If you leave this blank, the title of the folder will be used';
$string['foldersettings'] = 'Folder settings';
$string['defaultsortorder'] = 'Default sort order of files';
......@@ -56,6 +56,43 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return $result;
}
public static function has_config() {
return true;
}
public static function get_config_options() {
$elements = array();
$elements['foldersettings'] = array(
'type' => 'fieldset',
'legend' => get_string('foldersettings', 'blocktype.file/folder'),
'collapsible' => false,
'elements' => array(
'sortorder' => array(
'type' => 'select',
'labelhtml' => get_string('defaultsortorder', 'blocktype.file/folder'),
'defaultvalue' => get_config_plugin('blocktype', 'folder', 'sortorder'),
'options' => array(
'asc' => get_string('ascending'),
'desc' => get_string('descending'),
)
)
),
);
return array(
'elements' => $elements,
);
}
public static function save_config_options($values) {
set_config_plugin('blocktype', 'folder', 'sortorder', $values['sortorder']);
}
public static function postinst($prevversion) {
if ($prevversion < 2013120900) {
set_config_plugin('blocktype', 'folder', 'sortorder', 'asc');
}
}
public static function has_instance_config() {
return true;
}
......@@ -69,7 +106,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
'sortorder' => array(
'type' => 'select',
'labelhtml' => get_string('sortorder'),
'defaultvalue' => (isset($configdata['sortorder']) && $configdata['sortorder'] == 'desc') ? 'desc' : 'asc',
'defaultvalue' => isset($configdata['sortorder']) ? $configdata['sortorder'] : get_config_plugin('blocktype', 'folder', 'sortorder'),
'options' => array('asc' => get_string('ascending'), 'desc' => get_string('descending')),
),
);
......
......@@ -12,5 +12,5 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010090800;
$config->release = '1.0.0';
$config->version = 2013120900;
$config->release = '1.0.1';
Supports Markdown
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