From 228822a0980c475f80091e122a24131871b2d067 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sat, 19 Jun 2021 16:08:04 +0530 Subject: [PATCH 01/10] Add Model to mark active positions --- .../com_modules/src/Model/ModulesModel.php | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_modules/src/Model/ModulesModel.php b/administrator/components/com_modules/src/Model/ModulesModel.php index aa337ba202a..ad411cc7f73 100644 --- a/administrator/components/com_modules/src/Model/ModulesModel.php +++ b/administrator/components/com_modules/src/Model/ModulesModel.php @@ -13,6 +13,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; +use Joomla\CMS\Filesystem\Path; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\ListModel; use Joomla\Database\DatabaseQuery; @@ -178,6 +179,8 @@ protected function _getList($query, $limitstart = 0, $limit = 0) $listOrder = $this->getState('list.ordering', 'a.position'); $listDirn = $this->getState('list.direction', 'asc'); + $positionList = $this->getValidPositions(); + // If ordering by fields that need translate we need to sort the array of objects after translating them. if (in_array($listOrder, array('pages', 'name'))) { @@ -201,7 +204,14 @@ protected function _getList($query, $limitstart = 0, $limit = 0) $this->setState('list.start', 0); } - return array_slice($result, $limitstart, $limit ?: null); + $result = array_slice($result, $limitstart, $limit ?: null); + + foreach ($result as $row) + { + $row->activePosition = in_array($row->position, $positionList); + } + + return $result; } // If ordering by fields that doesn't need translate just order the query. @@ -226,6 +236,11 @@ protected function _getList($query, $limitstart = 0, $limit = 0) // Translate the results. $this->translate($result); + foreach ($result as $row) + { + $row->activePosition = in_array($row->position, $positionList); + } + return $result; } @@ -479,4 +494,55 @@ protected function getEmptyStateQuery() return $query; } + + /** + * Method to get the positions corresponding to a template. + * + * @return array List of all active template's position names. + * + * @since __DEPLOY_VERSION__ + */ + public function getValidPositions() + { + $clientId = $this->getState('client_id'); + $positions = []; + + $db = $this->getDbo(); + $query = $db->getQuery(true); + $query->select( + [ + $db->quoteName('template'), + ] + ) + ->from($db->quoteName('#__template_styles')); + + // Filter the active template + $query->where($db->quoteName('home') . ' = 1') + ->where($this->_db->quoteName('client_id') . ' = :client_id') + ->bind(':client_id', $clientId, ParameterType::INTEGER);; + $db->setQuery($query); + + $templateName = $db->loadObjectList()[0]->template; + + if (isset($templateName)) + { + $basePath = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE; + $path = Path::clean($basePath . '/templates/' . $templateName . '/templateDetails.xml'); + + if (file_exists($path)) + { + $xml = simplexml_load_file($path); + + if (isset($xml->positions[0])) + { + foreach ($xml->positions[0] as $position) + { + $positions[] = (string) $position; + } + } + } + } + + return $positions; + } } From 96c33b3896479c297be4a92c8a0760f56be49462 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sat, 19 Jun 2021 16:08:24 +0530 Subject: [PATCH 02/10] check if active position for badge class --- administrator/components/com_modules/tmpl/modules/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_modules/tmpl/modules/default.php b/administrator/components/com_modules/tmpl/modules/default.php index bd95ae2d29c..f4d94e595b4 100644 --- a/administrator/components/com_modules/tmpl/modules/default.php +++ b/administrator/components/com_modules/tmpl/modules/default.php @@ -147,7 +147,7 @@ position) : ?> - + "> position; ?> From 25ad2982eadbb3317a7bf2a8a80820a632938e72 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sun, 20 Jun 2021 10:51:53 +0530 Subject: [PATCH 03/10] add missing positions to templateDetails --- administrator/templates/atum/templateDetails.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/administrator/templates/atum/templateDetails.xml b/administrator/templates/atum/templateDetails.xml index 2badbf0b226..f5dd0ad1b45 100644 --- a/administrator/templates/atum/templateDetails.xml +++ b/administrator/templates/atum/templateDetails.xml @@ -40,6 +40,13 @@ toolbar cpanel + cpanel-components + cpanel-content + cpanel-help + cpanel-menus + cpanel-privacy + cpanel-system + cpanel-users icon login customtop From c0a4958d29cd8e6fbbf244f6abdd2541329d8901 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 21 Jun 2021 12:11:36 +0530 Subject: [PATCH 04/10] remove extra semicolon --- administrator/components/com_modules/src/Model/ModulesModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_modules/src/Model/ModulesModel.php b/administrator/components/com_modules/src/Model/ModulesModel.php index ad411cc7f73..95dc35af5b6 100644 --- a/administrator/components/com_modules/src/Model/ModulesModel.php +++ b/administrator/components/com_modules/src/Model/ModulesModel.php @@ -519,7 +519,7 @@ public function getValidPositions() // Filter the active template $query->where($db->quoteName('home') . ' = 1') ->where($this->_db->quoteName('client_id') . ' = :client_id') - ->bind(':client_id', $clientId, ParameterType::INTEGER);; + ->bind(':client_id', $clientId, ParameterType::INTEGER); $db->setQuery($query); $templateName = $db->loadObjectList()[0]->template; From 5fd6ec9952b000438775f49efaa6ea9fd5de03aa Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 22 Jun 2021 18:23:25 +0530 Subject: [PATCH 05/10] check positions for all templates that are in use --- .../com_modules/src/Model/ModulesModel.php | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/administrator/components/com_modules/src/Model/ModulesModel.php b/administrator/components/com_modules/src/Model/ModulesModel.php index 95dc35af5b6..e3ca5fe087a 100644 --- a/administrator/components/com_modules/src/Model/ModulesModel.php +++ b/administrator/components/com_modules/src/Model/ModulesModel.php @@ -505,26 +505,32 @@ protected function getEmptyStateQuery() public function getValidPositions() { $clientId = $this->getState('client_id'); - $positions = []; - $db = $this->getDbo(); + + // Get List of Template Style IDs that are used in Menus + $templateStylesQuery = $db->getQuery(true); + $templateStylesQuery->select('DISTINCT ' . $db->quoteName('template_style_id')) + ->from($db->quoteName('#__menu')); + + $templateStylesQuery->where($this->_db->quoteName('published') . ' = 1') + ->where($db->quoteName('client_id') . ' = :clientid'); + + // Get List of Template Names that are either set as Default or used in a menu $query = $db->getQuery(true); - $query->select( - [ - $db->quoteName('template'), - ] - ) + $query->select('DISTINCT ' . $db->quoteName('template')) ->from($db->quoteName('#__template_styles')); - // Filter the active template - $query->where($db->quoteName('home') . ' = 1') - ->where($this->_db->quoteName('client_id') . ' = :client_id') + $query->where($db->quoteName('client_id') . ' = :client_id') + ->where($db->quoteName('home') . ' = 1') + ->orWhere($db->quoteName('id') . ' IN (' . $templateStylesQuery . ')') + ->bind(':clientid', $clientId, ParameterType::INTEGER) ->bind(':client_id', $clientId, ParameterType::INTEGER); $db->setQuery($query); + $templateList = $db->loadColumn(); - $templateName = $db->loadObjectList()[0]->template; + $positions = []; - if (isset($templateName)) + foreach ($templateList as $templateName) { $basePath = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE; $path = Path::clean($basePath . '/templates/' . $templateName . '/templateDetails.xml'); @@ -537,7 +543,10 @@ public function getValidPositions() { foreach ($xml->positions[0] as $position) { - $positions[] = (string) $position; + if (!array_key_exists((string) $position, $positions)) + { + $positions[] = (string) $position; + } } } } From a6ac05090dc321054e5cc4e3bc45d75c9c6c422d Mon Sep 17 00:00:00 2001 From: Benjamin Trenkle Date: Wed, 23 Jun 2021 13:07:17 +0200 Subject: [PATCH 06/10] Update signature --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 9f197ff68a3..f37d0bfe6e4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -269,6 +269,6 @@ steps: --- kind: signature -hmac: 71729a12ae3556e03f924ac95c8a5cd14bb6a3c2d20ef6768fdd1e853397fd22 +hmac: 53e23beca546bde246f812a726320210f33d231106cb154a65cc900ecbf7502e ... From 011a4ebfe4d94547a5a96be411ae1e6ea1aaa890 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 28 Jun 2021 12:58:00 +0530 Subject: [PATCH 07/10] language constant for valid positions --- administrator/language/en-GB/joomla.ini | 2 ++ api/language/en-GB/joomla.ini | 2 ++ 2 files changed, 4 insertions(+) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index f52986c131e..55e161f3f46 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -554,6 +554,8 @@ JGLOBAL_PAGINATION_RESULTS_DESC="Show or hide pagination summary, for example, & JGLOBAL_PAGINATION_RESULTS_LABEL="Pagination Summary" JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." +JGLOBAL_POSITION_INVALID="Invalid Position" +JGLOBAL_POSITION_VALID="Valid Position" JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" JGLOBAL_PREVIEW_POSITION="Position: %s" diff --git a/api/language/en-GB/joomla.ini b/api/language/en-GB/joomla.ini index d77a4d87690..2ed9651471c 100644 --- a/api/language/en-GB/joomla.ini +++ b/api/language/en-GB/joomla.ini @@ -550,6 +550,8 @@ JGLOBAL_PAGINATION_RESULTS_DESC="Show or hide pagination summary, for example, & JGLOBAL_PAGINATION_RESULTS_LABEL="Pagination Summary" JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." +JGLOBAL_POSITION_INVALID="Invalid Position" +JGLOBAL_POSITION_VALID="Valid Position" JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" JGLOBAL_PREVIEW_POSITION="Position: %s" From f1709bb64ef502dda27cbbc426ea3cc78c91eb56 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 28 Jun 2021 12:59:51 +0530 Subject: [PATCH 08/10] add tooltip for valid positions --- .../components/com_modules/tmpl/modules/default.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_modules/tmpl/modules/default.php b/administrator/components/com_modules/tmpl/modules/default.php index f4d94e595b4..211969ebc1b 100644 --- a/administrator/components/com_modules/tmpl/modules/default.php +++ b/administrator/components/com_modules/tmpl/modules/default.php @@ -147,9 +147,12 @@ position) : ?> - "> + " aria-labelledby="pv-id ?>"> position; ?> + From ff437eace38b3a135e6d2d8326d3997746c8645d Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 29 Jun 2021 12:08:04 +0530 Subject: [PATCH 09/10] position color for modules select modal --- administrator/components/com_modules/tmpl/modules/modal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_modules/tmpl/modules/modal.php b/administrator/components/com_modules/tmpl/modules/modal.php index 972919a7dd7..7cf8632423d 100644 --- a/administrator/components/com_modules/tmpl/modules/modal.php +++ b/administrator/components/com_modules/tmpl/modules/modal.php @@ -99,7 +99,7 @@ position) : ?> - escape($item->position); ?> + escape($item->position); ?> From 53ebd852a780da5139a56e0e6e592c2e2b2ce3c8 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 29 Jun 2021 13:28:20 +0530 Subject: [PATCH 10/10] add tooltip to module position select modal --- administrator/components/com_modules/tmpl/modules/modal.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_modules/tmpl/modules/modal.php b/administrator/components/com_modules/tmpl/modules/modal.php index 7cf8632423d..2c57aea0a68 100644 --- a/administrator/components/com_modules/tmpl/modules/modal.php +++ b/administrator/components/com_modules/tmpl/modules/modal.php @@ -99,7 +99,10 @@ position) : ?> - escape($item->position); ?> + escape($item->position); ?> +