Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 50 |
| TGridRadioColumn | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
342 | |
0.00% |
0 / 50 |
| __construct | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 8 |
|||
| getEdit | |
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 33 |
|||
| setDescField | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getDescField | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setDescValue | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getDescValue | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setValues | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getValues | |
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 | class TGridRadioColumn extends TGridEditColumn |
| 43 | { |
| 44 | private $descField; |
| 45 | private $descValue; |
| 46 | private $values; |
| 47 | public function __construct(string $strEditName |
| 48 | ,string $strTitle=null |
| 49 | ,string $strKeyField,$strDescField=null,$boolReadOnly=null) |
| 50 | { |
| 51 | parent::__construct($strEditName,$strTitle,$strKeyField,'radio',null,null,null,null,$boolReadOnly); |
| 52 | $this->setSortable(true); |
| 53 | if( is_null( $strDescField ) ) |
| 54 | { |
| 55 | $this->setCss('text-align','center'); |
| 56 | } |
| 57 | $this->setDescField($strDescField); |
| 58 | if( $_POST && isset($_POST[$strEditName])) |
| 59 | { |
| 60 | $this->setvalues($_POST[$strEditName]); |
| 61 | } |
| 62 | } |
| 63 | //--------------------------------------------------------------------------------------------------- |
| 64 | public function getEdit() |
| 65 | { |
| 66 | if(!$this->getTitle()) |
| 67 | { |
| 68 | $this->setTitle('[X]'); |
| 69 | } |
| 70 | $radio = new TElement('input'); |
| 71 | $radio->setProperty('type','radio'); |
| 72 | $radio->setCss('vertical-align','middle'); |
| 73 | $radio->setId($this->getEditName().'_'.$this->getRowNum()); |
| 74 | //$radio->setName($this->getEditName().'['.$this->getRowNum().']'); |
| 75 | $radio->setName($this->getEditName().'[]'); |
| 76 | $radio->setValue($this->getValue()); |
| 77 | //$radio->addEvent('onclick',"fwFieldradioBoxClick(this,'".$this->getEditName().'_desc_'.$this->getRowNum()."')"); |
| 78 | if($this->getReadOnly()) |
| 79 | { |
| 80 | $radio->setProperty('disabled','true'); |
| 81 | } |
| 82 | $hidden=null; |
| 83 | if( is_array($this->getValues())) |
| 84 | { |
| 85 | //print $this->getValue().':'; |
| 86 | if( array_search($this->getValue(),$this->getValues()) !== false) |
| 87 | { |
| 88 | $radio->setProperty('checked','true'); |
| 89 | if($radio->getProperty('disabled')) |
| 90 | { |
| 91 | $hidden = new THidden($radio->getName(),$this->getValue()); |
| 92 | $hidden->setName($radio->getName()); |
| 93 | $hidden->setId($radio->getId()); |
| 94 | $radio->setId($radio->getId().'_disabled'); |
| 95 | $radio->setName($radio->getName().'_disabled'); |
| 96 | $radio->add($hidden); |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | } |
| 101 | if($this->getDescField()) |
| 102 | { |
| 103 | $span = new TElement('span'); |
| 104 | $span->setId($this->getEditName().'_desc_'.$this->getRowNum()); |
| 105 | $span->setCss('cursor','pointer'); |
| 106 | $span->setCss('margin-right','2px'); |
| 107 | $span->add($this->getDescValue()); |
| 108 | $span->setEvent('onclick',"fwGetObj('".$this->getEditName()."_".$this->getRowNum()."').click();"); |
| 109 | if($radio->getProperty('checked')) |
| 110 | { |
| 111 | //$span->setCss('color','#0000ff'); |
| 112 | } |
| 113 | $radio->add($span); |
| 114 | } |
| 115 | // adicionar o nome do campo como attibuto do input |
| 116 | $radio->setAttribute('fieldname',$this->getFieldName() ); |
| 117 | $radio->setEvents( $this->getEvents() ); |
| 118 | return $radio; |
| 119 | } |
| 120 | public function setDescField($strNewValue=null) |
| 121 | { |
| 122 | $this->descField = $strNewValue; |
| 123 | } |
| 124 | public function getDescField() |
| 125 | { |
| 126 | return $this->descField; |
| 127 | } |
| 128 | public function setDescValue($strNewValue=null) |
| 129 | { |
| 130 | $this->descValue = $strNewValue; |
| 131 | } |
| 132 | public function getDescValue() |
| 133 | { |
| 134 | return $this->descValue; |
| 135 | } |
| 136 | public function setValues($arrValues=null) |
| 137 | { |
| 138 | $this->values = $arrValues; |
| 139 | } |
| 140 | public function getValues($arrValues=null) |
| 141 | { |
| 142 | return $this->values; |
| 143 | } |
| 144 | } |
| 145 | ?> |