You've already forked joomla_test
first commit
This commit is contained in:
60
libraries/joomla/form/fields/accesslevel.php
Normal file
60
libraries/joomla/form/fields/accesslevel.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a list of access levels. Access levels control what users in specific
|
||||
* groups can see.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @see JAccess
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldAccessLevel extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'AccessLevel';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$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"' : '';
|
||||
$attr .= $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
// Get the field options.
|
||||
$options = $this->getOptions();
|
||||
|
||||
return JHtml::_('access.level', $this->name, $this->value, $attr, $options, $this->id);
|
||||
}
|
||||
}
|
54
libraries/joomla/form/fields/cachehandler.php
Normal file
54
libraries/joomla/form/fields/cachehandler.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a list of available cache handlers
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @see JCache
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldCacheHandler extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'CacheHandler';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Convert to name => name array.
|
||||
foreach (JCache::getStores() as $store)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $store, JText::_('JLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text');
|
||||
}
|
||||
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
119
libraries/joomla/form/fields/calendar.php
Normal file
119
libraries/joomla/form/fields/calendar.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
*
|
||||
* Provides a pop up date picker linked to a button.
|
||||
* Optionally may be filtered to use user's or server's time zone.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldCalendar extends JFormField
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'Calendar';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$format = $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d';
|
||||
|
||||
// Build the attributes array.
|
||||
$attributes = array();
|
||||
if ($this->element['size'])
|
||||
{
|
||||
$attributes['size'] = (int) $this->element['size'];
|
||||
}
|
||||
if ($this->element['maxlength'])
|
||||
{
|
||||
$attributes['maxlength'] = (int) $this->element['maxlength'];
|
||||
}
|
||||
if ($this->element['class'])
|
||||
{
|
||||
$attributes['class'] = (string) $this->element['class'];
|
||||
}
|
||||
if ((string) $this->element['readonly'] == 'true')
|
||||
{
|
||||
$attributes['readonly'] = 'readonly';
|
||||
}
|
||||
if ((string) $this->element['disabled'] == 'true')
|
||||
{
|
||||
$attributes['disabled'] = 'disabled';
|
||||
}
|
||||
if ($this->element['onchange'])
|
||||
{
|
||||
$attributes['onchange'] = (string) $this->element['onchange'];
|
||||
}
|
||||
if ($this->required)
|
||||
{
|
||||
$attributes['required'] = 'required';
|
||||
$attributes['aria-required'] = 'true';
|
||||
}
|
||||
|
||||
// Handle the special case for "now".
|
||||
if (strtoupper($this->value) == 'NOW')
|
||||
{
|
||||
$this->value = strftime($format);
|
||||
}
|
||||
|
||||
// Get some system objects.
|
||||
$config = JFactory::getConfig();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// If a known filter is given use it.
|
||||
switch (strtoupper((string) $this->element['filter']))
|
||||
{
|
||||
case 'SERVER_UTC':
|
||||
// Convert a date to UTC based on the server timezone.
|
||||
if ((int) $this->value)
|
||||
{
|
||||
// Get a date object based on the correct timezone.
|
||||
$date = JFactory::getDate($this->value, 'UTC');
|
||||
$date->setTimezone(new DateTimeZone($config->get('offset')));
|
||||
|
||||
// Transform the date string.
|
||||
$this->value = $date->format('Y-m-d H:i:s', true, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'USER_UTC':
|
||||
// Convert a date to UTC based on the user timezone.
|
||||
if ((int) $this->value)
|
||||
{
|
||||
// Get a date object based on the correct timezone.
|
||||
$date = JFactory::getDate($this->value, 'UTC');
|
||||
$date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
|
||||
|
||||
// Transform the date string.
|
||||
$this->value = $date->format('Y-m-d H:i:s', true, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return JHtml::_('calendar', $this->value, $this->name, $this->id, $format, $attributes);
|
||||
}
|
||||
}
|
64
libraries/joomla/form/fields/checkbox.php
Normal file
64
libraries/joomla/form/fields/checkbox.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Single check box field.
|
||||
* This is a boolean field with null for false and the specified option for true
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.checkbox.html#input.checkbox
|
||||
* @see JFormFieldCheckboxes
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldCheckbox extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'Checkbox';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
* The checked element sets the field to selected.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$value = $this->element['value'] ? (string) $this->element['value'] : '1';
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
if (empty($this->value))
|
||||
{
|
||||
$checked = (isset($this->element['checked'] )) ? ' checked="checked"' : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$checked = ' checked="checked"';
|
||||
}
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onclick = $this->element['onclick'] ? ' onclick="' . (string) $this->element['onclick'] . '"' : '';
|
||||
|
||||
return '<input type="checkbox" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"' . $class . $checked . $disabled . $onclick . $required . ' />';
|
||||
}
|
||||
}
|
137
libraries/joomla/form/fields/checkboxes.php
Normal file
137
libraries/joomla/form/fields/checkboxes.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Displays options as a list of check boxes.
|
||||
* Multiselect may be forced to be true.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @see JFormFieldCheckbox
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldCheckboxes extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Checkboxes';
|
||||
|
||||
/**
|
||||
* Flag to tell the field to always be in multiple values mode.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $forceMultiple = true;
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for check boxes.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$html = array();
|
||||
|
||||
// Initialize some field attributes.
|
||||
$class = $this->element['class'] ? ' class="checkboxes ' . (string) $this->element['class'] . '"' : ' class="checkboxes"';
|
||||
$checkedOptions = explode(',', (string) $this->element['checked']);
|
||||
|
||||
// Start the checkbox field output.
|
||||
$html[] = '<fieldset id="' . $this->id . '"' . $class . '>';
|
||||
|
||||
// Get the field options.
|
||||
$options = $this->getOptions();
|
||||
|
||||
// Build the checkbox field output.
|
||||
$html[] = '<ul>';
|
||||
foreach ($options as $i => $option)
|
||||
{
|
||||
// Initialize some option attributes.
|
||||
if (!isset($this->value) || empty($this->value))
|
||||
{
|
||||
$checked = (in_array((string) $option->value, (array) $checkedOptions) ? ' checked="checked"' : '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = !is_array($this->value) ? explode(',', $this->value) : $this->value;
|
||||
$checked = (in_array((string) $option->value, $value) ? ' checked="checked"' : '');
|
||||
}
|
||||
$class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
|
||||
$required = !empty($option->required) ? ' required="required" aria-required="true"' : '';
|
||||
$disabled = !empty($option->disable) ? ' disabled="disabled"' : '';
|
||||
|
||||
// Initialize some JavaScript option attributes.
|
||||
$onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';
|
||||
|
||||
$html[] = '<li>';
|
||||
$html[] = '<input type="checkbox" id="' . $this->id . $i . '" name="' . $this->name . '" value="'
|
||||
. htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . $required . '/>';
|
||||
|
||||
$html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . JText::_($option->text) . '</label>';
|
||||
$html[] = '</li>';
|
||||
}
|
||||
$html[] = '</ul>';
|
||||
|
||||
// End the checkbox field output.
|
||||
$html[] = '</fieldset>';
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
140
libraries/joomla/form/fields/color.php
Normal file
140
libraries/joomla/form/fields/color.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Color Form Field class for the Joomla Platform.
|
||||
* This implementation is designed to be compatible with HTML5's <input type="color">
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.color.html
|
||||
* @since 11.3
|
||||
*/
|
||||
class JFormFieldColor extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.3
|
||||
*/
|
||||
protected $type = 'Color';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.3
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Control value can be: hue (default), saturation, brightness, wheel or simpel
|
||||
$control = (string) $this->element['control'];
|
||||
|
||||
// Position of the panel can be: right (default), left, top or bottom
|
||||
$position = $this->element['position'] ? (string) $this->element['position'] : 'right';
|
||||
$position = ' data-position="' . $position . '"';
|
||||
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
$class = (string) $this->element['class'];
|
||||
|
||||
$color = strtolower($this->value);
|
||||
|
||||
if (!$color || in_array($color, array('none', 'transparent')))
|
||||
{
|
||||
$color = 'none';
|
||||
}
|
||||
elseif ($color['0'] != '#')
|
||||
{
|
||||
$color = '#' . $color;
|
||||
}
|
||||
|
||||
if ($control == 'simple')
|
||||
{
|
||||
$class = ' class="' . trim('simplecolors chzn-done ' . $class) . '"';
|
||||
JHtml::_('behavior.simplecolorpicker');
|
||||
|
||||
$colors = strtolower((string) $this->element['colors']);
|
||||
|
||||
if (empty($colors))
|
||||
{
|
||||
$colors = array(
|
||||
'none',
|
||||
'#049cdb',
|
||||
'#46a546',
|
||||
'#9d261d',
|
||||
'#ffc40d',
|
||||
'#f89406',
|
||||
'#c3325f',
|
||||
'#7a43b6',
|
||||
'#ffffff',
|
||||
'#999999',
|
||||
'#555555',
|
||||
'#000000'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$colors = explode(',', $colors);
|
||||
}
|
||||
|
||||
$split = (int) $this->element['split'];
|
||||
|
||||
if (!$split)
|
||||
{
|
||||
$count = count($colors);
|
||||
|
||||
if ($count % 5 == 0)
|
||||
{
|
||||
$split = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($count % 4 == 0)
|
||||
{
|
||||
$split = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$split = $split ? $split : 3;
|
||||
|
||||
$html = array();
|
||||
$html[] = '<select name="' . $this->name . '" id="' . $this->id . '"'
|
||||
. $class . $position . $onchange . ' style="visibility:hidden;width:22px;height:1px">';
|
||||
|
||||
foreach ($colors as $i => $c)
|
||||
{
|
||||
$html[] = '<option' . ($c == $color ? ' selected="selected"' : '') . '>' . $c . '</option>';
|
||||
|
||||
if (($i + 1) % $split == 0)
|
||||
{
|
||||
$html[] = '<option>-</option>';
|
||||
}
|
||||
}
|
||||
$html[] = '</select>';
|
||||
|
||||
return implode('', $html);
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = ' class="' . trim('minicolors ' . $class) . '"';
|
||||
$control = $control ? ' data-control="' . $control . '"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
|
||||
JHtml::_('behavior.colorpicker');
|
||||
|
||||
return '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
|
||||
. htmlspecialchars($color, ENT_COMPAT, 'UTF-8') . '"' . $class . $position . $control . $disabled . $onchange . '/>';
|
||||
}
|
||||
}
|
||||
}
|
74
libraries/joomla/form/fields/combo.php
Normal file
74
libraries/joomla/form/fields/combo.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Implements a combo box field.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldCombo extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'Combo';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for a combo box field.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$html = array();
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= $this->element['class'] ? ' class="combobox ' . (string) $this->element['class'] . '"' : ' class="combobox"';
|
||||
$attr .= ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
|
||||
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$attr .= $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
// Get the field options.
|
||||
$options = $this->getOptions();
|
||||
|
||||
// Load the combobox behavior.
|
||||
JHtml::_('behavior.combobox');
|
||||
|
||||
// Build the input for the combo box.
|
||||
$html[] = '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $attr . '/>';
|
||||
|
||||
// Build the list for the combo box.
|
||||
$html[] = '<ul id="combobox-' . $this->id . '" style="display:none;">';
|
||||
foreach ($options as $option)
|
||||
{
|
||||
$html[] = '<li>' . $option->text . '</li>';
|
||||
}
|
||||
$html[] = '</ul>';
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
}
|
84
libraries/joomla/form/fields/databaseconnection.php
Normal file
84
libraries/joomla/form/fields/databaseconnection.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a list of available database connections, optionally limiting to
|
||||
* a given list.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @see JDatabaseDriver
|
||||
* @since 11.3
|
||||
*/
|
||||
class JFormFieldDatabaseConnection extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.3
|
||||
*/
|
||||
public $type = 'DatabaseConnection';
|
||||
|
||||
/**
|
||||
* Method to get the list of database options.
|
||||
*
|
||||
* This method produces a drop down list of available databases supported
|
||||
* by JDatabaseDriver classes that are also supported by the application.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.3
|
||||
* @see JDatabaseDriver
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// This gets the connectors available in the platform and supported by the server.
|
||||
$available = JDatabaseDriver::getConnectors();
|
||||
|
||||
/**
|
||||
* This gets the list of database types supported by the application.
|
||||
* This should be entered in the form definition as a comma separated list.
|
||||
* If no supported databases are listed, it is assumed all available databases
|
||||
* are supported.
|
||||
*/
|
||||
$supported = $this->element['supported'];
|
||||
if (!empty($supported))
|
||||
{
|
||||
$supported = explode(',', $supported);
|
||||
foreach ($supported as $support)
|
||||
{
|
||||
if (in_array($support, $available))
|
||||
{
|
||||
$options[$support] = JText::_(ucfirst($support));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($available as $support)
|
||||
{
|
||||
$options[$support] = JText::_(ucfirst($support));
|
||||
}
|
||||
}
|
||||
|
||||
// This will come into play if an application is installed that requires
|
||||
// a database that is not available on the server.
|
||||
if (empty($options))
|
||||
{
|
||||
$options[''] = JText::_('JNONE');
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
55
libraries/joomla/form/fields/email.php
Normal file
55
libraries/joomla/form/fields/email.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides and input field for e-mail addresses
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.email.html#input.email
|
||||
* @see JFormRuleEmail
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldEMail extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Email';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for e-mail addresses.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
|
||||
$class = $this->element['class'] ? ' ' . (string) $this->element['class'] : '';
|
||||
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
return '<input type="text" name="' . $this->name . '" class="' . $class . '" id="' . $this->id . '" value="'
|
||||
. JStringPunycode::emailToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $onchange . $maxLength . $required . '/>';
|
||||
}
|
||||
}
|
58
libraries/joomla/form/fields/file.php
Normal file
58
libraries/joomla/form/fields/file.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides an input field for files
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.file.html#input.file
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldFile extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'File';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for the file field.
|
||||
* Field attributes allow specification of a maximum file size and a string
|
||||
* of accepted file extensions.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*
|
||||
* @note The field does not include an upload mechanism.
|
||||
* @see JFormFieldMedia
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$accept = $this->element['accept'] ? ' accept="' . (string) $this->element['accept'] . '"' : '';
|
||||
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
return '<input type="file" name="' . $this->name . '" id="' . $this->id . '" value=""' . $accept . $disabled . $class . $size
|
||||
. $onchange . $required . ' />';
|
||||
}
|
||||
}
|
105
libraries/joomla/form/fields/filelist.php
Normal file
105
libraries/joomla/form/fields/filelist.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
jimport('joomla.filesystem.file');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Supports an HTML select list of files
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldFileList extends JFormFieldList
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'FileList';
|
||||
|
||||
/**
|
||||
* Method to get the list of files for the field options.
|
||||
* Specify the target directory with a directory attribute
|
||||
* Attributes allow an exclude mask and stripping of extensions from file name.
|
||||
* Default attribute may optionally be set to null (no file) or -1 (use a default).
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Initialize some field attributes.
|
||||
$filter = (string) $this->element['filter'];
|
||||
$exclude = (string) $this->element['exclude'];
|
||||
$stripExt = (string) $this->element['stripext'];
|
||||
$hideNone = (string) $this->element['hide_none'];
|
||||
$hideDefault = (string) $this->element['hide_default'];
|
||||
|
||||
// Get the path in which to search for file options.
|
||||
$path = (string) $this->element['directory'];
|
||||
if (!is_dir($path))
|
||||
{
|
||||
$path = JPATH_ROOT . '/' . $path;
|
||||
}
|
||||
|
||||
// Prepend some default options based on field attributes.
|
||||
if (!$hideNone)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '-1', JText::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
|
||||
}
|
||||
if (!$hideDefault)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '', JText::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
|
||||
}
|
||||
|
||||
// Get a list of files in the search path with the given filter.
|
||||
$files = JFolder::files($path, $filter);
|
||||
|
||||
// Build the options list from the list of files.
|
||||
if (is_array($files))
|
||||
{
|
||||
foreach ($files as $file)
|
||||
{
|
||||
|
||||
// Check to see if the file is in the exclude mask.
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match(chr(1) . $exclude . chr(1), $file))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If the extension is to be stripped, do it.
|
||||
if ($stripExt)
|
||||
{
|
||||
$file = JFile::stripExt($file);
|
||||
}
|
||||
|
||||
$options[] = JHtml::_('select.option', $file, $file);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
94
libraries/joomla/form/fields/folderlist.php
Normal file
94
libraries/joomla/form/fields/folderlist.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Supports an HTML select list of folder
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldFolderList extends JFormFieldList
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'FolderList';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Initialize some field attributes.
|
||||
$filter = (string) $this->element['filter'];
|
||||
$exclude = (string) $this->element['exclude'];
|
||||
$hideNone = (string) $this->element['hide_none'];
|
||||
$hideDefault = (string) $this->element['hide_default'];
|
||||
|
||||
// Get the path in which to search for file options.
|
||||
$path = (string) $this->element['directory'];
|
||||
if (!is_dir($path))
|
||||
{
|
||||
$path = JPATH_ROOT . '/' . $path;
|
||||
}
|
||||
|
||||
// Prepend some default options based on field attributes.
|
||||
if (!$hideNone)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '-1', JText::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
|
||||
}
|
||||
if (!$hideDefault)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '', JText::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
|
||||
}
|
||||
|
||||
// Get a list of folders in the search path with the given filter.
|
||||
$folders = JFolder::folders($path, $filter);
|
||||
|
||||
// Build the options list from the list of folders.
|
||||
if (is_array($folders))
|
||||
{
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
|
||||
// Check to see if the file is in the exclude mask.
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match(chr(1) . $exclude . chr(1), $folder))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$options[] = JHtml::_('select.option', $folder, $folder);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
180
libraries/joomla/form/fields/groupedlist.php
Normal file
180
libraries/joomla/form/fields/groupedlist.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a grouped list select field.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldGroupedList extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'GroupedList';
|
||||
|
||||
/**
|
||||
* Method to get the field option groups.
|
||||
*
|
||||
* @return array The field option objects as a nested array in groups.
|
||||
*
|
||||
* @since 11.1
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
protected function getGroups()
|
||||
{
|
||||
$groups = array();
|
||||
$label = 0;
|
||||
|
||||
foreach ($this->element->children() as $element)
|
||||
{
|
||||
switch ($element->getName())
|
||||
{
|
||||
// The element is an <option />
|
||||
case 'option':
|
||||
// Initialize the group if necessary.
|
||||
if (!isset($groups[$label]))
|
||||
{
|
||||
$groups[$label] = array();
|
||||
}
|
||||
|
||||
// Create a new option object based on the <option /> element.
|
||||
$tmp = JHtml::_(
|
||||
'select.option', ($element['value']) ? (string) $element['value'] : trim((string) $element),
|
||||
JText::alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
|
||||
((string) $element['disabled'] == 'true')
|
||||
);
|
||||
|
||||
// Set some option attributes.
|
||||
$tmp->class = (string) $element['class'];
|
||||
|
||||
// Set some JavaScript option attributes.
|
||||
$tmp->onclick = (string) $element['onclick'];
|
||||
|
||||
// Add the option.
|
||||
$groups[$label][] = $tmp;
|
||||
break;
|
||||
|
||||
// The element is a <group />
|
||||
case 'group':
|
||||
// Get the group label.
|
||||
if ($groupLabel = (string) $element['label'])
|
||||
{
|
||||
$label = JText::_($groupLabel);
|
||||
}
|
||||
|
||||
// Initialize the group if necessary.
|
||||
if (!isset($groups[$label]))
|
||||
{
|
||||
$groups[$label] = array();
|
||||
}
|
||||
|
||||
// Iterate through the children and build an array of options.
|
||||
foreach ($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', ($option['value']) ? (string) $option['value'] : JText::_(trim((string) $option)),
|
||||
JText::_(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.
|
||||
$groups[$label][] = $tmp;
|
||||
}
|
||||
|
||||
if ($groupLabel)
|
||||
{
|
||||
$label = count($groups);
|
||||
}
|
||||
break;
|
||||
|
||||
// Unknown element type.
|
||||
default:
|
||||
throw new UnexpectedValueException(sprintf('Unsupported element %s in JFormFieldGroupedList', $element->getName()), 500);
|
||||
}
|
||||
}
|
||||
|
||||
reset($groups);
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup fora grouped list.
|
||||
* Multiselect is enabled by using the multiple attribute.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
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"' : '';
|
||||
$attr .= $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
// Get the field groups.
|
||||
$groups = (array) $this->getGroups();
|
||||
|
||||
// Create a read-only list (no name) with a hidden input to store the value.
|
||||
if ((string) $this->element['readonly'] == 'true')
|
||||
{
|
||||
$html[] = JHtml::_(
|
||||
'select.groupedlist', $groups, null,
|
||||
array(
|
||||
'list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'group.items' => null, 'option.key.toHtml' => false,
|
||||
'option.text.toHtml' => false
|
||||
)
|
||||
);
|
||||
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
|
||||
}
|
||||
// Create a regular list.
|
||||
else
|
||||
{
|
||||
$html[] = JHtml::_(
|
||||
'select.groupedlist', $groups, $this->name,
|
||||
array(
|
||||
'list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'group.items' => null, 'option.key.toHtml' => false,
|
||||
'option.text.toHtml' => false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
}
|
50
libraries/joomla/form/fields/hidden.php
Normal file
50
libraries/joomla/form/fields/hidden.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a hidden field
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.hidden.html#input.hidden
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldHidden extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Hidden';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
return '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $disabled . $onchange . ' />';
|
||||
}
|
||||
}
|
51
libraries/joomla/form/fields/imagelist.php
Normal file
51
libraries/joomla/form/fields/imagelist.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('filelist');
|
||||
|
||||
/**
|
||||
* Supports an HTML select list of image
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldImageList extends JFormFieldFileList
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'ImageList';
|
||||
|
||||
/**
|
||||
* Method to get the list of images field options.
|
||||
* Use the filter attribute to specify allowable file extensions.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Define the image file type filter.
|
||||
$filter = '\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$|\.jpeg$|\.psd$|\.eps$';
|
||||
|
||||
// Set the form field element attribute for file type filter.
|
||||
$this->element->addAttribute('filter', $filter);
|
||||
|
||||
// Get the field options.
|
||||
return parent::getOptions();
|
||||
}
|
||||
}
|
1
libraries/joomla/form/fields/index.html
Normal file
1
libraries/joomla/form/fields/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
87
libraries/joomla/form/fields/integer.php
Normal file
87
libraries/joomla/form/fields/integer.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a select list of integers with specified first, last and step values.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldInteger extends JFormFieldList
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Integer';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Initialize some field attributes.
|
||||
$first = (int) $this->element['first'];
|
||||
$last = (int) $this->element['last'];
|
||||
$step = (int) $this->element['step'];
|
||||
|
||||
// Sanity checks.
|
||||
if ($step == 0)
|
||||
{
|
||||
// Step of 0 will create an endless loop.
|
||||
return $options;
|
||||
}
|
||||
elseif ($first < $last && $step < 0)
|
||||
{
|
||||
// A negative step will never reach the last number.
|
||||
return $options;
|
||||
}
|
||||
elseif ($first > $last && $step > 0)
|
||||
{
|
||||
// A position step will never reach the last number.
|
||||
return $options;
|
||||
}
|
||||
elseif ($step < 0)
|
||||
{
|
||||
// Build the options array backwards.
|
||||
for ($i = $first; $i >= $last; $i += $step)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Build the options array.
|
||||
for ($i = $first; $i <= $last; $i += $step)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $i);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
57
libraries/joomla/form/fields/language.php
Normal file
57
libraries/joomla/form/fields/language.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a list of installed application languages
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @see JFormFieldContentLanguage for a select list of content languages.
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldLanguage extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Language';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$client = (string) $this->element['client'];
|
||||
if ($client != 'site' && $client != 'administrator')
|
||||
{
|
||||
$client = 'site';
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(
|
||||
parent::getOptions(),
|
||||
JLanguageHelper::createLanguageList($this->value, constant('JPATH_' . strtoupper($client)), true, true)
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
118
libraries/joomla/form/fields/list.php
Normal file
118
libraries/joomla/form/fields/list.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a generic list of options.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldList extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'List';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for a generic list.
|
||||
* Use the multiple attribute to enable multiselect.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$html = array();
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
|
||||
// To avoid user's confusion, readonly="true" should imply disabled="true".
|
||||
if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true')
|
||||
{
|
||||
$attr .= ' disabled="disabled"';
|
||||
}
|
||||
|
||||
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$attr .= $this->multiple ? ' multiple="multiple"' : '';
|
||||
$attr .= $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
// Get the field options.
|
||||
$options = (array) $this->getOptions();
|
||||
|
||||
// Create a read-only list (no name) with a hidden input to store the value.
|
||||
if ((string) $this->element['readonly'] == 'true')
|
||||
{
|
||||
$html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
|
||||
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
|
||||
}
|
||||
// Create a regular list.
|
||||
else
|
||||
{
|
||||
$html[] = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
|
||||
}
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$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'],
|
||||
JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), '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;
|
||||
}
|
||||
}
|
75
libraries/joomla/form/fields/note.php
Normal file
75
libraries/joomla/form/fields/note.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a one line text field.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldNote extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Note';
|
||||
|
||||
/**
|
||||
* Method to get the field label markup.
|
||||
*
|
||||
* @return string The field label markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
if (empty($this->element['label']) && empty($this->element['description']))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$title = $this->element['label'] ? (string) $this->element['label'] : ($this->element['title'] ? (string) $this->element['title'] : '');
|
||||
$heading = $this->element['heading'] ? (string) $this->element['heading'] : 'h4';
|
||||
$description = (string) $this->element['description'];
|
||||
$class = $this->element['class'] ? ' class="' . trim((string) $this->element['class']) . '"' : '';
|
||||
$close = (string) $this->element['close'];
|
||||
|
||||
$html = array();
|
||||
if ($close)
|
||||
{
|
||||
$close = $close == 'true' ? 'alert' : $close;
|
||||
$html[] = '<button type="button" class="close" data-dismiss="' . $close . '">×</button>';
|
||||
}
|
||||
$html[] = !empty($title) ? '<' . $heading . '>' . JText::_($title) . '</' . $heading . '>' : '';
|
||||
$html[] = !empty($description) ? JText::_($description) : '';
|
||||
|
||||
return '</div><div ' . $class . '>' . implode('', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
101
libraries/joomla/form/fields/password.php
Normal file
101
libraries/joomla/form/fields/password.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Text field for passwords
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.password.html#input.password
|
||||
* @note Two password fields may be validated as matching using JFormRuleEquals
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldPassword extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Password';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for password.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '99';
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
$auto = ((string) $this->element['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
|
||||
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$meter = ((string) $this->element['strengthmeter'] == 'true' ? ' $meter= 1' : ' $meter = 0');
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
$threshold = $this->element['threshold'] ? (int) $this->element['threshold'] : 66;
|
||||
$minimumLength = $this->element['minimum_length'] ? (int) $this->element['minimum_length'] : 4;
|
||||
$minimumIntegers = $this->element['minimum_integers'] ? (int) $this->element['minimum_integers'] : 0;
|
||||
$minimumSymbols = $this->element['minimum_symbols'] ? (int) $this->element['minimum_symbols'] : 0;
|
||||
$minimumUppercase = $this->element['minimum_uppercase'] ? (int) $this->element['minimum_uppercase'] : 0;
|
||||
|
||||
// If we have parameters from com_users, use those instead.
|
||||
// Some of these may be empty for legacy reasons.
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
if ($app->getClientId() != 2)
|
||||
{
|
||||
$params = JComponentHelper::getParams('com_users');
|
||||
|
||||
if (!empty($params))
|
||||
{
|
||||
$minimumLengthp = $params->get('minimum_length');
|
||||
$minimumIntegersp = $params->get('minimum_integers');
|
||||
$minimumSymbolsp = $params->get('minimum_symbols');
|
||||
$minimumUppercasep = $params->get('minimum_uppercase');
|
||||
|
||||
if (!empty($minimumLengthp))
|
||||
{
|
||||
$minimumLength = (int) $minimumLengthp;
|
||||
}
|
||||
|
||||
empty($minimumIntegersp) ? : $minimumIntegers = (int) $minimumIntegersp;
|
||||
empty($minimumSymbolsp) ? : $minimumSymbols = (int) $minimumSymbolsp;
|
||||
empty($minimumUppercasep) ? : $minimumUppercase = (int) $minimumUppercasep;
|
||||
}
|
||||
}
|
||||
|
||||
$script = '';
|
||||
|
||||
if ($meter == 1)
|
||||
{
|
||||
JHtml::_('script', 'system/passwordstrength.js', true, true);
|
||||
$script = '<script type="text/javascript">new Form.PasswordStrength("' . $this->id . '",
|
||||
{
|
||||
threshold: ' . $threshold . ',
|
||||
onUpdate: function(element, strength, threshold) {
|
||||
element.set("data-passwordstrength", strength);
|
||||
}
|
||||
}
|
||||
);</script>';
|
||||
}
|
||||
|
||||
return '<input type="password" name="' . $this->name . '" id="' . $this->id . '"' .
|
||||
' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' .
|
||||
$auto . $class . $readonly . $disabled . $size . $maxLength . $required . '/>' . $script;
|
||||
}
|
||||
}
|
78
libraries/joomla/form/fields/plugins.php
Normal file
78
libraries/joomla/form/fields/plugins.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Framework.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.4
|
||||
*/
|
||||
class JFormFieldPlugins extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.4
|
||||
*/
|
||||
protected $type = 'Plugins';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options.
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$folder = $this->element['folder'];
|
||||
|
||||
if (!empty($folder))
|
||||
{
|
||||
// Get list of plugins
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('element AS value, name AS text')
|
||||
->from('#__extensions')
|
||||
->where('folder = ' . $db->quote($folder))
|
||||
->where('enabled = 1')
|
||||
->order('ordering, name');
|
||||
$db->setQuery($query);
|
||||
|
||||
$options = $db->loadObjectList();
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
foreach ($options as $i => $item)
|
||||
{
|
||||
$source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value;
|
||||
$extension = 'plg_' . $folder . '_' . $item->value;
|
||||
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false)
|
||||
|| $lang->load($extension . '.sys', $source, null, false, false)
|
||||
|| $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|
||||
|| $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false);
|
||||
$options[$i]->text = JText::_($item->text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JLog::add(JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'), JLog::WARNING, 'jerror');
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
117
libraries/joomla/form/fields/radio.php
Normal file
117
libraries/joomla/form/fields/radio.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
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 JFormFieldRadio extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Radio';
|
||||
|
||||
/**
|
||||
* Method to get the radio button field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$html = array();
|
||||
|
||||
// Initialize some field attributes.
|
||||
$class = $this->element['class'] ? ' class="radio ' . (string) $this->element['class'] . '"' : ' class="radio"';
|
||||
|
||||
// Start the radio field output.
|
||||
$html[] = '<fieldset id="' . $this->id . '"' . $class . '>';
|
||||
|
||||
// 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"' : '';
|
||||
$required = !empty($option->required) ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// 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 . $required . '/>';
|
||||
|
||||
$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()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
311
libraries/joomla/form/fields/rules.php
Normal file
311
libraries/joomla/form/fields/rules.php
Normal file
@ -0,0 +1,311 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Field for assigning permissions to groups for a given asset
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @see JAccess
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldRules extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'Rules';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for Access Control Lists.
|
||||
* Optionally can be associated with a specific component and section.
|
||||
*
|
||||
* TODO: Add access check.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
|
||||
// Initialise some field attributes.
|
||||
$section = $this->element['section'] ? (string) $this->element['section'] : '';
|
||||
$component = $this->element['component'] ? (string) $this->element['component'] : '';
|
||||
$assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
|
||||
|
||||
// Get the actions for the asset.
|
||||
$actions = JAccess::getActions($component, $section);
|
||||
|
||||
// Iterate over the children and add to the actions.
|
||||
foreach ($this->element->children() as $el)
|
||||
{
|
||||
if ($el->getName() == 'action')
|
||||
{
|
||||
$actions[] = (object) array('name' => (string) $el['name'], 'title' => (string) $el['title'],
|
||||
'description' => (string) $el['description']);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the explicit rules for this asset.
|
||||
if ($section == 'component')
|
||||
{
|
||||
// Need to find the asset id by the name of the component.
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('id'))
|
||||
->from($db->quoteName('#__assets'))
|
||||
->where($db->quoteName('name') . ' = ' . $db->quote($component));
|
||||
$db->setQuery($query);
|
||||
$assetId = (int) $db->loadResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the asset id of the content.
|
||||
// Note that for global configuration, com_config injects asset_id = 1 into the form.
|
||||
$assetId = $this->form->getValue($assetField);
|
||||
}
|
||||
|
||||
// Use the compact form for the content rules (deprecated).
|
||||
|
||||
/* @todo remove code:
|
||||
if (!empty($component) && $section != 'component') {
|
||||
return JHtml::_('rules.assetFormWidget', $actions, $assetId, $assetId ? null : $component, $this->name, $this->id);
|
||||
}
|
||||
*/
|
||||
|
||||
// Full width format.
|
||||
|
||||
// Get the rules for just this asset (non-recursive).
|
||||
$assetRules = JAccess::getAssetRules($assetId);
|
||||
|
||||
// Get the available user groups.
|
||||
$groups = $this->getUserGroups();
|
||||
|
||||
// Prepare output
|
||||
$html = array();
|
||||
|
||||
// Description
|
||||
$html[] = '<p class="rule-desc">' . JText::_('JLIB_RULES_SETTINGS_DESC') . '</p>';
|
||||
|
||||
// Begin tabs
|
||||
$html[] = '<div id="permissions-sliders" class="tabbable tabs-left">';
|
||||
|
||||
// Building tab nav
|
||||
$html[] = '<ul class="nav nav-tabs">';
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
// Initial Active Tab
|
||||
$active = "";
|
||||
if ($group->value == 1)
|
||||
{
|
||||
$active = "active";
|
||||
}
|
||||
|
||||
$html[] = '<li class="' . $active . '">';
|
||||
$html[] = '<a href="#permission-' . $group->value . '" data-toggle="tab">';
|
||||
$html[] = str_repeat('<span class="level">–</span> ', $curLevel = $group->level) . $group->text;
|
||||
$html[] = '</a>';
|
||||
$html[] = '</li>';
|
||||
}
|
||||
$html[] = '</ul>';
|
||||
|
||||
$html[] = '<div class="tab-content">';
|
||||
|
||||
// Start a row for each user group.
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
// Initial Active Pane
|
||||
$active = "";
|
||||
if ($group->value == 1)
|
||||
{
|
||||
$active = " active";
|
||||
}
|
||||
|
||||
$html[] = '<div class="tab-pane' . $active . '" id="permission-' . $group->value . '">';
|
||||
$html[] = '<table class="table table-striped">';
|
||||
$html[] = '<thead>';
|
||||
$html[] = '<tr>';
|
||||
|
||||
$html[] = '<th class="actions" id="actions-th' . $group->value . '">';
|
||||
$html[] = '<span class="acl-action">' . JText::_('JLIB_RULES_ACTION') . '</span>';
|
||||
$html[] = '</th>';
|
||||
|
||||
$html[] = '<th class="settings" id="settings-th' . $group->value . '">';
|
||||
$html[] = '<span class="acl-action">' . JText::_('JLIB_RULES_SELECT_SETTING') . '</span>';
|
||||
$html[] = '</th>';
|
||||
|
||||
// The calculated setting is not shown for the root group of global configuration.
|
||||
$canCalculateSettings = ($group->parent_id || !empty($component));
|
||||
if ($canCalculateSettings)
|
||||
{
|
||||
$html[] = '<th id="aclactionth' . $group->value . '">';
|
||||
$html[] = '<span class="acl-action">' . JText::_('JLIB_RULES_CALCULATED_SETTING') . '</span>';
|
||||
$html[] = '</th>';
|
||||
}
|
||||
|
||||
$html[] = '</tr>';
|
||||
$html[] = '</thead>';
|
||||
$html[] = '<tbody>';
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$html[] = '<tr>';
|
||||
$html[] = '<td headers="actions-th' . $group->value . '">';
|
||||
$html[] = '<label for="' . $this->id . '_' . $action->name . '_' . $group->value . '" class="hasTooltip" title="'
|
||||
. htmlspecialchars(JText::_($action->title) . ' ' . JText::_($action->description), ENT_COMPAT, 'UTF-8') . '">';
|
||||
$html[] = JText::_($action->title);
|
||||
$html[] = '</label>';
|
||||
$html[] = '</td>';
|
||||
|
||||
$html[] = '<td headers="settings-th' . $group->value . '">';
|
||||
|
||||
$html[] = '<select class="input-small" name="' . $this->name . '[' . $action->name . '][' . $group->value . ']" id="' . $this->id . '_' . $action->name
|
||||
. '_' . $group->value . '" title="'
|
||||
. JText::sprintf('JLIB_RULES_SELECT_ALLOW_DENY_GROUP', JText::_($action->title), trim($group->text)) . '">';
|
||||
|
||||
$inheritedRule = JAccess::checkGroup($group->value, $action->name, $assetId);
|
||||
|
||||
// Get the actual setting for the action for this group.
|
||||
$assetRule = $assetRules->allow($action->name, $group->value);
|
||||
|
||||
// Build the dropdowns for the permissions sliders
|
||||
|
||||
// The parent group has "Not Set", all children can rightly "Inherit" from that.
|
||||
$html[] = '<option value=""' . ($assetRule === null ? ' selected="selected"' : '') . '>'
|
||||
. JText::_(empty($group->parent_id) && empty($component) ? 'JLIB_RULES_NOT_SET' : 'JLIB_RULES_INHERITED') . '</option>';
|
||||
$html[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_ALLOWED')
|
||||
. '</option>';
|
||||
$html[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_DENIED')
|
||||
. '</option>';
|
||||
|
||||
$html[] = '</select>  ';
|
||||
|
||||
// If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
|
||||
if (($assetRule === true) && ($inheritedRule === false))
|
||||
{
|
||||
$html[] = JText::_('JLIB_RULES_CONFLICT');
|
||||
}
|
||||
|
||||
$html[] = '</td>';
|
||||
|
||||
// Build the Calculated Settings column.
|
||||
// The inherited settings column is not displayed for the root group in global configuration.
|
||||
if ($canCalculateSettings)
|
||||
{
|
||||
$html[] = '<td headers="aclactionth' . $group->value . '">';
|
||||
|
||||
// This is where we show the current effective settings considering currrent group, path and cascade.
|
||||
// Check whether this is a component or global. Change the text slightly.
|
||||
|
||||
if (JAccess::checkGroup($group->value, 'core.admin', $assetId) !== true)
|
||||
{
|
||||
if ($inheritedRule === null)
|
||||
{
|
||||
$html[] = '<span class="label label-important">' . JText::_('JLIB_RULES_NOT_ALLOWED') . '</span>';
|
||||
}
|
||||
elseif ($inheritedRule === true)
|
||||
{
|
||||
$html[] = '<span class="label label-success">' . JText::_('JLIB_RULES_ALLOWED') . '</span>';
|
||||
}
|
||||
elseif ($inheritedRule === false)
|
||||
{
|
||||
if ($assetRule === false)
|
||||
{
|
||||
$html[] = '<span class="label label-important">' . JText::_('JLIB_RULES_NOT_ALLOWED') . '</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$html[] = '<span class="label"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED')
|
||||
. '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (!empty($component))
|
||||
{
|
||||
$html[] = '<span class="label label-success"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
|
||||
. '</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Special handling for groups that have global admin because they can't be denied.
|
||||
// The admin rights can be changed.
|
||||
if ($action->name === 'core.admin')
|
||||
{
|
||||
$html[] = '<span class="label label-success">' . JText::_('JLIB_RULES_ALLOWED') . '</span>';
|
||||
}
|
||||
elseif ($inheritedRule === false)
|
||||
{
|
||||
// Other actions cannot be changed.
|
||||
$html[] = '<span class="label label-important"><i class="icon-lock icon-white"></i> '
|
||||
. JText::_('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$html[] = '<span class="label label-success"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
|
||||
. '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$html[] = '</td>';
|
||||
}
|
||||
|
||||
$html[] = '</tr>';
|
||||
}
|
||||
|
||||
$html[] = '</tbody>';
|
||||
$html[] = '</table></div>';
|
||||
|
||||
}
|
||||
|
||||
$html[] = '</div></div>';
|
||||
|
||||
$html[] = '<div class="alert">';
|
||||
if ($section == 'component' || $section == null)
|
||||
{
|
||||
$html[] = JText::_('JLIB_RULES_SETTING_NOTES');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html[] = JText::_('JLIB_RULES_SETTING_NOTES_ITEM');
|
||||
}
|
||||
$html[] = '</div>';
|
||||
|
||||
return implode("\n", $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the user groups.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getUserGroups()
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level, a.parent_id')
|
||||
->from('#__usergroups AS a')
|
||||
->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->group('a.id, a.title, a.lft, a.rgt, a.parent_id')
|
||||
->order('a.lft ASC');
|
||||
$db->setQuery($query);
|
||||
$options = $db->loadObjectList();
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
55
libraries/joomla/form/fields/sessionhandler.php
Normal file
55
libraries/joomla/form/fields/sessionhandler.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides a select list of session handler options.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldSessionHandler extends JFormFieldList
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'SessionHandler';
|
||||
|
||||
/**
|
||||
* Method to get the session handler field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Get the options from JSession.
|
||||
foreach (JSession::getStores() as $store)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $store, JText::_('JLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text');
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
108
libraries/joomla/form/fields/spacer.php
Normal file
108
libraries/joomla/form/fields/spacer.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides spacer markup to be used in form layouts.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldSpacer extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Spacer';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for a spacer.
|
||||
* The spacer does not have accept input.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field label markup for a spacer.
|
||||
* Use the label text or name from the XML element as the spacer or
|
||||
* Use a hr="true" to automatically generate plain hr markup
|
||||
*
|
||||
* @return string The field label markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
$html = array();
|
||||
$class = $this->element['class'] ? (string) $this->element['class'] : '';
|
||||
|
||||
$html[] = '<span class="spacer">';
|
||||
$html[] = '<span class="before"></span>';
|
||||
$html[] = '<span class="' . $class . '">';
|
||||
if ((string) $this->element['hr'] == 'true')
|
||||
{
|
||||
$html[] = '<hr class="' . $class . '" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$label = '';
|
||||
|
||||
// Get the label text from the XML element, defaulting to the element name.
|
||||
$text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
|
||||
$text = $this->translateLabel ? JText::_($text) : $text;
|
||||
|
||||
// Build the class for the label.
|
||||
$class = !empty($this->description) ? 'hasTooltip' : '';
|
||||
$class = $this->required == true ? $class . ' required' : $class;
|
||||
|
||||
// Add the opening label tag and main attributes attributes.
|
||||
$label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"';
|
||||
|
||||
// If a description is specified, use it to build a tooltip.
|
||||
if (!empty($this->description))
|
||||
{
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
$label .= ' title="' . JHtml::tooltipText(trim($text, ':'), JText::_($this->description), 0) . '"';
|
||||
}
|
||||
|
||||
// Add the label text and closing tag.
|
||||
$label .= '>' . $text . '</label>';
|
||||
$html[] = $label;
|
||||
}
|
||||
$html[] = '</span>';
|
||||
$html[] = '<span class="after"></span>';
|
||||
$html[] = '</span>';
|
||||
|
||||
return implode('', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field title.
|
||||
*
|
||||
* @return string The field title.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getTitle()
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
}
|
77
libraries/joomla/form/fields/sql.php
Normal file
77
libraries/joomla/form/fields/sql.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Supports an custom SQL select list
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldSQL extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'SQL';
|
||||
|
||||
/**
|
||||
* Method to get the custom field options.
|
||||
* Use the query attribute to supply a query to generate the list.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Initialize some field attributes.
|
||||
$key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
|
||||
$value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
|
||||
$translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
|
||||
$query = (string) $this->element['query'];
|
||||
|
||||
// Get the database object.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Set the query and get the result list.
|
||||
$db->setQuery($query);
|
||||
$items = $db->loadObjectlist();
|
||||
|
||||
// Build the field options.
|
||||
if (!empty($items))
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if ($translate == true)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $item->$key, JText::_($item->$value));
|
||||
}
|
||||
else
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $item->$key, $item->$value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
34
libraries/joomla/form/fields/tel.php
Normal file
34
libraries/joomla/form/fields/tel.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a text field telephone numbers.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.tel.html
|
||||
* @see JFormRuleTel for telephone number validation
|
||||
* @see JHtmlTel for rendering of telephone numbers
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldTel extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Tel';
|
||||
}
|
55
libraries/joomla/form/fields/text.php
Normal file
55
libraries/joomla/form/fields/text.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a one line text field.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldText extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Text';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
return '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $readonly . $onchange . $maxLength . $required . '/>';
|
||||
}
|
||||
}
|
54
libraries/joomla/form/fields/textarea.php
Normal file
54
libraries/joomla/form/fields/textarea.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a multi line area for entry of plain text
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/textarea.html#textarea
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldTextarea extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Textarea';
|
||||
|
||||
/**
|
||||
* Method to get the textarea field input markup.
|
||||
* Use the rows and columns attributes to specify the dimensions of the area.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$columns = $this->element['cols'] ? ' cols="' . (int) $this->element['cols'] . '"' : '';
|
||||
$rows = $this->element['rows'] ? ' rows="' . (int) $this->element['rows'] . '"' : '';
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
return '<textarea name="' . $this->name . '" id="' . $this->id . '"' . $columns . $rows . $class . $disabled . $onchange . $required . '>'
|
||||
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '</textarea>';
|
||||
}
|
||||
}
|
107
libraries/joomla/form/fields/timezone.php
Normal file
107
libraries/joomla/form/fields/timezone.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('groupedlist');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldTimezone extends JFormFieldGroupedList
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Timezone';
|
||||
|
||||
/**
|
||||
* The list of available timezone groups to use.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected static $zones = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
|
||||
|
||||
/**
|
||||
* Method to get the time zone field option groups.
|
||||
*
|
||||
* @return array The field option objects as a nested array in groups.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getGroups()
|
||||
{
|
||||
$groups = array();
|
||||
|
||||
$keyField = $this->element['key_field'] ? (string) $this->element['key_field'] : 'id';
|
||||
$keyValue = $this->form->getValue($keyField);
|
||||
|
||||
// If the timezone is not set use the server setting.
|
||||
if (strlen($this->value) == 0 && empty($keyValue))
|
||||
{
|
||||
$this->value = JFactory::getConfig()->get('offset');
|
||||
}
|
||||
|
||||
// Get the list of time zones from the server.
|
||||
$zones = DateTimeZone::listIdentifiers();
|
||||
|
||||
// Build the group lists.
|
||||
foreach ($zones as $zone)
|
||||
{
|
||||
|
||||
// Time zones not in a group we will ignore.
|
||||
if (strpos($zone, '/') === false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the group/locale from the timezone.
|
||||
list ($group, $locale) = explode('/', $zone, 2);
|
||||
|
||||
// Only use known groups.
|
||||
if (in_array($group, self::$zones))
|
||||
{
|
||||
|
||||
// Initialize the group if necessary.
|
||||
if (!isset($groups[$group]))
|
||||
{
|
||||
$groups[$group] = array();
|
||||
}
|
||||
|
||||
// Only add options where a locale exists.
|
||||
if (!empty($locale))
|
||||
{
|
||||
$groups[$group][$zone] = JHtml::_('select.option', $zone, str_replace('_', ' ', $locale), 'value', 'text', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the group lists.
|
||||
ksort($groups);
|
||||
foreach ($groups as &$location)
|
||||
{
|
||||
sort($location);
|
||||
}
|
||||
|
||||
// Merge any additional groups in the XML definition.
|
||||
$groups = array_merge(parent::getGroups(), $groups);
|
||||
|
||||
return $groups;
|
||||
}
|
||||
}
|
57
libraries/joomla/form/fields/url.php
Normal file
57
libraries/joomla/form/fields/url.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a URL text field
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @link http://www.w3.org/TR/html-markup/input.url.html#input.url
|
||||
* @see JFormRuleUrl for validation of full urls
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldUrl extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Url';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 3.1.2 (CMS)
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Initialize some field attributes.
|
||||
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
|
||||
$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
|
||||
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '" ' : '" ';
|
||||
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
|
||||
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$required = $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
return '<input type="url" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="'
|
||||
. JStringPunycode::urlToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $onchange . $maxLength . $required . '/>';
|
||||
}
|
||||
}
|
81
libraries/joomla/form/fields/usergroup.php
Normal file
81
libraries/joomla/form/fields/usergroup.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a nested check box field listing user groups.
|
||||
* Multiselect is available by default.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldUsergroup extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Usergroup';
|
||||
|
||||
/**
|
||||
* Method to get the user group field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$options = 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"' : '';
|
||||
$attr .= $this->required ? ' required="required" aria-required="true"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
|
||||
|
||||
// Iterate through the children and build an array of options.
|
||||
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;
|
||||
}
|
||||
|
||||
return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user