Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 61 |
| TLoginForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
420 | |
0.00% |
0 / 61 |
| __construct | |
0.00% |
0 / 1 |
90 | |
0.00% |
0 / 32 |
|||
| show | |
0.00% |
0 / 1 |
132 | |
0.00% |
0 / 29 |
|||
| 1 | <?php |
| 2 | /* |
| 3 | * Formdin Framework |
| 4 | * Copyright (C) 2012 Ministério do Planejamento |
| 5 | * Criado por Luís Eugênio Barbosa |
| 6 | * Essa versão é um Fork https://github.com/bjverde/formDin |
| 7 | * |
| 8 | * ---------------------------------------------------------------------------- |
| 9 | * This file is part of Formdin Framework. |
| 10 | * |
| 11 | * Formdin Framework is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU Lesser General Public License version 3 |
| 13 | * as published by the Free Software Foundation. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public License version 3 |
| 21 | * along with this program; if not, see <http://www.gnu.org/licenses/> |
| 22 | * or write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 23 | * Fifth Floor, Boston, MA 02110-1301, USA. |
| 24 | * ---------------------------------------------------------------------------- |
| 25 | * Este arquivo é parte do Framework Formdin. |
| 26 | * |
| 27 | * O Framework Formdin é um software livre; você pode redistribuí-lo e/ou |
| 28 | * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação |
| 29 | * do Software Livre (FSF). |
| 30 | * |
| 31 | * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA |
| 32 | * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou |
| 33 | * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português |
| 34 | * para maiores detalhes. |
| 35 | * |
| 36 | * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título |
| 37 | * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> |
| 38 | * ou escreva para a Fundação do Software Livre (FSF) Inc., |
| 39 | * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
| 40 | */ |
| 41 | |
| 42 | Class TLoginForm extends TForm |
| 43 | { |
| 44 | private $title; |
| 45 | private $height; |
| 46 | private $width; |
| 47 | private $loginLabel; |
| 48 | private $passwordLabel; |
| 49 | private $loginField; |
| 50 | private $passworkField; |
| 51 | private $htmlField; |
| 52 | private $onLoginFunction; |
| 53 | private $onExitFunction; |
| 54 | private $btnLoginLabel; |
| 55 | private $btnExitLabel; |
| 56 | |
| 57 | public function __construct($strOnLoginFunction=null, $strOnExitFunction = null, $strTitle=null, $strFieldLoginLabel=null, $strFieldPasswordLabel=null, $strBtnLoginLabel=null,$strBtnExitLabel=null, $strHeight=null, $strWidth=null) |
| 58 | { |
| 59 | // valores padrão |
| 60 | $strTitle = is_null($strTitle) ? 'Acesso ao Sistema' : $strTitle; |
| 61 | $strHeight = is_null($strHeight) ? '160' : $strHeight; |
| 62 | $strWidth = is_null($strWidth) ? '300' : $strWidth; |
| 63 | $strTitle = is_null($strTitle) ? 'Acesso ao Sistema' : $strTitle; |
| 64 | $strFieldLoginLabel = is_null($strFieldLoginLabel) ? 'Login:' : $strFieldLoginLabel; |
| 65 | $strFieldPasswordLabel = is_null($strFieldPasswordLabel) ? 'Senha:' : $strFieldPasswordLabel; |
| 66 | $strBtnLoginLabel = is_null($strBtnLoginLabel) ? 'Entrar' : $strBtnLoginLabel; |
| 67 | $strBtnExitLabel = is_null($strBtnExitLabel) ? 'Sair' : $strBtnExitLabel; |
| 68 | |
| 69 | |
| 70 | parent::__construct($strTitle,$strHeight,$strWidth); |
| 71 | $this->setShowCloseButton(false); |
| 72 | $this->setShowMessageForm(false); |
| 73 | $this->setAutoSize(true); |
| 74 | $this->setColumns(60); |
| 75 | $this->setPageOverFlow(false); |
| 76 | |
| 77 | $this->loginLabel = $strFieldLoginLabel; |
| 78 | $this->passwordLabel = $strFieldPasswordLabel; |
| 79 | |
| 80 | $this->onLoginFunction = $strOnLoginFunction; |
| 81 | $this->onExitFunction = $strOnExitFunction; |
| 82 | $this->btnLoginLabel = $strBtnLoginLabel; |
| 83 | $this->btnExitLabel = $strBtnExitLabel; |
| 84 | $this->addGroupField('gpFields'); |
| 85 | $this->loginField = $this->addTextField('login',$this->loginLabel,30,true,30,null,true,null,null,false); |
| 86 | $this->passworkField = $this->addPasswordField('password',$this->passwordLabel,true,true,30,null,false); |
| 87 | $this->closeGroup(); |
| 88 | $this->addGroupField('gpMessage')->setvisible(false); |
| 89 | $this->htmlField = $this->addHtmlField('msg'); |
| 90 | $this->htmlField->setCss('text-align','center'); |
| 91 | $this->htmlField->setCss('font-size','18px'); |
| 92 | $this->htmlField->setCss('color','#000000'); |
| 93 | $this->htmlField->setCss('font-weight','bold'); |
| 94 | $this->closeGroup(); |
| 95 | } |
| 96 | public function show($print=true, $flat=false ) |
| 97 | { |
| 98 | $this->setAction($this->btnLoginLabel.','.$this->btnExitLabel); |
| 99 | |
| 100 | $_POST['formDinAcao'] = isset( $_POST['formDinAcao'] ) ? $_POST['formDinAcao'] : null; |
| 101 | if( $_POST['formDinAcao'] == $this->btnLoginLabel ) |
| 102 | { |
| 103 | if( $this->validate() ) |
| 104 | { |
| 105 | $login = $this->get('login'); |
| 106 | $password = $this->get('password'); |
| 107 | $message = null; |
| 108 | $script = null; |
| 109 | $this->setMessage($message); |
| 110 | $this->addJavascript($script); |
| 111 | $this->setTitle(''); |
| 112 | $this->removeField(null,'msg'); |
| 113 | $this->htmlField->setValue('<br>Validando informações!'); |
| 114 | $this->setAction(''); |
| 115 | if( $this->onLoginFunction && function_exists($this->onLoginFunction) ) |
| 116 | { |
| 117 | if( ! call_user_func_array($this->onLoginFunction,array(&$login,&$password,&$message,&$script ) ) ) |
| 118 | { |
| 119 | |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | else if( $_POST['formDinAcao'] == $this->btnExitLabel) |
| 125 | { |
| 126 | if( $this->onLoginFunction && function_exists($this->onExitFunction ) ) |
| 127 | { |
| 128 | die( call_user_func_array($this->onExitFunction,array(&$message,&$script) ) ) ; |
| 129 | } |
| 130 | if( $script ) |
| 131 | { |
| 132 | $this->setMessage($message); |
| 133 | $this->addJavascript($script); |
| 134 | $this->removeField(null,'msg'); |
| 135 | $this->addJavascript('fwApplicationEnd()'); |
| 136 | $this->htmlField->setValue('<br>Encerrando aplicação!'); |
| 137 | $this->setAction(''); |
| 138 | unset($_SESSION[APLICATIVO]); |
| 139 | } |
| 140 | } |
| 141 | return parent::show($print); |
| 142 | } |
| 143 | } |
| 144 | ?> |