field.php 0000666 00000032055 15137260030 0006346 0 ustar 00 XML element that describes the form field.
*
* @var SimpleXMLElement
* @since 11.1
*/
protected $element;
/**
* The JForm object of the form attached to the form field.
*
* @var JForm
* @since 11.1
*/
protected $form;
/**
* The form control prefix for field names from the JForm object attached to the form field.
*
* @var string
* @since 11.1
*/
protected $formControl;
/**
* The hidden state for the form field.
*
* @var boolean
* @since 11.1
*/
protected $hidden = false;
/**
* True to translate the field label string.
*
* @var boolean
* @since 11.1
*/
protected $translateLabel = true;
/**
* True to translate the field description string.
*
* @var boolean
* @since 11.1
*/
protected $translateDescription = true;
/**
* The document id for the form field.
*
* @var string
* @since 11.1
*/
protected $id;
/**
* The input for the form field.
*
* @var string
* @since 11.1
*/
protected $input;
/**
* The label for the form field.
*
* @var string
* @since 11.1
*/
protected $label;
/**
* The multiple state for the form field. If true then multiple values are allowed for the
* field. Most often used for list field types.
*
* @var boolean
* @since 11.1
*/
protected $multiple = false;
/**
* The name of the form field.
*
* @var string
* @since 11.1
*/
protected $name;
/**
* The name of the field.
*
* @var string
* @since 11.1
*/
protected $fieldname;
/**
* The group of the field.
*
* @var string
* @since 11.1
*/
protected $group;
/**
* The required state for the form field. If true then there must be a value for the field to
* be considered valid.
*
* @var boolean
* @since 11.1
*/
protected $required = false;
/**
* The form field type.
*
* @var string
* @since 11.1
*/
protected $type;
/**
* The validation method for the form field. This value will determine which method is used
* to validate the value for a field.
*
* @var string
* @since 11.1
*/
protected $validate;
/**
* The value of the form field.
*
* @var mixed
* @since 11.1
*/
protected $value;
/**
* The label's CSS class of the form field
*
* @var mixed
* @since 11.1
*/
protected $labelClass;
/**
* The count value for generated name field
*
* @var integer
* @since 11.1
*/
protected static $count = 0;
/**
* The string used for generated fields names
*
* @var integer
* @since 11.1
*/
protected static $generated_fieldname = '__field';
/**
* Method to instantiate the form field object.
*
* @param object $form The form to attach to the form field object.
*
* @since 11.1
*/
public function __construct($form = null)
{
// If there is a form passed into the constructor set the form and form control properties.
if ($form instanceof JForm)
{
$this->form = $form;
$this->formControl = $form->getFormControl();
}
// Detect the field type if not set
if (!isset($this->type))
{
$parts = JString::splitCamelCase(get_class($this));
if ($parts[0] == 'J')
{
$this->type = JString::ucfirst($parts[count($parts) - 1], '_');
}
else
{
$this->type = JString::ucfirst($parts[0], '_') . JString::ucfirst($parts[count($parts) - 1], '_');
}
}
}
/**
* Method to get certain otherwise inaccessible properties from the form field object.
*
* @param string $name The property name for which to the the value.
*
* @return mixed The property value or null.
*
* @since 11.1
*/
public function __get($name)
{
switch ($name)
{
case 'class':
case 'description':
case 'formControl':
case 'hidden':
case 'id':
case 'multiple':
case 'name':
case 'required':
case 'type':
case 'validate':
case 'value':
case 'labelClass':
case 'fieldname':
case 'group':
return $this->$name;
break;
case 'input':
// If the input hasn't yet been generated, generate it.
if (empty($this->input))
{
$this->input = $this->getInput();
}
return $this->input;
break;
case 'label':
// If the label hasn't yet been generated, generate it.
if (empty($this->label))
{
$this->label = $this->getLabel();
}
return $this->label;
break;
case 'title':
return $this->getTitle();
break;
}
return null;
}
/**
* Method to attach a JForm object to the field.
*
* @param JForm $form The JForm object to attach to the form field.
*
* @return object The form field object so that the method can be used in a chain.
*
* @since 11.1
*/
public function setForm(JForm $form)
{
$this->form = $form;
$this->formControl = $form->getFormControl();
return $this;
}
/**
* Method to attach a JForm object to the field.
*
* @param object &$element The SimpleXMLElement object representing the tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @since 11.1
*/
public function setup(&$element, $value, $group = null)
{
// Make sure there is a valid JFormField XML element.
if (!($element instanceof SimpleXMLElement) || (string) $element->getName() != 'field')
{
return false;
}
// Reset the input and label values.
$this->input = null;
$this->label = null;
// Set the XML element object.
$this->element = $element;
// Get some important attributes from the form field element.
$class = (string) $element['class'];
$id = (string) $element['id'];
$multiple = (string) $element['multiple'];
$name = (string) $element['name'];
$required = (string) $element['required'];
// Set the required and validation options.
$this->required = ($required == 'true' || $required == 'required' || $required == '1');
$this->validate = (string) $element['validate'];
// Add the required class if the field is required.
if ($this->required)
{
if ($class)
{
if (strpos($class, 'required') === false)
{
$this->element['class'] = $class . ' required';
}
}
else
{
$this->element->addAttribute('class', 'required');
}
}
// Set the multiple values option.
$this->multiple = ($multiple == 'true' || $multiple == 'multiple');
// Allow for field classes to force the multiple values option.
if (isset($this->forceMultiple))
{
$this->multiple = (bool) $this->forceMultiple;
}
// Set the field description text.
$this->description = (string) $element['description'];
// Set the visibility.
$this->hidden = ((string) $element['type'] == 'hidden' || (string) $element['hidden'] == 'true');
// Determine whether to translate the field label and/or description.
$this->translateLabel = !((string) $this->element['translate_label'] == 'false' || (string) $this->element['translate_label'] == '0');
$this->translateDescription = !((string) $this->element['translate_description'] == 'false'
|| (string) $this->element['translate_description'] == '0');
// Set the group of the field.
$this->group = $group;
// Set the field name and id.
$this->fieldname = $this->getFieldName($name);
$this->name = $this->getName($this->fieldname);
$this->id = $this->getId($id, $this->fieldname);
// Set the field default value.
$this->value = $value;
// Set the CSS class of field label
$this->labelClass = (string) $element['labelclass'];
return true;
}
/**
* Method to get the id used for the field input tag.
*
* @param string $fieldId The field element id.
* @param string $fieldName The field element name.
*
* @return string The id to be used for the field input tag.
*
* @since 11.1
*/
protected function getId($fieldId, $fieldName)
{
// Initialise variables.
$id = '';
// If there is a form control set for the attached form add it first.
if ($this->formControl)
{
$id .= $this->formControl;
}
// If the field is in a group add the group control to the field id.
if ($this->group)
{
// If we already have an id segment add the group control as another level.
if ($id)
{
$id .= '_' . str_replace('.', '_', $this->group);
}
else
{
$id .= str_replace('.', '_', $this->group);
}
}
// If we already have an id segment add the field id/name as another level.
if ($id)
{
$id .= '_' . ($fieldId ? $fieldId : $fieldName);
}
else
{
$id .= ($fieldId ? $fieldId : $fieldName);
}
// Clean up any invalid characters.
$id = preg_replace('#\W#', '_', $id);
return $id;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 11.1
*/
abstract protected function getInput();
/**
* Method to get the field title.
*
* @return string The field title.
*
* @since 11.1
*/
protected function getTitle()
{
// Initialise variables.
$title = '';
if ($this->hidden)
{
return $title;
}
// Get the label text from the XML element, defaulting to the element name.
$title = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
$title = $this->translateLabel ? JText::_($title) : $title;
return $title;
}
/**
* Method to get the field label markup.
*
* @return string The field label markup.
*
* @since 11.1
*/
protected function getLabel()
{
// Initialise variables.
$label = '';
if ($this->hidden)
{
return $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) ? 'hasTip' : '';
$class = $this->required == true ? $class . ' required' : $class;
$class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class;
// Add the opening label tag and main attributes attributes.
$label .= '';
}
else
{
$label .= '>' . $text . '';
}
return $label;
}
/**
* Method to get the name used for the field input tag.
*
* @param string $fieldName The field element name.
*
* @return string The name to be used for the field input tag.
*
* @since 11.1
*/
protected function getName($fieldName)
{
// Initialise variables.
$name = '';
// If there is a form control set for the attached form add it first.
if ($this->formControl)
{
$name .= $this->formControl;
}
// If the field is in a group add the group control to the field name.
if ($this->group)
{
// If we already have a name segment add the group control as another level.
$groups = explode('.', $this->group);
if ($name)
{
foreach ($groups as $group)
{
$name .= '[' . $group . ']';
}
}
else
{
$name .= array_shift($groups);
foreach ($groups as $group)
{
$name .= '[' . $group . ']';
}
}
}
// If we already have a name segment add the field name as another level.
if ($name)
{
$name .= '[' . $fieldName . ']';
}
else
{
$name .= $fieldName;
}
// If the field should support multiple values add the final array segment.
if ($this->multiple)
{
$name .= '[]';
}
return $name;
}
/**
* Method to get the field name used.
*
* @param string $fieldName The field element name.
*
* @return string The field name
*
* @since 11.1
*/
protected function getFieldName($fieldName)
{
if ($fieldName)
{
return $fieldName;
}
else
{
self::$count = self::$count + 1;
return self::$generated_fieldname . self::$count;
}
}
}
fields/folderlist.php 0000666 00000004346 15137260030 0010702 0 ustar 00 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;
}
}
fields/menuitem.php 0000666 00000004531 15137260030 0010352 0 ustar 00 element['menu_type'];
$published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
$disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
$language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language);
// Build group for a specific menu type.
if ($menuType)
{
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link)
{
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
// Build groups for all menu types.
else
{
// Build the groups arrays.
foreach ($items as $menu)
{
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link)
{
$groups[$menu->menutype][] = JHtml::_(
'select.option', $link->value, $link->text, 'value', 'text',
in_array($link->type, $disable)
);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
fields/textarea.php 0000666 00000003234 15137260030 0010343 0 ustar 00 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'] . '"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
return '';
}
}
fields/text.php 0000666 00000003441 15137260030 0007512 0 ustar 00 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'] . '"' : '';
$auto = ((string) $this->element['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
return '';
}
}
fields/spacer.php 0000666 00000005275 15137260030 0010012 0 ustar 00 element['class'] ? (string) $this->element['class'] : '';
$html[] = '';
$html[] = '';
$html[] = '';
if ((string) $this->element['hr'] == 'true')
{
$html[] = '';
}
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) ? 'hasTip' : '';
$class = $this->required == true ? $class . ' required' : $class;
// Add the opening label tag and main attributes attributes.
$label .= '';
$html[] = $label;
}
$html[] = '';
$html[] = '';
$html[] = '';
return implode('', $html);
}
/**
* Method to get the field title.
*
* @return string The field title.
*
* @since 11.1
*/
protected function getTitle()
{
return $this->getLabel();
}
}
fields/calendar.php 0000666 00000005526 15137260030 0010305 0 ustar 00 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'];
}
// 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 (intval($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 (intval($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);
}
}
fields/file.php 0000666 00000003345 15137260030 0007450 0 ustar 00 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"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
return '';
}
}
fields/rules.php 0000666 00000025165 15137260030 0007667 0 ustar 00 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);
$query->select($db->quoteName('id'));
$query->from($db->quoteName('#__assets'));
$query->where($db->quoteName('name') . ' = ' . $db->quote($component));
$db->setQuery($query);
$assetId = (int) $db->loadResult();
if ($error = $db->getErrorMsg())
{
JError::raiseNotice(500, $error);
}
}
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).
//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();
// Build the form control.
$curLevel = 0;
// Prepare output
$html = array();
$html[] = '
';
$html[] = '
' . JText::_('JLIB_RULES_SETTINGS_DESC') . '
';
$html[] = '
';
// Start a row for each user group.
foreach ($groups as $group)
{
$difLevel = $group->level - $curLevel;
if ($difLevel > 0)
{
$html[] = '
';
// The calculated setting is not shown for the root group of global configuration.
$canCalculateSettings = ($group->parent_id || !empty($component));
if ($canCalculateSettings)
{
$html[] = '
';
$html[] = ' ';
// 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[] = '
';
// Build the Calculated Settings column.
// The inherited settings column is not displayed for the root group in global configuration.
if ($canCalculateSettings)
{
$html[] = '
';
// 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[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . '';
}
elseif ($inheritedRule === true)
{
$html[] = '' . JText::_('JLIB_RULES_ALLOWED') . '';
}
elseif ($inheritedRule === false)
{
if ($assetRule === false)
{
$html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED') . '';
}
else
{
$html[] = '' . JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED')
. '';
}
}
}
elseif (!empty($component))
{
$html[] = '' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
. '';
}
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[] = '' . JText::_('JLIB_RULES_ALLOWED') . '';
}
elseif ($inheritedRule === false)
{
// Other actions cannot be changed.
$html[] = ''
. JText::_('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '';
}
else
{
$html[] = '' . JText::_('JLIB_RULES_ALLOWED_ADMIN')
. '';
}
}
$html[] = '
';
}
return implode("\n", $html);
}
}
fields/editors.php 0000666 00000004066 15137260030 0010203 0 ustar 00 getQuery(true);
// Build the query.
$query->select('element AS value, name AS text');
$query->from('#__extensions');
$query->where('folder = ' . $db->quote('editors'));
$query->where('enabled = 1');
$query->order('ordering, name');
// Set the query and load the options.
$db->setQuery($query);
$options = $db->loadObjectList();
$lang = JFactory::getLanguage();
foreach ($options as $i => $option)
{
$lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, null, false, true);
$options[$i]->text = JText::_($option->text);
}
// Check for a database error.
if ($db->getErrorNum())
{
JError::raiseWarning(500, $db->getErrorMsg());
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
fields/list.php 0000666 00000006104 15137260030 0007500 0 ustar 00 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"' : '';
// 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[] = '';
}
// 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()
{
// Initialize variables.
$options = array();
foreach ($this->element->children() as $option)
{
// Only add elements.
if ($option->getName() != 'option')
{
continue;
}
// Create a new option object based on the 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;
}
}
fields/category.php 0000666 00000007300 15137260030 0010341 0 ustar 00 element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope'];
$published = (string) $this->element['published'];
$name = (string) $this->element['name'];
// Load the category options for a given extension.
if (!empty($extension))
{
// Filter over published state or not depending upon if it is present.
if ($published)
{
$options = JHtml::_('category.options', $extension, array('filter.published' => explode(',', $published)));
}
else
{
$options = JHtml::_('category.options', $extension);
}
// Verify permissions. If the action attribute is set, then we scan the options.
if ((string) $this->element['action'])
{
// Get the current user object.
$user = JFactory::getUser();
// For new items we want a list of categories you are allowed to create in.
if (!$this->form->getValue($name))
{
foreach ($options as $i => $option) {
// To take save or create in a category you need to have create rights for that category
// unless the item is already in that category.
// Unset the option if the user isn't authorised for it. In this field assets are always categories.
if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true )
{
unset($options[$i]);
}
}
}
// If you have an existing category id things are more complex.
else
{
$categoryOld = $this->form->getValue($name);
foreach ($options as $i => $option)
{
// If you are only allowed to edit in this category but not edit.state, you should not get any
// option to change the category.
if ($user->authorise('core.edit.state', $extension . '.category.' . $categoryOld) != true)
{
if ($option->value != $categoryOld)
{
unset($options[$i]);
}
}
// However, if you can edit.state you can also move this to another category for which you have
// create permission and you should also still be able to save in the current category.
elseif
(($user->authorise('core.create', $extension . '.category.' . $option->value) != true)
&& $option->value != $categoryOld)
{
unset($options[$i]);
}
}
}
}
if (isset($this->element['show_root']))
{
array_unshift($options, JHtml::_('select.option', '0', JText::_('JGLOBAL_ROOT')));
}
}
else
{
JError::raiseWarning(500, JText::_('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY'));
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
fields/databaseconnection.php 0000666 00000004034 15137260030 0012351 0 ustar 00 element['supported'];
if (!empty($supported))
{
$supported = explode(',', $supported);
foreach ($supported as $support)
{
if (in_array($support, $available))
{
$options[$support] = ucfirst($support);
}
}
}
else
{
foreach ($available as $support)
{
$options[$support] = 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;
}
}
fields/.htaccess 0000666 00000000177 15137260030 0007616 0 ustar 00
Order allow,deny
Deny from all