Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
AuthorField.php000064400000003036151157547730007504 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Form Field to load a list of content authors
*
* @since 3.2
*/
class AuthorField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
public $type = 'Author';
/**
* Cached array of the category items.
*
* @var array
* @since 3.2
*/
protected static $options = array();
/**
* Method to get the options to populate list
*
* @return array The field option objects.
*
* @since 3.2
*/
protected function getOptions()
{
// Accepted modifiers
$hash = md5($this->element);
if (!isset(static::$options[$hash]))
{
static::$options[$hash] = parent::getOptions();
$db = Factory::getDbo();
// Construct the query
$query = $db->getQuery(true)
->select('u.id AS value, u.name AS text')
->from('#__users AS u')
->join('INNER', '#__content AS c ON c.created_by =
u.id')
->group('u.id, u.name')
->order('u.name');
// Setup the query
$db->setQuery($query);
// Return the result
if ($options = $db->loadObjectList())
{
static::$options[$hash] = array_merge(static::$options[$hash],
$options);
}
}
return static::$options[$hash];
}
}
CaptchaField.php000064400000010245151157547730007605 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Captcha\Captcha;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
/**
* Captcha field.
*
* @since 2.5
*/
class CaptchaField extends FormField
{
/**
* The field type.
*
* @var string
* @since 2.5
*/
protected $type = 'Captcha';
/**
* The captcha base instance of our type.
*
* @var Captcha
*/
protected $_captcha;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'plugin':
case 'namespace':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'plugin':
case 'namespace':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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 2.5
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
$app = Factory::getApplication();
$default = $app->get('captcha');
if ($app->isClient('site'))
{
$default = $app->getParams()->get('captcha', $default);
}
$plugin = $this->element['plugin'] ?
(string) $this->element['plugin'] :
$default;
$this->plugin = $plugin;
if ($plugin === 0 || $plugin === '0' || $plugin ===
'' || $plugin === null)
{
$this->hidden = true;
return false;
}
else
{
// Force field to be required. There's no reason to have a captcha
if it is not required.
// Obs: Don't put required="required" in the xml file,
you just need to have validate="captcha"
$this->required = true;
if (strpos($this->class, 'required') === false)
{
$this->class .= ' required';
}
}
$this->namespace = $this->element['namespace'] ? (string)
$this->element['namespace'] : $this->form->getName();
try
{
// Get an instance of the captcha class that we are using
$this->_captcha = Captcha::getInstance($this->plugin,
array('namespace' => $this->namespace));
/**
* Give the captcha instance a possibility to react on the
setup-process,
* e.g. by altering the XML structure of the field, for example hiding
the label
* when using invisible captchas.
*/
$this->_captcha->setupField($this, $element);
}
catch (\RuntimeException $e)
{
$this->_captcha = null;
\JFactory::getApplication()->enqueueMessage($e->getMessage(),
'error');
return false;
}
return $result;
}
/**
* Method to get the field input.
*
* @return string The field input.
*
* @since 2.5
*/
protected function getInput()
{
if ($this->hidden || $this->_captcha == null)
{
return '';
}
try
{
return $this->_captcha->display($this->name, $this->id,
$this->class);
}
catch (\RuntimeException $e)
{
\JFactory::getApplication()->enqueueMessage($e->getMessage(),
'error');
}
return '';
}
}
ChromestyleField.php000064400000013105151157547730010536 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('groupedlist');
/**
* Chrome Styles field.
*
* @since 3.0
*/
class ChromestyleField extends \JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 3.0
*/
public $type = 'ChromeStyle';
/**
* The client ID.
*
* @var integer
* @since 3.2
*/
protected $clientId;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'clientId':
return $this->clientId;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to get the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'clientId':
$this->clientId = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
// Get the client id.
$clientId = $this->element['client_id'];
if (!isset($clientId))
{
$clientName = $this->element['client'];
if (isset($clientName))
{
$client = \JApplicationHelper::getClientInfo($clientName, true);
$clientId = $client->id;
}
}
if (!isset($clientId) && $this->form instanceof \JForm)
{
$clientId = $this->form->getValue('client_id');
}
$this->clientId = (int) $clientId;
}
return $result;
}
/**
* Method to get the list of template chrome style options
* grouped by template.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.0
*/
protected function getGroups()
{
$groups = array();
// Add Module Style Field
$tmp = '---' .
\JText::_('JLIB_FORM_VALUE_FROM_TEMPLATE') . '---';
$groups[$tmp][] = \JHtml::_('select.option', '0',
\JText::_('JLIB_FORM_VALUE_INHERITED'));
$templateStyles = $this->getTemplateModuleStyles();
// Create one new option object for each available style, grouped by
templates
foreach ($templateStyles as $template => $styles)
{
$template = ucfirst($template);
$groups[$template] = array();
foreach ($styles as $style)
{
$tmp = \JHtml::_('select.option', $template . '-' .
$style, $style);
$groups[$template][] = $tmp;
}
}
reset($groups);
return $groups;
}
/**
* Method to get the templates module styles.
*
* @return array The array of styles, grouped by templates.
*
* @since 3.0
*/
protected function getTemplateModuleStyles()
{
$moduleStyles = array();
$templates = array($this->getSystemTemplate());
$templates = array_merge($templates, $this->getTemplates());
$path = JPATH_ADMINISTRATOR;
if ($this->clientId === 0)
{
$path = JPATH_SITE;
}
foreach ($templates as $template)
{
$modulesFilePath = $path . '/templates/' .
$template->element . '/html/modules.php';
// Is there modules.php for that template?
if (file_exists($modulesFilePath))
{
$modulesFileData = file_get_contents($modulesFilePath);
preg_match_all('/function[\s\t]*modChrome\_([a-z0-9\-\_]*)[\s\t]*\(/i',
$modulesFileData, $styles);
if (!array_key_exists($template->element, $moduleStyles))
{
$moduleStyles[$template->element] = array();
}
$moduleStyles[$template->element] = $styles[1];
}
}
return $moduleStyles;
}
/**
* Method to get the system template as an object.
*
* @return \stdClass The object of system template.
*
* @since 3.0
*/
protected function getSystemTemplate()
{
$template = new \stdClass;
$template->element = 'system';
$template->name = 'system';
return $template;
}
/**
* Return a list of templates
*
* @return array List of templates
*
* @since 3.2.1
*/
protected function getTemplates()
{
$db = Factory::getDbo();
// Get the database object and a new query object.
$query = $db->getQuery(true);
// Build the query.
$query->select('element, name')
->from('#__extensions')
->where('client_id = ' . $this->clientId)
->where('type = ' . $db->quote('template'))
->where('enabled = 1');
// Set the query and load the templates.
$db->setQuery($query);
return $db->loadObjectList('element');
}
}
ContenthistoryField.php000064400000003626151157547730011303
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Table\Table;
/**
* Field to select Content History from a modal list.
*
* @since 3.2
*/
class ContenthistoryField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
public $type = 'ContentHistory';
/**
* Layout to render the label
*
* @var string
*/
protected $layout = 'joomla.form.field.contenthistory';
/**
* Get the data that is going to be passed to the layout
*
* @return array
*/
public function getLayoutData()
{
// Get the basic field data
$data = parent::getLayoutData();
$typeId =
Table::getInstance('Contenttype')->getTypeId($this->element['data-typeAlias']);
$itemId = $this->form->getValue('id');
$label = \JText::_('JTOOLBAR_VERSIONS');
$link =
'index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&field='
. $this->id . '&item_id=' . $itemId .
'&type_id=' . $typeId . '&type_alias='
. $this->element['data-typeAlias'] . '&'
. Session::getFormToken() . '=1';
$extraData = array(
'type' => $typeId,
'item' => $itemId,
'label' => $label,
'link' => $link,
);
return array_merge($data, $extraData);
}
/**
* Method to get the content history field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
if (empty($this->layout))
{
throw new \UnexpectedValueException(sprintf('%s has no layout
assigned.', $this->name));
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
}
ContentlanguageField.php000064400000001655151157547730011365
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Provides a list of content languages
*
* @see JFormFieldLanguage for a select list of application languages.
* @since 1.6
*/
class ContentlanguageField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'ContentLanguage';
/**
* Method to get the field options for content languages.
*
* @return array The options the field is going to show.
*
* @since 1.6
*/
protected function getOptions()
{
return array_merge(parent::getOptions(),
\JHtml::_('contentlanguage.existing'));
}
}
ContenttypeField.php000064400000004432151157547730010557 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Content Type field.
*
* @since 3.1
*/
class ContenttypeField extends \JFormFieldList
{
/**
* A flexible tag list that respects access controls
*
* @var string
* @since 3.1
*/
public $type = 'Contenttype';
/**
* Method to get the field input for a list of content types.
*
* @return string The field input.
*
* @since 3.1
*/
protected function getInput()
{
if (!is_array($this->value))
{
if (is_object($this->value))
{
$this->value = $this->value->tags;
}
if (is_string($this->value))
{
$this->value = explode(',', $this->value);
}
}
return parent::getInput();
}
/**
* Method to get a list of content types
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$lang = Factory::getLanguage();
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('a.type_id AS value, a.type_title AS text, a.type_alias
AS alias')
->from('#__content_types AS a')
->order('a.type_title ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (\RuntimeException $e)
{
return array();
}
foreach ($options as $option)
{
// Make up the string from the component sys.ini file
$parts = explode('.', $option->alias);
$comp = array_shift($parts);
// Make sure the component sys.ini is loaded
$lang->load($comp . '.sys', JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load($comp . '.sys', JPATH_ADMINISTRATOR .
'/components/' . $comp, null, false, true);
$option->string = implode('_', $parts);
$option->string = $comp . '_CONTENT_TYPE_' .
$option->string;
if ($lang->hasKey($option->string))
{
$option->text = \JText::_($option->string);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}
EditorField.php000064400000017033151157547730007472 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Editor\Editor;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('textarea');
/**
* A textarea field for content creation
*
* @see JEditor
* @since 1.6
*/
class EditorField extends \JFormFieldTextarea
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'Editor';
/**
* The Editor object.
*
* @var Editor
* @since 1.6
*/
protected $editor;
/**
* The height of the editor.
*
* @var string
* @since 3.2
*/
protected $height;
/**
* The width of the editor.
*
* @var string
* @since 3.2
*/
protected $width;
/**
* The assetField of the editor.
*
* @var string
* @since 3.2
*/
protected $assetField;
/**
* The authorField of the editor.
*
* @var string
* @since 3.2
*/
protected $authorField;
/**
* The asset of the editor.
*
* @var string
* @since 3.2
*/
protected $asset;
/**
* The buttons of the editor.
*
* @var mixed
* @since 3.2
*/
protected $buttons;
/**
* The hide of the editor.
*
* @var array
* @since 3.2
*/
protected $hide;
/**
* The editorType of the editor.
*
* @var array
* @since 3.2
*/
protected $editorType;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'height':
case 'width':
case 'assetField':
case 'authorField':
case 'asset':
case 'buttons':
case 'hide':
case 'editorType':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'height':
case 'width':
case 'assetField':
case 'authorField':
case 'asset':
$this->$name = (string) $value;
break;
case 'buttons':
$value = (string) $value;
if ($value === 'true' || $value === 'yes' || $value
=== '1')
{
$this->buttons = true;
}
elseif ($value === 'false' || $value === 'no' ||
$value === '0')
{
$this->buttons = false;
}
else
{
$this->buttons = explode(',', $value);
}
break;
case 'hide':
$value = (string) $value;
$this->hide = $value ? explode(',', $value) : array();
break;
case 'editorType':
// Can be in the form of: editor="desired|alternative".
$this->editorType = explode('|', trim((string) $value));
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
$this->height = $this->element['height'] ? (string)
$this->element['height'] : '500';
$this->width = $this->element['width'] ? (string)
$this->element['width'] : '100%';
$this->assetField = $this->element['asset_field'] ?
(string) $this->element['asset_field'] : 'asset_id';
$this->authorField = $this->element['created_by_field']
? (string) $this->element['created_by_field'] :
'created_by';
$this->asset =
$this->form->getValue($this->assetField) ?: (string)
$this->element['asset_id'];
$buttons = (string) $this->element['buttons'];
$hide = (string) $this->element['hide'];
$editorType = (string) $this->element['editor'];
if ($buttons === 'true' || $buttons === 'yes' ||
$buttons === '1')
{
$this->buttons = true;
}
elseif ($buttons === 'false' || $buttons === 'no' ||
$buttons === '0')
{
$this->buttons = false;
}
else
{
$this->buttons = !empty($hide) ? explode(',', $buttons) :
array();
}
$this->hide = !empty($hide) ? explode(',', (string)
$this->element['hide']) : array();
$this->editorType = !empty($editorType) ? explode('|',
trim($editorType)) : array();
}
return $result;
}
/**
* Method to get the field input markup for the editor area
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
// Get an editor object.
$editor = $this->getEditor();
$params = array(
'autofocus' => $this->autofocus,
'readonly' => $this->readonly || $this->disabled,
'syntax' => (string)
$this->element['syntax'],
);
return $editor->display(
$this->name,
htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'),
$this->width,
$this->height,
$this->columns,
$this->rows,
$this->buttons ? (is_array($this->buttons) ?
array_merge($this->buttons, $this->hide) : $this->hide) : false,
$this->id,
$this->asset,
$this->form->getValue($this->authorField),
$params
);
}
/**
* Method to get an Editor object based on the form field.
*
* @return Editor The Editor object.
*
* @since 1.6
*/
protected function getEditor()
{
// Only create the editor if it is not already created.
if (empty($this->editor))
{
$editor = null;
if ($this->editorType)
{
// Get the list of editor types.
$types = $this->editorType;
// Get the database object.
$db = Factory::getDbo();
// Iterate over the types looking for an existing editor.
foreach ($types as $element)
{
// Build the query.
$query = $db->getQuery(true)
->select('element')
->from('#__extensions')
->where('element = ' . $db->quote($element))
->where('folder = ' .
$db->quote('editors'))
->where('enabled = 1');
// Check of the editor exists.
$db->setQuery($query, 0, 1);
$editor = $db->loadResult();
// If an editor was found stop looking.
if ($editor)
{
break;
}
}
}
// Create the JEditor instance based on the given editor.
if ($editor === null)
{
$editor = Factory::getConfig()->get('editor');
}
$this->editor = Editor::getInstance($editor);
}
return $this->editor;
}
/**
* Method to get the JEditor output for an onSave event.
*
* @return string The JEditor object output.
*
* @since 1.6
* @deprecated 4.0 Will be removed without replacement
* @see Editor::save()
*/
public function save()
{
$editor = $this->getEditor();
if (!method_exists($editor, 'save'))
{
return '';
}
return $editor->save($this->id);
}
}
FrontendlanguageField.php000064400000003730151157547730011526
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Provides a list of published content languages with home pages
*
* @see JFormFieldLanguage for a select list of application languages.
* @since 3.5
*/
class FrontendlanguageField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
public $type = 'Frontend_Language';
/**
* Method to get the field options for frontend published content
languages with homes.
*
* @return array The options the field is going to show.
*
* @since 3.5
*/
protected function getOptions()
{
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('a.lang_code AS value, a.title AS text')
->from($db->quoteName('#__languages') . ' AS
a')
->where('a.published = 1')
->order('a.title');
// Select the language home pages.
$query->select('l.home, l.language')
->innerJoin($db->quoteName('#__menu') . ' AS l ON
l.language=a.lang_code AND l.home=1 AND l.published=1 AND l.language
<> ' . $db->quote('*'))
->innerJoin($db->quoteName('#__extensions') . ' AS
e ON e.element = a.lang_code')
->where('e.client_id = 0')
->where('e.enabled = 1')
->where('e.state = 0');
$db->setQuery($query);
try
{
$languages = $db->loadObjectList();
}
catch (\RuntimeException $e)
{
$languages = array();
if (Factory::getUser()->authorise('core.admin'))
{
Factory::getApplication()->enqueueMessage($e->getMessage(),
'error');
}
}
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(), $languages);
}
}
HeadertagField.php000064400000001775151157547730010136 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla! CMS.
*
* @since 3.0
*/
class HeadertagField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.0
*/
protected $type = 'HeaderTag';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.0
*/
protected function getOptions()
{
$options = array();
$tags = array('h1', 'h2', 'h3',
'h4', 'h5', 'h6', 'p',
'div');
// Create one new option object for each tag
foreach ($tags as $tag)
{
$tmp = \JHtml::_('select.option', $tag, $tag);
$options[] = $tmp;
}
reset($options);
return $options;
}
}
HelpsiteField.php000064400000003265151157547730010023 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Help\Help;
FormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Platform.
* Provides a select list of help sites.
*
* @since 1.6
* @deprecated 4.0 To be removed
*/
class HelpsiteField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'Helpsite';
/**
* Method to get the help site field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
protected function getOptions()
{
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(),
Help::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml',
$this->value));
return $options;
}
/**
* Override to add refresh button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
\JHtml::_('script', 'system/helpsite.js',
array('version' => 'auto', 'relative'
=> true));
$showDefault = (string) $this->getAttribute('showDefault')
=== 'false' ? 'false' : 'true';
$html = parent::getInput();
$button = '<button
type="button"
class="btn btn-small"
id="helpsite-refresh"
rel="' . $this->id . '"
showDefault="' . $showDefault . '"
>
<span>' . \JText::_('JGLOBAL_HELPREFRESH_BUTTON')
. '</span>
</button>';
return $html . $button;
}
}
LastvisitdaterangeField.php000064400000002763151157547730012105
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Field to show a list of available date ranges to filter on last visit
date.
*
* @since 3.6
*/
class LastvisitdaterangeField extends \JFormFieldPredefinedList
{
/**
* Method to instantiate the form field object.
*
* @param Form $form The form to attach to the form field object.
*
* @since 1.7.0
*/
public function __construct($form = null)
{
parent::__construct($form);
// Set the type
$this->type = 'LastvisitDateRange';
// Load the required language
$lang = Factory::getLanguage();
$lang->load('com_users', JPATH_ADMINISTRATOR);
// Set the pre-defined options
$this->predefinedOptions = array(
'today' => 'COM_USERS_OPTION_RANGE_TODAY',
'past_week' =>
'COM_USERS_OPTION_RANGE_PAST_WEEK',
'past_1month' =>
'COM_USERS_OPTION_RANGE_PAST_1MONTH',
'past_3month' =>
'COM_USERS_OPTION_RANGE_PAST_3MONTH',
'past_6month' =>
'COM_USERS_OPTION_RANGE_PAST_6MONTH',
'past_year' =>
'COM_USERS_OPTION_RANGE_PAST_YEAR',
'post_year' =>
'COM_USERS_OPTION_RANGE_POST_YEAR',
'never' => 'COM_USERS_OPTION_RANGE_NEVER',
);
}
}
LimitboxField.php000064400000004374151157547730010037 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Field to load a list of posible item count limits
*
* @since 3.2
*/
class LimitboxField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
public $type = 'Limitbox';
/**
* Cached array of the category items.
*
* @var array
* @since 3.2
*/
protected static $options = array();
/**
* Default options
*
* @var array
*/
protected $defaultLimits = array(5, 10, 15, 20, 25, 30, 50, 100, 200,
500);
/**
* Method to get the options to populate to populate list
*
* @return array The field option objects.
*
* @since 3.2
*/
protected function getOptions()
{
// Accepted modifiers
$hash = md5($this->element->asXML());
if (!isset(static::$options[$hash]))
{
static::$options[$hash] = parent::getOptions();
$options = array();
$limits = $this->defaultLimits;
// Limits manually specified
if (isset($this->element['limits']))
{
$limits = explode(',',
$this->element['limits']);
}
// User wants to add custom limits
if (isset($this->element['append']))
{
$limits = array_unique(array_merge($limits, explode(',',
$this->element['append'])));
}
// User wants to remove some default limits
if (isset($this->element['remove']))
{
$limits = array_diff($limits, explode(',',
$this->element['remove']));
}
// Order the options
asort($limits);
// Add an option to show all?
$showAll = isset($this->element['showall']) ? (string)
$this->element['showall'] === 'true' : true;
if ($showAll)
{
$limits[] = 0;
}
if (!empty($limits))
{
foreach ($limits as $value)
{
$options[] = (object) array(
'value' => $value,
'text' => ($value != 0) ? \JText::_('J' .
$value) : \JText::_('JALL'),
);
}
static::$options[$hash] = array_merge(static::$options[$hash],
$options);
}
}
return static::$options[$hash];
}
}
MediaField.php000064400000014222151157547730007260 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Form\FormField;
/**
* Provides a modal media selector including upload mechanism
*
* @since 1.6
*/
class MediaField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Media';
/**
* The authorField.
*
* @var string
* @since 3.2
*/
protected $authorField;
/**
* The asset.
*
* @var string
* @since 3.2
*/
protected $asset;
/**
* The link.
*
* @var string
* @since 3.2
*/
protected $link;
/**
* Modal width.
*
* @var integer
* @since 3.4.5
*/
protected $width;
/**
* Modal height.
*
* @var integer
* @since 3.4.5
*/
protected $height;
/**
* The authorField.
*
* @var string
* @since 3.2
*/
protected $preview;
/**
* The preview.
*
* @var string
* @since 3.2
*/
protected $directory;
/**
* The previewWidth.
*
* @var int
* @since 3.2
*/
protected $previewWidth;
/**
* The previewHeight.
*
* @var int
* @since 3.2
*/
protected $previewHeight;
/**
* Layout to render
*
* @var string
* @since 3.5
*/
protected $layout = 'joomla.form.field.media';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'authorField':
case 'asset':
case 'link':
case 'width':
case 'height':
case 'preview':
case 'directory':
case 'previewWidth':
case 'previewHeight':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'authorField':
case 'asset':
case 'link':
case 'width':
case 'height':
case 'preview':
case 'directory':
$this->$name = (string) $value;
break;
case 'previewWidth':
case 'previewHeight':
$this->$name = (int) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
$assetField = $this->element['asset_field'] ? (string)
$this->element['asset_field'] : 'asset_id';
$this->authorField =
$this->element['created_by_field'] ? (string)
$this->element['created_by_field'] : 'created_by';
$this->asset = $this->form->getValue($assetField) ?:
(string) $this->element['asset_id'];
$this->link = (string) $this->element['link'];
$this->width = isset($this->element['width']) ?
(int) $this->element['width'] : 800;
$this->height = isset($this->element['height']) ?
(int) $this->element['height'] : 500;
$this->preview = (string)
$this->element['preview'];
$this->directory = (string)
$this->element['directory'];
$this->previewWidth =
isset($this->element['preview_width']) ? (int)
$this->element['preview_width'] : 200;
$this->previewHeight =
isset($this->element['preview_height']) ? (int)
$this->element['preview_height'] : 200;
}
return $result;
}
/**
* Method to get the field input markup for a media selector.
* Use attributes to identify specific created_by and asset_id fields
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
if (empty($this->layout))
{
throw new \UnexpectedValueException(sprintf('%s has no layout
assigned.', $this->name));
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Get the data that is going to be passed to the layout
*
* @return array
*/
public function getLayoutData()
{
// Get the basic field data
$data = parent::getLayoutData();
$asset = $this->asset;
if ($asset === '')
{
$asset =
\JFactory::getApplication()->input->get('option');
}
if ($this->value && file_exists(JPATH_ROOT . '/' .
$this->value))
{
$this->folder = explode('/', $this->value);
$this->folder = array_diff_assoc($this->folder,
explode('/',
ComponentHelper::getParams('com_media')->get('image_path',
'images')));
array_pop($this->folder);
$this->folder = implode('/', $this->folder);
}
elseif (file_exists(JPATH_ROOT . '/' .
ComponentHelper::getParams('com_media')->get('image_path',
'images') . '/' . $this->directory))
{
$this->folder = $this->directory;
}
else
{
$this->folder = '';
}
$extraData = array(
'asset' => $asset,
'authorField' => $this->authorField,
'authorId' =>
$this->form->getValue($this->authorField),
'folder' => $this->folder,
'link' => $this->link,
'preview' => $this->preview,
'previewHeight' => $this->previewHeight,
'previewWidth' => $this->previewWidth,
);
return array_merge($data, $extraData);
}
}
MenuField.php000064400000005603151157547730007150 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
// Import the com_menus helper.
require_once realpath(JPATH_ADMINISTRATOR .
'/components/com_menus/helpers/menus.php');
FormHelper::loadFieldClass('GroupedList');
/**
* Supports an HTML select list of menus
*
* @since 1.6
*/
class MenuField extends \JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'Menu';
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.7.0
* @throws \UnexpectedValueException
*/
protected function getGroups()
{
$clientId = (string) $this->element['clientid'];
$accessType = (string) $this->element['accesstype'];
$showAll = (string) $this->element['showAll'] ==
'true';
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->qn(array('id', 'menutype',
'title', 'client_id'), array('id',
'value', 'text', 'client_id')))
->from($db->quoteName('#__menu_types'))
->order('client_id, title');
if (strlen($clientId))
{
$query->where('client_id = ' . (int) $clientId);
}
$menus = $db->setQuery($query)->loadObjectList();
if ($accessType)
{
$user = Factory::getUser();
foreach ($menus as $key => $menu)
{
switch ($accessType)
{
case 'create':
case 'manage':
if (!$user->authorise('core.' . $accessType,
'com_menus.menu.' . (int) $menu->id))
{
unset($menus[$key]);
}
break;
// Editing a menu item is a bit tricky, we have to check the current
menutype for core.edit and all others for core.create
case 'edit':
$check = $this->value == $menu->value ? 'edit' :
'create';
if (!$user->authorise('core.' . $check,
'com_menus.menu.' . (int) $menu->id))
{
unset($menus[$key]);
}
break;
}
}
}
$opts = array();
// Protected menutypes can be shown if requested
if ($clientId == 1 && $showAll)
{
$opts[] = (object) array(
'value' => 'main',
'text' =>
\JText::_('COM_MENUS_MENU_TYPE_PROTECTED_MAIN_LABEL'),
'client_id' => 1,
);
}
$options = array_merge($opts, $menus);
$groups = array();
if (strlen($clientId))
{
$groups[0] = $options;
}
else
{
foreach ($options as $option)
{
// If client id is not specified we group the items.
$label = ($option->client_id == 1 ?
\JText::_('JADMINISTRATOR') : \JText::_('JSITE'));
$groups[$label][] = $option;
}
}
// Merge any additional options in the XML definition.
return array_merge(parent::getGroups(), $groups);
}
}
MenuitemField.php000064400000013637151157547730010035 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('groupedlist');
// Import the com_menus helper.
require_once realpath(JPATH_ADMINISTRATOR .
'/components/com_menus/helpers/menus.php');
/**
* Supports an HTML grouped select list of menu item grouped by menu
*
* @since 1.6
*/
class MenuitemField extends \JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'MenuItem';
/**
* The menu type.
*
* @var string
* @since 3.2
*/
protected $menuType;
/**
* The client id.
*
* @var string
* @since 3.2
*/
protected $clientId;
/**
* The language.
*
* @var array
* @since 3.2
*/
protected $language;
/**
* The published status.
*
* @var array
* @since 3.2
*/
protected $published;
/**
* The disabled status.
*
* @var array
* @since 3.2
*/
protected $disable;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'menuType':
case 'clientId':
case 'language':
case 'published':
case 'disable':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'menuType':
$this->menuType = (string) $value;
break;
case 'clientId':
$this->clientId = (int) $value;
break;
case 'language':
case 'published':
case 'disable':
$value = (string) $value;
$this->$name = $value ? explode(',', $value) : array();
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
$this->menuType = (string) $this->element['menu_type'];
$this->clientId = (int) $this->element['client_id'];
$this->published = $this->element['published'] ?
explode(',', (string) $this->element['published']) :
array();
$this->disable = $this->element['disable'] ?
explode(',', (string) $this->element['disable']) :
array();
$this->language = $this->element['language'] ?
explode(',', (string) $this->element['language']) :
array();
}
return $result;
}
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
$menuType = $this->menuType;
// Get the menu items.
$items = \MenusHelper::getMenuLinks($menuType, 0, 0, $this->published,
$this->language, $this->clientId);
// Build group for a specific menu type.
if ($menuType)
{
// If the menutype is empty, group the items by menutype.
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__menu_types'))
->where($db->quoteName('menutype') . ' = ' .
$db->quote($menuType));
$db->setQuery($query);
try
{
$menuTitle = $db->loadResult();
}
catch (\RuntimeException $e)
{
$menuTitle = $menuType;
}
// Initialize the group.
$groups[$menuTitle] = array();
// Build the options array.
foreach ($items as $link)
{
$levelPrefix = str_repeat('- ', max(0, $link->level - 1));
// Displays language code if not set to All
if ($link->language !== '*')
{
$lang = ' (' . $link->language . ')';
}
else
{
$lang = '';
}
$groups[$menuTitle][] = \JHtml::_('select.option',
$link->value, $levelPrefix . $link->text . $lang,
'value',
'text',
in_array($link->type, $this->disable)
);
}
}
// Build groups for all menu types.
else
{
// Build the groups arrays.
foreach ($items as $menu)
{
// Initialize the group.
$groups[$menu->title] = array();
// Build the options array.
foreach ($menu->links as $link)
{
$levelPrefix = str_repeat('- ', max(0, $link->level -
1));
// Displays language code if not set to All
if ($link->language !== '*')
{
$lang = ' (' . $link->language . ')';
}
else
{
$lang = '';
}
$groups[$menu->title][] = \JHtml::_('select.option',
$link->value, $levelPrefix . $link->text . $lang,
'value',
'text',
in_array($link->type, $this->disable)
);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
ModuleorderField.php000064400000006457151157547730010535 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Session\Session;
/**
* Module Order field.
*
* @since 1.6
*/
class ModuleorderField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ModuleOrder';
/**
* Name of the layout being used to render the field
*
* @var string
* @since 3.6.3
*/
protected $layout = 'joomla.form.field.moduleorder';
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.6.3
*/
public function __get($name)
{
switch ($name)
{
case 'linked':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.6.3
*/
public function __set($name, $value)
{
switch ($name)
{
case 'linked':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.6.3
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->linked = isset($this->element['linked']) ?
(int) $this->element['linked'] : 'position';
}
return $return;
}
/**
* Method to get the field input markup for the moduleorder field.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.6.3
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$extraData = array(
'ordering' =>
$this->form->getValue('ordering'),
'clientId' =>
$this->form->getValue('client_id'),
'moduleId' => $this->form->getValue('id'),
'name' => $this->name,
'token' => Session::getFormToken() . '=1',
'element' => $this->form->getName() . '_'
. $this->linked
);
return array_merge($data, $extraData);
}
}
ModulepositionField.php000064400000010112151157547730011245
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('text');
/**
* Module Position field.
*
* @since 1.6
*/
class ModulepositionField extends \JFormFieldText
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ModulePosition';
/**
* The client ID.
*
* @var integer
* @since 3.2
*/
protected $clientId;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'clientId':
return $this->clientId;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'clientId':
$this->clientId = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
// Get the client id.
$clientId = $this->element['client_id'];
if (!isset($clientId))
{
$clientName = $this->element['client'];
if (isset($clientName))
{
$client = ApplicationHelper::getClientInfo($clientName, true);
$clientId = $client->id;
}
}
if (!isset($clientId) && $this->form instanceof Form)
{
$clientId = $this->form->getValue('client_id');
}
$this->clientId = (int) $clientId;
}
return $result;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
// Load the modal behavior script.
\JHtml::_('behavior.modal', 'a.modal');
// Build the script.
$script = array();
$script[] = ' function jSelectPosition_' . $this->id .
'(name) {';
$script[] = ' document.getElementById("' . $this->id .
'").value = name;';
$script[] = ' jModalClose();';
$script[] = ' }';
// Add the script to the document head.
Factory::getDocument()->addScriptDeclaration(implode("\n",
$script));
// Setup variables for display.
$html = array();
$link =
'index.php?option=com_modules&view=positions&layout=modal&tmpl=component&function=jSelectPosition_'
. $this->id
. '&client_id=' . $this->clientId;
// The current user display field.
$html[] = '<div class="input-append">';
$html[] = parent::getInput()
. '<a class="btn modal" title="' .
\JText::_('COM_MODULES_CHANGE_POSITION_TITLE') . '"
href="' . $link
. '" rel="{handler: \'iframe\', size: {x: 800,
y: 450}}">'
. \JText::_('COM_MODULES_CHANGE_POSITION_BUTTON') .
'</a>';
$html[] = '</div>';
return implode("\n", $html);
}
}
ModuletagField.php000064400000002046151157547730010163 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Module Tag field.
*
* @since 3.0
*/
class ModuletagField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.0
*/
protected $type = 'ModuleTag';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.0
*/
protected function getOptions()
{
$options = array();
$tags = array('address', 'article',
'aside', 'details', 'div',
'footer', 'header', 'main', 'nav',
'section', 'summary');
// Create one new option object for each tag
foreach ($tags as $tag)
{
$tmp = \JHtml::_('select.option', $tag, $tag);
$options[] = $tmp;
}
reset($options);
return $options;
}
}
OrderingField.php000064400000011275151157547730010017 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\UCM\UCMType;
/**
* Ordering field.
*
* @since 3.2
*/
class OrderingField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'Ordering';
/**
* The form field content type.
*
* @var string
* @since 3.2
*/
protected $contentType;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'contentType':
return $this->contentType;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'contentType':
$this->contentType = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
$this->contentType = (string)
$this->element['content_type'];
}
return $result;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' .
$this->class . '"' : '';
$attr .= $this->disabled ? ' disabled' : '';
$attr .= !empty($this->size) ? ' size="' .
$this->size . '"' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($this->onchange) ? ' onchange="' .
$this->onchange . '"' : '';
$itemId = (int) $this->getItemId();
$query = $this->getQuery();
// Create a read-only list (no name) with a hidden input to store the
value.
if ($this->readonly)
{
$html[] = \JHtml::_('list.ordering', '', $query,
trim($attr), $this->value, $itemId ? 0 : 1);
$html[] = '<input type="hidden" name="' .
$this->name . '" value="' . $this->value .
'"/>';
}
else
{
// Create a regular list.
$html[] = \JHtml::_('list.ordering', $this->name, $query,
trim($attr), $this->value, $itemId ? 0 : 1);
}
return implode($html);
}
/**
* Builds the query for the ordering list.
*
* @return \JDatabaseQuery The query for the ordering form field
*
* @since 3.2
*/
protected function getQuery()
{
$categoryId = (int) $this->form->getValue('catid');
$ucmType = new UCMType;
$ucmRow =
$ucmType->getType($ucmType->getTypeId($this->contentType));
$ucmMapCommon = json_decode($ucmRow->field_mappings)->common;
if (is_object($ucmMapCommon))
{
$ordering = $ucmMapCommon->core_ordering;
$title = $ucmMapCommon->core_title;
}
elseif (is_array($ucmMapCommon))
{
$ordering = $ucmMapCommon[0]->core_ordering;
$title = $ucmMapCommon[0]->core_title;
}
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select(array($db->quoteName($ordering, 'value'),
$db->quoteName($title, 'text')))
->from($db->quoteName(json_decode($ucmRow->table)->special->dbtable))
->where($db->quoteName('catid') . ' = ' .
(int) $categoryId)
->order('ordering');
return $query;
}
/**
* Retrieves the current Item's Id.
*
* @return integer The current item ID
*
* @since 3.2
*/
protected function getItemId()
{
return (int) $this->form->getValue('id');
}
}
PluginstatusField.php000064400000001353151157547730010744 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Plugin Status field.
*
* @since 3.5
*/
class PluginstatusField extends \JFormFieldPredefinedList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
public $type = 'Plugin_Status';
/**
* Available statuses
*
* @var array
* @since 3.5
*/
protected $predefinedOptions = array(
'0' => 'JDISABLED',
'1' => 'JENABLED',
);
}
RedirectStatusField.php000064400000001466151157547730011214
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Redirect Status field.
*
* @since 3.8.0
*/
class RedirectStatusField extends \JFormFieldPredefinedList
{
/**
* The form field type.
*
* @var string
* @since 3.8.0
*/
public $type = 'Redirect_Status';
/**
* Available statuses
*
* @var array
* @since 3.8.0
*/
protected $predefinedOptions = array(
'-2' => 'JTRASHED',
'0' => 'JDISABLED',
'1' => 'JENABLED',
'2' => 'JARCHIVED',
'*' => 'JALL',
);
}
RegistrationdaterangeField.php000064400000002760151157547730012572
0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Registration Date Range field.
*
* @since 3.2
*/
class RegistrationdaterangeField extends \JFormFieldPredefinedList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'RegistrationDateRange';
/**
* Available options
*
* @var array
* @since 3.2
*/
protected $predefinedOptions = array(
'today' => 'COM_USERS_OPTION_RANGE_TODAY',
'past_week' =>
'COM_USERS_OPTION_RANGE_PAST_WEEK',
'past_1month' =>
'COM_USERS_OPTION_RANGE_PAST_1MONTH',
'past_3month' =>
'COM_USERS_OPTION_RANGE_PAST_3MONTH',
'past_6month' =>
'COM_USERS_OPTION_RANGE_PAST_6MONTH',
'past_year' =>
'COM_USERS_OPTION_RANGE_PAST_YEAR',
'post_year' =>
'COM_USERS_OPTION_RANGE_POST_YEAR',
);
/**
* Method to instantiate the form field object.
*
* @param Form $form The form to attach to the form field object.
*
* @since 1.7.0
*/
public function __construct($form = null)
{
parent::__construct($form);
// Load the required language
$lang = Factory::getLanguage();
$lang->load('com_users', JPATH_ADMINISTRATOR);
}
}
StatusField.php000064400000001454151157547730007527 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Form Field to load a list of states
*
* @since 3.2
*/
class StatusField extends \JFormFieldPredefinedList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
public $type = 'Status';
/**
* Available statuses
*
* @var array
* @since 3.2
*/
protected $predefinedOptions = array(
-2 => 'JTRASHED',
0 => 'JUNPUBLISHED',
1 => 'JPUBLISHED',
2 => 'JARCHIVED',
'*' => 'JALL',
);
}
TagField.php000064400000013073151157547730006757 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\Utilities\ArrayHelper;
FormHelper::loadFieldClass('list');
/**
* List of Tags field.
*
* @since 3.1
*/
class TagField extends \JFormFieldList
{
/**
* A flexible tag list that respects access controls
*
* @var string
* @since 3.1
*/
public $type = 'Tag';
/**
* Flag to work with nested tag field
*
* @var boolean
* @since 3.1
*/
public $isNested = null;
/**
* com_tags parameters
*
* @var \Joomla\Registry\Registry
* @since 3.1
*/
protected $comParams = null;
/**
* Constructor
*
* @since 3.1
*/
public function __construct()
{
parent::__construct();
// Load com_tags config
$this->comParams = ComponentHelper::getParams('com_tags');
}
/**
* Method to get the field input for a tag field.
*
* @return string The field input.
*
* @since 3.1
*/
protected function getInput()
{
// AJAX mode requires ajax-chosen
if (!$this->isNested())
{
// Get the field id
$id = isset($this->element['id']) ?
$this->element['id'] : null;
$cssId = '#' . $this->getId($id,
$this->element['name']);
// Load the ajax-chosen customised field
\JHtml::_('tag.ajaxfield', $cssId, $this->allowCustom());
}
if (!is_array($this->value) && !empty($this->value))
{
if ($this->value instanceof TagsHelper)
{
if (empty($this->value->tags))
{
$this->value = array();
}
else
{
$this->value = $this->value->tags;
}
}
// String in format 2,5,4
if (is_string($this->value))
{
$this->value = explode(',', $this->value);
}
}
return parent::getInput();
}
/**
* Method to get a list of tags
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function getOptions()
{
$published = $this->element['published'] ?: array(0, 1);
$app = Factory::getApplication();
$tag = $app->getLanguage()->getTag();
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT a.id AS value, a.path, a.title AS text,
a.level, a.published, a.lft')
->from('#__tags AS a')
->join('LEFT', $db->qn('#__tags') . ' AS
b ON a.lft > b.lft AND a.rgt < b.rgt');
// Limit Options in multilanguage
if ($app->isClient('site') &&
Multilanguage::isEnabled())
{
$lang =
ComponentHelper::getParams('com_tags')->get('tag_list_language_filter');
if ($lang == 'current_language')
{
$query->where('a.language in (' . $db->quote($tag) .
',' . $db->quote('*') . ')');
}
}
// Filter language
elseif (!empty($this->element['language']))
{
if (strpos($this->element['language'], ',') !==
false)
{
$language = implode(',', $db->quote(explode(',',
$this->element['language'])));
}
else
{
$language = $db->quote($this->element['language']);
}
$query->where($db->quoteName('a.language') . ' IN
(' . $language . ')');
}
$query->where($db->qn('a.lft') . ' > 0');
// Filter on the published state
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif (is_array($published))
{
$published = ArrayHelper::toInteger($published);
$query->where('a.published IN (' . implode(',',
$published) . ')');
}
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (\RuntimeException $e)
{
return array();
}
// Block the possibility to set a tag as it own parent
if ($this->form->getName() === 'com_tags.tag')
{
$id = (int) $this->form->getValue('id', 0);
foreach ($options as $option)
{
if ($option->value == $id)
{
$option->disable = true;
}
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
// Prepare nested data
if ($this->isNested())
{
$this->prepareOptionsNested($options);
}
else
{
$options = TagsHelper::convertPathsToNames($options);
}
return $options;
}
/**
* Add "-" before nested tags, depending on level
*
* @param array &$options Array of tags
*
* @return array The field option objects.
*
* @since 3.1
*/
protected function prepareOptionsNested(&$options)
{
if ($options)
{
foreach ($options as &$option)
{
$repeat = (isset($option->level) && $option->level - 1
>= 0) ? $option->level - 1 : 0;
$option->text = str_repeat('- ', $repeat) .
$option->text;
}
}
return $options;
}
/**
* Determine if the field has to be tagnested
*
* @return boolean
*
* @since 3.1
*/
public function isNested()
{
if ($this->isNested === null)
{
// If mode="nested" || ( mode not set & config = nested )
if (isset($this->element['mode']) && (string)
$this->element['mode'] === 'nested'
|| !isset($this->element['mode']) &&
$this->comParams->get('tag_field_ajax_mode', 1) == 0)
{
$this->isNested = true;
}
}
return $this->isNested;
}
/**
* Determines if the field allows or denies custom values
*
* @return boolean
*/
public function allowCustom()
{
if (isset($this->element['custom']) && (string)
$this->element['custom'] === 'deny')
{
return false;
}
return true;
}
}
TemplatestyleField.php000064400000011237151157547730011100 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('groupedlist');
/**
* Supports a select grouped list of template styles
*
* @since 1.6
*/
class TemplatestyleField extends \JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'TemplateStyle';
/**
* The client name.
*
* @var mixed
* @since 3.2
*/
protected $clientName;
/**
* The template.
*
* @var mixed
* @since 3.2
*/
protected $template;
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'clientName':
case 'template':
return $this->$name;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'clientName':
case 'template':
$this->$name = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
if ($result === true)
{
// Get the clientName template.
$this->clientName = $this->element['client'] ? (string)
$this->element['client'] : 'site';
$this->template = (string) $this->element['template'];
}
return $result;
}
/**
* Method to get the list of template style options grouped by template.
* Use the client attribute to specify a specific client.
* Use the template attribute to specify a specific template
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
$lang = Factory::getLanguage();
// Get the client and client_id.
$client = ApplicationHelper::getClientInfo($this->clientName, true);
// Get the template.
$template = $this->template;
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('s.id, s.title, e.name as name, s.template')
->from('#__template_styles as s')
->where('s.client_id = ' . (int) $client->id)
->order('template')
->order('title');
if ($template)
{
$query->where('s.template = ' . $db->quote($template));
}
$query->join('LEFT', '#__extensions as e on
e.element=s.template')
->where('e.enabled = 1')
->where($db->quoteName('e.type') . ' = ' .
$db->quote('template'));
// Set the query and load the styles.
$db->setQuery($query);
$styles = $db->loadObjectList();
// Build the grouped list array.
if ($styles)
{
foreach ($styles as $style)
{
$template = $style->template;
$lang->load('tpl_' . $template . '.sys',
$client->path, null, false, true)
|| $lang->load('tpl_' . $template . '.sys',
$client->path . '/templates/' . $template, null, false, true);
$name = \JText::_($style->name);
// Initialize the group if necessary.
if (!isset($groups[$name]))
{
$groups[$name] = array();
}
$groups[$name][] = \JHtml::_('select.option', $style->id,
$style->title);
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
UseractiveField.php000064400000002264151157547730010356 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Field to show a list of available user active statuses
*
* @since 3.2
*/
class UseractiveField extends \JFormFieldPredefinedList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'UserActive';
/**
* Available statuses
*
* @var array
* @since 3.2
*/
protected $predefinedOptions = array(
'0' => 'COM_USERS_ACTIVATED',
'1' => 'COM_USERS_UNACTIVATED',
);
/**
* Method to instantiate the form field object.
*
* @param Form $form The form to attach to the form field object.
*
* @since 1.7.0
*/
public function __construct($form = null)
{
parent::__construct($form);
// Load the required language
$lang = Factory::getLanguage();
$lang->load('com_users', JPATH_ADMINISTRATOR);
}
}
UserField.php000064400000007552151157547730007167 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\User\User;
/**
* Field to select a user ID from a modal list.
*
* @since 1.6
*/
class UserField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'User';
/**
* Filtering groups
*
* @var array
* @since 3.5
*/
protected $groups = null;
/**
* Users to exclude from the list of users
*
* @var array
* @since 3.5
*/
protected $excluded = null;
/**
* Layout to render
*
* @var string
* @since 3.5
*/
protected $layout = 'joomla.form.field.user';
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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 3.7.0
*
* @see JFormField::setup()
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
// If user can't access com_users the field should be readonly.
if ($return && !$this->readonly)
{
$this->readonly =
!Factory::getUser()->authorise('core.manage',
'com_users');
}
return $return;
}
/**
* Method to get the user field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
if (empty($this->layout))
{
throw new \UnexpectedValueException(sprintf('%s has no layout
assigned.', $this->name));
}
return
$this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* Get the data that is going to be passed to the layout
*
* @return array
*
* @since 3.5
*/
public function getLayoutData()
{
// Get the basic field data
$data = parent::getLayoutData();
// Initialize value
$name = \JText::_('JLIB_FORM_SELECT_USER');
if (is_numeric($this->value))
{
$name = User::getInstance($this->value)->name;
}
// Handle the special case for "current".
elseif (strtoupper($this->value) === 'CURRENT')
{
// 'CURRENT' is not a reasonable value to be placed in the
html
$current = Factory::getUser();
$this->value = $current->id;
$data['value'] = $this->value;
$name = $current->name;
}
// User lookup went wrong, we assign the value instead.
if ($name === null && $this->value)
{
$name = $this->value;
}
$extraData = array(
'userName' => $name,
'groups' => $this->getGroups(),
'excluded' => $this->getExcluded(),
);
return array_merge($data, $extraData);
}
/**
* Method to get the filtering groups (null means no filtering)
*
* @return mixed Array of filtering groups or null.
*
* @since 1.6
*/
protected function getGroups()
{
if (isset($this->element['groups']))
{
return explode(',', $this->element['groups']);
}
return;
}
/**
* Method to get the users to exclude from the list of users
*
* @return mixed Array of users to exclude or null to to not exclude
them
*
* @since 1.6
*/
protected function getExcluded()
{
if (isset($this->element['exclude']))
{
return explode(',', $this->element['exclude']);
}
return;
}
}
UsergrouplistField.php000064400000005364151157547730011137 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Helper\UserGroupsHelper;
FormHelper::loadFieldClass('list');
/**
* Field to load a dropdown list of available user groups
*
* @since 3.2
*/
class UsergrouplistField extends \JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'UserGroupList';
/**
* Cached array of the category items.
*
* @var array
* @since 3.2
*/
protected static $options = array();
/**
* Method to attach a JForm object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object
representing the `<field>` 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 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 1.7.0
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
if (is_string($value) && strpos($value, ',') !== false)
{
$value = explode(',', $value);
}
return parent::setup($element, $value, $group);
}
/**
* Method to get the options to populate list
*
* @return array The field option objects.
*
* @since 3.2
*/
protected function getOptions()
{
$options = parent::getOptions();
$checkSuperUser = (int)
$this->getAttribute('checksuperusergroup', 0);
// Cache user groups base on checksuperusergroup attribute value
if (!isset(static::$options[$checkSuperUser]))
{
$groups = UserGroupsHelper::getInstance()->getAll();
$isSuperUser =
Factory::getUser()->authorise('core.admin');
$cacheOptions = array();
foreach ($groups as $group)
{
// Don't show super user groups to non super users.
if ($checkSuperUser && !$isSuperUser &&
Access::checkGroup($group->id, 'core.admin'))
{
continue;
}
$cacheOptions[] = (object) array(
'text' => str_repeat('- ', $group->level) .
$group->title,
'value' => $group->id,
'level' => $group->level,
);
}
static::$options[$checkSuperUser] = $cacheOptions;
}
return array_merge($options, static::$options[$checkSuperUser]);
}
}
UserstateField.php000064400000001402151157547730010214 0ustar00<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Form\Field;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('predefinedlist');
/**
* Field to load a list of available users statuses
*
* @since 3.2
*/
class UserstateField extends \JFormFieldPredefinedList
{
/**
* The form field type.
*
* @var string
* @since 3.2
*/
protected $type = 'UserState';
/**
* Available statuses
*
* @var array
* @since 3.2
*/
protected $predefinedOptions = array(
'0' => 'JENABLED',
'1' => 'JDISABLED',
);
}