first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?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_PLATFORM') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/browser.php';
class JceModelBrowser extends JModelLegacy
{
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$filter = $app->input->getCmd('filter', '');
$url = WfBrowserHelper::getBrowserLink(null, $filter);
if (empty($url)) {
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->redirect('index.php?option=com_jce');
}
$this->setState('url', $url);
}
}

View File

@@ -0,0 +1,214 @@
<?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_PLATFORM') or die;
// load base model
jimport('joomla.application.component.modelform');
class JceModelConfig extends JModelForm
{
/**
* Returns a Table object, always creating it.
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional
* @param array $config Configuration array for model. Optional
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Extension', $prefix = 'JTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a form object.
*
* @param array $data Data for the form
* @param bool $loadData True if the form is to load its own data (default case), false if not
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jce.config', 'config', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_jce.config.data', array());
if (empty($data)) {
$data = $this->getData();
}
$this->preprocessData('com_jce.config', $data);
return $data;
}
/* Override to prevent plugins from processing form data */
protected function preprocessData($context, &$data, $group = 'system')
{
if (!isset($data->params)) {
return;
}
$config = $data->params;
if (is_string($config)) {
$config = json_decode($config, true);
}
if (empty($config)) {
return;
}
if (!empty($config['custom_config'])) {
// settings syntax, eg: key:value
if (is_string($config['custom_config']) && strpos($config['custom_config'], ':') !== false) {
if (!WFUtility::isJson($config['custom_config'])) {
$values = explode(';', $config['custom_config']);
// reset as array
$config['custom_config'] = array();
foreach ($values as $value) {
list($key, $val) = explode(':', $value);
$config['custom_config'][] = array(
'name' => $key,
'value' => trim($val, " \t\n\r\0\x0B'\""),
);
}
}
}
}
$data->params = $config;
}
/**
* Method to get the configuration data.
*
* This method will load the global configuration data straight from
* JConfig. If configuration data has been saved in the session, that
* data will be merged into the original data, overwriting it.
*
* @return array An array containg all global config data
*
* @since 1.6
*/
public function getData()
{
$table = $this->getTable();
$id = $table->find(array(
'type' => 'plugin',
'element' => 'jce',
'folder' => 'editors',
));
if (!$table->load($id)) {
$this->setError($table->getError());
return false;
}
// json_decode
$json = json_decode($table->params, true);
if (empty($json)) {
$json = array();
}
array_walk($json, function (&$value, $key) {
if (is_numeric($value)) {
$value = $value + 0;
}
});
$data = new StdClass;
$data->params = $json;
return $data;
}
/**
* Method to save the form data.
*
* @param array The form data
*
* @return bool True on success
*
* @since 2.7
*/
public function save($data)
{
$table = $this->getTable();
$id = $table->find(array(
'type' => 'plugin',
'element' => 'jce',
'folder' => 'editors',
));
if (!$id) {
$this->setError('Invalid plugin');
return false;
}
// Load the previous Data
if (!$table->load($id)) {
$this->setError($table->getError());
return false;
}
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
return true;
}
}

View File

@@ -0,0 +1,128 @@
<?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_PLATFORM') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_jce/includes/constants.php';
class JceModelCpanel extends JModelLegacy
{
public function getIcons()
{
$user = JFactory::getUser();
$icons = array();
$views = array(
'config' => 'equalizer',
'profiles' => 'users',
'browser' => 'picture',
'mediabox' => 'pictures',
);
foreach ($views as $name => $icon) {
// if its mediabox, check the plugin is installed and enabled
if ($name === "mediabox" && !JPluginHelper::isEnabled('system', 'jcemediabox')) {
continue;
}
// check if its allowed...
if (!$user->authorise('jce.' . $name, 'com_jce')) {
continue;
}
$link = 'index.php?option=com_jce&amp;view=' . $name;
$title = JText::_('WF_' . strtoupper($name));
if ($name === "browser") {
if (!JPluginHelper::isEnabled('quickicon', 'jce')) {
continue;
}
$title = JText::_('WF_' . strtoupper($name) . '_TITLE');
}
$icons[] = '<li class="quickicon mb-3"><a title="' . JText::_('WF_' . strtoupper($name) . '_DESC') . '" href="' . $link . '" class="btn btn-default" role="button"><div class="quickicon-icon d-flex align-items-end" role="presentation"><span class="fa fa-' . $icon . ' icon-' . $icon . '" aria-hidden="true" role="presentation"></span></div><div class="quickicon-text d-flex align-items-center"><span class="j-links-link">' . $title . '</span></div></a></li>';
}
return $icons;
}
public function getFeeds()
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_jce');
$limit = $params->get('feed_limit', 2);
$feeds = array();
$options = array(
'rssUrl' => 'https://www.joomlacontenteditor.net/news?format=feed',
);
$xml = simplexml_load_file($options['rssUrl']);
if (empty($xml)) {
return $feeds;
}
jimport('joomla.filter.input');
$filter = JFilterInput::getInstance();
$count = count($xml->channel->item);
if ($count) {
$count = ($count > $limit) ? $limit : $count;
for ($i = 0; $i < $count; ++$i) {
$feed = new StdClass();
$item = $xml->channel->item[$i];
$link = (string) $item->link;
$feed->link = htmlspecialchars($filter->clean($link));
$title = (string) $item->title;
$feed->title = htmlspecialchars($filter->clean($title));
$description = (string) $item->description;
$feed->description = htmlspecialchars($filter->clean($description));
$feeds[] = $feed;
}
}
return $feeds;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$licence = "";
$version = "";
if ($xml = simplexml_load_file(JPATH_ADMINISTRATOR . '/components/com_jce/jce.xml')) {
$licence = (string) $xml->license;
$version = (string) $xml->version;
if (WF_EDITOR_PRO) {
$version = '<span class="badge badge-info badge-primary bg-primary">Pro</span>&nbsp;' . $version;
}
}
$this->setState('version', $version);
$this->setState('licence', $licence);
}
}

View File

@@ -0,0 +1,63 @@
<?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_PLATFORM') or die;
class WFModelEditor extends JObject
{
private static $editor;
public function buildEditor()
{
if (!isset(self::$editor)) {
self::$editor = new WFEditor();
}
$settings = self::$editor->getEditorSettings();
return self::$editor->render($settings);
}
public function getEditorSettings()
{
if (!isset(self::$editor)) {
self::$editor = new WFEditor();
}
return self::$editor->getEditorSettings();
}
public function render($settings = array())
{
if (!isset(self::$editor)) {
self::$editor = new WFEditor();
}
if (empty($settings)) {
$settings = self::$editor->getEditorSettings();
}
self::$editor->render($settings);
$document = JFactory::getDocument();
foreach (self::$editor->getScripts() as $script) {
$document->addScript($script, array('version' => 'auto'), array('defer' => 'defer'));
}
foreach (self::$editor->getStyleSheets() as $style) {
$document->addStylesheet($style, array('version' => 'auto'));
}
$script = "document.addEventListener('DOMContentLoaded',function handler(){" . implode("", self::$editor->getScriptDeclaration()) . ";this.removeEventListener('DOMContentLoaded',handler);});";
$document->addScriptDeclaration($script);
}
}

View File

@@ -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;
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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);
}
}

View 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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,10 @@
<?php
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('filetype');
class JFormFieldExtension extends JFormFieldFiletype
{
}

View 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;
}
}

View 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>&nbsp;' . $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);
}
}

View 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();
}
}

View 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);
}
}

View 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();
}
}

View 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);
}
}

View 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);
}
}

View 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;
}
}

View 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);
}
}

View File

@@ -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');
}
}

View 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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View 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);
}
}

View 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);
}*/
}

View 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">&nbsp;<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;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="config" label="Global Configuration">
<field name="verify_html" type="radio" default="1" label="WF_PARAM_CLEANUP" description="WF_PARAM_CLEANUP_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="schema" type="list" default="mixed" label="WF_PARAM_DOCTYPE" description="WF_PARAM_DOCTYPE_DESC">
<option value="html4">HTML4</option>
<option value="mixed">WF_PARAM_DOCTYPE_MIXED</option>
<option value="html5">HTML5</option>
</field>
<field name="entity_encoding" type="list" default="raw" label="WF_PARAM_ENTITY_ENCODING" description="WF_PARAM_ENTITY_ENCODING_DESC">
<option value="raw">UTF-8</option>
<option value="named">WF_PARAM_NAMED</option>
<option value="numeric">WF_PARAM_NUMERIC</option>
</field>
<field name="keep_nbsp" type="radio" default="1" label="WF_PARAM_KEEP_NBSP" description="WF_PARAM_KEEP_NBSP_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="pad_empty_tags" type="radio" default="1" label="WF_PARAM_PAD_EMPTY_TAGS" description="WF_PARAM_PAD_EMPTY_TAGS_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="spacer1" type="spacer" hr="true" />
<field name="forced_root_block" type="list" default="p" label="WF_PARAM_ROOT_BLOCK" description="WF_PARAM_ROOT_BLOCK_DESC">
<option value="p">WF_OPTION_PARAGRAPH</option>
<option value="div">WF_OPTION_DIV</option>
<option value="forced_root_block:p|force_block_newlines:0">WF_OPTION_PARAGRAPH_LINEBREAK</option>
<option value="forced_root_block:div|force_block_newlines:0">WF_OPTION_DIV_LINEBREAK</option>
<option value="forced_root_block:0|force_block_newlines:1">WF_OPTION_PARAGRAPH_MIXED</option>
<option value="0">WF_OPTION_LINEBREAK</option>
</field>
<field name="content_style_reset" type="list" default="auto" label="WF_PARAM_EDITOR_STYLE_RESET" description="WF_PARAM_EDITOR_STYLE_RESET_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
<option value="auto">WF_OPTION_AUTO</option>
</field>
<field name="content_css" type="list" default="1" label="WF_PARAM_EDITOR_GLOBAL_CSS" description="WF_PARAM_EDITOR_GLOBAL_CSS_DESC" filter="integer">
<option value="0">WF_PARAM_CSS_CUSTOM</option>
<option value="1">WF_PARAM_CSS_TEMPLATE</option>
<option value="2">WF_OPTION_DEFAULT</option>
</field>
<field name="content_css_custom" type="repeatable" default="" label="WF_PARAM_CSS_CUSTOM" description="WF_PARAM_CSS_CUSTOM_DESC" showon="content_css:0">
<field type="text" size="50" hiddenLabel="true" hint="eg: templates/$template/css/content.css" />
</field>
<!--field name="content_css_custom" type="textarea" rows="2" class="input-xlarge" default="" hint="eg: templates/$template/css/content.css" label="WF_PARAM_CSS_CUSTOM" description="WF_PARAM_CSS_CUSTOM_DESC" showon="content_css:0" /-->
<field name="body_class" type="text" default="" placeholder="eg: content" label="WF_PARAM_EDITOR_BODY_CLASS" description="WF_PARAM_EDITOR_BODY_CLASS_DESC" />
<field name="spacer2" type="spacer" hr="true" />
<field name="compress_javascript" type="radio" default="0" label="WF_PARAM_COMPRESS_JAVASCRIPT" description="WF_PARAM_COMPRESS_JAVASCRIPT_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="compress_css" type="radio" default="0" label="WF_PARAM_COMPRESS_CSS" description="WF_PARAM_COMPRESS_CSS_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="compress_cache_validation" type="radio" default="1" label="WF_PARAM_COMPRESS_CACHE_VALIDATION" description="WF_PARAM_COMPRESS_CACHE_VALIDATION_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="spacer3" type="spacer" hr="true" />
<field name="use_cookies" type="radio" default="1" label="WF_PARAM_USE_COOKIES" description="WF_PARAM_USE_COOKIES_DESC" class="btn-group btn-group-yesno" filter="integer">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="custom_config" type="keyvalue" default="" label="WF_PARAM_CUSTOM_CONFIG" description="WF_PARAM_CUSTOM_CONFIG_DESC">
<field type="text" name="name" label="WF_PROFILES_CUSTOM_KEY" />
<field type="text" name="value" label="WF_PROFILES_CUSTOM_VALUE" />
</field>
</fieldset>
</fields>
</form>

View File

@@ -0,0 +1,224 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="editor">
<fieldset name="editor.features" addfieldpath="/administrator/components/com_categories/models/fields">
<field name="width" type="text" size="5" default="" placeholder="auto" label="WF_PARAM_EDITOR_WIDTH" description="WF_PARAM_EDITOR_WIDTH_DESC" />
<field name="height" type="text" size="5" default="" placeholder="auto" label="WF_PARAM_EDITOR_HEIGHT" description="WF_PARAM_EDITOR_HEIGHT_DESC" />
<field name="toolbar_theme" type="list" default="modern" label="WF_PARAM_EDITOR_TOOLBAR_THEME" description="WF_PARAM_EDITOR_TOOLBAR_THEME_DESC">
<option value="modern">WF_PARAM_EDITOR_SKIN_RETINA</option>
<option value="modern.touch">WF_PARAM_EDITOR_SKIN_RETINA_TOUCH</option>
<!--option value="modern.dark">WF_PARAM_EDITOR_SKIN_RETINA_DARK</option-->
<option value="default">WF_PARAM_EDITOR_SKIN_CLASSIC</option>
<option value="default.touch">WF_PARAM_EDITOR_SKIN_CLASSIC_TOUCH</option>
<option value="o2k7">WF_PARAM_EDITOR_SKIN_OFFICE_BLUE</option>
<option value="o2k7.silver">WF_PARAM_EDITOR_SKIN_OFFICE_SILVER</option>
<option value="o2k7.black">WF_PARAM_EDITOR_SKIN_OFFICE_BLACK</option>
</field>
<field name="toolbar_align" type="list" default="left" label="WF_PARAM_EDITOR_TOOLBAR_ALIGN" description="WF_PARAM_EDITOR_TOOLBAR_ALIGN_DESC">
<option value="left">WF_OPTION_LEFT</option>
<option value="center">WF_OPTION_CENTER</option>
<option value="right">WF_OPTION_RIGHT</option>
</field>
<field name="toolbar_location" type="list" default="top" label="WF_PARAM_EDITOR_TOOLBAR_LOCATION" description="WF_PARAM_EDITOR_TOOLBAR_LOCATION_DESC">
<option value="top">WF_OPTION_TOP</option>
<option value="bottom">WF_OPTION_BOTTOM</option>
</field>
<field name="statusbar_location" type="list" default="bottom" label="WF_PARAM_EDITOR_STATUSBAR_LOCATION" description="WF_PARAM_EDITOR_STATUSBAR_LOCATION_DESC">
<option value="top">WF_OPTION_TOP</option>
<option value="bottom">WF_OPTION_BOTTOM</option>
<option value="none">JNONE</option>
</field>
<field name="path" type="yesno" default="1" label="WF_PARAM_EDITOR_PATH" description="WF_PARAM_EDITOR_PATH_DESC" showon="statusbar_location:top[OR]statusbar_location:bottom">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="resizing" type="list" default="1" label="WF_PARAM_EDITOR_RESIZING" description="WF_PARAM_EDITOR_RESIZING_DESC" showon="statusbar_location:top[OR]statusbar_location:bottom">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="resize_horizontal" type="yesno" default="1" label="WF_PARAM_EDITOR_RESIZE_HORIZONTAL" description="WF_PARAM_EDITOR_RESIZE_HORIZONTAL_DESC" showon="resizing:1">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="active_tab" type="list" default="wysiwyg" label="WF_PARAM_EDITOR_ACTIVE_TAB" description="WF_PARAM_EDITOR_ACTIVE_TAB_DESC">
<option value="wysiwyg">WF_PARAM_EDITOR_ACTIVE_TAB_WYSIWYG</option>
<option value="source">WF_PARAM_EDITOR_ACTIVE_TAB_CODE</option>
<option value="preview">WF_PARAM_EDITOR_ACTIVE_TAB_PREVIEW</option>
</field>
</fieldset>
<fieldset name="editor.setup">
<field name="convert_urls" type="list" default="relative" label="WF_PARAM_EDITOR_CONVERT_URLS" description="WF_PARAM_EDITOR_CONVERT_URLS_DESC">
<option value="none">WF_OPTION_NONE</option>
<option value="relative">WF_OPTION_RELATIVE</option>
<option value="absolute">WF_OPTION_ABSOLUTE</option>
</field>
<field name="verify_html" type="list" default="" label="WF_PARAM_CLEANUP" description="WF_PARAM_EDITOR_PROFILE_CLEANUP_DESC" class="btn-group btn-group-yesno">
<option value="">WF_OPTION_INHERIT</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="schema" type="list" default="" label="WF_PARAM_DOCTYPE" description="WF_PARAM_EDITOR_PROFILE_DOCTYPE_DESC">
<option value="">WF_OPTION_INHERIT</option>
<option value="mixed">WF_PARAM_DOCTYPE_MIXED</option>
<option value="html4">HTML4</option>
<option value="html5">HTML5</option>
</field>
</fieldset>
<fieldset name="editor.typography">
<field name="forced_root_block" type="list" default="" label="WF_PARAM_ROOT_BLOCK" description="WF_PARAM_EDITOR_PROFILE_ROOT_BLOCK_DESC">
<option value="">WF_OPTION_INHERIT</option>
<option value="p">WF_OPTION_PARAGRAPH</option>
<option value="div">WF_OPTION_DIV</option>
<option value="forced_root_block:p|force_block_newlines:0">WF_OPTION_PARAGRAPH_LINEBREAK</option>
<option value="forced_root_block:div|force_block_newlines:0">WF_OPTION_DIV_LINEBREAK</option>
<option value="forced_root_block:0|force_block_newlines:1">WF_OPTION_PARAGRAPH_MIXED</option>
<option value="0">WF_OPTION_LINEBREAK</option>
</field>
<field name="profile_content_css" type="list" default="2" label="WF_PARAM_EDITOR_PROFILE_CSS" description="WF_PARAM_EDITOR_PROFILE_CSS_DESC">
<option value="0">WF_PARAM_CSS_ADD</option>
<option value="1">WF_PARAM_CSS_OVERWRITE</option>
<option value="2">WF_PARAM_CSS_INHERIT</option>
</field>
<field name="profile_content_css_custom" type="repeatable" default="" label="WF_PARAM_CSS_CUSTOM" description="WF_PARAM_CSS_CUSTOM_DESC" showon="profile_content_css:0[OR]profile_content_css:1">
<field type="text" size="50" hiddenLabel="true" hint="eg: templates/$template/css/content.css" />
</field>
<field name="custom_colors" type="textarea" rows="3" cols="50" default="" label="WF_PARAM_CUSTOM_COLORS" description="WF_PARAM_CUSTOM_COLORS_DESC" placeholder="eg: #CC0000,#FF0000" />
</fieldset>
<fieldset name="editor.filesystem">
<field name="dir" type="text" default="" size="50" placeholder="images" label="WF_PARAM_DIRECTORY" description="WF_PARAM_DIRECTORY_DESC"/>
<field name="dir_filter" type="repeatable" default="" label="WF_PARAM_DIRECTORY_FILTER" description="WF_PARAM_DIRECTORY_FILTER_DESC">
<field type="text" size="50" hiddenLabel="true" />
</field>
<field name="filesystem" type="filesystem" default="joomla" label="WF_PARAM_FILESYSTEM" description="WF_PARAM_FILESYSTEM_DESC" />
<field name="max_size" class="input-small" hint="1024" max="" type="uploadmaxsize" step="128" default="" label="WF_PARAM_UPLOAD_SIZE" description="WF_PARAM_UPLOAD_SIZE_DESC" />
<field name="upload_conflict" type="list" default="overwrite" label="WF_PARAM_UPLOAD_EXISTS" description="WF_PARAM_UPLOAD_EXISTS_DESC">
<option value="unique">WF_PARAM_UPLOAD_EXISTS_UNIQUE</option>
<option value="overwrite">WF_PARAM_UPLOAD_EXISTS_OVERWRITE</option>
</field>
<field name="upload_suffix" placeholder="_copy" max="" type="text" default="" label="WF_PARAM_UPLOAD_SUFFIX" description="WF_PARAM_UPLOAD_SUFFIX_DESC" showon="upload_conflict:unique" />
<field name="browser_position" type="list" default="bottom" label="WF_PARAM_BROWSER_POSITION" description="WF_PARAM_BROWSER_POSITION_DESC">
<option value="top">WF_LABEL_TOP</option>
<option value="bottom">WF_LABEL_BOTTOM</option>
</field>
<field name="folder_tree" type="yesno" default="1" label="WF_PARAM_FOLDER_TREE" description="WF_PARAM_FOLDER_TREE_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="list_limit" type="list" default="all" label="WF_PARAM_LIST_LIMIT" description="WF_PARAM_LIST_LIMIT_DESC">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="all">WF_OPTION_ALL</option>
</field>
<field name="validate_mimetype" type="yesno" default="1" label="WF_PARAM_VALIDATE_MIMETYPE" description="WF_PARAM_VALIDATE_MIMETYPE_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="websafe_mode" type="list" default="utf-8" label="WF_PARAM_WEBSAFE_MODE" description="WF_PARAM_WEBSAFE_MODE_DESC">
<option value="utf-8">UTF-8</option>
<option value="ascii">ASCII</option>
</field>
<field name="websafe_allow_spaces" type="list" default="_" label="WF_PARAM_WEBSAFE_ALLOW_SPACES" description="WF_PARAM_WEBSAFE_ALLOW_SPACES_DESC">
<option value="1">JYES</option>
<option value="_">WF_OPTION_WEBSAFE_ALLOW_SPACES_UNDERSCORE</option>
<option value="-">WF_OPTION_WEBSAFE_ALLOW_SPACES_DASH</option>
<option value=".">WF_OPTION_WEBSAFE_ALLOW_SPACES_PERIOD</option>
</field>
<field name="websafe_textcase" type="checkboxes" multiple="multiple" default="uppercase,lowercase" label="WF_PARAM_WEBSAFE_TEXTCASE" description="WF_PARAM_WEBSAFE_TEXTCASE_DESC">
<option value="uppercase">WF_OPTION_UPPERCASE</option>
<option value="lowercase">WF_OPTION_LOWERCASE</option>
</field>
<field name="upload_add_random" type="yesno" default="0" label="WF_PARAM_UPLOAD_ADD_RANDOM" description="WF_PARAM_UPLOAD_ADD_RANDOM_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="date_format" type="text" default="" hint="eg: %d/%m/%Y, %H:%M" label="WF_PARAM_DATE_FORMAT" description="WF_PARAM_DATE_FORMAT_DESC" />
<field name="total_files" type="number" default="" class="input-small" step="1" label="WF_PARAM_TOTAL_FILES_LIMIT" description="WF_PARAM_TOTAL_FILES_LIMIT_DESC" />
<field name="total_size" type="number" default="" class="input-small" step="1" label="WF_PARAM_TOTAL_FILES_SIZE_LIMIT" description="WF_PARAM_TOTAL_FILES_SIZE_LIMIT_DESC" />
</fieldset>
<fieldset name="editor.advanced">
<field type="container" label="WF_PARAM_STARTUP_CONTENT" description="WF_PARAM_STARTUP_CONTENT_DESC">
<field type="mediajce" name="startup_content_url" size="30" mediatype="html,htm,txt,md" default="" label="WF_PARAM_STARTUP_CONTENT_URL" description="WF_PARAM_STARTUP_CONTENT_URL_DESC" />
<field type="spacer" label="WF_LABEL_OR" />
<field type="textarea" name="startup_content_html" filter="html" rows="2" cols="3" class="input-xlarge" default="" label="WF_PARAM_STARTUP_CONTENT_HTML" spellcheck="false" description="WF_PARAM_STARTUP_CONTENT_HTML_DESC" />
</field>
<field type="spacer" />
<field name="invalid_elements" type="text" size="50" default="" label="WF_PARAM_NO_ELEMENTS" description="WF_PARAM_NO_ELEMENTS_DESC" />
<field name="invalid_attributes" type="text" size="50" default="dynsrc,lowsrc" label="WF_PARAM_INVALID_ATTRIBUTES" description="WF_PARAM_INVALID_ATTRIBUTES_DESC" />
<field name="invalid_attribute_values" type="text" size="50" default="" label="WF_PARAM_INVALID_ATTRIBUTE_VALUES" description="WF_PARAM_INVALID_ATTRIBUTE_VALUES_DESC" />
<field name="extended_elements" type="textarea" rows="2" cols="46" default="" label="WF_PARAM_ELEMENTS" description="WF_PARAM_ELEMENTS_DESC" />
<field name="validate_styles" type="yesno" default="1" label="WF_PARAM_VALIDATE_STYLES" description="WF_PARAM_VALIDATE_STYLES_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field type="container" class="alert alert-warning p-4 bg-light" label="WF_PARAM_CODE_BLOCKS" description="WF_PARAM_CODE_BLOCKS_DESC_WARNING">
<field name="code_blocks" type="yesno" default="1" label="WF_PARAM_CODE_BLOCKS_ENABLE" description="WF_PARAM_CODE_BLOCKS_ENABLE_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="allow_javascript" type="yesno" default="0" label="WF_PARAM_JAVASCRIPT" description="WF_PARAM_JAVASCRIPT_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="allow_css" type="yesno" default="0" label="WF_PARAM_CSS" description="WF_PARAM_CSS_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="allow_php" type="yesno" default="0" label="WF_PARAM_PHP" description="WF_PARAM_PHP_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="allow_custom_xml" type="yesno" default="0" label="WF_PARAM_ALLOW_CUSTOM_XML" description="WF_PARAM_ALLOW_CUSTOM_XML_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</field>
<field name="protect_shortcode" type="yesno" default="0" label="WF_PARAM_PROTECT_SHORTCODE" description="WF_PARAM_PROTECT_SHORTCODE_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="allow_event_attributes" type="yesno" default="0" label="WF_PARAM_ALLOW_EVENT_ATTRIBUTES" description="WF_PARAM_ALLOW_EVENT_ATTRIBUTES_DESC" showon="allow_javascript:0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field type="spacer" hr="true" />
<field name="wordcount_limit" type="number" default="0" label="WF_PARAM_WORDCOUNT_LIMIT" description="WF_PARAM_WORDCOUNT_LIMIT_DESC" class="input-small" />
<field name="wordcount_alert" type="yesno" default="0" label="WF_PARAM_WORDCOUNT_ALERT" description="WF_PARAM_WORDCOUNT_ALERT_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field type="spacer" hr="true" />
<field name="object_resizing" type="yesno" default="1" label="WF_PARAM_OBJECT_RESIZING" description="WF_PARAM_OBJECT_RESIZING_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>

View File

@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_jce/models/fields" />
<fields name="filter">
<field
name="search"
type="text"
label="COM_PLUGINS_FILTER_SEARCH_LABEL"
description="COM_PLUGINS_SEARCH_IN_TITLE"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="JOPTION_SELECT_PUBLISHED"
description="JOPTION_SELECT_PUBLISHED_DESC"
onchange="this.form.submit();"
filter="0,1"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="area"
type="list"
label="WF_PROFILES_AREA"
description="WF_PROFILES_AREA_DESC"
onchange="this.form.submit();"
>
<option value="">WF_PROFILES_AREA_FILTER_SELECT</option>
<option value="1">WF_PROFILES_AREA_FRONTEND</option>
<option value="2">WF_PROFILES_AREA_BACKEND</option>
</field>
<field
name="device"
type="list"
label="WF_PROFILES_DEVICE"
description="WF_PROFILES_DEVICE_DESC"
onchange="this.form.submit();"
>
<option value="">WF_PROFILES_DEVICE_FILTER_SELECT</option>
<option value="phone">WF_PROFILES_DEVICE_PHONE</option>
<option value="tablet">WF_PROFILES_DEVICE_TABLET</option>
<option value="desktop">WF_PROFILES_DEVICE_DESKTOP</option>
</field>
<field
name="components"
type="components"
label="WF_PROFILES_COMPONENTS"
description="WF_PROFILES_COMPONENTS_DESC"
onchange="this.form.submit();"
>
<option value="">WF_PROFILES_COMPONENTS_FILTER_SELECT</option>
</field>
<field
name="usergroups"
type="usergrouplist"
label="WF_PROFILES_GROUPS"
description="WF_PROFILES_GROUPS_DESC"
onchange="this.form.submit();"
>
<option value="">WF_PROFILES_GROUPS_FILTER_SELECT</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="folder ASC"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="published ASC">JSTATUS_ASC</option>
<option value="published DESC">JSTATUS_DESC</option>
<option value="name ASC">JGLOBAL_TITLE_ASC</option>
<option value="name DESC">JGLOBAL_TITLE_DESC</option>
<option value="id ASC">JGRID_HEADING_ID_ASC</option>
<option value="id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields>
<fieldset name="setup">
<field name="name" type="text" class="input-xxlarge input-large-text" size="40" label="JGLOBAL_TITLE" description="WF_PROFILES_NAME_DESC" required="true" />
<field name="description" type="text" class="input-xxlarge" label="JGLOBAL_DESCRIPTION" description="WF_PROFILES_DESCRIPTION_DESC" />
<field name="published" type="radio" label="JSTATUS" description="WF_PROFILES_ENABLED_DESC" class="btn-group btn-group-yesno" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="ordering" type="Profileordering" label="JFIELD_ORDERING_LABEL" description="JFIELD_ORDERING_DESC"/>
<field name="id" type="hidden" default="0" />
</fieldset>
<fieldset name="assignment" addfieldpath="/administrator/components/com_categories/models/fields">
<field name="area" type="checkboxes" multiple="multiple" class="inline" label="WF_PROFILES_AREA" description="WF_PROFILES_AREA_DESC" checked="1,2">
<option value="1">WF_PROFILES_AREA_FRONTEND</option>
<option value="2">WF_PROFILES_AREA_BACKEND</option>
</field>
<field name="device" type="checkboxes" multiple="multiple" class="inline" label="WF_PROFILES_DEVICE" description="WF_PROFILES_DEVICE_DESC" checked="desktop,tablet,phone">
<option value="phone">WF_PROFILES_DEVICE_PHONE</option>
<option value="tablet">WF_PROFILES_DEVICE_TABLET</option>
<option value="desktop">WF_PROFILES_DEVICE_DESKTOP</option>
</field>
<field name="components_select" type="radio" label="WF_PROFILES_COMPONENTS" description="WF_PROFILES_COMPONENTS_DESC" class="extensions-select" default="0">
<option value="0">WF_PROFILES_COMPONENTS_ALL</option>
<option value="1">WF_PROFILES_COMPONENTS_SELECT</option>
</field>
<field name="components" type="components" multiple="multiple" label="" layout="joomla.form.field.list-fancy-select" />
<field name="types" type="usergrouplist" multiple="multiple" label="WF_PROFILES_GROUPS" description="WF_PROFILES_GROUPS_DESC" layout="joomla.form.field.list-fancy-select" />
<field name="users" type="users" multiple="multiple" label="WF_PROFILES_USERS" description="WF_PROFILES_USERS_DESC" />
</fieldset>
</fields>
<fields name="config"></fields>
</form>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields>
<fieldset>
<field name="title" type="text" default="" hint="WF_STYLEFORMAT_TITLE" label="" hiddenLabel="true" />
<field name="element" type="groupedlist" default="" label="WF_STYLEFORMAT_ELEMENT" description="WF_STYLEFORMAT_ELEMENT_DESC">
<option value="" selected="selected">WF_OPTION_SELECTED_ELEMENT</option>
<group label="WF_OPTION_SECTION_ELEMENTS">
<option value="section">section</option>
<option value="nav">nav</option>
<option value="article">article</option>
<option value="aside">aside</option>
<option value="h1">h1</option>
<option value="h2">h2</option>
<option value="h3">h3</option>
<option value="h4">h4</option>
<option value="h5">h5</option>
<option value="h6">h6</option>
<option value="header">header</option>
<option value="footer">footer</option>
<option value="address">address</option>
<option value="main">main</option>
</group>
<group label="WF_OPTION_GROUPING_ELEMENTS">
<option value="p">p</option>
<option value="pre">pre</option>
<option value="blockquote">blockquote</option>
<option value="figure">figure</option>
<option value="figcaption">figcaption</option>
<option value="div">div</option>
</group>
<group label="WF_OPTION_TEXT_LEVEL_ELEMENTS">
<option value="a">a</option>
<option value="em">em</option>
<option value="strong">strong</option>
<option value="small">small</option>
<option value="s">s</option>
<option value="cite">cite</option>
<option value="q">q</option>
<option value="dfn">dfn</option>
<option value="abbr">abbr</option>
<option value="data">data</option>
<option value="time">time</option>
<option value="code">code</option>
<option value="var">var</option>
<option value="samp">samp</option>
<option value="kbd">kbd</option>
<option value="sub">sub</option>
<option value="i">i</option>
<option value="b">b</option>
<option value="u">u</option>
<option value="mark">mark</option>
<option value="ruby">ruby</option>
<option value="rt">rt</option>
<option value="rp">rp</option>
<option value="bdi">bdi</option>
<option value="bdo">bdo</option>
<option value="span">span</option>
<option value="wbr">wbr</option>
</group>
<group label="WF_OPTION_FORM_ELEMENTS">
<option value="form">form</option>
<option value="input">input</option>
<option value="button">button</option>
<option value="fieldset">fieldset</option>
<option value="legend">legend</option>
</group>
</field>
<field name="styles" type="text" default="" label="WF_STYLEFORMAT_STYLES" description="WF_STYLEFORMAT_STYLES_DESC" />
<field name="attributes" type="text" default="" label="WF_STYLEFORMAT_ATTRIBUTES" description="WF_STYLEFORMAT_ATTRIBUTES_DESC" />
<field name="selector" type="text" default="" label="WF_STYLEFORMAT_SELECTOR" description="WF_STYLEFORMAT_SELECTOR_DESC" />
<field name="classes" type="text" default="" label="WF_STYLEFORMAT_CLASSES" description="WF_STYLEFORMAT_CLASSES_DESC" />
</fieldset>
</fields>
</form>

View File

@@ -0,0 +1,138 @@
<?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_PLATFORM') or die;
class JceModelHelp extends JModelLegacy
{
public function getLanguage()
{
$language = JFactory::getLanguage();
$tag = $language->getTag();
return substr($tag, 0, strpos($tag, '-'));
}
public function getTopics($file)
{
$result = '';
if (file_exists($file)) {
// load xml
$xml = simplexml_load_file($file);
if ($xml) {
foreach ($xml->help->children() as $topic) {
$subtopics = $topic->subtopic;
$class = count($subtopics) ? 'subtopics' : '';
$key = (string) $topic->attributes()->key;
$title = (string) $topic->attributes()->title;
$file = (string) $topic->attributes()->file;
// if file attribute load file
if ($file) {
$result .= $this->getTopics(JPATH_SITE . '/components/com_jce/editor/' . $file);
} else {
$result .= '<li id="' . $key . '" class="nav-item ' . $class . '"><a href="#" class="nav-link"><i class="icon-copy"></i>&nbsp;' . trim(JText::_($title)) . '</a>';
}
if (count($subtopics)) {
$result .= '<ul class="nav nav-list hidden">';
foreach ($subtopics as $subtopic) {
$sub_subtopics = $subtopic->subtopic;
// if a file is set load it as sub-subtopics
if ($file = (string) $subtopic->attributes()->file) {
$result .= '<li class="nav-item subtopics"><a href="#" class="nav-link"><i class="icon-file"></i>&nbsp;' . trim(JText::_((string) $subtopic->attributes()->title)) . '</a>';
$result .= '<ul class="nav nav-list hidden">';
$result .= $this->getTopics(JPATH_SITE . '/components/com_jce/editor/' . $file);
$result .= '</ul>';
$result .= '</li>';
} else {
$id = $subtopic->attributes()->key ? ' id="' . (string) $subtopic->attributes()->key . '"' : '';
$class = count($sub_subtopics) ? ' class="nav-item subtopics"' : '';
$result .= '<li' . $class . $id . '><a href="#" class="nav-link"><i class="icon-file"></i>&nbsp;' . trim(JText::_((string) $subtopic->attributes()->title)) . '</a>';
if (count($sub_subtopics)) {
$result .= '<ul class="nav nav-list hidden">';
foreach ($sub_subtopics as $sub_subtopic) {
$result .= '<li id="' . (string) $sub_subtopic->attributes()->key . '" class="nav-item"><a href="#" class="nav-link"><i class="icon-file"></i>&nbsp;' . trim(JText::_((string) $sub_subtopic->attributes()->title)) . '</a></li>';
}
$result .= '</ul>';
}
$result .= '</li>';
}
}
$result .= '</ul>';
}
}
}
}
return $result;
}
/**
* Returns a formatted list of help topics.
*
* @return string
*
* @since 1.5
*/
public function renderTopics()
{
$app = JFactory::getApplication();
$section = $app->input->getWord('section', 'admin');
$category = $app->input->getWord('category', 'cpanel');
$document = JFactory::getDocument();
$language = JFactory::getLanguage();
$language->load('com_jce', JPATH_SITE);
$language->load('com_jce_pro', JPATH_SITE);
$document->setTitle(JText::_('WF_HELP') . ' : ' . JText::_('WF_' . strtoupper($category) . '_TITLE'));
switch ($section) {
case 'admin':
$file = __DIR__ . '/' . $category . '.xml';
break;
case 'editor':
$file = JPATH_SITE . '/components/com_jce/editor/tiny_mce/plugins/' . $category . '/' . $category . '.xml';
// check for installed plugin
$plugin = JPluginHelper::getPlugin('jce', 'editor-' . $category);
if ($plugin) {
$file = JPATH_PLUGINS . '/jce/editor-' . $category . '/editor-' . $category . '.xml';
$language->load('plg_jce_editor_' . $category, JPATH_ADMINISTRATOR);
}
if (!is_file($file)) {
$file = JPATH_SITE . '/components/com_jce/editor/libraries/xml/help/editor.xml';
} else {
$language->load('WF_' . $category, JPATH_SITE);
}
break;
}
$result = '';
$result .= '<ul class="nav nav-list" id="help-menu"><li class="nav-header">' . JText::_('WF_' . strtoupper($category) . '_TITLE') . '</li>';
$result .= $this->getTopics($file);
$result .= '</ul>';
return $result;
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<help>
<topic key="admin.about" title="WF_HELP_ADMINISTRATION" />
<topic key="admin.interface" title="WF_HELP_INTERFACE" />
</help>

View File

@@ -0,0 +1,164 @@
<?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_PLATFORM') or die;
// load base model
jimport('joomla.application.component.modelform');
use Joomla\Utilities\ArrayHelper;
class JceModelMediabox extends JModelForm
{
/**
* Returns a Table object, always creating it.
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional
* @param array $config Configuration array for model. Optional
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Extension', $prefix = 'JTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get a form object.
*
* @param array $data Data for the form
* @param bool $loadData True if the form is to load its own data (default case), false if not
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
JForm::addFormPath(JPATH_PLUGINS . '/system/jcemediabox');
JFactory::getLanguage()->load('plg_system_jcemediabox', JPATH_ADMINISTRATOR);
JFactory::getLanguage()->load('plg_system_jcemediabox', JPATH_PLUGINS . '/system/jcemediabox');
// Get the form.
$form = $this->loadForm('com_jce.mediabox', 'jcemediabox', array('control' => 'jform', 'load_data' => $loadData), true, '//config');
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_jce.mediabox.plugin.data', array());
if (empty($data)) {
$data = $this->getData();
}
return $data;
}
/**
* Method to get the configuration data.
*
* This method will load the global configuration data straight from
* JConfig. If configuration data has been saved in the session, that
* data will be merged into the original data, overwriting it.
*
* @return array An array containg all global config data
*
* @since 1.6
*/
public function getData()
{
// Get the editor data
$plugin = JPluginHelper::getPlugin('system', 'jcemediabox');
// json_decode
$json = json_decode($plugin->params, true);
array_walk($json, function(&$value, $key) {
if (is_numeric($value)) {
$value = $value + 0;
}
});
$data = new StdClass;
$data->params = $json;
return $data;
}
/**
* Method to save the form data.
*
* @param array The form data
*
* @return bool True on success
*
* @since 2.7
*/
public function save($data)
{
$table = $this->getTable();
$id = $table->find(array(
'type' => 'plugin',
'element' => 'jcemediabox',
'folder' => 'system'
));
if (!$id) {
$this->setError('Invalid plugin');
return false;
}
// Load the previous Data
if (!$table->load($id))
{
$this->setError($table->getError());
return false;
}
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
return true;
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<mediabox>
<help>
<topic key="admin.mediabox.config" title="WF_MEDIABOX_HELP_CONFIG" />
</help>
</mediabox>

View File

@@ -0,0 +1,904 @@
<?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_PLATFORM') or die;
require JPATH_SITE . '/components/com_jce/editor/libraries/classes/editor.php';
require JPATH_ADMINISTRATOR . '/components/com_jce/helpers/plugins.php';
require JPATH_ADMINISTRATOR . '/components/com_jce/helpers/profiles.php';
/**
* Item Model for a Profile.
*
* @since 1.6
*/
class JceModelProfile extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
*
* @since 3.2
*/
public $typeAlias = 'com_jce.profile';
/**
* The prefix to use with controller messages.
*
* @var string
*
* @since 1.6
*/
protected $text_prefix = 'COM_JCE';
/**
* Returns a Table object, always creating it.
*
* @param type $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional
* @param array $config Configuration array for model. Optional
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Profiles', $prefix = 'JceTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/* Override to prevent plugins from processing form data */
protected function preprocessData($context, &$data, $group = 'system')
{
if (!isset($data->config)) {
return;
}
$config = $data->config;
if (is_string($config)) {
$config = json_decode($config, true);
}
if (empty($config)) {
return;
}
// editor parameters
if (isset($config['editor'])) {
if (!empty($config['editor']['toolbar_theme']) && $config['editor']['toolbar_theme'] === 'mobile') {
$config['editor']['toolbar_theme'] = 'default.touch';
}
if (isset($config['editor']['relative_urls']) && !isset($config['editor']['convert_urls'])) {
$config['editor']['convert_urls'] = $config['editor']['relative_urls'] == 0 ? 'absolute' : 'relative';
}
}
// decode config values for display
array_walk_recursive($config, function(&$value) {
$value = htmlspecialchars_decode($value);
});
$data->config = $config;
}
/**
* Method to allow derived classes to preprocess the form.
*
* @param JForm $form A JForm object
* @param mixed $data The data expected for the form
* @param string $group The name of the plugin group to import (defaults to "content")
*
* @see JFormField
* @since 1.6
*
* @throws Exception if there is an error in the form event
*/
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
if (!empty($data)) {
$registry = new JRegistry($data->config);
// process individual fields to remove default value if required
$fields = $form->getFieldset();
foreach ($fields as $field) {
$name = $field->getAttribute('name');
// get the field group and add the field name
$group = (string) $field->group;
// must be a grouped parameter, eg: editor, imgmanager etc.
if (!$group) {
continue;
}
// create key from group and name
$group = $group . '.' . $name;
// explode group to array
$parts = explode('.', $group);
// remove "config" from group name so it matches params data object
if ($parts[0] === "config") {
array_shift($parts);
$group = implode('.', $parts);
}
// reset the "default" attribute value if a value is set
if ($registry->exists($group)) {
$form->setFieldAttribute($name, 'default', '', (string) $field->group);
}
}
}
// allow plugins to process form, eg: MediaField etc.
parent::preprocessForm($form, $data);
}
public function getForm($data = array(), $loadData = true)
{
JFormHelper::addFieldPath('JPATH_ADMINISTRATOR/components/com_jce/models/fields');
// Get the setup form.
$form = $this->loadForm('com_jce.profile', 'profile', array('control' => 'jform', 'load_data' => false));
if (!$form) {
return false;
}
JFactory::getLanguage()->load('com_jce_pro', JPATH_SITE);
// editor manifest
$manifest = __DIR__ . '/forms/editor.xml';
// load editor manifest
if (is_file($manifest)) {
if ($editor_xml = simplexml_load_file($manifest)) {
$form->setField($editor_xml, 'config');
}
}
// pro manifest
$manifest = WF_EDITOR_LIBRARIES . '/pro/xml/pro.xml';
// load pro manifest
if (is_file($manifest)) {
if ($pro_xml = simplexml_load_file($manifest)) {
$form->setField($pro_xml, 'config');
}
}
$data = $this->loadFormData();
// Allow for additional modification of the form, and events to be triggered.
// We pass the data because plugins may require it.
$this->preprocessForm($form, $data);
// Load the data into the form after the plugins have operated.
$form->bind($data);
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form
*
* @since 1.6
*/
protected function loadFormData()
{
$data = $this->getItem();
// convert 0 value to null to force defaults
if (empty($data->area)) {
$data->area = null;
}
// convert to array if set
if (!empty($data->device)) {
$data->device = explode(',', $data->device);
}
if (!empty($data->components)) {
$data->components = explode(',', $data->components);
$data->components_select = 1;
}
$data->types = explode(',', $data->types);
$data->config = $data->params;
$this->preprocessData('com_jce.profiles', $data);
return $data;
}
public function getRows()
{
$data = $this->getItem();
$array = array();
$rows = explode(';', $data->rows);
$plugins = $this->getButtons();
$i = 1;
foreach ($rows as $row) {
$groups = array();
// remove spacers
$row = str_replace(array('|', 'spacer'), '', $row);
foreach (explode('spacer', $row) as $group) {
// get items in group
$items = explode(',', $group);
$buttons = array();
// remove duplicates
$items = array_unique($items);
foreach ($items as $x => $item) {
if ($item === 'spacer') {
unset($items[$x]);
continue;
}
// not in the list...
if (empty($item) || array_key_exists($item, $plugins) === false) {
continue;
}
// must be assigned...
if (!$plugins[$item]->active) {
continue;
}
// assign icon
$buttons[] = $plugins[$item];
}
$groups[] = $buttons;
}
$array[$i] = $groups;
++$i;
}
return $array;
}
/**
* An array of buttons not in the current editor layout.
*
* @return array
*/
public function getAvailableButtons()
{
$plugins = $this->getButtons();
$available = array_filter($plugins, function ($plugin) {
return !$plugin->active;
});
return $available;
}
public function getAdditionalPlugins()
{
$plugins = $this->getButtons();
$additional = array_filter($plugins, function ($plugin) {
return $plugin->editable && !$plugin->row;
});
return $additional;
}
public function getButtons()
{
$commands = $this->getCommands();
$plugins = $this->getPlugins();
return array_merge($commands, $plugins);
}
public function getCommands()
{
static $commands;
if (empty($commands)) {
$data = $this->getItem();
$rows = preg_split('#[;,]#', $data->rows);
$commands = array();
foreach (JcePluginsHelper::getCommands() as $name => $command) {
// set as active
$command->active = in_array($name, $rows);
$command->icon = explode(',', $command->icon);
// set default empty value
$command->image = '';
// ui class, default is blank
if (empty($command->class)) {
$command->class = '';
}
// cast row to integer
$command->row = (int) $command->row;
// cast editable to integer
$command->editable = (int) $command->editable;
// translate title
$command->title = JText::_($command->title);
// translate description
$command->description = JText::_($command->description);
$command->name = $name;
$commands[$name] = $command;
}
}
// merge plugins and commands
return $commands;
}
public function getPlugins()
{
static $plugins;
if (empty($plugins)) {
$plugins = array();
$data = $this->loadFormData();
// array or profile plugin items
$rows = explode(',', $data->plugins);
// remove duplicates
$rows = array_unique($rows);
$extensions = JcePluginsHelper::getExtensions();
// only need plugins with xml files
foreach (JcePluginsHelper::getPlugins() as $name => $plugin) {
$plugin->icon = empty($plugin->icon) ? array() : explode(',', $plugin->icon);
// set as active if it is in the profile
$plugin->active = in_array($plugin->name, $rows);
// ui class, default is blank
if (empty($plugin->class)) {
$plugin->class = '';
}
$plugin->class = preg_replace_callback('#\b([a-z0-9]+)-([a-z0-9]+)\b#', function ($matches) {
return 'mce' . ucfirst($matches[1]) . ucfirst($matches[2]);
}, $plugin->class);
// translate title
$plugin->title = JText::_($plugin->title);
// translate description
$plugin->description = JText::_($plugin->description);
// cast row to integer
$plugin->row = (int) $plugin->row;
// cast editable to integer
$plugin->editable = (int) $plugin->editable;
// plugin extensions
$plugin->extensions = array();
if (is_file($plugin->manifest)) {
$plugin->form = $this->loadForm('com_jce.profile.' . $plugin->name, $plugin->manifest, array('control' => 'jform[config]', 'load_data' => true), true, '//extension');
$plugin->formclass = 'options-grid-form options-grid-form-full';
$fieldsets = $plugin->form->getFieldsets();
// no parameter fields
if (empty($fieldsets)) {
$plugin->form = false;
$plugins[$name] = $plugin;
continue;
}
// bind data to the form
$plugin->form->bind($data->params);
foreach ($extensions as $type => $items) {
$item = new StdClass;
$item->name = '';
$item->title = '';
$item->manifest = WF_EDITOR_LIBRARIES . '/xml/config/' . $type . '.xml';
$item->context = '';
array_unshift($items, $item);
foreach ($items as $p) {
// check for plugin fieldset using xpath, as fieldset can be empty
$fieldset = $plugin->form->getXml()->xpath('(//fieldset[@name="plugin.' . $type . '"])');
// not supported, move along...
if (empty($fieldset)) {
continue;
}
$context = (string) $fieldset[0]->attributes()->context;
// check for a context, eg: images, web, video
if ($context && !in_array($p->context, explode(',', $context))) {
continue;
}
if (is_file($p->manifest)) {
$path = array($plugin->name, $type, $p->name);
// create new extension object
$extension = new StdClass;
// set extension name as the plugin name
$extension->name = $p->name;
// set extension title
$extension->title = $p->title;
// load form
$extension->form = $this->loadForm('com_jce.profile.' . implode('.', $path), $p->manifest, array('control' => 'jform[config][' . $plugin->name . '][' . $type . ']', 'load_data' => true), true, '//extension');
$extension->formclass = 'options-grid-form options-grid-form-full';
// get fieldsets if any
$fieldsets = $extension->form->getFieldsets();
foreach ($fieldsets as $fieldset) {
// load form
$plugin->extensions[$type][$p->name] = $extension;
if (!isset($data->params[$plugin->name])) {
continue;
}
if (!isset($data->params[$plugin->name][$type])) {
continue;
}
// bind data to the form
$extension->form->bind($data->params[$plugin->name][$type]);
}
}
}
}
}
// add to array
$plugins[$name] = $plugin;
}
}
return $plugins;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable $table A reference to a JTable object
*
* @since 1.6
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
foreach ($table->getProperties() as $key => $value) {
switch ($key) {
case 'name':
case 'description':
$value = filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
break;
case 'device':
$value = implode(',', filter_var_array($value, FILTER_SANITIZE_STRING));
break;
case 'area':
if (is_array($value)) {
// remove empty value
$value = array_filter($value, 'strlen');
// for simplicity, set multiple area selections as "0"
if (count($value) > 1) {
$value = 0;
} else {
$value = $value[0];
}
}
$value = $value;
break;
case 'components':
if (is_array($value)) {
$value = implode(',', filter_var_array($value, FILTER_SANITIZE_STRING));
}
break;
case 'types':
case 'users':
if (is_string($value)) {
$value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
}
if (is_array($value)) {
$value = implode(',', filter_var_array($value, FILTER_SANITIZE_NUMBER_INT));
}
break;
case 'plugins':
$value = preg_replace('#[^\w,]+#', '', $value);
break;
case 'rows':
$value = preg_replace('#[^\w,;]+#', '', $value);
break;
case 'params':
break;
}
$table->$key = $value;
}
if (empty($table->id)) {
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering)')
->from($db->quoteName('#__wf_profiles'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
}
public function validate($form, $data, $group = null)
{
$filter = JFilterInput::getInstance();
// get unfiltered config data
$config = isset($data['config']) ? $data['config'] : array();
// get layout rows and plugins data
$rows = isset($data['rows']) ? $data['rows'] : '';
$plugins = isset($data['plugins']) ? $data['plugins'] : '';
// clean layout rows and plugins data
$data['rows'] = $filter->clean($rows, 'STRING');
$data['plugins'] = $filter->clean($plugins, 'STRING');
// add back config data
$data['params'] = $filter->clean($config, 'ARRAY');
if (empty($data['components']) || empty($data['components_select'])) {
$data['components'] = '';
}
if (empty($data['users'])) {
$data['users'] = '';
}
if (empty($data['types'])) {
$data['types'] = '';
}
return $data;
}
private static function cleanParamData($data)
{
// clean up link plugin parameters
array_walk($data, function(&$params, $plugin) {
if ($plugin === "link") {
if (isset($params['dir'])) {
if (!empty($params['dir']) && empty($params['direction'])) {
$params['direction'] = $params['dir'];
}
unset($params['dir']);
}
}
if (is_array($params) && WFUtility::is_associative_array($params)) {
array_walk($params, function(&$value, $key) {
if (is_string($value) && WFUtility::isJson($value)) {
$value = json_decode($value, true);
}
});
}
});
return $data;
}
/**
* Method to save the form data.
*
* @param array The form data
*
* @return bool True on success
*
* @since 2.7
*/
public function save($data)
{
$app = JFactory::getApplication();
// get profile table
$table = $this->getTable();
// Alter the title for save as copy
if ($app->input->get('task') == 'save2copy') {
// Alter the title
$name = $data['name'];
while ($table->load(array('name' => $name))) {
if ($name == $table->name) {
$name = Joomla\String\StringHelper::increment($name);
}
}
$data['name'] = $name;
$data['published'] = 0;
}
$key = $table->getKeyName();
$pk = (!empty($data[$key])) ? $data[$key] : (int) $this->getState($this->getName() . '.id');
if ($pk && $table->load($pk)) {
if (empty($data['rows'])) {
$data['rows'] = $table->rows;
}
if (empty($data['plugins'])) {
$data['plugins'] = $table->plugins;
}
$json = array();
$params = empty($table->params) ? '' : $table->params;
// convert params to json data array
$params = (array) json_decode($params, true);
$plugins = isset($data['plugins']) ? $data['plugins'] : $table->plugins;
// get plugins
$items = explode(',', $plugins);
// add "editor"
$items[] = 'editor';
// make sure we have a value
if (empty($data['params'])) {
$data['params'] = array();
}
$data['params'] = self::cleanParamData($data['params']);
// data for editor and plugins
foreach ($items as $item) {
// add config data
if (array_key_exists($item, $data['params'])) {
$value = $data['params'][$item];
// clean and add to json array for merging
$json[$item] = filter_var_array($value, FILTER_SANITIZE_SPECIAL_CHARS);
}
}
// merge and encode as json string
$data['params'] = json_encode(WFUtility::array_merge_recursive_distinct($params, $json));
}
// set a default value for validation
if (empty($data['params'])) {
$data['params'] = '{}';
}
if (parent::save($data)) {
return true;
}
return false;
}
public function copy($ids)
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$table = $this->getTable();
foreach ($ids as $id) {
if (!$table->load($id)) {
$this->setError($table->getError());
} else {
$name = JText::sprintf('WF_PROFILES_COPY_OF', $table->name);
$table->name = $name;
$table->id = 0;
$table->published = 0;
}
// Check the row.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the row.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
}
return true;
}
public function export($ids)
{
$db = JFactory::getDBO();
$buffer = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
$buffer .= "\n" . '<export type="profiles">';
$buffer .= "\n\t" . '<profiles>';
$validFields = array('name', 'description', 'users', 'types', 'components', 'area', 'device', 'rows', 'plugins', 'published', 'ordering', 'params');
foreach ($ids as $id) {
$table = $this->getTable();
if (!$table->load($id)) {
continue;
}
$buffer .= "\n\t\t";
$buffer .= '<profile>';
$fields = $table->getProperties();
foreach ($fields as $key => $value) {
// only allow a subset of fields
if (false == in_array($key, $validFields)) {
continue;
}
// set published to 0
if ($key === "published") {
$value = 0;
}
if ($key == 'params') {
$buffer .= "\n\t\t\t" . '<' . $key . '><![CDATA[' . trim($value) . ']]></' . $key . '>';
} else {
$buffer .= "\n\t\t\t" . '<' . $key . '>' . JceProfilesHelper::encodeData($value) . '</' . $key . '>';
}
}
$buffer .= "\n\t\t</profile>";
}
$buffer .= "\n\t</profiles>";
$buffer .= "\n</export>";
// set_time_limit doesn't work in safe mode
if (!ini_get('safe_mode')) {
@set_time_limit(0);
}
$name = 'jce_editor_profile_' . date('Y_m_d') . '.xml';
$app = JFactory::getApplication();
$app->allowCache(false);
$app->setHeader('Content-Transfer-Encoding', 'binary');
$app->setHeader('Content-Type', 'text/xml');
$app->setHeader('Content-Disposition', 'attachment;filename="' . $name . '";');
// set output content
$app->setBody($buffer);
// stream to client
echo $app->toString();
jexit();
}
/**
* Process XML restore file.
*
* @param object $xml
*
* @return bool
*/
public function import()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
jimport('joomla.filesystem.file');
$app = JFactory::getApplication();
$tmp = $app->getCfg('tmp_path');
jimport('joomla.filesystem.file');
$file = $app->input->files->get('profile_file', null, 'raw');
// check for valid uploaded file
if (empty($file) || !is_uploaded_file($file['tmp_name'])) {
$app->enqueueMessage(JText::_('WF_PROFILES_UPLOAD_NOFILE'), 'error');
return false;
}
if ($file['error'] || $file['size'] < 1) {
$app->enqueueMessage(JText::_('WF_PROFILES_UPLOAD_NOFILE'), 'error');
return false;
}
// sanitize the file name
$name = JFile::makeSafe($file['name']);
if (empty($name)) {
$app->enqueueMessage(JText::_('WF_PROFILES_IMPORT_ERROR'), 'error');
return false;
}
// Build the appropriate paths.
$config = JFactory::getConfig();
$destination = $config->get('tmp_path') . '/' . $name;
$source = $file['tmp_name'];
// Move uploaded file.
JFile::upload($source, $destination, false, true);
if (!is_file($destination)) {
$app->enqueueMessage(JText::_('WF_PROFILES_UPLOAD_FAILED'), 'error');
return false;
}
$result = JceProfilesHelper::processImport($destination);
if ($result === false) {
$app->enqueueMessage(JText::_('WF_PROFILES_IMPORT_ERROR'), 'error');
return false;
}
$app->enqueueMessage(JText::sprintf('WF_PROFILES_IMPORT_SUCCESS', $result));
return true;
}
}

View File

@@ -0,0 +1,266 @@
<?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_PLATFORM') or die;
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/profiles.php';
class JceModelProfiles extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JControllerLegacy
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'id',
'name', 'name',
'checked_out', 'checked_out',
'checked_out_time', 'checked_out_time',
'published', 'published',
'ordering', 'ordering'
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @note Calling getState in this method will result in recursion.
* @since 1.6
*/
protected function populateState($ordering = 'id', $direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_jce');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.components');
return parent::getStoreId($id);
}
/**
* Method to get an array of data items.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
$items = parent::getItems();
// Filter by device
$device = $this->getState('filter.device');
// Filter by component
$components = $this->getState('filter.components');
// Filter by user groups
$usergroups = $this->getState('filter.usergroups');
$items = array_filter($items, function($item) use ($device, $components, $usergroups) {
$state = true;
if ($device) {
$state = in_array($device, explode(',', $item->device));
}
if ($components) {
$state = in_array($components, explode(',', $item->components));
}
if ($usergroups) {
$state = in_array($usergroups, explode(',', $item->types));
}
return $state;
});
// Get a storage key.
$store = $this->getStoreId();
// update cache store
$this->cache[$store] = $items;
return $items;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = JFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'*'
)
);
$query->from($db->quoteName('#__wf_profiles'));
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where($db->quoteName('published') . ' = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(' . $db->quoteName('published') . ' = 0 OR ' . $db->quoteName('published') . ' = 1)');
}
// Filter by area
$area = (int) $this->getState('filter.area');
if ($area)
{
$query->where($db->quoteName('area') . ' = ' . (int) $area);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where($db->quoteName('id') . ' = ' . (int) substr($search, 3));
} else {
$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
$query->where('(' . $db->quoteName('name') . ' LIKE ' . $search . ' OR ' . $db->quoteName('description') . ' LIKE ' . $search . ')');
}
}
// Add the list ordering clause.
$listOrder = $this->getState('list.ordering', 'ordering');
$listDirn = $this->getState('list.direction', 'ASC');
$query->order($db->escape($listOrder . ' ' . $listDirn));
return $query;
}
public function repair()
{
$file = __DIR__ . '/profiles.xml';
if (!is_file($file)) {
$this->setError(JText::_('WF_PROFILES_REPAIR_ERROR'));
return false;
}
$xml = simplexml_load_file($file);
if (!$xml) {
$this->setError(JText::_('WF_PROFILES_REPAIR_ERROR'));
return false;
}
foreach ($xml->profiles->children() as $profile) {
$groups = JceProfilesHelper::getUserGroups((int) $profile->children('area'));
$table = JTable::getInstance('Profiles', 'JceTable');
foreach ($profile->children() as $item) {
switch ((string) $item->getName()) {
case 'description':
$table->description = JText::_((string) $item);
case 'types':
$table->types = implode(',', $groups);
break;
case 'area':
$table->area = (int) $item;
break;
case 'rows':
$table->rows = (string) $item;
break;
case 'plugins':
$table->plugins = (string) $item;
break;
default:
$key = $item->getName();
$table->$key = (string) $item;
break;
}
}
// default
$table->checked_out = 0;
$table->checked_out_time = '0000-00-00 00:00:00';
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<profiles>
<help>
<topic key="admin.profiles.about" title="WF_PROFILES_HELP_ABOUT" />
<topic key="admin.profiles.manage" title="WF_PROFILES_HELP_MANAGE">
<subtopic key="admin.profiles.manage.copy" title="WF_PROFILES_HELP_MANAGE_COPY" />
<subtopic key="admin.profiles.manage.delete" title="WF_PROFILES_HELP_MANAGE_DELETE" />
<subtopic key="admin.profiles.manage.export" title="WF_PROFILES_HELP_MANAGE_EXPORT" />
<subtopic key="admin.profiles.manage.import" title="WF_PROFILES_HELP_MANAGE_IMPORT" />
<subtopic key="admin.profiles.manage.ordering" title="WF_PROFILES_HELP_MANAGE_ORDERING" />
<subtopic key="admin.profiles.manage.enable" title="WF_PROFILES_HELP_MANAGE_ENABLE" />
</topic>
<topic key="admin.profiles.edit" title="WF_PROFILES_HELP_EDIT">
<subtopic key="admin.profiles.edit.setup" title="WF_PROFILES_HELP_EDIT_SETUP" />
<subtopic key="admin.profiles.edit.features" title="WF_PROFILES_HELP_EDIT_FEATURES" />
<subtopic key="admin.profiles.edit.editor" title="WF_PROFILES_HELP_EDIT_EDITOR" />
<subtopic key="admin.profiles.edit.plugins" title="WF_PROFILES_HELP_EDIT_PLUGINS" />
<subtopic key="admin.profiles.edit.widgets" title="WF_PROFILES_HELP_EDIT_WIDGETS" />
</topic>
</help>
<profiles>
<profile name="Default" default="default">
<name>Default</name>
<description>WF_PROFILES_DEFAULT_DESC</description>
<users></users>
<types></types>
<components></components>
<area>0</area>
<device>desktop,tablet,phone</device>
<rows>help,newdocument,undo,redo,spacer,bold,italic,underline,strikethrough,justifyfull,justifycenter,justifyleft,justifyright,spacer,blockquote,formatselect,styleselect,removeformat,cleanup;fontselect,fontsizeselect,fontcolor,spacer,clipboard,indent,outdent,lists,sub,sup,textcase,charmap,hr;directionality,fullscreen,print,searchreplace,spacer,table,style,attributes;visualaid,visualchars,visualblocks,nonbreaking,anchor,unlink,link,imgmanager,spellchecker,article</rows>
<plugins>formatselect,styleselect,cleanup,fontselect,fontsizeselect,fontcolor,clipboard,lists,textcase,charmap,hr,directionality,fullscreen,print,searchreplace,table,style,attributes,visualchars,visualblocks,nonbreaking,anchor,link,imgmanager,spellchecker,article,spellchecker,article,browser,contextmenu,media,preview,source</plugins>
<published>1</published>
<ordering>1</ordering>
<params>{"editor":{"toolbar_theme":"modern"}}</params>
</profile>
<profile name="Front End">
<name>Front End</name>
<description>WF_PROFILES_FRONTEND_DESC</description>
<users></users>
<types></types>
<components></components>
<area>1</area>
<device>desktop,tablet,phone</device>
<rows>help,newdocument,undo,redo,spacer,bold,italic,underline,strikethrough,justifyfull,justifycenter,justifyleft,justifyright,spacer,formatselect,styleselect;clipboard,searchreplace,indent,outdent,lists,cleanup,charmap,removeformat,hr,sub,sup,textcase,nonbreaking,visualchars,visualblocks;fullscreen,print,visualaid,style,attributes,anchor,unlink,link,imgmanager,spellchecker,article</rows>
<plugins>charmap,contextmenu,help,clipboard,searchreplace,fullscreen,preview,print,style,textcase,nonbreaking,visualchars,visualblocks,attributes,imgmanager,anchor,link,spellchecker,article,lists,formatselect,styleselect,hr</plugins>
<published>0</published>
<ordering>2</ordering>
<params>{"editor":{"toolbar_theme":"modern"}}</params>
</profile>
<profile name="Blogger">
<name>Blogger</name>
<description>Simple Blogging Profile</description>
<users></users>
<types></types>
<components></components>
<area>0</area>
<device>desktop,tablet,phone</device>
<rows>bold,italic,strikethrough,lists,blockquote,spacer,justifyleft,justifycenter,justifyright,spacer,link,unlink,imgmanager,article,spellchecker,fullscreen,kitchensink;formatselect,styleselect,underline,justifyfull,clipboard,removeformat,charmap,indent,outdent,undo,redo,help</rows>
<plugins>link,imgmanager,article,spellchecker,fullscreen,kitchensink,clipboard,contextmenu,lists,formatselect,styleselect,textpattern</plugins>
<published>0</published>
<ordering>3</ordering>
<params>{"editor":{"toolbar_theme":"modern"}}</params>
</profile>
<profile name="Mobile">
<name>Mobile</name>
<description>Sample Mobile Profile</description>
<users></users>
<types></types>
<components></components>
<area>0</area>
<device>tablet,phone</device>
<rows>undo,redo,spacer,bold,italic,underline,formatselect,spacer,justifyleft,justifycenter,justifyfull,justifyright,spacer,fullscreen,kitchensink;styleselect,lists,spellchecker,article,link,unlink</rows>
<plugins>fullscreen,kitchensink,spellchecker,article,link,lists,formatselect,styleselect,textpattern</plugins>
<published>0</published>
<ordering>4</ordering>
<params>{"editor":{"toolbar_theme":"modern.touch","resizing":"0","resize_horizontal":"0","resizing_use_cookie":"0","links":{"popups":{"default":"","jcemediabox":{"enable":"0"},"window":{"enable":"0"}}}}}</params>
</profile>
<profile>
<name>Markdown</name>
<description>Sample Markdown Profile</description>
<users></users>
<types>6,7,3,4,5,8</types>
<components></components>
<area>0</area>
<device>desktop,tablet,phone</device>
<rows>fullscreen,justifyleft,justifycenter,justifyfull,justifyright,link,unlink,imgmanager,styleselect</rows>
<plugins>fullscreen,link,imgmanager,styleselect,media,textpattern</plugins>
<published>0</published>
<ordering>5</ordering>
<params>{"editor":{"toolbar_theme":"modern"}}</params>
</profile>
</profiles>
</profiles>