From 6ffe5654ba237993d1798ffbc2ddb107d18a00c3 Mon Sep 17 00:00:00 2001 From: Magnus Singer Date: Thu, 24 Mar 2022 18:04:24 +0100 Subject: [PATCH 1/9] fix issue #37312 --- components/com_content/src/Controller/ArticleController.php | 4 ++++ components/com_content/tmpl/form/edit.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/com_content/src/Controller/ArticleController.php b/components/com_content/src/Controller/ArticleController.php index 2c440673ce2ee..8b27efc68f8de 100644 --- a/components/com_content/src/Controller/ArticleController.php +++ b/components/com_content/src/Controller/ArticleController.php @@ -395,6 +395,10 @@ public function save($key = null, $urlVar = 'a_id') { // Redirect to the article page, use the redirect url set from parent controller } + elseif ($this->getTask() === 'apply') + { + // Do not redirect + } else { // If ok, redirect to the return page. diff --git a/components/com_content/tmpl/form/edit.php b/components/com_content/tmpl/form/edit.php index 5b5865023f31e..91843c636b78f 100644 --- a/components/com_content/tmpl/form/edit.php +++ b/components/com_content/tmpl/form/edit.php @@ -157,10 +157,14 @@
- + showSaveAsCopy) : ?>
- +
- + diff --git a/administrator/components/com_languages/tmpl/installed/default.php b/administrator/components/com_languages/tmpl/installed/default.php index 19cd82a360939..fc58225bfd116 100644 --- a/administrator/components/com_languages/tmpl/installed/default.php +++ b/administrator/components/com_languages/tmpl/installed/default.php @@ -17,6 +17,10 @@ use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Version; +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns'); + $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); diff --git a/administrator/components/com_languages/tmpl/languages/default.php b/administrator/components/com_languages/tmpl/languages/default.php index 6502ae4ec0de7..d41787d26e461 100644 --- a/administrator/components/com_languages/tmpl/languages/default.php +++ b/administrator/components/com_languages/tmpl/languages/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_languages/tmpl/overrides/default.php b/administrator/components/com_languages/tmpl/overrides/default.php index 2a1a30fd90b94..7b4081d370457 100644 --- a/administrator/components/com_languages/tmpl/overrides/default.php +++ b/administrator/components/com_languages/tmpl/overrides/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $client = $this->state->get('filter.client') == 'site' ? Text::_('JSITE') : Text::_('JADMINISTRATOR'); $language = $this->state->get('filter.language'); diff --git a/administrator/components/com_mails/tmpl/templates/default.php b/administrator/components/com_mails/tmpl/templates/default.php index 772904f6c4972..d0c3d023b9a08 100644 --- a/administrator/components/com_mails/tmpl/templates/default.php +++ b/administrator/components/com_mails/tmpl/templates/default.php @@ -16,6 +16,10 @@ HTMLHelper::_('bootstrap.dropdown', '.dropdown-toggle'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns'); + $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> diff --git a/administrator/components/com_media/resources/scripts/app/Api.es6.js b/administrator/components/com_media/resources/scripts/app/Api.es6.js index 697204b733e16..d9d14895f0be2 100644 --- a/administrator/components/com_media/resources/scripts/app/Api.es6.js +++ b/administrator/components/com_media/resources/scripts/app/Api.es6.js @@ -27,6 +27,9 @@ class Api { this.videoExtensions = options.videoExtensions; this.documentExtensions = options.documentExtensions; this.mediaVersion = (new Date().getTime()).toString(); + this.canCreate = options.canCreate || false; + this.canEdit = options.canEdit || false; + this.canDelete = options.canDelete || false; } /** diff --git a/administrator/components/com_media/resources/scripts/components/browser/actionItems/actionItemsContainer.vue b/administrator/components/com_media/resources/scripts/components/browser/actionItems/actionItemsContainer.vue index ecdc2ae0bb4cf..630322a1ce93b 100644 --- a/administrator/components/com_media/resources/scripts/components/browser/actionItems/actionItemsContainer.vue +++ b/administrator/components/com_media/resources/scripts/components/browser/actionItems/actionItemsContainer.vue @@ -28,7 +28,7 @@ :main-action="openPreview" :closing-action="hideActions" @keyup.up="$refs.actionDelete.$el.focus()" - @keyup.down="$refs.actionDownload.$el.focus()" + @keyup.down="$refs.actionDelete.$el.previousElementSibling.focus()" />
  • @@ -39,11 +39,12 @@ :main-action="download" :closing-action="hideActions" @keyup.up="$refs.actionPreview.$el.focus()" - @keyup.down="$refs.actionRename.$el.focus()" + @keyup.down="$refs.actionPreview.$el.previousElementSibling.focus()" />
  • @@ -83,13 +84,14 @@ @keyup.up=" canEdit ? $refs.actionEdit.$el.focus() - : $refs.actionRename.$el.focus() + : $refs.actionEdit.$el.previousElementSibling.focus() " @keyup.down="$refs.actionDelete.$el.focus()" />
  • @@ -113,6 +115,7 @@ diff --git a/administrator/components/com_media/resources/scripts/components/browser/items/image.vue b/administrator/components/com_media/resources/scripts/components/browser/items/image.vue index 9b25d92967d85..98822dd030013 100644 --- a/administrator/components/com_media/resources/scripts/components/browser/items/image.vue +++ b/administrator/components/com_media/resources/scripts/components/browser/items/image.vue @@ -9,10 +9,16 @@ :title="item.name" >
    -
    + :src="getURL" + :alt="altTag" + loading="lazy" + :width="width" + :height="height" + > +
    1 + ? `${this.item.thumb_path}?${api.mediaVersion}` + : `${this.item.thumb_path}`; + }, + width() { + return this.item.width; + }, + height() { + return this.item.height; + }, + altTag() { + return this.item.name; }, }, methods: { - /* Check if the item is a document to edit */ + /* Check if the item is an image to edit */ canEdit() { return ['jpg', 'jpeg', 'png'].includes(this.item.extension.toLowerCase()); }, diff --git a/administrator/components/com_media/resources/scripts/components/modals/rename-modal.vue b/administrator/components/com_media/resources/scripts/components/modals/rename-modal.vue index 4d3bee44458cc..af36a5a2a0e4f 100644 --- a/administrator/components/com_media/resources/scripts/components/modals/rename-modal.vue +++ b/administrator/components/com_media/resources/scripts/components/modals/rename-modal.vue @@ -116,7 +116,7 @@ export default { // Rename the item this.$store.dispatch('renameItem', { - path: this.item.path, + item: this.item, newPath: newPath + newName, newName, }); diff --git a/administrator/components/com_media/resources/scripts/store/actions.es6.js b/administrator/components/com_media/resources/scripts/store/actions.es6.js index 58db65fc97919..30825caec04fe 100644 --- a/administrator/components/com_media/resources/scripts/store/actions.es6.js +++ b/administrator/components/com_media/resources/scripts/store/actions.es6.js @@ -129,6 +129,9 @@ export const toggleBrowserItemSelect = (context, payload) => { * @param payload object with the new folder name and its parent directory */ export const createDirectory = (context, payload) => { + if (!api.canCreate) { + return; + } context.commit(types.SET_IS_LOADING, true); api.createDirectory(payload.name, payload.parent) .then((folder) => { @@ -150,6 +153,9 @@ export const createDirectory = (context, payload) => { * @param payload object with the new folder name and its parent directory */ export const uploadFile = (context, payload) => { + if (!api.canCreate) { + return; + } context.commit(types.SET_IS_LOADING, true); api.upload(payload.name, payload.parent, payload.content, payload.override || false) .then((file) => { @@ -172,15 +178,22 @@ export const uploadFile = (context, payload) => { /** * Rename an item * @param context - * @param payload object: the old and the new path + * @param payload object: the item and the new path */ export const renameItem = (context, payload) => { + if (!api.canEdit) { + return; + } + + if (typeof payload.item.canEdit !== 'undefined' && payload.item.canEdit === false) { + return; + } context.commit(types.SET_IS_LOADING, true); - api.rename(payload.path, payload.newPath) + api.rename(payload.item.path, payload.newPath) .then((item) => { context.commit(types.RENAME_SUCCESS, { item, - oldPath: payload.path, + oldPath: payload.item.path, newName: payload.newName, }); context.commit(types.HIDE_RENAME_MODAL); @@ -199,11 +212,17 @@ export const renameItem = (context, payload) => { * @param context */ export const deleteSelectedItems = (context) => { + if (!api.canDelete) { + return; + } context.commit(types.SET_IS_LOADING, true); // Get the selected items from the store const { selectedItems } = context.state; if (selectedItems.length > 0) { selectedItems.forEach((item) => { + if (typeof item.canDelete !== 'undefined' && item.canDelete === false) { + return; + } api.delete(item.path) .then(() => { context.commit(types.DELETE_SUCCESS, item); diff --git a/administrator/components/com_media/tmpl/media/default.php b/administrator/components/com_media/tmpl/media/default.php index aff6f9b1f0dd4..94d219bc82a6c 100644 --- a/administrator/components/com_media/tmpl/media/default.php +++ b/administrator/components/com_media/tmpl/media/default.php @@ -14,8 +14,10 @@ use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Uri\Uri; +$app = Factory::getApplication(); $params = ComponentHelper::getParams('com_media'); -$input = Factory::getApplication()->input; +$input = $app->input; +$user = $app->getIdentity(); /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); @@ -39,7 +41,7 @@ $mediaTypes = '&mediatypes=' . $input->getString('mediatypes', '0,1,2,3'); // Populate the media config -$config = array( +$config = [ 'apiBaseUrl' => Uri::base() . 'index.php?option=com_media&format=json' . $mediaTypes, 'csrfToken' => Session::getFormToken(), 'filePath' => $params->get('file_path', 'images'), @@ -54,7 +56,10 @@ 'providers' => (array) $this->providers, 'currentPath' => $this->currentPath, 'isModal' => $tmpl === 'component', -); + 'canCreate' => $user->authorise('core.create', 'com_media'), + 'canEdit' => $user->authorise('core.edit', 'com_media'), + 'canDelete' => $user->authorise('core.delete', 'com_media'), +]; $this->document->addScriptOptions('com_media', $config); ?>
    diff --git a/administrator/components/com_menus/tmpl/items/default.php b/administrator/components/com_menus/tmpl/items/default.php index 6fc61e276648d..7b8a79ba495f3 100644 --- a/administrator/components/com_menus/tmpl/items/default.php +++ b/administrator/components/com_menus/tmpl/items/default.php @@ -18,7 +18,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $app = Factory::getApplication(); diff --git a/administrator/components/com_menus/tmpl/menus/default.php b/administrator/components/com_menus/tmpl/menus/default.php index 6ce6fc3234e0e..b58d96da2438d 100644 --- a/administrator/components/com_menus/tmpl/menus/default.php +++ b/administrator/components/com_menus/tmpl/menus/default.php @@ -15,6 +15,11 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); + $uri = Uri::getInstance(); $return = base64_encode($uri); $user = Factory::getUser(); diff --git a/administrator/components/com_modules/tmpl/modules/default.php b/administrator/components/com_modules/tmpl/modules/default.php index ca2d4a419d9f9..c3bccaa60f501 100644 --- a/administrator/components/com_modules/tmpl/modules/default.php +++ b/administrator/components/com_modules/tmpl/modules/default.php @@ -18,7 +18,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $clientId = (int) $this->state->get('client_id', 0); $user = Factory::getUser(); diff --git a/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php b/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php index 70f12a91c15be..7611fe76a8789 100644 --- a/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php +++ b/administrator/components/com_newsfeeds/tmpl/newsfeeds/default.php @@ -18,7 +18,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_plugins/tmpl/plugins/default.php b/administrator/components/com_plugins/tmpl/plugins/default.php index ca919e1dc9a36..541fd8e0f351f 100644 --- a/administrator/components/com_plugins/tmpl/plugins/default.php +++ b/administrator/components/com_plugins/tmpl/plugins/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_privacy/tmpl/consents/default.php b/administrator/components/com_privacy/tmpl/consents/default.php index 8f343a4921015..f4240c1933ea2 100644 --- a/administrator/components/com_privacy/tmpl/consents/default.php +++ b/administrator/components/com_privacy/tmpl/consents/default.php @@ -18,7 +18,10 @@ /** @var \Joomla\Component\Privacy\Administrator\View\Consents\HtmlView $this */ -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_privacy/tmpl/requests/default.php b/administrator/components/com_privacy/tmpl/requests/default.php index 16a72551f0451..9c7a9fa19fcd6 100644 --- a/administrator/components/com_privacy/tmpl/requests/default.php +++ b/administrator/components/com_privacy/tmpl/requests/default.php @@ -19,7 +19,10 @@ /** @var \Joomla\Component\Privacy\Administrator\View\Request\HtmlView $this */ -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_redirect/tmpl/links/default.php b/administrator/components/com_redirect/tmpl/links/default.php index 95c65fba1dcb6..8be568281c1e4 100644 --- a/administrator/components/com_redirect/tmpl/links/default.php +++ b/administrator/components/com_redirect/tmpl/links/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_scheduler/tmpl/tasks/default.php b/administrator/components/com_scheduler/tmpl/tasks/default.php index b26b06b04d0e3..ab4595e3a5383 100644 --- a/administrator/components/com_scheduler/tmpl/tasks/default.php +++ b/administrator/components/com_scheduler/tmpl/tasks/default.php @@ -22,6 +22,11 @@ /** @var HtmlView $this*/ +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); + Text::script('COM_SCHEDULER_TEST_RUN_TITLE'); Text::script('COM_SCHEDULER_TEST_RUN_TASK'); Text::script('COM_SCHEDULER_TEST_RUN_DURATION'); diff --git a/administrator/components/com_tags/tmpl/tags/default.php b/administrator/components/com_tags/tmpl/tags/default.php index b168a57201ce2..c3e455a2b66dc 100644 --- a/administrator/components/com_tags/tmpl/tags/default.php +++ b/administrator/components/com_tags/tmpl/tags/default.php @@ -18,7 +18,10 @@ use Joomla\CMS\Session\Session; use Joomla\String\Inflector; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $app = Factory::getApplication(); $user = Factory::getUser(); diff --git a/administrator/components/com_templates/tmpl/styles/default.php b/administrator/components/com_templates/tmpl/styles/default.php index 9039e612b56d6..a610932134949 100644 --- a/administrator/components/com_templates/tmpl/styles/default.php +++ b/administrator/components/com_templates/tmpl/styles/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $clientId = (int) $this->state->get('client_id', 0); diff --git a/administrator/components/com_templates/tmpl/templates/default.php b/administrator/components/com_templates/tmpl/templates/default.php index 279fbc2530d67..42959af23cca7 100644 --- a/administrator/components/com_templates/tmpl/templates/default.php +++ b/administrator/components/com_templates/tmpl/templates/default.php @@ -15,7 +15,10 @@ use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_users/tmpl/groups/default.php b/administrator/components/com_users/tmpl/groups/default.php index fa183349a1eb7..def943cd56c4b 100644 --- a/administrator/components/com_users/tmpl/groups/default.php +++ b/administrator/components/com_users/tmpl/groups/default.php @@ -24,8 +24,9 @@ /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); -$wa->useScript('multiselect') - ->useScript('com_users.admin-users-groups'); +$wa->useScript('com_users.admin-users-groups') + ->useScript('multiselect') + ->useScript('table.columns'); ?> diff --git a/administrator/components/com_users/tmpl/levels/default.php b/administrator/components/com_users/tmpl/levels/default.php index 5af7c2fb4d599..73fa1285dbfda 100644 --- a/administrator/components/com_users/tmpl/levels/default.php +++ b/administrator/components/com_users/tmpl/levels/default.php @@ -18,7 +18,10 @@ use Joomla\CMS\Session\Session; use Joomla\Component\Users\Administrator\Helper\UsersHelper; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_users/tmpl/notes/default.php b/administrator/components/com_users/tmpl/notes/default.php index ce1ffcba3eba5..07586c547a7d5 100644 --- a/administrator/components/com_users/tmpl/notes/default.php +++ b/administrator/components/com_users/tmpl/notes/default.php @@ -15,7 +15,10 @@ use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/administrator/components/com_users/tmpl/users/default.php b/administrator/components/com_users/tmpl/users/default.php index 4b2e285f09daf..874bbf9b9c605 100644 --- a/administrator/components/com_users/tmpl/users/default.php +++ b/administrator/components/com_users/tmpl/users/default.php @@ -18,7 +18,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\String\PunycodeHelper; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); diff --git a/administrator/components/com_workflow/tmpl/stages/default.php b/administrator/components/com_workflow/tmpl/stages/default.php index 5293217c74b9c..48c4a7969a085 100644 --- a/administrator/components/com_workflow/tmpl/stages/default.php +++ b/administrator/components/com_workflow/tmpl/stages/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); $userId = $user->id; diff --git a/administrator/components/com_workflow/tmpl/transitions/default.php b/administrator/components/com_workflow/tmpl/transitions/default.php index b24fa8d0853a6..6cc6eee815d58 100644 --- a/administrator/components/com_workflow/tmpl/transitions/default.php +++ b/administrator/components/com_workflow/tmpl/transitions/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $user = Factory::getUser(); diff --git a/administrator/components/com_workflow/tmpl/workflows/default.php b/administrator/components/com_workflow/tmpl/workflows/default.php index 27a9faa523b18..449445fae312d 100644 --- a/administrator/components/com_workflow/tmpl/workflows/default.php +++ b/administrator/components/com_workflow/tmpl/workflows/default.php @@ -16,7 +16,10 @@ use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); diff --git a/administrator/language/en-GB/install.xml b/administrator/language/en-GB/install.xml index 4b7cd872fc0da..dacc5f79ed5bd 100644 --- a/administrator/language/en-GB/install.xml +++ b/administrator/language/en-GB/install.xml @@ -2,8 +2,8 @@ English (en-GB) en-GB - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index b14b1967f7179..5f96f9bbab9ec 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -386,6 +386,7 @@ JGLOBAL_CHOOSE_COMPONENT_DESC="Choose a component from the list." JGLOBAL_CHOOSE_COMPONENT_LABEL="Choose a component" JGLOBAL_CLICK_TO_SORT_THIS_COLUMN="Select to sort by this column" JGLOBAL_CLICK_TO_TOGGLE_STATE="Select icon to toggle state." +JGLOBAL_COLUMNS="Columns" JGLOBAL_CONFIRM_DELETE="Are you sure you want to delete? Confirming will permanently delete the selected item(s)!" JGLOBAL_COPY="(copy)" JGLOBAL_CREATED="Created" diff --git a/administrator/language/en-GB/langmetadata.xml b/administrator/language/en-GB/langmetadata.xml index 75c6c6462a23b..a7be25c6c1d8c 100644 --- a/administrator/language/en-GB/langmetadata.xml +++ b/administrator/language/en-GB/langmetadata.xml @@ -1,8 +1,8 @@ English (en-GB) - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/administrator/manifests/files/joomla.xml b/administrator/manifests/files/joomla.xml index 5677cf0518699..84402f72b2c08 100644 --- a/administrator/manifests/files/joomla.xml +++ b/administrator/manifests/files/joomla.xml @@ -6,8 +6,8 @@ www.joomla.org (C) 2019 Open Source Matters, Inc. GNU General Public License version 2 or later; see LICENSE.txt - 4.1.1-rc2-dev - March 2022 + 4.2.0-dev + January 2022 FILES_JOOMLA_XML_DESCRIPTION administrator/components/com_admin/script.php diff --git a/administrator/manifests/packages/pkg_en-GB.xml b/administrator/manifests/packages/pkg_en-GB.xml index 22c1330d7b266..5703987769047 100644 --- a/administrator/manifests/packages/pkg_en-GB.xml +++ b/administrator/manifests/packages/pkg_en-GB.xml @@ -2,8 +2,8 @@ English (en-GB) Language Pack en-GB - 4.1.1.1 - March 2022 + 4.2.0.1 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/api/components/com_content/src/Controller/ArticlesController.php b/api/components/com_content/src/Controller/ArticlesController.php index 691a64936022b..bf616d451a866 100644 --- a/api/components/com_content/src/Controller/ArticlesController.php +++ b/api/components/com_content/src/Controller/ArticlesController.php @@ -75,6 +75,18 @@ public function displayList() $this->modelState->set('filter.language', $filter->clean($apiFilterInfo['language'], 'STRING')); } + $apiListInfo = $this->input->get('list', [], 'array'); + + if (array_key_exists('ordering', $apiListInfo)) + { + $this->modelState->set('list.ordering', $filter->clean($apiListInfo['ordering'], 'STRING')); + } + + if (array_key_exists('direction', $apiListInfo)) + { + $this->modelState->set('list.direction', $filter->clean($apiListInfo['direction'], 'STRING')); + } + return parent::displayList(); } diff --git a/api/language/en-GB/install.xml b/api/language/en-GB/install.xml index 0a87bcd2a3ba8..73660740293cf 100644 --- a/api/language/en-GB/install.xml +++ b/api/language/en-GB/install.xml @@ -2,8 +2,8 @@ English (en-GB) en-GB - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/api/language/en-GB/langmetadata.xml b/api/language/en-GB/langmetadata.xml index 98ed03e860f08..cdbc39cfb98d6 100644 --- a/api/language/en-GB/langmetadata.xml +++ b/api/language/en-GB/langmetadata.xml @@ -1,8 +1,8 @@ English (en-GB) - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/build.xml b/build.xml index eca54ed52ef28..02218eaf40946 100644 --- a/build.xml +++ b/build.xml @@ -85,7 +85,7 @@ - + diff --git a/build/media_source/com_joomlaupdate/js/default.es6.js b/build/media_source/com_joomlaupdate/js/default.es6.js index ce4398ad1badb..cad9bef335a43 100644 --- a/build/media_source/com_joomlaupdate/js/default.es6.js +++ b/build/media_source/com_joomlaupdate/js/default.es6.js @@ -44,6 +44,7 @@ Joomla = window.Joomla || {}; }; document.addEventListener('DOMContentLoaded', () => { + const uploadForm = document.getElementById('uploadForm'); const uploadButton = document.getElementById('uploadButton'); const uploadField = document.getElementById('install_package'); const installButton = document.querySelector('.emptystate-btnadd', document.getElementById('joomlaupdate-wrapper')); @@ -52,9 +53,28 @@ Joomla = window.Joomla || {}; const task = form ? form.querySelector('[name=task]', form) : null; if (uploadButton) { uploadButton.addEventListener('click', Joomla.submitbuttonUpload); + updateCheck.addEventListener('change', () => { + uploadButton.disabled = !updateCheck.checked; + }); } if (uploadField) { uploadField.addEventListener('change', Joomla.installpackageChange); + uploadField.addEventListener('change', () => { + const fileSize = uploadForm.install_package.files[0].size; + const allowedSize = uploadForm.max_upload_size.value; + if (fileSize <= allowedSize && updateCheck.disabled) { + updateCheck.disabled = !updateCheck.disabled; + } else if (fileSize <= allowedSize && !updateCheck.disabled && !updateCheck.checked) { + updateCheck.disabled = false; + } else if (fileSize <= allowedSize && updateCheck.checked) { + updateCheck.checked = false; + uploadButton.disabled = true; + } else if (fileSize > allowedSize && !updateCheck.disabled) { + updateCheck.disabled = !updateCheck.disabled; + updateCheck.checked = false; + uploadButton.disabled = true; + } + }); } // Trigger (re-) install (including checkbox confirm if we update) if (installButton && installButton.getAttribute('href') === '#' && task) { diff --git a/build/media_source/com_media/scss/components/_media-browser.scss b/build/media_source/com_media/scss/components/_media-browser.scss index 9d0cbed5acb55..b6bcfa75231d0 100644 --- a/build/media_source/com_media/scss/components/_media-browser.scss +++ b/build/media_source/com_media/scss/components/_media-browser.scss @@ -204,13 +204,23 @@ } .image-cropped { - padding-bottom: 100%; - background-repeat: no-repeat; - background-position: center; - background-size: contain; + aspect-ratio: 1/1; + max-width: 100%; + height: auto; + object-fit: contain; border-radius: $grid-item-border-radius; } +.image-placeholder { + display: flex; + align-items: center; + justify-content: center; + aspect-ratio: 1/1; + max-width: 100%; + height: auto; + color: #9d9d9d; +} + .file-background, .folder-background { padding-bottom: 100%; background-color: hsl(var(--hue), 20%, 97%); diff --git a/build/media_source/system/joomla.asset.json b/build/media_source/system/joomla.asset.json index e4d8a65543529..56bb579487c6a 100644 --- a/build/media_source/system/joomla.asset.json +++ b/build/media_source/system/joomla.asset.json @@ -150,6 +150,19 @@ "type": "style", "uri": "system/fields/switcher.min.css" }, + { + "name": "table.columns", + "type": "script", + "class": "TableColumnsAssetItem", + "uri": "system/table-columns.min.js", + "dependencies": [ + "core" + ], + "attributes": { + "defer": true, + "type": "module" + } + }, { "name": "form.validate", "type": "script", diff --git a/build/media_source/system/js/multiselect.es6.js b/build/media_source/system/js/multiselect.es6.js index 038c871e433ff..5ac631e6db782 100644 --- a/build/media_source/system/js/multiselect.es6.js +++ b/build/media_source/system/js/multiselect.es6.js @@ -14,7 +14,7 @@ this.tableEl = document.querySelector(formElement); if (this.tableEl) { - this.boxes = [].slice.call(this.tableEl.querySelectorAll('input[type=checkbox]')); + this.boxes = [].slice.call(this.tableEl.querySelectorAll('td input[type=checkbox]')); this.rows = [].slice.call(document.querySelectorAll('tr[class^="row"]')); this.checkallToggle = document.querySelector('[name="checkall-toggle"]'); diff --git a/installation/language/en-GB/langmetadata.xml b/installation/language/en-GB/langmetadata.xml index 9e98cb60d7402..7c4b9ace040ca 100644 --- a/installation/language/en-GB/langmetadata.xml +++ b/installation/language/en-GB/langmetadata.xml @@ -1,8 +1,8 @@ English (United Kingdom) - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project (C) 2005 Open Source Matters, Inc. GNU General Public License version 2 or later; see LICENSE.txt diff --git a/language/en-GB/install.xml b/language/en-GB/install.xml index 9355942372b34..b5c586eec48ec 100644 --- a/language/en-GB/install.xml +++ b/language/en-GB/install.xml @@ -2,8 +2,8 @@ English (en-GB) en-GB - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/language/en-GB/langmetadata.xml b/language/en-GB/langmetadata.xml index 8b59e3ef0d561..1239b6afccc1a 100644 --- a/language/en-GB/langmetadata.xml +++ b/language/en-GB/langmetadata.xml @@ -1,8 +1,8 @@ English (en-GB) - 4.1.1 - March 2022 + 4.2.0 + January 2022 Joomla! Project admin@joomla.org www.joomla.org diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php index 04b79ec48aea5..92893b35facb0 100644 --- a/libraries/src/HTML/HTMLHelper.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -286,15 +286,7 @@ public static function getServiceRegistry(): Registry */ protected static function call(callable $function, $args) { - // PHP 5.3 workaround - $temp = array(); - - foreach ($args as &$arg) - { - $temp[] = &$arg; - } - - return \call_user_func_array($function, $temp); + return \call_user_func_array($function, $args); } /** diff --git a/libraries/src/Version.php b/libraries/src/Version.php index 69e9853662be4..1564e8a077973 100644 --- a/libraries/src/Version.php +++ b/libraries/src/Version.php @@ -42,7 +42,7 @@ final class Version * @var integer * @since 3.8.0 */ - const MINOR_VERSION = 1; + const MINOR_VERSION = 2; /** * Patch release version. @@ -50,7 +50,7 @@ final class Version * @var integer * @since 3.8.0 */ - const PATCH_VERSION = 1; + const PATCH_VERSION = 0; /** * Extra release version info. @@ -61,7 +61,7 @@ final class Version * @var string * @since 3.8.0 */ - const EXTRA_VERSION = 'rc2-dev'; + const EXTRA_VERSION = 'dev'; /** * Development status. @@ -85,7 +85,7 @@ final class Version * @var string * @since 3.5 */ - const RELDATE = '18-March-2022'; + const RELDATE = '23-January-2022'; /** * Release time. @@ -93,7 +93,7 @@ final class Version * @var string * @since 3.5 */ - const RELTIME = '20:38'; + const RELTIME = '11:04'; /** * Release timezone. From af3de305b4f0cf65cca9b4b38854fd3e7c0df574 Mon Sep 17 00:00:00 2001 From: Magnus Singer Date: Thu, 24 Mar 2022 20:43:41 +0100 Subject: [PATCH 3/9] rebase to 4.2 --- .../system/js/table-columns.es6.js | 204 ++++++++++++++++++ .../AssetItem/TableColumnsAssetItem.php | 40 ++++ 2 files changed, 244 insertions(+) create mode 100644 build/media_source/system/js/table-columns.es6.js create mode 100644 libraries/src/WebAsset/AssetItem/TableColumnsAssetItem.php diff --git a/build/media_source/system/js/table-columns.es6.js b/build/media_source/system/js/table-columns.es6.js new file mode 100644 index 0000000000000..a233c0fb103df --- /dev/null +++ b/build/media_source/system/js/table-columns.es6.js @@ -0,0 +1,204 @@ +/** + * TableColumns class for toggle visibility of columns. + */ +class TableColumns { + constructor($table, tableName) { + this.$table = $table; + this.tableName = tableName; + this.storageKey = `joomla-tablecolumns-${this.tableName}`; + + this.$headers = [].slice.call($table.querySelector('thead tr').children); + this.$rows = [].slice.call($table.querySelectorAll('tbody tr')); + this.listOfHidden = []; + + // Load previous state + this.loadState(); + + // Find protected columns + this.protectedCols = [0]; + if (this.$rows[0]) { + [].slice.call(this.$rows[0].children).forEach(($el, index) => { + if ($el.nodeName === 'TH') { + this.protectedCols.push(index); + + // Make sure it's not in the list of hidden + const ih = this.listOfHidden.indexOf(index); + if (ih !== -1) { + this.listOfHidden.splice(ih, 1); + } + } + }); + } + + // Set up toggle menu + this.createControls(); + + // Restore state + this.listOfHidden.forEach((index) => { + this.toggleColumn(index, true); + }); + } + + /** + * Create a controls to select visible columns + */ + createControls() { + const $divouter = document.createElement('div'); + $divouter.setAttribute('class', 'dropdown float-end pb-2'); + + const $divinner = document.createElement('div'); + $divinner.setAttribute('class', 'dropdown-menu dropdown-menu-end'); + $divinner.setAttribute('data-bs-popper', 'static'); + + // Create a toggle button + const $button = document.createElement('button'); + $button.type = 'button'; + $button.textContent = Joomla.Text._('JGLOBAL_COLUMNS'); + $button.classList.add('btn', 'btn-primary', 'btn-sm', 'dropdown-toggle'); + $button.setAttribute('data-bs-toggle', 'dropdown'); + $button.setAttribute('data-bs-auto-close', 'false'); + $button.setAttribute('aria-haspopup', 'true'); + $button.setAttribute('aria-expanded', 'false'); + + const $ul = document.createElement('ul'); + $ul.setAttribute('class', 'list-unstyled p-2'); + $ul.setAttribute('id', 'columnList'); + + // Collect a list of headers for dropdown + this.$headers.forEach(($el, index) => { + // Skip the first column, unless it's a th, as we don't want to display the checkboxes + if (index === 0 && $el.nodeName !== 'TH') return; + + const $li = document.createElement('li'); + const $label = document.createElement('label'); + const $input = document.createElement('input'); + $input.classList.add('form-check-input', 'me-1'); + $input.type = 'checkbox'; + $input.name = 'table[column][]'; + $input.checked = this.listOfHidden.indexOf(index) === -1; + $input.disabled = this.protectedCols.indexOf(index) !== -1; + $input.value = index; + + // Find the header name + let $titleEl = $el.querySelector('span'); + let title = $titleEl ? $titleEl.textContent.trim() : ''; + + if (!title) { + $titleEl = $el.querySelector('span.visually-hidden') || $el; + title = $titleEl.textContent.trim(); + } + + if (title.includes(':')) { + title = title.split(':', 2)[1].trim(); + } + + $label.textContent = title; + $label.insertAdjacentElement('afterbegin', $input); + $li.appendChild($label); + $ul.appendChild($li); + }); + + this.$table.insertAdjacentElement('beforebegin', $divouter); + $divouter.appendChild($button); + $divouter.appendChild($divinner); + $divinner.appendChild($ul); + + // Listen to checkboxes change + $ul.addEventListener('change', (event) => { + this.toggleColumn(parseInt(event.target.value, 10)); + this.saveState(); + }); + + // Remove "media query" classes, which may prevent toggling from working. + this.$headers.forEach(($el) => { + $el.classList.remove('d-none', 'd-md-table-cell', 'd-lg-table-cell', 'd-xl-table-cell'); + }); + this.$rows.forEach(($row) => { + [].slice.call($row.children).forEach(($el) => { + $el.classList.remove('d-none', 'd-md-table-cell', 'd-lg-table-cell', 'd-xl-table-cell'); + }); + }); + + this.$button = $button; + this.$menu = $ul; + this.updateCounter(); + } + + /** + * Update button text + */ + updateCounter() { + // Don't count the checkboxes column in the total + const total = this.$headers.length - 1; + const visible = total - this.listOfHidden.length; + + this.$button.textContent = `${visible}/${total} ${Joomla.Text._('JGLOBAL_COLUMNS')}`; + } + + /** + * Toggle column visibility + * + * @param {Number} index The column index + * @param {Boolean} force To force hide + */ + toggleColumn(index, force) { + // Skip incorrect index + if (!this.$headers[index]) return; + + // Skip the protected columns + if (this.protectedCols.indexOf(index) !== -1) return; + + const i = this.listOfHidden.indexOf(index); + + if (i === -1) { + this.listOfHidden.push(index); + } else if (force !== true) { + this.listOfHidden.splice(i, 1); + } + + this.$headers[index].classList.toggle('d-none', force); + + this.$rows.forEach(($col) => { + $col.children[index].classList.toggle('d-none', force); + }); + + this.updateCounter(); + } + + /** + * Save state, list of hidden columns + */ + saveState() { + window.localStorage.setItem(this.storageKey, this.listOfHidden.join(',')); + } + + /** + * Load state, list of hidden columns + */ + loadState() { + const stored = window.localStorage.getItem(this.storageKey); + + if (stored) { + this.listOfHidden = stored.split(',').map((val) => parseInt(val, 10)); + } + } +} + +if (window.innerWidth > 992) { + // Look for dataset name else page-title + [...document.querySelectorAll('table')].forEach(($table) => { + const tableName = ($table.dataset.name ? $table.dataset.name : document.querySelector('.page-title') + .textContent.trim() + .replace(/[^a-z0-9]/gi, '-') + .toLowerCase() + ); + + // Skip unnamed table + if (!tableName) { + return; + } + + /* eslint-disable-next-line no-new */ + new TableColumns($table, tableName); + }); +} diff --git a/libraries/src/WebAsset/AssetItem/TableColumnsAssetItem.php b/libraries/src/WebAsset/AssetItem/TableColumnsAssetItem.php new file mode 100644 index 0000000000000..0adadf8d2e880 --- /dev/null +++ b/libraries/src/WebAsset/AssetItem/TableColumnsAssetItem.php @@ -0,0 +1,40 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\WebAsset\AssetItem; + +\defined('JPATH_PLATFORM') or die; + +use Joomla\CMS\Document\Document; +use Joomla\CMS\Language\Text; +use Joomla\CMS\WebAsset\WebAssetAttachBehaviorInterface; +use Joomla\CMS\WebAsset\WebAssetItem; + +/** + * Web Asset Item class for tables.column asset + * + * @since __DEPLOY_VERSION__ + */ +class TableColumnsAssetItem extends WebAssetItem implements WebAssetAttachBehaviorInterface +{ + /** + * Method called when asset attached to the Document. + * Used to add the language strings required by the script. + * + * @param Document $doc Active document + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function onAttachCallback(Document $doc) + { + // Add table-columns.js language strings + Text::script('JGLOBAL_COLUMNS'); + } +} From ce9d80f784e54e8cae4680d43eb8269637695b15 Mon Sep 17 00:00:00 2001 From: Magnus Singer Date: Thu, 24 Mar 2022 20:53:41 +0100 Subject: [PATCH 4/9] update text of save & close button --- components/com_content/tmpl/form/edit.php | 2 +- language/en-GB/joomla.ini | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/com_content/tmpl/form/edit.php b/components/com_content/tmpl/form/edit.php index 91843c636b78f..1437c88d14546 100644 --- a/components/com_content/tmpl/form/edit.php +++ b/components/com_content/tmpl/form/edit.php @@ -163,7 +163,7 @@ showSaveAsCopy) : ?>