/** * Renders bulk actions for categories. * * @param coursecat $category The currently selected category if there is one. * @return string */ public function category_bulk_actions(coursecat $category = null) { // Resort courses. // Change parent. $strgo = new lang_string('go'); $html = html_writer::start_div('category-bulk-actions bulk-actions'); if (coursecat::can_resort_any()) { $selectoptions = array('selectedcategories' => get_string('selectedcategories'), 'allcategories' => get_string('allcategories')); $form = html_writer::start_div(); if ($category) { $selectoptions = array('thiscategory' => get_string('thiscategory')) + $selectoptions; $form .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentcategoryid', 'value' => $category->id)); } $form .= html_writer::div(html_writer::select($selectoptions, 'selectsortby', 'selectedcategories', false)); $form .= html_writer::div(html_writer::select(array('name' => get_string('sortcategoriesbyname'), 'idnumber' => get_string('sortcategoriesbyidnumber'), 'none' => get_string('dontsortcategories')), 'resortcategoriesby', 'name', false)); $form .= html_writer::div(html_writer::select(array('fullname' => get_string('sortcoursesbyfullname'), 'shortname' => get_string('sortcoursesbyshortname'), 'idnumber' => get_string('sortcoursesbyidnumber'), 'none' => get_string('dontsortcourses')), 'resortcoursesby', 'fullname', false)); $form .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'bulksort', 'value' => get_string('sort'))); $form .= html_writer::end_div(); $html .= $this->detail_pair(get_string('sorting'), $form); } if (coursecat::can_change_parent_any()) { $options = array(); if (has_capability('moodle/category:manage', context_system::instance())) { $options[0] = coursecat::get(0)->get_formatted_name(); } $options += coursecat::make_categories_list('moodle/category:manage'); $select = html_writer::select($options, 'movecategoriesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcategoriesto')); $submit = array('type' => 'submit', 'name' => 'bulkmovecategories', 'value' => get_string('move')); $html .= $this->detail_pair(html_writer::span(get_string('moveselectedcategoriesto'), '', array('id' => 'moveselectedcategoriesto')), $select . html_writer::empty_tag('input', $submit)); } $html .= html_writer::end_div(); return $html; }
/** * Renders bulk actions for categories. * * @param coursecat $category The currently selected category if there is one. * @return string */ public function category_bulk_actions(coursecat $category = null) { // Resort courses. // Change parent. if (!coursecat::can_resort_any() && !coursecat::can_change_parent_any()) { return ''; } $strgo = new lang_string('go'); $html = html_writer::start_div('category-bulk-actions bulk-actions'); $html .= html_writer::div(get_string('categorybulkaction'), 'accesshide', array('tabindex' => '0')); if (coursecat::can_resort_any()) { $selectoptions = array('selectedcategories' => get_string('selectedcategories'), 'allcategories' => get_string('allcategories')); $form = html_writer::start_div(); if ($category) { $selectoptions = array('thiscategory' => get_string('thiscategory')) + $selectoptions; $form .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentcategoryid', 'value' => $category->id)); } $form .= html_writer::div(html_writer::select($selectoptions, 'selectsortby', 'selectedcategories', false, array('aria-label' => get_string('selectcategorysort')))); $form .= html_writer::div(html_writer::select(array('name' => get_string('sortbyx', 'moodle', get_string('categoryname')), 'namedesc' => get_string('sortbyxreverse', 'moodle', get_string('categoryname')), 'idnumber' => get_string('sortbyx', 'moodle', get_string('idnumbercoursecategory')), 'idnumberdesc' => get_string('sortbyxreverse', 'moodle', get_string('idnumbercoursecategory')), 'none' => get_string('dontsortcategories')), 'resortcategoriesby', 'name', false, array('aria-label' => get_string('selectcategorysortby')))); $form .= html_writer::div(html_writer::select(array('fullname' => get_string('sortbyx', 'moodle', get_string('fullnamecourse')), 'fullnamedesc' => get_string('sortbyxreverse', 'moodle', get_string('fullnamecourse')), 'shortname' => get_string('sortbyx', 'moodle', get_string('shortnamecourse')), 'shortnamedesc' => get_string('sortbyxreverse', 'moodle', get_string('shortnamecourse')), 'idnumber' => get_string('sortbyx', 'moodle', get_string('idnumbercourse')), 'idnumberdesc' => get_string('sortbyxreverse', 'moodle', get_string('idnumbercourse')), 'timecreated' => get_string('sortbyx', 'moodle', get_string('timecreatedcourse')), 'timecreateddesc' => get_string('sortbyxreverse', 'moodle', get_string('timecreatedcourse')), 'none' => get_string('dontsortcourses')), 'resortcoursesby', 'fullname', false, array('aria-label' => get_string('selectcoursesortby')))); $form .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'bulksort', 'value' => get_string('sort'))); $form .= html_writer::end_div(); $html .= html_writer::start_div('detail-pair row yui3-g'); $html .= html_writer::div(html_writer::span(get_string('sorting')), 'pair-key span3 yui3-u-1-4'); $html .= html_writer::div($form, 'pair-value span9 yui3-u-3-4'); $html .= html_writer::end_div(); } if (coursecat::can_change_parent_any()) { $options = array(); if (has_capability('moodle/category:manage', context_system::instance())) { $options[0] = coursecat::get(0)->get_formatted_name(); } $options += coursecat::make_categories_list('moodle/category:manage'); $select = html_writer::select($options, 'movecategoriesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcategoriesto')); $submit = array('type' => 'submit', 'name' => 'bulkmovecategories', 'value' => get_string('move')); $html .= $this->detail_pair(html_writer::span(get_string('moveselectedcategoriesto'), '', array('id' => 'moveselectedcategoriesto')), $select . html_writer::empty_tag('input', $submit)); } $html .= html_writer::end_div(); return $html; }