first commit
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
class JFormFieldBlockformats extends JFormFieldCheckboxes
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Blockformats';
|
||||
|
||||
/**
|
||||
* Name of the layout being used to render the field
|
||||
*
|
||||
* @var string
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $layout = 'form.field.blockformats';
|
||||
|
||||
protected static $blockformats = array(
|
||||
'p' => 'Paragraph',
|
||||
'div' => 'Div',
|
||||
'div_container' => 'Div Container',
|
||||
'h1' => 'Heading1',
|
||||
'h2' => 'Heading2',
|
||||
'h3' => 'Heading3',
|
||||
'h4' => 'Heading4',
|
||||
'h5' => 'Heading5',
|
||||
'h6' => 'Heading6',
|
||||
'blockquote' => 'Blockquote',
|
||||
'address' => 'Address',
|
||||
'code' => 'Code',
|
||||
'pre' => 'Preformatted',
|
||||
'samp' => 'Sample',
|
||||
'span' => 'Span',
|
||||
'section' => 'Section',
|
||||
'article' => 'Article',
|
||||
'aside' => 'Aside',
|
||||
'header' => 'Header',
|
||||
'footer' => 'Footer',
|
||||
'nav' => 'Nav',
|
||||
'figure' => 'Figure',
|
||||
'dt' => 'Definition Term',
|
||||
'dd' => 'Definition List'
|
||||
);
|
||||
|
||||
/**
|
||||
* Allow to override renderer include paths in child fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return array(JPATH_ADMINISTRATOR . '/components/com_jce/layouts', JPATH_SITE . '/layouts');
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname);
|
||||
$options = array();
|
||||
|
||||
if (empty($this->value)) {
|
||||
$data = array_keys(self::$blockformats);
|
||||
$values = $data;
|
||||
} else {
|
||||
if (is_string($this->value)) {
|
||||
$this->value = explode(',', $this->value);
|
||||
}
|
||||
$values = $this->value;
|
||||
$data = array_unique(array_merge($this->value, array_keys(self::$blockformats)));
|
||||
}
|
||||
|
||||
// create default font structure
|
||||
foreach ($data as $format) {
|
||||
if (array_key_exists($format, self::$blockformats) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$text = self::$blockformats[$format];
|
||||
|
||||
$tmp = array(
|
||||
'value' => $format,
|
||||
'text' => JText::alt($text, $fieldname),
|
||||
'checked' => in_array($format, $values)
|
||||
);
|
||||
|
||||
$options[] = (object) $tmp;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
73
administrator/components/com_jce/models/fields/buttons.php
Normal file
73
administrator/components/com_jce/models/fields/buttons.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('checkboxes');
|
||||
|
||||
class JFormFieldButtons extends JFormFieldCheckboxes
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Buttons';
|
||||
|
||||
/**
|
||||
* Name of the layout being used to render the field
|
||||
*
|
||||
* @var string
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $layout = 'form.field.buttons';
|
||||
|
||||
/**
|
||||
* Method to get the field label markup for a spacer.
|
||||
* Use the label text or name from the XML element as the spacer or
|
||||
* Use a hr="true" to automatically generate plain hr markup.
|
||||
*
|
||||
* @return string The field label markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
$this->class = trim($this->class . ' mceDefaultSkin');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to override renderer include paths in child fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return array(JPATH_ADMINISTRATOR . '/components/com_jce/layouts', JPATH_SITE . '/layouts');
|
||||
}
|
||||
}
|
||||
180
administrator/components/com_jce/models/fields/checkboxes.php
Normal file
180
administrator/components/com_jce/models/fields/checkboxes.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Displays options as a list of checkboxes.
|
||||
* Multiselect may be forced to be true.
|
||||
*
|
||||
* @see JFormFieldCheckbox
|
||||
* @since 1.7.0
|
||||
*/
|
||||
class JFormFieldCheckboxes extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.7.0
|
||||
*/
|
||||
protected $type = 'Checkboxes';
|
||||
|
||||
/**
|
||||
* Name of the layout being used to render the field
|
||||
*
|
||||
* @var string
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $layout = 'form.field.checkboxes';
|
||||
|
||||
/**
|
||||
* Flag to tell the field to always be in multiple values mode.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 1.7.0
|
||||
*/
|
||||
protected $forceMultiple = true;
|
||||
|
||||
/**
|
||||
* The comma separated list of checked checkboxes value.
|
||||
*
|
||||
* @var mixed
|
||||
* @since 3.2
|
||||
*/
|
||||
public $checkedOptions;
|
||||
|
||||
/**
|
||||
* 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 'forceMultiple':
|
||||
case 'checkedOptions':
|
||||
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 'checkedOptions':
|
||||
$this->checkedOptions = (string) $value;
|
||||
break;
|
||||
|
||||
default:
|
||||
parent::__set($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the radio button field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
if ($return)
|
||||
{
|
||||
$this->checkedOptions = (string) $this->element['checked'];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data to be passed to the layout for rendering.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutData()
|
||||
{
|
||||
$data = parent::getLayoutData();
|
||||
|
||||
// True if the field has 'value' set. In other words, it has been stored, don't use the default values.
|
||||
$hasValue = (isset($this->value) && !empty($this->value));
|
||||
|
||||
// If a value has been stored, use it. Otherwise, use the defaults.
|
||||
$checkedOptions = $hasValue ? $this->value : $this->checkedOptions;
|
||||
|
||||
$extraData = array(
|
||||
'checkedOptions' => is_array($checkedOptions) ? $checkedOptions : explode(',', (string) $checkedOptions),
|
||||
'hasValue' => $hasValue,
|
||||
'options' => $this->getOptions(),
|
||||
);
|
||||
|
||||
return array_merge($data, $extraData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to override renderer include paths in child fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return array(JPATH_ADMINISTRATOR . '/components/com_jce/layouts', JPATH_SITE . '/layouts');
|
||||
}
|
||||
}
|
||||
50
administrator/components/com_jce/models/fields/color.php
Normal file
50
administrator/components/com_jce/models/fields/color.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Form
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('color');
|
||||
|
||||
/**
|
||||
* Color Form Field class for the Joomla Platform.
|
||||
* This implementation is designed to be compatible with HTML5's `<input type="color">`
|
||||
*
|
||||
* @link http://www.w3.org/TR/html-markup/input.color.html
|
||||
* @since 11.3
|
||||
*/
|
||||
class JFormFieldColorPicker extends JFormFieldColor
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 11.3
|
||||
*/
|
||||
protected $type = 'ColorPicker';
|
||||
|
||||
/**
|
||||
* Name of the layout being used to render the field
|
||||
*
|
||||
* @var string
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $layout = 'form.field.colorpicker';
|
||||
|
||||
/**
|
||||
* Allow to override renderer include paths in child fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return array(JPATH_ADMINISTRATOR . '/components/com_jce/layouts', JPATH_SITE . '/layouts');
|
||||
}
|
||||
}
|
||||
101
administrator/components/com_jce/models/fields/components.php
Normal file
101
administrator/components/com_jce/models/fields/components.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Framework.
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
class JFormFieldComponents extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
protected $type = 'Components';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$language = JFactory::getLanguage();
|
||||
|
||||
$exclude = array(
|
||||
'com_admin',
|
||||
'com_cache',
|
||||
'com_checkin',
|
||||
'com_config',
|
||||
'com_cpanel',
|
||||
'com_fields',
|
||||
'com_finder',
|
||||
'com_installer',
|
||||
'com_languages',
|
||||
'com_login',
|
||||
'com_mailto',
|
||||
'com_menus',
|
||||
'com_media',
|
||||
'com_messages',
|
||||
'com_newsfeeds',
|
||||
'com_plugins',
|
||||
'com_redirect',
|
||||
'com_templates',
|
||||
'com_users',
|
||||
'com_wrapper',
|
||||
'com_search',
|
||||
'com_user',
|
||||
'com_updates',
|
||||
);
|
||||
|
||||
// Get list of plugins
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('element AS value, name AS text')
|
||||
->from('#__extensions')
|
||||
->where('type = '.$db->quote('component'))
|
||||
->where('enabled = 1')
|
||||
->order('ordering, name');
|
||||
$db->setQuery($query);
|
||||
|
||||
$components = $db->loadObjectList();
|
||||
|
||||
$options = array();
|
||||
|
||||
// load component languages
|
||||
for ($i = 0; $i < count($components); ++$i) {
|
||||
if (!in_array($components[$i]->value, $exclude)) {
|
||||
// load system language file
|
||||
$language->load($components[$i]->value.'.sys', JPATH_ADMINISTRATOR);
|
||||
$language->load($components[$i]->value, JPATH_ADMINISTRATOR);
|
||||
|
||||
if ($components[$i]->text === "COM_JCE") {
|
||||
$components[$i]->text = "WF_CPANEL_BROWSER";
|
||||
}
|
||||
|
||||
// translate name
|
||||
$components[$i]->text = JText::_($components[$i]->text, true);
|
||||
|
||||
$components[$i]->disable = '';
|
||||
|
||||
$options[] = $components[$i];
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
114
administrator/components/com_jce/models/fields/container.php
Normal file
114
administrator/components/com_jce/models/fields/container.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JCE
|
||||
* @subpackage Component
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
|
||||
* @copyright Copyright (C) 2006 - 2020 Ryan Demmer. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the JCE.
|
||||
* Display a field with a repeatable set of defined sub fields
|
||||
*
|
||||
* @since 2.8.13
|
||||
*/
|
||||
class JFormFieldContainer extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.8.13
|
||||
*/
|
||||
protected $type = 'Container';
|
||||
|
||||
/**
|
||||
* Method to get the field label markup for a spacer.
|
||||
* Use the label text or name from the XML element as the spacer or
|
||||
* Use a hr="true" to automatically generate plain hr markup.
|
||||
*
|
||||
* @return string The field label markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 2.8.13
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$group = $this->group;
|
||||
|
||||
// subfields require JCE Pro
|
||||
if (isset($this->element['pro']) && !WF_EDITOR_PRO) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$subForm = new JForm('', array('control' => $this->formControl . '[' . str_replace('.', '][', $group) . ']'));
|
||||
$children = $this->element->children();
|
||||
|
||||
$subForm->load($children);
|
||||
$subForm->setFields($children);
|
||||
|
||||
$data = $this->form->getData()->toObject();
|
||||
|
||||
// extract relevant data level using group
|
||||
foreach (explode('.', $group) as $key) {
|
||||
if (isset($data->$key)) {
|
||||
$data = $data->$key;
|
||||
}
|
||||
}
|
||||
|
||||
$subForm->bind($data);
|
||||
|
||||
// And finaly build a main container
|
||||
$str = array();
|
||||
|
||||
$fields = $subForm->getFieldset();
|
||||
|
||||
if ($this->class === 'inset') {
|
||||
$this->class .= ' well well-small well-light p-4 bg-light';
|
||||
}
|
||||
|
||||
$str[] = '<div class="form-field-container ' . $this->class . '">';
|
||||
$str[] = ' <fieldset class="form-field-container-group">';
|
||||
|
||||
if ($this->element['label']) {
|
||||
$text = $this->element['label'];
|
||||
$text = $this->translateLabel ? JText::_($text) : $text;
|
||||
|
||||
$str[] = '<legend>' . $text . '</legend>';
|
||||
}
|
||||
|
||||
if ($this->element['description']) {
|
||||
$text = $this->element['description'];
|
||||
$text = $this->translateLabel ? JText::_($text) : $text;
|
||||
|
||||
$str[] = '<small class="description">' . $text . '</small>';
|
||||
|
||||
// reset description
|
||||
$this->description = '';
|
||||
}
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$str[] = $field->renderField(array('description' => $field->description));
|
||||
}
|
||||
|
||||
$str[] = ' </fieldset>';
|
||||
$str[] = '</div>';
|
||||
|
||||
return implode("", $str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldCustomList extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'CustomList';
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
$this->class = trim($this->class.' com_jce_select_custom');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = parent::getOptions();
|
||||
|
||||
$this->value = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
|
||||
$custom = array();
|
||||
|
||||
foreach ($this->value as $value) {
|
||||
$tmp = array(
|
||||
'value' => $value,
|
||||
'text' => $value,
|
||||
'selected' => true,
|
||||
);
|
||||
|
||||
$found = false;
|
||||
|
||||
foreach($options as $option) {
|
||||
if ($option->value === $value) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$custom[] = (object) $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge($options, $custom);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldElementList extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'ElementList';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname);
|
||||
$options = array();
|
||||
|
||||
$tags = 'a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del,details,dfn,dialog,div,dl,dt,em,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,img,input,ins,kbd,keygen,label,legend,li,main,map,mark,menu,menuitem,meter,nav,noscript,ol,optgroup,option,output,p,param,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,section,select,small,source,span,strong,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,tr,track,u,ul,var,video,wbr';
|
||||
|
||||
foreach (explode(',', $tags) as $option) {
|
||||
$value = (string) $option;
|
||||
$text = trim((string) $option);
|
||||
|
||||
$tmp = array(
|
||||
'value' => $value,
|
||||
'text' => JText::alt($text, $fieldname),
|
||||
'disable' => false,
|
||||
'class' => '',
|
||||
'selected' => false,
|
||||
'checked' => false,
|
||||
);
|
||||
|
||||
// Add the option object to the result set.
|
||||
$options[] = (object) $tmp;
|
||||
}
|
||||
|
||||
reset($options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
10
administrator/components/com_jce/models/fields/extension.php
Normal file
10
administrator/components/com_jce/models/fields/extension.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('filetype');
|
||||
|
||||
class JFormFieldExtension extends JFormFieldFiletype
|
||||
{
|
||||
|
||||
}
|
||||
161
administrator/components/com_jce/models/fields/filesystem.php
Normal file
161
administrator/components/com_jce/models/fields/filesystem.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldFilesystem extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Filesystem';
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$value = $this->value;
|
||||
|
||||
// decode json string
|
||||
if (!empty($value) && is_string($value)) {
|
||||
$value = json_decode($value, true);
|
||||
}
|
||||
|
||||
// default
|
||||
if (empty($value)) {
|
||||
$value = array('name' => $this->default);
|
||||
} else {
|
||||
if (!isset($value['name'])) {
|
||||
$value['name'] = $this->default;
|
||||
}
|
||||
}
|
||||
|
||||
$plugins = $this->getPlugins();
|
||||
$options = $this->getOptions();
|
||||
|
||||
$html = '';
|
||||
$html .= '<div class="controls-row">';
|
||||
|
||||
$html .= '<div class="control-group">';
|
||||
$html .= JHtml::_('select.genericlist', $options, $this->name . '[name]', 'data-toggle="filesystem-options" class="custom-select"', 'value', 'text', $value['name']);
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="filesystem-options clearfix">';
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$form = JForm::getInstance('plg_jce_' . $this->name . '_' . $plugin->name, $plugin->manifest, array('control' => $this->name . '[' . $plugin->name . ']'), true, '//extension');
|
||||
|
||||
if ($form) {
|
||||
// get the data for this form, if set
|
||||
$data = isset($value[$plugin->name]) ? $value[$plugin->name] : array();
|
||||
|
||||
// bind data to form
|
||||
$form->bind($data);
|
||||
|
||||
$html .= '<div class="well well-small p-2 bg-light" data-toggle-target="filesystem-options-' . $plugin->name . '">';
|
||||
|
||||
$fields = $form->getFieldset('filesystem.' . $plugin->name);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$html .= $field->renderField(array('description' => $field->description));
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getPlugins()
|
||||
{
|
||||
static $plugins;
|
||||
|
||||
if (!isset($plugins)) {
|
||||
$plugins = JcePluginsHelper::getExtensions('filesystem');
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname);
|
||||
|
||||
$options = parent::getOptions();
|
||||
|
||||
/*$options[] = array(
|
||||
'value' => '',
|
||||
'text' => JText::_('WF_OPTION_NOT_SET'),
|
||||
);*/
|
||||
|
||||
$plugins = $this->getPlugins();
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$value = (string)$plugin->name;
|
||||
$text = (string)$plugin->title;
|
||||
|
||||
$tmp = array(
|
||||
'value' => $value,
|
||||
'text' => JText::alt($text, $fieldname),
|
||||
'disable' => false,
|
||||
'class' => '',
|
||||
'selected' => false,
|
||||
);
|
||||
|
||||
// Add the option object to the result set.
|
||||
$options[] = (object)$tmp;
|
||||
}
|
||||
|
||||
reset($options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
183
administrator/components/com_jce/models/fields/filetype.php
Normal file
183
administrator/components/com_jce/models/fields/filetype.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldFiletype extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Filetype';
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private static function array_flatten($array, $return)
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$return = self::array_flatten($value, $return);
|
||||
} else {
|
||||
$return[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function mapValue($value)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
// no grouping
|
||||
if (strpos($value, '=') === false) {
|
||||
return array(explode(',', $value));
|
||||
}
|
||||
|
||||
foreach (explode(';', $value) as $group) {
|
||||
$items = explode('=', $group);
|
||||
$name = $items[0];
|
||||
$values = explode(',', $items[1]);
|
||||
|
||||
array_walk($values, function (&$item) use ($name) {
|
||||
if ($name === '-') {
|
||||
$item = '-' . $item;
|
||||
}
|
||||
});
|
||||
|
||||
$data[$name] = $values;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function cleanValue($value)
|
||||
{
|
||||
$data = $this->mapValue($value);
|
||||
// get array values only
|
||||
$values = self::array_flatten($data, array());
|
||||
// convert to string
|
||||
$string = implode(',', $values);
|
||||
// return single array
|
||||
return explode(',', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// cleanup string
|
||||
$value = htmlspecialchars_decode($this->value);
|
||||
|
||||
// map default values to groups
|
||||
$default = $this->mapValue($this->default);
|
||||
|
||||
// remove leading = if any
|
||||
if ($value && $value[0] === '=') {
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
|
||||
// map values to groups
|
||||
$data = $this->mapValue($value);
|
||||
|
||||
$html = array();
|
||||
|
||||
$html[] = '<div class="filetype">';
|
||||
$html[] = ' <div class="input-append input-group">';
|
||||
|
||||
$html[] = ' <input type="text" value="' . $value . '" disabled class="form-control" />';
|
||||
$html[] = ' <input type="hidden" name="' . $this->name . '" value="' . $value . '" />';
|
||||
$html[] = ' <div class="input-group-append">';
|
||||
$html[] = ' <a class="btn btn-secondary filetype-edit add-on input-group-text" role="button"><i class="icon-edit icon-apply"></i><span role="none">Edit</span></a>';
|
||||
$html[] = ' </div>';
|
||||
$html[] = ' </div>';
|
||||
|
||||
foreach ($data as $group => $items) {
|
||||
$custom = array();
|
||||
|
||||
$html[] = '<dl class="filetype-list">';
|
||||
|
||||
if (is_string($group)) {
|
||||
$checked = '';
|
||||
|
||||
$is_default = isset($default[$group]);
|
||||
|
||||
if (empty($value) || $is_default || (!$is_default && $group[0] !== '-')) {
|
||||
$checked = ' checked="checked"';
|
||||
}
|
||||
|
||||
// clear minus sign
|
||||
$group = str_replace('-', '', $group);
|
||||
|
||||
$groupKey = 'WF_FILEGROUP_' . strtoupper($group);
|
||||
$groupName = JText::_('WF_FILEGROUP_' . strtoupper($group));
|
||||
|
||||
// create simple label if there is no translation
|
||||
if ($groupName === $groupKey) {
|
||||
$groupName = ucfirst($group);
|
||||
}
|
||||
|
||||
$html[] = '<dt class="filetype-group" data-filetype-group="' . $group . '"><label><input type="checkbox" value="' . $group . '"' . $checked . ' />' . $groupName . '</label></dt>';
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
$checked = '';
|
||||
|
||||
$item = strtolower($item);
|
||||
|
||||
// clear minus sign
|
||||
$mod = str_replace('-', '', $item);
|
||||
|
||||
$is_default = !empty($default[$group]) && in_array($item, $default[$group]);
|
||||
|
||||
if (empty($value) || $is_default || (!$is_default && $mod === $item)) {
|
||||
$checked = ' checked="checked"';
|
||||
}
|
||||
|
||||
$html[] = '<dd class="filetype-item"><label><input type="checkbox" value="' . $mod . '"' . $checked . ' /><span class="file ' . $mod . '"></span> ' . $mod . '</label>';
|
||||
|
||||
if (!$is_default) {
|
||||
$html[] = '<button class="btn btn-link filetype-remove"><span class="icon-trash"></span></button>';
|
||||
}
|
||||
|
||||
$html[] = '</dd>';
|
||||
}
|
||||
|
||||
$html[] = '<dd class="filetype-item filetype-custom row form-row"><div class="file"></div><input type="text" class="span8 col-md-8 form-control" value="" placeholder="' . JText::_('WF_EXTENSION_MAPPER_TYPE_NEW') . '" /><button class="pull-right float-right btn btn-link filetype-add"><span class="icon-plus"></span></button><button class="pull-right float-right btn btn-link filetype-remove"><span class="icon-trash"></span></button></dd>';
|
||||
|
||||
$html[] = '</dl>';
|
||||
}
|
||||
|
||||
$html[] = ' </div>';
|
||||
|
||||
return implode("\n", $html);
|
||||
}
|
||||
}
|
||||
36
administrator/components/com_jce/models/fields/fontlist.php
Normal file
36
administrator/components/com_jce/models/fields/fontlist.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('filelist');
|
||||
|
||||
class JFormFieldFontList extends JFormFieldFileList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'FontList';
|
||||
|
||||
/**
|
||||
* Method to get the field input for a fontlist field.
|
||||
*
|
||||
* @return string The field input
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
if (!is_array($this->value) && !empty($this->value)) {
|
||||
// String in format 2,5,4
|
||||
if (is_string($this->value)) {
|
||||
$this->value = explode(',', $this->value);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::getInput();
|
||||
}
|
||||
}
|
||||
139
administrator/components/com_jce/models/fields/fonts.php
Normal file
139
administrator/components/com_jce/models/fields/fonts.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
class JFormFieldFonts extends JFormFieldCheckboxes
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Fonts';
|
||||
|
||||
/**
|
||||
* Name of the layout being used to render the field
|
||||
*
|
||||
* @var string
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $layout = 'form.field.fonts';
|
||||
|
||||
/**
|
||||
* Flag to tell the field to always be in multiple values mode.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $forceMultiple = false;
|
||||
|
||||
private static $fonts = array(
|
||||
'Andale Mono' => 'andale mono,times',
|
||||
'Arial' => 'arial,helvetica,sans-serif',
|
||||
'Arial Black' => 'arial black,avant garde',
|
||||
'Book Antiqua' => 'book antiqua,palatino',
|
||||
'Comic Sans MS' => 'comic sans ms,sans-serif',
|
||||
'Courier New' => 'courier new,courier',
|
||||
'Georgia' => 'georgia,palatino',
|
||||
'Helvetica' => 'helvetica',
|
||||
'Impact' => 'impact,chicago',
|
||||
'Symbol' => 'symbol',
|
||||
'Tahoma' => 'tahoma,arial,helvetica,sans-serif',
|
||||
'Terminal' => 'terminal,monaco',
|
||||
'Times New Roman' => 'times new roman,times',
|
||||
'Trebuchet MS' => 'trebuchet ms,geneva',
|
||||
'Verdana' => 'verdana,geneva',
|
||||
'Webdings' => 'webdings',
|
||||
'Wingdings' => 'wingdings,zapf dingbats',
|
||||
);
|
||||
|
||||
/**
|
||||
* Allow to override renderer include paths in child fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return array(JPATH_ADMINISTRATOR . '/components/com_jce/layouts', JPATH_SITE . '/layouts');
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname);
|
||||
$options = array();
|
||||
|
||||
if (is_string($this->value)) {
|
||||
$this->value = json_decode(htmlspecialchars_decode($this->value), true);
|
||||
}
|
||||
|
||||
// cast to array
|
||||
$this->value = (array) $this->value;
|
||||
|
||||
$fonts = array();
|
||||
|
||||
// map associative array to array of key value pairs
|
||||
foreach ($this->value as $key => $value) {
|
||||
if (is_numeric($key) && is_array($value)) {
|
||||
$fonts[] = $value;
|
||||
} else {
|
||||
$fonts[] = array($key => $value);
|
||||
}
|
||||
}
|
||||
// array of font names to exclude from default list
|
||||
$exclude = array();
|
||||
// array of custom font key/value pairs
|
||||
$custom = array();
|
||||
|
||||
foreach ($fonts as $font) {
|
||||
list($text) = array_keys($font);
|
||||
list($value) = array_values($font);
|
||||
|
||||
// add to $exclude array
|
||||
$exclude[] = $text;
|
||||
|
||||
$value = htmlspecialchars_decode($value, ENT_QUOTES);
|
||||
|
||||
$isCustom = !in_array($value, array_values(self::$fonts));
|
||||
|
||||
$item = array(
|
||||
'value' => $value,
|
||||
'text' => JText::alt($text, $fieldname),
|
||||
'checked' => true,
|
||||
'custom' => $isCustom,
|
||||
);
|
||||
|
||||
$item = (object) $item;
|
||||
|
||||
if ($isCustom) {
|
||||
$custom[] = $item;
|
||||
} else {
|
||||
$options[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$checked = empty($exclude) ? true : false;
|
||||
|
||||
// assign empty (unchecked) options for unused fonts
|
||||
foreach (self::$fonts as $text => $value) {
|
||||
|
||||
if (in_array($text, $exclude)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmp = array(
|
||||
'value' => $value,
|
||||
'text' => JText::alt($text, $fieldname),
|
||||
'checked' => $checked,
|
||||
'custom' => false,
|
||||
);
|
||||
|
||||
$options[] = (object) $tmp;
|
||||
}
|
||||
|
||||
return array_merge($options, $custom);
|
||||
}
|
||||
}
|
||||
80
administrator/components/com_jce/models/fields/heading.php
Normal file
80
administrator/components/com_jce/models/fields/heading.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Provides spacer markup to be used in form layouts.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldHeading extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Heading';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for a spacer.
|
||||
* The spacer does not have accept input.
|
||||
*
|
||||
* @return string The field input markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field label markup for a spacer.
|
||||
* Use the label text or name from the XML element as the spacer or
|
||||
* Use a hr="true" to automatically generate plain hr markup.
|
||||
*
|
||||
* @return string The field label markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
$html = array();
|
||||
$class = !empty($this->class) ? ' class="'.$this->class.'"' : '';
|
||||
$html[] = '<h3'.$class.'>';
|
||||
|
||||
// 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;
|
||||
|
||||
$html[] = $text;
|
||||
|
||||
$html[] = '</h3>';
|
||||
|
||||
// If a description is specified, use it to build a tooltip.
|
||||
if (!empty($this->description)) {
|
||||
$html[] = '<small>'.JText::_($this->description).'</small>';
|
||||
}
|
||||
|
||||
return implode('', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field title.
|
||||
*
|
||||
* @return string The field title
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getTitle()
|
||||
{
|
||||
return $this->getLabel();
|
||||
}
|
||||
}
|
||||
139
administrator/components/com_jce/models/fields/keyvalue.php
Normal file
139
administrator/components/com_jce/models/fields/keyvalue.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
class JFormFieldKeyValue extends JFormField
|
||||
{
|
||||
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 2.8
|
||||
*/
|
||||
protected $type = 'KeyValue';
|
||||
|
||||
/**
|
||||
* 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 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.8
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$values = $this->value;
|
||||
|
||||
if (is_string($values) && !empty($values)) {
|
||||
$value = htmlspecialchars_decode($this->value);
|
||||
|
||||
$values = json_decode($value, true);
|
||||
|
||||
if (empty($values) && strpos($value, ':') !== false && strpos($value, '{') === false) {
|
||||
$values = array();
|
||||
|
||||
foreach (explode(',', $value) as $item) {
|
||||
$pair = explode(':', $item);
|
||||
|
||||
array_walk($pair, function (&$val) {
|
||||
$val = trim($val, chr(0x22) . chr(0x27) . chr(0x38));
|
||||
});
|
||||
|
||||
$values[] = array(
|
||||
'name' => $pair[0],
|
||||
'value' => $pair[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default
|
||||
if (empty($values)) {
|
||||
$values = array(
|
||||
array(
|
||||
'name' => '',
|
||||
'value' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$subForm = new JForm($this->name, array('control' => $this->formControl));
|
||||
$children = $this->element->children();
|
||||
|
||||
$subForm->load($children);
|
||||
$subForm->setFields($children);
|
||||
|
||||
$fields = $subForm->getFieldset();
|
||||
|
||||
// And finaly build a main container
|
||||
$str = array();
|
||||
|
||||
foreach ($values as $value) {
|
||||
$str[] = '<div class="form-field-repeatable-item wf-keyvalue">';
|
||||
$str[] = ' <div class="form-field-repeatable-item-group well well-small p-4 bg-light">';
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$field->element['multiple'] = true;
|
||||
|
||||
$name = (string) $field->element['name'];
|
||||
|
||||
$val = is_array($value) && isset($value[$name]) ? $value[$name] : '';
|
||||
|
||||
// escape value
|
||||
$field->value = htmlspecialchars_decode($val);
|
||||
|
||||
$field->setup($field->element, $field->value, $this->group);
|
||||
|
||||
// reset id
|
||||
$field->id .= '_' . $n;
|
||||
|
||||
// reset name
|
||||
$field->name = $name;
|
||||
|
||||
$str[] = $field->renderField(array('description' => $field->description));
|
||||
|
||||
$n++;
|
||||
}
|
||||
|
||||
$str[] = ' </div>';
|
||||
|
||||
$str[] = ' <div class="form-field-repeatable-item-control">';
|
||||
$str[] = ' <button class="btn btn-link form-field-repeatable-add" aria-label="' . JText::_('JGLOBAL_FIELD_ADD') . '"><i class="icon icon-plus pull-right float-right"></i></button>';
|
||||
$str[] = ' <button class="btn btn-link form-field-repeatable-remove" aria-label="' . JText::_('JGLOBAL_FIELD_REMOVE') . '"><i class="icon icon-trash pull-right float-right"></i></button>';
|
||||
$str[] = ' </div>';
|
||||
|
||||
$str[] = '</div>';
|
||||
}
|
||||
|
||||
if (!empty($this->value)) {
|
||||
$this->value = htmlspecialchars(json_encode($values));
|
||||
}
|
||||
|
||||
$str[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" />';
|
||||
|
||||
return implode("", $str);
|
||||
}
|
||||
}
|
||||
109
administrator/components/com_jce/models/fields/mediajce.php
Normal file
109
administrator/components/com_jce/models/fields/mediajce.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package JCE
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @copyright Copyright (C) 2022 Ryan Demmer All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
use Joomla\CMS\Form\Field\MediaField;
|
||||
use Joomla\CMS\Helper\MediaHelper;
|
||||
|
||||
/**
|
||||
* Provides a modal media selector field for the JCE File Browser
|
||||
*
|
||||
* @since 2.6.17
|
||||
*/
|
||||
class JFormFieldMediaJce extends MediaField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'MediaJce';
|
||||
|
||||
/**
|
||||
* Layout to render
|
||||
*
|
||||
* @var string
|
||||
* @since 3.5
|
||||
*/
|
||||
protected $layout = 'joomla.form.field.media';
|
||||
|
||||
/**
|
||||
* 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()
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$result = parent::setup($element, $value, $group);
|
||||
|
||||
if ($result === true) {
|
||||
$this->mediatype = isset($this->element['mediatype']) ? (string) $this->element['mediatype'] : 'images';
|
||||
|
||||
// Joomla 4 custom layout
|
||||
if (isset($this->types)) {
|
||||
$this->layout = 'joomla.form.field.mediacustom';
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data that is going to be passed to the layout
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLayoutData()
|
||||
{
|
||||
require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php';
|
||||
|
||||
$config = array(
|
||||
'element' => $this->id,
|
||||
'mediatype' => strtolower($this->mediatype),
|
||||
'converted' => (int) $this->element['converted'] ? true : false
|
||||
);
|
||||
|
||||
if (isset($this->element['plugin'])) {
|
||||
$config['plugin'] = (string) $this->element['plugin'];
|
||||
}
|
||||
|
||||
$options = WFBrowserHelper::getMediaFieldOptions($config);
|
||||
|
||||
$this->link = $options['url'];
|
||||
|
||||
// Get the basic field data
|
||||
$data = parent::getLayoutData();
|
||||
|
||||
// not a valid file browser link
|
||||
if (!$this->link) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$extraData = array(
|
||||
'link' => $this->link,
|
||||
'class' => $this->element['class'] . ' input-medium wf-media-input wf-media-input-active'
|
||||
);
|
||||
|
||||
if ($options['upload'] == 1) {
|
||||
$extraData['class'] .= ' wf-media-input-upload';
|
||||
}
|
||||
|
||||
return array_merge($data, $extraData);
|
||||
}
|
||||
}
|
||||
116
administrator/components/com_jce/models/fields/plugin.php
Normal file
116
administrator/components/com_jce/models/fields/plugin.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
class JFormFieldPlugin extends JFormFieldFileList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Plugin';
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$value = $this->value;
|
||||
|
||||
// decode json string
|
||||
if (!empty($value) && is_string($value)) {
|
||||
$value = json_decode($value, true);
|
||||
}
|
||||
|
||||
// default
|
||||
if (empty($value)) {
|
||||
$type = $this->default;
|
||||
$path = '';
|
||||
}
|
||||
|
||||
$plugins = $this->getPlugins();
|
||||
|
||||
$html = '<div class="span9">';
|
||||
foreach ($plugins as $plugin) {
|
||||
$name = (string) str_replace($this->name.'-', '', $plugin->element);
|
||||
|
||||
$form = JForm::getInstance('plg_jce_'.$plugin->element, $plugin->manifest, array('control' => $this->name.'['.$name.']'), true, '//extension');
|
||||
|
||||
if ($form) {
|
||||
$html .= $form->renderFieldset('extension.'.$name.'.'.$name);
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getPlugins()
|
||||
{
|
||||
static $plugins;
|
||||
|
||||
if (!isset($plugins)) {
|
||||
$language = JFactory::getLanguage();
|
||||
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('name, element')
|
||||
->from('#__extensions')
|
||||
->where('enabled = 1')
|
||||
->where('type ='.$db->quote('plugin'))
|
||||
->where('state IN (0,1)')
|
||||
->where('folder = '.$db->quote('jce'))
|
||||
->where('element LIKE '.$db->quote($this->name.'-%'))
|
||||
->order('ordering');
|
||||
|
||||
$plugins = $db->setQuery($query)->loadObjectList();
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$name = str_replace($this->name, '', $plugin->element);
|
||||
|
||||
// load language file
|
||||
$language->load('plg_jce_'.$this->name.'_'.$name, JPATH_ADMINISTRATOR);
|
||||
|
||||
// create manifest path
|
||||
$plugin->manifest = JPATH_PLUGINS.'/jce/'.$plugin->element.'/'.$plugin->element.'.xml';
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
}
|
||||
44
administrator/components/com_jce/models/fields/popups.php
Normal file
44
administrator/components/com_jce/models/fields/popups.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldPopups extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'Popups';
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$extensions = JcePluginsHelper::getExtensions('popups');
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($extensions as $item) {
|
||||
$option = new StdClass;
|
||||
|
||||
$option->text = JText::_($item->title, true);
|
||||
$option->disable = '';
|
||||
$option->value = $item->name;
|
||||
|
||||
$options[] = $option;
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('ordering');
|
||||
|
||||
/**
|
||||
* Supports an HTML select list of plugins.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class JFormFieldProfileordering extends JFormFieldOrdering
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'Profileordering';
|
||||
|
||||
/**
|
||||
* Builds the query for the ordering list.
|
||||
*
|
||||
* @return JDatabaseQuery The query for the ordering form field
|
||||
*/
|
||||
protected function getQuery()
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Build the query for the ordering list.
|
||||
$query = $db->getQuery(true)
|
||||
->select(array($db->quoteName('ordering', 'value'), $db->quoteName('name', 'text'), $db->quote('id')))
|
||||
->from($db->quoteName('#__wf_profiles'))
|
||||
->order('ordering');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current Item's Id.
|
||||
*
|
||||
* @return int The current item ID
|
||||
*/
|
||||
protected function getItemId()
|
||||
{
|
||||
return (int) $this->form->getValue('id');
|
||||
}
|
||||
}
|
||||
111
administrator/components/com_jce/models/fields/repeatable.php
Normal file
111
administrator/components/com_jce/models/fields/repeatable.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JCE
|
||||
* @subpackage Component
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
|
||||
* @copyright Copyright (C) 2006 - 2020 Ryan Demmer. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Form Field class for the JCE.
|
||||
* Display a field with a repeatable set of defined sub fields
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
class JFormFieldRepeatable extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.7
|
||||
*/
|
||||
protected $type = 'Repeatable';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$subForm = new JForm($this->name, array('control' => $this->formControl));
|
||||
$children = $this->element->children();
|
||||
$subForm->load($children);
|
||||
$subForm->setFields($children);
|
||||
|
||||
// And finaly build a main container
|
||||
$str = array();
|
||||
|
||||
$values = $this->value;
|
||||
|
||||
// explode to array if string
|
||||
if (is_string($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
$fields = $subForm->getFieldset();
|
||||
|
||||
$str[] = '<div class="form-field-repeatable">';
|
||||
|
||||
foreach ($values as $value) {
|
||||
$class = '';
|
||||
|
||||
// highlight grouped fields
|
||||
if (count($fields) > 1) {
|
||||
$class = ' well well-small p-4 bg-light';
|
||||
}
|
||||
|
||||
$str[] = '<div class="form-field-repeatable-item">';
|
||||
$str[] = ' <div class="form-field-repeatable-item-group' . $class . '">';
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$field->element['multiple'] = true;
|
||||
|
||||
// substitute for repeatable element
|
||||
$field->element['name'] = (string) $this->element['name'];
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = isset($value[$n]) ? $value[$n] : $value[0];
|
||||
}
|
||||
|
||||
// escape value
|
||||
$field->value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
$field->setup($field->element, $field->value, $this->group);
|
||||
|
||||
// reset id
|
||||
$field->id .= '_' . $n;
|
||||
|
||||
if (strpos($field->name, '[]') === false) {
|
||||
$field->name .= '[]';
|
||||
}
|
||||
|
||||
$str[] = $field->renderField(array('description' => $field->description));
|
||||
|
||||
$n++;
|
||||
}
|
||||
|
||||
$str[] = ' </div>';
|
||||
|
||||
$str[] = ' <div class="form-field-repeatable-item-control">';
|
||||
$str[] = ' <button class="btn btn-link form-field-repeatable-add" aria-label="' . JText::_('JGLOBAL_FIELD_ADD') . '"><i class="icon icon-plus pull-right float-right"></i></button>';
|
||||
$str[] = ' <button class="btn btn-link form-field-repeatable-remove" aria-label="' . JText::_('JGLOBAL_FIELD_REMOVE') . '"><i class="icon icon-trash pull-right float-right"></i></button>';
|
||||
$str[] = ' </div>';
|
||||
|
||||
$str[] = '</div>';
|
||||
}
|
||||
|
||||
$str[] = '</div>';
|
||||
|
||||
return implode("", $str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('plugins');
|
||||
|
||||
class JFormFieldSearchPlugins extends JFormFieldPlugins
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'SearchPlugins';
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if (is_string($value) && strpos($value, ',') !== false)
|
||||
{
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
if ($return)
|
||||
{
|
||||
$this->folder = 'search';
|
||||
$this->useaccess = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options
|
||||
*
|
||||
* @since 11.4
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
$default = explode(',', $this->default);
|
||||
|
||||
foreach (parent::getOptions() as $item) {
|
||||
if (in_array($item->value, $default)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip "newsfeeds"
|
||||
if ($item->value == 'newsfeeds') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[] = $item;
|
||||
}
|
||||
|
||||
foreach ($default as $name) {
|
||||
if (!is_dir(JPATH_SITE . '/components/com_jce/editor/extensions/search/adapter/' . $name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$option = new StdClass;
|
||||
|
||||
$option->text = JText::_('PLG_SEARCH_' . strtoupper($name) . '_' . strtoupper($name), true);
|
||||
$option->disable = '';
|
||||
$option->value = $name;
|
||||
|
||||
$options[] = $option;
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
class JFormFieldSortableCheckboxes extends JFormFieldCheckboxes
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 2.8.16
|
||||
*/
|
||||
protected $type = 'SortableCheckboxes';
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 2.8.16
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
$this->class = trim($this->class . ' sortable');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function getOptionFromValue($value)
|
||||
{
|
||||
$options = parent::getOptions();
|
||||
|
||||
foreach($options as $option) {
|
||||
if ($option->value == $value) {
|
||||
return $option;
|
||||
}
|
||||
}
|
||||
|
||||
return (object) array(
|
||||
'value' => $value,
|
||||
'text' => $value
|
||||
);
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = parent::getOptions();
|
||||
|
||||
$values = is_array($this->value) ? $this->value : explode(',', $this->value);
|
||||
|
||||
if (!empty($values)) {
|
||||
$custom = array();
|
||||
|
||||
foreach ($values as $value) {
|
||||
$tmp = $this->getOptionFromValue($value);
|
||||
$tmp->checked = true;
|
||||
|
||||
$custom[] = $tmp;
|
||||
}
|
||||
|
||||
// add default options not checked to the end of the options array
|
||||
foreach($options as $option) {
|
||||
if (!in_array($option->value, $values)) {
|
||||
$custom[] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
return $custom;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
129
administrator/components/com_jce/models/fields/styleformat.php
Normal file
129
administrator/components/com_jce/models/fields/styleformat.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE is free software. This version may have been modified pursuant
|
||||
* to the GNU General Public License, and as distributed it includes or
|
||||
* is derivative of works licensed under the GNU General Public License or
|
||||
* other free or open source software licenses
|
||||
*/
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
/**
|
||||
* Renders a select element.
|
||||
*/
|
||||
class JFormFieldStyleFormat extends JFormField
|
||||
{
|
||||
/*
|
||||
* Element type
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'StyleFormat';
|
||||
|
||||
protected function getInput()
|
||||
{
|
||||
$wf = WFApplication::getInstance();
|
||||
|
||||
$output = array();
|
||||
|
||||
// default item list (remove "attributes" for now)
|
||||
$default = array('title' => '', 'element' => '', 'selector' => '', 'classes' => '', 'styles' => '', 'attributes' => '');
|
||||
|
||||
// pass to items
|
||||
$items = $this->value;
|
||||
|
||||
if (is_string($items)) {
|
||||
$items = json_decode(htmlspecialchars_decode($this->value), true);
|
||||
}
|
||||
|
||||
// cast to array
|
||||
$items = (array) $items;
|
||||
|
||||
/* Convert legacy styles */
|
||||
$theme_advanced_styles = $wf->getParam('editor.theme_advanced_styles', '');
|
||||
|
||||
if (!empty($theme_advanced_styles)) {
|
||||
foreach (explode(',', $theme_advanced_styles) as $styles) {
|
||||
$style = json_decode('{' . preg_replace('#([^=]+)=([^=]+)#', '"title":"$1","classes":"$2"', $styles) . '}', true);
|
||||
|
||||
if ($style) {
|
||||
$items[] = $style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create default array if no items
|
||||
if (empty($items)) {
|
||||
$items = array($default);
|
||||
}
|
||||
|
||||
$subForm = new JForm($this->name);
|
||||
|
||||
// editor manifest
|
||||
$manifest = JPATH_ADMINISTRATOR . '/components/com_jce/models/forms/styleformat.xml';
|
||||
$xml = simplexml_load_file($manifest);
|
||||
$subForm->load($xml);
|
||||
|
||||
$fields = $subForm->getFieldset();
|
||||
|
||||
$output[] = '<div class="styleformat-list">';
|
||||
|
||||
$x = 0;
|
||||
|
||||
foreach ($items as $item) {
|
||||
$elements = array('<div class="styleformat">');
|
||||
|
||||
foreach($fields as $field) {
|
||||
$key = (string) $field->element['name'];
|
||||
|
||||
// default value
|
||||
$field->value = "";
|
||||
|
||||
if (array_key_exists($key, $item)) {
|
||||
$field->value = htmlspecialchars_decode($item[$key], ENT_QUOTES);
|
||||
}
|
||||
|
||||
$field->setup($field->element, $field->value, $this->group);
|
||||
$field->id = '';
|
||||
$field->name = '';
|
||||
|
||||
$elements[] = '<div class="styleformat-item-' . $key . '" data-key="' . $key . '">' . $field->renderField(array('description' => $field->description)) . '</div>';
|
||||
}
|
||||
|
||||
$elements[] = '<div class="styleformat-header">';
|
||||
|
||||
// handle
|
||||
$elements[] = '<span class="styleformat-item-handle"></span>';
|
||||
// delete button
|
||||
$elements[] = '<button class="styleformat-item-trash btn btn-link pull-right float-right"><i class="icon icon-trash"></i></button>';
|
||||
// collapse
|
||||
$elements[] = '<button class="close collapse btn btn-link"><i class="icon icon-chevron-up"></i><i class="icon icon-chevron-down"></i></button>';
|
||||
|
||||
$elements[] = '</div>';
|
||||
|
||||
$elements[] = '</div>';
|
||||
|
||||
$output[] = implode('', $elements);
|
||||
|
||||
$x++;
|
||||
}
|
||||
|
||||
$output[] = '<button class="btn btn-link styleformat-item-plus"><span class="span10 col-md-10 text-left">' . JText::_('WF_STYLEFORMAT_NEW') . '</span><i class="icon icon-plus pull-right float-right"></i></button>';
|
||||
|
||||
// hidden field
|
||||
$output[] = '<input type="hidden" name="' . $this->name . '" value="" />';
|
||||
|
||||
if (!empty($theme_advanced_styles)) {
|
||||
$output[] = '<input type="hidden" name="' . $this->getName('theme_advanced_styles') . '" value="" class="isdirty" />';
|
||||
}
|
||||
|
||||
$output[] = '</div>';
|
||||
|
||||
return implode("\n", $output);
|
||||
}
|
||||
}
|
||||
68
administrator/components/com_jce/models/fields/taglist.php
Normal file
68
administrator/components/com_jce/models/fields/taglist.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldTagList extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public $type = 'TagList';
|
||||
|
||||
/**
|
||||
* Name of the layout being used to render the field
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
//protected $layout = 'joomla.form.field.tag';
|
||||
|
||||
/**
|
||||
* Method to get the field input for a tag field.
|
||||
*
|
||||
* @return string The field input.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
/*protected function getInput()
|
||||
{
|
||||
$data = $this->getLayoutData();
|
||||
|
||||
// Get the field id
|
||||
$id = isset($this->element['id']) ? $this->element['id'] : null;
|
||||
$cssId = '#' . $this->getId($id, $this->element['name']);
|
||||
|
||||
\JHtml::_('tag.ajaxfield', $cssId, true);
|
||||
|
||||
if (!\is_array($this->value) && !empty($this->value))
|
||||
{
|
||||
// String in format 2,5,4
|
||||
if (\is_string($this->value))
|
||||
{
|
||||
$this->value = explode(',', $this->value);
|
||||
}
|
||||
|
||||
// Integer is given
|
||||
if (\is_int($this->value))
|
||||
{
|
||||
$this->value = array($this->value);
|
||||
}
|
||||
|
||||
$data['value'] = $this->value;
|
||||
}
|
||||
|
||||
$data['remoteSearch'] = false;
|
||||
$data['options'] = $this->getOptions();
|
||||
$data['isNested'] = false;
|
||||
$data['allowCustom'] = true;
|
||||
$data['minTermLength'] = (int) 3;
|
||||
|
||||
return $this->getRenderer($this->layout)->render($data);
|
||||
}*/
|
||||
}
|
||||
128
administrator/components/com_jce/models/fields/uploadmaxsize.php
Normal file
128
administrator/components/com_jce/models/fields/uploadmaxsize.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('number');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Platform.
|
||||
* Supports a one line text field.
|
||||
*
|
||||
* @link http://www.w3.org/TR/html-markup/input.text.html#input.text
|
||||
* @since 11.1
|
||||
*/
|
||||
class JFormFieldUploadMaxSize extends JFormFieldNumber
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'uploadmaxsize';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$this->max = (int) $this->getUploadValue();
|
||||
$this->class = trim($this->class.' input-small');
|
||||
|
||||
$html = '<div class="input-append input-group">';
|
||||
|
||||
$html .= parent::getInput();
|
||||
$html .= ' <div class="input-group-append">';
|
||||
$html .= ' <span class="add-on input-group-text">Kb</span>';
|
||||
$html .= ' </div>';
|
||||
$html .= ' <small class="help-inline form-text"> <em>'.JText::_('WF_SERVER_UPLOAD_SIZE').' : '.$this->getUploadValue().'</em></small>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getUploadValue()
|
||||
{
|
||||
$upload = trim(ini_get('upload_max_filesize'));
|
||||
$post = trim(ini_get('post_max_size'));
|
||||
|
||||
$upload = $this->convertValue($upload);
|
||||
$post = $this->convertValue($post);
|
||||
|
||||
if (intval($post) === 0) {
|
||||
return $upload;
|
||||
}
|
||||
|
||||
if (intval($upload) < intval($post)) {
|
||||
return $upload;
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
public function convertValue($value)
|
||||
{
|
||||
$unit = 'KB';
|
||||
$prefix = '';
|
||||
|
||||
preg_match('#([0-9]+)\s?([a-z]*)#i', $value, $matches);
|
||||
|
||||
// get unit
|
||||
if (isset($matches[2])) {
|
||||
$prefix = $matches[2];
|
||||
|
||||
// extract first character only, eg: g, m, k
|
||||
if ($prefix) {
|
||||
$prefix = strtolower($prefix[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// get value
|
||||
if (isset($matches[1])) {
|
||||
$value = (int) $matches[1];
|
||||
}
|
||||
|
||||
$value = intval($value);
|
||||
|
||||
// Convert to bytes
|
||||
switch ($prefix) {
|
||||
case 'g':
|
||||
$value *= 1073741824;
|
||||
break;
|
||||
case 'm':
|
||||
$value *= 1048576;
|
||||
break;
|
||||
case 'k':
|
||||
$value *= 1024;
|
||||
break;
|
||||
}
|
||||
|
||||
// Convert to unit value
|
||||
switch (strtolower($unit[0])) {
|
||||
case 'g':
|
||||
$value /= 1073741824;
|
||||
break;
|
||||
case 'm':
|
||||
$value /= 1048576;
|
||||
break;
|
||||
case 'k':
|
||||
$value /= 1024;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($unit) {
|
||||
return (int) $value . ' ' . $unit;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
123
administrator/components/com_jce/models/fields/users.php
Normal file
123
administrator/components/com_jce/models/fields/users.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
/**
|
||||
* Field to select a user ID from a modal list.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
class JFormFieldUsers extends JFormFieldUser
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.7
|
||||
*/
|
||||
public $type = 'Users';
|
||||
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
|
||||
$options = $this->getOptions();
|
||||
|
||||
$name = $this->name;
|
||||
|
||||
// clear name
|
||||
$this->name = "";
|
||||
|
||||
// set onchange to update
|
||||
$this->onchange = "(function(){WfSelectUsers();})();";
|
||||
|
||||
// remove autocomplete
|
||||
$this->autocomplete = false;
|
||||
|
||||
// clear value
|
||||
$this->value = "";
|
||||
|
||||
$html = $this->getRenderer($this->layout)->render($this->getLayoutData());
|
||||
$html .= '<div class="users-select">';
|
||||
|
||||
// add "joomla-field-fancy-select" manually for Joomla 4
|
||||
$html .= '<joomla-field-fancy-select placeholder="...">';
|
||||
$html .= '<select name="' . $name . '" id="' . $this->id . '_select" class="custom-select" data-placeholder="..." multiple>';
|
||||
|
||||
foreach ($options as $option) {
|
||||
$html .= '<option value="' . $option->value . '" selected>' . $option->text . '</option>';
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
$html .= '</joomla-field-fancy-select>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to override renderer include paths in child fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return array(JPATH_ADMINISTRATOR . '/components/com_jce/layouts', JPATH_SITE . '/layouts');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
if (empty($this->value)) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
$fieldname = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname);
|
||||
$table = JTable::getInstance('user');
|
||||
|
||||
// clean value
|
||||
$this->value = str_replace('"', '', $this->value);
|
||||
|
||||
foreach (explode(',', $this->value) as $id) {
|
||||
if (empty($id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($table->load((int) $id)) {
|
||||
$text = htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8');
|
||||
$text = JText::alt($text, $fieldname);
|
||||
|
||||
$tmp = array(
|
||||
'value' => $id,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
// Add the option object to the result set.
|
||||
$options[] = (object) $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
39
administrator/components/com_jce/models/fields/yesno.php
Normal file
39
administrator/components/com_jce/models/fields/yesno.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('radio');
|
||||
|
||||
class JFormFieldYesNo extends JFormFieldRadio
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected $type = 'YesNo';
|
||||
|
||||
/**
|
||||
* 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 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 bool True on success
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
$this->class = trim($this->class.' btn-group btn-group-yesno');
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user