From 43a58be79225182cee19d1e02ff24d26d1a5ec61 Mon Sep 17 00:00:00 2001 From: jerome mouneyrac Date: Mon, 20 Sep 2010 07:43:31 +0000 Subject: [PATCH] community block MDL-22890 sort search results --- blocks/community/communitycourse.php | 2 ++ blocks/community/forms.php | 11 +++++++++++ blocks/community/lang/en/block_community.php | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/blocks/community/communitycourse.php b/blocks/community/communitycourse.php index f6896473d8e..2766618f4b9 100644 --- a/blocks/community/communitycourse.php +++ b/blocks/community/communitycourse.php @@ -149,6 +149,8 @@ if (!empty($fromform)) { $options->language = $fromform->language; } + $options->orderby = $fromform->orderby; + //check if the selected hub is from the registered list (in this case we use the private token) $token = 'publichub'; $registrationmanager = new registration_manager(); diff --git a/blocks/community/forms.php b/blocks/community/forms.php index da8638f26e0..3c9fef6f278 100644 --- a/blocks/community/forms.php +++ b/blocks/community/forms.php @@ -214,6 +214,17 @@ class community_hub_search_form extends moodleform { $mform->setDefault('language', 'all'); $mform->addHelpButton('language', 'language', 'block_community'); + $mform->addElement('radio', 'orderby', get_string('orderby', 'block_community'), + get_string('orderbynewest', 'block_community'), 'newest'); + $mform->addElement('radio', 'orderby', null, + get_string('orderbyeldest', 'block_community'), 'eldest'); + $mform->addElement('radio', 'orderby', null, + get_string('orderbyname', 'block_community'), 'fullname'); + $mform->addElement('radio', 'orderby', null, + get_string('orderbypublisher', 'block_community'), 'publisher'); + $mform->setDefault('orderby', 'newest'); + $mform->setType('orderby', PARAM_ALPHA); + $mform->addElement('text', 'search', get_string('keywords', 'block_community')); $mform->addHelpButton('search', 'keywords', 'block_community'); diff --git a/blocks/community/lang/en/block_community.php b/blocks/community/lang/en/block_community.php index 2ca5e4d798f..32a3aaa5524 100644 --- a/blocks/community/lang/en/block_community.php +++ b/blocks/community/lang/en/block_community.php @@ -75,6 +75,12 @@ $string['nocomments'] = 'No comments'; $string['nocourse'] = 'No courses found'; $string['noratings'] = 'No ratings'; $string['operation'] = 'Operation'; +$string['orderby'] = 'Sort by'; +$string['orderby_help'] = 'The order the search results are displayed.'; +$string['orderbynewest'] = 'Newest'; +$string['orderbyeldest'] = 'Eldest'; +$string['orderbyname'] = 'Name'; +$string['orderbypublisher'] = 'Publisher'; $string['outcomes'] = 'Outcomes: {$a}'; $string['pluginname'] = 'Community'; $string['rateandcomment'] = 'Rate and comment';