| Current Path : /home/cbequiperp/www/administrator/components/com_uniterevolution/models/fields/ |
| Current File : /home/cbequiperp/www/administrator/components/com_uniterevolution/models/fields/myradio.php |
<?php
/**
* @package Unite Revolution Slider for Joomla 1.7-2.5
* @author UniteCMS.net
* @copyright (C) 2012 Unite CMS, All Rights Reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
defined('JPATH_PLATFORM') or die;
/**
* Form Field class for the Joomla Platform.
* Provides radio button inputs
*
* @package Joomla.Platform
* @subpackage Form
* @link http://www.w3.org/TR/html-markup/command.radio.html#command.radio
* @since 11.1
*/
class JFormFieldMyradio extends JMasterFieldUniteRev
{
/**
* The form field type.
*
* @var string
* @since 11.1
*/
protected $type = 'MyRadio';
/**
* Method to get the radio button field input markup.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
$this->operateControlStates();
// Initialize variables.
$html = array();
// Initialize some field attributes.
$class = "radio_small";
if(!empty($this->element['class']))
$class = $this->element['class'];
$class = 'class="radio '.$class.'"';
$style = "";
if($this->hidden == true)
$style = " style='display:none;' ";
// Start the radio field output.
$html[] = '<fieldset id="' . $this->id . '"' . $class . $style . ' >';
// Get the field options.
$options = $this->getOptions();
// Build the radio field output.
foreach ($options as $i => $option)
{
// Initialize some option attributes.
$checked = ((string) $option->value == (string) $this->value) ? ' checked="checked"' : '';
$class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
$disabled = !empty($option->disable) ? ' disabled="disabled"' : '';
// Initialize some JavaScript option attributes.
$onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';
$html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="'
. htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>';
$html[] = '<label for="' . $this->id . $i . '"' . $class . '>'
. JText::alt($option->text, preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)) . '</label>';
}
// End the radio field output.
$html[] = '</fieldset>';
return implode($html);
}
/**
* Method to get the field options for radio buttons.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
// Initialize variables.
$options = array();
foreach ($this->element->children() as $option)
{
// Only add <option /> elements.
if ($option->getName() != 'option')
{
continue;
}
// Create a new option object based on the <option /> element.
$tmp = JHtml::_(
'select.option', (string) $option['value'], trim((string) $option), 'value', 'text',
((string) $option['disabled'] == 'true')
);
// Set some option attributes.
$tmp->class = (string) $option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $option['onclick'];
// Add the option object to the result set.
$options[] = $tmp;
}
reset($options);
return $options;
}
}