Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
35.48% |
11 / 31 |
CRAP | |
50.72% |
35 / 69 |
| TGridColumn | |
0.00% |
0 / 1 |
|
35.48% |
11 / 31 |
242.12 | |
50.72% |
35 / 69 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
15 / 15 |
|||
| setFieldName | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getFieldName | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| show | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setTitle | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getTitle | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setWidth | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getWidth | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 7 |
|||
| setColumnType | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getColumnType | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setRowNum | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getRowNum | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setHeaderAlign | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getHeaderAlign | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
|||
| getHeader | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 3 |
|||
| setReadOnly | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getReadOnly | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setTextAlign | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getTextAlign | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setSortable | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getSortable | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
|||
| setDataType | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getDataType | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
| setColIndex | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getColIndex | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setNoWrap | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getNoWrap | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
|||
| setGridId | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getGridId | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setVisible | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getVisible | |
0.00% |
0 / 1 |
6 | |
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 | class TGridColumn extends TElement |
| 42 | { |
| 43 | private $fieldName; |
| 44 | private $title; |
| 45 | private $width; |
| 46 | private $columnType; |
| 47 | private $headerAlign; |
| 48 | private $textAlign; |
| 49 | private $rowNum; |
| 50 | private $header; |
| 51 | private $readonly; |
| 52 | private $sortable; |
| 53 | private $dataType; |
| 54 | private $colIndex; |
| 55 | private $noWrap; |
| 56 | private $gridId; |
| 57 | private $visible; |
| 58 | |
| 59 | /** |
| 60 | * Classe para construir as colunas no gride |
| 61 | * |
| 62 | * @param string $strFieldName 1: ID da coluna = Nome da coluna da tabela |
| 63 | * @param string $strTitle 2: Nome do Label que irá aparecer |
| 64 | * @param string $strWidth 3: tamanho da coluna |
| 65 | * @param string $strTextAlign 4: Alinhamento do texto left|right|center|justify |
| 66 | * @param boolean $boolReadOnly |
| 67 | * @param boolean $boolSortable |
| 68 | * @param boolean $boolVisivle |
| 69 | * @return TGridColumn |
| 70 | */ |
| 71 | public function __construct($strFieldName=null,$strTitle=null,$strWidth=null,$strTextAlign=null,$boolReadOnly=null,$boolSortable=null,$boolVisible=null) |
| 72 | { |
| 73 | parent::__construct('span'); |
| 74 | $this->clearCss(); |
| 75 | //$strFieldName = is_null($strFieldName)?'':strtolower($strFieldName); |
| 76 | $this->setId($strFieldName); |
| 77 | $this->setFieldName($strFieldName); |
| 78 | $this->setWidth($strWidth); |
| 79 | $this->setTitle($strTitle); |
| 80 | $this->setColumnType('plain'); |
| 81 | $this->setHeaderAlign('center'); |
| 82 | $this->setTextAlign($strTextAlign); |
| 83 | $this->header = new TLabel($this->getId(),$strTitle); |
| 84 | $this->header->clearCss(); |
| 85 | $this->setReadOnly($boolReadOnly); |
| 86 | $this->setSortable($boolSortable); |
| 87 | $this->setVisible($boolVisible); |
| 88 | } |
| 89 | //----------------------------------------------------------------------------------------- |
| 90 | public function setFieldName($strFieldName) |
| 91 | { |
| 92 | $this->fieldName = $strFieldName; |
| 93 | return $this; |
| 94 | } |
| 95 | //----------------------------------------------------------------------------------------- |
| 96 | public function getFieldName() |
| 97 | { |
| 98 | return $this->fieldName; |
| 99 | } |
| 100 | //--------------------------------------------------------------------------------------- |
| 101 | public function show($boolPrint=true) |
| 102 | { |
| 103 | } |
| 104 | //--------------------------------------------------------------------------------------- |
| 105 | public function setTitle($strNewValue=null) |
| 106 | { |
| 107 | $this->title = $strNewValue; |
| 108 | return $this; |
| 109 | } |
| 110 | //--------------------------------------------------------------------------------------- |
| 111 | public function getTitle() |
| 112 | { |
| 113 | return $this->title; |
| 114 | } |
| 115 | //--------------------------------------------------------------------------------------- |
| 116 | public function setWidth($strNewValue=null) |
| 117 | { |
| 118 | $this->width = $strNewValue; |
| 119 | return $this; |
| 120 | } |
| 121 | //--------------------------------------------------------------------------------------- |
| 122 | public function getWidth() |
| 123 | { |
| 124 | if(is_null($this->width)) |
| 125 | { |
| 126 | return 'auto'; |
| 127 | } |
| 128 | else |
| 129 | { |
| 130 | if( strpos($this->width,'%')===false ) |
| 131 | { |
| 132 | $w = @preg_replace('/[^0-9]/','',$this->width).'px'; |
| 133 | $w = $w == 'px' ? 'auto' : $w; |
| 134 | } |
| 135 | else |
| 136 | { |
| 137 | return $this->width; |
| 138 | } |
| 139 | } |
| 140 | return $w; |
| 141 | } |
| 142 | //--------------------------------------------------------------------------------------- |
| 143 | public function setColumnType($strNewValue) |
| 144 | { |
| 145 | $this->columnType = strtolower($strNewValue); |
| 146 | return $this; |
| 147 | } |
| 148 | //--------------------------------------------------------------------------------------- |
| 149 | public function getColumnType() |
| 150 | { |
| 151 | return $this->columnType; |
| 152 | } |
| 153 | //--------------------------------------------------------------------------------------- |
| 154 | public function setRowNum($intNewValue=null) |
| 155 | { |
| 156 | $this->rowNum = $intNewValue; |
| 157 | return $this; |
| 158 | } |
| 159 | //--------------------------------------------------------------------------------------- |
| 160 | public function getRowNum() |
| 161 | { |
| 162 | return $this->rowNum; |
| 163 | } |
| 164 | //---------------------------------------------------------------------------------------- |
| 165 | public function setHeaderAlign($strNewValue=null) |
| 166 | { |
| 167 | $this->headerAlign = $strNewValue; |
| 168 | return $this; |
| 169 | } |
| 170 | //---------------------------------------------------------------------------------------- |
| 171 | public function getHeaderAlign() |
| 172 | { |
| 173 | return is_null( $this->headerAlign ) ? 'center' : $this->headerAlign; |
| 174 | } |
| 175 | //----------------------------------------------------------------------------------------- |
| 176 | public function getHeader() |
| 177 | { |
| 178 | /* |
| 179 | if($this->getDataType() == 'checkbox') |
| 180 | { |
| 181 | if($this->getAllowCheckAll()) |
| 182 | { |
| 183 | $tb = new TTable('chk_'.$this->getId().'_table'); |
| 184 | $tb->setClass('fwGridHeader'); |
| 185 | $tbr= $tb->addRow(); |
| 186 | $chk = new TElement('input'); |
| 187 | $chk->setProperty('type','checkbox'); |
| 188 | $chk->setId('chk_'.$this->getId().'_header'); |
| 189 | $chk->setCss('cursor','pointer'); |
| 190 | //$chk->setCss('float','left'); |
| 191 | //$chk->setCss('clear','both'); |
| 192 | $chk->setProperty('title','marcar/desmarcar todos'); |
| 193 | $chk->addEvent('onclick',"fwGridCheckUncheckAll(this,'{$this->getEditName()}')"); |
| 194 | $tbr->addCell($chk); |
| 195 | $tbr->addCell($this->header->getValue()); |
| 196 | $tb = $tb->show(false); |
| 197 | //$this->header->add($tb); |
| 198 | $this->header->setValue($tb); |
| 199 | } |
| 200 | } |
| 201 | else */ |
| 202 | if( $this->getSortable() && $this->getColumnType() != 'action' ) |
| 203 | { |
| 204 | //<a href="#" title="Ordenar coluna" style="cursor:pointer;" class="sortheader" onclick="ts_resortTable(this, 0);return false;">Nº<span sortdir="up" class="sortarrow"></span></a></ |
| 205 | //$a = '<a href="javascript:void(0);" title="Ordenar coluna" style="cursor:pointer" class="sortheader" onClick="ts_resortTable(this,'.$this->getColIndex().');jQuery(\'#'.$this->getGridId().'_sorted_column\').val(\''.$this->getFieldName().'\');jQuery(\'#'.$this->getGridId().'_sorted_column_order\').val(jQuery(this).find(\'span\').attr(\'sortdir\'));return false;">'.$this->header->getValue().'<span sortdir="up" class="sortarrow"></span></a>'; |
| 206 | //$this->header->setValue($a); |
| 207 | //$this->header->setCss( array('color'=>'#3661F1','text-decoration'=>'underline')); |
| 208 | $this->header->setClass('fwGridHeaderSortable'); |
| 209 | } |
| 210 | return $this->header; |
| 211 | } |
| 212 | //----------------------------------------------------------------------------------------- |
| 213 | public function setReadOnly($boolNewValue=null) |
| 214 | { |
| 215 | $this->readonly = $boolNewValue; |
| 216 | return $this; |
| 217 | } |
| 218 | //----------------------------------------------------------------------------------------- |
| 219 | public function getReadOnly() |
| 220 | { |
| 221 | return (bool) $this->readonly; |
| 222 | } |
| 223 | //------------------------------------------------------------------------------------------- |
| 224 | public function setTextAlign($strNewValue=null) |
| 225 | { |
| 226 | $this->textAlign = $strNewValue; |
| 227 | return $this; |
| 228 | } |
| 229 | //------------------------------------------------------------------------------------------- |
| 230 | public function getTextAlign() |
| 231 | { |
| 232 | return $this->textAlign; |
| 233 | } |
| 234 | //------------------------------------------------------------------------------------------- |
| 235 | public function setSortable($boolNewValue=null) |
| 236 | { |
| 237 | $this->sortable = $boolNewValue; |
| 238 | return $this; |
| 239 | } |
| 240 | //------------------------------------------------------------------------------------------- |
| 241 | public function getSortable() |
| 242 | { |
| 243 | return is_null($this->sortable) ? true : $this->sortable; |
| 244 | } |
| 245 | //------------------------------------------------------------------------ |
| 246 | public function setDataType($newDataType=null) |
| 247 | { |
| 248 | $this->dataType = $newDataType; |
| 249 | return $this; |
| 250 | } |
| 251 | //------------------------------------------------------------------------ |
| 252 | public function getDataType() |
| 253 | { |
| 254 | if( is_null($this->dataType)) |
| 255 | { |
| 256 | return 'text'; |
| 257 | } |
| 258 | return $this->dataType; |
| 259 | } |
| 260 | // |
| 261 | public function setColIndex($newValue=null) |
| 262 | { |
| 263 | $this->colIndex = (int) $newValue; |
| 264 | return $this; |
| 265 | } |
| 266 | public function getColIndex() |
| 267 | { |
| 268 | return (int)$this->colIndex; |
| 269 | } |
| 270 | public function setNoWrap($boolNewValue=null) |
| 271 | { |
| 272 | $this->noWrap = $boolNewValue; |
| 273 | return $this; |
| 274 | } |
| 275 | public function getNoWrap() |
| 276 | { |
| 277 | return ($this->noWrap === true ) ? true : $this->noWrap; |
| 278 | } |
| 279 | public function setGridId($strNewValue=null) |
| 280 | { |
| 281 | $this->gridId = $strNewValue; |
| 282 | } |
| 283 | public function getGridId() |
| 284 | { |
| 285 | return $this->gridId; |
| 286 | } |
| 287 | public function setVisible($boolNewValue=null) |
| 288 | { |
| 289 | $this->visible = $boolNewValue; |
| 290 | } |
| 291 | public function getVisible() |
| 292 | { |
| 293 | return ( $this->visible === false ) ? false : true; |
| 294 | } |
| 295 | } |
| 296 | ?> |