﻿<?php
/**
 * RSS de la web
 *
 * @author Víctor Estévez Gómez <victor.estevez@isertia.grupobittia.com>
 * @category Public
 * @copyright Copyright © 2010, BITTIA - Grupo BITTIA
 * @filesource
 * @package Public
 * @version 1.1
 */


/**
 * 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
$data['news']['title'] = array('type' => 'string');
$data['news']['permalink'] = array('type' => 'string');
$data['news']['text'] = array('type' => 'text');
$data['news']['news_multimedia'] = array(
	'type' => 'multimedia_n',	
	'table_relation' => 'news_multimedia',
	'table_source' => 'multimedia',
	'show' => 'title',
	'id_origin' => 'id',
	'id_source' => 'id',
	'insert' => 'yes',
	'link' => 'no',
	'display' => 'yes',
	'show_items' => 1,
);
$data['news']['news_categories'] = array(
	'type' => 'relation_n',	
	'table_relation' => 'news_categories',
	'table_source' => 'categories',
	'show' => 'title',
	'id_origin' => 'id',
	'id_source' => 'id',
	'insert' => 'no',
	'link' => 'no',
	'unique' => 'no',
);
$data['news']['tags'] = array('type' => 'tags', 'table_relation' => 'news_tags');
$data['news']['web'] = array('type' => 'web');
$data['news']['visible'] = array('type' => 'bool', 'display' => 'yes', 'required' => 'no', 'options' => array('yes', 'no')); 
$data['news']['date'] = array('type' => 'time', 'time' => 'yes', 'default' => time());

//Configuración
$config['sql']['show']['order'] = 'position DESC, id_language';
$config['sql']['show']['limit'] = 10;

//Datos
$data = new data(&$data, &$config);
$data->load();



header('content-type: application/xhtml+xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>
';
?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?=$krnl->lng('web_title')?></title> 
<atom:link href="<?=PROTOCOL.DOMAIN.INSTALATION_DIR?>/rss.xml" rel="self" type="application/rss+xml" />
<link>http://<?=$_SERVER['HTTP_HOST']?><?=INSTALATION_DIR?></link> 
<description /> 
<pubDate><?=date(DATE_RFC2822)?></pubDate> 
<generator>BiTTia</generator> 
<language><?=$krnl->lng_get()?></language> 
<?php
while($data->next_row())
{
	$foto = $data->get('news_multimedia');
	$categories = $data->get('news_categories');
?>
	<item>
		<title><![CDATA[<?=$data->get('title')?>]]></title> 
		<link><?=$krnl->make_url('news', $data->get('permalink'))?></link> 
		<pubDate><?=$data->get('time')?></pubDate>
		<?php
		if(is_array($categories))
		{
			foreach($categories as $item)
			{
				?><category domain=""><?=$item[1]?></category><?
			}
		}
		?>
		<dc:creator>BiTTia</dc:creator> 
		<guid isPermaLink="false"><?=$krnl->make_url('news', $data->get('permalink'))?></guid> 
		<content:encoded><![CDATA[<?=$data->get('text')?>
			<?php if(is_array($foto)): ?>
			<img src="<?=$krnl->url_img($foto[0]['url'], 4)?>" alt="<?=$foto[0]['title']?>" />
			<?php endif; ?>
		]]></content:encoded>
		<description><![CDATA[<?=$data->get('text')?>]]></description>
	</item>
<?
}	
?>
</channel>
</rss>
