Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
26.09% |
6 / 23 |
CRAP | |
34.00% |
51 / 150 |
| TBox | |
0.00% |
0 / 1 |
|
26.09% |
6 / 23 |
600.59 | |
34.00% |
51 / 150 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
36 / 36 |
|||
| showFlat | |
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 16 |
|||
| show | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 54 |
|||
| setWidth | |
100.00% |
1 / 1 |
4 | |
100.00% |
5 / 5 |
|||
| getWidth | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setHeight | |
100.00% |
1 / 1 |
5 | |
100.00% |
6 / 6 |
|||
| getHeight | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| add | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| setCssBody | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| setFlat | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getFlat | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setLegend | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getLegend | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| setLegendText | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| setOpenCloseButton | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| setPosition | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| getPosition | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getDivContent | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getDivBox | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getDivBody | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getOutside | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getOutsideHtml | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| addOutside | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| 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 TBox extends TControl |
| 42 | { |
| 43 | private $divBox; |
| 44 | private $divContent; |
| 45 | public $divBody; |
| 46 | private $flat; |
| 47 | public $legend; // devido a compatibilidade com IE, a legenda só será exibida no modo FLAT |
| 48 | public $openCloseButton; |
| 49 | private $position; |
| 50 | private $outside; |
| 51 | public function __construct($strName=null,$intWidth=null,$intHeight=null,$boolFlat=null) |
| 52 | { |
| 53 | |
| 54 | parent::__construct('fieldset',$strName); |
| 55 | $this->clearCss(); |
| 56 | parent::setFieldType('box'); |
| 57 | parent::setCss('border','none'); |
| 58 | parent::setCss('width','auto'); |
| 59 | parent::setCss('height','auto'); |
| 60 | parent::setCss('overflow','hidden'); |
| 61 | parent::setCss('display','inline'); |
| 62 | parent::setCss('vertical-align','top'); |
| 63 | parent::setCss('margin','0'); |
| 64 | parent::setCss('padding','0'); |
| 65 | parent::setCss('position','relative'); |
| 66 | parent::setCss('background-color','#efefef'); |
| 67 | $this->setFlat($boolFlat); |
| 68 | $this->divBox = new TElement('div'); |
| 69 | $this->divBox->clearCss(); |
| 70 | $this->divBox->setProperty('id','box_'.$strName); |
| 71 | $this->divBox->setCss('padding','0'); |
| 72 | $this->divBox->setcss('margin','0'); |
| 73 | $this->divBox->setcss('border','none'); |
| 74 | $this->divBox->setcss('background-color','transparent'); |
| 75 | $this->divContent = new TElement('div'); |
| 76 | $this->divContent->setProperty('id','content_'.$strName); |
| 77 | $this->divContent->setClass('content'); |
| 78 | $this->divContent->clearCss(); |
| 79 | $this->divContent->setCss('background-color','transparent'); |
| 80 | |
| 81 | $this->divBody = new TElement('div'); |
| 82 | $this->divBody->clearCss(); |
| 83 | $this->divBody->setCss('padding-top','0'); |
| 84 | $this->divBody->setCss('border','none'); |
| 85 | $this->divBody->setCss('overflow','auto'); |
| 86 | $this->divBody->setProperty('id','body_'.$strName); |
| 87 | $this->setWidth($intWidth); |
| 88 | $this->setheight($intHeight); |
| 89 | |
| 90 | $this->outside = new TElement(); |
| 91 | } |
| 92 | public function showFlat($print=true) { |
| 93 | |
| 94 | if(is_object($this->openCloseButton ) ) { |
| 95 | parent::add($this->openCloseButton); |
| 96 | } |
| 97 | if(is_object($this->legend)) { |
| 98 | //parent::add('<img class="fwGroupBoxImage" src="base/imagens/folder.gif">'); |
| 99 | parent::add($this->legend); |
| 100 | } |
| 101 | if( (string)$this->divBody->getCss('width')=="") { |
| 102 | $this->divBody->setCss('width',$this->divBox->getCss('width')); |
| 103 | } |
| 104 | if( (string)$this->divBody->getCss('height')=="") { |
| 105 | $this->divBody->setCss('height',$this->divContent->getCss('height')); |
| 106 | } |
| 107 | if( $this->divBody->getCss('background-color') == "") { |
| 108 | $this->divBody->setCss('background-color',$this->getCss('background-color')); |
| 109 | } |
| 110 | if($this->getCss('border')=='none') { |
| 111 | $this->setCss('border','1px solid #c0c0c0'); |
| 112 | //$this->setClass('fwFieldBoarder'); |
| 113 | } |
| 114 | if( $this->getPosition() ) { |
| 115 | $this->divBody->add('<script>window.setTimeout(\'fwSet_position("'.$this->getId().'","'.$this->getPosition().'")\',100);</script>'); |
| 116 | } |
| 117 | parent::add($this->divBody); |
| 118 | return parent::show($print).$this->getOutsideHtml($print); |
| 119 | } |
| 120 | |
| 121 | public function show($print=true,$flat=false) |
| 122 | { |
| 123 | |
| 124 | //$content = $this->divBody->getChildren(); |
| 125 | // limpar o array de objetos para poder chamar o metodo show() "n" vezes seguidas |
| 126 | //$this->divBox->clearChildren(); |
| 127 | //$this->divContent->clearChildren(); |
| 128 | //$this->divBody->add($content); |
| 129 | if( (bool)$flat==true || $this->getFlat() || is_object($this->legend) ) |
| 130 | { |
| 131 | return $this->showFlat($print); |
| 132 | } |
| 133 | $this->divBody->setCss('height',(int)($this->getHeight()-8- ((int)$this->divBody->getCss('margin-top')) )); |
| 134 | $this->divBody->setCss('width',(int)($this->getwidth()-13)); |
| 135 | $this->divBody->SetCss('position','absolute'); |
| 136 | $this->divBody->SetCss('border','none'); |
| 137 | $this->divBody->SetCss('top','5px'); |
| 138 | $this->divBody->SetCss('left','5px'); |
| 139 | |
| 140 | $this->divContent->add($this->divBody); |
| 141 | |
| 142 | // cria a estrutura de divs com as imagens para da o efeito de caixa com cantos arredondados |
| 143 | $divlb = new TElement('div'); |
| 144 | $divlb->clearCss(); |
| 145 | $divlb->setCss('background-color','transparent'); |
| 146 | $divlb->setClass('lb'); |
| 147 | |
| 148 | $divrb = new TElement('div'); |
| 149 | $divrb->clearCss(); |
| 150 | $divrb->setClass('rb'); |
| 151 | $divrb->setCss('background-color','transparent'); |
| 152 | |
| 153 | |
| 154 | $divbb = new TElement('div'); |
| 155 | $divbb->setClass('bb'); |
| 156 | $divbb->clearCss(); |
| 157 | $divbb->setCss('background-color','transparent'); |
| 158 | |
| 159 | $divblc = new TElement('div'); |
| 160 | $divblc->setClass('blc'); |
| 161 | $divblc->clearCss(); |
| 162 | $divblc->setCss('background-color','transparent'); |
| 163 | |
| 164 | |
| 165 | $divbrc = new TElement('div'); |
| 166 | $divbrc->setClass('brc'); |
| 167 | $divbrc->clearCss(); |
| 168 | $divbrc->setCss('background-color','transparent'); |
| 169 | |
| 170 | $divtb = new TElement('div'); |
| 171 | $divtb->setClass('tb'); |
| 172 | $divtb->clearCss(); |
| 173 | $divtb->setCss('background-color','transparent'); |
| 174 | |
| 175 | $divtlc = new TElement('div'); |
| 176 | $divtlc->setClass('tlc'); |
| 177 | $divtlc->clearCss(); |
| 178 | $divtlc->setCss('background-color','transparent'); |
| 179 | |
| 180 | $divtrc = new TElement('div'); |
| 181 | $divtrc->setClass('trc'); |
| 182 | $divtrc->clearCss(); |
| 183 | $divtrc->setCss('background-color','transparent'); |
| 184 | |
| 185 | $divtrc->add($this->divContent); |
| 186 | $divtlc->add($divtrc); |
| 187 | $divtb->add($divtlc); |
| 188 | $divbrc->add($divtb); |
| 189 | $divblc->add($divbrc); |
| 190 | $divbb->add($divblc); |
| 191 | $divrb->add($divbb); |
| 192 | $divlb->add($divrb); |
| 193 | $this->divBox->add($divlb); |
| 194 | if( $this->getPosition() ) |
| 195 | { |
| 196 | $this->divBody->add('<script>window.setTimeout(\'fwSet_position("'.$this->getId().'","'.$this->getPosition().'")\',100);</script>'); |
| 197 | } |
| 198 | parent::add($this->divBox); |
| 199 | return parent::show($print).$this->getOutsideHtml($print); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * |
| 204 | */ |
| 205 | public function setWidth($strNewWidth=null) |
| 206 | { |
| 207 | if( isset( $strNewWidth ) && (string)$strNewWidth !='auto' ) |
| 208 | { |
| 209 | if(strpos($strNewWidth,'%')===false) |
| 210 | { |
| 211 | /*if( $this->getFieldType()!='groupbox') |
| 212 | { |
| 213 | $strNewWidth = (int)$strNewWidth == 0 ? 100 : (int)$strNewWidth; |
| 214 | } |
| 215 | */ |
| 216 | $strNewWidth = (int)$strNewWidth; |
| 217 | } |
| 218 | } |
| 219 | $this->divBox->setCss('width',$strNewWidth); |
| 220 | return $this; |
| 221 | } |
| 222 | public function getWidth( $strMinWidth = null ) |
| 223 | { |
| 224 | return $this->divBox->getCss('width'); |
| 225 | } |
| 226 | /** |
| 227 | * |
| 228 | */ |
| 229 | public function setHeight($strNewHeight=null) |
| 230 | { |
| 231 | if( isset($strNewHeight ) && (string)$strNewHeight != 'auto') |
| 232 | { |
| 233 | if(strpos($strNewHeight,'%')===false) |
| 234 | { |
| 235 | if( $this->getFieldType()!='groupbox') |
| 236 | { |
| 237 | //$strNewHeight = (int)$strNewHeight == 0 ? 50 : (int)$strNewHeight; |
| 238 | } |
| 239 | $strNewHeight = (int)$strNewHeight; |
| 240 | } |
| 241 | } |
| 242 | $this->divContent->setCss('height',$strNewHeight); |
| 243 | return $this; |
| 244 | } |
| 245 | public function getHeight( $strMinHeight = null ) |
| 246 | { |
| 247 | return $this->divContent->getCss('height'); |
| 248 | } |
| 249 | public function add($value,$body=true){ |
| 250 | if( $body ){ |
| 251 | $this->divBody->add($value); |
| 252 | }else{ |
| 253 | parent::add($value); |
| 254 | } |
| 255 | } |
| 256 | /** |
| 257 | * Define o css que será aplicado na div onde será colocado o conteudo do BOX |
| 258 | * |
| 259 | * @param string $strCssProperty |
| 260 | * @param string $strValue |
| 261 | */ |
| 262 | public function setCssBody($strCssProperty,$strValue){ |
| 263 | $this->divBody->setCss($strCssProperty,$strValue); |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Define se a caixa terá borda 3D ou Simples |
| 268 | * |
| 269 | * @param boolean $boolNewValue |
| 270 | */ |
| 271 | public function setFlat($boolNewValue=null){ |
| 272 | $this->flat = (bool)$boolNewValue; |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Retorna true ou false para exibir a caixa com borda 3D ou Simples |
| 277 | * |
| 278 | */ |
| 279 | public function getFlat(){ |
| 280 | return $this->flat; |
| 281 | } |
| 282 | /** |
| 283 | * Define o objeto legenda |
| 284 | * Obs: devido a compatibilidade com IE, a legenda só será exibida no modo FLAT |
| 285 | * |
| 286 | * @param TElement $objLegend |
| 287 | */ |
| 288 | public function setLegend($objLegend) |
| 289 | { |
| 290 | $this->legend = $objLegend; |
| 291 | } |
| 292 | /** |
| 293 | * Retorna o objeto legenda |
| 294 | * |
| 295 | */ |
| 296 | public function getLegend() |
| 297 | { |
| 298 | if($this->legend) |
| 299 | { |
| 300 | $legend = $this->legend->getChildren(); |
| 301 | return $legend[0]; |
| 302 | } |
| 303 | } |
| 304 | /** |
| 305 | * Define o texto da legenda do grupo |
| 306 | * |
| 307 | * @param string $strLegend |
| 308 | */ |
| 309 | public function setLegendText($strLegend=null) |
| 310 | { |
| 311 | $this->legend->clearChildren(); |
| 312 | if((string)$strLegend!="") |
| 313 | { |
| 314 | $this->legend->add($strLegend); |
| 315 | } |
| 316 | } |
| 317 | public function setOpenCloseButton($objNewValue=null){ |
| 318 | $this->openCloseButton = $objNewValue; |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Define a posição do box na tela. Os valores possíveis são: |
| 323 | * |
| 324 | * TL = Top Left CL = Center Left BL = Bottom Left |
| 325 | * TC = Top Center CC = Center Center BC = Bottom Center |
| 326 | * TR = Top Right CR = Center Right BR = Bottom Right |
| 327 | * |
| 328 | * <code> |
| 329 | * $box->setPosition( 'CC' ); |
| 330 | * </code> |
| 331 | * |
| 332 | * @param mixed $strNewValue |
| 333 | */ |
| 334 | public function setPosition($strNewValue='tl|tc|tr|cl|cc|cr|bl|bc|br') |
| 335 | { |
| 336 | $this->position=$strNewValue; |
| 337 | } |
| 338 | public function getPosition() |
| 339 | { |
| 340 | return $this->position; |
| 341 | } |
| 342 | |
| 343 | public function getDivContent() |
| 344 | { |
| 345 | return $this->divContent; |
| 346 | } |
| 347 | |
| 348 | public function getDivBox() |
| 349 | { |
| 350 | return $this->divBox; |
| 351 | } |
| 352 | |
| 353 | public function getDivBody() |
| 354 | { |
| 355 | return $this->divBody; |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * Método para retornar a instância do objeto outside |
| 360 | * |
| 361 | */ |
| 362 | public function getOutside() |
| 363 | { |
| 364 | return $this->outside; |
| 365 | } |
| 366 | /** |
| 367 | * Método utilizado para retornar o html adicionado fora da área do formulário. |
| 368 | * |
| 369 | */ |
| 370 | public function getOutsideHtml($print=true) |
| 371 | { |
| 372 | return $this->outside->show($print); |
| 373 | } |
| 374 | //----------------------------------------------------------------------------- |
| 375 | /** |
| 376 | * Método utilizado para adicionar objetos e ou códigos html |
| 377 | * fora da área do formulário |
| 378 | */ |
| 379 | public function addOutside($mixNewValue=null) |
| 380 | { |
| 381 | $this->outside->add($mixNewValue); |
| 382 | } |
| 383 | |
| 384 | } |
| 385 | ?> |