Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 11 |
| TMaskEdit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 11 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| setMask | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| getMask | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| show | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
| 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 | /** |
| 43 | * Classe base para criação de inputs de texto com mascara de edição |
| 44 | */ |
| 45 | class TMaskEdit extends TEdit |
| 46 | { |
| 47 | private $mask; |
| 48 | public function __construct($strName,$strValue=null,$strMask=null,$boolRequired=null) |
| 49 | { |
| 50 | parent::__construct($strName,$strValue,null,$boolRequired); |
| 51 | $this->setMask($strMask); |
| 52 | } |
| 53 | //------------------------------------------------------------------------------------- |
| 54 | public function setMask($strNewMask=null) |
| 55 | { |
| 56 | $this->mask=(string)$strNewMask; |
| 57 | $len = strlen($this->mask); |
| 58 | parent::setMaxLenght($len); |
| 59 | } |
| 60 | //------------------------------------------------------------------------------------- |
| 61 | public function getMask() |
| 62 | { |
| 63 | return $this->mask; |
| 64 | } |
| 65 | //------------------------------------------------------------------------------------- |
| 66 | public function show($print=true) |
| 67 | { |
| 68 | if( (string) $this->getMask()!='') |
| 69 | { |
| 70 | //$this->setEvent('onKeyUp','fwColocarMascara(this,"'.$this->getMask().'",event)'); |
| 71 | $this->addEvent('onFocus','MaskInput(this,"'.$this->getMask().'")'); |
| 72 | // retirar a borda vermelha se o campo tiver sido validado errado |
| 73 | } |
| 74 | return parent::show($print); |
| 75 | } |
| 76 | } |
| 77 | /* |
| 78 | return; |
| 79 | $campo = new TMaskEdit('teste','123456789','9.9.9.9.9.9.9.9.9',true); |
| 80 | $campo->show(); |
| 81 | */ |
| 82 | /* |
| 83 | $cpf = new TCpfField('num_cpf','CPF:',true); |
| 84 | $cpf->show(); |
| 85 | $cnpj = new TCnpjField('num_cnpj','CNPJ:',true); |
| 86 | $cnpj->show(); |
| 87 | */ |
| 88 | |
| 89 | ?> |