<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.0
 *	LISENSE: http://www.flynax.com/license-agreement.html
 *	PRODUCT: General Classifieds
 *	
 *	FILE: MY_FAVORITE.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/
 *
 ******************************************************************************/

$reefless -> loadClass( 'Listings' );
$reefless -> loadClass( 'Actions' );

/* paging info */
$pInfo['current'] = (int)$_GET['pg'];

/* fields for sorting */
$sorting = array(
	'category' => array(
		'name' => $lang['category'],
		'field' => 'Category_ID'
	),
	'featured' => array(
		'name' => $lang['featured'],
		'field' => 'Featured'
	)
);
$rlSmarty -> assign_by_ref( 'sorting', $sorting );

/* define sort field */
$sort_by = empty($_GET['sort_by']) ? $_SESSION['fl_sort_by'] : $_GET['sort_by'];
if ( !empty($sorting[$sort_by]) )
{
	$order_field = $sorting[$sort_by]['field'];
}
$_SESSION['fl_sort_by'] = $sort_by;
$rlSmarty -> assign_by_ref( 'sort_by', $sort_by );

/* define sort type */
$sort_type = empty($_GET['sort_type']) ? $_SESSION['fl_sort_type'] : $_GET['sort_type'] ;
$sort_type = ( $sort_type == 'asc' || $sort_type == 'desc' ) ? $sort_type : false ;
$_SESSION['fl_sort_type'] = $sort_type;
$rlSmarty -> assign_by_ref( 'sort_type', $sort_type );

/* get listings */
$listings = $rlListings -> getMyFavorite( $order_field, $sort_type, $pInfo['current'], $config['listings_per_page']);
$rlSmarty -> assign_by_ref( 'listings', $listings );

$pInfo['calc'] = $rlListings -> calc;
$rlSmarty -> assign_by_ref( 'pInfo', $pInfo );