<?php
/**
 * Mobile Joomla! Pro
 * http://www.mobilejoomla.com
 *
 * @version		1.2.13.pro
 * @license		GNU/GPL v2 - http://www.gnu.org/licenses/gpl-2.0.html
 * @copyright	(C) 2008-2015 Kuneri Ltd.
 * @date		February 2015
 */
defined('_JEXEC') or die('Restricted access');

if(class_exists('JElement'))
{
	class JElementConnecttype extends JElement
	{
		public $_name = 'Connecttype';
		public function fetchElement($name, $value, &$node, $control_name)
		{
			return $this->renderElement($control_name.'['.$name.']', $value, $control_name.$name, 'class="inputbox"');
		}
		private function renderElement($name, $value, $id, $attribs='')
		{
			$options = array ();
			$options[] = JHTML::_('select.option', '-',  '- '.JText::_('None').' -');
			$options[] = JHTML::_('select.option', 'fsock',  JText::_('fsock'),  'value', 'text', !function_exists('fsockopen'));
			$options[] = JHTML::_('select.option', 'curl',   JText::_('curl'),   'value', 'text', !function_exists('curl_init'));
			$options[] = JHTML::_('select.option', 'stream', JText::_('stream'), 'value', 'text', !ini_get('allow_url_fopen'));

			return JHTML::_('select.genericlist', $options, $name, $attribs, 'value', 'text', $value, $id);
		}
	}
}

if(class_exists('JFormField'))
{
	class JFormFieldConnecttype extends JFormField
	{
		protected $type = 'Connecttype';
		protected function getInput()
		{
			return $this->renderElement($this->name, $this->value, $this->id);
		}
		private function renderElement($name, $value, $id, $attribs='')
		{
			$options = array ();
			$options[] = JHTML::_('select.option', '-',  '- '.JText::_('None').' -');
			$options[] = JHTML::_('select.option', 'fsock',  JText::_('fsock'),  'value', 'text', !function_exists('fsockopen'));
			$options[] = JHTML::_('select.option', 'curl',   JText::_('curl'),   'value', 'text', !function_exists('curl_init'));
			$options[] = JHTML::_('select.option', 'stream', JText::_('stream'), 'value', 'text', !ini_get('allow_url_fopen'));

			return JHTML::_('select.genericlist', $options, $name, $attribs, 'value', 'text', $value, $id);
		}
	}
}
