mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
MDL-55517 login: Rework the login/index.php through a mustache template
Part of MDL-55071
This commit is contained in:
parent
400274bc61
commit
23ef5a971c
3 changed files with 185 additions and 125 deletions
153
lib/templates/login.mustache
Normal file
153
lib/templates/login.mustache
Normal file
|
@ -0,0 +1,153 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core/login
|
||||
|
||||
Moodle template for the login page
|
||||
|
||||
}}
|
||||
<div class="loginbox clearfix {{columns}}">
|
||||
<div class="loginpanel">
|
||||
{{#_signuplink}}
|
||||
<div class="skiplinks">
|
||||
<a class="skip" href="signup.php">{{#str}} tocreatenewaccount {{/str}}</a>
|
||||
</div>
|
||||
{{/_signuplink}}
|
||||
<h2>{{#str}} login {{/str}}</h2>
|
||||
<div class="subcontent loginsub">
|
||||
{{#errormsg}}
|
||||
<div class="loginerrors">
|
||||
<a href="#" id="loginerrormessage", class="accesshide">{{errormsg}}</a>
|
||||
{{{errormsg_error_text}}}
|
||||
</div>
|
||||
{{/errormsg}}
|
||||
<form action="{{httpswwwroot}}/login/index.php" method="post" id="login" {{^_loginpasswordautocomplete_empty}}autocomplete="off"{{/_loginpasswordautocomplete_empty}}>
|
||||
<div class="loginform">
|
||||
<div class="form-label">
|
||||
<label for="username">
|
||||
{{#_authloginviaemail_empty}}
|
||||
{{#str}} username {{/str}}
|
||||
{{/_authloginviaemail_empty}}
|
||||
{{^_authloginviaemail_empty}}
|
||||
{{#str}} usernameemail {{/str}}
|
||||
{{/_authloginviaemail_empty}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-input">
|
||||
<input type="text" name="username" id="username" size="15" value="{{frm_username}}" />
|
||||
</div>
|
||||
<div class="clearer"><!-- --></div>
|
||||
<div class="form-label">
|
||||
<label for="password">{{#str}} password {{/str}}</label>
|
||||
</div>
|
||||
<div class="form-input">
|
||||
<input type="password" name="password" id="password" size="15" value="" {{autocomplete}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearer"><!-- --></div>
|
||||
{{#_rememberusername}}
|
||||
<div class="rememberpass">
|
||||
<input type="checkbox" name="rememberusername" id="rememberusername" value="1" {{#frm_username}}checked="checked"{{/frm_username}} />
|
||||
<label for="rememberusername">{{#str}} rememberusername, admin {{/str}}</label>
|
||||
</div>
|
||||
{{/_rememberusername}}
|
||||
<div class="clearer"><!-- --></div>
|
||||
<input id="anchor" type="hidden" name="anchor" value="" />
|
||||
<script>document.getElementById('anchor').value = location.hash;</script>
|
||||
<input type="submit" id="loginbtn" value="{{#str}} login {{/str}}" />
|
||||
<div class="forgetpass">
|
||||
<a href="forgot_password.php">{{#str}} forgotten {{/str}}</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="desc">
|
||||
{{#str}} cookiesenabled {{/str}}
|
||||
{{{cookiesenabled_help_icon}}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{#_guestloginbutton}}
|
||||
<div class="subcontent guestsub">
|
||||
<div class="desc">{{#str}} someallowguest {{/str}}</div>
|
||||
<form action="index.php" method="post" id="guestlogin">
|
||||
<div class="guestform">
|
||||
<input type="hidden" name="username" value="guest" />
|
||||
<input type="hidden" name="password" value="guest" />
|
||||
<input type="submit" value="{{#str}} loginguest {{/str}}" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{/_guestloginbutton}}
|
||||
|
||||
</div>
|
||||
|
||||
{{#_show_instructions}}
|
||||
<div class="signuppanel">
|
||||
<h2>{{#str}} firsttime {{/str}}</h2>
|
||||
<div class="subcontent">
|
||||
{{#_no_auth_enabled}} {{! instructions override the rest for security reasons }}
|
||||
{{#str}} loginstepsnone {{/str}}
|
||||
{{/_no_auth_enabled}}
|
||||
{{^_no_auth_enabled}}
|
||||
{{#_registerauth_is_email}}
|
||||
{{#auth_instructions}}
|
||||
{{{auth_instructions}}}
|
||||
{{/auth_instructions}}
|
||||
{{^auth_instructions}}
|
||||
{{#str}} loginsteps, , 'signup.php' {{/str}}
|
||||
{{/auth_instructions}}
|
||||
<div class="signupform">
|
||||
<form action="signup.php" method="get" id="signup">
|
||||
<div>
|
||||
<input type="submit" value="{{#str}} startsignup {{/str}}" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{/_registerauth_is_email}}
|
||||
{{^_registerauth_is_email}}
|
||||
{{#_registerauth_not_empty}}
|
||||
{{{auth_instructions}}}
|
||||
<div class="signupform">
|
||||
<form action="signup.php" method="get" id="signup">
|
||||
<div>
|
||||
<input type="submit" value="{{#str}} startsignup {{/str}}" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{/_registerauth_not_empty}}
|
||||
{{^_registerauth_not_empty}}
|
||||
{{{auth_instructions}}}
|
||||
{{/_registerauth_not_empty}}
|
||||
{{/_registerauth_is_email}}
|
||||
{{/_no_auth_enabled}}
|
||||
</div>
|
||||
</div>
|
||||
{{/_show_instructions}}
|
||||
|
||||
{{#_potentialidps_not_empty}}
|
||||
<div class="subcontent potentialidps">
|
||||
<h6>{{#str}} potentialidps, auth {{/str}}</h6>
|
||||
<div class="potentialidplist">
|
||||
{{#potentialidps}}
|
||||
<div class="potentialidp">{{{.}}}</div>
|
||||
{{/potentialidps}}
|
||||
</div>
|
||||
</div>
|
||||
{{/_potentialidps_not_empty}}
|
||||
</div>
|
|
@ -367,7 +367,38 @@ if (isloggedin() and !isguestuser()) {
|
|||
echo $OUTPUT->confirm(get_string('alreadyloggedin', 'error', fullname($USER)), $logout, $continue);
|
||||
echo $OUTPUT->box_end();
|
||||
} else {
|
||||
include("index_form.html");
|
||||
if ($show_instructions) {
|
||||
$columns = 'twocolumns';
|
||||
} else {
|
||||
$columns = 'onecolumn';
|
||||
}
|
||||
|
||||
// Prepare all objects needed for the login page mustache template.
|
||||
$data = new stdClass;
|
||||
$data->columns = $columns;
|
||||
$data->_signuplink = ($CFG->registerauth == 'email') || !empty($CFG->registerauth);
|
||||
$data->errormsg = $errormsg;
|
||||
$data->errormsg_error_text = $OUTPUT->error_text($errormsg);
|
||||
$data->httpswwwroot = $CFG->httpswwwroot;
|
||||
$data->_loginpasswordautocomplete_empty = empty($CFG->loginpasswordautocomplete);
|
||||
$data->_authloginviaemail_empty = empty($CFG->authloginviaemail);
|
||||
$data->frm_username = p($frm->username);
|
||||
$data->_rememberusername = (isset($CFG->rememberusername) and $CFG->rememberusername == 2);
|
||||
$data->cookiesenabled_help_icon = $OUTPUT->help_icon('cookiesenabled');
|
||||
$data->_guestloginbutton = $CFG->guestloginbutton and !isguestuser();
|
||||
$data->_show_instructions = $show_instructions;
|
||||
$data->_no_auth_enabled = is_enabled_auth('none');
|
||||
$data->_registerauth_is_email = ($CFG->registerauth == 'email');
|
||||
$data->_registerauth_not_empty = !empty($CFG->registerauth);
|
||||
$data->_potentialidps_not_empty = !empty($potentialidps);
|
||||
$data->potentialidps = $potentialidps;
|
||||
$data->potentialidps = array();
|
||||
foreach($potentialidps as $idp) {
|
||||
$data->potentialidps[] = html_writer::link($idp['url']->out(), $OUTPUT->render($idp['icon'], $idp['name']) . $idp['name'], array('title' => $idp['name']));
|
||||
}
|
||||
|
||||
echo $OUTPUT->render_from_template('core/login', $data);
|
||||
|
||||
if ($errormsg) {
|
||||
$PAGE->requires->js_init_call('M.util.focus_login_error', null, true);
|
||||
} else if (!empty($CFG->loginpageautofocus)) {
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
if ($show_instructions) {
|
||||
$columns = 'twocolumns';
|
||||
} else {
|
||||
$columns = 'onecolumn';
|
||||
}
|
||||
|
||||
if (!empty($CFG->loginpasswordautocomplete)) {
|
||||
$autocomplete = 'autocomplete="off"';
|
||||
} else {
|
||||
$autocomplete = '';
|
||||
}
|
||||
if (empty($CFG->authloginviaemail)) {
|
||||
$strusername = get_string('username');
|
||||
} else {
|
||||
$strusername = get_string('usernameemail');
|
||||
}
|
||||
?>
|
||||
<div class="loginbox clearfix <?php echo $columns ?>">
|
||||
<div class="loginpanel">
|
||||
<?php
|
||||
if (($CFG->registerauth == 'email') || !empty($CFG->registerauth)) { ?>
|
||||
<div class="skiplinks"><a class="skip" href="signup.php"><?php print_string("tocreatenewaccount"); ?></a></div>
|
||||
<?php
|
||||
} ?>
|
||||
<h2><?php print_string("login") ?></h2>
|
||||
<div class="subcontent loginsub">
|
||||
<?php
|
||||
if (!empty($errormsg)) {
|
||||
echo html_writer::start_tag('div', array('class' => 'loginerrors'));
|
||||
echo html_writer::link('#', $errormsg, array('id' => 'loginerrormessage', 'class' => 'accesshide'));
|
||||
echo $OUTPUT->error_text($errormsg);
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo $CFG->httpswwwroot; ?>/login/index.php" method="post" id="login" <?php echo $autocomplete; ?> >
|
||||
<div class="loginform">
|
||||
<div class="form-label"><label for="username"><?php echo($strusername) ?></label></div>
|
||||
<div class="form-input">
|
||||
<input type="text" name="username" id="username" size="15" value="<?php p($frm->username) ?>" />
|
||||
</div>
|
||||
<div class="clearer"><!-- --></div>
|
||||
<div class="form-label"><label for="password"><?php print_string("password") ?></label></div>
|
||||
<div class="form-input">
|
||||
<input type="password" name="password" id="password" size="15" value="" <?php echo $autocomplete; ?> />
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"><!-- --></div>
|
||||
<?php if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) { ?>
|
||||
<div class="rememberpass">
|
||||
<input type="checkbox" name="rememberusername" id="rememberusername" value="1" <?php if ($frm->username) {echo 'checked="checked"';} ?> />
|
||||
<label for="rememberusername"><?php print_string('rememberusername', 'admin') ?></label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="clearer"><!-- --></div>
|
||||
<input id="anchor" type="hidden" name="anchor" value="" />
|
||||
<script>document.getElementById('anchor').value = location.hash</script>
|
||||
<input type="submit" id="loginbtn" value="<?php print_string("login") ?>" />
|
||||
<div class="forgetpass"><a href="forgot_password.php"><?php print_string("forgotten") ?></a></div>
|
||||
</form>
|
||||
<div class="desc">
|
||||
<?php
|
||||
echo get_string("cookiesenabled");
|
||||
echo $OUTPUT->help_icon('cookiesenabled');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($CFG->guestloginbutton and !isguestuser()) { ?>
|
||||
<div class="subcontent guestsub">
|
||||
<div class="desc">
|
||||
<?php print_string("someallowguest") ?>
|
||||
</div>
|
||||
<form action="index.php" method="post" id="guestlogin">
|
||||
<div class="guestform">
|
||||
<input type="hidden" name="username" value="guest" />
|
||||
<input type="hidden" name="password" value="guest" />
|
||||
<input type="submit" value="<?php print_string("loginguest") ?>" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php if ($show_instructions) { ?>
|
||||
<div class="signuppanel">
|
||||
<h2><?php print_string("firsttime") ?></h2>
|
||||
<div class="subcontent">
|
||||
<?php if (is_enabled_auth('none')) { // instructions override the rest for security reasons
|
||||
print_string("loginstepsnone");
|
||||
} else if ($CFG->registerauth == 'email') {
|
||||
if (!empty($CFG->auth_instructions)) {
|
||||
echo format_text($CFG->auth_instructions);
|
||||
} else {
|
||||
print_string("loginsteps", "", "signup.php");
|
||||
} ?>
|
||||
<div class="signupform">
|
||||
<form action="signup.php" method="get" id="signup">
|
||||
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } else if (!empty($CFG->registerauth)) {
|
||||
echo format_text($CFG->auth_instructions); ?>
|
||||
<div class="signupform">
|
||||
<form action="signup.php" method="get" id="signup">
|
||||
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
|
||||
</form>
|
||||
</div>
|
||||
<?php } else {
|
||||
echo format_text($CFG->auth_instructions);
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($potentialidps)) { ?>
|
||||
<div class="subcontent potentialidps">
|
||||
<h6><?php print_string('potentialidps', 'auth'); ?></h6>
|
||||
<div class="potentialidplist">
|
||||
<?php foreach ($potentialidps as $idp) {
|
||||
echo '<div class="potentialidp"><a href="' . $idp['url']->out() . '" title="' . $idp['name'] . '">' . $OUTPUT->render($idp['icon'], $idp['name']) . $idp['name'] . '</a></div>';
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue