Commit 3190703b01e52b2b887f61126dfb6eb9f094eabb

Authored by Eriksen Costa Paixão
1 parent 6e20b1e0
Exists in master

Refactoring para coding standards

Showing 1 changed file with 247 additions and 259 deletions   Show diff stats
ieducar/intranet/include/clsDetalhe.inc.php
1 <?php 1 <?php
2 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
3 -* *  
4 -* @author Prefeitura Municipal de Itaja� *  
5 -* @updated 29/03/2007 *  
6 -* Pacote: i-PLB Software P�blico Livre e Brasileiro *  
7 -* *  
8 -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itaja� *  
9 -* ctima@itajai.sc.gov.br *  
10 -* *  
11 -* Este programa � software livre, voc� pode redistribu�-lo e/ou *  
12 -* modific�-lo sob os termos da Licen�a P�blica Geral GNU, conforme *  
13 -* publicada pela Free Software Foundation, tanto a vers�o 2 da *  
14 -* Licen�a como (a seu crit�rio) qualquer vers�o mais nova. *  
15 -* *  
16 -* Este programa � distribu�do na expectativa de ser �til, mas SEM *  
17 -* QUALQUER GARANTIA. Sem mesmo a garantia impl�cita de COMERCIALI- *  
18 -* ZA��O ou de ADEQUA��O A QUALQUER PROP�SITO EM PARTICULAR. Con- *  
19 -* sulte a Licen�a P�blica Geral GNU para obter mais detalhes. *  
20 -* *  
21 -* Voc� deve ter recebido uma c�pia da Licen�a P�blica Geral GNU *  
22 -* junto com este programa. Se n�o, escreva para a Free Software *  
23 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *  
24 -* 02111-1307, USA. *  
25 -* *  
26 -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */  
27 -if(class_exists("clsPmiajudaPagina"))  
28 -{  
29 - require_once ( "include/pmiajuda/clsPmiajudaPagina.inc.php" );  
30 -}  
31 2
32 -class clsDetalhe 3 +/**
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
  25 + * @package Core
  26 + * @subpackage UI
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
  29 + */
  30 +
  31 +/**
  32 + * clsDetalhe class.
  33 + *
  34 + * Cria um template para a visualização de um registro de alguma tabela do banco
  35 + * de dados.
  36 + *
  37 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  38 + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
  39 + * @package Core
  40 + * @subpackage UI
  41 + * @since Classe disponível desde a versão 1.0.0
  42 + * @version $Id$
  43 + */
  44 +class clsDetalhe
33 { 45 {
34 - var $titulo;  
35 - var $banner = false;  
36 - var $bannerLateral = false;  
37 - var $titulo_barra;  
38 - var $bannerClose = false;  
39 - var $largura;  
40 - var $detalhe = array();  
41 -  
42 - var $url_novo;  
43 - var $caption_novo = "Novo";  
44 - var $url_editar;  
45 - var $url_cancelar;  
46 - var $nome_url_cancelar = "Voltar";  
47 -  
48 - var $array_botao;  
49 - var $array_botao_url;  
50 - var $array_botao_url_script;  
51 -  
52 - function addBanner( $strBannerUrl = "", $strBannerLateralUrl = "", $strBannerTitulo = "", $boolFechaBanner = true )  
53 - {  
54 - if( $strBannerUrl != "" )  
55 - {  
56 - $this->banner = $strBannerUrl;  
57 - }  
58 - if( $strBannerLateralUrl != "" )  
59 - {  
60 - $this->bannerLateral = $strBannerLateralUrl;  
61 - }  
62 - if( $strBannerTitulo != "" )  
63 - {  
64 - $this->titulo_barra = $strBannerTitulo;  
65 - }  
66 - $this->bannerClose = $boolFechaBanner;  
67 - }  
68 -  
69 - function addDetalhe( $detalhe )  
70 - {  
71 - $this->detalhe[] = $detalhe;  
72 - }  
73 -  
74 - function Gerar ()  
75 - {  
76 - return false;  
77 - }  
78 -  
79 - function RenderHTML()  
80 - {  
81 - $this->titulo_barra= "Intranet";  
82 - $this->Gerar();  
83 -  
84 - $retorno = "";  
85 - if( $this->banner )  
86 - {  
87 - $retorno .= "<table width='100%' style=\"height:100%\" border='0' cellpadding='0' cellspacing='0'><tr>";  
88 - $retorno .= "<td class=\"barraLateral\" width=\"21\" valign=\"top\"><a href='#'><img src=\"{$this->bannerLateral}\" align=\"right\" border=\"0\" alt=\"$this->titulo_barra\" title=\"$this->titulo_barra\"></a></td><td valign='top'>";  
89 - }  
90 -  
91 - $script = explode("/",$_SERVER["PHP_SELF"]);  
92 - $script = $script[count($script)-1];  
93 -  
94 - $width = empty( $this->largura ) ? "" : "width='$this->largura'";  
95 -  
96 - /*  
97 - * adiciona os botoes de help para a pagina atual  
98 - */  
99 - $url = parse_url($_SERVER['REQUEST_URI']);  
100 - $url = ereg_replace( "^/", "", $url["path"] );  
101 - if( strpos($url,"_det.php") !== false )  
102 - {  
103 - $tipo = "det";  
104 - }  
105 - else if( strpos($url,"_lst.php") !== false )  
106 - {  
107 - $tipo = "lst";  
108 - }  
109 - else if( strpos($url,"_pdf.php") !== false )  
110 - {  
111 - $tipo = "pdf";  
112 - }  
113 - else  
114 - {  
115 - $tipo = "cad";  
116 - }  
117 -  
118 - $barra = "<b>{$this->titulo}</b>";  
119 - if(class_exists("clsPmiajudaPagina"))  
120 - {  
121 - $ajudaPagina = new clsPmiajudaPagina();  
122 - $lista = $ajudaPagina->lista(null,null,$url);  
123 - if( $lista )  
124 - {  
125 - $barra = "  
126 - <table border=\"0\" cellpading=\"0\" cellspacing=\"0\" width=\"100%\">  
127 - <tr>  
128 - <script type=\"text/javascript\">document.help_page_index = 0;</script>  
129 - <td width=\"20\"><a href=\"javascript:showExpansivelIframe(700,500,'ajuda_mostra.php?cod_topico={$lista[0]["ref_cod_topico"]}&tipo={$tipo}');\"><img src=\"imagens/banco_imagens/interrogacao.gif\" border=\"0\" alt=\"Bot�o de Ajuda\" title=\"Clique aqui para obter ajuda sobre esta p�gina\"></a></td>  
130 - <td><b>{$this->titulo}</b></td>  
131 - <td align=\"right\"><a href=\"javascript:showExpansivelIframe(700,500,'ajuda_mostra.php?cod_topico={$lista[0]["ref_cod_topico"]}&tipo={$tipo}');\"><img src=\"imagens/banco_imagens/interrogacao.gif\" border=\"0\" alt=\"Bot�o de Ajuda\" title=\"Clique aqui para obter ajuda sobre esta p�gina\"></a></td>  
132 - </tr>  
133 - </table>";  
134 - }  
135 - }  
136 -  
137 - $retorno .= "  
138 - <!-- detalhe begin -->  
139 - <table class='tableDetalhe' $width border='0' cellpadding='2' cellspacing='2'>  
140 - <tr>  
141 - <td class='formdktd' colspan='2' height='24'>{$barra}</td>  
142 - </tr>  
143 - ";  
144 -  
145 - if ( empty( $this->detalhe ) )  
146 - {  
147 - $retorno .= "<tr><td class='tableDetalheLinhaSim' colspan='2'>N&atilde;o h&aacute; informa&ccedil;&atilde;o a ser apresentada.</td></tr>\n";  
148 - }  
149 - else  
150 - {  
151 - if (is_array($this->detalhe))  
152 - {  
153 - reset( $this->detalhe );  
154 - $campo_anterior = "";  
155 - $md = true;  
156 - foreach($this->detalhe as $pardetalhe)  
157 - {  
158 -// if($pardetalhe[0] && $pardetalhe[1])  
159 -// {  
160 - $campo = $pardetalhe[0].":";  
161 - $texto = $pardetalhe[1];  
162 -// }  
163 - if ($campo == $campo_anterior)  
164 - {  
165 - $campo = "";  
166 - }  
167 - else  
168 - {  
169 - $campo_anterior = $campo;  
170 - $md = !$md;  
171 - }  
172 -  
173 - if ($campo == "-:")  
174 - {  
175 - if (empty( $texto ))  
176 - $texto = "&nbsp;";  
177 -  
178 - $retorno .= "<tr><td colspan='2' class='' width='20%'><span class='form'><b>$texto</b></span></td></tr>\n";  
179 - }  
180 - else  
181 - {  
182 - $classe = $md ? 'formmdtd' : 'formlttd';  
183 -  
184 - $retorno .= "<tr><td class='$classe' width='20%'>$campo</td><td class='$classe'>$texto</td></tr>\n";  
185 - }  
186 - }  
187 - }  
188 - }  
189 - $retorno .= "<tr><td class='tableDetalheLinhaSeparador' colspan='2'></td></tr>\n";  
190 -  
191 - if ( !empty( $this->url_editar ) || !empty( $this->url_cancelar ) || $this->array_botao )  
192 - {  
193 - $retorno .= "  
194 - <tr>  
195 - <td colspan='2' align='center'>  
196 - <script type=\"text/javascript\" language='javascript'>  
197 - function go( url ) {  
198 - document.location = url;  
199 - }  
200 - </script>  
201 - ";  
202 -  
203 - if ($this->url_novo)  
204 - {  
205 - $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"$this->url_novo\" );' value=' {$this->caption_novo} '>&nbsp;\n";  
206 - }  
207 - if ($this->url_editar)  
208 - {  
209 - $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"$this->url_editar\" );' value=' Editar '>&nbsp;\n";  
210 - }  
211 - if ($this->url_cancelar)  
212 - {  
213 - $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"$this->url_cancelar\" );' value=' $this->nome_url_cancelar '>&nbsp;\n";  
214 - }  
215 - $retorno .= "</td></tr>";  
216 -  
217 - if ($this->array_botao_url || $this->array_botao_url_script)  
218 - {  
219 -  
220 - $retorno .= "<tr><td colspan=2><table width='100%' summary=''><tr><td></td><td height='1' width='90%' bgcolor='#858585' style='font-size: 0px;'>&nbsp;</td><td></td></tr></table></td></tr><tr><td colspan='2' align='center'>";  
221 - }  
222 -  
223 - if($this->array_botao_url)  
224 - {  
225 - for ( $i = 0; $i < count($this->array_botao); $i++)  
226 - {  
227 - $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"".$this->array_botao_url[$i]."\" );' value='".$this->array_botao[$i]."'>&nbsp;\n";  
228 - }  
229 - }  
230 - elseif ($this->array_botao_url_script)  
231 - {  
232 - for ( $i = 0; $i < count($this->array_botao); $i++)  
233 - {  
234 - $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='{$this->array_botao_url_script[$i]}' value='".$this->array_botao[$i]."'>&nbsp;\n";  
235 - }  
236 - }  
237 -  
238 - if ($this->array_botao_url || $this->array_botao_url_script)  
239 - {  
240 - $retorno .= "</td></tr>";  
241 - }  
242 -  
243 - $retorno .= "<tr><td colspan='2' height='1' bgcolor='black' style='font-size: 0px;'>&nbsp;</td></tr>";  
244 - }  
245 - $retorno .= "  
246 - </table><br><br>  
247 - <!-- detalhe end -->";  
248 -  
249 - if( $this->bannerClose )  
250 - {  
251 - $retorno .= "  
252 - <!-- Fechando o Banner (clsDetalhe) -->  
253 - </td>  
254 - </tr>  
255 - </table>  
256 - ";  
257 - }  
258 -  
259 - return $retorno;  
260 - }  
261 -}  
262 -?>  
263 \ No newline at end of file 46 \ No newline at end of file
  47 + var $titulo;
  48 + var $banner = FALSE;
  49 + var $bannerLateral = FALSE;
  50 + var $titulo_barra;
  51 + var $bannerClose = FALSE;
  52 + var $largura;
  53 + var $detalhe = array();
  54 +
  55 + var $url_novo;
  56 + var $caption_novo = "Novo";
  57 + var $url_editar;
  58 + var $url_cancelar;
  59 + var $nome_url_cancelar = "Voltar";
  60 +
  61 + var $array_botao;
  62 + var $array_botao_url;
  63 + var $array_botao_url_script;
  64 +
  65 + function addBanner($strBannerUrl = '', $strBannerLateralUrl = '',
  66 + $strBannerTitulo = '', $boolFechaBanner = TRUE)
  67 + {
  68 + if ($strBannerUrl != '') {
  69 + $this->banner = $strBannerUrl;
  70 + }
  71 +
  72 + if ($strBannerLateralUrl != '') {
  73 + $this->bannerLateral = $strBannerLateralUrl;
  74 + }
  75 +
  76 + if ($strBannerTitulo != '') {
  77 + $this->titulo_barra = $strBannerTitulo;
  78 + }
  79 +
  80 + $this->bannerClose = $boolFechaBanner;
  81 + }
  82 +
  83 +
  84 + function addDetalhe($detalhe) {
  85 + $this->detalhe[] = $detalhe;
  86 + }
  87 +
  88 + function Gerar() {
  89 + return FALSE;
  90 + }
  91 +
  92 + function RenderHTML()
  93 + {
  94 + $this->titulo_barra= 'Intranet';
  95 + $this->Gerar();
  96 +
  97 + $retorno = '';
  98 + if ($this->banner) {
  99 + $retorno .= "<table width='100%' style=\"height:100%\" border='0' cellpadding='0' cellspacing='0'><tr>";
  100 + $retorno .= "<td class=\"barraLateral\" width=\"21\" valign=\"top\"><a href='#'><img src=\"{$this->bannerLateral}\" align=\"right\" border=\"0\" alt=\"$this->titulo_barra\" title=\"$this->titulo_barra\"></a></td><td valign='top'>";
  101 + }
  102 +
  103 + $script = explode('/', $_SERVER['PHP_SELF']);
  104 + $script = $script[count($script)-1];
  105 +
  106 + $width = empty($this->largura) ? '' : 'width=' . $this->largura;
  107 +
  108 + /*
  109 + * adiciona os botoes de help para a pagina atual
  110 + */
  111 + $url = parse_url($_SERVER['REQUEST_URI']);
  112 + $url = ereg_replace( "^/", "", $url["path"] );
  113 +
  114 + if (strpos($url, '_det.php') !== FALSE) {
  115 + $tipo = "det";
  116 + }
  117 + elseif (strpos($url, '_lst.php') !== FALSE) {
  118 + $tipo = 'lst';
  119 + }
  120 + elseif (strpos($url, '_pdf.php') !== FALSE) {
  121 + $tipo = 'pdf';
  122 + }
  123 + else {
  124 + $tipo = 'cad';
  125 + }
  126 +
  127 + $barra = '<b>' . $this->titulo . '</b>';
  128 + if (class_exists('clsPmiajudaPagina')) {
  129 + $ajudaPagina = new clsPmiajudaPagina();
  130 + $lista = $ajudaPagina->lista(null,null,$url);
  131 +
  132 + if ($lista) {
  133 + $barra = "
  134 + <table border=\"0\" cellpading=\"0\" cellspacing=\"0\" width=\"100%\">
  135 + <tr>
  136 + <script type=\"text/javascript\">document.help_page_index = 0;</script>
  137 + <td width=\"20\"><a href=\"javascript:showExpansivelIframe(700,500,'ajuda_mostra.php?cod_topico={$lista[0]["ref_cod_topico"]}&tipo={$tipo}');\"><img src=\"imagens/banco_imagens/interrogacao.gif\" border=\"0\" alt=\"Bot�o de Ajuda\" title=\"Clique aqui para obter ajuda sobre esta p�gina\"></a></td>
  138 + <td><b>{$this->titulo}</b></td>
  139 + <td align=\"right\"><a href=\"javascript:showExpansivelIframe(700,500,'ajuda_mostra.php?cod_topico={$lista[0]["ref_cod_topico"]}&tipo={$tipo}');\"><img src=\"imagens/banco_imagens/interrogacao.gif\" border=\"0\" alt=\"Bot�o de Ajuda\" title=\"Clique aqui para obter ajuda sobre esta p�gina\"></a></td>
  140 + </tr>
  141 + </table>";
  142 + }
  143 + }
  144 +
  145 + $retorno .= "
  146 + <!-- detalhe begin -->
  147 + <table class='tableDetalhe' $width border='0' cellpadding='2' cellspacing='2'>
  148 + <tr>
  149 + <td class='formdktd' colspan='2' height='24'>{$barra}</td>
  150 + </tr>
  151 + ";
  152 +
  153 + if (empty($this->detalhe)) {
  154 + $retorno .= "<tr><td class='tableDetalheLinhaSim' colspan='2'>N&atilde;o h&aacute; informa&ccedil;&atilde;o a ser apresentada.</td></tr>\n";
  155 + }
  156 + else {
  157 + if (is_array($this->detalhe)) {
  158 + reset($this->detalhe);
  159 +
  160 + $campo_anterior = "";
  161 + $md = TRUE;
  162 +
  163 + foreach ($this->detalhe as $pardetalhe) {
  164 + $campo = $pardetalhe[0].":";
  165 + $texto = $pardetalhe[1];
  166 +
  167 + if ($campo == $campo_anterior) {
  168 + $campo = "";
  169 + }
  170 + else {
  171 + $campo_anterior = $campo;
  172 + $md = !$md;
  173 + }
  174 +
  175 + if ($campo == "-:") {
  176 + if (empty($texto)) {
  177 + $texto = '&nbsp;';
  178 + }
  179 +
  180 + $retorno .= "<tr><td colspan='2' class='' width='20%'><span class='form'><b>$texto</b></span></td></tr>\n";
  181 + }
  182 + else {
  183 + $classe = $md ? 'formmdtd' : 'formlttd';
  184 + $retorno .= "<tr><td class='$classe' width='20%'>$campo</td><td class='$classe'>$texto</td></tr>\n";
  185 + }
  186 + }
  187 + }
  188 + }
  189 +
  190 + $retorno .= "<tr><td class='tableDetalheLinhaSeparador' colspan='2'></td></tr>\n";
  191 +
  192 + if (!empty($this->url_editar) || !empty($this->url_cancelar) || $this->array_botao) {
  193 + $retorno .= "
  194 + <tr>
  195 + <td colspan='2' align='center'>
  196 + <script type='text/javascript'>
  197 + function go(url) {
  198 + document.location = url;
  199 + }
  200 + </script>";
  201 +
  202 + if ($this->url_novo) {
  203 + $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"$this->url_novo\" );' value=' {$this->caption_novo} '>&nbsp;\n";
  204 + }
  205 +
  206 + if ($this->url_editar) {
  207 + $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"$this->url_editar\" );' value=' Editar '>&nbsp;\n";
  208 + }
  209 +
  210 + if ($this->url_cancelar) {
  211 + $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"$this->url_cancelar\" );' value=' $this->nome_url_cancelar '>&nbsp;\n";
  212 + }
  213 + $retorno .= "</td></tr>";
  214 +
  215 + if ($this->array_botao_url || $this->array_botao_url_script) {
  216 + $retorno .= "<tr><td colspan=2><table width='100%' summary=''><tr><td></td><td height='1' width='90%' bgcolor='#858585' style='font-size: 0px;'>&nbsp;</td><td></td></tr></table></td></tr><tr><td colspan='2' align='center'>";
  217 + }
  218 +
  219 + if ($this->array_botao_url) {
  220 + for ($i = 0, $total = count($this->array_botao); $i < $total; $i++) {
  221 + $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='javascript:go( \"".$this->array_botao_url[$i]."\" );' value='".$this->array_botao[$i]."'>&nbsp;\n";
  222 + }
  223 + }
  224 + elseif ($this->array_botao_url_script) {
  225 + for ($i = 0, $total = count($this->array_botao); $i < $total; $i++) {
  226 + $retorno .= "&nbsp;<input type='button' class='botaolistagem' onclick='{$this->array_botao_url_script[$i]}' value='".$this->array_botao[$i]."'>&nbsp;\n";
  227 + }
  228 + }
  229 +
  230 + if ($this->array_botao_url || $this->array_botao_url_script) {
  231 + $retorno .= "</td></tr>";
  232 + }
  233 +
  234 + $retorno .= "<tr><td colspan='2' height='1' bgcolor='black' style='font-size: 0px;'>&nbsp;</td></tr>";
  235 + }
  236 +
  237 + $retorno .= "
  238 + </table><br><br>
  239 + <!-- detalhe end -->";
  240 +
  241 + if ($this->bannerClose) {
  242 + $retorno .= "
  243 + <!-- Fechando o Banner (clsDetalhe) -->
  244 + </td>
  245 + </tr>
  246 + </table>";
  247 + }
  248 +
  249 + return $retorno;
  250 + }
  251 +}
264 \ No newline at end of file 252 \ No newline at end of file