Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_actions_form_Login | |
0.00% |
0 / 27 |
|
0.00% |
0 / 2 |
72 | |
0.00% |
0 / 1 |
| initForm | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| initElements | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
56 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | use oat\tao\helpers\Layout; |
| 26 | |
| 27 | /** |
| 28 | * This container initialize the login form. |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 32 | * @package tao |
| 33 | |
| 34 | */ |
| 35 | class tao_actions_form_Login extends tao_helpers_form_FormContainer |
| 36 | { |
| 37 | // --- ASSOCIATIONS --- |
| 38 | |
| 39 | |
| 40 | // --- ATTRIBUTES --- |
| 41 | |
| 42 | // --- OPERATIONS --- |
| 43 | |
| 44 | /** |
| 45 | * Short description of method initForm |
| 46 | * |
| 47 | * @access public |
| 48 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 49 | * @return mixed |
| 50 | */ |
| 51 | public function initForm() |
| 52 | { |
| 53 | $this->form = tao_helpers_form_FormFactory::getForm('loginForm'); |
| 54 | |
| 55 | $connectElt = tao_helpers_form_FormFactory::getElement('connect', 'Submit'); |
| 56 | $connectElt->setValue(__('Log in')); |
| 57 | $connectElt->setAttributes(['disabled' => 'disabled']); |
| 58 | $connectElt->addClass('disabled'); |
| 59 | $this->form->setActions([$connectElt], 'bottom'); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Short description of method initElements |
| 64 | * |
| 65 | * @access public |
| 66 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 67 | * @return mixed |
| 68 | */ |
| 69 | public function initElements() |
| 70 | { |
| 71 | if (isset($this->data['redirect']) && !empty($this->data['redirect'])) { |
| 72 | $hiddenElt = tao_helpers_form_FormFactory::getElement('redirect', 'Hidden'); |
| 73 | $hiddenElt->setValue($this->data['redirect']); |
| 74 | $this->form->addElement($hiddenElt); |
| 75 | } |
| 76 | $loginElt = tao_helpers_form_FormFactory::getElement('login', 'Textbox'); |
| 77 | $loginElt->setDescription(Layout::getLoginLabel()); |
| 78 | $loginElt->setAttributes(['autofocus' => 'autofocus']); |
| 79 | $loginElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); |
| 80 | $this->form->addElement($loginElt); |
| 81 | |
| 82 | $passwordWidgetId = (isset($this->data['enablePasswordReveal']) && !empty($this->data['enablePasswordReveal'])) |
| 83 | ? 'ViewableHiddenbox' |
| 84 | : 'Hiddenbox'; |
| 85 | $passElt = tao_helpers_form_FormFactory::getElement('password', $passwordWidgetId); |
| 86 | $passElt->setDescription(Layout::getPasswordLabel()); |
| 87 | $passElt->addValidator( |
| 88 | tao_helpers_form_FormFactory::getValidator('NotEmpty') |
| 89 | ); |
| 90 | $this->form->addElement($passElt); |
| 91 | |
| 92 | if (isset($this->data['disableAutocomplete']) && !empty($this->data['disableAutocomplete'])) { |
| 93 | $loginElt->setAttributes(['autofocus' => 'autofocus', 'autocomplete' => 'off']); |
| 94 | $passElt->setAttributes(['autocomplete' => 'off']); |
| 95 | } |
| 96 | } |
| 97 | } |