| Línea 60... |
Línea 60... |
| 60 |
'moodle'
|
60 |
'moodle'
|
| 61 |
);
|
61 |
);
|
| 62 |
}
|
62 |
}
|
| Línea 63... |
Línea 63... |
| 63 |
|
63 |
|
| 64 |
/**
|
- |
|
| 65 |
* @deprecated since Moodle 4.0. This is now handled/replaced with the tertiary navigation
|
- |
|
| 66 |
*/
|
- |
|
| 67 |
#[\core\attribute\deprecated(
|
- |
|
| 68 |
replacement: 'manage_categories_action_bar',
|
- |
|
| 69 |
since: '4.0',
|
- |
|
| 70 |
mdl: 'MDL-73462',
|
- |
|
| 71 |
final: true,
|
- |
|
| 72 |
)]
|
- |
|
| 73 |
public function management_heading() {
|
- |
|
| 74 |
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
- |
|
| 75 |
}
|
- |
|
| 76 |
|
- |
|
| 77 |
/**
|
64 |
/**
|
| 78 |
* Prepares the form element for the course category listing bulk actions.
|
65 |
* Prepares the form element for the course category listing bulk actions.
|
| 79 |
*
|
66 |
*
|
| 80 |
* @return string
|
67 |
* @return string
|
| 81 |
*/
|
68 |
*/
|
| Línea 101... |
Línea 88... |
| 101 |
* Presents a course category listing.
|
88 |
* Presents a course category listing.
|
| 102 |
*
|
89 |
*
|
| 103 |
* @param core_course_category $category The currently selected category. Also the category to highlight in the listing.
|
90 |
* @param core_course_category $category The currently selected category. Also the category to highlight in the listing.
|
| 104 |
* @return string
|
91 |
* @return string
|
| 105 |
*/
|
92 |
*/
|
| 106 |
public function category_listing(core_course_category $category = null) {
|
93 |
public function category_listing(?core_course_category $category = null) {
|
| Línea 107... |
Línea 94... |
| 107 |
|
94 |
|
| 108 |
if ($category === null) {
|
95 |
if ($category === null) {
|
| 109 |
$selectedparents = array();
|
96 |
$selectedparents = array();
|
| 110 |
$selectedcategory = null;
|
97 |
$selectedcategory = null;
|
| Línea 117... |
Línea 104... |
| 117 |
$catatlevel[] = array_shift($selectedparents);
|
104 |
$catatlevel[] = array_shift($selectedparents);
|
| 118 |
$catatlevel = array_unique($catatlevel);
|
105 |
$catatlevel = array_unique($catatlevel);
|
| Línea 119... |
Línea 106... |
| 119 |
|
106 |
|
| Línea 120... |
Línea 107... |
| 120 |
$listing = core_course_category::top()->get_children();
|
107 |
$listing = core_course_category::top()->get_children();
|
| 121 |
|
108 |
|
| 122 |
$attributes = array(
|
109 |
$attributes = [
|
| 123 |
'class' => 'ml-1 list-unstyled',
|
110 |
'class' => 'ms-1 list-unstyled category-list list-group',
|
| 124 |
'role' => 'tree',
|
111 |
'role' => 'tree',
|
| Línea 125... |
Línea 112... |
| 125 |
'aria-labelledby' => 'category-listing-title'
|
112 |
'aria-labelledby' => 'category-listing-title',
|
| 126 |
);
|
113 |
];
|
| 127 |
|
114 |
|
| 128 |
$html = html_writer::start_div('category-listing card w-100');
|
115 |
$html = html_writer::start_div('category-listing card w-100');
|
| Línea 176... |
Línea 163... |
| 176 |
'data-expandable' => $isexpandable ? '1' : '0',
|
163 |
'data-expandable' => $isexpandable ? '1' : '0',
|
| 177 |
'data-expanded' => $isexpanded ? '1' : '0',
|
164 |
'data-expanded' => $isexpanded ? '1' : '0',
|
| 178 |
'data-selected' => $activecategory ? '1' : '0',
|
165 |
'data-selected' => $activecategory ? '1' : '0',
|
| 179 |
'data-visible' => $category->visible ? '1' : '0',
|
166 |
'data-visible' => $category->visible ? '1' : '0',
|
| 180 |
'role' => 'treeitem',
|
167 |
'role' => 'treeitem',
|
| 181 |
'aria-expanded' => $isexpanded ? 'true' : 'false'
|
168 |
'aria-expanded' => $isexpanded ? 'true' : 'false',
|
| - |
|
169 |
'data-course-count' => $category->get_courses_count(['recursive' => 1]),
|
| - |
|
170 |
'data-category-name' => $category->get_formatted_name(),
|
| 182 |
);
|
171 |
);
|
| 183 |
$text = $category->get_formatted_name();
|
172 |
$text = $category->get_formatted_name();
|
| 184 |
if (($parent = $category->get_parent_coursecat()) && $parent->id) {
|
173 |
if (($parent = $category->get_parent_coursecat()) && $parent->id) {
|
| 185 |
$a = new stdClass;
|
174 |
$a = new stdClass;
|
| 186 |
$a->category = $text;
|
175 |
$a->category = $text;
|
| 187 |
$a->parentcategory = $parent->get_formatted_name();
|
176 |
$a->parentcategory = $parent->get_formatted_name();
|
| 188 |
$textlabel = get_string('categorysubcategoryof', 'moodle', $a);
|
177 |
$textlabel = get_string('categorysubcategoryof', 'moodle', $a);
|
| 189 |
}
|
178 |
}
|
| 190 |
$courseicon = $this->output->pix_icon('i/course', get_string('courses'));
|
179 |
$courseicon = $this->output->pix_icon('i/course', get_string('courses'), 'core', ['class' => 'ps-1']);
|
| 191 |
$bcatinput = array(
|
180 |
$bcatinput = array(
|
| 192 |
'id' => 'categorylistitem' . $category->id,
|
181 |
'id' => 'categorylistitem' . $category->id,
|
| 193 |
'type' => 'checkbox',
|
182 |
'type' => 'checkbox',
|
| 194 |
'name' => 'bcat[]',
|
183 |
'name' => 'bcat[]',
|
| 195 |
'value' => $category->id,
|
184 |
'value' => $category->id,
|
| 196 |
'class' => 'bulk-action-checkbox custom-control-input',
|
185 |
'class' => 'bulk-action-checkbox form-check-input',
|
| 197 |
'data-action' => 'select'
|
186 |
'data-action' => 'select'
|
| 198 |
);
|
187 |
);
|
| Línea 199... |
Línea 188... |
| 199 |
|
188 |
|
| 200 |
$checkboxclass = '';
|
189 |
$checkboxclass = '';
|
| Línea 209... |
Línea 198... |
| 209 |
'moodle', array('class' => 'tree-icon', 'title' => ''));
|
198 |
'moodle', array('class' => 'tree-icon', 'title' => ''));
|
| 210 |
$icon = html_writer::link(
|
199 |
$icon = html_writer::link(
|
| 211 |
$viewcaturl,
|
200 |
$viewcaturl,
|
| 212 |
$icon,
|
201 |
$icon,
|
| 213 |
array(
|
202 |
array(
|
| 214 |
'class' => 'float-left',
|
203 |
'class' => 'float-start',
|
| 215 |
'data-action' => 'collapse',
|
204 |
'data-action' => 'collapse',
|
| 216 |
'title' => get_string('collapsecategory', 'moodle', $text),
|
205 |
'title' => get_string('collapsecategory', 'moodle', $text),
|
| 217 |
'aria-controls' => 'subcategoryof'.$category->id
|
206 |
'aria-controls' => 'subcategoryof'.$category->id
|
| 218 |
)
|
207 |
)
|
| 219 |
);
|
208 |
);
|
| Línea 222... |
Línea 211... |
| 222 |
'moodle', array('class' => 'tree-icon', 'title' => ''));
|
211 |
'moodle', array('class' => 'tree-icon', 'title' => ''));
|
| 223 |
$icon = html_writer::link(
|
212 |
$icon = html_writer::link(
|
| 224 |
$viewcaturl,
|
213 |
$viewcaturl,
|
| 225 |
$icon,
|
214 |
$icon,
|
| 226 |
array(
|
215 |
array(
|
| 227 |
'class' => 'float-left',
|
216 |
'class' => 'float-start',
|
| 228 |
'data-action' => 'expand',
|
217 |
'data-action' => 'expand',
|
| 229 |
'title' => get_string('expandcategory', 'moodle', $text)
|
218 |
'title' => get_string('expandcategory', 'moodle', $text)
|
| 230 |
)
|
219 |
)
|
| 231 |
);
|
220 |
);
|
| 232 |
} else {
|
221 |
} else {
|
| 233 |
$icon = $this->output->pix_icon(
|
222 |
$icon = $this->output->pix_icon(
|
| 234 |
'i/empty',
|
223 |
'i/navigationitem',
|
| 235 |
'',
|
224 |
'',
|
| 236 |
'moodle',
|
225 |
'moodle',
|
| 237 |
array('class' => 'tree-icon'));
|
226 |
array('class' => 'tree-icon'));
|
| 238 |
$icon = html_writer::span($icon, 'float-left');
|
227 |
$icon = html_writer::span($icon, 'float-start');
|
| 239 |
}
|
228 |
}
|
| 240 |
$actions = \core_course\management\helper::get_category_listitem_actions($category);
|
229 |
$actions = \core_course\management\helper::get_category_listitem_actions($category);
|
| 241 |
$hasactions = !empty($actions) || $category->can_create_course();
|
230 |
$hasactions = !empty($actions) || $category->can_create_course();
|
| Línea 242... |
Línea 231... |
| 242 |
|
231 |
|
| 243 |
$html = html_writer::start_tag('li', $attributes);
|
232 |
$html = html_writer::start_tag('li', $attributes);
|
| 244 |
$html .= html_writer::start_div('clearfix');
|
233 |
$html .= html_writer::start_div('clearfix');
|
| 245 |
$html .= html_writer::start_div('float-left ' . $checkboxclass);
|
234 |
$html .= html_writer::start_div('float-start ' . $checkboxclass);
|
| 246 |
$html .= html_writer::start_div('custom-control custom-checkbox mr-1 ');
|
235 |
$html .= html_writer::start_div('form-check me-1 ');
|
| 247 |
$html .= html_writer::empty_tag('input', $bcatinput);
|
236 |
$html .= html_writer::empty_tag('input', $bcatinput);
|
| 248 |
$labeltext = html_writer::span(get_string('bulkactionselect', 'moodle', $text), 'sr-only');
|
237 |
$labeltext = html_writer::span(get_string('bulkactionselect', 'moodle', $text), 'visually-hidden');
|
| 249 |
$html .= html_writer::tag('label', $labeltext, array(
|
238 |
$html .= html_writer::tag('label', $labeltext, array(
|
| 250 |
'class' => 'custom-control-label',
|
239 |
'class' => 'form-check-label',
|
| 251 |
'for' => 'categorylistitem' . $category->id));
|
240 |
'for' => 'categorylistitem' . $category->id));
|
| 252 |
$html .= html_writer::end_div();
|
241 |
$html .= html_writer::end_div();
|
| 253 |
$html .= html_writer::end_div();
|
242 |
$html .= html_writer::end_div();
|
| 254 |
$html .= $icon;
|
243 |
$html .= $icon;
|
| 255 |
if ($hasactions) {
|
244 |
if ($hasactions) {
|
| 256 |
$textattributes = array('class' => 'float-left categoryname aalink');
|
245 |
$textattributes = array('class' => 'float-start categoryname aalink');
|
| 257 |
} else {
|
246 |
} else {
|
| 258 |
$textattributes = array('class' => 'float-left categoryname without-actions');
|
247 |
$textattributes = array('class' => 'float-start categoryname without-actions');
|
| 259 |
}
|
248 |
}
|
| 260 |
if (isset($textlabel)) {
|
249 |
if (isset($textlabel)) {
|
| 261 |
$textattributes['aria-label'] = $textlabel;
|
250 |
$textattributes['aria-label'] = $textlabel;
|
| 262 |
}
|
251 |
}
|
| 263 |
$html .= html_writer::link($viewcaturl, $text, $textattributes);
|
252 |
$html .= html_writer::link($viewcaturl, $text, $textattributes);
|
| 264 |
$html .= html_writer::start_div('float-right d-flex');
|
253 |
$html .= html_writer::start_div('float-end d-flex');
|
| 265 |
if ($category->idnumber) {
|
254 |
if ($category->idnumber) {
|
| 266 |
$html .= html_writer::tag('span', s($category->idnumber), array('class' => 'text-muted idnumber'));
|
255 |
$html .= html_writer::tag('span', s($category->idnumber), array('class' => 'text-muted idnumber'));
|
| 267 |
}
|
256 |
}
|
| 268 |
if ($hasactions) {
|
257 |
if ($hasactions) {
|
| Línea 307... |
Línea 296... |
| 307 |
* That happens through category_listitem_actions.
|
296 |
* That happens through category_listitem_actions.
|
| 308 |
*
|
297 |
*
|
| 309 |
* @param core_course_category $category
|
298 |
* @param core_course_category $category
|
| 310 |
* @return string
|
299 |
* @return string
|
| 311 |
*/
|
300 |
*/
|
| 312 |
public function category_listing_actions(core_course_category $category = null) {
|
301 |
public function category_listing_actions(?core_course_category $category = null) {
|
| 313 |
$actions = array();
|
302 |
$actions = array();
|
| Línea 314... |
Línea 303... |
| 314 |
|
303 |
|
| 315 |
$cancreatecategory = $category && $category->can_create_subcategory();
|
304 |
$cancreatecategory = $category && $category->can_create_subcategory();
|
| 316 |
$cancreatecategory = $cancreatecategory || core_course_category::can_create_top_level_category();
|
305 |
$cancreatecategory = $cancreatecategory || core_course_category::can_create_top_level_category();
|
| Línea 336... |
Línea 325... |
| 336 |
*
|
325 |
*
|
| 337 |
* @param core_course_category $category
|
326 |
* @param core_course_category $category
|
| 338 |
* @param array $actions
|
327 |
* @param array $actions
|
| 339 |
* @return string
|
328 |
* @return string
|
| 340 |
*/
|
329 |
*/
|
| 341 |
public function category_listitem_actions(core_course_category $category, array $actions = null) {
|
330 |
public function category_listitem_actions(core_course_category $category, ?array $actions = null) {
|
| 342 |
if ($actions === null) {
|
331 |
if ($actions === null) {
|
| 343 |
$actions = \core_course\management\helper::get_category_listitem_actions($category);
|
332 |
$actions = \core_course\management\helper::get_category_listitem_actions($category);
|
| 344 |
}
|
333 |
}
|
| 345 |
$menu = new action_menu();
|
334 |
$menu = new action_menu();
|
| 346 |
$menu->attributes['class'] .= ' category-item-actions item-actions';
|
335 |
$menu->attributes['class'] .= ' category-item-actions item-actions';
|
| Línea 373... |
Línea 362... |
| 373 |
* Renders bulk actions for categories.
|
362 |
* Renders bulk actions for categories.
|
| 374 |
*
|
363 |
*
|
| 375 |
* @param core_course_category $category The currently selected category if there is one.
|
364 |
* @param core_course_category $category The currently selected category if there is one.
|
| 376 |
* @return string
|
365 |
* @return string
|
| 377 |
*/
|
366 |
*/
|
| 378 |
public function category_bulk_actions(core_course_category $category = null) {
|
367 |
public function category_bulk_actions(?core_course_category $category = null) {
|
| 379 |
// Resort courses.
|
368 |
// Resort courses.
|
| 380 |
// Change parent.
|
369 |
// Change parent.
|
| 381 |
if (!core_course_category::can_resort_any() && !core_course_category::can_change_parent_any()) {
|
370 |
if (!core_course_category::can_resort_any() && !core_course_category::can_change_parent_any()) {
|
| 382 |
return '';
|
371 |
return '';
|
| 383 |
}
|
372 |
}
|
| Línea 456... |
Línea 445... |
| 456 |
$select = html_writer::select(
|
445 |
$select = html_writer::select(
|
| 457 |
$options,
|
446 |
$options,
|
| 458 |
'movecategoriesto',
|
447 |
'movecategoriesto',
|
| 459 |
'',
|
448 |
'',
|
| 460 |
array('' => 'choosedots'),
|
449 |
array('' => 'choosedots'),
|
| 461 |
array('aria-labelledby' => 'moveselectedcategoriesto', 'class' => 'mr-1')
|
450 |
array('aria-labelledby' => 'moveselectedcategoriesto', 'class' => 'me-1')
|
| 462 |
);
|
451 |
);
|
| 463 |
$submit = array('type' => 'submit', 'name' => 'bulkmovecategories', 'value' => get_string('move'),
|
452 |
$submit = array('type' => 'submit', 'name' => 'bulkmovecategories', 'value' => get_string('move'),
|
| 464 |
'class' => 'btn btn-secondary');
|
453 |
'class' => 'btn btn-secondary');
|
| 465 |
$html .= $this->detail_pair(
|
454 |
$html .= $this->detail_pair(
|
| 466 |
html_writer::span(get_string('moveselectedcategoriesto'), '', array('id' => 'moveselectedcategoriesto')),
|
455 |
html_writer::span(get_string('moveselectedcategoriesto'), '', array('id' => 'moveselectedcategoriesto')),
|
| Línea 479... |
Línea 468... |
| 479 |
* @param int $page The page being displayed.
|
468 |
* @param int $page The page being displayed.
|
| 480 |
* @param int $perpage The number of courses to display per page.
|
469 |
* @param int $perpage The number of courses to display per page.
|
| 481 |
* @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'.
|
470 |
* @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'.
|
| 482 |
* @return string
|
471 |
* @return string
|
| 483 |
*/
|
472 |
*/
|
| 484 |
public function course_listing(core_course_category $category = null, core_course_list_element $course = null,
|
473 |
public function course_listing(?core_course_category $category = null, ?core_course_list_element $course = null,
|
| 485 |
$page = 0, $perpage = 20, $viewmode = 'default') {
|
474 |
$page = 0, $perpage = 20, $viewmode = 'default') {
|
| Línea 486... |
Línea 475... |
| 486 |
|
475 |
|
| 487 |
if ($category === null) {
|
476 |
if ($category === null) {
|
| 488 |
$html = html_writer::start_div('select-a-category');
|
477 |
$html = html_writer::start_div('select-a-category');
|
| Línea 523... |
Línea 512... |
| 523 |
$html .= html_writer::tag('h3', $category->get_formatted_name(),
|
512 |
$html .= html_writer::tag('h3', $category->get_formatted_name(),
|
| 524 |
array('id' => 'course-listing-title', 'tabindex' => '0', 'class' => 'card-header'));
|
513 |
array('id' => 'course-listing-title', 'tabindex' => '0', 'class' => 'card-header'));
|
| 525 |
$html .= html_writer::start_div('card-body');
|
514 |
$html .= html_writer::start_div('card-body');
|
| 526 |
$html .= $this->course_listing_actions($category, $course, $perpage);
|
515 |
$html .= $this->course_listing_actions($category, $course, $perpage);
|
| 527 |
$html .= $this->listing_pagination($category, $page, $perpage, false, $viewmode);
|
516 |
$html .= $this->listing_pagination($category, $page, $perpage, false, $viewmode);
|
| 528 |
$html .= html_writer::start_tag('ul', array('class' => 'ml course-list'));
|
517 |
$html .= html_writer::start_tag('ul', ['class' => 'course-list list-group', 'role' => 'list']);
|
| 529 |
foreach ($category->get_courses($options) as $listitem) {
|
518 |
foreach ($category->get_courses($options) as $listitem) {
|
| 530 |
$html .= $this->course_listitem($category, $listitem, $courseid);
|
519 |
$html .= $this->course_listitem($category, $listitem, $courseid);
|
| 531 |
}
|
520 |
}
|
| 532 |
$html .= html_writer::end_tag('ul');
|
521 |
$html .= html_writer::end_tag('ul');
|
| 533 |
$html .= $this->listing_pagination($category, $page, $perpage, true, $viewmode);
|
522 |
$html .= $this->listing_pagination($category, $page, $perpage, true, $viewmode);
|
| Línea 601... |
Línea 590... |
| 601 |
$bulkcourseinput = array(
|
590 |
$bulkcourseinput = array(
|
| 602 |
'id' => 'courselistitem' . $course->id,
|
591 |
'id' => 'courselistitem' . $course->id,
|
| 603 |
'type' => 'checkbox',
|
592 |
'type' => 'checkbox',
|
| 604 |
'name' => 'bc[]',
|
593 |
'name' => 'bc[]',
|
| 605 |
'value' => $course->id,
|
594 |
'value' => $course->id,
|
| 606 |
'class' => 'bulk-action-checkbox custom-control-input',
|
595 |
'class' => 'bulk-action-checkbox form-check-input',
|
| 607 |
'data-action' => 'select'
|
596 |
'data-action' => 'select'
|
| 608 |
);
|
597 |
);
|
| Línea 609... |
Línea 598... |
| 609 |
|
598 |
|
| 610 |
$checkboxclass = '';
|
599 |
$checkboxclass = '';
|
| Línea 618... |
Línea 607... |
| 618 |
$html = html_writer::start_tag('li', $attributes);
|
607 |
$html = html_writer::start_tag('li', $attributes);
|
| 619 |
$html .= html_writer::start_div('d-flex flex-wrap');
|
608 |
$html .= html_writer::start_div('d-flex flex-wrap');
|
| Línea 620... |
Línea 609... |
| 620 |
|
609 |
|
| 621 |
if ($category->can_resort_courses()) {
|
610 |
if ($category->can_resort_courses()) {
|
| 622 |
// In order for dnd to be available the user must be able to resort the category children..
|
611 |
// In order for dnd to be available the user must be able to resort the category children..
|
| 623 |
$html .= html_writer::div($this->output->pix_icon('i/move_2d', get_string('dndcourse')), 'float-left drag-handle');
|
612 |
$html .= html_writer::div($this->output->pix_icon('i/move_2d', get_string('dndcourse')), 'float-start drag-handle');
|
| Línea 624... |
Línea 613... |
| 624 |
}
|
613 |
}
|
| 625 |
|
614 |
|
| 626 |
$html .= html_writer::start_div('float-left ' . $checkboxclass);
|
615 |
$html .= html_writer::start_div('float-start ' . $checkboxclass);
|
| 627 |
$html .= html_writer::start_div('custom-control custom-checkbox mr-1 ');
|
616 |
$html .= html_writer::start_div('form-check me-1 ');
|
| 628 |
$html .= html_writer::empty_tag('input', $bulkcourseinput);
|
617 |
$html .= html_writer::empty_tag('input', $bulkcourseinput);
|
| 629 |
$labeltext = html_writer::span(get_string('bulkactionselect', 'moodle', $text), 'sr-only');
|
618 |
$labeltext = html_writer::span(get_string('bulkactionselect', 'moodle', $text), 'visually-hidden');
|
| 630 |
$html .= html_writer::tag('label', $labeltext, array(
|
619 |
$html .= html_writer::tag('label', $labeltext, array(
|
| 631 |
'class' => 'custom-control-label',
|
620 |
'class' => 'form-check-label',
|
| 632 |
'for' => 'courselistitem' . $course->id));
|
621 |
'for' => 'courselistitem' . $course->id));
|
| 633 |
$html .= html_writer::end_div();
|
622 |
$html .= html_writer::end_div();
|
| 634 |
$html .= html_writer::end_div();
|
623 |
$html .= html_writer::end_div();
|
| 635 |
$html .= html_writer::link(
|
624 |
$html .= html_writer::link(
|
| 636 |
$viewcourseurl, $text, array('class' => 'text-break col pl-0 mb-2 coursename aalink')
|
625 |
$viewcourseurl, $text, array('class' => 'text-break col ps-0 mb-2 coursename aalink')
|
| 637 |
);
|
626 |
);
|
| 638 |
$html .= html_writer::start_div('flex-shrink-0 ml-auto');
|
627 |
$html .= html_writer::start_div('flex-shrink-0 ms-auto');
|
| 639 |
if ($course->idnumber) {
|
628 |
if ($course->idnumber) {
|
| 640 |
$html .= html_writer::tag('span', s($course->idnumber), array('class' => 'text-muted idnumber'));
|
629 |
$html .= html_writer::tag('span', s($course->idnumber), array('class' => 'text-muted idnumber'));
|
| 641 |
}
|
630 |
}
|
| Línea 654... |
Línea 643... |
| 654 |
* @param core_course_category $category
|
643 |
* @param core_course_category $category
|
| 655 |
* @param core_course_list_element $course The currently selected course.
|
644 |
* @param core_course_list_element $course The currently selected course.
|
| 656 |
* @param int $perpage
|
645 |
* @param int $perpage
|
| 657 |
* @return string
|
646 |
* @return string
|
| 658 |
*/
|
647 |
*/
|
| 659 |
public function course_listing_actions(core_course_category $category, core_course_list_element $course = null, $perpage = 20) {
|
648 |
public function course_listing_actions(core_course_category $category, ?core_course_list_element $course = null, $perpage = 20) {
|
| 660 |
$actions = array();
|
649 |
$actions = array();
|
| 661 |
if ($category->can_create_course()) {
|
650 |
if ($category->can_create_course()) {
|
| 662 |
$url = new moodle_url('/course/edit.php', array('category' => $category->id, 'returnto' => 'catmanage'));
|
651 |
$url = new moodle_url('/course/edit.php', array('category' => $category->id, 'returnto' => 'catmanage'));
|
| 663 |
$actions[] = html_writer::link($url, get_string('createnewcourse'), array('class' => 'btn btn-secondary'));
|
652 |
$actions[] = html_writer::link($url, get_string('createnewcourse'), array('class' => 'btn btn-secondary'));
|
| 664 |
}
|
653 |
}
|
| Línea 722... |
Línea 711... |
| 722 |
$perpage = $strall;
|
711 |
$perpage = $strall;
|
| 723 |
}
|
712 |
}
|
| 724 |
$menu->attributes['class'] .= ' courses-per-page';
|
713 |
$menu->attributes['class'] .= ' courses-per-page';
|
| 725 |
$menu->set_menu_trigger(get_string('perpagea', 'moodle', $perpage));
|
714 |
$menu->set_menu_trigger(get_string('perpagea', 'moodle', $perpage));
|
| 726 |
$actions[] = $this->render($menu);
|
715 |
$actions[] = $this->render($menu);
|
| 727 |
return html_writer::div(join(' ', $actions), 'listing-actions course-listing-actions');
|
716 |
return html_writer::div(join(' ', $actions), 'listing-actions course-listing-actions mb-3');
|
| 728 |
}
|
717 |
}
|
| Línea 729... |
Línea 718... |
| 729 |
|
718 |
|
| 730 |
/**
|
719 |
/**
|
| 731 |
* Renderers actions for individual course actions.
|
720 |
* Renderers actions for individual course actions.
|
| Línea 742... |
Línea 731... |
| 742 |
$actionshtml = array();
|
731 |
$actionshtml = array();
|
| 743 |
foreach ($actions as $action) {
|
732 |
foreach ($actions as $action) {
|
| 744 |
$action['attributes']['role'] = 'button';
|
733 |
$action['attributes']['role'] = 'button';
|
| 745 |
$actionshtml[] = $this->output->action_icon($action['url'], $action['icon'], null, $action['attributes']);
|
734 |
$actionshtml[] = $this->output->action_icon($action['url'], $action['icon'], null, $action['attributes']);
|
| 746 |
}
|
735 |
}
|
| 747 |
return html_writer::span(join('', $actionshtml), 'course-item-actions item-actions mr-0');
|
736 |
return html_writer::span(join('', $actionshtml), 'course-item-actions item-actions me-0');
|
| 748 |
}
|
737 |
}
|
| Línea 749... |
Línea 738... |
| 749 |
|
738 |
|
| 750 |
/**
|
739 |
/**
|
| 751 |
* Renderers bulk actions that can be performed on courses.
|
740 |
* Renderers bulk actions that can be performed on courses.
|
| Línea 762... |
Línea 751... |
| 762 |
$select = html_writer::select(
|
751 |
$select = html_writer::select(
|
| 763 |
$options,
|
752 |
$options,
|
| 764 |
'movecoursesto',
|
753 |
'movecoursesto',
|
| 765 |
'',
|
754 |
'',
|
| 766 |
array('' => 'choosedots'),
|
755 |
array('' => 'choosedots'),
|
| 767 |
array('aria-labelledby' => 'moveselectedcoursesto', 'class' => 'mr-1')
|
756 |
array('aria-labelledby' => 'moveselectedcoursesto', 'class' => 'me-1')
|
| 768 |
);
|
757 |
);
|
| 769 |
$submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'),
|
758 |
$submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'),
|
| 770 |
'class' => 'btn btn-secondary');
|
759 |
'class' => 'btn btn-secondary');
|
| 771 |
$html .= $this->detail_pair(
|
760 |
$html .= $this->detail_pair(
|
| 772 |
html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')),
|
761 |
html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')),
|
| Línea 836... |
Línea 825... |
| 836 |
* @param string $class
|
825 |
* @param string $class
|
| 837 |
* @return string
|
826 |
* @return string
|
| 838 |
*/
|
827 |
*/
|
| 839 |
protected function detail_pair($key, $value, $class ='') {
|
828 |
protected function detail_pair($key, $value, $class ='') {
|
| 840 |
$html = html_writer::start_div('detail-pair row yui3-g '.preg_replace('#[^a-zA-Z0-9_\-]#', '-', $class));
|
829 |
$html = html_writer::start_div('detail-pair row yui3-g '.preg_replace('#[^a-zA-Z0-9_\-]#', '-', $class));
|
| 841 |
$html .= html_writer::div(html_writer::span($key), 'pair-key col-md-3 yui3-u-1-4 font-weight-bold');
|
830 |
$html .= html_writer::div(html_writer::span($key), 'pair-key col-md-3 yui3-u-1-4 fw-bold');
|
| 842 |
$html .= html_writer::div(html_writer::span($value), 'pair-value col-md-8 yui3-u-3-4');
|
831 |
$html .= html_writer::div(html_writer::div($value, 'd-flex'), 'pair-value col-md-8 yui3-u-3-4');
|
| 843 |
$html .= html_writer::end_div();
|
832 |
$html .= html_writer::end_div();
|
| 844 |
return $html;
|
833 |
return $html;
|
| 845 |
}
|
834 |
}
|
| Línea 846... |
Línea 835... |
| 846 |
|
835 |
|
| Línea 856... |
Línea 845... |
| 856 |
return '';
|
845 |
return '';
|
| 857 |
}
|
846 |
}
|
| 858 |
$options = array();
|
847 |
$options = array();
|
| 859 |
foreach ($actions as $action) {
|
848 |
foreach ($actions as $action) {
|
| 860 |
$options[] = $this->action_link($action['url'], $action['string'], null,
|
849 |
$options[] = $this->action_link($action['url'], $action['string'], null,
|
| 861 |
array('class' => 'btn btn-sm btn-secondary mr-1 mb-3'));
|
850 |
array('class' => 'btn btn-sm btn-secondary me-1 mb-3'));
|
| 862 |
}
|
851 |
}
|
| 863 |
return html_writer::div(join('', $options), 'listing-actions course-detail-listing-actions');
|
852 |
return html_writer::div(join('', $options), 'listing-actions course-detail-listing-actions');
|
| 864 |
}
|
853 |
}
|
| Línea 865... |
Línea 854... |
| 865 |
|
854 |
|
| Línea 982... |
Línea 971... |
| 982 |
* @param component_action $action
|
971 |
* @param component_action $action
|
| 983 |
* @param array $attributes associative array of html link attributes + disabled
|
972 |
* @param array $attributes associative array of html link attributes + disabled
|
| 984 |
* @param bool $linktext show title next to image in link
|
973 |
* @param bool $linktext show title next to image in link
|
| 985 |
* @return string HTML fragment
|
974 |
* @return string HTML fragment
|
| 986 |
*/
|
975 |
*/
|
| 987 |
public function action_icon($url, pix_icon $pixicon, component_action $action = null,
|
976 |
public function action_icon($url, pix_icon $pixicon, ?component_action $action = null,
|
| 988 |
array $attributes = null, $linktext = false) {
|
977 |
?array $attributes = null, $linktext = false) {
|
| 989 |
if (!($url instanceof moodle_url)) {
|
978 |
if (!($url instanceof moodle_url)) {
|
| 990 |
$url = new moodle_url($url);
|
979 |
$url = new moodle_url($url);
|
| 991 |
}
|
980 |
}
|
| 992 |
$attributes = (array)$attributes;
|
981 |
$attributes = (array)$attributes;
|
| Línea 1014... |
Línea 1003... |
| 1014 |
* @param string $currentmode The current view mode.
|
1003 |
* @param string $currentmode The current view mode.
|
| 1015 |
* @param moodle_url $url The URL to use when changing actions. Defaults to the page URL.
|
1004 |
* @param moodle_url $url The URL to use when changing actions. Defaults to the page URL.
|
| 1016 |
* @param string $param The param name.
|
1005 |
* @param string $param The param name.
|
| 1017 |
* @return string
|
1006 |
* @return string
|
| 1018 |
*/
|
1007 |
*/
|
| 1019 |
public function view_mode_selector(array $modes, $currentmode, moodle_url $url = null, $param = 'view') {
|
1008 |
public function view_mode_selector(array $modes, $currentmode, ?moodle_url $url = null, $param = 'view') {
|
| 1020 |
if ($url === null) {
|
1009 |
if ($url === null) {
|
| 1021 |
$url = $this->page->url;
|
1010 |
$url = $this->page->url;
|
| 1022 |
}
|
1011 |
}
|
| Línea 1023... |
Línea 1012... |
| 1023 |
|
1012 |
|
| 1024 |
$menu = new action_menu;
|
1013 |
$menu = new action_menu;
|
| Línea 1025... |
Línea 1014... |
| 1025 |
$menu->attributes['class'] .= ' view-mode-selector vms ml-1';
|
1014 |
$menu->attributes['class'] .= ' view-mode-selector vms ms-1';
|
| 1026 |
|
1015 |
|
| 1027 |
$selected = null;
|
1016 |
$selected = null;
|
| 1028 |
foreach ($modes as $mode => $modestr) {
|
1017 |
foreach ($modes as $mode => $modestr) {
|
| Línea 1062... |
Línea 1051... |
| 1062 |
* @param int $page The current page, starting at 0.
|
1051 |
* @param int $page The current page, starting at 0.
|
| 1063 |
* @param int $perpage The number of courses to display per page.
|
1052 |
* @param int $perpage The number of courses to display per page.
|
| 1064 |
* @param string $search The string we are searching for.
|
1053 |
* @param string $search The string we are searching for.
|
| 1065 |
* @return string
|
1054 |
* @return string
|
| 1066 |
*/
|
1055 |
*/
|
| 1067 |
public function search_listing(array $courses, $totalcourses, core_course_list_element $course = null, $page = 0, $perpage = 20,
|
1056 |
public function search_listing(array $courses, $totalcourses, ?core_course_list_element $course = null, $page = 0, $perpage = 20,
|
| 1068 |
$search = '') {
|
1057 |
$search = '') {
|
| 1069 |
$page = max($page, 0);
|
1058 |
$page = max($page, 0);
|
| 1070 |
$perpage = max($perpage, 2);
|
1059 |
$perpage = max($perpage, 2);
|
| 1071 |
$totalpages = ceil($totalcourses / $perpage);
|
1060 |
$totalpages = ceil($totalcourses / $perpage);
|
| 1072 |
if ($page > $totalpages - 1) {
|
1061 |
if ($page > $totalpages - 1) {
|
| Línea 1190... |
Línea 1179... |
| 1190 |
$bulkcourseinput = array(
|
1179 |
$bulkcourseinput = array(
|
| 1191 |
'type' => 'checkbox',
|
1180 |
'type' => 'checkbox',
|
| 1192 |
'id' => 'coursesearchlistitem' . $course->id,
|
1181 |
'id' => 'coursesearchlistitem' . $course->id,
|
| 1193 |
'name' => 'bc[]',
|
1182 |
'name' => 'bc[]',
|
| 1194 |
'value' => $course->id,
|
1183 |
'value' => $course->id,
|
| 1195 |
'class' => 'bulk-action-checkbox custom-control-input',
|
1184 |
'class' => 'bulk-action-checkbox form-check-input',
|
| 1196 |
'data-action' => 'select'
|
1185 |
'data-action' => 'select'
|
| 1197 |
);
|
1186 |
);
|
| 1198 |
}
|
1187 |
}
|
| 1199 |
$viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id));
|
1188 |
$viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id));
|
| 1200 |
$categoryname = core_course_category::get($course->category)->get_formatted_name();
|
1189 |
$categoryname = core_course_category::get($course->category)->get_formatted_name();
|
| Línea 1201... |
Línea 1190... |
| 1201 |
|
1190 |
|
| 1202 |
$html = html_writer::start_tag('li', $attributes);
|
1191 |
$html = html_writer::start_tag('li', $attributes);
|
| 1203 |
$html .= html_writer::start_div('clearfix');
|
1192 |
$html .= html_writer::start_div('clearfix');
|
| 1204 |
$html .= html_writer::start_div('float-left');
|
1193 |
$html .= html_writer::start_div('float-start');
|
| 1205 |
if ($bulkcourseinput) {
|
1194 |
if ($bulkcourseinput) {
|
| 1206 |
$html .= html_writer::start_div('custom-control custom-checkbox mr-1');
|
1195 |
$html .= html_writer::start_div('form-check me-1');
|
| 1207 |
$html .= html_writer::empty_tag('input', $bulkcourseinput);
|
1196 |
$html .= html_writer::empty_tag('input', $bulkcourseinput);
|
| 1208 |
$labeltext = html_writer::span(get_string('bulkactionselect', 'moodle', $text), 'sr-only');
|
1197 |
$labeltext = html_writer::span(get_string('bulkactionselect', 'moodle', $text), 'visually-hidden');
|
| 1209 |
$html .= html_writer::tag('label', $labeltext, array(
|
1198 |
$html .= html_writer::tag('label', $labeltext, array(
|
| 1210 |
'class' => 'custom-control-label',
|
1199 |
'class' => 'form-check-label',
|
| 1211 |
'for' => 'coursesearchlistitem' . $course->id));
|
1200 |
'for' => 'coursesearchlistitem' . $course->id));
|
| 1212 |
$html .= html_writer::end_div();
|
1201 |
$html .= html_writer::end_div();
|
| 1213 |
}
|
1202 |
}
|
| 1214 |
$html .= html_writer::end_div();
|
1203 |
$html .= html_writer::end_div();
|
| 1215 |
$html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename aalink'));
|
1204 |
$html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-start coursename aalink'));
|
| 1216 |
$html .= html_writer::tag('span', $categoryname, array('class' => 'float-left ml-3 text-muted'));
|
1205 |
$html .= html_writer::tag('span', $categoryname, array('class' => 'float-start ms-3 text-muted'));
|
| 1217 |
$html .= html_writer::start_div('float-right');
|
1206 |
$html .= html_writer::start_div('float-end');
|
| 1218 |
$html .= $this->search_listitem_actions($course);
|
1207 |
$html .= $this->search_listitem_actions($course);
|
| 1219 |
$html .= html_writer::tag('span', s($course->idnumber), array('class' => 'text-muted idnumber'));
|
1208 |
$html .= html_writer::tag('span', s($course->idnumber), array('class' => 'text-muted idnumber'));
|
| 1220 |
$html .= html_writer::end_div();
|
1209 |
$html .= html_writer::end_div();
|
| 1221 |
$html .= html_writer::end_div();
|
1210 |
$html .= html_writer::end_div();
|
| Línea 1275... |
Línea 1264... |
| 1275 |
}
|
1264 |
}
|
| 1276 |
return html_writer::span(join('', $actions), 'course-item-actions item-actions');
|
1265 |
return html_writer::span(join('', $actions), 'course-item-actions item-actions');
|
| 1277 |
}
|
1266 |
}
|
| Línea 1278... |
Línea 1267... |
| 1278 |
|
1267 |
|
| 1279 |
/**
|
- |
|
| 1280 |
* @deprecated since Moodle 4.0. This is now handled within manage_categories_action_bar
|
- |
|
| 1281 |
*/
|
- |
|
| 1282 |
#[\core\attribute\deprecated(
|
- |
|
| 1283 |
replacement: 'manage_categories_action_bar',
|
- |
|
| 1284 |
since: '4.0',
|
- |
|
| 1285 |
mdl: 'MDL-73462',
|
- |
|
| 1286 |
final: true,
|
- |
|
| 1287 |
)]
|
- |
|
| 1288 |
public function course_search_form() {
|
- |
|
| 1289 |
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
- |
|
| 1290 |
}
|
- |
|
| 1291 |
|
- |
|
| 1292 |
/**
|
1268 |
/**
|
| 1293 |
* Creates access hidden skip to links for the displayed sections.
|
1269 |
* Creates access hidden skip to links for the displayed sections.
|
| 1294 |
*
|
1270 |
*
|
| 1295 |
* @param bool $displaycategorylisting
|
1271 |
* @param bool $displaycategorylisting
|
| 1296 |
* @param bool $displaycourselisting
|
1272 |
* @param bool $displaycourselisting
|