primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,99 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 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\Component\Conditions\Administrator\Helper\Summary;
use RegularLabs\Component\Conditions\Administrator\Model\ItemModel;
use RegularLabs\Library\Input as RL_Input;
if (JFactory::getApplication()->isClient('site'))
{
die();
}
echo (new Conditions)->render();
die;
class Conditions
{
private $extension = '';
private $message = '';
public function getCondition()
{
$id = RL_Input::getInt('id');
$enabled_types = RL_Input::getString('enabled_types');
if ($id)
{
return (new ItemModel)->getConditionById($id, false, $enabled_types);
}
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
if ($extension && $item_id)
{
return (new ItemModel)->getConditionByExtensionItem($extension, $item_id, false, $enabled_types);
}
$data = [];
$form = RL_Input::getRaw('form', []);
foreach ($form as $key => $value)
{
$key = str_replace('jform[', '', $key);
$data[$key] = $value;
}
if (isset($data['extension']))
{
$this->extension = $data['extension'];
}
if (isset($data['message']))
{
$this->message = $data['message'];
}
if (isset($data['enabled_types']))
{
$enabled_types = $data['enabled_types'];
unset($data['enabled_types']);
}
return (new ItemModel)->getConditionFromData($data, $enabled_types);
}
public function render()
{
$condition = $this->getCondition();
$extension = $this->extension ?: RL_Input::getCmd('extension');
$message = $this->message ?: RL_Input::get('message', '');
if ($extension && $condition && $condition->published !== 1)
{
$condition = null;
}
return json_encode((object) [
'has_conditions' => ! empty($condition),
'id' => $condition->id ?? '',
'alias' => $condition->alias ?? '',
'name' => $condition->name ?? '',
'content' => Summary::render($condition, $extension, $message),
]);
}
}

View File

@ -0,0 +1,120 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Layout\LayoutHelper as JLayout;
use Joomla\CMS\Router\Route as JRoute;
use RegularLabs\Component\Conditions\Administrator\Helper\Helper;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Language as RL_Language;
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$canAccess = $user->authorise('core.admin', 'com_conditions');
$canEdit = $user->authorise('core.edit', 'com_conditions');
if ( ! $canAccess || ! $canEdit)
{
throw new NotAllowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
RL_Document::useScript('keepalive');
RL_Document::useScript('form.validate');
RL_Document::usePreset('choicesjs');
RL_Document::useScript('webcomponent.field-fancy-select');
RL_Document::script('regularlabs.regular');
RL_Document::script('regularlabs.admin-form');
RL_Document::script('regularlabs.admin-form-descriptions');
RL_Document::script('regularlabs.treeselect');
RL_Document::script('conditions.script');
$script = "document.addEventListener('DOMContentLoaded', function(){RegularLabs.Conditions.init()});";
RL_Document::scriptDeclaration($script, 'Conditions', true, 'after');
RL_Language::load('com_content', JPATH_ADMINISTRATOR);
?>
<form action="<?php echo JRoute::_('index.php?option=com_conditions&id=' . (int) $this->item->id); ?>"
method="post" name="adminForm" id="conditionsForm"
aria-label="<?php echo JText::_('COM_CONDITIONS_FORM_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>"
class="form-validate rl-form">
<?php echo JLayout::render('joomla.edit.title_alias', $this); ?>
<fieldset class="mt-3">
<?php echo JHtml::_('uitab.startTabSet', 'main', ['active' => 'details']); ?>
<?php echo JHtml::_('uitab.addTab', 'main', 'details', JText::_('CON_RULES')); ?>
<div class="hide-on-update-summary position-relative">
<div class="rl-spinner rl-spinner-lg"></div>
</div>
<div class="row show-on-update-summary hidden">
<div id="conditionsFormFields" class="col-lg-8">
<?php echo $this->form->renderFieldset('rules'); ?>
</div>
<div class="col-lg-4">
<h3><?php echo JText::_('CON_SUMMARY'); ?></h3>
<div id="rules_summary" class="position-relative">
<div id="rules_summary_content" class="hidden"></div>
</div>
</div>
</div>
<?php echo JHtml::_('uitab.endTab'); ?>
<?php
$title = JText::_('CON_USAGE')
. ' <span class="badge bg-secondary">' . $this->item->nr_of_uses . '</span>';
?>
<?php echo JHtml::_('uitab.addTab', 'main', 'variables', $title); ?>
<?php if (empty($this->item->usage)): ?>
<div class="alert alert-warning">
<?php echo JText::_('CON_NOT_USED'); ?>
</div>
<?php else: ?>
<p><?php echo JText::_('CON_USED_ON'); ?></p>
<?php foreach ($this->item->usage as $extension_name => $extension_usage) : ?>
<?php $extension_name = Helper::getExtensionName($extension_name); ?>
<h3><?php echo $extension_name; ?></h3>
<ul>
<?php foreach ($extension_usage as $usage_items) : ?>
<li>
<?php if ($usage_items->url): ?>
<a href="<?php echo $usage_items->url; ?>" target="_blank">
<?php echo $usage_items->item_name; ?>
</a>
<?php else: ?>
<?php echo $usage_items->item_name; ?>
<?php endif; ?>
<small>[<?php echo JText::_('JGLOBAL_FIELD_ID_LABEL'); ?>
: <?php echo $usage_items->item_id; ?>]</small>
<?php if ($usage_items->published !== 1): ?>
<span class="badge bg-danger"><?php echo Helper::getPublishStateString($usage_items->published); ?></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endforeach; ?>
<?php endif; ?>
<?php echo JHtml::_('uitab.endTab'); ?>
<?php echo JHtml::_('uitab.addTab', 'main', 'variables', JText::_('JDETAILS')); ?>
<?php echo $this->form->renderFieldset('details'); ?>
<?php echo JHtml::_('uitab.endTab'); ?>
<?php echo JHtml::_('uitab.endTabSet'); ?>
<input type="hidden" name="task" value="">
<?php echo JHtml::_('form.token'); ?>
</fieldset>
</form>

View File

@ -0,0 +1,17 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
?>
<div class="alert alert-error">
Oops, something went wromg!
</div>

View File

@ -0,0 +1,140 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Layout\LayoutHelper as JLayout;
use Joomla\CMS\Router\Route as JRoute;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Input as RL_Input;
use RegularLabs\Library\Language as RL_Language;
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$canEdit = $user->authorise('core.edit', 'com_conditions');
if ( ! $canEdit)
{
throw new NotAllowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
$id = RL_Input::getInt('id');
$table = RL_Input::getCmd('table');
$name_column = RL_Input::getCmd('name_column');
$enabled_types = RL_Input::getString('enabled_types');
$message = RL_Input::get('message', '');
RL_Document::useScript('keepalive');
RL_Document::useScript('form.validate');
RL_Document::usePreset('choicesjs');
RL_Document::useScript('webcomponent.field-fancy-select');
RL_Document::script('regularlabs.regular');
RL_Document::script('regularlabs.admin-form');
RL_Document::script('regularlabs.admin-form-descriptions');
RL_Document::script('regularlabs.treeselect');
RL_Document::script('conditions.script');
$script = "document.addEventListener('DOMContentLoaded', function(){RegularLabs.Conditions.init()});";
RL_Document::scriptDeclaration($script, 'Conditions', true, 'after');
$update = '';
if ($extension && $item_id)
{
$update = 'parent.RegularLabs.Conditions.updateSummaryByExtension("' . $extension . '", ' . $item_id . ', "' . $message . '", "' . $enabled_types . '");';
}
if ($id)
{
$update = 'parent.RegularLabs.Conditions.updateSummaryByCondition(' . $id . ', "' . $extension . '", "' . $message . '", "' . $enabled_types . '");';
}
$script = '
document.addEventListener("DOMContentLoaded", function(){
window.parent.document.querySelectorAll(".modal-dialog .conditions-button").forEach((btn) => {
Regular.removeClass(btn, "hidden");
});
});';
if ($update)
{
$script .= '
document.addEventListener("DOMContentLoaded", function(){
const modal = window.parent.Joomla.Modal && window.parent.Joomla.Modal.getCurrent();
if (modal) {
modal.addEventListener("hidden.bs.modal", () => {
' . $update . '
});
}
});';
}
RL_Document::scriptDeclaration($script, 'ConditionsModal', true, 'after', true);
RL_Language::load('com_content', JPATH_ADMINISTRATOR);
$params = [
'id' => (int) $this->item->id,
'extension' => $extension,
'item_id' => $item_id,
'table' => $table,
'name_column' => $name_column,
'enabled_types' => $enabled_types,
'message' => $message,
'tmpl' => RL_Input::getString('tmpl'),
];
$append = http_build_query($params);
$url = 'index.php?option=com_conditions&' . $append;
?>
<?php if (count($this->item->usage) > 1) : ?>
<div class="alert alert-warning">
<?php echo JText::_('CON_WARNING_FOR_EDITING_MULTIPLE_USAGE'); ?>
</div>
<?php endif; ?>
<form action="<?php echo JRoute::_($url); ?>"
method="post" name="adminForm" id="conditionsForm"
aria-label="<?php echo JText::_('COM_CONDITIONS_FORM_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>"
class="form-validate rl-form">
<?php echo JLayout::render('joomla.edit.title_alias', $this); ?>
<div class="hide-on-update-summary position-relative">
<div class="rl-spinner rl-spinner-lg"></div>
</div>
<div class="row show-on-update-summary hidden">
<div id="conditionsFormFields" class="col-lg-8">
<?php echo $this->form->renderFieldset('rules'); ?>
</div>
<div class="col-lg-4">
<h3><?php echo JText::_('CON_SUMMARY'); ?></h3>
<div id="rules_summary" class="position-relative">
<div id="rules_summary_content" class="hidden"></div>
</div>
</div>
</div>
<input type="hidden" name="extension" value="<?php echo $extension; ?>">
<input type="hidden" name="item_id" value="<?php echo $item_id; ?>">
<input type="hidden" name="enabled_types" value="<?php echo $enabled_types; ?>">
<input type="hidden" name="message" value="<?php echo $message; ?>">
<input type="hidden" name="task" value="">
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1,90 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 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 Joomla\CMS\Router\Route as JRoute;
use RegularLabs\Component\Conditions\Administrator\Helper\Helper;
use RegularLabs\Library\Input as RL_Input;
use RegularLabs\Library\StringHelper as RL_String;
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$canCreate = $user->authorise('core.create', 'com_conditions');
$canEdit = $user->authorise('core.edit', 'com_conditions');
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
$table = RL_Input::getCmd('table');
$name_column = RL_Input::getCmd('name_column');
$enabled_types = RL_Input::getString('enabled_types');
$message = RL_Input::get('message', '');
$current_item_name = $this->item->usage[$extension][$item_id]->item_name ?? null;
$url = 'index.php?option=com_conditions'
. '&view=item'
. '&id=' . $this->item->id
. '&extension=' . $extension
. '&item_id=' . $item_id
. '&table=' . $table
. '&name_column=' . $name_column
. '&enabled_types=' . $enabled_types
. '&message=' . $message
. '&layout=modal_edit'
. '&tmpl=component';
?>
<div class="alert alert-warning">
<p><?php echo JText::_('CON_USED_ON'); ?></p>
<?php if ( ! empty($this->item->name)) : ?>
<h3><?php echo RL_String::escape($this->item->name); ?></h3>
<?php endif; ?>
<?php foreach ($this->item->usage as $extension_name => $extension_usage) : ?>
<?php $extension_name = Helper::getExtensionName($extension_name); ?>
<span class="badge badge-sm bg-secondary"><?php echo $extension_name; ?></span>
<ul class="mb-1">
<?php foreach ($extension_usage as $usage_item) : ?>
<?php $is_current = ($usage_item->extension == $extension && $usage_item->item_id == $item_id); ?>
<li>
<?php echo $is_current ? '<strong>' : ''; ?>
[<?php echo $usage_item->item_id; ?>] <?php echo $usage_item->item_name; ?>
<?php echo $is_current ? '</strong>' : ''; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endforeach; ?>
</div>
<div class="text-center">
<?php if ($canCreate && $canEdit) : ?>
<p><?php echo JText::_('CON_WHAT_TO_DO'); ?></p>
<?php endif; ?>
<p>
<?php if ($canCreate) : ?>
<a class="btn btn-primary" title="<?php echo JText::_('CON_BUTTON_COPY', true); ?>"
href="<?php echo JRoute::_($url . '&task=item.copy'); ?>">
<span class="icon-copy" aria-hidden="true"></span>
<?php echo JText::sprintf('CON_BUTTON_CONFIRM_COPY', $current_item_name ? ': ' . $current_item_name : ''); ?>
</a>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a class="btn btn-warning" title="<?php echo JText::_('CON_BUTTON_EDIT', true); ?>"
href="<?php echo JRoute::_($url . '&task=item.edit'); ?>">
<span class="icon-edit" aria-hidden="true"></span>
<?php echo JText::sprintf('CON_BUTTON_CONFIRM_EDIT', $current_item_name ? ': ' . $current_item_name : ''); ?>
</a>
<?php endif; ?>
</p>
</div>

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 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 Joomla\CMS\Router\Route as JRoute;
use RegularLabs\Library\Input as RL_Input;
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$canDelete = $user->authorise('core.delete', 'com_conditions');
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
$table = RL_Input::getCmd('table');
$name_column = RL_Input::getCmd('name_column');
$current_item_name = $this->item->usage[$extension][$item_id]->item_name ?? null;
$url = 'index.php?option=com_conditions'
. '&view=item'
. '&id=' . $this->item->id
. '&extension=' . $extension
. '&item_id=' . $item_id
. '&table=' . $table
. '&name_column=' . $name_column
. '&task=item.remove_mapping'
. '&tmpl=component'
?>
<div class="text-center">
<p>
<?php echo JText::_('CON_ONLY_ITEM_USING_CONDITION'); ?>
<?php if ($canDelete) : ?>
<br>
<?php echo JText::_('CON_WHAT_TO_DO'); ?>
<?php endif; ?>
</p>
<p>
<a class="btn btn-primary" title="<?php echo JText::_('CON_BUTTON_REMOVE', true); ?>"
href="<?php echo JRoute::_($url . '&remove=1'); ?>">
<span class="icon-times" aria-hidden="true"></span>
<?php echo JText::sprintf('CON_BUTTON_CONFIRM_REMOVE_BUT_KEEP', $current_item_name ? ': ' . $current_item_name : ''); ?>
</a>
<?php if ($canDelete) : ?>
<a class="btn btn-danger" title="<?php echo JText::_('CON_BUTTON_REMOVE', true); ?>"
href="<?php echo JRoute::_($url . '&remove=all'); ?>"
onclick="return confirm('<?php echo JText::_('RL_ARE_YOU_SURE', true); ?>')">
<span class="icon-trash" aria-hidden="true"></span>
<?php echo JText::_('CON_BUTTON_CONFIRM_REMOVE_COMPLETELY'); ?>
</a>
<?php endif; ?>
</p>
</div>

View File

@ -0,0 +1,49 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 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\Document as RL_Document;
use RegularLabs\Library\Input as RL_Input;
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
$id = RL_Input::getInt('id');
$enabled_types = RL_Input::getString('enabled_types');
$message = RL_Input::get('message', '');
$update = 'parent.RegularLabs.Conditions.updateSummaryByExtension("' . $extension . '", ' . $item_id . ', "' . $message . '", "' . $enabled_types . '");';
if ($id)
{
$update = 'parent.RegularLabs.Conditions.updateSummaryByCondition(' . $id . ', "' . $extension . '", "' . $message . '", "' . $enabled_types . '");';
}
$script = '
const modal = window.parent.Joomla.Modal && window.parent.Joomla.Modal.getCurrent();
if (modal) {
modal.addEventListener("shown.bs.modal", () => {
setTimeout(()=>{modal.close();}, 500);
});
modal.addEventListener("hidden.bs.modal", () => {
' . $update . '
});
modal.close();
} else {
' . $update . '
}
';
RL_Document::scriptDeclaration($script, 'ConditionsModal', true, 'after');
?>
<div class="rl-spinner rl-spinner-lg"></div>

View File

@ -0,0 +1,196 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 Regular Labs All Rights Reserved
* @license GNU General Public License version 2 or later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Filter\OutputFilter as JFilterOutput;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Layout\LayoutHelper as JLayout;
use Joomla\CMS\Router\Route as JRoute;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Form\Field\MiniColorField;
use RegularLabs\Library\StringHelper as RL_String;
use RegularLabs\Library\Version as RL_Version;
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$canAccess = $user->authorise('core.admin', 'com_conditions');
if ( ! $canAccess)
{
throw new NotAllowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$canCreate = $user->authorise('core.create', 'com_conditions');
$canEdit = $user->authorise('core.edit', 'com_conditions');
$canChange = $user->authorise('core.edit.state', 'com_conditions');
$canCheckin = $user->authorise('core.manage', 'com_checkin');
RL_Document::style('regularlabs.admin-form');
$listOrder = RL_String::escape($this->state->get('list.ordering'));
$listDirn = RL_String::escape($this->state->get('list.direction'));
$ordering = ($listOrder == 'a.name');
$filter_state = $this->state->get('filter.state') ?: 1;
$showColors = $this->config->use_colors;
$showCategories = ($this->hasCategories && $this->config->use_categories);
?>
<form action="<?php echo JRoute::_('index.php?option=com_conditions&view=items'); ?>"
method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
<?php
// Search tools bar
echo JLayout::render('joomla.searchtools.default', ['view' => $this]);
?>
<table class="table table-striped" id="itemList">
<thead>
<tr>
<td scope="col" class="w-1 text-center">
<?php echo JHtml::_('grid.checkall'); ?>
</td>
<?php if ($showColors) : ?>
<th scope="col" class="w-1 text-center d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', '', 'a.color', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if ($filter_state != 1): ?>
<th scope="col" class="w-1 text-nowrap text-center">
<?php echo JText::_('JSTATUS'); ?>
</th>
<?php endif; ?>
<th scope="col" class="">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.name', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_DESCRIPTION', 'a.description', $listDirn, $listOrder); ?>
</th>
<?php if ($showCategories) : ?>
<th scope="col" class="w-10 d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JCATEGORY', 'a.category', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<th scope="col" class="w-1 text-nowrap text-center d-none d-md-table-cell">
<?php echo JText::_('CON_USAGE'); ?>
</th>
<th scope="col" class="w-1 text-nowrap text-center d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tbody>
<?php if (empty($this->items)): ?>
<tr>
<td colspan="5">
<?php echo JText::_('RL_NO_ITEMS_FOUND'); ?>
</td>
</tr>
<?php else: ?>
<?php foreach ($this->items as $i => $item) : ?>
<?php
$canCheckinItem = ($canCheckin || $item->checked_out == 0 || $item->checked_out == $user->get('id'));
$canChangeItem = ($canChange && $canCheckinItem);
$description = explode('---', $item->description);
?>
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo JFilterOutput::stringURLSafe($item->category) ?: 'no-group'; ?>">
<td class="text-center d-none d-md-table-cell">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<?php if ($showColors) : ?>
<td class="center inlist">
<?php
$colorfield = new MiniColorField;
$color = $item->color ?? '';
$element = new SimpleXMLElement(
'<field
id="color_' . $i . '"
name="color_' . $i . '"
type="MiniColor"
default=""
colors="' . ($this->config->main_colors ?? '') . '"
table="conditions"
item_id="' . $item->id . '"
/>'
);
$element->value = $color;
$colorfield->setup($element, $color);
echo $colorfield->__get('input');
?>
</td>
<?php endif; ?>
<?php if ($filter_state != 1): ?>
<td class="text-center">
<span class="tbody-icon">
<?php echo JLayout::render('joomla.icon.iconclass', ['icon' => $item->published == 1 ? 'icon-check' : 'icon-trash']); ?>
</span>
</td>
<?php endif; ?>
<td>
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'items.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_conditions&task=item.edit&id=' . $item->id); ?>">
<?php echo RL_String::escape($item->name); ?></a>
<?php else : ?>
<span title="<?php echo JText::sprintf('JFIELD_ALIAS_LABEL', RL_String::escape($item->alias)); ?>">
<?php echo RL_String::escape($item->name); ?>
</span>
<?php endif; ?>
<div class="small break-word">
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', RL_String::escape($item->alias)); ?>
</div>
</td>
<td class="d-none d-md-table-cell">
<span><?php echo nl2br(RL_String::escape(trim($description[0]))); ?></span>
<?php if ( ! empty($description[1])) : ?>
<div role="tooltip"><?php echo nl2br(RL_String::escape(trim($description[1]))); ?></div>
<?php endif; ?>
</td>
<?php if ($showCategories) : ?>
<td class="small d-none d-md-table-cell">
<?php echo $item->category ? '<span class="badge rl-bg-teal">' . $item->category . '</span>' : ''; ?>
</td>
<?php endif; ?>
<td class="text-center d-none d-md-table-cell">
<span class="badge bg-secondary<?php echo ! $item->nr_of_uses ? ' opacity-50' : ''; ?>">
<?php echo $item->nr_of_uses; ?>
</span>
</td>
<td class="text-center d-none d-md-table-cell">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php // load the pagination. ?>
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?php echo JHtml::_('form.token'); ?>
</form>
<?php
// Copyright
echo RL_Version::getFooter('CONDITIONS', true, false);

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 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\Filter\OutputFilter as JFilterOutput;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Layout\LayoutHelper as JLayout;
use Joomla\CMS\Router\Route as JRoute;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Input as RL_Input;
use RegularLabs\Library\StringHelper as RL_String;
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
$table = RL_Input::getCmd('table');
$name_column = RL_Input::getCmd('name_column');
$enabled_types = RL_Input::getString('enabled_types');
$message = RL_Input::get('message', '');
if (empty($extension))
{
JFactory::getApplication()->enqueueMessage(
JText::_('Direct access forbidden.'),
'error'
);
return;
}
RL_Document::style('regularlabs.admin-form');
$listOrder = RL_String::escape($this->state->get('list.ordering'));
$listDirn = RL_String::escape($this->state->get('list.direction'));
$ordering = ($listOrder == 'a.name');
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$canCreate = $user->authorise('core.create', 'com_conditions');
$canEdit = $user->authorise('core.edit', 'com_conditions');
$canChange = $user->authorise('core.edit.state', 'com_conditions');
$canCheckin = $user->authorise('core.manage', 'com_checkin');
$form_url = 'index.php?option=com_conditions&view=items'
. '&layout=modal&tmpl=component'
. '&extension=' . $extension
. '&item_id=' . $item_id
. '&table=' . $table
. '&enabled_types=' . $enabled_types
. '&message=' . $message
. '&name_column=' . $name_column;
$link_url = 'index.php?option=com_conditions&view=item'
. '&task=item.map'
. '&extension=' . $extension
. '&item_id=' . $item_id
. '&table=' . $table
. '&enabled_types=' . $enabled_types
. '&message=' . $message
. '&name_column=' . $name_column;
$this->filterForm->removeField('state', 'filter');
?>
<form action="<?php echo JRoute::_($form_url); ?>"
method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
<?php
// Search tools bar
echo JLayout::render('joomla.searchtools.default', ['view' => $this]);
?>
<table class="table table-striped" id="itemList">
<thead>
<tr>
<th scope="col" class="">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.name', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_DESCRIPTION', 'a.description', $listDirn, $listOrder); ?>
</th>
<th scope="col" class="w-1 text-nowrap text-center d-none d-md-table-cell">
<?php echo JText::_('CON_USAGE'); ?>
</th>
<th scope="col" class="w-1 text-nowrap text-center d-none d-md-table-cell">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tbody>
<?php if (empty($this->items)): ?>
<tr>
<td colspan="4">
<?php echo JText::_('RL_NO_ITEMS_FOUND'); ?>
</td>
</tr>
<?php else: ?>
<?php foreach ($this->items as $i => $item) : ?>
<?php
$canCheckinItem = ($canCheckin || $item->checked_out == 0 || $item->checked_out == $user->get('id'));
$canChangeItem = ($canChange && $canCheckinItem);
$isPublished = $item->published === 1;
$description = explode('---', $item->description);
?>
<tr class="row<?php echo $i % 2; ?><?php echo $isPublished ? '' : ' muted'; ?>" data-draggable-group="<?php echo JFilterOutput::stringURLSafe($item->category) ?: 'no-group'; ?>">
<td>
<?php if ($isPublished) : ?>
<a class="btn btn-primary" title="<?php echo JText::sprintf('JFIELD_ALIAS_LABEL', RL_String::escape($item->alias)); ?>"
href="<?php echo JRoute::_($link_url . '&id=' . $item->id); ?>">
<?php echo RL_String::escape($item->name); ?>
</a>
<?php else: ?>
<?php echo RL_String::escape($item->name); ?>
<?php endif; ?>
<div class="small break-word">
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', RL_String::escape($item->alias)); ?>
</div>
<?php if ($item->category) : ?>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': '; ?>
<span class="badge bg-info rl-badge">
<?php echo RL_String::escape($item->category); ?>
</span>
</div>
<?php endif; ?>
</td>
<td class="d-none d-md-table-cell">
<span><?php echo nl2br(RL_String::escape(trim($description[0]))); ?></span>
<?php if ( ! empty($description[1])) : ?>
<div role="tooltip"><?php echo nl2br(RL_String::escape(trim($description[1]))); ?></div>
<?php endif; ?>
</td>
<td class="text-center d-none d-md-table-cell">
<span class="badge bg-secondary<?php echo ! $item->nr_of_uses ? ' opacity-50' : ''; ?>">
<?php echo $item->nr_of_uses; ?>
</span>
</td>
<td class="text-center d-none d-md-table-cell">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php // load the pagination. ?>
<?php echo $this->pagination->getListFooter(); ?>
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1,49 @@
<?php
/**
* @package Conditions
* @version 24.11.1459
*
* @author Peter van Westen <info@regularlabs.com>
* @link https://regularlabs.com
* @copyright Copyright © 2024 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\Document as RL_Document;
use RegularLabs\Library\Input as RL_Input;
$extension = RL_Input::getCmd('extension');
$item_id = RL_Input::getInt('item_id');
$id = RL_Input::getInt('id');
$enabled_types = RL_Input::getString('enabled_types');
$message = RL_Input::get('message', '');
$update = 'parent.RegularLabs.Conditions.updateSummaryByExtension("' . $extension . '", ' . $item_id . ', "' . $message . '", "' . $enabled_types . '");';
if ($id)
{
$update = 'parent.RegularLabs.Conditions.updateSummaryByCondition(' . $id . ', "' . $extension . '", "' . $message . '", "' . $enabled_types . '");';
}
$script = '
const modal = window.parent.Joomla.Modal && window.parent.Joomla.Modal.getCurrent();
if (modal) {
modal.addEventListener("shown.bs.modal", () => {
setTimeout(()=>{modal.close();}, 500);
});
modal.addEventListener("hidden.bs.modal", () => {
' . $update . '
});
modal.close();
} else {
' . $update . '
}
';
RL_Document::scriptDeclaration($script, 'ConditionsModal', true, 'after');
?>
<div class="rl-spinner rl-spinner-lg"></div>