Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3490c85
Update tag.php
beni71 May 16, 2023
0344544
Added possibility to batch remove a tag
beni71 May 17, 2023
5a433a7
Changed text keys
beni71 May 17, 2023
d9bf8bf
Reverted string change
beni71 May 17, 2023
a06a386
Merge branch '5.0-dev' into beni71-23185
beni71 Aug 27, 2023
a44b1b0
Merge branch '5.0-dev' into beni71-23185
HLeithner Sep 3, 2023
c369d6d
Merge branch '5.0-dev' into beni71-23185
beni71 Sep 3, 2023
ba2293d
Merge branch '5.0-dev' into beni71-23185
QuyTon Sep 3, 2023
0bffe0d
Merge branch '5.0-dev' into beni71-23185
beni71 Sep 30, 2023
60b14d9
Merge branch '5.1-dev' into beni71-23185
beni71 Oct 1, 2023
59189e4
Merge branch '5.1-dev' into beni71-23185
beni71 Oct 7, 2023
dc8994a
Merge branch '5.1-dev' into beni71-23185
beni71 Oct 21, 2023
53b590e
Merge branch '5.1-dev' into beni71-23185
QuyTon Nov 3, 2023
8ecfef2
Merge branch '5.1-dev' into beni71-23185
beni71 Dec 8, 2023
59588d4
Merge branch '5.1-dev' into beni71-23185
beni71 Dec 9, 2023
8ede036
Merge branch 'beni71-23185' of https://github.com/beni71/joomla-cms i…
beni71 Dec 9, 2023
926301c
Merge branch '5.1-dev' into beni71-23185
beni71 Dec 17, 2023
ec84c96
Merge branch '5.1-dev' into beni71-23185
beni71 Dec 19, 2023
ae898c5
Merge branch '5.1-dev' into beni71-23185
beni71 Dec 23, 2023
6d95ca6
Merge branch '5.1-dev' into beni71-23185
beni71 Dec 27, 2023
70fa69c
Merge branch '5.1-dev' into beni71-23185
beni71 Jan 13, 2024
2053bf7
Merge branch '6.0-dev' into beni71-23185
bembelimen Mar 2, 2024
6bb0927
Merge branch 'beni71-23185' of https://github.com/beni71/joomla-cms i…
beni71 Mar 3, 2024
ed50b68
Merge branch 'beni71-23185' of https://github.com/beni71/joomla-cms i…
beni71 Mar 3, 2024
bfd2a91
Merge branch '6.0-dev' into beni71-23185
laoneo Mar 20, 2024
c5bb746
Merge branch '6.0-dev' into beni71-23185
beni71 Mar 31, 2024
3c17486
Merge branch '6.0-dev' into beni71-23185
beni71 Apr 6, 2024
e132af5
Deprecated batchTag function for b/c and created a new batchTags func…
beni71 Apr 6, 2024
34b3006
Fixed function docu spacing.
beni71 Apr 6, 2024
d805e69
Fixed function docu spacing
beni71 Apr 6, 2024
a460918
Merge branch '6.0-dev' into beni71-23185
beni71 May 25, 2024
bae7589
Merge branch '6.0-dev' into beni71-23185
bembelimen Jun 12, 2024
6e3e9c7
Merge branch '6.0-dev' into beni71-23185
Bodge-IT Jul 7, 2024
26b6441
Merge branch '6.0-dev' into beni71-23185
beni71 Oct 3, 2024
20c2030
Deprecated postStoreProcess function for b/c and created a new postSt…
beni71 Oct 4, 2024
10b3993
Merge branch 'beni71-23185' of https://github.com/beni71/joomla-cms i…
beni71 Oct 4, 2024
a056cfd
Simplified else if structure.
beni71 Oct 4, 2024
e03b7b8
Fixed texts in both language files.
beni71 Oct 4, 2024
f4ed759
Merge branch '6.0-dev' into beni71-23185
beni71 Oct 31, 2024
8d129ec
Merge branch '6.0-dev' into beni71-23185
Bodge-IT Nov 13, 2024
840059a
Merge branch '6.0-dev' into beni71-23185
Bodge-IT Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion administrator/language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,11 @@ JLIB_HTML_BATCH_MOVE="Move"
JLIB_HTML_BATCH_MOVE_QUESTION="Action to Perform"
JLIB_HTML_BATCH_NO_CATEGORY="- Don't copy or move -"
JLIB_HTML_BATCH_NOCHANGE="- Keep original Access Levels -"
JLIB_HTML_BATCH_TAG_LABEL="Add Tag"
JLIB_HTML_BATCH_TAG_ADD="Add"
JLIB_HTML_BATCH_TAG_ADDREMOVE_QUESTION="Action to Perform"
JLIB_HTML_BATCH_TAG_LABEL="Add or remove a Tag"
JLIB_HTML_BATCH_TAG_NOCHANGE="- Keep original Tags -"
JLIB_HTML_BATCH_TAG_REMOVE="Remove"
JLIB_HTML_BATCH_USER_LABEL="Set User."
JLIB_HTML_BATCH_USER_NOCHANGE="- Keep original User -"
JLIB_HTML_BATCH_USER_NOUSER="No User."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

(() => {
const onSelect = () => {
const batchTag = document.getElementById('batch-tag-id');
const batchTagAddRemove = document.getElementById('batch-tag-addremove');
let batchSelector;

const onChange = () => {
if (!batchSelector.value
|| (batchSelector.value && parseInt(batchSelector.value, 10) === 0)) {
batchTagAddRemove.classList.add('hidden');
} else {
batchTagAddRemove.classList.remove('hidden');
}
};

if (batchTag) {
batchSelector = batchTag;
}

if (batchTagAddRemove) {
batchTagAddRemove.classList.add('hidden');
}

if (batchTagAddRemove) {
batchSelector.addEventListener('change', onChange);
}

// Cleanup
document.removeEventListener('DOMContentLoaded', onSelect, true);
};

// Document loaded
document.addEventListener('DOMContentLoaded', onSelect, true);

// Joomla updated
document.addEventListener('joomla:updated', onSelect, true);
})();
8 changes: 8 additions & 0 deletions build/media_source/system/joomla.asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@
"defer": true
}
},
{
"name": "joomla.batch-tag-addremove",
"type": "script",
"uri": "layouts/joomla/html/batch/batch-tag-addremove.min.js",
"attributes": {
"defer": true
}
},
{
"name": "webcomponent.field-fancy-select-legacy",
"type": "script",
Expand Down
5 changes: 4 additions & 1 deletion language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,11 @@ JLIB_HTML_BATCH_MOVE="Move"
JLIB_HTML_BATCH_MOVE_QUESTION="Action to Perform"
JLIB_HTML_BATCH_NO_CATEGORY="- Don't copy or move -"
JLIB_HTML_BATCH_NOCHANGE="- Keep original Access Levels -"
JLIB_HTML_BATCH_TAG_LABEL="Add Tag"
JLIB_HTML_BATCH_TAG_ADD="Add"
JLIB_HTML_BATCH_TAG_ADDREMOVE_QUESTION="Action to Perform"
JLIB_HTML_BATCH_TAG_LABEL="Add or remove a Tag"
JLIB_HTML_BATCH_TAG_NOCHANGE="- Keep original Tags -"
JLIB_HTML_BATCH_TAG_REMOVE="Remove"
JLIB_HTML_BATCH_USER_LABEL="Set User."
JLIB_HTML_BATCH_USER_NOCHANGE="- Keep original User -"
JLIB_HTML_BATCH_USER_NOUSER="No User."
Expand Down
31 changes: 26 additions & 5 deletions layouts/joomla/html/batch/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,35 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

// Create the add/remove tag options.
$options = [
HTMLHelper::_('select.option', 'a', Text::_('JLIB_HTML_BATCH_TAG_ADD')),
HTMLHelper::_('select.option', 'r', Text::_('JLIB_HTML_BATCH_TAG_REMOVE'))
];

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useScript('joomla.batch-tag-addremove');

?>
<label id="batch-tag-lbl" for="batch-tag-id">
<label id="batch-tag-choose-action-lbl" for="batch-tag-id">
<?php echo Text::_('JLIB_HTML_BATCH_TAG_LABEL'); ?>
</label>
<select name="batch[tag]" class="form-select" id="batch-tag-id">
<option value=""><?php echo Text::_('JLIB_HTML_BATCH_TAG_NOCHANGE'); ?></option>
<?php echo HTMLHelper::_('select.options', HTMLHelper::_('tag.tags', ['filter.published' => [1]]), 'value', 'text'); ?>
</select>
<div id="batch-tag-choose-action" class="control-group">
<select name="batch[tag]" class="form-select" id="batch-tag-id">
<option value=""><?php echo Text::_('JLIB_HTML_BATCH_TAG_NOCHANGE'); ?></option>
<?php echo HTMLHelper::_('select.options', HTMLHelper::_('tag.tags', ['filter.published' => [1]]), 'value', 'text'); ?>
</select>
</div>
<div id="batch-tag-addremove" class="control-group radio">
<fieldset id="batch-tag-addremove-id">
<legend>
<?php echo Text::_('JLIB_HTML_BATCH_TAG_ADDREMOVE_QUESTION'); ?>
</legend>
<?php echo HTMLHelper::_('select.radiolist', $options, 'batch[tag_addremove]', '', 'value', 'text', 'a'); ?>
</fieldset>
</div>
27 changes: 26 additions & 1 deletion libraries/src/Helper/TagsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,29 @@ public static function getTypes($arrayType = 'objectList', $selectTypes = null,
* @return boolean
*
* @since 3.1
*
* @deprecated 6.0 will be removed in 7.0
* Please use postStore
*/
public function postStoreProcess(TableInterface $table, $newTags = [], $replace = true)
{
$this->postStore($table, $newTags, $replace);
}

/**
* Function that handles saving tags used in a table class after a store().
*
* @param TableInterface $table Table being processed.
* @param array $newTags Array of new tags.
* @param boolean $replace Flag indicating if all existing tags should be replaced.
* This flag takes precedence before $remove.
* @param boolean $remove Flag indicating if the tags in $newTags should be removed.
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function postStore(TableInterface $table, $newTags = [], $replace = true, $remove = false)
{
if (!empty($table->newTags) && empty($newTags)) {
$newTags = $table->newTags;
Expand Down Expand Up @@ -856,7 +877,11 @@ public function postStoreProcess(TableInterface $table, $newTags = [], $replace
$ucmId = $ucmContentTable->core_content_id;

// Store the tag data if the article data was saved and run related methods.
$result = $result && $this->tagItem($ucmId, $table, $newTags, $replace);
if ($remove) {
$result = $result && $this->unTagItem($ucmId, $table, $newTags);
} else {
$result = $result && $this->tagItem($ucmId, $table, $newTags, $replace);
}
}
}

Expand Down
29 changes: 28 additions & 1 deletion libraries/src/MVC/Model/AdminModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,13 @@ public function batch($commands, $pks, $contexts)

foreach ($this->batch_commands as $identifier => $command) {
if (!empty($commands[$identifier])) {
if (!$this->$command($commands[$identifier], $pks, $contexts)) {
if ($command === 'batchTag') {
$removeTags = ArrayHelper::getValue($commands, 'tag_addremove', 'a') === 'r';

if (!$this->batchTags($commands[$identifier], $pks, $contexts, $removeTags)) {
return false;
}
} elseif (!$this->$command($commands[$identifier], $pks, $contexts)) {
return false;
}

Expand Down Expand Up @@ -693,8 +699,28 @@ protected function batchMove($value, $pks, $contexts)
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 3.1
*
* @deprecated 6.0 will be removed in 7.0
* Please use batchTags
*/
protected function batchTag($value, $pks, $contexts)
{
return $this->batchTags($value, $pks, $contexts);
}

/**
* Batch tag a list of item.
*
* @param integer $value The value of the new tag.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
* @param boolean $removeTags Flag indicating whether the tags in $value have to be removed.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since __DEPLOY_VERSION__
*/
protected function batchTags($value, $pks, $contexts, $removeTags = false)
{
// Initialize re-usable member properties, and re-usable local variables
$this->initBatch();
Expand All @@ -711,6 +737,7 @@ protected function batchTag($value, $pks, $contexts)
'subject' => $this->table,
'newTags' => $tags,
'replaceTags' => false,
'removeTags' => $removeTags,
]
);

Expand Down
7 changes: 4 additions & 3 deletions plugins/behaviour/taggable/src/Extension/Taggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ public function onTableAfterStore(AfterStoreEvent $event)
$newTags = $table->newTags ?? [];

if (empty($newTags)) {
$result = $tagsHelper->postStoreProcess($table);
$result = $tagsHelper->postStore($table);
} else {
if (\is_string($newTags) && (strpos($newTags, ',') !== false)) {
$newTags = explode(',', $newTags);
} elseif (!\is_array($newTags)) {
$newTags = (array) $newTags;
}

$result = $tagsHelper->postStoreProcess($table, $newTags);
$result = $tagsHelper->postStore($table, $newTags);
}
}

Expand Down Expand Up @@ -231,6 +231,7 @@ public function onTableSetNewTags(SetNewTagsEvent $event)
$table = $event['subject'];
$newTags = $event['newTags'];
$replaceTags = $event['replaceTags'];
$removeTags = $event['removeTags'];

// If the tags table doesn't implement the interface bail
if (!($table instanceof TaggableTableInterface)) {
Expand All @@ -247,7 +248,7 @@ public function onTableSetNewTags(SetNewTagsEvent $event)
$tagsHelper = $table->getTagsHelper();
$tagsHelper->typeAlias = $table->getTypeAlias();

if (!$tagsHelper->postStoreProcess($table, $newTags, $replaceTags)) {
if (!$tagsHelper->postStore($table, $newTags, $replaceTags, $removeTags)) {
throw new \RuntimeException($table->getError());
}
}
Expand Down