<?php

/**

* @version		1.1

* @package		DJ Classifieds

* @subpackage	DJ Classifieds Component

* @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');



jimport('joomla.application.component.model');



JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');







class DjclassifiedsModelEdit extends JModel



{	



	function getCat()



	{

		global $option;



		JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');

		$row =& JTable::getInstance('categories','Table');

		$cid = JRequest::getVar('cid', array(0), '', 'array' );

  		$id = $cid[0];

		$row->load( $id ); 

		return $row;

	}

	

	var $_categories;

	var $wynik = array();

	

	function checkChilds(&$tab){

		

		

		for($i=0; $i< count($tab); $i++){

			$wynik[] = $this->_categories[$i];

			$query = "SELECT * FROM #__djcf_categories WHERE parent_id LIKE ".$this->_categories[$i]->id."";

			$wyni = $this->_getList($query,0,0);

			$wynik = array_merge($wynik,$wyni);

			

		}

		$this->checkChilds($wyni);

	}

	

	function getCategories(){

		$cid = JRequest::getVar('cid', array(0), '', 'array' );

  		$id = $cid[0];

		if(!$this->_categories){

			

			$query = "SELECT * FROM #__djcf_categories WHERE id !=".$id." ORDER BY parent_id";



			$this->_categories = $this->_getList($query, 0, 0);



		}

		

		



		return $this->_categories;

	}

}