Commit d66262201c905bb1793d1b0d930ab36be67908a6

Authored by Eriksen Costa
1 parent b9242b56
Exists in master

Refactoring para coding standards.

Showing 1 changed file with 76 additions and 62 deletions   Show diff stats
ieducar/intranet/educar_serie_xml.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 - header( 'Content-type: text/xml' );  
28 2
29 - require_once( "include/clsBanco.inc.php" );  
30 - require_once( "include/funcoes.inc.php" );  
31 - echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n<query xmlns=\"sugestoes\">\n";  
32 - if( is_numeric( $_GET["esc"] ) && is_numeric( $_GET["cur"] ) )  
33 - {  
34 - $db = new clsBanco();  
35 - $db->Consulta( "SELECT cod_serie, nm_serie FROM pmieducar.serie WHERE ref_cod_curso = {$_GET["cur"]} AND ativo = 1 ORDER BY nm_serie ASC" );  
36 - while ( $db->ProximoRegistro() )  
37 - {  
38 - list( $cod, $nome ) = $db->Tupla();  
39 - echo " <serie cod_serie=\"{$cod}\">{$nome}</serie>\n";  
40 - }  
41 - }  
42 - elseif( is_numeric( $_GET["cur"] ) )  
43 - {  
44 - $db = new clsBanco();  
45 - $db->Consulta( "  
46 - SELECT  
47 - cod_serie  
48 - , nm_serie  
49 - FROM  
50 - pmieducar.serie  
51 - WHERE  
52 - ref_cod_curso = {$_GET["cur"]}  
53 - AND ativo = 1  
54 - ORDER BY  
55 - nm_serie ASC  
56 - " ); 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 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @todo As duas queries são idênticas, o parâmetro 'esc' nunca é usado.
  29 + * Verificar e refatorar.
  30 + * @version $Id$
  31 + */
57 32
58 - while ( $db->ProximoRegistro() )  
59 - {  
60 - list( $cod, $nome ) = $db->Tupla();  
61 - echo " <serie cod_serie=\"{$cod}\">{$nome}</serie>\n";  
62 - }  
63 - }  
64 - echo "</query>";  
65 -?>  
66 \ No newline at end of file 33 \ No newline at end of file
  34 +header('Content-type: text/xml');
  35 +
  36 +require_once 'include/clsBanco.inc.php';
  37 +require_once 'include/funcoes.inc.php';
  38 +
  39 +echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n<query xmlns=\"sugestoes\">\n";
  40 +
  41 +if (is_numeric($_GET['esc']) && is_numeric($_GET['cur']))
  42 +{
  43 + $db = new clsBanco();
  44 + $db->Consulta(sprintf('SELECT
  45 + cod_serie, nm_serie
  46 + FROM
  47 + pmieducar.serie
  48 + WHERE
  49 + ref_cod_curso = %d AND ativo = 1
  50 + ORDER BY
  51 + nm_serie ASC', $_GET['cur']
  52 + ));
  53 +
  54 + while ($db->ProximoRegistro())
  55 + {
  56 + list($cod, $nome) = $db->Tupla();
  57 + print sprintf(' <serie cod_serie="%d">%s</serie>%s', $cod, $nome, PHP_EOL);
  58 + }
  59 +}
  60 +elseif (is_numeric($_GET['cur']))
  61 +{
  62 + $db = new clsBanco();
  63 + $db->Consulta(sprintf('SELECT
  64 + cod_serie, nm_serie
  65 + FROM
  66 + pmieducar.serie
  67 + WHERE
  68 + ref_cod_curso = %d AND ativo = 1
  69 + ORDER BY
  70 + nm_serie ASC', $_GET["cur"]
  71 + ));
  72 +
  73 + while ($db->ProximoRegistro())
  74 + {
  75 + list($cod, $nome) = $db->Tupla();
  76 + print sprintf(' <serie cod_serie="%d">%s</serie>%s', $cod, $nome, PHP_EOL);
  77 + }
  78 +}
  79 +
  80 +echo '</query>';