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 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 44
TFormImage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 8
650
0.00% covered (danger)
0.00%
0 / 44
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 8
 show
0.00% covered (danger)
0.00%
0 / 1
56
0.00% covered (danger)
0.00%
0 / 15
 setBgImage
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
 getBgImage
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 setBgPosition
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBgPosition
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 setBgRepeat
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBgRepeat
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 10
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 * Extensão da classe TForm para criar formulários com imagem de fundo
44 */
45 class TFormImage extends TForm
46 {
47    private $bgImage;
48    private $bgRepeat;
49    private $bgPosition;
50    private $width;
51    private $height;
52    public function __construct($strTitle=null, $strbgImagePath=null, $strBgRepeat=null, $strBgPosition=null, $strHeight=null, $strWidth=null, $strFormName=null, $strMethod=null, $strAction=null,$boolPublicMode=null )
53    {
54        parent::__construct(null, $strHeight, $strWidth, $strFormName, $strMethod, $strAction,$boolPublicMode);
55        $this->width     = $strWidth;
56        $this->height     = $strHeight;
57        $this->setBgImage($strbgImagePath);
58        $this->setBgRepeat($strBgRepeat);
59        $this->setBgPosition($strBgPosition);
60        $this->setRequiredFieldText('');
61    }
62    public function show( $print=true, $flat=false  )
63    {
64        $this->setFlat(true);
65        $this->body->setCss('border-top','0px');
66        $this->body->setCss('border-bottom','0px');
67        $this->setCss('background-color','transparent');
68        $this->setCss('background-image','url('.$this->getBgImage().')');
69        $this->setCss('background-repeat',$this->getBgRepeat());
70        $this->setCss('background-position',$this->getBgPosition());
71        if( $this->width=='' || $this->height==''  )
72        {
73            if( $this->getBgImage() && function_exists('getimagesize') )
74            {
75                list($width, $height) = getimagesize( $this->getBgImage() );
76                   if( is_null($this->width)  )
77                   {
78                    $this->setWidth($width);
79                }
80                if( is_null($this->height ) )
81                {
82                    $this->setHeight($height);
83                }
84            }
85        }
86        return parent::show($print);
87    }
88
89    //-----------------------------------------------------------------------------------
90    public function setBgImage($strNewValue = null,$strRepeat=null)
91    {
92        $this->bgImage = $strNewValue;
93        $this->setBgRepeat( $strRepeat );
94    }
95    public function getBgImage()
96    {
97        if( file_exists($this->bgImage))
98        {
99            return $this->bgImage;
100        }
101        return null;
102    }
103    //-----------------------------------------------------------------------------------
104    public function setBgPosition($strNewValue = null)
105    {
106        $this->bgPosition = $strNewValue;
107    }
108    public function getBgPosition()
109    {
110        return is_null($this->bgPosition) ? 'top': $this->bgPosition;
111    }
112    //-----------------------------------------------------------------------------------
113    public function setBgRepeat($strNewValue = null)
114    {
115        $this->bgRepeat = $strNewValue;
116    }
117    public function getBgRepeat()
118    {
119        if( is_null($this->bgRepeat) && $this->getBgImage() && function_exists('getimagesize') )
120        {
121            list($width, $height) = getimagesize( $this->getBgImage() );
122            //echo $this->getBgImage().' w:'.$width. ' h:'.$height.'<br>';
123            if( $width > 100 && $height < 30 )
124            {
125                return 'repeat-y';
126            }
127            if( $width < 30 && $height < 100 )
128            {
129                return 'repeat-x';
130            }
131            if( $width < 10 && $height < 10 )
132            {
133                return '';
134            }
135            return 'no-repeat';
136        }
137        return $this->bgRepeat;
138    }
139    //-----------------------------------------------------------------------------------
140    //-----------------------------------------------------------------------------------
141    //-----------------------------------------------------------------------------------
142    //-----------------------------------------------------------------------------------
143    //-----------------------------------------------------------------------------------
144    //-----------------------------------------------------------------------------------
145
146}
147?>