diff --git a/blocks/community/forms.php b/blocks/community/forms.php index 02b679e0c88..c5159119fdb 100644 --- a/blocks/community/forms.php +++ b/blocks/community/forms.php @@ -240,22 +240,11 @@ class community_hub_search_form extends moodleform { $publicationmanager = new course_publish_manager(); $options = $publicationmanager->get_sorted_subjects(); - foreach ($options as $key => &$option) { - $keylength = strlen($key); - if ($keylength == 10) { - $option = "  " . $option; - } else if ($keylength == 12) { - $option = "    " . $option; - } - } - $options = array_merge(array('all' => get_string('any')), $options); - $mform->addElement('select', 'subject', get_string('subject', 'block_community'), + $mform->addElement('searchableselector', 'subject', get_string('subject', 'block_community'), $options, array('id' => 'communitysubject')); $mform->setDefault('subject', $subject); unset($options); $mform->addHelpButton('subject', 'subject', 'block_community'); - $this->init_javascript_enhancement('subject', 'smartselect', - array('selectablecategories' => true, 'mode' => 'compact')); require_once($CFG->libdir . "/licenselib.php"); $licensemanager = new license_manager(); diff --git a/course/publish/forms.php b/course/publish/forms.php index 898c5ac4598..45ccbfb212f 100644 --- a/course/publish/forms.php +++ b/course/publish/forms.php @@ -303,23 +303,12 @@ class course_publication_form extends moodleform { $options = $publicationmanager->get_sorted_subjects(); - //prepare data for the smartselect - foreach ($options as $key => &$option) { - $keylength = strlen($key); - if ($keylength == 10) { - $option = "  " . $option; - } else if ($keylength == 12) { - $option = "    " . $option; - } - } - - $options = array('none' => get_string('none', 'hub')) + $options; - $mform->addElement('select', 'subject', get_string('subject', 'hub'), $options); + $mform->addElement('searchableselector', 'subject', + get_string('subject', 'hub'), $options); unset($options); $mform->addHelpButton('subject', 'subject', 'hub'); $mform->setDefault('subject', $defaultsubject); $mform->addRule('subject', $strrequired, 'required', null, 'client'); - $this->init_javascript_enhancement('subject', 'smartselect', array('selectablecategories' => false, 'mode' => 'compact')); $options = array(); $options[HUB_AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub'); diff --git a/course/publish/lib.php b/course/publish/lib.php index fe13219fce9..af0d5962da5 100644 --- a/course/publish/lib.php +++ b/course/publish/lib.php @@ -267,33 +267,17 @@ class course_publish_manager { public function get_sorted_subjects() { $subjects = get_string_manager()->load_component_strings('edufields', current_language()); - //sort the subjects + // Sort the subjects. + $return = []; asort($subjects); foreach ($subjects as $key => $option) { $keylength = strlen($key); - if ($keylength == 8) { - $toplevel[$key] = $option; - } else if ($keylength == 10) { - $sublevel[substr($key, 0, 8)][$key] = $option; - } else if ($keylength == 12) { - $subsublevel[substr($key, 0, 8)][substr($key, 0, 10)][$key] = $option; + if ($keylength == 12) { + $return[$key] = $option; // We want only selectable categories. } } - - //recreate the initial structure returned by get_string_manager() - $subjects = array(); - foreach ($toplevel as $key => $name) { - $subjects[$key] = $name; - foreach ($sublevel[$key] as $subkey => $subname) { - $subjects[$subkey] = $subname; - foreach ($subsublevel[$key][$subkey] as $subsubkey => $subsubname) { - $subjects[$subsubkey] = $subsubname; - } - } - } - - return $subjects; + return $return; } } -?> +