Your IP : 216.73.216.41


Current Path : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/explorer/
Upload File :
Current File : /home/purehotels/public_html/components/com_easyfolderlistingpro/views/explorer/view.raw.php

<?php
/**
* @version		3.2
* @author		Michael A. Gilkes (michael@valorapps.com)
* @copyright	Michael Albert Gilkes
* @license		GNU/GPLv3

Easy Folder Listing Pro Component for Joomla!
Copyright (C) 2012-2016 Michael Albert Gilkes (Valor Apps)

This program 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.

This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
*/

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

require_once(JPATH_SITE.'/components/com_easyfolderlistingpro/helpers/ListingData.Class.php');
require_once(JPATH_SITE.'/components/com_easyfolderlistingpro/helpers/EFLPExplorerList.Class.php');
require_once(JPATH_ADMINISTRATOR.'/components/com_easyfolderlistingpro/helpers/eflphelper.php');
jimport('joomla.filesystem.file');


class EasyFolderListingProViewExplorer extends JViewLegacy
{
	protected $listing = null;
	protected $token = null;
	
	protected $message = null;
	
	/**
	 * Overwriting JView display method
	 */
	function display($tpl = null) 
	{
		//get the listing data. It is already normalized.
		$listing_data = JFactory::getApplication()->input->get('data', '', 'raw');
		
		//decode the data
		$normalized = ValorUtilities::elucidate($listing_data);
		
		//if no data exists. log the error
		if (empty($normalized))
		{
			//form the message
			$error = JText::sprintf('COM_EFLP_EXPLORER_NODATA_ERROR', ValorUtilities::getUserIP());
			
			//log the error
			JLog::add($error, JLog::ALERT, 'com_easyfolderlistingpro');
			
			//format the message
			$message = EFLPHelper::formatMessage($error, 'error');
			
			//display the error
			echo EFLPHelper::systemMessageHTML($message);
		}
		else
		{
			$data = new ListingData($normalized);
			
			//determine file depth and sorting order based on type of listing
			$ignore_subfolders = false;
			$preserve_folders = true;
		
			//get the processed files data
			$files = $data->getFilesData($ignore_subfolders, $preserve_folders);
		
			//check to see if there are errors from processing the files data
			if (count($data->getErrors()))
			{
				//format the messages
				$messages = EFLPHelper::formatMessages($data->getErrors(), 'error');
				
				//display the error
				echo EFLPHelper::systemMessageHTML($messages);
				
				return; //bye
			}
		
			//if the files is empty, get the errors and display them
			if (empty($files))
			{
				//format the message
				$message = EFLPHelper::formatMessage(JText::_('COM_EFLP_EXPLORER_NO_FILES'), 'notice');
				
				//display the error
				echo EFLPHelper::systemMessageHTML($message);
				
				return; //bye
			}
		
			//seems like we need to get the folders too
			$folders = $data->getFoldersData($ignore_subfolders);
		
			//check to see if there are errors from processing the folders data
			if (count($data->getErrors()))
			{
				//format the messages
				$messages = EFLPHelper::formatMessages($data->getErrors(), 'error');
				
				//display the error
				echo EFLPHelper::systemMessageHTML($messages);
				
				return; //bye
			}
			
			//get the listing Id from the request variables
			$id = JFactory::getApplication()->input->get('listingId', null, 'raw');
			
			//get the Component Configuration
			$config = EFLPHelper::retrieveConfig();
			
			//get the Component Icons data
			$icons = EFLPHelper::retrieveIcons();
			
			//instantiate the listing variable
			$this->listing = new EFLPExplorerList($id, $normalized, $config, $icons, $files, $folders);
			
			if (empty($this->listing))
			{
				//format the message
				$message = EFLPHelper::formatMessage(JText::_('COM_EFLP_EXPLORER_INSTANTIATING_LISTING_OBJECT_ERROR'), 'error');
				
				//display the error
				echo EFLPHelper::systemMessageHTML($message);
				
				return; //bye
			}
			
			//get the folder status from the request
			$status = JFactory::getApplication()->input->get('status', '', 'raw');
			
			//decode the data
			$folder_status = ValorUtilities::elucidate($status);
			
			//set the pagelimit as the limit per page of the listing
			$this->listing->setCurrentFolder($folder_status['current']);
			$this->listing->setParentFolder($folder_status['parent']);
			
			//get the token, to maintain the same token
			$this->token = JFactory::getApplication()->input->get('token', null, 'raw');
			
			//load the language file for the companion plugin
			$lang = JFactory::getLanguage();
			$langLoaded = $lang->load('plg_content_easyfolderlistingpro', JPATH_ADMINISTRATOR, null, false, true);
			if (!$langLoaded)
			{
				$langLoaded = $lang->load('plg_content_easyfolderlistingpro', JPATH_PLUGINS.'/content/easyfolderlistingpro', null, false, true);
				if (!$langLoaded)
				{
					//log the fact that the plugin language file wasn't loaded.
					JLog::add(JText::_('COM_EFLP_EXPLORER_PLUGIN_LANGUAGE_FILE_NOT_LOADED'), JLog::ALERT, 'com_easyfolderlistingpro');
				}
			}
			
			//display the text
			parent::display($tpl);
		}
	}
}