<?php
/**
* @version 1.0.0
* @package RSFiles! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

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

class rsfilesViewFiles extends JView
{
	//Creates the Event Feed

	function display( )
	{
		global $mainframe;

		$doc		= & JFactory::getDocument();
		$db			= & JFactory::getDBO();
		
		//get the itemid
		$Itemid = JRequest::getVar('Itemid','','request');
		$itemid = ($Itemid == '') ? '' : '&Itemid='.$Itemid;

		//get the current folder
		$currentfolder = $this->get('CurrentFolder');
		
		// Get some data from the model
		JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
		$rows = & $this->get('FolderFiles');
		
		foreach ( $rows as $row )
		{
			// strip html from feed item title
			$title = $this->escape( $row->name );
			$title = html_entity_decode( $title );
			

			// url link to article
			// & used instead of &amp; as this is converted by feed creator
			if($row->type == 'folder')
				$link = 'index.php?option=com_rsfiles&view=files&folder='.$row->fullpath.$itemid;
			else
				$link = 'index.php?option=com_rsfiles&view=files&layout=download&path='.$row->fullpath.$itemid;
			$link = JRoute::_( $link );

			@$created =  ($row->time == 0) ? date( 'r', $row->time) : date( 'r', $row->time) ;

			// load individual item creator class
			$item = new JFeedItem();
			$item->title 		= $title;
			$item->link 		= $link;
			$item->description 	= $row->filedescription;
			$item->date			= $created;

			// loads item info into rss array
			$doc->addItem( $item );
		}
	}
}
?>