Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
36.36% |
4 / 11 |
CRAP | |
32.69% |
17 / 52 |
| TMemo | |
0.00% |
0 / 1 |
|
36.36% |
4 / 11 |
105.12 | |
32.69% |
17 / 52 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
8 / 8 |
|||
| show | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 26 |
|||
| setColumns | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| getColumns | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setRows | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| getRows | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setShowCounter | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| getShowCounter | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| clear | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| setOnlineSearch | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getOnlineSearch | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| 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 para implementar campos de entrada de dados de varias linhas (textareas) |
| 44 | * |
| 45 | */ |
| 46 | class TMemo extends TEdit |
| 47 | { |
| 48 | private $showCounter; |
| 49 | private $onlineSearch; |
| 50 | public function __construct(string $strName,string $strValue=null,$intMaxLength,$boolRequired=null,$intColumns=null,$intRows=null,$boolShowCounter=null) |
| 51 | { |
| 52 | parent::__construct($strName,$strValue,$intMaxLength,$boolRequired); |
| 53 | parent::setTagType('textarea'); |
| 54 | parent::setFieldType('memo'); |
| 55 | $this->setColumns($intColumns); |
| 56 | $this->setRows($intRows); |
| 57 | $this->setShowCounter($boolShowCounter); |
| 58 | $this->setProperty('wrap','virtual'); //Physical, off |
| 59 | } |
| 60 | public function show($print=true) |
| 61 | { |
| 62 | $this->setProperty('size',null); |
| 63 | $valor = $this->getValue(); |
| 64 | $valor = isset($valor)?(string)trim($valor):''; |
| 65 | if($valor!=""){ |
| 66 | $this->add($this->getValue()); |
| 67 | } |
| 68 | $this->value=null; |
| 69 | // adicionar o evento de validação de tamanho |
| 70 | $this->addEvent('onkeyup','fwCheckNumChar(this,'.$this->maxlength.')'); |
| 71 | // remover os caracteres ENTER deixando somente as quebras de linhas |
| 72 | $this->addEvent('onBlur','fwRemoverCaractere(this,13);this.onkeyup();'); |
| 73 | |
| 74 | // se for para mostrar o contador de caracteres, criar um div externo |
| 75 | if($this->getShowCounter()) |
| 76 | { |
| 77 | $divId = $this->getId().'_div'; |
| 78 | $div = new TDiv($divId); |
| 79 | $div->setCss('display','inline'); |
| 80 | $div->add( parent::show(false).$this->getOnlineSearch()); |
| 81 | $counter = new TElement('span'); |
| 82 | $counter->setId($this->getId().'_counter'); |
| 83 | $counter->setCss('border','none'); |
| 84 | $counter->setCss('font-size','11'); |
| 85 | $counter->setCss('color','#00000'); |
| 86 | $div->add('<br>'); |
| 87 | $div->add($counter); |
| 88 | $script=new TElement('<script>'); |
| 89 | $script->add('// inicializar o contador de caracteres.'); |
| 90 | $script->add('fwGetObj("'.$this->getId().'").onkeyup();'); |
| 91 | $div->add($script); |
| 92 | return $div->show($print); |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | return parent::show($print).$this->getOnlineSearch(); |
| 97 | } |
| 98 | } |
| 99 | public function setColumns($intNewValue=null) |
| 100 | { |
| 101 | $intNewValue = is_null($intNewValue) ? 50 : $intNewValue; |
| 102 | $this->setProperty('cols',$intNewValue); |
| 103 | } |
| 104 | public function getColumns() |
| 105 | { |
| 106 | return $this->getProperty('cols'); |
| 107 | } |
| 108 | public function setRows($intNewValue=null) |
| 109 | { |
| 110 | $intNewValue = is_null($intNewValue) ? 5 : (int) $intNewValue; |
| 111 | $this->setProperty('rows',$intNewValue); |
| 112 | } |
| 113 | public function getRows() |
| 114 | { |
| 115 | return $this->getProperty('rows'); |
| 116 | } |
| 117 | public function setShowCounter($boolShow=null) |
| 118 | { |
| 119 | $boolShow = is_null($boolShow) ? true : (bool) $boolShow; |
| 120 | $this->showCounter = $boolShow; |
| 121 | } |
| 122 | public function getShowCounter() |
| 123 | { |
| 124 | return $this->showCounter; |
| 125 | } |
| 126 | public function clear() |
| 127 | { |
| 128 | $this->clearChildren(); |
| 129 | parent::clear(); |
| 130 | } |
| 131 | public function setOnlineSearch($strNewValue=null) |
| 132 | { |
| 133 | $this->onlineSearch = $strNewValue; |
| 134 | } |
| 135 | public function getOnlineSearch() |
| 136 | { |
| 137 | return $this->onlineSearch; |
| 138 | } |
| 139 | } |
| 140 | ?> |