From 83cf0a600579a4b59b7458f42eacf92eb75ba5b5 Mon Sep 17 00:00:00 2001 From: Gonzalo Merayo Date: Tue, 8 Jul 2003 15:50:53 +0000 Subject: [PATCH] Abstraccion de los titulares en el objeto HTML_Titulares --- sistema/local_lib/HTML_Noticia.php | 2 +- sistema/local_lib/HTML_Titulares.php | 114 +++++++++++++++++++++++++++ sistema/www/noticias.php | 77 ++++-------------- 3 files changed, 130 insertions(+), 63 deletions(-) create mode 100644 sistema/local_lib/HTML_Titulares.php diff --git a/sistema/local_lib/HTML_Noticia.php b/sistema/local_lib/HTML_Noticia.php index 7477fe9..bbbf200 100644 --- a/sistema/local_lib/HTML_Noticia.php +++ b/sistema/local_lib/HTML_Noticia.php @@ -130,4 +130,4 @@ class HTML_Noticia extends HTML_Table { // -X2C } // -X2C Class :HTML_Noticia -?> +?> \ No newline at end of file diff --git a/sistema/local_lib/HTML_Titulares.php b/sistema/local_lib/HTML_Titulares.php new file mode 100644 index 0000000..1c003c9 --- /dev/null +++ b/sistema/local_lib/HTML_Titulares.php @@ -0,0 +1,114 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id: xmi2code.tpl.php 1 2003-06-23 18:29:20Z gmeray $ +// + +require_once '../../lib/noticia.php'; +require_once '../local_lib/HTML_Noticia.php'; +require_once '../../lib/mecondavdb.php'; + +// +X2C includes +require_once 'HTML/Table.php'; +// ~X2C + +// +X2C Class 187 :HTML_Titulares +/** + * @access public + */ +class HTML_Titulares extends HTML_Table { + /** + * @var int $antiguedad + * @access public + */ + var $antiguedad = null; + + /** + * @var int $grupo_secciones + * @access public + */ + var $grupo_secciones; + + // ~X2C + + // +X2C Operation 190 + /** + * @param int $grupo_secciones + * @param int $antiguedad + * + * @return void + * @access public + */ + function HTML_Titulares($grupo_secciones = null, $antiguedad = null) // ~X2C + { + parent::HTML_Table(array('width'=>'600', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0')); + $db = MEconDAVDB::Connect(); + $hoy = new Date(); + $fecha_nuevo = $hoy->format('%Y-%m-%d'); + $query = "SELECT Articles.article_id, + IF(Articles.publication_date > '$fecha_nuevo', 'NUEVA', null) + FROM Articles, ArticlePublicationStates + WHERE Articles.article_publication_state_id = + ArticlePublicationStates.article_publication_state_id + AND ArticlePublicationStates.publication_state_id=5 "; + if(!is_null($antiguedad)) + { + $hoy->subtractSeconds(60*60*24*$antiguedad); + $fecha_limite = $hoy->format('%Y-%m-%d'); + $query .= "AND Articles.publication_date > '$fecha_limite' "; + } + $query .= "ORDER BY Articles.publication_date desc"; + $result = $db->query($query); + if(DB::isError($result)) + die($result->getMessage("query mal hecho")); + $ht1 = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0')); + $ht2 = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0')); + $impar = true; + while($row = $result->fetchRow()) + { + $n = new noticia($row[0]); + $not = new HTML_Noticia($n); + if($row[1] == 'NUEVA') + $not->setNuevo(true); + if($impar) + { + $impar = false; + $ht1->addRow(array($not)); + } + else + { + $impar = true; + $ht2->addRow(array($not)); + } + } + + + $this->addRow(array($ht1,$ht2)); + } + // -X2C + +} // -X2C Class :HTML_Titulares +?> diff --git a/sistema/www/noticias.php b/sistema/www/noticias.php index 90f5331..8a6c0b2 100644 --- a/sistema/www/noticias.php +++ b/sistema/www/noticias.php @@ -2,72 +2,25 @@ toHTML(); -?> - - - - - -
- display(); + $noticias = new HTML_Table(array('width' => '760', 'border' => '0')); + require_once '../local_lib/intranetdb.php'; + require_once 'MECON/HTML/Arbol/ArbolDB.php'; + $db = IntranetDB::connect(); + $dbdata = array( 'db' => $db, 'tabla' => 'grupo_secciones', 'id' => 'grupo', 'nombre' => 'nombre', 'id_padre' => 'grupo_padre', 'prepend_link' => 'noticias.php?grupo='); - $arbol = new HTML_ArbolDB($dbdata, '/MECON/images/arbol_noticias.gif'); - echo $arbol->toHTML(); - ?> - - format('%Y-%m-%d'); - $hoy->subtractSeconds(60*60*24*7);//7 dias - $fecha_limite = $hoy->format('%Y-%m-%d'); - $query = "SELECT Articles.article_id, - IF(Articles.publication_date > '$fecha_nuevo', 'NUEVA', null) - FROM Articles, ArticlePublicationStates - WHERE Articles.article_publication_state_id = - ArticlePublicationStates.article_publication_state_id - AND ArticlePublicationStates.publication_state_id=5 - AND Articles.publication_date > '$fecha_limite' - ORDER BY Articles.publication_date desc"; - $result = $db->query($query); - if(DB::isError($result)) - die($result->getMessage("query mal hecho")); - $ht1 = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0')); - $ht2 = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0')); - $impar = true; - while($row = $result->fetchRow()) - { - $n = new noticia($row[0]); - $not = new HTML_Noticia($n); - if($row[1] == 'NUEVA') - $not->setNuevo(true); - if($impar) - { - $impar = false; - $ht1->addRow(array($not)); - } - else - { - $impar = true; - $ht2->addRow(array($not)); - } - } - $ht = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0')); - $ht->addRow(array($ht1,$ht2)); - $ht->display(); - ?> -
+ $arbol = new HTML_ArbolDB($dbdata, '/MECON/images/arbol_noticias.gif'); + + require_once '../local_lib/HTML_Titulares.php'; + $titulares = new HTML_Titulares(null, 7); + $noticias->addRow(array($arbol,$titulares)); + $noticias->updateCellAttributes(0, 0, array('valign'=>'top', 'width'=>'160')); + $noticias->updateCellAttributes(0, 1, array('width'=>'600')); + $noticias->display(); +?> -- 2.43.0