Your IP : 216.73.216.41


Current Path : /home/purehotels/public_html/plugins/content/easyfolderlistingpro/fields/
Upload File :
Current File : /home/purehotels/public_html/plugins/content/easyfolderlistingpro/fields/eflpprofile.php

<?php
/**
* @version		3.0
* @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 to this file
defined('_JEXEC') or die('Restricted access');

//Register the Loggers
JLog::addLogger(array('logger' => 'messagequeue', 'context' => 'com_easyfolderlistingpro'), JLog::EMERGENCY + JLog::ALERT + JLog::CRITICAL + JLog::ERROR + JLog::WARNING + JLog::NOTICE, array('com_easyfolderlistingpro'));
JLog::addLogger(array('logger' => 'formattedtext', 'text_file' => 'valorapps.errors.php'), JLog::EMERGENCY + JLog::ALERT + JLog::CRITICAL + JLog::ERROR + JLog::WARNING, array('com_easyfolderlistingpro'));
JLog::addLogger(array('logger' => 'formattedtext', 'text_file' => 'valorapps.debug.php'), JLog::DEBUG, array('com_easyfolderlistingpro'));

//get joomla form related functions
jimport('joomla.form.formfield');

class JFormFieldEFLPProfile extends JFormField
{
	//The form field type
	protected $type = 'eflpprofile';
	
	//The initialised state of the document object
	protected static $initialised = false;
	
	
	protected function getInput()
	{
		$html = array();
		$attr = '';

		// Initialize some field attributes.
		$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
		$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
		$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
		$attr .= $this->multiple ? ' multiple="multiple"' : '';

		// Initialize JavaScript field attributes.
		$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		// The text field.
		$html[] = '	<select name="'.$this->name.'" id="'.$this->id.'"'.$attr.' >';
		$html[] = JHtml::_('select.options', $this->profileOptions(), 'value', 'text', htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'));
		$html[] = '</select>';

		return implode("\n", $html);
	}
	
	protected function profileOptions()
	{
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		
		$query->select('id, title');
		$query->from('#__eflp_profiles');

		$db->setQuery($query);
		$profiles = $db->loadAssocList();
		
		// Check for a database error.
		if ($db->getErrorNum())
		{
			JLog::add($db->getErrorMsg(), JLog::ERROR, 'com_easyfolderlistingpro');
			//$e = new JException($db->getErrorMsg());
		}
		
		// Build the active state filter options.
		$options = array();

		if ($profiles)
		{
			foreach($profiles as $profile) 
			{
				$options[] = JHtml::_('select.option', $profile['id'], $profile['title']);
			}
		}
		return $options;
	}
}