<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.0
 *	LISENSE: http://www.flynax.com/license-agreement.html
 *	PRODUCT: General Classifieds
 *	
 *	FILE: NEWS.INC.PHP
 *
 *	This script is a commercial software and any kind of using it must be 
 *	coordinate with Flynax Owners Team and be agree to Flynax License Agreement
 *
 *	This block may not be removed from this file or any other files with out 
 *	permission of Flynax respective owners.
 *
 *	Copyrights Flynax Classifieds Software | 2012
 *	http://www.flynax.com/
 *
 ******************************************************************************/

if( $config['mod_rewrite'] )
{
	$path = $rlValid -> xSql( $_GET['nvar_1'] );
	$news_id = $rlDb -> getOne('ID', "`Path` = '{$path}'", 'news');
}
else
{
	$news_id = (int)$_GET['id'];
}

$pInfo['current'] = (int)$_GET['pg'];

$reefless -> loadClass( 'News' );

if ( empty($news_id) )
{
	if ( $pInfo['current'] > 1 )
	{
		$bc_page = str_replace('{page}', $pInfo['current'], $lang['title_page_part']);
		
		/* add bread crumbs item */
		$bread_crumbs[1]['title'] .= $bc_page;
	}
	
	$all_news = $rlNews -> get( false, true, $pInfo['current'] );
	$rlSmarty -> assign_by_ref( 'all_news', $all_news );
	
	$pInfo['calc'] = $rlNews -> calc_news;
	$rlSmarty -> assign_by_ref( 'pInfo', $pInfo );
	
	/* build rss */
	$rss = array(
		'item' => 'news',
		'title' => $lang['pages+name+'.$pages['news']]
	);
	$rlSmarty -> assign_by_ref( 'rss', $rss );
}
else
{
	$news = $rlNews -> get( $news_id, true );
	$rlSmarty -> assign( 'news', $news );
	
	$page_info['meta_description'] = $news['meta_description'];
	$page_info['meta_keywords'] = $news['meta_keywords'];
	
	$bread_crumbs[] = array(
		'title' => $news['title']
	);
	$page_info['name'] = $news['title'];
}
