Skip to content

Commit

Permalink
MDL-29189 mutlilang Reviewed the uses of course shortname and ensured…
Browse files Browse the repository at this point in the history
… things are being formatted consistently
  • Loading branch information
Sam Hemelryk committed Sep 7, 2011
1 parent 5d2db8a commit 8ebbb06
Show file tree
Hide file tree
Showing 70 changed files with 296 additions and 167 deletions.
2 changes: 1 addition & 1 deletion backup/backup_scheduled.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function schedule_backup_cron() {

//Build the message subject
$site = get_site();
$prefix = $site->shortname.": ";
$prefix = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))).": ";
if ($count_error != 0 || $count_unfinished != 0) {
$prefix .= "[".strtoupper(get_string('error'))."] ";
}
Expand Down
2 changes: 2 additions & 0 deletions backup/util/dbops/backup_plan_dbops.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ public static function get_default_backup_filename($format, $type, $id, $users,
switch ($type) {
case backup::TYPE_1COURSE:
$shortname = $DB->get_field('course', 'shortname', array('id' => $id));
$context = get_context_instance(CONTEXT_COURSE, $id);
$shortname = format_string($shortname, true, array('context' => $context));
break;
case backup::TYPE_1SECTION:
if (!$shortname = $DB->get_field('course_sections', 'name', array('id' => $id))) {
Expand Down
2 changes: 1 addition & 1 deletion backup/util/helper/backup_cron_helper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL

//Build the message subject
$site = get_site();
$prefix = $site->shortname.": ";
$prefix = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))).": ";
if ($haserrors) {
$prefix .= "[".strtoupper(get_string('error'))."] ";
}
Expand Down
4 changes: 2 additions & 2 deletions backup/util/ui/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public function render_restore_course_search(restore_course_search $component) {
}
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$course->id)),
$course->shortname,
format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
$course->fullname
);
$table->data[] = $row;
Expand Down Expand Up @@ -587,7 +587,7 @@ public function render_import_course_search(import_course_search $component) {
}
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'importid', 'value'=>$course->id)),
$course->shortname,
format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
$course->fullname
);
$table->data[] = $row;
Expand Down
9 changes: 6 additions & 3 deletions blocks/course_list/block_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ function get_content() {
!(has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) and $adminseesall)) { // Just print My Courses
if ($courses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC')) {
foreach ($courses as $course) {
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
$this->content->items[]="<a $linkcss title=\"" . format_string($course->shortname) . "\" ".
$this->content->items[]="<a $linkcss title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">".$icon.format_string($course->fullname). "</a>";
}
$this->title = get_string('mycourses');
Expand Down Expand Up @@ -70,10 +71,11 @@ function get_content() {

if ($courses) {
foreach ($courses as $course) {
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";

$this->content->items[]="<a $linkcss title=\""
. format_string($course->shortname)."\" ".
. format_string($course->shortname, true, array('context' => $coursecontext))."\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">"
.$icon. format_string($course->fullname) . "</a>";
}
Expand Down Expand Up @@ -117,7 +119,8 @@ function get_remote_courses() {
$this->content->items[] = get_string('remotecourses','mnet');
$this->content->icons[] = '';
foreach ($courses as $course) {
$this->content->items[]="<a title=\"" . format_string($course->shortname) . "\" ".
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$this->content->items[]="<a title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" ".
"href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&amp;wantsurl=/course/view.php?id={$course->remoteid}\">"
.$icon. format_string($course->fullname) . "</a>";
}
Expand Down
60 changes: 37 additions & 23 deletions blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,11 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 1: No entry, mod, course or user params: all site entries to be shown (filtered by search and tag/tagid)
// Note: if action is set to 'add' or 'edit', we do this at the end
if (empty($entryid) && empty($modid) && empty($courseid) && empty($userid) && !in_array($action, array('edit', 'add'))) {
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$site->shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$site->shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $site->shortname);
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
// $headers['strview'] = get_string('viewsiteentries', 'blog');
}

Expand All @@ -770,14 +771,14 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else {
$mycourseid = $site->id;
}
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));

$PAGE->navbar->add($strblogentries, $blogurl);

$blogurl->remove_params('userid');
$PAGE->navbar->add($entry->subject, $blogurl);

$PAGE->set_title("$site->shortname: " . fullname($user) . ": $entry->subject");
$PAGE->set_heading("$site->shortname: " . fullname($user) . ": $entry->subject");
$PAGE->set_title("$shortname: " . fullname($user) . ": $entry->subject");
$PAGE->set_heading("$shortname: " . fullname($user) . ": $entry->subject");
$headers['heading'] = get_string('blogentrybyuser', 'blog', fullname($user));

// We ignore tag and search params
Expand All @@ -789,23 +790,26 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

// Case 3: A user's blog entries
if (!empty($userid) && empty($entryid) && ((empty($courseid) && empty($modid)) || !$CFG->useblogassociations)) {
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$blogurl->param('userid', $userid);
$PAGE->set_title("$site->shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
$PAGE->set_heading("$site->shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
$PAGE->set_title("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
$headers['heading'] = get_string('userblog', 'blog', fullname($user));
$headers['strview'] = get_string('viewuserentries', 'blog', fullname($user));

} else

// Case 4: No blog associations, no userid
if (!$CFG->useblogassociations && empty($userid) && !in_array($action, array('edit', 'add'))) {
$PAGE->set_title("$site->shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$site->shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $site->shortname);
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
} else

// Case 5: Blog entries associated with an activity by a specific user (courseid ignored)
if (!empty($userid) && !empty($modid) && empty($entryid)) {
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$blogurl->param('userid', $userid);
$blogurl->param('modid', $modid);

Expand All @@ -814,8 +818,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->navbar->add(fullname($user), "$CFG->wwwroot/user/view.php?id=$user->id");
$PAGE->navbar->add($strblogentries, $blogurl);

$PAGE->set_title("$site->shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_heading("$site->shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_title("$shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_heading("$shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));

$a = new stdClass();
$a->user = fullname($user);
Expand All @@ -828,13 +832,15 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

// Case 6: Blog entries associated with a course by a specific user
if (!empty($userid) && !empty($courseid) && empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$blogurl->param('userid', $userid);
$blogurl->param('courseid', $courseid);

$PAGE->navbar->add($strblogentries, $blogurl);

$PAGE->set_title("$site->shortname: $course->shortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_heading("$site->shortname: $course->shortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_title("$siteshortname: $courseshortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$PAGE->set_heading("$siteshortname: $courseshortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));

$a = new stdClass();
$a->user = fullname($user);
Expand All @@ -850,15 +856,17 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

// Case 7: Blog entries by members of a group, associated with that group's course
if (!empty($groupid) && empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$blogurl->param('courseid', $course->id);

$PAGE->navbar->add($strblogentries, $blogurl);
$blogurl->remove_params(array('courseid'));
$blogurl->param('groupid', $groupid);
$PAGE->navbar->add($group->name, $blogurl);

$PAGE->set_title("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_heading("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog') . ": $group->name");

$a = new stdClass();
$a->group = $group->name;
Expand All @@ -871,15 +879,17 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

// Case 8: Blog entries by members of a group, associated with an activity in that course
if (!empty($groupid) && !empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$headers['cm'] = $cm;
$blogurl->param('modid', $modid);
$PAGE->navbar->add($strblogentries, $blogurl);

$blogurl->param('groupid', $groupid);
$PAGE->navbar->add($group->name, $blogurl);

$PAGE->set_title("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_heading("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_title("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
$PAGE->set_heading("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");

$a = new stdClass();
$a->group = $group->name;
Expand All @@ -893,11 +903,13 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

// Case 9: All blog entries associated with an activity
if (!empty($modid) && empty($userid) && empty($groupid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$PAGE->set_cm($cm, $course);
$blogurl->param('modid', $modid);
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog'));
$PAGE->set_heading("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog'));
$PAGE->set_title("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog'));
$PAGE->set_heading("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog'));
$headers['heading'] = get_string('blogentriesabout', 'blog', $cm->name);
$a = new stdClass();
$a->type = get_string('modulename', $cm->modname);
Expand All @@ -907,10 +919,12 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu

// Case 10: All blog entries associated with a course
if (!empty($courseid) && empty($userid) && empty($groupid) && empty($modid) && empty($entryid)) {
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$blogurl->param('courseid', $courseid);
$PAGE->navbar->add($strblogentries, $blogurl);
$PAGE->set_title("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog'));
$PAGE->set_heading("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog'));
$PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesabout', 'blog', $course->fullname);
Expand Down
3 changes: 2 additions & 1 deletion calendar/export_execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
$ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
}
if ($event->courseid != 0) {
$ev->add_property('categories', $courses[$event->courseid]->shortname);
$coursecontext = get_context_instance(CONTEXT_COURSE, $event->courseid);
$ev->add_property('categories', format_string($courses[$event->courseid]->shortname, true, array('context' => $coursecontext)));
}
$ical->add_component($ev);
}
Expand Down
3 changes: 2 additions & 1 deletion calendar/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ protected function course_filter_selector(moodle_url $returnurl, $label=null) {
$courseoptions = array();
$courseoptions[SITEID] = get_string('fulllistofcourses');
foreach ($courses as $course) {
$courseoptions[$course->id] = format_string($course->shortname);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$courseoptions[$course->id] = format_string($course->shortname, true, array('context' => $coursecontext));
}

if ($this->page->course->id !== SITEID) {
Expand Down
9 changes: 5 additions & 4 deletions course/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@
}

$category = $DB->get_record("course_categories", array("id"=>$course->category));
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));

$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php/'));
$PAGE->navbar->add($strcategories, new moodle_url('/course/index.php'));
$PAGE->navbar->add($category->name, new moodle_url('/course/category.php', array('id'=>$course->category)));
if (! $delete) {
$strdeletecheck = get_string("deletecheck", "", $course->shortname);
$strdeletecheck = get_string("deletecheck", "", $courseshortname);
$strdeletecoursecheck = get_string("deletecoursecheck");

$PAGE->navbar->add($strdeletecheck);
$PAGE->set_title("$site->shortname: $strdeletecheck");
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();

$message = "$strdeletecoursecheck<br /><br />" . format_string($course->fullname) . " (" . format_string($course->shortname) . ")";
$message = "$strdeletecoursecheck<br /><br />" . format_string($course->fullname) . " (" . $courseshortname . ")";
echo $OUTPUT->confirm($message, "delete.php?id=$course->id&delete=".md5($course->timemodified), "category.php?id=$course->category");

echo $OUTPUT->footer();
Expand All @@ -62,7 +63,7 @@

add_to_log(SITEID, "course", "delete", "view.php?id=$course->id", "$course->fullname (ID $course->id)");

$strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname));
$strdeletingcourse = get_string("deletingcourse", "", $courseshortname);

$PAGE->navbar->add($strdeletingcourse);
$PAGE->set_title("$site->shortname: $strdeletingcourse");
Expand All @@ -73,7 +74,7 @@
delete_course($course);
fix_course_sortorder(); //update course count in catagories

echo $OUTPUT->heading( get_string("deletedcourse", "", format_string($course->shortname)) );
echo $OUTPUT->heading( get_string("deletedcourse", "", $courseshortname) );

echo $OUTPUT->continue_button("category.php?id=$course->category");

Expand Down
Loading

0 comments on commit 8ebbb06

Please sign in to comment.