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,44 @@
<?php
/**
* @package OSMap
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2021-2024 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSMap.
*
* OSMap is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
*/
// phpcs:disable PSR1.Files.SideEffects
defined('_JEXEC') or die();
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
trait TraitOsmapField
{
/**
* @inheritDoc
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
if (is_callable([parent::class, 'setup']) && parent::setup($element, $value, $group)) {
$include = JPATH_ADMINISTRATOR . '/components/com_osmap/include.php';
return is_file($include) && include $include;
}
return $this->enabled;
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* @package ShackDefaultFiles
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2015-2021 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of ShackDefaultFiles.
*
* ShackDefaultFiles is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* ShackDefaultFiles is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ShackDefaultFiles. If not, see <https://www.gnu.org/licenses/>.
*/
use Joomla\CMS\Form\FormField;
defined('_JEXEC') or die();
/**
* Class ShackFormFieldBase
*
* @property bool $fromInstaller
*/
class ShackFormFieldBase extends FormField
{
/**
* @var bool
*/
protected $fromInstaller = false;
public function __set($name, $value = null)
{
switch ($name) {
case 'fromInstaller':
$this->fromInstaller = (bool)$value;
break;
default:
parent::__set($name, $value);
}
}
/**
* @inheritDoc
*/
protected function getInput()
{
return '';
}
/**
* @param ?string $path
*
* @return string
*/
protected function getStyle(?string $path): string
{
if ($path && is_file($path)) {
return '<style>' . file_get_contents($path) . '</style>';
}
return '';
}
/**
* @inheritDoc
*/
protected function getLabel()
{
return '';
}
/**
* @param SimpleXMLElement $element
*
* @return ?string
*/
public function getInputUsingCustomElement(SimpleXMLElement $element): ?string
{
$this->element = $element;
$this->setup($element, null);
return $this->getInput();
}
}

View File

@ -0,0 +1,176 @@
<?php
/**
* @package ShackDefaultFiles
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2015-2024 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of ShackDefaultFiles.
*
* ShackDefaultFiles is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* ShackDefaultFiles is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ShackDefaultFiles. If not, see <https://www.gnu.org/licenses/>.
*/
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
// phpcs:disable PSR1.Files.SideEffects
defined('_JEXEC') or die();
// phpcs:enable PSR1.Files.SideEffects
// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
/**
* @property bool $fromInstaller
*/
class JFormFieldCustomFooter extends FormField
{
/**
* @inheritdoc
*/
protected $layout = 'alledia.customfooter';
/**
* @var bool
*/
protected $fromInstaller = false;
/**
* @inheritDoc
*/
public function __set($name, $value = null)
{
switch ($name) {
case 'fromInstaller':
$this->fromInstaller = (bool)$value;
break;
default:
parent::__set($name, $value);
}
}
/**
* @inheritDoc
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
if ($path = realpath(__DIR__ . '/../..')) {
Factory::getLanguage()->load('shackdefaultfiles', $path);
}
return parent::setup($element, $value, $group);
}
/**
* @inheritDoc
*/
protected function getInput()
{
return $this->getRenderer($this->layout)->render($this->getLayoutData());
}
/**
* @inheritDoc
*/
protected function getRenderer($layoutId = 'default')
{
$renderer = parent::getRenderer($layoutId);
if ($layoutId == $this->layout) {
$renderer->addIncludePath(__DIR__ . '/layouts');
}
return $renderer;
}
/**
* @inheritDoc
*/
protected function getLayoutData()
{
$displayData = parent::getLayoutData();
$requiredClasses = [
'joomlashack-footer',
'row-fluid'
];
if ($this->fromInstaller) {
$requiredClasses[] = 'installer';
}
$classes = array_unique(
array_filter(
array_merge(
preg_split('/\s/', $displayData['class']),
$requiredClasses
)
)
);
$goProUrl = (string)$this->element['showgoproad'] ?: '0';
$showGoProAd = !($goProUrl == '0' || $goProUrl == 'false');
if ($showGoProAd && !filter_var($goProUrl, FILTER_VALIDATE_URL)) {
$goProUrl = 'https://www.joomlashack.com/plans';
}
return array_merge(
$displayData,
[
'class' => join(' ', $classes),
'media' => $this->element['media'],
'jslogo' => (string)$this->element['jslogo'] ?: 'joomlashack-logo.png',
'jshome' => (string)$this->element['jshome'] ?: 'https://www.joomlashack.com',
'jedurl' => (string)$this->element['jedurl'],
'fromInstaller' => $this->fromInstaller,
'showGoProAd' => $showGoProAd,
'goProUrl' => $goProUrl
]
);
}
/**
* @param ?string $path
*
* @return string
* @TODO: Doesn't seem to be useful
*/
protected function getStyle(?string $path): string
{
if ($path && is_file($path)) {
return '<style>' . file_get_contents($path) . '</style>';
}
return '';
}
/**
* @inheritDoc
*/
protected function getLabel()
{
return '';
}
/**
* @param SimpleXMLElement $element
*
* @return ?string
*/
public function getInputUsingCustomElement(SimpleXMLElement $element): ?string
{
$this->element = $element;
$this->setup($element, null);
return $this->getInput();
}
}

View File

@ -0,0 +1,112 @@
<?php
/**
* @package ShackDefaultFiles
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2018-2024 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of ShackDefaultFiles.
*
* ShackDefaultFiles is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* ShackDefaultFiles is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ShackDefaultFiles. If not, see <https://www.gnu.org/licenses/>.
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
defined('_JEXEC') or die();
/**
* @var array $displayData
*/
$class = $displayData['class'];
$media = $displayData['media'];
$jslogo = $media . '/' . $displayData['jslogo'];
$jedurl = $displayData['jedurl'];
$showGoProAd = $displayData['showGoProAd'];
$goProUrl = $displayData['goProUrl'];
$fromInstaller = $displayData['fromInstaller'];
$footerCss = HTMLHelper::_('stylesheet', $media . '/field_customfooter.css', ['relative' => true, 'pathOnly' => true]);
$adminCss = HTMLHelper::_('stylesheet', $media . '/admin-default.css', ['relative' => true, 'pathOnly' => true]);
?>
<link href="<?php echo $footerCss; ?>" rel="stylesheet"/>
<link href="<?php echo $adminCss; ?>" rel="stylesheet"/>
<div class="<?php echo $class; ?>">
<div>
<?php
if ($showGoProAd) :
?>
<div class="gopro-ad">
<?php
echo HTMLHelper::_(
'link',
$goProUrl,
Text::_('SHACKDEFAULTFILES_GO_PRO'),
'class="gopto-btn" target="_blank"'
);
?>
</div>
<?php endif;
if ($jedurl) : ?>
<div class="joomlashack-jedlink">
<?php
echo Text::_('SHACKDEFAULTFILES_LIKE_THIS_EXTENSION');
echo '&nbsp;'
. HTMLHelper::_(
'link',
$jedurl,
Text::_('SHACKDEFAULTFILES_LEAVE_A_REVIEW_ON_JED'),
'target="_blank"'
);
echo '&nbsp;' . str_repeat("<i class=\"icon-star\"></i>", 5);
?>
</div>
<?php endif; ?>
<div class="poweredby">
Powered by
<?php
echo HTMLHelper::_(
'link',
'https://www.joomlashack.com',
HTMLHelper::_('image', $jslogo, 'Joomlashack', 'class="joomlashack-logo" width="150"', true),
'target="_blank"'
);
?>
</div>
<div class="joomlashack-copyright">
<?php echo '&copy; ' . date('Y'); ?> Joomlashack.com. All rights reserved.
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let footer = document.getElementsByClassName('joomlashack-footer').item(0),
container = footer ? footer.parentElement : null,
wrapper = null;
if (container && container.classList.contains('controls')) {
wrapper = document.getElementById('content') || document.querySelector('.container-popup');
}
if (footer && wrapper) {
wrapper.parentNode.insertBefore(footer, wrapper.nextSibling);
} else if (footer) {
footer.remove();
}
});
</script>

View File

@ -0,0 +1,195 @@
<?php
/**
* @package OSMap
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2021-2024 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSMap.
*
* OSMap is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
*/
use Alledia\OSMap\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\Utilities\ArrayHelper;
defined('_JEXEC') or die();
/**
* @var FileLayout $this
* @var array $displayData
* @var string $layoutOutput
* @var string $path
*/
/**
* @var string $autocomplete
* @var boolean $autofocus
* @var string $class
* @var string $description
* @var boolean $disabled
* @var FormField $field
* @var NULL $group
* @var boolean $hidden
* @var string $hint
* @var string $id
* @var string $label
* @var string $labelclass
* @var boolean $multiple
* @var string $name
* @var string $onchange
* @var string $onclick
* @var string $pattern
* @var string $validationtext
* @var boolean $readonly
* @var boolean $repeat
* @var boolean $required
* @var integer $size
* @var boolean $spellcheck
* @var string $validate
* @var array[] $value
* @var object[] $options
*/
extract($displayData);
$attributes = [
'type' => $multiple ? 'checkbox' : 'radio',
'size' => $size,
'class' => $class,
];
$sortableId = $id . '_menus';
HTMLHelper::_('jquery.framework');
HTMLHelper::_('draggablelist.draggable');
$script = <<<JSCRIPT
;jQuery(document).ready(function ($) {
let \$ordering = $('#{$id}_menus_ordering'),
drake = dragula([document.querySelector('.osmap-draggable')]);
let menuItems = function() {
return $('#{$sortableId}').find('[id^="{$id}_"]:checkbox');
};
let setOrdering = function() {
let menu_ordering = [];
menuItems().each(function() {
if (this.checked) {
menu_ordering.push('menu_' + this.value);
}
});
\$ordering.val(menu_ordering.join(','));
};
menuItems().on('click', setOrdering);
drake.on('drop', setOrdering);
setOrdering();
});
JSCRIPT;
Factory::getDocument()->addScriptDeclaration($script);
if ($disabled || $readonly) :
$attributes['disabled'] = 'disabled';
endif;
$changeFrequencyLabel = Text::_('COM_OSMAP_CHANGE_FREQUENCY_LABEL');
$priorityLabel = Text::_('COM_OSMAP_PRIORITY_LABEL');
$selectedLabel = Text::_('COM_OSMAP_SELECTED_LABEL');
$titleLabel = Text::_('COM_OSMAP_TITLE_LABEL');
?>
<table id="<?php echo $sortableId; ?>" class="adminlist table table-striped">
<thead>
<tr>
<th scope="col" class="w-1 text-center"><?php echo $selectedLabel; ?></th>
<th scope="col" class="w-10"><?php echo $titleLabel; ?></th>
<th scope="col" class="w-5"><?php echo $priorityLabel; ?></th>
<th scope="col" class="w-5"><?php echo $changeFrequencyLabel; ?></th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
<tbody class="osmap-draggable">
<?php
$currentItems = array_keys($value);
$nameRegex = sprintf('/(%s\[[^]]+)(].*)/', $field->formControl);
foreach ($options as $idx => $option) :
$prioritiesName = preg_replace($nameRegex, '$1_priority$2', $name);
$changeFrequencyName = preg_replace($nameRegex, '$1_changefreq$2', $name);
$selected = isset($value[$option->value]);
$thisId = $id . '_' . $idx;
$changePriorityField = HTMLHelper::_(
'osmap.priorities',
$prioritiesName,
($selected ? number_format($value[$option->value]['priority'], 1) : '0.5'),
$idx
);
$changeChangeFreqField = HTMLHelper::_(
'osmap.changefrequency',
$changeFrequencyName,
($selected ? $value[$option->value]['changefreq'] : 'weekly'),
$idx
);
$currentAttributes = array_filter(
array_merge(
$attributes,
[
'id' => $thisId,
'name' => $name,
'value' => $option->value
]
)
);
if ($selected) :
$currentAttributes['checked'] = 'checked';
endif;
?>
<tr>
<td class="text-center">
<input <?php echo ArrayHelper::toString($currentAttributes); ?>/>
</td>
<td class="text-nowrap">
<label for="<?php echo $thisId . '_id'; ?>" class="menu_label">
<?php echo $option->text; ?>
</label>
</td>
<td class="w2">
<?php echo $changePriorityField; ?>
</td>
<td class="w5">
<?php echo $changeChangeFreqField; ?>
</td>
<td>&nbsp;</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden"
id="<?php echo $id . '_menus_ordering'; ?>"
name="<?php echo sprintf('%s[menus_ordering]', $field->formControl); ?>"
value=""/>

View File

@ -0,0 +1,178 @@
<?php
/**
* @package OSMap
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2021-2024 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSMap.
*
* OSMap is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
*/
use Alledia\OSMap\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\Utilities\ArrayHelper;
defined('_JEXEC') or die();
/**
* @var FileLayout $this
* @var array $displayData
* @var string $layoutOutput
* @var string $path
*/
/**
* @var string $autocomplete
* @var boolean $autofocus
* @var string $class
* @var string $description
* @var boolean $disabled
* @var FormField $field
* @var NULL $group
* @var boolean $hidden
* @var string $hint
* @var string $id
* @var string $label
* @var string $labelclass
* @var boolean $multiple
* @var string $name
* @var string $onchange
* @var string $onclick
* @var string $pattern
* @var string $validationtext
* @var boolean $readonly
* @var boolean $repeat
* @var boolean $required
* @var integer $size
* @var boolean $spellcheck
* @var string $validate
* @var array[] $value
* @var object[] $options
*/
extract($displayData);
$attributes = [
'type' => $multiple ? 'checkbox' : 'radio',
'size' => $size,
'class' => $class,
];
HTMLHelper::_('jquery.ui', ['core', 'sortable']);
HTMLHelper::_('script', 'jui/sortablelist.js', false, true);
HTMLHelper::_('stylesheet', 'jui/sortablelist.css', false, true, false);
$sortableId = $id . '_menus';
$script = <<<JSCRIPT
;jQuery(document).ready(function ($) {
let \$menus = $('#{$sortableId}');
\$menus.sortable({appendTo: document.body})
.on('sortupdate', function() {
let ordering = $(this).sortable('toArray').toString();
$('#{$id}_menus_ordering').val(ordering);
})
.trigger('sortupdate');
});
JSCRIPT;
Factory::getDocument()->addScriptDeclaration($script);
if ($disabled || $readonly) :
$attributes['disabled'] = 'disabled';
endif;
$changeFrequencyLabel = Text::_('COM_OSMAP_CHANGE_FREQUENCY_LABEL');
$priorityLabel = Text::_('COM_OSMAP_PRIORITY_LABEL');
$selectedLabel = Text::_('COM_OSMAP_SELECTED_LABEL');
$titleLabel = Text::_('COM_OSMAP_TITLE_LABEL');
?>
<div class="osmap-table">
<div class="osmap-list-header">
<div class="osmap-cell osmap-col-selected"><?php echo $selectedLabel; ?></div>
<div class="osmap-cell osmap-col-title"><?php echo $titleLabel; ?></div>
<div class="osmap-cell osmap-col-priority"><?php echo $priorityLabel; ?></div>
<div class="osmap-cell osmap-col-changefreq"><?php echo $changeFrequencyLabel; ?></div>
</div>
<ul id="<?php echo $sortableId; ?>" class="ul_sortable">
<?php
$currentItems = array_keys($value);
$nameRegex = sprintf('/(%s\[[^]]+)(].*)/', $field->formControl);
foreach ($options as $idx => $option) :
$prioritiesName = preg_replace($nameRegex, '$1_priority$2', $name);
$changeFrequencyName = preg_replace($nameRegex, '$1_changefreq$2', $name);
$selected = isset($value[$option->value]);
$thisId = $id . '_' . $idx;
$changePriorityField = HTMLHelper::_(
'osmap.priorities',
$prioritiesName,
($selected ? number_format($value[$option->value]['priority'], 1) : '0.5'),
$idx
);
$changeChangeFreqField = HTMLHelper::_(
'osmap.changefrequency',
$changeFrequencyName,
($selected ? $value[$option->value]['changefreq'] : 'weekly'),
$idx
);
$currentAttributes = array_filter(
array_merge(
$attributes,
[
'id' => $thisId,
'name' => $name,
'value' => $option->value
]
)
);
if ($selected) :
$currentAttributes['checked'] = 'checked';
endif;
?>
<li id="<?php echo 'menu_' . $option->value; ?>"
class="osmap-menu-item">
<div class="osmap-cell osmap-col-selected">
<input <?php echo ArrayHelper::toString($currentAttributes); ?>/>
</div>
<div class="osmap-cell osmap-col-title">
<label for="<?php echo $thisId . '_id'; ?>" class="menu_label">
<?php echo $option->text; ?>
</label>
</div>
<div class="osmap-cell osmap-col-priority osmap-menu-options">
<?php echo $changePriorityField; ?>
</div>
<div class="osmap-cell osmap-col-changefreq osmap-menu-options">
<?php echo $changeChangeFreqField; ?>
</div>
</li>
<?php endforeach; ?>
</ul>
<input type="hidden"
id="<?php echo $id . '_menus_ordering'; ?>"
name="<?php echo sprintf('%s[menus_ordering]', $field->formControl); ?>"
value=""/>
</div>

View File

@ -0,0 +1,137 @@
<?php
/**
* @package OSMap
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2007-2014 XMap - Joomla! Vargas - Guillermo Vargas. All rights reserved.
* @copyright 2016-2024 Joomlashack.com. All rights reserved.
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSMap.
*
* OSMap is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
*/
use Alledia\Framework\Joomla\Form\Field\TraitLayouts;
use Alledia\OSMap\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\Registry\Registry;
defined('_JEXEC') or die();
require_once 'TraitOsmapField.php';
class OsmapFormFieldMenus extends FormField
{
use TraitOsmapField;
use TraitLayouts;
/**
* @inheritdoc
*/
public $type = 'osmapmenus';
/**
* @inheritdoc
*/
protected $layout = 'osmap.menus';
/**
* @inheritDoc
*/
protected function getInput()
{
if (!is_array($this->value)) {
// Ensure value is an array
$registry = new Registry($this->value);
$this->value = $registry->toArray();
}
return parent::getInput();
}
/**
* @inheritDoc
*/
protected function getLayoutData()
{
return array_merge(
parent::getLayoutData(),
[
'options' => $this->getOptions()
]
);
}
/**
* @inheritDoc
*/
protected function getLabel()
{
return '';
}
/**
* @return object[]
* @throws Exception
*/
protected function getOptions()
{
$db = Factory::getDbo();
// Get the list of menus from the database
$query = $db->getQuery(true)
->select([
'id AS value',
'title AS text'
])
->from('#__menu_types AS menus')
->order('menus.title');
$options = $db->setQuery($query)->loadObjectList();
uasort($options, [$this, 'sortOptions']);
return $options;
}
/**
* @param object $a
* @param object $b
*
* @return int
*/
public function sortOptions(object $a, object $b): int
{
$indexA = array_search($a->value, array_keys($this->value));
$indexB = array_search($b->value, array_keys($this->value));
if ($indexA === $indexB && $indexA !== false) {
return 0;
}
if ($indexA === false && $indexA === $indexB) {
return ($a->value < $b->value) ? -1 : 1;
}
if ($indexA === false) {
return 1;
}
if ($indexB === false) {
return -1;
}
return ($indexA < $indexB) ? -1 : 1;
}
}

View File

@ -0,0 +1,103 @@
<?php
/**
* @package OSMap
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2007-2014 XMap - Joomla! Vargas - Guillermo Vargas. All rights reserved.
* @copyright 2016-2024 Joomlashack.com. All rights reserved.
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSMap.
*
* OSMap is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSMap. If not, see <https://www.gnu.org/licenses/>.
*/
use Alledia\OSMap\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
defined('_JEXEC') or die();
require_once 'TraitOsmapField.php';
class OsmapFormFieldSitemaps extends FormField
{
use TraitOsmapField;
/**
* @inheritdoc
*/
protected $type = 'Sitemaps';
/**
* @var string
*/
protected static $scripts = [];
/**
* @inheritDoc
*/
protected function getInput()
{
if ($value = $this->value ?: '') {
$db = Factory::getDbo();
$db->setQuery(
$db->getQuery(true)
->select('name')
->from('#__osmap_sitemaps')
->where('id = ' . (int)$value)
);
$selectedName = $db->loadResult();
}
if (empty($selectedName)) {
$selectedName = Text::_('COM_OSMAP_OPTION_SELECT_SITEMAP');
}
$function = 'osmapSelectSitemap_' . $this->id;
$linkQuery = [
'option' => 'com_osmap',
'view' => 'sitemaps',
'layout' => 'modal',
'tmpl' => 'component',
'function' => $function
];
$link = 'index.php?' . htmlspecialchars(http_build_query($linkQuery));
return HTMLHelper::_(
'alledia.renderModal',
[
'id' => $this->id,
'name' => $this->name,
'link' => $link,
'function' => $function,
'itemType' => 'Sitemap',
'title' => Text::_('COM_OSMAP_OPTION_SELECT_SITEMAP'),
'hint' => $selectedName,
'value' => $value,
'required' => $this->required,
]
);
}
/**
* @inheritDoc
*/
protected function getLabel()
{
return str_replace($this->id, $this->id . '_id', parent::getLabel());
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* @package ShackDefaultFiles
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2015-2024 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of ShackDefaultFiles.
*
* ShackDefaultFiles is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* ShackDefaultFiles is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ShackDefaultFiles. If not, see <https://www.gnu.org/licenses/>.
*/
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
defined('_JEXEC') or die();
FormHelper::loadFieldClass('Spacer');
class JFormFieldSubtitle extends JFormFieldSpacer
{
/**
* @inheritDoc
*/
protected function getLabel()
{
$html = [];
$class = $this->class ?: sprintf(' class="%s"', $this->class);
$tag = $this->element['tag'] ? (string)$this->element['tag'] : 'h4';
$html[] = '<span class="spacer">';
$html[] = '<span class="before"></span>';
$html[] = '<span' . $class . '>';
if ((string)$this->element['hr'] == 'true') {
$html[] = '<hr' . $class . '>';
} else {
$label = '';
// Get the label text from the XML element, defaulting to the element name.
$text = (string)$this->element['label'] ?: (string)$this->element['name'];
$text = $this->translateLabel ? Text::_($text) : $text;
// Build the class for the label.
$class = $this->description ? 'hasTooltip' : '';
$class = $this->required == true ? $class . ' required' : $class;
// Add the opening label tag and main attributes attributes.
$label .= '<' . $tag . ' id="' . $this->id . '-lbl" class="' . $class . '"';
if ($this->description) {
// Use description to build a tooltip.
HTMLHelper::_('bootstrap.tooltip');
$label .= sprintf(
' title="%s"',
HTMLHelper::tooltipText(trim($text, ':'), Text::_($this->description), 0)
);
}
// Add the label text and closing tag.
$label .= '>' . $text . '</' . $tag . '>';
$html[] = $label;
}
$html[] = '</span>';
$html[] = '<span class="after"></span>';
$html[] = '</span>';
return implode('', $html);
}
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field name="search"
type="text"/>
<field name="published"
type="status"
onchange="this.form.submit();"
filter="0,1,-2,*">
<option value="">COM_OSMAP_OPTION_SELECT_PUBLISHED</option>
</field>
<field name="default"
type="list"
onchange="this.form.submit();">
<option value="">COM_OSMAP_OPTION_SELECT_DEFAULT</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fields>
<fields name="list">
<field name="fullordering"
type="list"
label="COM_OSMAP_LIST_FULL_ORDERING"
description="COM_OSMAP_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="sitemap.id DESC">
<option value="">JGLOBAL_SORT_BY</option>
<option value="sitemap.published ASC">COM_OSMAP_GRID_PUBLISHED_ASC</option>
<option value="sitemap.published DESC">COM_OSMAP_GRID_PUBLISHED_DESC</option>
<option value="sitemap.name ASC">COM_OSMAP_GRID_NAME_ASC</option>
<option value="sitemap.name DESC">COM_OSMAP_GRID_NAME_DESC</option>
<option value="sitemap.id ASC">COM_OSMAP_GRID_ID_ASC</option>
<option value="sitemap.id DESC">COM_OSMAP_GRID_ID_DESC</option>
</field>
<field name="limit"
type="limitbox"
class="inputbox input-mini"
default="25"
label="COM_OSMAP_LIST_LIMIT"
description="COM_OSMAP_LIST_LIMIT_DESC"
onchange="this.form.submit();"/>
</fields>
</form>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<form addfieldpath="/administrator/components/com_osmap/form/fields">
<fieldset name="name">
<field name="name"
type="text"
label="COM_OSMAP_SITEMAP_NAME_LABEL"
description="COM_OSMAP_SITEMAP_NAME_DESC"
class="input-xxlarge input-large-text required"
required="true"/>
</fieldset>
<fieldset name="menus">
<field name="menus"
type="osmap.menus"
labelclass="control-label"
multiple="multiple"
array="true"/>
<field name="menus_priority"
type="hidden"/>
<field name="menus_changefreq"
type="hidden"/>
<field name="menus_ordering"
type="hidden"/>
</fieldset>
<fieldset name="params" label="COM_OSMAP_SITEMAP_PAGE_MAIN">
<field name="id"
type="hidden"/>
<field name="is_default"
type="radio"
layout="joomla.form.field.radio.switcher"
class="btn-group btn-group-yesno"
label="COM_OSMAP_SITEMAP_IS_DEFAULT_LABEL"
description="COM_OSMAP_SITEMAP_IS_DEFAULT_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="published"
type="list"
default="1"
class="chzn-color-state form-select-color-state"
label="COM_OSMAP_COMMON_PUBLISHED_LABEL">
<option value="0">JUNPUBLISHED</option>
<option value="1">JPUBLISHED</option>
</field>
</fieldset>
</form>