Commit e0fecbb7 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Adding the sortorder as plugin config option (bug 1233896)"

parents eee4f445 8b56c23d
...@@ -15,3 +15,5 @@ $string['title'] = 'Folder'; ...@@ -15,3 +15,5 @@ $string['title'] = 'Folder';
$string['description'] = 'A single folder from your files area (see Content -> Files)'; $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['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 { ...@@ -56,6 +56,43 @@ class PluginBlocktypeFolder extends PluginBlocktype {
return $result; 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() { public static function has_instance_config() {
return true; return true;
} }
...@@ -69,7 +106,7 @@ class PluginBlocktypeFolder extends PluginBlocktype { ...@@ -69,7 +106,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
'sortorder' => array( 'sortorder' => array(
'type' => 'select', 'type' => 'select',
'labelhtml' => get_string('sortorder'), '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')), 'options' => array('asc' => get_string('ascending'), 'desc' => get_string('descending')),
), ),
); );
......
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
defined('INTERNAL') || die(); defined('INTERNAL') || die();
$config = new StdClass; $config = new StdClass;
$config->version = 2010090800; $config->version = 2013120900;
$config->release = '1.0.0'; $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