From 64c2ced1d639da5599209abd69fe307e72743b42 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 24 Jul 2006 22:14:36 +0000 Subject: [PATCH] r942: - Adding ListSorter::fetch_as_text() - Creating a setting for default sort orders --- includes/class_sort.php | 29 +++++++++++++++++++++++++++++ includes/settings.php | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/includes/class_sort.php b/includes/class_sort.php index 2c0c38d..cb1a4c0 100644 --- a/includes/class_sort.php +++ b/includes/class_sort.php @@ -194,6 +194,35 @@ class ListSorter } } + // ################################################################### + /** + * Returns the display text for a given sort order direction + * + * @access public static + * + * @param string Sort direction, or FALSE for the array + * + * @return mixed Display text if param is string, or array of all key=>text if param is NULL + */ + function fetch_as_text($key) + { + global $lang; + + $keys = array( + 'asc' => $lang->string('Ascending'), + 'desc' => $lang->string('Descending'), + ); + + if ($key === false) + { + return $keys; + } + else + { + return $keys["$key"]; + } + } + // ################################################################### /** * Returns a multi-dimensional array with sort by keys indexing arrays diff --git a/includes/settings.php b/includes/settings.php index e782c04..af9b35b 100755 --- a/includes/settings.php +++ b/includes/settings.php @@ -32,6 +32,8 @@ VARNAME => array(CODE, DEFAULT, VOLATILE, NAME, DESCRIPTION); <-- sets up a setting */ +require_once('./includes/class_sort.php'); + // ################################################################### $settings = array( @@ -66,6 +68,8 @@ $settings = array( ':lang' => $lang->string('Bug Listing Display Options'), 'hidestatuses' => array('" . construct_option_select("setting[hidestatuses]", $bugsys->datastore["status"], $bugsys->options["hidestatuses"], "statusid", "status", 0, true) . "', '', false, $lang->string('Hide Statuses on Bug Listings'), $lang->string('Here you can specify which statuses to hide on the bug list displays. Users have options in their controls to change this from these values, and this does not affect searches or the favourites list.')), + 'defaultsortkey' => array('" . construct_option_select("setting[defaultsortkey]", ListSorter::fetch_by_text(false), $bugsys->options["defaultsortkey"]) . "', 'lastpost', false, $lang->string('Default Sort Column'), $lang->string('Select the column to sort bugs by on listings. This is only a default setting which users can override in their preferences.')), + 'defaultsortas' => array('" . construct_option_select("setting[defaultsortas]", ListSorter::fetch_as_text(false), $bugsys->options["defaultsortas"]) . "', 'desc', false, $lang->string('Default Sort Direction'), $lang->string('Specify the default direction to sort bugs in the selected column. This works with and follows the same rules as the Sort Column.')) ), 'pagination' => array( -- 2.22.5