first commit
This commit is contained in:
103
layouts/joomla/searchtools/default.php
Normal file
103
layouts/joomla/searchtools/default.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$data = $displayData;
|
||||
|
||||
// Receive overridable options
|
||||
$data['options'] = !empty($data['options']) ? $data['options'] : [];
|
||||
|
||||
$noResultsText = '';
|
||||
$hideActiveFilters = false;
|
||||
$showFilterButton = false;
|
||||
$showSelector = false;
|
||||
$selectorFieldName = $data['options']['selectorFieldName'] ?? 'client_id';
|
||||
|
||||
// If a filter form exists.
|
||||
if (isset($data['view']->filterForm) && !empty($data['view']->filterForm)) {
|
||||
// Checks if a selector (e.g. client_id) exists.
|
||||
if ($selectorField = $data['view']->filterForm->getField($selectorFieldName)) {
|
||||
$showSelector = $selectorField->getAttribute('filtermode', '') === 'selector' ? true : $showSelector;
|
||||
|
||||
// Checks if a selector should be shown in the current layout.
|
||||
if (isset($data['view']->layout)) {
|
||||
$showSelector = $selectorField->getAttribute('layout', 'default') != $data['view']->layout ? false : $showSelector;
|
||||
}
|
||||
|
||||
// Unset the selector field from active filters group.
|
||||
unset($data['view']->activeFilters[$selectorFieldName]);
|
||||
}
|
||||
|
||||
// Checks if the filters button should exist.
|
||||
$filters = $data['view']->filterForm->getGroup('filter');
|
||||
$showFilterButton = isset($filters['filter_search']) && count($filters) === 1 ? false : true;
|
||||
|
||||
// Checks if it should show the be hidden.
|
||||
$hideActiveFilters = empty($data['view']->activeFilters);
|
||||
|
||||
// Check if the no results message should appear.
|
||||
if (isset($data['view']->total) && (int) $data['view']->total === 0) {
|
||||
$noResults = $data['view']->filterForm->getFieldAttribute('search', 'noresults', '', 'filter');
|
||||
if (!empty($noResults)) {
|
||||
$noResultsText = Text::_($noResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set some basic options.
|
||||
$customOptions = [
|
||||
'filtersHidden' => isset($data['options']['filtersHidden']) && $data['options']['filtersHidden'] ? $data['options']['filtersHidden'] : $hideActiveFilters,
|
||||
'filterButton' => isset($data['options']['filterButton']) && $data['options']['filterButton'] ? $data['options']['filterButton'] : $showFilterButton,
|
||||
'defaultLimit' => $data['options']['defaultLimit'] ?? Factory::getApplication()->get('list_limit', 20),
|
||||
'searchFieldSelector' => '#filter_search',
|
||||
'selectorFieldName' => $selectorFieldName,
|
||||
'showSelector' => $showSelector,
|
||||
'orderFieldSelector' => '#list_fullordering',
|
||||
'showNoResults' => !empty($noResultsText),
|
||||
'noResultsText' => !empty($noResultsText) ? $noResultsText : '',
|
||||
'formSelector' => !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm',
|
||||
];
|
||||
|
||||
// Merge custom options in the options array.
|
||||
$data['options'] = array_merge($customOptions, $data['options']);
|
||||
|
||||
// Add class to hide the active filters if needed.
|
||||
$filtersActiveClass = $hideActiveFilters ? '' : ' js-stools-container-filters-visible';
|
||||
|
||||
// Load search tools
|
||||
HTMLHelper::_('searchtools.form', $data['options']['formSelector'], $data['options']);
|
||||
?>
|
||||
<div class="js-stools" role="search">
|
||||
<?php if ($data['options']['showSelector']) : ?>
|
||||
<div class="js-stools-container-selector">
|
||||
<?php echo $this->sublayout('selector', $data); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="js-stools-container-bar">
|
||||
<div class="btn-toolbar">
|
||||
<?php echo $this->sublayout('bar', $data); ?>
|
||||
<?php echo $this->sublayout('list', $data); ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Filters div -->
|
||||
<div class="js-stools-container-filters clearfix<?php echo $filtersActiveClass; ?>">
|
||||
<?php if ($data['options']['filterButton']) : ?>
|
||||
<?php echo $this->sublayout('filters', $data); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($data['options']['showNoResults']) : ?>
|
||||
<?php echo $this->sublayout('noitems', $data); ?>
|
||||
<?php endif; ?>
|
||||
62
layouts/joomla/searchtools/default/bar.php
Normal file
62
layouts/joomla/searchtools/default/bar.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
$data = $displayData;
|
||||
|
||||
// Receive overridable options
|
||||
$data['options'] = !empty($data['options']) ? $data['options'] : [];
|
||||
|
||||
if (is_array($data['options'])) {
|
||||
$data['options'] = new Registry($data['options']);
|
||||
}
|
||||
|
||||
// Options
|
||||
$filterButton = $data['options']->get('filterButton', true);
|
||||
$searchButton = $data['options']->get('searchButton', true);
|
||||
|
||||
$filters = $data['view']->filterForm->getGroup('filter');
|
||||
|
||||
if (empty($filters['filter_search']) || !$searchButton) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="filter-search-bar btn-group">
|
||||
<div class="input-group">
|
||||
<?php echo $filters['filter_search']->input; ?>
|
||||
<?php if ($filters['filter_search']->description) : ?>
|
||||
<div role="tooltip" id="<?php echo ($filters['filter_search']->id ?: $filters['filter_search']->name) . '-desc'; ?>" class="filter-search-bar__description">
|
||||
<?php echo htmlspecialchars(Text::_($filters['filter_search']->description), ENT_COMPAT, 'UTF-8'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<span class="filter-search-bar__label visually-hidden">
|
||||
<?php echo $filters['filter_search']->label; ?>
|
||||
</span>
|
||||
<button type="submit" class="filter-search-bar__button btn btn-primary" aria-label="<?php echo Text::_('JSEARCH_FILTER_SUBMIT'); ?>">
|
||||
<span class="filter-search-bar__button-icon icon-search" aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-search-actions btn-group">
|
||||
<?php if ($filterButton) : ?>
|
||||
<button type="button" class="filter-search-actions__button btn btn-primary js-stools-btn-filter">
|
||||
<?php echo Text::_('JFILTER_OPTIONS'); ?>
|
||||
<span class="icon-angle-down" aria-hidden="true"></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="filter-search-actions__button btn btn-primary js-stools-btn-clear">
|
||||
<?php echo Text::_('JSEARCH_FILTER_CLEAR'); ?>
|
||||
</button>
|
||||
</div>
|
||||
39
layouts/joomla/searchtools/default/filters.php
Normal file
39
layouts/joomla/searchtools/default/filters.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\FormHelper;
|
||||
|
||||
$data = $displayData;
|
||||
|
||||
// Load the form filters
|
||||
$filters = $data['view']->filterForm->getGroup('filter');
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
|
||||
|
||||
?>
|
||||
<?php if ($filters) : ?>
|
||||
<?php foreach ($filters as $fieldName => $field) : ?>
|
||||
<?php if ($fieldName !== 'filter_search') : ?>
|
||||
<?php $dataShowOn = ''; ?>
|
||||
<?php if ($field->showon) : ?>
|
||||
<?php $wa->useScript('showon'); ?>
|
||||
<?php $dataShowOn = " data-showon='" . json_encode(FormHelper::parseShowOnConditions($field->showon, $field->formControl, $field->group)) . "'"; ?>
|
||||
<?php endif; ?>
|
||||
<div class="js-stools-field-filter"<?php echo $dataShowOn; ?>>
|
||||
<span class="visually-hidden"><?php echo $field->label; ?></span>
|
||||
<?php echo $field->input; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
27
layouts/joomla/searchtools/default/list.php
Normal file
27
layouts/joomla/searchtools/default/list.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
$data = $displayData;
|
||||
|
||||
// Load the form list fields
|
||||
$list = $data['view']->filterForm->getGroup('list');
|
||||
?>
|
||||
<?php if ($list) : ?>
|
||||
<div class="ordering-select">
|
||||
<?php foreach ($list as $fieldName => $field) : ?>
|
||||
<div class="js-stools-field-list">
|
||||
<span class="visually-hidden"><?php echo $field->label; ?></span>
|
||||
<?php echo $field->input; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
20
layouts/joomla/searchtools/default/noitems.php
Normal file
20
layouts/joomla/searchtools/default/noitems.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$data = $displayData;
|
||||
?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo $data['options']['noResultsText']; ?>
|
||||
</div>
|
||||
20
layouts/joomla/searchtools/default/selector.php
Normal file
20
layouts/joomla/searchtools/default/selector.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
$data = $displayData;
|
||||
?>
|
||||
<div class="js-stools-field-selector">
|
||||
<div class="visually-hidden">
|
||||
<?php echo $data['view']->filterForm->getField($data['options']['selectorFieldName'])->label; ?>
|
||||
</div>
|
||||
<?php echo $data['view']->filterForm->getField($data['options']['selectorFieldName'])->input; ?>
|
||||
</div>
|
||||
54
layouts/joomla/searchtools/grid/sort.php
Normal file
54
layouts/joomla/searchtools/grid/sort.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$data = $displayData;
|
||||
$icon = 'icon-sort';
|
||||
$sort = '';
|
||||
$caption = '';
|
||||
$selected = '';
|
||||
$id = '';
|
||||
|
||||
if ($data->order === $data->selected) :
|
||||
$icon = $data->orderIcon;
|
||||
$sort = $data->direction === 'asc' ? 'descending' : 'ascending';
|
||||
$heading = !empty($data->title) ? Text::_($data->title) : Text::_('JGRID_HEADING_ORDERING');
|
||||
$caption = Text::sprintf('JGRID_HEADING_CAPTION_' . ($data->direction === 'asc' ? 'desc' : 'asc'), $heading);
|
||||
$selected = ' selected';
|
||||
$id = 'id="sorted"';
|
||||
endif;
|
||||
|
||||
Factory::getDocument()->getWebAssetManager()->useScript('list-view');
|
||||
?>
|
||||
|
||||
<a href="#" class="js-stools-column-order<?php echo $selected; ?> js-stools-button-sort"
|
||||
<?php echo $id; ?>
|
||||
data-order="<?php echo $data->order; ?>"
|
||||
data-direction="<?php echo strtoupper($data->direction); ?>"
|
||||
data-caption="<?php echo $caption; ?>"
|
||||
<?php if (!empty($sort)) : ?>
|
||||
data-sort="<?php echo $sort; ?>"
|
||||
<?php endif; ?>>
|
||||
<?php // The following statement has been concatenated purposely to remove whitespace. ?>
|
||||
<?php // Please leave as is. ?>
|
||||
<?php if (!empty($data->title)) :
|
||||
?><span><?php echo Text::_($data->title); ?></span><?php
|
||||
endif; ?><span
|
||||
class="ms-1 <?php echo $icon; ?>"
|
||||
aria-hidden="true"></span>
|
||||
<span class="visually-hidden">
|
||||
<?php echo Text::_('JGLOBAL_SORT_BY'); ?>
|
||||
<?php echo (!empty($data->title)) ? Text::_($data->title) : Text::_('JGRID_HEADING_ORDERING'); ?>
|
||||
</span>
|
||||
</a>
|
||||
Reference in New Issue
Block a user