| Current Path : /home/digilove/.cagefs/tmp/ |
| Current File : /home/digilove/.cagefs/tmp/phpuSuNq3 |
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text as JText;
use Joomla\Registry\Registry;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_AccessLevel extends Field
{
public $type = 'AccessLevel';
public function getAjaxRaw(Registry $attributes)
{
$name = $attributes->get('name', $this->type);
$id = $attributes->get('id', strtolower($name));
$value = $attributes->get('value', []);
$size = $attributes->get('size');
$multiple = $attributes->get('multiple');
$options = $this->getOptions(
(bool) $attributes->get('show_all'),
(bool) $attributes->get('use_names')
);
return $this->selectList($options, $name, $value, $id, $size, $multiple);
}
protected function getAccessLevels($use_names = false)
{
$value = $use_names ? 'a.title' : 'a.id';
$query = $this->db->getQuery(true)
->select($value . ' as value, a.title as text')
->from('#__viewlevels AS a')
->group('a.id')
->order('a.ordering ASC');
$this->db->setQuery($query);
return $this->db->loadObjectList();
}
protected function getInput()
{
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$show_all = $this->get('show_all');
$use_names = $this->get('use_names');
return $this->selectListAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'multiple', 'show_all', 'use_names')
);
}
protected function getOptions($show_all = false, $use_names = false)
{
$options = $this->getAccessLevels($use_names);
if ($show_all)
{
$option = (object) [];
$option->value = -1;
$option->text = '- ' . JText::_('JALL') . ' -';
$option->disable = '';
array_unshift($options, $option);
}
return $options;
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\Registry\Registry;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Agents extends Field
{
public $type = 'Agents';
public function getAgents($group = 'os')
{
$agents = [];
switch ($group)
{
/* Browsers */
case 'browsers':
if ($this->get('simple') && $this->get('simple') !== 'false')
{
$agents[] = ['Chrome', 'Chrome'];
$agents[] = ['Firefox', 'Firefox'];
$agents[] = ['Edge', 'Edge'];
$agents[] = ['Internet Explorer', 'MSIE'];
$agents[] = ['Opera', 'Opera'];
$agents[] = ['Safari', 'Safari'];
break;
}
$agents[] = ['Chrome', 'Chrome'];
$agents[] = ['Firefox', 'Firefox'];
$agents[] = ['Microsoft Edge', 'MSIE Edge']; // missing MSIE is added to agent string in assignments/agents.php
$agents[] = ['Internet Explorer', 'MSIE [0-9]']; // missing MSIE is added to agent string in assignments/agents.php
$agents[] = ['Opera', 'Opera'];
$agents[] = ['Safari', 'Safari'];
break;
/* Mobile browsers */
case 'mobile':
$agents[] = [JText::_('JALL'), 'mobile'];
$agents[] = ['Android', 'Android'];
$agents[] = ['Android Chrome', '#Android.*Chrome#'];
$agents[] = ['Blackberry', 'Blackberry'];
$agents[] = ['IE Mobile', 'IEMobile'];
$agents[] = ['iPad', 'iPad'];
$agents[] = ['iPhone', 'iPhone'];
$agents[] = ['iPod Touch', 'iPod'];
$agents[] = ['NetFront', 'NetFront'];
$agents[] = ['Nokia', 'NokiaBrowser'];
$agents[] = ['Opera Mini', 'Opera Mini'];
$agents[] = ['Opera Mobile', 'Opera Mobi'];
$agents[] = ['UC Browser', 'UC Browser'];
break;
/* OS */
case 'os':
default:
$agents[] = ['Windows', 'Windows'];
$agents[] = ['Mac OS', '#(Mac OS|Mac_PowerPC|Macintosh)#'];
$agents[] = ['Linux', '#(Linux|X11)#'];
$agents[] = ['Open BSD', 'OpenBSD'];
$agents[] = ['Sun OS', 'SunOS'];
$agents[] = ['QNX', 'QNX'];
$agents[] = ['BeOS', 'BeOS'];
$agents[] = ['OS/2', 'OS/2'];
break;
}
$options = [];
foreach ($agents as $agent)
{
$option = JHtml::_('select.option', $agent[1], $agent[0]);
$options[] = $option;
}
return $options;
}
public function getAjaxRaw(Registry $attributes)
{
$name = $attributes->get('name', $this->type);
$id = $attributes->get('id', strtolower($name));
$value = $attributes->get('value', []);
$size = $attributes->get('size');
$options = $this->getAgents(
$attributes->get('group')
);
return $this->selectListSimple($options, $name, $value, $id, $size, true);
}
protected function getInput()
{
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$size = (int) $this->get('size');
$group = $this->get('group', 'os');
return $this->selectListSimpleAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'group')
);
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Ajax extends Field
{
public $type = 'Ajax';
protected function getInput()
{
RL_Document::loadMainDependencies();
$class = $this->get('class', 'btn');
if ($this->get('disabled'))
{
return $this->getButton($class . ' disabled', 'disabled');
}
$loading = 'jQuery("#' . $this->id . ' span:nth-child(1)").attr("class", "icon-refresh icon-spin");';
$success = '
jQuery("#' . $this->id . '").removeClass("btn-warning").addClass("btn-success");
jQuery("#' . $this->id . ' span:nth-child(1)").attr("class", "icon-ok");
if(data){
jQuery("#message_' . $this->id . '").addClass("alert alert-success alert-noclose alert-inline").html(data);
}
';
$error = '
jQuery("#' . $this->id . '").removeClass("btn-success").addClass("btn-warning");
jQuery("#' . $this->id . ' span:nth-child(1)").attr("class", "icon-warning");
if(data){
let error = data;
if(data.statusText) {
error = data.statusText;
if(data.responseText.test(/<blockquote>/)) {
error = data.responseText.replace(/^[.\\\\s\\\\S]*?<blockquote>([.\\\\s\\\\S]*?)<\\\\/blockquote>[.\\\\s\\\\S]*$/gm, "$1");
}
}
jQuery("#message_' . $this->id . '").addClass("alert alert-danger alert-noclose alert-inline").html(error);
}';
if ($this->get('success-disabled'))
{
$success .= '
jQuery("#' . $this->id . '").disabled = true;
jQuery("#' . $this->id . '").addClass("disabled");
jQuery("#' . $this->id . '").attr("onclick", "return false;");
';
}
if ($this->get('success-text') || $this->get('error-text'))
{
$success_text = $this->get('success-text', $this->get('text'));
$error_text = $this->get('error-text', $this->get('text'));
$success .= '
jQuery("#' . $this->id . ' span:nth-child(2)").text("' . addslashes(JText::_($success_text)) . '");
';
$error .= '
jQuery("#' . $this->id . ' span:nth-child(2)").text("' . addslashes(JText::_($error_text)) . '");
';
}
$query = '';
$url_query = $this->get('url-query');
if ($url_query)
{
$name_prefix = $this->form->getFormControl() . '\\\[' . $this->group . '\\\]';
$id_prefix = $this->form->getFormControl() . '_' . $this->group . '_';
$query_parts = [];
$url_query = explode(',', $url_query);
foreach ($url_query as $url_query_part)
{
[$key, $id] = explode(':', $url_query_part);
$el_name = 'document.querySelector("input[name=' . $name_prefix . '\\\[' . $id . '\\\]]:checked")';
$el_id = 'document.querySelector("#' . $id_prefix . $id . '")';
$query_parts[] = '`&' . $key . '=`'
. ' + encodeURI(' . $el_name . ' ? ' . $el_name . '.value : (' . $el_id . ' ? ' . $el_id . '.value' . ' : ""))';
}
$query = '+' . implode('+', $query_parts);
}
$script = 'function loadAjax' . $this->id . '() {
' . $loading . '
jQuery("#message_' . $this->id . '").attr("class", "").html("");
RegularLabsScripts.loadajax(
`' . addslashes($this->get('url')) . '`' . $query . ',
`
if(data == "" || data.substring(0,1) == "+") {
data = data.trim().replace(/^[+]/, "");
' . $success . '
} else {
data = data.trim().replace(/^[-]/, "");
' . $error . '
}`,
`' . $error . '`
);
}';
$script = preg_replace('#\s*\n\s*#', ' ', $script);
JFactory::getDocument()->addScriptDeclaration($script);
$attributes = 'onclick="loadAjax' . $this->id . '();return false;"';
return $this->getButton($class, $attributes);
}
private function getButton($class = 'btn', $attributes = '')
{
$icon = $this->get('icon', '')
? 'icon-' . $this->get('icon', '')
: '';
return
'<button id="' . $this->id . '" class="' . $class . '"'
. ' title="' . JText::_($this->get('description')) . '"'
. ' ' . $attributes . '>'
. '<span class="' . $icon . '"></span> '
. '<span>' . JText::_($this->get('text', $this->get('label'))) . '</span>'
. '</button>'
. '<div id="message_' . $this->id . '"></div>';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
use RegularLabs\Library\FieldGroup;
defined('_JEXEC') or die;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_AkeebaSubs extends FieldGroup
{
public $default_group = 'Levels';
public $type = 'AkeebaSubs';
public function getLevels()
{
$query = $this->db->getQuery(true)
->select('l.akeebasubs_level_id as id, l.title AS name, l.enabled as published')
->from('#__akeebasubs_levels AS l')
->where('l.enabled > -1')
->order('l.title, l.akeebasubs_level_id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['id']);
}
protected function getInput()
{
$error = $this->missingFilesOrTables(['levels']);
return $error ?: $this->getSelectList();
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\FieldGroup;
use RegularLabs\Library\Form as RL_Form;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Zoo extends FieldGroup
{
public $type = 'Zoo';
public function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__zoo_category AS c')
->where('c.published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$options = [];
if ($this->get('show_ignore'))
{
if (in_array('-1', $this->value))
{
$this->value = ['-1'];
}
$options[] = JHtml::_('select.option', '-1', '- ' . JText::_('RL_IGNORE') . ' -');
$options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true);
}
$query->clear()
->select('a.id, a.name')
->from('#__zoo_application AS a')
->order('a.name, a.id');
$this->db->setQuery($query);
$apps = $this->db->loadObjectList();
foreach ($apps as $i => $app)
{
$query->clear()
->select('c.id, c.parent AS parent_id, c.name AS title, c.published')
->from('#__zoo_category AS c')
->where('c.application_id = ' . (int) $app->id)
->where('c.published > -1')
->order('c.ordering, c.name');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
if ($i)
{
$options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true);
}
// establish the hierarchy of the menu
// TODO: use node model
$children = [];
if ($items)
{
// first pass - collect children
foreach ($items as $v)
{
$pt = $v->parent_id;
$list = @$children[$pt] ?: [];
array_push($list, $v);
$children[$pt] = $list;
}
}
// second pass - get an indent list of the items
$list = JHtml::_('menu.treerecurse', 0, '', [], $children, 9999, 0, 0);
// assemble items to the array
$options[] = JHtml::_('select.option', 'app' . $app->id, '[' . $app->name . ']');
foreach ($list as $item)
{
$item->treename = ' ' . str_replace('  - ', ' ', $item->treename);
$item->treename = RL_Form::prepareSelectItem($item->treename, $item->published);
$option = JHtml::_('select.option', $item->id, $item->treename);
$option->level = 1;
$options[] = $option;
}
}
return $options;
}
public function getItems()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__zoo_item AS i')
->where('i.state > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('i.id, i.name, a.name as cat, i.state as published')
->join('LEFT', '#__zoo_application AS a ON a.id = i.application_id')
->group('i.id')
->order('i.name, i.priority, i.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['cat', 'id']);
}
protected function getInput()
{
$error = $this->missingFilesOrTables(['applications' => 'application', 'categories' => 'category', 'items' => 'item']);
if ($error)
{
return $error;
}
return $this->getSelectList();
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
use RegularLabs\Library\StringHelper as RL_String;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
/**
* @deprecated 2018-10-30 Use ConditionSelection instead
*/
class JFormFieldRL_AssignmentSelection extends Field
{
public $type = 'AssignmentSelection';
protected function getInput()
{
require_once __DIR__ . '/toggler.php';
$toggler = new RLFieldToggler;
$this->value = (int) $this->value;
$label = $this->get('label');
$param_name = $this->get('name');
$use_main_toggle = $this->get('use_main_toggle', 1);
$showclose = $this->get('showclose', 0);
$html = [];
if ( ! $label)
{
if ($use_main_toggle)
{
$html[] = $toggler->getInput(['div' => 1]);
}
$html[] = $toggler->getInput(['div' => 1]);
return '</div>' . implode('', $html);
}
$label = RL_String::html_entity_decoder(JText::_($label));
$html[] = '</div>';
if ($use_main_toggle)
{
$html[] = $toggler->getInput(['div' => 1, 'param' => 'show_assignments|' . $param_name, 'value' => '1|1,2']);
}
$class = 'well well-small rl_well';
if ($this->value === 1)
{
$class .= ' alert-success';
}
else if ($this->value === 2)
{
$class .= ' alert-error';
}
$html[] = '<div class="' . $class . '">';
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
if ($showclose && $user->authorise('core.admin'))
{
$html[] = '<button type="button" class="close rl_remove_assignment" aria-label="Close">×</button>';
}
$html[] = '<div class="control-group">';
$html[] = '<div class="control-label">';
$html[] = '<label><h4 class="rl_assignmentselection-header">' . $label . '</h4></label>';
$html[] = '</div>';
$html[] = '<div class="controls">';
$html[] = '<fieldset id="' . $this->id . '" class="radio btn-group">';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this, 0)"';
$html[] = '<input type="radio" id="' . $this->id . '0" name="' . $this->name . '" value="0"' . (( ! $this->value) ? ' checked="checked"' : '') . $onclick . '>';
$html[] = '<label class="rl_btn-ignore" for="' . $this->id . '0">' . JText::_('RL_IGNORE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this, 1)"';
$html[] = '<input type="radio" id="' . $this->id . '1" name="' . $this->name . '" value="1"' . (($this->value === 1) ? ' checked="checked"' : '') . $onclick . '>';
$html[] = '<label class="rl_btn-include" for="' . $this->id . '1">' . JText::_('RL_INCLUDE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this, 2)"';
$onclick .= ' onload="RegularLabsForm.setToggleTitleClass(this, ' . $this->value . ', 7)"';
$html[] = '<input type="radio" id="' . $this->id . '2" name="' . $this->name . '" value="2"' . (($this->value === 2) ? ' checked="checked"' : '') . $onclick . '>';
$html[] = '<label class="rl_btn-exclude" for="' . $this->id . '2">' . JText::_('RL_EXCLUDE') . '</label>';
$html[] = '</fieldset>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="clearfix"> </div>';
$html[] = $toggler->getInput(['div' => 1, 'param' => $param_name, 'value' => '1,2']);
$html[] = '<div><div>';
return '</div>' . implode('', $html);
}
protected function getLabel()
{
return '';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Block extends Field
{
public $type = 'Block';
protected function getInput()
{
$title = $this->get('label');
$description = $this->get('description');
$class = $this->get('class');
$showclose = $this->get('showclose', 0);
$nowell = $this->get('nowell', 0);
$start = $this->get('start', 0);
$end = $this->get('end', 0);
$html = [];
if ($start || ! $end)
{
$html[] = '</div>';
if (strpos($class, 'alert') !== false)
{
$class = 'alert ' . $class;
}
else if ( ! $nowell)
{
$class = 'well well-small ' . $class;
}
$html[] = '<div class="' . $class . '">';
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
if ($showclose && $user->authorise('core.admin'))
{
$html[] = '<button type="button" class="close rl_remove_assignment" aria-label="Close">×</button>';
}
if ($title)
{
$html[] = '<h4>' . $this->prepareText($title) . '</h4>';
}
if ($description)
{
$html[] = '<div>' . $this->prepareText($description) . '</div>';
}
$html[] = '<div><div>';
}
if ( ! $start && ! $end)
{
$html[] = '</div>';
}
return '</div>' . implode('', $html);
}
protected function getLabel()
{
return '';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Checkbox extends Field
{
public $type = 'Checkbox';
protected function getInput()
{
$showcheckall = $this->get('showcheckall', 0);
$checkall = ($this->value == '*');
if ( ! $checkall)
{
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
}
$options = [];
foreach ($this->element->children() as $option)
{
if ($option->getName() != 'option')
{
continue;
}
$text = trim((string) $option);
if ( ! isset($option['value']))
{
$options[] = '<label style="clear:both;"><strong>' . JText::_($text) . '</strong></label>';
continue;
}
$val = (string) $option['value'];
$disabled = (int) $option['disabled'];
$option = '<input type="checkbox" class="rl_' . $this->id . '" id="' . $this->id . $val . '" name="' . $this->name . '[]" value="' . $val . '"';
if ($checkall || in_array($val, $this->value))
{
$option .= ' checked="checked"';
}
if ($disabled)
{
$option .= ' disabled="disabled"';
}
$option .= '> <label for="' . $this->id . $val . '" class="checkboxes">' . JText::_($text) . '</label>';
$options[] = $option;
}
$options = implode('', $options);
if ($showcheckall)
{
$js = "
jQuery(document).ready(function() {
RegularLabsForm.initCheckAlls('rl_checkall_" . $this->id . "', 'rl_" . $this->id . "');
});
";
JFactory::getDocument()->addScriptDeclaration($js);
$checker = '<input id="rl_checkall_' . $this->id . '" type="checkbox" onclick=" RegularLabsForm.checkAll( this, \'rl_' . $this->id . '\' );"> ' . JText::_('JALL');
$options = $checker . '<br>' . $options;
}
$options .= '<input type="hidden" id="' . $this->id . 'x" name="' . $this->name . '' . '[]" value="x" checked="checked">';
$html = [];
$html[] = '<fieldset id="' . $this->id . '" class="checkbox">';
$html[] = $options;
$html[] = '</fieldset>';
return implode('', $html);
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Editor\Editor as JEditor;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_CodeEditor extends Field
{
public $type = 'CodeEditor';
protected function getInput()
{
$width = $this->get('width', '100%');
$height = $this->get('height', 400);
$syntax = $this->get('syntax', 'html');
$editor_plugin = JPluginHelper::getPlugin('editors', 'codemirror');
if (empty($editor_plugin))
{
return
'<textarea name="' . $this->name . '" style="'
. 'width:' . (strpos($width, '%') ? $width : $width . 'px') . ';'
. 'height:' . (strpos($height, '%') ? $height : $height . 'px') . ';'
. '" id="' . $this->id . '">' . $this->value . '</textarea>';
}
RL_Document::script('regularlabs/codemirror.min.js');
RL_Document::stylesheet('regularlabs/codemirror.min.css');
JFactory::getDocument()->addScriptDeclaration("
jQuery(document).ready(function($) {
RegularLabsCodeMirror.init('" . $this->id . "');
});
");
JFactory::getDocument()->addStyleDeclaration("
#rl_codemirror_" . $this->id . " .CodeMirror {
height: " . $height . "px;
min-height: " . min($height, '100') . "px;
}
");
return '<div class="rl_codemirror" id="rl_codemirror_' . $this->id . '">'
. JEditor::getInstance('codemirror')->display(
$this->name, htmlentities($this->value),
$width, $height,
80, 10,
false,
$this->id, null, null,
['markerGutter' => false, 'activeLine' => true, 'syntax' => $syntax]
)
. '</div>';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Form\FormField as JFormField;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\RegEx as RL_RegEx;
jimport('joomla.form.formfield');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Color extends JFormField
{
public $type = 'Color';
protected function getInput()
{
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return null;
}
$field = new RLFieldColor;
return $field->getInput($this->name, $this->id, $this->value, $this->element->attributes());
}
}
class RLFieldColor
{
public function getInput($name, $id, $value, $params)
{
$this->name = $name;
$this->id = $id;
$this->value = $value;
$this->params = $params;
$class = trim('rl_color minicolors ' . $this->get('class'));
$disabled = $this->get('disabled') ? ' disabled="disabled"' : '';
RL_Document::script('regularlabs/color.min.js');
RL_Document::stylesheet('regularlabs/color.min.css');
$this->value = strtolower(RL_RegEx::replace('[^a-z0-9]', '', $this->value));
return '<input type="text" name="' . $this->name . '" id="' . $this->id . '" class="' . $class . '" value="' . $this->value . '"' . $disabled . '>';
}
private function get($val, $default = '')
{
return (isset($this->params[$val]) && (string) $this->params[$val] != '') ? (string) $this->params[$val] : $default;
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\Registry\Registry;
use RegularLabs\Library\Field;
use RegularLabs\Library\RegEx as RL_RegEx;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Components extends Field
{
public $type = 'Components';
public function getAjaxRaw(Registry $attributes)
{
$name = $attributes->get('name', $this->type);
$id = $attributes->get('id', strtolower($name));
$value = $attributes->get('value', []);
$size = $attributes->get('size');
$options = $this->getComponents();
return $this->selectListSimple($options, $name, $value, $id, $size, true, true);
}
public function getComponents()
{
$frontend = $this->get('frontend', 1);
$admin = $this->get('admin', 1);
if ( ! $frontend && ! $admin)
{
return [];
}
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$query = $this->db->getQuery(true)
->select('e.name, e.element')
->from('#__extensions AS e')
->where('e.type = ' . $this->db->quote('component'))
->where('e.name != ""')
->where('e.element != ""')
->group('e.element')
->order('e.element, e.name');
$this->db->setQuery($query);
$components = $this->db->loadObjectList();
$comps = [];
$lang = JFactory::getLanguage();
foreach ($components as $i => $component)
{
if (empty($component->element))
{
continue;
}
$component_folder = ($frontend ? JPATH_SITE : JPATH_ADMINISTRATOR) . '/components/' . $component->element;
if ( ! JFolder::exists($component_folder) && $admin)
{
$component_folder = JPATH_ADMINISTRATOR . '/components/' . $component->element;
}
// return if there is no main component folder
if ( ! JFolder::exists($component_folder))
{
continue;
}
// return if there is no view(s) folder
if ( ! JFolder::exists($component_folder . '/views') && ! JFolder::exists($component_folder . '/view'))
{
continue;
}
if (strpos($component->name, ' ') === false)
{
// Load the core file then
// Load extension-local file.
$lang->load($component->element . '.sys', JPATH_BASE, null, false, false)
|| $lang->load($component->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component->element, null, false, false)
|| $lang->load($component->element . '.sys', JPATH_BASE, $lang->getDefault(), false, false)
|| $lang->load($component->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component->element, $lang->getDefault(), false, false);
$component->name = JText::_(strtoupper($component->name));
}
$comps[RL_RegEx::replace('[^a-z0-9_]', '', $component->name . '_' . $component->element)] = $component;
}
ksort($comps);
$options = [];
foreach ($comps as $component)
{
$options[] = JHtml::_('select.option', $component->element, $component->name);
}
return $options;
}
protected function getInput()
{
$size = (int) $this->get('size');
return $this->selectListSimpleAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size')
);
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
use RegularLabs\Library\ShowOn as RL_ShowOn;
use RegularLabs\Library\StringHelper as RL_String;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_ConditionSelection extends Field
{
public $type = 'ConditionSelection';
protected function closeShowOn()
{
return RL_ShowOn::close();
}
protected function getInput()
{
$this->value = (int) $this->value;
$label = $this->get('label');
$param_name = $this->get('name');
$use_main_switch = $this->get('use_main_switch', 1);
$showclose = $this->get('showclose', 0);
$html = [];
if ( ! $label)
{
if ($use_main_switch)
{
$html[] = $this->closeShowOn();
}
$html[] = $this->closeShowOn();
return '</div>' . implode('', $html);
}
$label = RL_String::html_entity_decoder(JText::_($label));
$html[] = '</div>';
if ($use_main_switch)
{
$html[] = $this->openShowOn('show_conditions:1[OR]show_assignments:1[OR]' . $param_name . ':1,2');
}
$class = 'well well-small rl_well';
if ($this->value === 1)
{
$class .= ' alert-success';
}
else if ($this->value === 2)
{
$class .= ' alert-error';
}
$html[] = '<div class="' . $class . '">';
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
if ($showclose && $user->authorise('core.admin'))
{
$html[] = '<button type="button" class="close" aria-label="Close">×</button>';
}
$html[] = '<div class="control-group">';
$html[] = '<div class="control-label">';
$html[] = '<label><h4>' . $label . '</h4></label>';
$html[] = '</div>';
$html[] = '<div class="controls">';
$html[] = '<fieldset id="' . $this->id . '" class="radio btn-group">';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this, 0)"';
$html[] = '<input type="radio" id="' . $this->id . '0" name="' . $this->name . '" value="0"' . (( ! $this->value) ? ' checked="checked"' : '') . $onclick . '>';
$html[] = '<label class="rl_btn-ignore" for="' . $this->id . '0">' . JText::_('RL_IGNORE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this, 1)"';
$html[] = '<input type="radio" id="' . $this->id . '1" name="' . $this->name . '" value="1"' . (($this->value === 1) ? ' checked="checked"' : '') . $onclick . '>';
$html[] = '<label class="rl_btn-include" for="' . $this->id . '1">' . JText::_('RL_INCLUDE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this, 2)"';
$onclick .= ' onload="RegularLabsForm.setToggleTitleClass(this, ' . $this->value . ', 7)"';
$html[] = '<input type="radio" id="' . $this->id . '2" name="' . $this->name . '" value="2"' . (($this->value === 2) ? ' checked="checked"' : '') . $onclick . '>';
$html[] = '<label class="rl_btn-exclude" for="' . $this->id . '2">' . JText::_('RL_EXCLUDE') . '</label>';
$html[] = '</fieldset>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="clearfix"> </div>';
$html[] = $this->openShowOn($param_name . ':1,2');
$html[] = '<div><div>';
return '</div>' . implode('', $html);
}
protected function getLabel()
{
return '';
}
protected function openShowOn($condition = '')
{
if ( ! $condition)
{
return $this->closeShowon();
}
$formControl = $this->get('form', $this->formControl);
$formControl = $formControl == 'root' ? '' : $formControl;
if ($this->group)
{
$formControl .= '[' . $this->group . ']';
}
return RL_ShowOn::open($condition, $formControl);
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\ArrayHelper as RL_ArrayHelper;
use RegularLabs\Library\FieldGroup;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Content extends FieldGroup
{
public $type = 'Content';
public function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__categories')
->where('extension = ' . $this->db->quote('com_content'))
->where('parent_id > 0')
->where('published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$this->value = RL_ArrayHelper::toArray($this->value);
// assemble items to the array
$options = [];
if ($this->get('show_ignore'))
{
if (in_array('-1', $this->value))
{
$this->value = ['-1'];
}
$options[] = JHtml::_('select.option', '-1', '- ' . JText::_('RL_IGNORE') . ' -');
$options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true);
}
$query->clear('select')
->select('id, title as name, level, published, language')
->order('lft');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
$options = array_merge($options, $this->getOptionsByList($list, ['language'], -1));
return $options;
}
public function getItems()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__content AS i')
->where('i.access > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('i.id, i.title as name, i.language, c.title as cat, i.state as published')
->join('LEFT', '#__categories AS c ON c.id = i.catid')
->order('i.title, i.ordering, i.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
$options = $this->getOptionsByList($list, ['language', 'cat', 'id']);
if ($this->get('showselect'))
{
array_unshift($options, JHtml::_('select.option', '-', ' ', 'value', 'text', true));
array_unshift($options, JHtml::_('select.option', '-', '- ' . JText::_('Select Item') . ' -'));
}
return $options;
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
use RegularLabs\Library\StringHelper as RL_String;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_CustomFieldKey extends Field
{
public $type = 'CustomFieldKey';
protected function getInput()
{
return '<div style="display:none;"><div><div>';
}
protected function getLabel()
{
$label = $this->get('label') ?: '';
$size = $this->get('size') ? 'style="width:' . $this->get('size') . 'px"' : '';
$class = 'class="' . ($this->get('class') ?: 'text_area') . '"';
$this->value = htmlspecialchars(RL_String::html_entity_decoder($this->value), ENT_QUOTES);
return
'<label for="' . $this->id . '" style="margin-top: -5px;">'
. '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="' . $this->value
. '" placeholder="' . JText::_($label) . '" title="' . JText::_($label) . '" ' . $class . ' ' . $size . '>'
. '</label>';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
use RegularLabs\Library\StringHelper as RL_String;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_CustomFieldValue extends Field
{
public $type = 'CustomFieldValue';
protected function getInput()
{
$label = $this->get('label') ?: '';
$size = $this->get('size') ? 'style="width:' . $this->get('size') . 'px"' : '';
$class = 'class="' . ($this->get('class') ?: 'text_area') . '"';
$this->value = htmlspecialchars(RL_String::html_entity_decoder($this->value), ENT_QUOTES);
return
'</div></div></div>'
. '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="' . $this->value
. '" placeholder="' . JText::_($label) . '" title="' . JText::_($label) . '" ' . $class . ' ' . $size . '>';
}
protected function getLabel()
{
return '';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Date as RL_Date;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_DateTime extends Field
{
public $type = 'DateTime';
protected function getInput()
{
$label = $this->get('label');
$format = $this->get('format');
$date = JFactory::getDate();
$tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
$date->setTimeZone($tz);
if ($format)
{
if (strpos($format, '%') !== false)
{
$format = RL_Date::strftimeToDateFormat($format);
}
$html = $date->format($format, true);
}
else
{
$html = $date->format('', true);
}
if ($label)
{
$html = JText::sprintf($label, $html);
}
return '</div><div>' . $html;
}
protected function getLabel()
{
return '';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
use RegularLabs\Library\RegEx as RL_RegEx;
jimport('joomla.form.formfield');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Dependency extends Field
{
public $type = 'Dependency';
protected function getInput()
{
$file = $this->get('file');
if ($file)
{
$label = $this->get('label', 'the main extension');
RLFieldDependency::setMessage($file, $label);
return '';
}
$path = ($this->get('path') == 'site') ? '' : '/administrator';
$label = $this->get('label');
$file = $this->get('alias', $label);
$file = RL_RegEx::replace('[^a-z-]', '', strtolower($file));
$extension = $this->get('extension');
switch ($extension)
{
case 'com':
$file = $path . '/components/com_' . $file . '/com_' . $file . '.xml';
break;
case 'mod':
$file = $path . '/modules/mod_' . $file . '/mod_' . $file . '.xml';
break;
default:
$file = '/plugins/' . str_replace('plg_', '', $extension) . '/' . $file . '.xml';
break;
}
$label = JText::_($label) . ' (' . JText::_('RL_' . strtoupper($extension)) . ')';
RLFieldDependency::setMessage($file, $label);
return '';
}
protected function getLabel()
{
return '';
}
}
class RLFieldDependency
{
static function setMessage($file, $name)
{
jimport('joomla.filesystem.file');
$file = str_replace('\\', '/', $file);
$file = (strpos($file, '/administrator') === 0)
? str_replace('/administrator', JPATH_ADMINISTRATOR, $file)
: JPATH_SITE . '/' . $file;
$file = str_replace('//', '/', $file);
$file_alt = RL_RegEx::replace('(com|mod)_([a-z-_]+\.)', '\2', $file);
if (file_exists($file) || file_exists($file_alt))
{
return;
}
$msg = JText::sprintf('RL_THIS_EXTENSION_NEEDS_THE_MAIN_EXTENSION_TO_FUNCTION', JText::_($name));
$messageQueue = JFactory::getApplication()->getMessageQueue();
foreach ($messageQueue as $queue_message)
{
if ($queue_message['type'] == 'error' && $queue_message['message'] == $msg)
{
return;
}
}
JFactory::getApplication()->enqueueMessage($msg, 'error');
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
use RegularLabs\Library\FieldGroup;
defined('_JEXEC') or die;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_EasyBlog extends FieldGroup
{
public $type = 'EasyBlog';
public function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__easyblog_category AS c')
->where('c.published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('c.id, c.parent_id, c.title, c.published')
->order('c.ordering, c.title');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
return $this->getOptionsTreeByList($items);
}
public function getItems()
{
$query = $this->db->getQuery(true)
->select('i.id, i.title as name, c.title as cat, i.published')
->from('#__easyblog_post AS i')
->join('LEFT', '#__easyblog_category AS c ON c.id = i.category_id')
->where('i.published > -1')
->order('i.title, c.title, i.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['cat', 'id']);
}
public function getTags()
{
$query = $this->db->getQuery(true)
->select('t.alias as id, t.title as name')
->from('#__easyblog_tag AS t')
->where('t.published > -1')
->where('t.title != ' . $this->db->quote(''))
->group('t.title')
->order('t.title');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
protected function getInput()
{
$error = $this->missingFilesOrTables(['categories' => 'category', 'items' => 'post', 'tags' => 'tag']);
return $error ?: $this->getSelectList();
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Editor extends Field
{
public $type = 'Editor';
protected function getInput()
{
$width = $this->get('width', '100%');
$height = $this->get('height', 400);
$this->value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
// Get an editor object.
$editor = JFactory::getEditor();
$html = $editor->display($this->name, $this->value, $width, $height, true, $this->id);
return '</div><div>' . $html;
}
protected function getLabel()
{
return '';
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\Field;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Field extends Field
{
public $type = 'Field';
public function getFields()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT a.id, a.name, a.type, a.title')
->from('#__fields AS a')
->where('a.state = 1')
->order('a.name');
$db->setQuery($query);
$fields = $db->loadObjectList();
$options = [];
$options[] = JHtml::_('select.option', '', '- ' . JText::_('RL_SELECT_FIELD') . ' -');
foreach ($fields as &$field)
{
// Skip our own subfields type. We won't have subfields in subfields.
if ($field->type == 'subfields' || $field->type == 'repeatable')
{
continue;
}
$options[] = JHtml::_('select.option', $field->name, ($field->title . ' (' . $field->type . ')'));
}
if ($this->get('show_custom'))
{
$options[] = JHtml::_('select.option', 'custom', '- ' . JText::_('RL_CUSTOM') . ' -');
}
return $options;
}
protected function getInput()
{
$options = $this->getFields();
return $this->selectListSimple($options, $this->name, $this->value, $this->id);
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\RegEx as RL_RegEx;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
JFormHelper::loadFieldClass('list');
class JFormFieldRL_FileList extends JFormFieldList
{
public $type = 'FileList';
private $params = null;
protected function getInput()
{
return parent::getInput();
}
protected function getOptions()
{
$options = [];
$path = $this->get('folder');
if ( ! is_dir($path))
{
$path = JPATH_ROOT . '/' . $path;
}
// Prepend some default options based on field attributes.
if ( ! $this->get('hidenone', 0))
{
$options[] = JHtml::_('select.option', '-1', JText::alt('JOPTION_DO_NOT_USE',
RL_RegEx::replace('[^a-z0-9_\-]', '_', $this->fieldname)));
}
if ( ! $this->get('hidedefault', 0))
{
$options[] = JHtml::_('select.option', '', JText::alt('JOPTION_USE_DEFAULT',
RL_RegEx::replace('[^a-z0-9_\-]', '_', $this->fieldname)));
}
// Get a list of files in the search path with the given filter.
$files = JFolder::files($path, $this->get('filter'));
// Build the options list from the list of files.
if (is_array($files))
{
foreach ($files as $file)
{
// Check to see if the file is in the exclude mask.
if ($this->get('exclude'))
{
if (RL_RegEx::match(chr(1) . $this->get('exclude') . chr(1), $file))
{
continue;
}
}
// If the extension is to be stripped, do it.
if ($this->get('stripext', 1))
{
$file = JFile::stripExt($file);
}
$label = $file;
if ($this->get('language_prefix'))
{
$label = JText::_($this->get('language_prefix') . strtoupper($label));
}
$options[] = JHtml::_('select.option', $file, $label);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
private function get($val, $default = '')
{
if (isset($this->element[$val]))
{
return (string) $this->element[$val] != '' ? (string) $this->element[$val] : $default;
}
if (isset($this->params[$val]))
{
return (string) $this->params[$val] != '' ? (string) $this->params[$val] : $default;
}
return $default;
}
}
<?php
/**
* @package Regular Labs Library
* @version 23.7.24631
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
use RegularLabs\Library\FieldGroup;
defined('_JEXEC') or die;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_FlexiContent extends FieldGroup
{
public $default_group = 'Tags';
public $type = 'FlexiContent';
public function getTags()
{
$query = $this->db->getQuery(true)
->select('t.name as id, t.name')
->from('#__flexicontent_tags AS t')
->where('t.published = 1')
->where('t.name != ' . $this->db->quote(''))
->group('t.name')
->order('t.name');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
public function getTypes()
{
$query = $this->db->getQuery(true)
->select('t.id, t.name')
->from('#__flexicontent_types AS t')
->where('t.published = 1')
->order('t.name, t.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
protected function getInput()
{
$error = $this->missingFilesOrTables(['tags', 'types']);
return $error ?: $this->getSelectList();
}
}