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 / 98
CRAP
0.00% covered (danger)
0.00%
0 / 639
TApplication
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 98
105950
0.00% covered (danger)
0.00%
0 / 628
 __construct
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 28
 setFormDinMinimumVersion
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 10
 includePathClasses
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 includePathDao
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 setTitle
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getTitle
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 3
 setTitleTag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getTitleTag
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 3
 setSubtitle
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getSubtitle
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setSigla
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
 getSigla
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 18
 setUnit
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getUnit
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setVersionSystem
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getVersionSystem
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setShowMenu
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 getShowMenu
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getAppRootDir
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setAppRootDir
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getImgLogoPath
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setImgLogoPath
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getImgLogoHtml
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 12
 setResponsiveMode
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getResponsiveMode
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 loadModule
0.00% covered (danger)
0.00%
0 / 1
56
0.00% covered (danger)
0.00%
0 / 12
 run
0.00% covered (danger)
0.00%
0 / 1
132
0.00% covered (danger)
0.00%
0 / 45
 setOnPostModuloAndAction
0.00% covered (danger)
0.00%
0 / 1
42
0.00% covered (danger)
0.00%
0 / 21
 setJavaScriptCss
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 23
 clearTempFiles
0.00% covered (danger)
0.00%
0 / 1
132
0.00% covered (danger)
0.00%
0 / 17
 checkIfExistConfigFile
n/a
0 / 0
4
n/a
0 / 0
 defineConstantSystemTitle
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 defineConstantAplicativo
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 includesAppAction
n/a
0 / 0
5
n/a
0 / 0
 criaXmlSegurancaLerMenu
0.00% covered (danger)
0.00%
0 / 1
42
0.00% covered (danger)
0.00%
0 / 21
 getHeaderHtmlForm
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 8
 processRequest
0.00% covered (danger)
0.00%
0 / 1
1190
0.00% covered (danger)
0.00%
0 / 78
 processXajaxRequest
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 21
 setDefaultModule
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getDefaultModule
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setConnectionFile
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 getConnectionFile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setLoginFile
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 6
 getLoginFile
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 setMainMenuFile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getMainMenuFile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setConfigFile
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 addIncludeFile
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 getIncludeFiles
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getConfigFile
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 3
 includeConnectionFile
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 getRealPath
0.00% covered (danger)
0.00%
0 / 1
462
0.00% covered (danger)
0.00%
0 / 39
 includePath
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
 setBackgroundImage
0.00% covered (danger)
0.00%
0 / 1
56
0.00% covered (danger)
0.00%
0 / 10
 setBackgroundRepeat
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBackgroundRepeat
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 setBackgroundPosition
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBackgroundPosition
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getBackgroundImage
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 8
 setWaterMark
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getWaterMark
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 8
 setCssFile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getCssFile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setCssDefaultFormFile
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 getCssFileFormDefault
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setLoginInfo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getLoginInfo
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 3
 setHeaderContent
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getHeaderContent
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 setBodyContent
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBodyContent
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 setFooterContent
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getFooterContent
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 5
 setVerticalAlign
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getVerticalAlign
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 setHorizontalAlign
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getHorizontalAlign
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getHeaderLogo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 getHeaderSubTitle
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 6
 getHeaderTitle
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 7
 getHeaderLogin
0.00% covered (danger)
0.00%
0 / 1
72
0.00% covered (danger)
0.00%
0 / 16
 buildMainMenu
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 7
 buildPageHeader
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 13
 buildPageFooter
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 15
 parsePhpFile
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 7
 getLoCenter
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setBeforeActionFunction
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getBeforeActionFunction
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setonBeforeActionFunction
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOnBeforeActionFunction
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setOnGetLoginInfo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOnGetLoginInfo
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setMenuIconsPath
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getMenuIconsPath
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setMenuTheme
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
 getMenuTheme
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
 setOnBeforeLogin
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOnBeforeLogin
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getLoginDone
0.00% covered (danger)
0.00%
0 / 1
42
0.00% covered (danger)
0.00%
0 / 9
 setWidth
n/a
0 / 0
1
n/a
0 / 0
 getWidth
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 buildCssNorthArea
n/a
0 / 0
7
n/a
0 / 0
 buildCssSouthArea
n/a
0 / 0
7
n/a
0 / 0
 setHeaderBgImage
n/a
0 / 0
6
n/a
0 / 0
 getHeaderBgImage
n/a
0 / 0
1
n/a
0 / 0
 setHeaderBgRepeat
n/a
0 / 0
1
n/a
0 / 0
 getHeaderBgRepeat
n/a
0 / 0
1
n/a
0 / 0
 setFooterBgImage
n/a
0 / 0
4
n/a
0 / 0
 getFooterBgImage
n/a
0 / 0
1
n/a
0 / 0
 setFooterBgRepeat
n/a
0 / 0
1
n/a
0 / 0
 getFooterBgRepeat
n/a
0 / 0
1
n/a
0 / 0
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 */
41if (! defined ( 'DS' )) {
42    define ( 'DS', DIRECTORY_SEPARATOR );
43}
44$currentl_dir = dirname ( __FILE__ );
45$dirClasses = $currentl_dir.DS.'..'.DS;
46
47require_once $dirClasses.'constants.php';
48require_once $dirClasses.'exceptions' . DS. 'UploadException.class.php';
49require_once $dirClasses.'helpers'.DS.'autoload_formdin_helper.php';
50require_once $dirClasses.'..'.DS.'vendor/autoload.php';   //Composer
51require_once 'autoload_formdin.php';
52
53//FPDF
54define( 'FPDF_FONTPATH', $dirClasses.'..'.DS.'lib_fpdf184/font/' ); //Constante usada pela FPDF
55require_once $dirClasses.'..'.DS.'lib_fpdf184/fpdf.php';            //FPDF
56
57class TApplication extends TLayout {
58    private $strTitle;
59    private $strTitleTag;
60    private $strSubtitle;
61    private $strSigla;
62    private $strUnit;
63    private $strVersionSystem;
64    private $defaultModule;
65    private $showMenu;
66    private $connectionFile;
67    private $loginFile;
68    private $mainMenuFile;
69    private $configFile;
70    private $includeFiles;
71    private $waterMark;
72    private $backgroundImage;
73    private $backgroundRepeat;
74    private $backgroundPosition;
75    private $cssFile;
76    private $cssFileFormDefault;
77    private $loginInfo;
78    private $headerContent;
79    private $footerContent;
80    private $bodyContent;
81    private $horizontalAlign;
82    private $verticalAlign;
83    private $loCenter; // instância do LayoutCenter
84    private $beforeActionFunction;
85    private $width;
86    private $onGetLoginInfo;
87    private $menuIconsPath;
88    private $headerBgImage;
89    private $headerBgRepeat;
90    private $footerBgImage;
91    private $footerBgRepeat;
92    private $menuTheme;
93    private $onBeforeLogin;
94    private $appRootDir;
95    private $imgLogoPath;
96    private $responsiveMode;
97
98    /***
99     * Classe para criação da aplicação
100     * 
101     * @param string $strTitle     1: Titulo do sistema
102     * @param string $strSubtitle  2: SubTitulo
103     * @param string $strSigla     3: Sigla
104     * @param string $strUnit      4: Nome da unidade
105     * @param string $intWidth     5: @deprecated - não tem uso, será removido
106     * @param string $charSet      6: @deprecated - não tem uso, será removido
107     */
108    public function __construct($strTitle = null, $strSubtitle = null, $strSigla = null, $strUnit = null, $intWidth = null, $charSet = null) {
109        if( !empty($intWidth) ){
110            throw new InvalidArgumentException('ERRO !! remova o parametro $intWidth');
111        }
112        if( !empty($charSet) ){
113            throw new InvalidArgumentException('ERRO !! remova o parametro $charSet');
114        }        
115        ini_set ( 'xdebug.max_nesting_level', 150 );
116        date_default_timezone_set ( 'America/Sao_Paulo' );
117        
118        $this->includePathDao();
119        $this->includePathClasses();
120        
121        session_start();
122        
123        // desenv: error_reporting( E_ALL | E_STRICT );
124        // error_reporting( E_ALL | E_STRICT );
125        parent::__construct( 'app', 50, 20 ); // criar layout com norte=50px e sul=20px
126        $this->setPadding( 0 );
127        // criar o layout central com area de menu 30px e o iframe central
128        $this->loCenter = new TLayout( 'loCenter', 30 );
129        $this->loCenter->setPadding( '0px' );
130        $this->loCenter->getCenterArea()->setTagType( 'iframe' );
131        $this->loCenter->getCenterArea()->setId( 'app_iframe' );
132        $this->loCenter->getNorthArea()->setId( 'div_main_menu' );
133        $this->loCenter->setNorthInitClosed( false );
134        $this->addLayout( $this->loCenter, 'C' );
135        
136        $this->setTitle( $strTitle );
137        $this->setSubtitle( $strSubtitle );
138        $this->setUnit( $strUnit );
139        $this->setSigla( $strSigla );
140        $this->setShowMenu( true );
141        $this->setResponsiveMode( true );
142        
143        // arquivo css padrão localizado na base base/css
144        $this->addCssFile ( 'css/app.css' );
145        $this->setBackgroundImage ( $this->getBase().'/css/imagens/app/bg_listrado.jpg' );
146        
147        // biblioteca de funções geral
148        $this->addIncludeFile ( $this->getBase().'includes/funcoes.inc' );
149    }
150
151    /***
152     * Sets the minimum formDin version for the system to work
153     * 
154     * Define a versão minima do formDin para o sistema funcionar
155     * @param string $minimumVersion
156     */
157    public function setFormDinMinimumVersion($minimumVersion) {        
158        if ( empty($minimumVersion) ) {
159            throw new DomainException(TMessage::FORM_MIN_VERSION_BLANK);            
160        } else {
161            $t = explode(".", $minimumVersion);
162            if( CountHelper::count($t) != 3 ){
163                throw new DomainException(TMessage::FORM_MIN_VERSION_INVALID_FORMAT);
164            }
165            $t = explode("-", $minimumVersion);
166            $minimumVersion = $t[0];
167            if( !FormDinHelper::versionMinimum($minimumVersion) ){
168                throw new DomainException(TMessage::FORM_MIN_YOU_VERSION.FORMDIN_VERSION.TMessage::FORM_MIN_VERSION_NOT.$minimumVersion);
169            }
170        }
171    }
172
173    private function includePathClasses() {
174        if (file_exists ( 'classes/' )) {
175            $this->includePath ( 'classes/' );
176        }
177    }
178
179    private function includePathDao() {
180        if (file_exists ( 'dao/' )) {
181            $this->includePath ( 'dao/' );
182        }
183    }
184
185    public function setTitle($strNewValue = null) {
186        $this->strTitle = $strNewValue;
187    }
188    public function getTitle() {
189        if (is_null ( $this->strTitle ) && defined ( 'TITULO_SISTEMA' )) {
190            return TITULO_SISTEMA;
191        }        
192        return $this->strTitle;
193    }
194    /**
195     * Define a tag <title> da página que aparecerá na aba do browser
196     *
197     * @param string $strNewValue
198     */
199    public function setTitleTag($strNewValue = null) {
200        $this->strTitleTag = $strNewValue;
201    }
202    public function getTitleTag() {
203        if (is_null ( $this->strTitleTag ) && defined ( 'APLICATIVO' )) {
204            return APLICATIVO;
205        }
206        return $this->strTitleTag;
207    }
208    public function setSubtitle($strNewValue) {
209        $this->strSubtitle = $strNewValue;
210    }
211    public function getSubtitle() {
212        return $this->strSubtitle;
213    }
214    
215    /***
216     * Recebe o nome a sigla do sistema e/ou nome do arquivo
217     * que fará aparecer o logo no cabeçalho 
218     * @param string $strNewValue
219     */
220    public function setSigla($strNewValue) {
221        $this->strSigla = $strNewValue;
222        if (! $this->getTitleTag ()) {
223            $this->setTitleTag ( $this->strSigla );
224        }
225    }
226    public function getSigla() {
227        if( !is_null( $this->getImgLogoHtml() ) ){
228            return $this->getImgLogoHtml();
229        }
230        
231        if (is_null ( $this->strSigla )) {
232            if (! $this->getHeaderBgImage ()) {
233                $this->setSigla ( APLICATIVO );
234            }
235        }
236        if (! $this->strSigla) {
237            return null;
238        }
239        if (preg_match ( '/</', strtolower ( $this->strSigla ) )) {
240            return $this->strSigla;
241        } else if (preg_match ( '/jp?|gif|png|bmp/', $this->strSigla )) {
242            if( FileHelper::exists($this->strSigla) ){
243                return '<img src="' . $this->strSigla . '">';
244            }
245            
246            // procurar na pasta includes/imagens da apliacao e na base/
247            if (file_exists ( $this->getRoot () . 'imagens/' . $this->strSigla )) {
248                return '<img src="' . $this->getRoot () . 'imagens/' . $this->strSigla . '">';
249            } else if (file_exists ( $this->getBase () . 'imagens/' . $this->strSigla )) {
250                return '<img src="' . $this->getBase () . 'imagens/' . $this->strSigla . '">';
251            }
252        } else {
253            return $this->strSigla;
254        }
255    }
256    public function setUnit($strNewValue = null) {
257        $this->strUnit = $strNewValue;
258    }
259    public function getUnit() {
260        return $this->strUnit;
261    }
262    public function setVersionSystem($strVersionSystem = null) {
263        $this->strVersionSystem = $strVersionSystem;
264    }
265    public function getVersionSystem() {
266        return $this->strVersionSystem;
267    }
268    
269    /**
270     * Permite ocultar ou exibir o menu principal da aplicação
271     */
272    public function setShowMenu($boolNewValue = null) {
273        $boolNewValue = is_null ( $boolNewValue ) ? true : $boolNewValue;
274        $this->showMenu = $boolNewValue;
275    }
276    public function getShowMenu() {
277        return $this->showMenu;
278    }
279    
280    /**
281     * @return mixed
282     */
283    public function getAppRootDir() {
284        return $this->appRootDir;
285    }
286    
287    /**
288     * Enter the root directory of the application.
289     * Recommendation to use __DIR__
290     * 
291     * Informe o diretorio raiz da aplicação.
292     * Recomendação usar __DIR__
293     * 
294     * @param mixed $appRootDir
295     */
296    public function setAppRootDir($appRootDir) {
297        $this->appRootDir = $appRootDir;
298    }
299    
300    /**
301     * Returns the relative path of the application logo.
302     * 
303     * Retorna o caminho relativo do logo da aplicação.
304     * 
305     * @return string
306     */
307    public function getImgLogoPath() {
308        return $this->imgLogoPath;
309    }
310    //---------------------------------------------------------------------------------
311    /**
312     * Enter the relative path of the application logo image.
313     * This setting will show the application logo in place of the acronym text.
314     * 
315     * Informe o caminho relativo da imagem do logo da aplicação.
316     * Essa configuração irá mostrar a logo da aplicação no lugar do texto da sigla.
317     * 
318     * @param string $appImgLogoPath
319     */
320    public function setImgLogoPath($imgLogoPath) {
321        $this->imgLogoPath = $imgLogoPath;
322    }    
323    public function getImgLogoHtml(){
324        $stringHtml = null;
325        $appRootDir = $this->getAppRootDir();
326        $appImgLogo = $this->getImgLogoPath();
327        
328        if( !is_null($appImgLogo) ){
329            $appImgLogoExists = FileHelper::exists( $appImgLogo );
330            if ($appImgLogoExists) {
331                $stringHtml = '<img src="'.$appImgLogo.'">';
332            }
333            
334            if ( !is_null($appRootDir) ) {
335                $appImgLogoExists = FileHelper::exists( $appRootDir.$appImgLogo );
336                if ($appImgLogoExists) {
337                    $stringHtml = '<img src="'.$appRootDir.$appImgLogo.'">';
338                }
339            }
340        }        
341        return $stringHtml;
342    }
343    //---------------------------------------------------------------------------------
344    /**
345     * @param boolean $responsiveMode
346     */
347    public function setResponsiveMode($responsiveMode)
348    {
349        $this->responsiveMode = $responsiveMode;
350    }
351    /**
352     * @return boolean
353     */
354    public function getResponsiveMode()
355    {
356        return $this->responsiveMode;
357    }
358    
359    public function loadModule() {
360        // se pressionar F5, recarregar o ultimo módulo solicitado
361        $loadModule = null;
362        if (isset ( $_SESSION [APLICATIVO] ['modulo'] ) && $_SESSION [APLICATIVO] ['modulo']) {
363            
364            if ($_SESSION [APLICATIVO] ['modulo'] != $this->getLoginFile ()) {
365                // $this->addJavascript( '//se pressionar F5, recarregar o ultimo módulo solicitado' );
366                $loadModule = $_SESSION [APLICATIVO] ['modulo'];
367                // $this->addJavascript( 'app_load_module("' . $_SESSION[ APLICATIVO ][ 'modulo' ] . '")' );
368            }
369        }
370        if (!$loadModule) {
371            if ($this->getDefaultModule()) {
372                $loadModule = $this->getDefaultModule();
373                $this->addJavascript( 'var app_default_module="'.$loadModule.'";' );
374                // $this->addJavascript( 'app_load_module("' . $this->getDefaultModule() . '")' );
375            } else {
376                // desenhar o background e marca dagua
377                // $this->addJavascript( 'app_load_module("about:blank")' );
378                $loadModule = 'about:blank';
379            }
380        }
381        if ($loadModule) {
382            $this->addJavascript ( 'app_load_module("'.$loadModule.'")' );
383        }
384    }
385    //---------------------------------------------------------------------------------    
386    /**
387     * Este método inicializa a aplicação e cria a interface da aplicação.
388     * Se for passado o modulo ele apenas inclui módulo e sai funcionando como o modulo ler_modulo.php antigo
389     */
390    public function run() {
391        ini_set ( 'default_charset', $this->getCharset() );
392        ob_start (); // arquivos includes podem conter espaços no final que causam erros nas chamadas ajax
393            $this->checkIfExistConfigFile();
394        ob_clean ();
395        $this->defineConstantAplicativo();        
396        $this->defineConstantSystemTitle();
397        $this->includesAppAction();
398        $this->setOnPostModuloAndAction();
399        
400        // ******************************************************************************************
401        $this->processRequest(); // se existir modulo postado, a aplicação termina nesta linha senão cria a tela básica do aplicativo
402        // ******************************************************************************************
403        
404        $this->clearTempFiles();
405        
406        if( !$this->getLoginFile() && !$this->getMainMenuFile() && !$this->getDefaultModule() ) {
407            $_SESSION [APLICATIVO] = null;
408        }
409        
410        if ( $this->getResponsiveMode() == false &&  $this->getWidth()  ) {
411            $e = new TElement ( 'div' );
412            $e->setCss ( $this->getCss () );
413            $e->SetCss ( array (
414                    'background-color' => 'transparent',
415                    'height' => '100%',
416                    'margin' => '0 auto',
417                    'width' => '100%',
418                    'max-width' => $this->getWidth () . 'px',
419                    'min-width' => '700px',
420                    '_width' => '700px' 
421            ) );
422            
423            $this->setContainer ( $e );
424        }
425        
426        $this->buildCssNorthArea();
427        $this->buildCssSouthArea();
428
429        if ($this->getTitleTag ()) {
430            parent::setTitle ( $this->getTitleTag () );
431        }
432        
433        
434        $this->setJavaScriptCss();
435        
436        if ( $this->getLoginDone() ) {
437            $this->buildPageHeader(); // montar o cabeçalho da pagina
438            $this->buildPageFooter(); // montar o rodapé da pagina
439        } else {
440            $this->buildPageHeader(); // montar o cabeçalho da pagina
441            $this->buildPageFooter(); // montar o rodapé da pagina
442            
443            if ( $this->getLoginFile() ) {
444                if ( FileHelper::exists( $this->getLoginFile() )  ) {
445                    $loginInfo = is_null($this->getLoginInfo())?null:addslashes ( $this->getLoginInfo () );
446                    $this->addJavascript ( 'app_login(false,"' . $this->getLoginFile () . '","' .$loginInfo. '")' );
447                } else {
448                    $this->addJavascript ( 'alert("Tela de login:' . $this->getLoginFile () . ', defindo para a aplicação, não existe.")' );
449                }
450                $this->show ();
451                exit ();
452            }
453        }
454        $this->buildMainMenu();
455        $this->loadModule();
456        $this->show();
457    }
458    
459    /**
460     * 
461     */
462     private function setOnPostModuloAndAction() {
463        if ($this->getBeforeActionFunction()) {
464            $this->includeConnectionFile();
465            $action = null;
466            $module = null;
467            if (isset ( $_REQUEST ['modulo'] )) {
468                $module = $_REQUEST ['modulo'];
469            } else if (isset ( $_POST ['modulo'] )) {
470                $module = $_POST ['modulo'];
471            }
472            if (isset ( $_POST ['formDinAcao'] )) {
473                $action = $_POST ['formDinAcao'];
474            }
475            $params = ( object ) array (
476                    'module' => $module,
477                    'action' => $action 
478            );
479            if (! call_user_func ( $this->getBeforeActionFunction (), $this, $params )) {
480                exit ();
481            }
482            $module = $params->module;
483            $action = $params->action;
484            // echo 'Novo:'.$module.',';
485            $_REQUEST ['modulo'] = $module;
486            $_POST ['modulo'] = $module;
487            $_POST ['formDinAcao'] = $action;
488        }
489     }
490     
491     private function setJavaScriptCss() {
492        // $this->addJsCssFile('greybox/gb_styles.css');
493        // $menuTheme = 'clear_silver'; // Estilos válidos: standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
494        // $menuTheme = 'aqua_dark'; // Estilos válidos: standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
495        // $menuTheme = 'aqua_orange'; // Estilos válidos: standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
496        // $menuTheme = 'aqua_sky'; // Estilos válidos: standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
497        // $menuTheme = 'aqua_sky'; // Estilos válidos: standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
498        // $menuTheme = 'clear_blue'; // Estilos válidos: standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
499        // $menuTheme = 'clear_green'; // Estilos válidos: clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
500        
501        // ajustar css. o height do item pricipal esta muito pequeno
502        // $menuTheme = 'dhx_black'; // dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
503        // $menuTheme = 'dhx_blue'; // dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver
504        
505        // estes estão com o funco combinando com o tema, ver como fazer para os outros que estão cinza
506        // $menuTheme = 'glassy_blue'; // glassy_blue,modern_black,modern_blue,modern_red,clear_silver
507        
508        // heihght ok, falta o fundo na cor do thema
509        // $menuTheme = 'modern_black'; // modern_blue,modern_red,clear_silver
510        // $menuTheme = 'modern_blue'; // modern_red,clear_silver
511        // $menuTheme = 'modern_red';
512        // $menuTheme = 'standard';
513        
514        // javascript
515        $this->addJsCssFile ( 'dhtmlx/dhtmlxcommon.js' );
516        $this->addJsCssFile ( 'dhtmlx/menu/dhtmlxmenu_cas.js' );
517        
518        // o nome do estilo tem que ser alterado no arquivo app.js tambem
519        $this->addJavascript ( "app_layout=true;" );
520        $this->addJavascript ( "pastaBase='{$this->getBase()}';" );
521        $this->addJavascript ( 'GB_ROOT_DIR     = pastaBase+\'js/greybox/\';' );
522        $this->addJavascript ( "menuTheme='{$this->getMenuTheme()}';" );
523        $this->addJavascript ( "menuIconsPath='" . $this->getMenuIconsPath () . "';" );
524        $this->addJavascript ( "aplicativo='" . APLICATIVO . "';" );
525        $this->addJavascript ( "marca_dagua='" . $this->getWaterMark () . "';" );
526        $this->addJavascript ( "background_image='" . $this->getBackgroundImage () . "';" );
527        $this->addJavascript ( "background_repeat='" . $this->getBackgroundRepeat () . "';" );
528        $this->addJavascript ( "background_position='" . $this->getBackgroundPosition () . "';" );
529        
530        $this->addJsCssFile ( $this->getBase () . 'js/dhtmlx/menu/skins/' . $this->getMenuTheme() . '/' . $this->getMenuTheme() . '.css' );
531        $this->addJsCssFile ( 'js/app.js' );
532        $this->addJsCssFile ( 'css/FormDin4.css' );
533        $this->addJsCssFile ( $this->getCssFile() );
534        
535        // arquivo js que será carregado por último se existir
536        $this->addJsCssFile ( 'js/main.js' );
537        
538        // arquivo css que será carregado por último se existir
539        $this->addJsCssFile ( 'css/main.css' );
540        
541        /*
542         * $this->addJsCssFile( 'jquery/jquery.js' );
543         * $this->addJsCssFile( 'jquery/jquery.corner.js' );
544         * $this->addJsCssFile( 'jquery/jAlert/jquery.alerts.js' );
545         * $this->addJsCssFile( 'jquery/jAlert/jquery.alerts.css' );
546         * $this->addJsCssFile( 'lazyload/lazyload-min.js' );
547         */
548        
549        if (! $this->getShowMenu ()) {
550            $this->addJavascript ( 'showMenu = false;' );
551        } else {
552            $this->addJavascript ( 'showMenu = true;' );
553        }
554        
555        $this->addJavascript ( 'app_init()' );
556    }
557
558    
559    /**
560     * Limpar arquivos temporários mas de 2 dias
561     */
562    private function clearTempFiles() {
563        // $h=opendir(getcwd().'/../tmp');
564        $tmpDir = preg_replace ( '/\/\//', '/', $this->getBase () . '/tmp/' );
565        if (is_dir ( $tmpDir )) {
566            $h = opendir ( $tmpDir );
567            if ($h) {
568                $t = time (); // agora
569                while ( $filetmp = readdir ( $h ) ) {
570                    if ($filetmp != '.' && $filetmp != '..') {
571                        $filepath = $tmpDir . $filetmp;
572                        if (! is_dir ( $filepath ) && FileHelper::exists($filepath) ){
573                            $lastModified = @filemtime ( $filepath );
574                            if ($lastModified == NULL)
575                                $lastModified = @filemtime ( utf8_decode ( $filepath ) );
576                            if ($lastModified) {
577                                // 172800 seconds = 2 dias
578                                if ($t - $lastModified > 172800) {
579                                    @unlink ( $filepath );
580                                }
581                            }
582                        }
583                    }
584                }
585                closedir ( $h );
586            }
587        }
588    }
589
590    
591    /**
592     * adicionar os arquivos definidos no setIncludeFile()
593     * @codeCoverageIgnore
594     */
595    private function checkIfExistConfigFile() {
596        if ($this->getIncludeFiles ()) {
597            foreach ( $this->getIncludeFiles () as $k => $v ) {
598                $k = $k; //POG para avitar mensagem de variavel não usada
599                if ( FileHelper::exists($v) ) {
600                    require_once ($v);
601                }
602            }
603        }
604    }
605    
606    // -----------------------------------------------------------------
607    /**
608     * Definir o Titulo do sistema
609     */
610    public function defineConstantSystemTitle() {
611        if (! defined ( 'TITULO_SISTEMA' )) {
612            define ( 'TITULO_SISTEMA', $this->getTitle () );
613        }
614    }
615    
616    // -----------------------------------------------------------------
617    /**
618     * Definir a constante de controle de sessão do aplicativo caso não tenha sido definido no config.inc (php)
619     */
620    public function defineConstantAplicativo() {
621        if (! defined ( 'APLICATIVO' )) {
622            define ( 'APLICATIVO', 'FORMDIN' );
623        }
624    }
625    
626    // -----------------------------------------------------------------
627    /**
628     * Adicionar os arquivos de Actions Gerais ou da aplicação
629     * @codeCoverageIgnore
630     */
631    private function includesAppAction() {
632        if (isset ( $_REQUEST ['app_action'] ) && $_REQUEST ['app_action']) {
633            $this->includeConnectionFile ();
634            // arquivo de actions gerais
635            if (file_exists ( $this->getBase () . 'includes/app_action.php' )) {
636                include ($this->getBase () . 'includes/app_action.php');
637            }
638            // arquivo de actions da aplicação
639            if (file_exists ( 'includes/app_action.php' )) {
640                include ('includes/app_action.php');
641            }
642            exit ();
643        }
644    }
645    
646    
647    /**
648     * utilizado para criar o xml do menu quando o modulo base/seguranca/ler_menu_xml.php for chamado 
649     * @param string $modulo
650     */
651    private function criaXmlSegurancaLerMenu($modulo)
652    {
653        // utilizado para criar o xml do menu quando o modulo base/seguranca/ler_menu_xml.php for chamado
654        if (isset ( $_REQUEST ['content-type'] ) && strtolower ( $_REQUEST ['content-type'] ) == 'xml') {
655            $_SESSION [APLICATIVO] ['modulo'] = null;
656            if (! file_exists ( $modulo )) {
657                header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
658                header ( "Cache-Control: no-cache" );
659                header ( "Pragma: no-cache" );
660                header ( "content-type: text/xml; charset=" . $this->getCharset () . '"' );
661                
662                echo '<menu>
663                            <item id="cadastro" img="error16.gif" text="Arquivo: ' . $modulo . ' não existe."/>
664                            <item id="verifique" text="Verifique as configurações no index.php"/>
665                        </menu>';
666                exit ();
667            }
668            
669            $aFileInfo = pathinfo ( $modulo );
670            
671            if ($aFileInfo ['extension'] == 'php' || $aFileInfo ['extension'] == 'inc') {
672                header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
673                header ( "Cache-Control: no-cache" );
674                header ( "Pragma: no-cache" );
675                header ( "content-type: text/xml; charset=" . $this->getCharset () . '"' );
676                $this->includeConnectionFile ();
677                require_once ($modulo);
678            } else {
679                header ( "content-type: text/xml; charset=" . $this->getCharset () . "'" );
680                
681                echo file_get_contents ( $modulo );
682            }
683            
684            exit ();
685        }
686    }
687    
688    private function getHeaderHtmlForm()
689    {
690        $htmlViewPort = HtmlHelper::getViewPort();
691        $htmlScript = "<!DOCTYPE html>"
692                     ."\n<html>"
693                     ."\n<head>"
694                     ."\n<meta charset=\"".$this->getCharset()."\">"
695                     ."\n".$htmlViewPort
696                     ."\n</head>"
697                     ."\n<body>"
698                     ."\n<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n<td name=\"data_content\" id=\"data_content\" align=\"" . $this->getHorizontalAlign () . "\" valign=\"" . $this->getVerticalAlign () . "\">";
699        return $htmlScript;
700    }
701    
702    // -----------------------------------------------------------------
703    /**
704     * Este método é responsável por processar as requisições web
705     */
706    private function processRequest() {
707        $modulo = '';
708        
709        if (isset ( $_REQUEST ['modulo'] )) {
710            $_POST ['modulo'] = $_REQUEST ['modulo'];
711            $_GET ['modulo'] = $_REQUEST ['modulo'];
712            $modulo = $_REQUEST ['modulo'];
713        } else if (isset ( $_REQUEST ['MODULO'] )) {
714            $modulo = $_REQUEST ['MODULO'];
715            $_POST ['modulo'] = $modulo;
716            $_GET ['modulo'] = $modulo;
717            $_REQUEST ['modulo'] = $modulo;
718        }
719        
720        if (isset ( $_POST ['formDinAcao'] )) {
721            $acao = $_POST ['formDinAcao'];
722        } else if (isset ( $_POST ['FORMDINACAO'] )) {
723            $acao = $_POST ['FORMDINACAO'];
724            $_POST ['formDinAcao'] = $acao;
725            $_GET ['formDinAcao'] = $acao;
726            $_REQUEST ['formDinAcao'] = $acao;
727        }
728        
729        if (isset ( $_POST ['modulo'] ) && ! isset ( $modulo )) {
730            $modulo = $_POST ['modulo'];
731        }
732        
733        if (isset ( $modulo ) && $modulo != '') {
734            if (! $this->getLoginDone ()) {
735                if ($modulo != $this->getLoginFile ()) {
736                    if (ob_get_level () > 0) {
737                        ob_clean ();
738                    }
739                    $_SESSION [APLICATIVO] = null;
740                    $_POST ['fwSession_expired'] = true; // avisar a classe TForm para reiniciar a aplicação
741                                                        // die('<html><head><script>window.setTimeout("top.app_restart(\'Sua sessão foi encerrada.\\\n\\\nPressione OK para continuar.\')",100);</script></head><body></body></html>');
742                    if ((isset ( $_REQUEST ['ajax'] ) && $_REQUEST ['ajax']) || $_REQUEST ['gridOffline']) {
743                        if (strtolower ( $_REQUEST ['dataType'] ) == 'json') {
744                            $resAjax = null;
745                            $resAjax ['status'] = - 1;
746                            $resAjax ['data'] = null;
747                            $resAjax ['message'] = 'fwSession_expired';
748                            echo json_encode ( $resAjax );
749                            die ();
750                        } else if (strtolower ( $_REQUEST ['dataType'] ) == 'text') {
751                            die ( 'fwSession_expired' );
752                        } else if (strtolower ( $_REQUEST ['dataType'] ) == 'textjson') {
753                            die ( '{"fwSession_expired":"1"}' );
754                        } else {
755                            die ( 'Sessão Expirada. Efetue login novamente.' );
756                        }
757                        
758                        die ();
759                    }
760                }
761            }
762            
763            // ajustar caminho do modulo recebido
764            $modulo = $this->getRealPath ( $modulo );
765            
766            $this->criaXmlSegurancaLerMenu($modulo);
767            
768            $htmlScript = $this->getHeaderHtmlForm();
769            
770            if (! file_exists ( $modulo )) {
771                echo $htmlScript;
772                $this->addJavascript ( 'top.app_show_message("Modulo ' . $_POST ['modulo'] . ' não encontrado","ERROR",8)' );
773                $this->addJavascript ( 'top.app_setFooterModule();' );
774                
775                echo $this->getJavascript ( true, false );
776                $_POST ['modulo'] = null;
777                $_GET ['modulo'] = null;
778                $_REQUEST ['modulo'] = null;
779                $_SESSION [APLICATIVO] ['modulo'] = null;
780                unset ( $_SESSION [APLICATIVO] ['modulo'] );
781            } else {
782                
783                $this->includeConnectionFile ();
784                if ((isset ( $_REQUEST ['fpdf'] ) && $_REQUEST ['fpdf']) || (isset ( $_REQUEST ['pdf'] ) && $_REQUEST ['pdf'])) {
785                    require_once ($modulo);
786                    exit ();
787                }
788                
789                if (file_exists ( $this->getBase () . 'includes/formDin4Ajax.php' )) {
790                    require_once ($this->getBase () . 'includes/formDin4Ajax.php');
791                }
792                
793                if ((isset ( $_REQUEST ['ajax'] ) && $_REQUEST ['ajax']) || (isset ( $_REQUEST ['gridOffline'] ) && $_REQUEST ['gridOffline'] == 1)) {
794                    require_once ($modulo);
795                    exit ();
796                }
797                
798                // se existir o modulo terminado com xajax este será chamado
799                if ($xajax = $this->processXajaxRequest ( $modulo )) {
800                    $xajax->processRequest ();
801                }
802                
803                if (! isset ( $_REQUEST ['subform'] ) || ! $_REQUEST ['subform']) {
804                    // guardar o modulo na sessão para reexibir a página se o usuario pressionar F5
805                    $_SESSION [APLICATIVO] ['modulo'] = $_POST ['modulo'];
806                }
807                
808                echo $htmlScript;
809                
810                //TODO incluir dados estatisticos aqui
811                
812                require_once ($modulo);
813                
814                // evitar notice do php
815                if (! isset ( $acao )) {
816                    $acao = null;
817                }
818                
819                // quando for subformularios dentro de um facebox, não sobrepor o nome do modulo principal aberto guardado na sessão
820                if (! isset ( $_REQUEST ['subform'] )) {
821                    $this->addJavascript ( "try{ parent.app_setFooterModule(\"{$modulo}\",\"{$acao}\");}catch(e){}" );
822                }
823                
824                echo $this->getJavascript ( true );
825                
826                if ($xajax) {
827                    // $xajax->configure('javascript URI', $this->getBase().'js/');
828                    // $xajax->register(XAJAX_EVENT_HANDLER,'afterProcessing','xajaxDone');
829                    $xajax->printJavascript ();
830                    
831                    echo "
832                    <script>
833                    //http://xajaxproject.org/en/docs-tutorials/upgrading-from-xajax-0-2-x-to-0-5/
834                    // fazer controle de requisições xajax
835                    var globalXajaxRequests    = 0;
836                    xajax.callback.global.onRequest = function()
837                    {
838                        globalXajaxRequests++;
839                        //alert('Requisição n. '+globalXajaxRequests);
840                        try{parent.app_setFooterMessage('Xajax:'+globalXajaxRequests);}catch(e){}
841                        //xajax.$('loadingMsg').style.display = 'block';
842                    };
843                    xajax.callback.global.onComplete = function()
844                    {
845                        globalXajaxRequests--;
846                        if(globalXajaxRequests<0)
847                        {
848                            globalXajaxRequests = 0;
849                        }
850                        //xajax.$('loadingMsg').style.display = 'none';
851                        try{parent.app_setFooterMessage('Xajax:'+globalXajaxRequests);}catch(e){}
852                    };
853                    xajax.callback.global.onFailure = function(args)
854                    {
855                        alert('Xajax Falha. HTTP status code: ' + args.request.status);
856                    }
857                    </script>
858                    ";
859                }
860            }
861            
862            echo "</td>\n</tr>\n</table>\n</body>\n</html>";
863            
864            exit ();
865        }
866    }
867    
868    /**
869     * Este método faz a integração da aplicação com a classe XAJAX
870     * Ao receber o modulo, ela verifica se existe o arquivo correspondente terminado em _xajax.
871     * Se existir este será incluido e todas as suas funções serão extraidas e registradas automaticamente.
872     *
873     * @param string $modulo
874     * @return object xajax
875     */
876    protected function processXajaxRequest($modulo) {
877        // fazer integração com a classe XAJAX
878        $moduloXajax = str_replace ( '.inc', '_xajax.php', str_replace ( '.php', '_xajax.php', $modulo ) );
879        $xajax = null;
880        
881        if (strpos ( $moduloXajax, 'xajax.php' ) > 0) {
882            if (file_exists ( $moduloXajax )) {
883                $_POST ['modulo_xajax'] = $moduloXajax;
884                require_once ($this->getBase () . 'classes/xajax_core/xajax.inc.php');
885                // $xajax = new xajax();
886                $xajax = new xajax ( $_SERVER ["SCRIPT_URI"] . '?modulo=' . $modulo );
887                $xajax->configure ( 'javascript URI', $this->getBase () . 'js/' );
888                // $xajax->configure('errorHandler', true);
889                // $xajax->configure('logFile', 'xajax_error_log.log');
890                // $xajax->configure('debug', true);
891                $xajax->setCharEncoding ( ENCODINGS );
892                $xajax->setFlag ( "decodeUTF8Input", true );
893                require_once ($moduloXajax);
894                $lines = file ( $moduloXajax, FILE_SKIP_EMPTY_LINES );
895                
896                foreach ( $lines as $line_num => $line ) {
897                    $line_num = $line_num;  //POG para evisar aviso de variavel não usada
898                    $line = trim ( $line );
899                    
900                    if (strpos ( $line, 'function ' ) === 0) {
901                        $posFunction = strpos ( $line, ' ' ) + 1;
902                        $posParenteses = strpos ( $line, '(' );
903                        $functionName = substr ( $line, $posFunction, $posParenteses - $posFunction );
904                        // print $functionName .'<br>';
905                        // $xajax->registerFunction($functionName);
906                        $xajax->register ( XAJAX_FUNCTION, $functionName );
907                    }
908                }
909            }
910        }
911        
912        return $xajax;
913    }
914    public function setDefaultModule($strNewValue = null) {
915        $this->defaultModule = $strNewValue;
916    }
917    public function getDefaultModule() {
918        return $this->defaultModule;
919    }    
920    // -------------------------------------------------------------------------------------------
921    public function setConnectionFile($strNewValue = null) {
922        $this->connectionFile = $strNewValue;
923        
924        if ($strNewValue) {
925            if (! file_exists ( $strNewValue )) {
926                die ( 'Arquivo ' . $strNewValue . ' informado não existe!' );
927            }
928        }
929    }    
930    // -------------------------------------------------------------------------------------------
931    public function getConnectionFile() {
932        return $this->connectionFile;
933    }    
934    // -------------------------------------------------------------------------------------------
935    public function setLoginFile($strNewValue = null, $onBeforeLoginFunction = null) {
936        if ( !empty($strNewValue) && !FileHelper::exists($strNewValue) ) {
937            throw new LogicException('File not Exists: '.$strNewValue);
938        }
939        $this->loginFile = $strNewValue;
940        if (! is_null ( $onBeforeLoginFunction )) {
941            $this->setOnBeforeLogin ( $onBeforeLoginFunction );
942        }
943    }    
944    // -------------------------------------------------------------------------------------------
945    public function getLoginFile() {
946        // tentar encontrar o arquivo na pasta modulos
947        if ( !FileHelper::exists( $this->loginFile ) ) {
948            return $this->getRealPath ( $this->loginFile );
949        }
950        return $this->loginFile;
951    }    
952    // -------------------------------------------------------------------------------------------
953    public function setMainMenuFile($strNewValue = null) {
954        $this->mainMenuFile = $strNewValue;
955    }    
956    // -------------------------------------------------------------------------------------------
957    public function getMainMenuFile() {
958        return $this->mainMenuFile;
959    }    
960    // --------------------------------------------------------------------------------------------
961    public function setConfigFile($strNewValue = null) {
962        $this->configFile = $strNewValue;
963        if (! is_null ( $this->configFile ) && file_exists ( $this->configFile )) {
964            require_once ($this->configFile);
965        } else {
966            $this->addWarning ( 'config file ' . $strNewValue . ' not found!' );
967        }
968    }    
969    // --------------------------------------------------------------------------------------------
970    public function addIncludeFile($strFileName = null) {
971        if ($strFileName) {
972            $this->includeFiles [$strFileName] = $strFileName;
973        }
974    }    
975    // --------------------------------------------------------------------------------------------
976    public function getIncludeFiles() {
977        return $this->includeFiles;
978    }    
979    // --------------------------------------------------------------------------------------------
980    public function getConfigFile() {
981        if (isset ( $this->configFile ) && file_exists ( $this->configFile )) {
982            return $this->configFile;
983        }        
984        return null;
985    }
986    // --------------------------------------------------------------------------------------------
987    private function includeConnectionFile() {
988        if ($this->getConnectionFile ()) {
989            if (file_exists ( $this->getConnectionFile () )) {
990                require_once ($this->getConnectionFile ());
991            } else {
992                $this->addJavascript ( 'alert("Arquivo de conexão:' . $this->getConnectionFile () . ', defindo para a aplicação, não existe.")' );
993            }
994        }
995    }    
996    // -----------------------------------------------------------------------------
997    /**
998     * Método para encontrar e retornar o caminho correto do módulo dentro do diretório modulos/ da aplicação
999     *
1000     * @param string $strFileName
1001     */
1002    public function getRealPath($strFileName = null) {
1003        if ($strFileName == '') {
1004            return $strFileName;
1005        }
1006        if ($strFileName == 'menu_principal.php') {
1007            return $strFileName;
1008        }
1009        
1010        if (file_exists ( 'modulos/' )) {
1011            $pathModulos = 'modulos/';
1012        } else {
1013            if (strpos ( $strFileName, 'modulos/' ) === false || strpos ( $strFileName, 'modulos/' ) > 0) {
1014                $pathModulos = str_replace ( 'base/', 'modulos/', $this->getBase () );
1015            }
1016        }
1017        
1018        $aFileParts = pathinfo ( $strFileName );
1019        
1020        $baseName = $aFileParts ['basename'];
1021        $fileName = $aFileParts ['filename'];
1022        $dirName = $aFileParts ['dirname'];
1023        // extensão padrão é inc
1024        $extName = isset ( $aFileParts ['extension'] ) ? $aFileParts ['extension'] : 'inc';
1025        $dirName = ($dirName == '.') ? '' : $dirName;
1026        $dirName = ($dirName == './') ? '' : $dirName;
1027        $dirName .= ($dirName != '') ? '/' : '';
1028        
1029        // se exisiter o diretório, não acrescenter o diretório modulos/
1030        if ($dirName != '' && is_dir ( $dirName )) {
1031            $pathModulos = '';
1032        }
1033        
1034        if (! $fileName) {
1035            $fileName = basename ( $baseName, '.' . $extName );
1036        }
1037        
1038        // 1º possibilidade: Estrutura de Visão e Controle
1039        $file = $pathModulos . $dirName . $fileName;
1040        
1041        if (is_dir ( $file )) {
1042            $fileOut = $file . '/' . $fileName . '.' . $extName;
1043            
1044            if (file_exists ( $fileOut )) {
1045                return $fileOut;
1046            }
1047            
1048            $extName2 = $extName == 'inc' ? 'php' : 'inc';
1049            $fileOut = $file . '/' . $fileName . '.' . $extName2;
1050            
1051            if (file_exists ( $fileOut )) {
1052                return $fileOut;
1053            }
1054        }
1055        
1056        // 2º possibilidade modelo normal na pasta modulos
1057        $fileOut = $pathModulos . $dirName . $fileName . '.' . $extName;
1058        
1059        if (file_exists ( $fileOut )) {
1060            return $fileOut;
1061        }
1062        
1063        $extName2 = $extName == 'inc' ? 'php' : 'inc';
1064        $fileOut = $pathModulos . $dirName . $fileName . '.' . $extName2;
1065        
1066        if (file_exists ( $fileOut )) {
1067            return $fileOut;
1068        }
1069        
1070        if (file_exists ( $strFileName )) {
1071            return $strFileName;
1072        }
1073        
1074        return null;
1075    }
1076    
1077    /**
1078     * Adicinar diretórios no caminho de pesquisa de arquivos do php
1079     *
1080     * @param string $path
1081     */
1082    public function includePath($path = null) {
1083        if ($path) {
1084            $path = PATH_SEPARATOR . $path . PATH_SEPARATOR . get_include_path ();
1085            set_include_path ( preg_replace ( '/' . PATH_SEPARATOR . PATH_SEPARATOR . '/', PATH_SEPARATOR, $path ) );
1086        }
1087        return $this;
1088    }
1089    
1090    /**
1091     * Define a imagem que será exibida no fundo da tela principal da aplicação
1092     * Se for uma imagem do diretório base/imagem/ ou ./imagem/ basta informar o nome da imagem
1093     *
1094     * @param string $strNewValue
1095     */
1096    public function setBackgroundImage($strNewValue = null, $strRepeat = null, $strPosition = null) {
1097        $this->backgroundImage = $strNewValue;
1098        if ($strNewValue && file_exists ( $strNewValue )) {
1099            if ( function_exists ( 'getimagesize' ) && FileHelper::exists($this->getFooterBgImage($strNewValue)) ) {
1100                list ( $width, $height ) = getimagesize ( $strNewValue );
1101                if (($width + $height) > 800) {
1102                    $this->setBackgroundRepeat ( 'repeat-y' );
1103                }
1104            }
1105        }
1106        if ($strRepeat) {
1107            $this->setBackgroundRepeat ( $strRepeat );
1108        }
1109        $this->setBackgroundPosition ( $strPosition );
1110    }
1111    public function setBackgroundRepeat($strNewValue = null) {
1112        $this->backgroundRepeat = $strNewValue;
1113    }
1114    public function getBackgroundRepeat() {
1115        return is_null ( $this->backgroundRepeat ) ? 'repeat' : $this->backgroundRepeat;
1116    }
1117    public function setBackgroundPosition($strNewValue = null) {
1118        $this->backgroundPosition = $strNewValue;
1119    }
1120    public function getBackgroundPosition() {
1121        return is_null ( $this->backgroundPosition ) ? '' : $this->backgroundPosition;
1122    }
1123    
1124    /**
1125     * Retorna a imagem que será exibida no fundo da tela principal da aplicação
1126     * Se for uma imagem do diretório base/imagem/ ou ./imagem/ basta informar o nome da imagem
1127     *
1128     * @param string $strNewValue
1129     */
1130    public function getBackgroundImage() {
1131        if (isset ( $this->backgroundImage )) {
1132            if (file_exists ( $this->backgroundImage )) {
1133                return $this->backgroundImage;
1134            } else {
1135                if (file_exists ( $this->getRoot () . 'imagens/' . $this->backgroundImage )) {
1136                    return $this->getRoot () . 'imagens/' . $this->backgroundImage;
1137                } else if (file_exists ( $this->getBase () . 'imagens/' . $this->backgroundImage )) {
1138                    return $this->getBase () . 'imagens/' . $this->backgroundImage;
1139                }
1140            }
1141        }
1142        
1143        return null;
1144    }
1145    
1146    /**
1147     * Define a imagem que será exibida no centro da tela principal da aplicação
1148     * Se for uma imagem do diretório base/imagem/ ou ./imagem/ basta informar o nome da imagem
1149     *
1150     * @param string $strNewValue
1151     */
1152    public function setWaterMark($strNewValue = null) {
1153        $this->waterMark = $strNewValue;
1154        // $this->backgroundImage=null;
1155    }
1156    
1157    /**
1158     * Retorna a imagem definida como marca d`agua da aplicacao
1159     */
1160    public function getWaterMark() {
1161        if (isset ( $this->waterMark )) {
1162            if (file_exists ( $this->waterMark )) {
1163                return $this->waterMark;
1164            } else {
1165                if (file_exists ( $this->getRoot () . 'imagens/' . $this->waterMark )) {
1166                    return $this->getRoot () . 'imagens/' . $this->waterMark;
1167                } else if (file_exists ( $this->getBase () . 'imagens/' . $this->waterMark )) {
1168                    return $this->getBase () . 'imagens/' . $this->waterMark;
1169                }
1170            }
1171        }
1172        
1173        return null;
1174    }
1175    
1176    /**
1177     * Configura um arquivo de CSS para parte externa da Aplicação: Hearder, Footer. 
1178     * Não funciona com o form. Para configura o CSS padrão de todos os 
1179     * forms utilize setCssDefaultFormFile
1180     * @param string $strNewValue
1181     */
1182    public function setCssFile($strNewValue = null) {
1183        $this->cssFile = $strNewValue;
1184    }
1185    public function getCssFile() {
1186        return $this->cssFile;
1187    }
1188    
1189    /**
1190     * Configura um arquivo de CSS Default para todos os formulários.
1191     * Para configura o CSS da parte externa utilize setCssFile
1192     * @param string $strNewValue
1193     */
1194    public function setCssDefaultFormFile($strNewValue = null) {
1195        if (file_exists ( $strNewValue )) {
1196           $this->cssFileFormDefault = $strNewValue;
1197           define('CSS_FILE_FORM_DEFAULT', $strNewValue);
1198        }else{
1199            throw new DomainException(TMessage::CSS_FILE_FORM_DEFAULT_FAIL);
1200        }
1201    }
1202    public function getCssFileFormDefault() {
1203        return $this->cssFileFormDefault;
1204    }
1205    
1206    
1207    public function setLoginInfo($strInfo = null) {
1208        $this->loginInfo = preg_replace ( '/' . chr ( 10 ) . '/', '<br/>', $strInfo );
1209    }
1210    public function getLoginInfo() {
1211        if (isset ( $this->onGetLoginInfo ) && function_exists ( $this->removeIllegalChars ( $this->onGetLoginInfo ) )) {
1212            return call_user_func ( $this->getOnGetLoginInfo () );
1213        }
1214        return $this->loginInfo;
1215    }
1216    
1217    /**
1218     * Define o conetudo ou o arquivo para montagem do cabeçalho da página
1219     * 
1220     * @param string $strNewValue
1221     */
1222    public function setHeaderContent($strNewValue = null) {
1223        $this->headerContent = $strNewValue;
1224    }
1225    public function getHeaderContent() {
1226        if ( FormDinHelper::pregMatch( '/\.php?|\.inc|\.htm?/', $this->headerContent ) > 0) {
1227            if ( FileHelper::exists( $this->headerContent) ) {
1228                // $code= file_get_contents($this->headerContent);
1229                // $code= file_get_contents($this->headerContent);
1230                return $this->parsePhpFile ( $this->headerContent );
1231            } else {
1232                return 'Arquivo <b>' . $this->headerContent . '<b> definido para o cabeçalho não encontrado.';
1233            }
1234        }        
1235        return $this->headerContent;
1236    }
1237    
1238    /**
1239     * Define o conetudo ou o arquivo para montagem do corpo da página
1240     *
1241     * @param string $strNewValue
1242     */
1243    public function setBodyContent($strNewValue = null) {
1244        $this->bodyContent = $strNewValue;
1245    }
1246    public function getBodyContent() {
1247        if ( FormDinHelper::pregMatch( '/\.php?|\.inc|\.htm?/', $this->bodyContent ) > 0) {
1248            if ( FileHelper::exists( $this->bodyContent )) {
1249                return file_get_contents ( $this->bodyContent );
1250            } else {
1251                return 'Arquivo <b>' . $this->bodyContent . '<b> definido para o corpo não encontrado.';
1252            }
1253        }        
1254        return $this->bodyContent;
1255    }
1256    
1257    /**
1258     * Define o conetudo ou o arquivo para montagem do rodapé
1259     *
1260     * @param string $strNewValue
1261     */
1262    public function setFooterContent($strNewValue = null) {
1263        $this->footerContent = $strNewValue;
1264    }
1265    public function getFooterContent() {
1266        if (FormDinHelper::pregMatch( '/\.php?|\.inc|\.htm?/', $this->footerContent ) > 0) {
1267            if ( FileHelper::exists($this->footerContent) ){
1268                return file_get_contents ( $this->footerContent );
1269            } else {
1270                return 'Arquivo <b>' . $this->footerContent . '<b> definido para o rodapé não encontrado.';
1271            }
1272        }
1273        return $this->footerContent;
1274    }
1275    
1276    /**
1277     * Define o alinhamento vertical dos formulários na tela
1278     *
1279     * @param mixed $strNewValue
1280     *            - top,center,bottom
1281     */
1282    public function setVerticalAlign($strNewValue = null) {
1283        $this->verticalAlign = $strNewValue;
1284    }
1285    
1286    /**
1287     * Recupera o valor definido para o alinhamento vertical dos formulários na tela
1288     */
1289    public function getVerticalAlign() {
1290        return (is_null ( $this->verticalAlign ) || strtolower ( $this->verticalAlign ) == 'center') ? 'middle' : $this->verticalAlign;
1291    }
1292    
1293    /**
1294     * Define o alinhamento horizontal dos formulários na tela
1295     *
1296     * @param mixed $strNewValue
1297     */
1298    public function setHorizontalAlign($strNewValue = null) {
1299        $this->horizontalAlign = $strNewValue;
1300    }
1301    
1302    /**
1303     * Recupera o valor do alinhamento vertical dos formulários na tela
1304     */
1305    public function getHorizontalAlign() {
1306        return is_null ( $this->horizontalAlign ) ? 'center' : $this->horizontalAlign;
1307    }
1308    
1309    private function getHeaderLogo() {
1310        $app_header_logo = new TDiv( 'app_header_logo' );
1311        $sigla = $this->getSigla();
1312        $app_header_logo->add( $sigla );
1313        return $app_header_logo;
1314    }
1315    
1316    private function getHeaderSubTitle() {
1317        $app_header_subtitle = null;
1318        if ( $this->getSubtitle() ) {
1319            $app_header_subtitle = new TDiv( 'app_header_subtitle' );
1320            $title = $this->getSubtitle();
1321            $app_header_subtitle->add( $title );
1322        }
1323        return $app_header_subtitle;
1324    }
1325    
1326    private function getHeaderTitle() {
1327        $app_header_title = new TDiv( 'app_header_title' );
1328        //$app_header_title->setAttribute('class','elm');
1329        
1330        $app_header_title_main = new TDiv( 'app_header_title_main' );
1331        $title = $this->getTitle();
1332        $app_header_title_main->add( $title );
1333        
1334        $app_header_title->add( $app_header_title_main );
1335        $app_header_title->add( $this->getHeaderSubTitle() );
1336        
1337        return $app_header_title;
1338    }
1339    
1340    private function getHeaderLogin()
1341    {        
1342        $userInfo  = null;
1343        $btnLogOut = null;
1344        if ($this->getLoginDone ()) {
1345            // exibir o botão de ecerrar a sessão somente se existir tela de login definida
1346            if ($this->getLoginFile ()) {
1347                $btnLogOut = '<input id="button_end_session" type="button" value="Encerrar Sessão" onclick="app_login(1,\'' . $this->getLoginFile () . '\')">';
1348            }
1349            if ($this->getLoginInfo ()) {
1350                $userInfo = $this->getLoginInfo ();
1351            } else if (isset ( $_SESSION [APLICATIVO] ["login"] ["num_cpf"] ) && $_SESSION [APLICATIVO] ["login"] ["num_cpf"]) {
1352                $userInfo = 'CPF:' . formatar_cpf_cnpj ( $_SESSION [APLICATIVO] ["login"] ["num_cpf"] ) . '<br/>' . $_SESSION [APLICATIVO] ["login"] ["nom_pessoa"] ;
1353            }
1354            
1355            if (preg_match ( '/<input/i', $this->getLoginInfo () ) == 0) {
1356                $userInfo =  $userInfo. '<br/>' . $btnLogOut;
1357            }
1358        } else {
1359            if ( $this->getLoginInfo() ) {
1360                $userInfo = $this->getLoginInfo();
1361            }
1362        }
1363        
1364        $app_header_login = new TDiv( 'app_header_login' );
1365        $app_header_login->add( $userInfo );
1366        return $app_header_login;
1367    }
1368    
1369    private function buildMainMenu() {
1370        if( $this->getShowMenu() ) {
1371            if( $this->getMainMenuFile() ){
1372                if( file_exists( $this->getMainMenuFile() ) ){
1373                    $this->addJavascript ( 'try{app_main_menu = new dhtmlXMenuObject("div_main_menu",menuTheme);}catch(e){alert( "Erro no menu. Não foi possível instanciar a classe dhtmlXMenuObject.\t"+e.message)}' );
1374                    $this->addJavascript ( 'app_build_menu(false,null,"'.$this->getMainMenuFile().'")' );
1375                } else {
1376                    $this->addJavascript ( 'alert("Módulo de menu:'.$this->getMainMenuFile().', defindo para a aplicação, não existe.")' );
1377                }
1378            }
1379        }
1380    }
1381    
1382    private function buildPageHeader() {
1383        
1384        $app_hearder = new TElement('header');
1385        //$app_hearder = new TDiv( 'header' );
1386        
1387        if ( $this->getHeaderContent() ) {
1388            $app_hearderUser = new TDiv( 'app_header' );
1389            $app_hearderUser->add( $this->getHeaderContent() );
1390            $app_hearder->add( $app_hearderUser );
1391        }else{
1392            $app_header_logo  = $this->getHeaderLogo();
1393            $app_header_title = $this->getHeaderTitle();
1394            $app_header_login = $this->getHeaderLogin();
1395            
1396            $app_hearder->add( $app_header_logo );
1397            $app_hearder->add( $app_header_title );
1398            $app_hearder->add( $app_header_login );
1399        }
1400        
1401        $this->getNorthArea()->add ( $app_hearder );
1402    }
1403    
1404    /**
1405     * Build defaulf page Footer  Div: app_footer
1406     * div chindren  app_footer_message,app_footer_company, app_footer_module
1407     */
1408    private function buildPageFooter()
1409    {
1410        if (! $this->getSouthArea ()) {
1411            return;
1412        }
1413        
1414        $app_footer = new TElement('footer');
1415        //$app_footer = new TDiv( 'footer' );        
1416        
1417        if ( $this->getFooterContent() ) {
1418            $app_footer->add( $this->getFooterContent() );
1419        } else {
1420            $app_footer_message = new TDiv('app_footer_message');
1421            
1422            $info_company = $this->getUnit () . ' ' . $this->getVersionSystem ();
1423            $app_footer_company = new TDiv( 'app_footer_company' );
1424            $app_footer_company->add($info_company);
1425            
1426            $app_footer_module = new TDiv( 'app_footer_module' );            
1427            
1428            $app_footer->add($app_footer_message);
1429            $app_footer->add($app_footer_company);
1430            $app_footer->add($app_footer_module);
1431        }
1432        //$app_footer->add('&nbsp;');
1433        $this->getSouthArea()->add( $app_footer );
1434    }
1435    
1436    public function parsePhpFile($strFileName = null, $var = null)
1437    {
1438        if (is_null ( $strFileName ) || ! file_exists ( $strFileName )) {
1439            return null;
1440        }
1441        
1442        ob_start ();
1443        eval ( "?>" . implode ( "", file ( $strFileName ) ) . "<?" );
1444        $c = ob_get_contents ();
1445        ob_clean ();
1446        return $c;
1447    }
1448    public function getLoCenter() {
1449        return $this->loCenter;
1450    }
1451    public function setBeforeActionFunction($strNewValue = null) {
1452        $this->beforeActionFunction = $strNewValue;
1453    }
1454    public function getBeforeActionFunction() {
1455        return $this->beforeActionFunction;
1456    }
1457    public function setonBeforeActionFunction($strNewValue = null) {
1458        $this->setBeforeActionFunction ( $strNewValue );
1459    }
1460    public function getOnBeforeActionFunction() {
1461        return $this->getBeforeActionFunction ();
1462    }
1463    public function setOnGetLoginInfo($strNewValue = null) {
1464        $this->onGetLoginInfo = $strNewValue;
1465    }
1466    public function getOnGetLoginInfo() {
1467        return $this->onGetLoginInfo;
1468    }
1469    public function setMenuIconsPath($strNewValue = null) {
1470        $this->menuIconsPath = $strNewValue;
1471    }
1472    public function getMenuIconsPath() {
1473        // if ( isset( $this->menuIconsPath ) && file_exists( $this->menuIconsPath ) )
1474        {
1475            return $this->menuIconsPath;
1476        }
1477        return '';
1478    }
1479    
1480    public function setMenuTheme($strNewValue = 'standard | aqua_dark | aqua_sky | aqua_orange | clear_blue | clear_green | dhx_black | dhx_blue | glassy_blue | modern_black | modern_blue | modern_red | clear_silver') {
1481        $aThemes = explode ( ',', 'standard,aqua_dark,aqua_sky,aqua_orange,clear_blue,clear_green,dhx_black,dhx_blue,glassy_blue,modern_black,modern_blue,modern_red,clear_silver' );
1482        if (array_search ( $strNewValue, $aThemes )=== false ) {
1483            $strNewValue = 'clear_silver';
1484        }
1485        $this->menuTheme = $strNewValue;
1486    }
1487    public function getMenuTheme() {
1488        if( ! is_null( $this->menuTheme ) ) {
1489            return $this->menuTheme;
1490        }else{
1491            $this->setMenuTheme('clear_silver');
1492        }
1493        return $this->menuTheme;
1494    }
1495    
1496    public function setOnBeforeLogin( $strFunctionName = null )
1497    {
1498        $this->onBeforeLogin = $strFunctionName;
1499    }
1500
1501    public function getOnBeforeLogin()
1502    {
1503        return $this->onBeforeLogin;
1504    }
1505
1506    public function getLoginDone()
1507    {
1508        // se não existe tela de login definida, então sempre retornar verdadeiro
1509        if( !$this->getLoginFile() ){
1510            return true;
1511        }
1512        if( $this->getOnBeforeLogin() ) {
1513            if ( function_exists( $this->removeIllegalChars( $this->getOnBeforeLogin()) ) )
1514            {
1515                return call_user_func( $this->getOnBeforeLogin(), $this );
1516            } else {
1517                $this->addJavascript('app_alert("Function '.$this->getOnBeforeLogin().' is not defined.");');
1518            }
1519        } else {
1520            if ( isset( $_SESSION[ APLICATIVO ][ "conectado" ] ) && $_SESSION[ APLICATIVO ][ "conectado" ] ){
1521              return true;
1522            }
1523        }
1524        return false;
1525    }
1526    
1527    //---------------------------------------------------------------------------------
1528    
1529    /**
1530     * @deprecated in formDin 4.3.0. Please use CSS to change Style of Width App
1531     * to work, setResponsiveMode = false
1532     * @param integer $intNewValue
1533     * @codeCoverageIgnore
1534     */
1535    public function setWidth($intNewValue = null) {
1536        $this->width = $intNewValue;
1537    }
1538    public function getWidth() {
1539        return $this->width;
1540    }
1541    
1542    /**
1543     * @deprecated Please use CSS to change Style of North Area
1544     * maintained for backward compatibility
1545     * @codeCoverageIgnore
1546     */
1547    private function buildCssNorthArea(){
1548        // css
1549        if ( $this->getHeaderBgImage() ) {
1550            // sobrescrever as definições do app.css
1551            $this->addStyle( '#app_header_title{background    :transparent;}' );
1552            $this->addStyle( '#app_header_login{background    :transparent;}' );
1553            $this->addStyle( '#app_header_logo{background    :transparent;}' );
1554            
1555            if ( $this->getNorthArea() ) {
1556                // definir a imagem de fundo do cabecalho
1557                $this->getNorthArea()->setCss ( 'background-image', "url('" . $this->getHeaderBgImage () . "')" );
1558                $this->getNorthArea()->setCss ( 'background-position', "50% 50%" );
1559                $this->getNorthArea()->setCss ( 'border', "0px" );
1560                if (is_null ( $this->getHeaderBgRepeat () )) {
1561                    if (function_exists ( 'getimagesize' ) && file_exists ( $this->getHeaderBgImage () )) {
1562                        
1563                        list ( $width, $height ) = getimagesize ( $this->getHeaderBgImage () );
1564                        $height = $height; //POG para retirar mensagens de variavel não usada;
1565                        if ($width < 30) {
1566                            $this->getNorthArea ()->setCss ( 'background-repeat', 'repeat-x' );
1567                        }
1568                    }
1569                } else {
1570                    $this->getNorthArea ()->setCss ( 'background-repeat', $this->getHeaderBgRepeat () );
1571                }
1572            }
1573        }
1574    }
1575    //---------------------------------------------------------------------------------
1576    /**
1577     * @deprecated Please use CSS to change Style of South Area
1578     * maintained for backward compatibility
1579     * @codeCoverageIgnore
1580     */
1581    private function buildCssSouthArea()
1582    {
1583        if ( $this->getFooterBgImage() ) {
1584            // sobrescrever as definições do app.css
1585            $this->addStyle ( '#app_footer_message{background    :transparent;}' );
1586            $this->addStyle ( '#app_footer_company{background    :transparent;}' );
1587            $this->addStyle ( '#app_footer_module{background    :transparent;}' );
1588            
1589            if ($this->getSouthArea ()) {
1590                // definir a imagem de fundo do cabecalho
1591                $this->getSouthArea ()->setCss ( 'background-image', "url('" . $this->getFooterBgImage () . "')" );
1592                $this->getSouthArea ()->setCss ( 'background-position', "50% 50%" );
1593                $this->getSouthArea ()->setCss ( 'border', "0px" );
1594                if (is_null ( $this->getFooterBgRepeat () )) {
1595                    if (function_exists ( 'getimagesize' ) && file_exists ( $this->getFooterBgImage () )) {
1596                        
1597                        list ( $width, $height ) = getimagesize ( $this->getFooterBgImage () );
1598                        $height = $height; //POG para retirar mensagens de variavel não usada;
1599                        if ($width < 30) {
1600                            $this->getSouthArea ()->setCss ( 'background-repeat', 'repeat-x' );
1601                        }
1602                    }
1603                } else {
1604                    $this->getSouthArea ()->setCss ( 'background-repeat', $this->getFooterBgRepeat () );
1605                }
1606            }
1607        }
1608    }
1609    //---------------------------------------------------------------------------------
1610    /**
1611     * @deprecated Please use CSS to change Image Back Ground
1612     * Define a imagem de fundo do cabeçalho da aplicação
1613     * O parametro $strRepeat define a maneira como a imagem de fundo é repetida:
1614     * repeat -> repete vertical e horizontal
1615     * repeat-y -> repete vertical;
1616     * repeat-x -> repete horizontal;
1617     *
1618     * @param mixed $strNewImage
1619     * @param mixed $strRepeat
1620     * @codeCoverageIgnore
1621     */
1622    public function setHeaderBgImage($strNewImage = null, $strRepeat = null)
1623    {
1624        $this->headerBgImage = $strNewImage;
1625        if (is_null ( $this->getWidth () )) {
1626            if (function_exists ( 'getimagesize' ) && file_exists ( $strNewImage )) {
1627                list ( $width, $height ) = getimagesize ( $strNewImage );
1628                $this->setNorthSize ( $height );
1629                if ($width > 600) {
1630                    $this->setWidth ( $width );
1631                }
1632            }
1633        }
1634        if (is_null ( $this->getHeaderBgRepeat () )) {
1635            $this->setHeaderBgRepeat ( $strRepeat );
1636        }
1637    }
1638    
1639    /**
1640     * @deprecated Please use CSS to change Background Header
1641     * @codeCoverageIgnore
1642     */
1643    public function getHeaderBgImage()
1644    {
1645        return $this->headerBgImage;
1646    }
1647    //---------------------------------------------------------------------------------
1648    /**
1649     * @deprecated Please use CSS to change Image Back Ground
1650     * @codeCoverageIgnore
1651     * @param string $strNewValue
1652     */
1653    public function setHeaderBgRepeat($strNewValue = null)
1654    {
1655        $this->headerBgRepeat = $strNewValue;
1656    }
1657    
1658    /**
1659     * @deprecated Please use CSS to change Background Header
1660     * @codeCoverageIgnore
1661     */
1662    public function getHeaderBgRepeat()
1663    {
1664        return $this->headerBgRepeat;
1665    }
1666    //---------------------------------------------------------------------------------
1667    /**
1668     * @deprecated Please use CSS to change Image Back Ground
1669     * @codeCoverageIgnore
1670     * @param string $strNewValue
1671     */
1672    public function setFooterBgImage($strNewImage = null, $strRepeat = null)
1673    {
1674        $this->footerBgImage = $strNewImage;
1675        if (function_exists ( 'getimagesize' ) && file_exists ( $strNewImage )) {
1676            list ( $width, $height ) = getimagesize ( $strNewImage );
1677            $width = $width; //POG para retirar mensagens de variavel não usada;
1678            $this->setSouthSize ( $height );
1679        }
1680        if (is_null ( $this->getFooterBgRepeat () )) {
1681            $this->setFooterBgRepeat ( $strRepeat );
1682        }
1683    }
1684    
1685    /**
1686     * @deprecated Please use CSS to change Background footer
1687     * @codeCoverageIgnore
1688     */
1689    public function getFooterBgImage()
1690    {
1691        return $this->footerBgImage;
1692    }
1693    //---------------------------------------------------------------------------------
1694    /**
1695     * @deprecated Please use CSS to change Image Back Ground
1696     * @codeCoverageIgnore
1697     * @param string $strNewValue
1698     */
1699    public function setFooterBgRepeat($strNewValue = null) {
1700        $this->footerBgRepeat = $strNewValue;
1701    }
1702    
1703    /**
1704     * @deprecated Please use CSS to change Background footer
1705     * @codeCoverageIgnore
1706     */
1707    public function getFooterBgRepeat() {
1708        return $this->footerBgRepeat;
1709    }
1710    
1711}