﻿<?php
/**
 * RSS de la web
 *
 * @author Víctor Estévez Gómez <victor.estevez@isertia.com>
 * @category Public
 * @copyright Copyright 2008, Isertia
 * @filesource
 * @package Public
 * @version 1.0 2008/10/01
 */


/**
 * Inicializador de las cosas
 */
include('inc/init_public.php');

/**
 * Obtener datos de la base de datos
 */
require_once(INSTALATION_DIR_ABS.'/inc/data.class.php');

//Campos noticias anteriores o noticia seleccionada
$data['news']['id'] = array('type' => 'int');
$data['news']['id_language'] = array('type' => 'id_language', 'default' => $krnl->lng_content_get());
$data['news']['title'] = array('type' => 'string');
$data['news']['text'] = array('type' => 'text'); 
$data['news']['id_businessarea'] = array('type' => 'relation', 'table_source' => 'businessareas', 'show' => 'title', 'id_source' => 'id', 'insert' => 'yes', 'link' => 'no');
$data['news']['time'] = array('type' => 'time', 'format' => DATE_RFC2822, 'time'=>'no');
$data['news']['news_multimedia'] = array('type' => 'multimedia_n', 'table_relation' => 'news_multimedia', 'table_source' => 'multimedia', 'show' => 'title', 'id_origin' => 'id', 'id_source' => 'id', 'link' => 'no');

//Configuración
$config['sql']['show']['order'] = 'time DESC, id_language';
$config['sql']['show']['where'] = 'visible="yes"';
$config['sql']['show']['limit'] = '10';

//Datos
$data = new data(&$data, &$config);
$data->load();


header('content-type: ');
//header('content-type: application/xhtml+xml');

echo '<?xml version="1.0" encoding="utf-8" ?>
';
?>
<rss version="2.0">
<channel>
<title><?=$krnl->lng('web_title')?></title> 
<link>http://<?=$_SERVER['HTTP_HOST']?><?=INSTALATION_DIR?></link> 
<description>RSS oficial del GRUPO BITTIA</description>
<pubDate><?=date(DATE_RFC2822)?></pubDate> 
<generator>BiTTia</generator> 
<language><?=$krnl->lng_get()?></language>
<?
while($data->next_row())
{
	//Primera foto existente
	$foto = $data->get('news_multimedia');
	for($i=0; $foto[$i]['type'] != 'image' && $i < 20; $i++)
	{
	}
	
	$service = $data->get('id_businessarea');
?>
	<item>
		<title><?=$data->get('title')?></title> 
		<link><?=$krnl->make_url('news', $krnl->make_permalink($data->get('title')).'_'.$data->get('id'))?></link> 
		<pubDate><?=$data->get('time')?></pubDate>
		<?
		if(is_array($service))
		{
		?><category domain="<?=$krnl->make_url('services', $krnl->make_permalink($service[1]).'_'.$service[0])?>"><?=$service[1]?></category><?
		}
		?>
		<guid isPermaLink="false"><?=$krnl->make_url('news', $krnl->make_permalink($data->get('title')).'_'.$data->get('id'))?></guid> 
		<?
		if(is_array($foto[$i]))
		{
		?>
		<enclosure url="http://<?=$_SERVER['HTTP_HOST']?><?=$krnl->url_img($foto[$i]['img'], 4)?>" type="image/jpeg"/>
		<?
		}
		?>
		<description><![CDATA[<?=$data->get('text')?>]]></description>
	</item>
<?
}
?>
</channel>
</rss>