Skip to content

Commit

Permalink
MDL-21119 lang menu and login info now handled by themes
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Dec 29, 2009
1 parent 684b988 commit 244a32c
Show file tree
Hide file tree
Showing 26 changed files with 155 additions and 187 deletions.
12 changes: 0 additions & 12 deletions auth/shibboleth/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@
/// Define variables used in page
$site = get_site();

if (empty($CFG->langmenu)) {
$langmenu = "";
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$select = html_select::make_popup_form("$CFG->httpswwwroot/login/index.php", 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
$langmenu = '<div class="langmenu">'.$OUTPUT->select($select).'</div>';
}

$loginsite = get_string("loginsite");

$loginurl = (!empty($CFG->alternateloginurl)) ? $CFG->alternateloginurl : '';
Expand Down Expand Up @@ -82,7 +71,6 @@
$PAGE->set_title("$site->fullname: $loginsite");
$PAGE->set_heading($site->fullname);
$PAGE->set_focuscontrol('idp');
$PAGE->set_headingmenu($langmenu);

echo $OUTPUT->header();
include("index_form.html");
Expand Down
1 change: 0 additions & 1 deletion calendar/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
$PAGE->navbar->add($title);
$PAGE->set_title($site->shortname.': '.$strcalendar.': '.$title);
$PAGE->set_heading($strcalendar);
$PAGE->set_headingmenu(user_login_string($site));

echo $OUTPUT->header();
echo $OUTPUT->box_start('eventlist');
Expand Down
1 change: 0 additions & 1 deletion calendar/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@
$PAGE->navbar->add($title);
$PAGE->set_title($site->shortname.': '.$strcalendar.': '.$title);
$PAGE->set_heading($strcalendar);
$PAGE->set_headingmenu(user_login_string($site));

echo $OUTPUT->header();

Expand Down
1 change: 0 additions & 1 deletion calendar/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@

$PAGE->set_title($site->shortname.': '.$strcalendar.': '.$pagetitle);
$PAGE->set_heading($strcalendar);
$PAGE->set_headingmenu(user_login_string($site));
$PAGE->set_button($prefsbutton);
$PAGE->set_focuscontrol('eventform.name');

Expand Down
1 change: 0 additions & 1 deletion calendar/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@

$PAGE->set_title("$site->shortname: $strcalendar: $strpreferences");
$PAGE->set_heading($strcalendar);
$PAGE->set_headingmenu(user_login_string($site));

echo $OUTPUT->header();

Expand Down
1 change: 0 additions & 1 deletion calendar/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
// Print title and header
$PAGE->set_title("$site->shortname: $strcalendar: $pagetitle");
$PAGE->set_heading($strcalendar);
$PAGE->set_headingmenu(user_login_string($site));
$PAGE->set_button($prefsbutton);

$PAGE->requires->yui2_lib('animation');
Expand Down
1 change: 0 additions & 1 deletion course/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
$PAGE->set_heading('Course info');
$PAGE->set_course($course);
$PAGE->navbar->add(get_string('summary'));
$PAGE->set_headingmenu(user_login_string());

echo $OUTPUT->header();
echo $OUTPUT->heading('<a href="view.php?id='.$course->id.'">'.format_string($course->fullname) . '</a><br />(' . format_string($course->shortname) . ')');
Expand Down
2 changes: 0 additions & 2 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
$PAGE->set_button($buttons);
//TODO: MDL-21123 this should be done in course page layout, not here with this ugly hack!
//$PAGE->set_headingmenu(user_login_string($course, $USER));
echo $OUTPUT->header();

if ($completion->is_enabled() && ajaxenabled()) {
Expand Down
1 change: 0 additions & 1 deletion group/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
/// Print header
$PAGE->set_title("$course->shortname: $strgroups");
$PAGE->set_heading($course->fullname);
$PAGE->set_headingmenu(user_login_string($course, $USER));
echo $OUTPUT->header();

?>
Expand Down
1 change: 0 additions & 1 deletion group/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
/// Print header
$PAGE->set_title("$course->shortname: $strgroups");
$PAGE->set_heading($course->fullname);
$PAGE->set_headingmenu(user_login_string($course, $USER));
echo $OUTPUT->header();
?>

Expand Down
15 changes: 1 addition & 14 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,14 @@
$PAGE->set_pagetype('site-index');
$PAGE->set_course($SITE);

if (empty($CFG->langmenu)) {
$langmenu = '';
} else {
$currlang = current_language();
$langs = get_list_of_languages();

$select = html_select::make_popup_form($CFG->wwwroot .'/index.php', 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
//TODO: MDL-21123
$langmenu = '<div class="langmenu">'.$OUTPUT->select($select).'</div>';
}
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
$PAGE->set_url('');
$PAGE->set_docs_path('');
$PAGE->set_pagelayout('frontpage');
$editing = $PAGE->user_is_editing();
$PAGE->set_title($SITE->fullname);
$PAGE->set_heading($SITE->fullname);
$PAGE->set_headingmenu($langmenu);
echo $OUTPUT->header($langmenu);
echo $OUTPUT->header();

/// Print Section
if ($SITE->numsections > 0) {
Expand Down
17 changes: 17 additions & 0 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,23 @@ function print_footer($course = NULL, $usercourse = NULL, $return = false) {
}
}

/**
* Returns text to be displayed to the user which reflects their login status
*
* @global object
* @global object
* @global object
* @global object
* @uses CONTEXT_COURSE
* @param course $course {@link $COURSE} object containing course information
* @param user $user {@link $USER} object containing user information
* @return string HTML
*/
function user_login_string($course='ignored', $user='ignored') {
debugging('user_login_info() has been deprecated. User login info is now handled via themes layouts.');
return '';
}

/**
* Prints a nice side block with an optional header. The content can either
* be a block of HTML or a list of text with optional icons.
Expand Down
4 changes: 0 additions & 4 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,6 @@ public static function make_popup_form($baseurl, $name, $options, $formid, $sele
$selectedurl = $baseurl->out(false, array($name => $selected), false);
}

if (!($baseurl instanceof moodle_url)) {
$baseurl = new moodle_url($baseurl);
}

// Replace real value by formatted URLs
foreach ($options as $value => $label) {
$options[$baseurl->out(false, array($name => $value), false)] = $label;
Expand Down
107 changes: 104 additions & 3 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,80 @@ public function standard_end_of_body_html() {
* @return string HTML fragment.
*/
public function login_info() {
global $USER;
return user_login_string($this->page->course, $USER);
global $USER, $CFG, $DB;

if (during_initial_install()) {
return '';
}

$course = $this->page->course;

if (session_is_loggedinas()) {
$realuser = session_get_realuser();
$fullname = fullname($realuser, true);
$realuserinfo = " [<a $CFG->frametarget
href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;return=1&amp;sesskey=".sesskey()."\">$fullname</a>] ";
} else {
$realuserinfo = '';
}

$loginurl = get_login_url();

if (empty($course->id)) {
// $course->id is not defined during installation
return '';
} else if (!empty($USER->id)) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);

$fullname = fullname($USER, true);
$username = "<a $CFG->frametarget href=\"$CFG->wwwroot/user/view.php?id=$USER->id&amp;course=$course->id\">$fullname</a>";
if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id'=>$USER->mnethostid))) {
$username .= " from <a $CFG->frametarget href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
}
if (isset($USER->username) && $USER->username == 'guest') {
$loggedinas = $realuserinfo.get_string('loggedinasguest').
" (<a $CFG->frametarget href=\"$loginurl\">".get_string('login').'</a>)';
} else if (!empty($USER->access['rsw'][$context->path])) {
$rolename = '';
if ($role = $DB->get_record('role', array('id'=>$USER->access['rsw'][$context->path]))) {
$rolename = ': '.format_string($role->name);
}
$loggedinas = get_string('loggedinas', 'moodle', $username).$rolename.
" (<a $CFG->frametarget
href=\"$CFG->wwwroot/course/view.php?id=$course->id&amp;switchrole=0&amp;sesskey=".sesskey()."\">".get_string('switchrolereturn').'</a>)';
} else {
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).' '.
" (<a $CFG->frametarget href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
}
} else {
$loggedinas = get_string('loggedinnot', 'moodle').
" (<a $CFG->frametarget href=\"$loginurl\">".get_string('login').'</a>)';
}

$loggedinas = '<div class="logininfo">'.$loggedinas.'</div>';

if (isset($SESSION->justloggedin)) {
unset($SESSION->justloggedin);
if (!empty($CFG->displayloginfailures)) {
if (!empty($USER->username) and $USER->username != 'guest') {
if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
$loggedinas .= '&nbsp;<div class="loginfailures">';
if (empty($count->accounts)) {
$loggedinas .= get_string('failedloginattempts', '', $count);
} else {
$loggedinas .= get_string('failedloginattemptsall', '', $count);
}
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_SYSTEM))) {
$loggedinas .= ' (<a href="'.$CFG->wwwroot.'/course/report/log/index.php'.
'?chooselog=1&amp;id=1&amp;modid=site_errors">'.get_string('logs').'</a>)';
}
$loggedinas .= '</div>';
}
}
}
}

return $loggedinas;
}

/**
Expand Down Expand Up @@ -668,6 +740,35 @@ public function container_end_all($shouldbenone = false) {
return $this->opencontainers->pop_all_but_last($shouldbenone);
}

/**
* Returns lang menu or '', this method also checks forcing of languages in courses.
* @return string
*/
public function lang_menu() {
global $CFG;

if (empty($CFG->langmenu)) {
return '';
}

if ($this->page->course != SITEID and !empty($this->page->course->lang)) {
// do not show lang menu if language forced
return '';
}

$currlang = current_language();
$langs = get_list_of_languages();

if (count($langs) < 2) {
return '';
}

$select = html_select::make_popup_form($this->page->url, 'lang', $langs, 'chooselang', $currlang);
$select->nothinglabel = false;
$select->set_label(get_accesshide(get_string('language')));
return '<div class="langmenu">'.$this->select($select).'</div>';
}

/**
* Output the row of editing icons for a block, as defined by the controls array.
* @param array $controls an array like {@link block_contents::$controls}.
Expand Down Expand Up @@ -1028,7 +1129,7 @@ public function doc_link($path, $text=false, $iconpath=false) {
* @param moodle_action_icon $icon A moodle_action_icon object
* @return string HTML fragment
*/
public function action_icon($icon) {
public function action_icon(moodle_action_icon $icon) {
$icon = clone($icon);
$icon->prepare($this, $this->page, $this->target);
$imageoutput = $this->image($icon->image);
Expand Down
Loading

0 comments on commit 244a32c

Please sign in to comment.