navigation MDL-14632 Added fuzzy matching as a worst case scenario to find the active node and tidied up course report page layouts

This commit is contained in:
Sam Hemelryk 2010-05-19 07:57:00 +00:00
parent dec1351465
commit 7c4efe3bc4
6 changed files with 56 additions and 25 deletions

View File

@ -34,10 +34,12 @@
$logformat = optional_param('logformat', 'showashtml', PARAM_ALPHA);
$params = array();
if ($id !== 0) $params['id'] = $id;
if ($host_course !== '') $params['host_course'] = $host_course;
if ($group !== 0) $params['group'] = $group;
if ($user !== 0) $params['user'] = $user;
if ($date !== 0) $params['date'] = $date;
if ($modname !== 0) $params['modname'] = $modname;
if ($modname !== '') $params['modname'] = $modname;
if ($modid !== 0) $params['modid'] = $modid;
if ($modaction !== '') $params['modaction'] = $modaction;
if ($page !== '0') $params['page'] = $page;
@ -47,6 +49,7 @@
if ($chooselog !== 0) $params['chooselog'] = $chooselog;
if ($logformat !== 'showashtml') $params['logformat'] = $logformat;
$PAGE->set_url('/course/report/log/index.php', $params);
$PAGE->set_pagelayout('admin');
if ($hostid == $CFG->mnet_localhost_id) {
if (!$course = $DB->get_record('course', array('id'=>$id))) {
@ -141,13 +144,11 @@
} else {
if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($strlogs);
echo $OUTPUT->header();
}

View File

@ -12,6 +12,7 @@
}
$PAGE->set_url('/course/report/outline/index.php', array('id'=>$id));
$PAGE->set_pagelayout('admin');
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
@ -35,8 +36,6 @@
$PAGE->set_title($course->shortname .': '. $stractivityreport);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($stractivityreport);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($course->fullname));

View File

@ -14,7 +14,15 @@
$page = optional_param('page', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page
$PAGE->set_url('/course/report/participation/index.php', compact('id', 'roleid', 'instanceid', 'timefrom', 'page', 'perpage'));
$url = new moodle_url('/course/report/participation/index.php', array('id'=>$id));
if ($roleid !== 0) $url->param('roleid');
if ($instanceid !== 0) $url->param('instanceid');
if ($timefrom !== 0) $url->param('timefrom');
if ($action !== '') $url->param('action');
if ($page !== 0) $url->param('page');
if ($perpage !== DEFAULT_PAGE_SIZE) $url->param('perpage');
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
if ($action != 'view' and $action != 'post') {
$action = ''; // default to all (don't restrict)
@ -51,8 +59,6 @@
$PAGE->set_title($course->shortname .': '. $strparticipation);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($strparticipation);
echo $OUTPUT->header();
$modinfo = get_fast_modinfo($course);

View File

@ -46,10 +46,11 @@ if ($sort !== '') {
if ($format !== '') {
$url->param('format', $format);
}
if ($start !== '') {
if ($start !== 0) {
$url->param('start', $start);
}
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
require_login($course);
@ -99,10 +100,6 @@ if($csv) {
$PAGE->set_title($strcompletion);
$PAGE->set_heading($course->fullname);
if (has_capability('moodle/site:viewreports', $context)) {
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
}
$PAGE->navbar->add($strcompletion);
echo $OUTPUT->header();
if($svgcleverness) {

View File

@ -466,6 +466,24 @@ class navigation_node implements renderable {
return false;
}
/**
* Searches all children for the best matching active node
* @return navigation_node|false
*/
public function search_for_active_node() {
if ($this->check_if_active(URL_MATCH_BASE)) {
return $this;
} else {
foreach ($this->children as &$child) {
$outcome = $child->search_for_active_node();
if ($outcome !== false) {
return $outcome;
}
}
}
return false;
}
/**
* Gets the content for this node.
*
@ -896,21 +914,23 @@ class global_navigation extends navigation_node {
case CONTEXT_SYSTEM :
case CONTEXT_COURSECAT :
// Load the front page course navigation
$this->load_course($SITE);
$coursenode = $this->load_course($SITE);
$this->add_front_page_course_essentials($coursenode, $SITE);
break;
case CONTEXT_BLOCK :
case CONTEXT_COURSE :
// Load the course associated with the page into the navigation
$course = $this->page->course;
$coursenode = $this->load_course($course);
// Make it active
$coursenode->make_active();
// Add the essentials such as reports etc...
$this->add_course_essentials($coursenode, $course);
if ($this->format_display_course_content($course->format)) {
// Load the course sections
$sections = $this->load_course_sections($course, $coursenode);
}
if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) {
$coursenode->make_active();
}
break;
case CONTEXT_MODULE :
$course = $this->page->course;
@ -938,8 +958,11 @@ class global_navigation extends navigation_node {
}
// Finally load the cm specific navigaton information
$this->load_activity($cm, $course, $activities[$cm->id]);
// And make the activity node active.
$activities[$cm->id]->make_active();
// Check if we have an active ndoe
if (!$activities[$cm->id]->contains_active_node() && !$activities[$cm->id]->search_for_active_node()) {
// And make the activity node active.
$activities[$cm->id]->make_active();
}
break;
case CONTEXT_USER :
$course = $this->page->course;
@ -1000,6 +1023,10 @@ class global_navigation extends navigation_node {
}
}
if (!$this->contains_active_node()) {
$this->search_for_active_node();
}
// If the user is not logged in modify the navigation structure as detailed
// in {@link http://docs.moodle.org/en/Development:Navigation_2.0_structure}
if (!isloggedin()) {

View File

@ -15,23 +15,24 @@ $page = optional_param('page', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', 18, PARAM_INT);
$params = array();
if ($query) {
if ($query !== '') {
$params['query'] = $query;
}
if ($page) {
if ($page !== 0) {
$params['page'] = $page;
}
if ($perpage) {
if ($perpage !== 18) {
$params['perpage'] = $perpage;
}
$PAGE->set_url('/tag/search.php', $params);
$PAGE->set_url(new moodle_url('/tag/search.php', $params));
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_pagelayout('standard');
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$manage_link = ' ';
$PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
$PAGE->set_title(get_string('tags', 'tag'));
$PAGE->set_heading($SITE->fullname.': '.$PAGE->title);
echo $OUTPUT->header();
if ( has_capability('moodle/tag:manage',$systemcontext) ) {