Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 19
CRAP
0.00% covered (danger)
0.00%
0 / 100
TGroup
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 19
1332
0.00% covered (danger)
0.00%
0 / 100
 __construct
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 42
 show
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 17
 setImageClosed
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setImageOpened
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 setCloseGroupId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getCloseGroupId
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 getImageClosed
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 4
 getImageOpened
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 4
 setOpened
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOpened
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 setCloseble
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getCloseble
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getImage
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getLegend
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setWidth
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 7
 setHeight
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 getHeight
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setAccordionId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getAccordionId
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
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 criar grupo de campos identificados com um titulo
44*
45*/
46class TGroup Extends TForm
47{
48    private $imageClosed;
49    private $imageOpened;
50    private $closeGroupId;
51    private $opened;
52    private $closeble;
53    private $accordionId;
54    // composição
55    private $divLegend;
56    private $objImage;
57    private $objLegend;
58    public function __construct($strName, $strLegend=null, $strHeight=null, $strWidth=null, $boolCloseble=null, $boolOpened=null, $boolOverflowY=null,$boolOverflowX=null, $strAccordionId=null )
59    {
60        $this->divLegend     = new TElement('div');
61        $this->objLegend     = new TElement('span');
62        $this->objImage     = new TElement('img');
63        parent::__construct(null,$strHeight,$strWidth,$strName,"",null);
64        $this->setTagType('div');
65        $this->setFieldType('group');
66        $this->setflat(true);
67        $this->removeField('fw_back_to');
68        $this->setShowHtmlTag(null);
69        $this->setCloseble($boolCloseble);
70        $this->setOpened($boolOpened);
71        $this->setAccordionId($strAccordionId);
72        $this->setOverflowX( ( is_null($boolOverflowX) ? false : $boolOverflowX) );
73        $this->setOverflowY((is_null($boolOverflowY) ? false : $boolOverflowY) );
74        $this->clearCss();
75        $this->setCss(array("margin"=>"2px","padding"=>"0px","border"=>"1px solid silver","width"=>$this->getWidth()."px","height"=>"auto","margin-left"=>"0px","margin-top"=>"15px"));
76
77        //$this->setWidth( is_null($strWidth)   ? '400' : $strWidth );
78        $this->setHeight('auto'); // tem que ser auto, a div body é quem manda na altura e no scroll do componente
79
80
81        $this->divLegend->clearCss();
82        $this->divLegend->setCss(array("padding"=>"0px","margin"=>"0px","position"=>"relative","top"=>"-9px","left"=>"0px","width"=>$this->getWidth()."px","height"=>"14px","border"=>"none","background-color"=>"transparent"));
83
84        $this->objLegend->add($strLegend);
85        $this->objLegend->setClass("fwGroupBoxLegend");
86        $this->objLegend->setCss(array("margin"=>"0px","padding"=>"0px","margin-left"=>"10px","padding-left"=>"5px","padding-right"=>"3px") );
87
88        $this->objImage->clearCss();
89        $this->objImage->setId($this->getId().'_img_open_close');
90        $this->objImage->setProperty('title'        ,'Fechar');
91        $this->objImage->setProperty('tooltip'        ,'true');
92        $this->objImage->setProperty('groupId'        ,$this->getId());
93        $this->objImage->setProperty('groupHeight'    ,$this->getHeight());
94        $this->objImage->setProperty('bodyHeight'    ,( $this->getHeight() != 'auto' ? ($this->getHeight()-13) : $this->getHeight() ) );
95        $this->objImage->setProperty('imgOpened'    ,$this->getImageOpened());
96        $this->objImage->setProperty('imgClosed'    ,$this->getImageClosed());
97        $this->objImage->setProperty('status'        ,'opened');
98        $this->objImage->setCss(array("width"=>"16px","height"=>"16px","cursor"=>"pointer","float"=>"right","margin"=>"0px","padding"=>"0px","margin-top"=>"0px","margin-right"=>"2px"));
99        $this->objImage->setProperty("src"            ,$this->getImageOpened());
100        $this->objImage->addEvent('onclick'            ,'fwGroupboxOpenCloseClick(this)');
101
102        $this->divLegend->add( $this->objImage );
103        $this->divLegend->add( $this->objLegend );
104        $this->add( $this->divLegend, false );
105
106        $this->divBody->clearCss();
107        $h = is_null($strHeight) ? 'auto' : $strHeight;
108        $this->divBody->setCss(array("margin"=>"0px","padding"=>"0px","position"=>"relative","top"=>"-5px","border"=>"0px","width"=>($this->getWidth()-13)."px","height"=>$h,"overflow"=>"hidden","overflow-x"=>"hidden","overflow-y"=>"hidden","padding-left"=>"10px"));
109
110    }
111    public function show($print=true,$flat=false)
112    {
113
114        if( $this->getAccordionId())
115        {
116            $this->objImage->setAttribute('accordion_id',$this->getAccordionId());
117        }
118        //definir os ids dos componentes que compoem o objeto groupbox
119        $this->divLegend->setId($this->getId().'_div_legend');
120        $this->objImage->setId($this->getId().'_img_open_close');
121        $this->objLegend->setId($this->getId().'_legend');
122        if( ! $this->objLegend->getChildren() )
123        {
124            $this->objLegend->setCss('display','none');
125        }
126        $this->divBody->setCss('overflow-x',$this->getOverFlowX());
127        $this->divBody->setCss('overflow-y',$this->getOverflowY());
128        if( ! $this->getCloseble() )
129        {
130            $this->objImage->setCss('display','none');
131        }
132        if( ! $this->getOpened() )
133        {
134            $this->divBody->setCss('height','0px');
135            $this->objImage->setProperty('status','closed');
136            $this->objImage->setProperty('src',$this->getImageClosed());
137            $this->objImage->setProperty('title','Abrir');
138        }
139        return parent::show($print);
140    }
141    public function setImageClosed($strNewValue=null)
142    {
143        $this->imageClosed = $strNewValue;
144        return $this;
145    }
146    public function setImageOpened($strNewValue=null)
147    {
148        $this->imageOpened = $strNewValue;
149        return $this;
150    }
151    public function setCloseGroupId($strNewValue=null)
152    {
153        $this->closeGroupId =  $strNewValue;
154        return $this;
155
156    }
157    public function getCloseGroupId()
158    {
159        if( is_null($this->closeGroupId ) )
160        {
161            $this->setCloseGroupId( $this->getRandomChars() );
162        }
163        return $this->closeGroupId;
164    }
165    public function getImageClosed()
166    {
167        $image = is_null( $this->imageClosed ) ? 'fwFolder.gif' : $this->imageClosed;
168        if( ! file_exists( $image) )
169        {
170            $image = $this->getBase().'imagens/'.$image;
171        }
172        return $image;
173    }
174    public function getImageOpened()
175    {
176        $image = is_null( $this->imageOpened ) ? 'fwFolderOpen.gif' : $this->imageOpened;
177        if( ! file_exists( $image ) )
178        {
179            $image = $this->getBase().'imagens/'.$image;
180        }
181        return $image;
182    }
183    public function setOpened($boolNewValue=null)
184    {
185        $this->opened = $boolNewValue;
186        return $this;
187    }
188    public function getOpened()
189    {
190        return is_null($this->opened) ? true : $this->opened;
191    }
192    public function setCloseble($boolNewValue=null)
193    {
194        $this->closeble = $boolNewValue;
195        return $this;
196    }
197    public function getCloseble()
198    {
199        return ( $this->closeble === true ? true : false ) ;
200    }
201    public function getImage()
202    {
203        return $this->objImagem;
204    }
205    public function getLegend()
206    {
207        return $this->objLegend;
208    }
209    public function setWidth($strNewValue=null)
210    {
211        parent::setWidth($strNewValue);
212        $width = $this->getWidth();
213        $width = is_null($width) ? 0 : $width;
214        $this->setCss("width", $this->getWidth() );
215        $this->divLegend->setCss("width",$this->getWidth() );
216        $this->divBody->setCss("width", ( $this->getWidth()-13) );
217        return $this;
218    }
219    public function setHeight($strNewValue=null)
220    {
221        parent::setHeight('auto');
222        $this->setCss("height",'auto' );
223        $height = is_null( $strNewValue ) ? 'auto' : $strNewValue;
224        $this->divBody->setCss("height",$height);
225        return $this;
226    }
227    public function getHeight($strMinHeight = null)
228    {
229        return $this->divBody->getCss("height");
230    }
231    public function setAccordionId($strNewValue=null)
232    {
233        $this->accordionId = $strNewValue;
234        return $this;
235    }
236    public function getAccordionId()
237    {
238        return $this->accordionId;
239    }
240}
241?>