<?php

/**

* @version		0.9.1

* @package		DJ Classifieds

* @subpackage	DJ Classifieds Items Module

* @copyright	Copyright (C) 2010 Blue Constant Media LTD, All rights reserved.

* @license		http://www.gnu.org/licenses GNU/GPL

* @autor url    http://design-joomla.eu

* @autor email  contact@design-joomla.eu

* @Developer    Lukasz Ciastek - lukasz.ciastek@design-joomla.eu

* 

* 

* DJ Classifieds is free software: you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation, either version 3 of the License, or

* (at your option) any later version.

*

* DJ Classifieds is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

* GNU General Public License for more details.

*

* You should have received a copy of the GNU General Public License

* along with DJ Classifieds. If not, see <http://www.gnu.org/licenses/>.

* 

*/





defined ('_JEXEC') or die('Restricted access');

	$date_time =& JFactory::getDate();

	$date_all=$date_time->toMySQL();

	$date = explode(' ',$date_all);	

	$ord = "i.date_start DESC";



	if($params->get('items_ord')==1){

		$ord = "i.display DESC"; 

	}else if($params->get('items_ord')==2){

		$ord = "rand()";

	}	

	

	$db= &JFactory::getDBO();	

	$query = "SELECT i.*, c.name as c_name FROM #__djcf_items i , #__djcf_categories c WHERE i.date_exp > '".$date[0]."' AND i.published = 1 AND i.cat_id=c.id ORDER BY ".$ord." limit ".$params->get('items_nr');

	$db->setQuery($query);

	$items=$db->loadObjectList();



		$par_id = $params->get('mainid');

		

		$menus	= &JSite::getMenu();



		foreach($menus->_items as $m){

			if($m->link == 'index.php?option=com_djclassifieds&view=show&cid=0'){

				$itemid=$m->id;

				break;

			}

		}		



if(JRequest::getVar('option')!='com_djclassifieds'){

	$document=& JFactory::getDocument();

	$cs = JURI::base().'components/com_djclassifieds/style.css';

	$document->addStyleSheet($cs);	

}



require(JModuleHelper::getLayoutPath('mod_djclassifiedsitems'));



?>

