MDL-51610 course: Change section menu to "Edit" and order buttons

This commit is contained in:
Eric Merrill 2015-10-12 11:11:39 -04:00
parent 74fad2ce3d
commit d76acdbc17
5 changed files with 28 additions and 17 deletions

View File

@ -98,11 +98,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$o = "";
if (!empty($controls)) {
$menu = new action_menu();
if ($section->section && get_string_manager()->string_exists('sectionmenu', 'format_'.$course->format)) {
$menu->set_menu_trigger(get_string('sectionmenu', 'format_'.$course->format));
} else {
$menu->set_menu_trigger(get_string('sectionmenu'));
}
$menu->set_menu_trigger(get_string('edit'));
$menu->attributes['class'] .= ' section-actions';
foreach ($controls as $value) {
$url = empty($value['url']) ? '' : $value['url'];

View File

@ -28,7 +28,6 @@ $string['editsection'] = 'Edit topic';
$string['deletesection'] = 'Delete topic';
$string['sectionname'] = 'Topic';
$string['pluginname'] = 'Topics format';
$string['sectionmenu'] = 'Topic menu';
$string['section0name'] = 'General';
$string['page-course-view-topics'] = 'Any course main page in topics format';
$string['page-course-view-topics-x'] = 'Any course page in topics format';

View File

@ -104,21 +104,39 @@ class format_topics_renderer extends format_section_renderer_base {
$url->param('marker', 0);
$markedthistopic = get_string('markedthistopic');
$highlightoff = get_string('highlightoff');
$controls[] = array("url" => $url, "icon" => 'i/marked',
"name" => $highlightoff,
'pixattr' => array('class' => '', 'alt' => $markedthistopic),
"attr" => array('class' => 'editing_highlight', 'title' => $markedthistopic));
$controls['highlight'] = array('url' => $url, "icon" => 'i/marked',
'name' => $highlightoff,
'pixattr' => array('class' => '', 'alt' => $markedthistopic),
'attr' => array('class' => 'editing_highlight', 'title' => $markedthistopic));
} else {
$url->param('marker', $section->section);
$markthistopic = get_string('markthistopic');
$highlight = get_string('highlight');
$controls[] = array("url" => $url, "icon" => 'i/marker',
"name" => $highlight,
'pixattr' => array('class' => '', 'alt' => $markthistopic),
"attr" => array('class' => 'editing_highlight', 'title' => $markthistopic));
$controls['highlight'] = array('url' => $url, "icon" => 'i/marker',
'name' => $highlight,
'pixattr' => array('class' => '', 'alt' => $markthistopic),
'attr' => array('class' => 'editing_highlight', 'title' => $markthistopic));
}
}
return array_merge($controls, parent::section_edit_control_items($course, $section, $onsectionpage));
$parentcontrols = parent::section_edit_control_items($course, $section, $onsectionpage);
// If the edit key exists, we are going to insert our controls after it.
if (array_key_exists("edit", $parentcontrols)) {
$merged = array();
// We can't use splice because we are using associative arrays.
// Step through the array and merge the arrays.
foreach ($parentcontrols as $key => $action) {
$merged[$key] = $action;
if ($key == "edit") {
// If we have come to the edit key, merge these controls here.
$merged = array_merge($merged, $controls);
}
}
return $merged;
} else {
return array_merge($controls, $parentcontrols);
}
}
}

View File

@ -28,7 +28,6 @@ $string['editsection'] = 'Edit week';
$string['deletesection'] = 'Delete week';
$string['sectionname'] = 'Week';
$string['pluginname'] = 'Weekly format';
$string['sectionmenu'] = 'Week menu';
$string['section0name'] = 'General';
$string['page-course-view-weeks'] = 'Any course main page in weeks format';
$string['page-course-view-weeks-x'] = 'Any course page in weeks format';

View File

@ -1633,7 +1633,6 @@ $string['secondstotime86400'] = '1 day';
$string['secretalreadyused'] = 'Change password confirmation link was already used, password was not changed.';
$string['secs'] = 'secs';
$string['section'] = 'Section';
$string['sectionmenu'] = 'Section menu';
$string['sectionname'] = 'Section name';
$string['sections'] = 'Sections';
$string['sectionusedefaultname'] = 'Use default section name';