From e717f38f8e02826d52f107fc7207e7d9b6a1c9fc Mon Sep 17 00:00:00 2001 From: Septdir Date: Sun, 22 Apr 2018 13:20:49 +0300 Subject: [PATCH 1/9] Fix category link (Revert #19681) --- components/com_content/helpers/route.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/components/com_content/helpers/route.php b/components/com_content/helpers/route.php index 822d59dc54634..d8e2077184eb3 100644 --- a/components/com_content/helpers/route.php +++ b/components/com_content/helpers/route.php @@ -78,14 +78,6 @@ public static function getCategoryRoute($catid, $language = 0) { $link .= '&lang=' . $language; } - - $jinput = JFactory::getApplication()->input; - $layout = $jinput->get('layout'); - - if ($layout !== '') - { - $link .= '&layout=' . $layout; - } } return $link; From 91520259a4ba58abdf2120da9d02731b128bc3b7 Mon Sep 17 00:00:00 2001 From: Septdir Date: Mon, 23 Apr 2018 17:00:52 +0300 Subject: [PATCH 2/9] Add layout to route helper --- components/com_content/helpers/route.php | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/components/com_content/helpers/route.php b/components/com_content/helpers/route.php index d8e2077184eb3..4f6faaf6709d2 100644 --- a/components/com_content/helpers/route.php +++ b/components/com_content/helpers/route.php @@ -19,15 +19,16 @@ abstract class ContentHelperRoute /** * Get the article route. * - * @param integer $id The route of the content item. - * @param integer $catid The category ID. - * @param integer $language The language code. + * @param integer $id The route of the content item. + * @param integer $catid The category ID. + * @param integer $language The language code. + * @param string $layout The Article layout * * @return string The article route. * * @since 1.5 */ - public static function getArticleRoute($id, $catid = 0, $language = 0) + public static function getArticleRoute($id, $catid = 0, $language = 0, $layout = null) { // Create the link $link = 'index.php?option=com_content&view=article&id=' . $id; @@ -42,20 +43,26 @@ public static function getArticleRoute($id, $catid = 0, $language = 0) $link .= '&lang=' . $language; } + if ($layout) + { + $link .= '&layout=' . $layout; + } + return $link; } /** * Get the category route. * - * @param integer $catid The category ID. - * @param integer $language The language code. + * @param integer $catid The category ID. + * @param integer $language The language code. + * @param string $layout The category layout * * @return string The article route. * * @since 1.5 */ - public static function getCategoryRoute($catid, $language = 0) + public static function getCategoryRoute($catid, $language = 0, $layout = null) { if ($catid instanceof JCategoryNode) { @@ -78,6 +85,11 @@ public static function getCategoryRoute($catid, $language = 0) { $link .= '&lang=' . $language; } + + if ($layout) + { + $link .= '&layout=' . $layout; + } } return $link; From 6f6ecedf968f36ad07a914b03dee3377c3a011a2 Mon Sep 17 00:00:00 2001 From: Septdir Date: Mon, 23 Apr 2018 17:16:50 +0300 Subject: [PATCH 3/9] Add layout to content Associations helper --- components/com_content/helpers/association.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/com_content/helpers/association.php b/components/com_content/helpers/association.php index 462dc0593fcb9..780bb0e9bacf7 100644 --- a/components/com_content/helpers/association.php +++ b/components/com_content/helpers/association.php @@ -23,17 +23,19 @@ abstract class ContentHelperAssociation extends CategoryHelperAssociation /** * Method to get the associations for a given item * - * @param integer $id Id of the item - * @param string $view Name of the view + * @param integer $id Id of the item + * @param string $view Name of the view + * @param string $layout View layout * * @return array Array of associations for the item * * @since 3.0 */ - public static function getAssociations($id = 0, $view = null) + public static function getAssociations($id = 0, $view = null, $layout = null) { $jinput = JFactory::getApplication()->input; $view = $view === null ? $jinput->get('view') : $view; + $layout = $layout === null ? $jinput->get('view', '', 'string') : $view; $id = empty($id) ? $jinput->getInt('id') : $id; $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); @@ -65,7 +67,7 @@ public static function getAssociations($id = 0, $view = null) if ($result > 0) { - $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language); + $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language, $layout); } } } From 7f78d601099d52021504ede93344fd258af21f2d Mon Sep 17 00:00:00 2001 From: Septdir Date: Mon, 23 Apr 2018 17:17:28 +0300 Subject: [PATCH 4/9] Add layout to category Associations helper --- .../components/com_categories/helpers/association.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_categories/helpers/association.php b/administrator/components/com_categories/helpers/association.php index 67196ee95aa25..4609b3bc149b6 100644 --- a/administrator/components/com_categories/helpers/association.php +++ b/administrator/components/com_categories/helpers/association.php @@ -25,12 +25,13 @@ abstract class CategoryHelperAssociation * * @param integer $id Id of the item * @param string $extension Name of the component + * @param string $layout Category layout * * @return array Array of associations for the component categories * * @since 3.0 */ - public static function getCategoryAssociations($id = 0, $extension = 'com_content') + public static function getCategoryAssociations($id = 0, $extension = 'com_content', $layout = null) { $return = array(); @@ -46,11 +47,11 @@ public static function getCategoryAssociations($id = 0, $extension = 'com_conten { if (class_exists($helperClassname) && is_callable(array($helperClassname, 'getCategoryRoute'))) { - $return[$tag] = $helperClassname::getCategoryRoute($item, $tag); + $return[$tag] = $helperClassname::getCategoryRoute($item, $tag, $layout); } else { - $return[$tag] = 'index.php?option=' . $extension . '&view=category&id=' . $item; + $return[$tag] = 'index.php?option=' . $extension . '&view=category&id=' . $item . '&layout=' . $layout; } } } From 1712f81d7b23d2b2e63e8da7388edf5fca0a7858 Mon Sep 17 00:00:00 2001 From: Septdir Date: Mon, 23 Apr 2018 17:40:57 +0300 Subject: [PATCH 5/9] Fix get layout in content associations --- components/com_content/helpers/association.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/com_content/helpers/association.php b/components/com_content/helpers/association.php index 780bb0e9bacf7..272067705a959 100644 --- a/components/com_content/helpers/association.php +++ b/components/com_content/helpers/association.php @@ -35,7 +35,7 @@ public static function getAssociations($id = 0, $view = null, $layout = null) { $jinput = JFactory::getApplication()->input; $view = $view === null ? $jinput->get('view') : $view; - $layout = $layout === null ? $jinput->get('view', '', 'string') : $view; + $layout = $layout === null ? $jinput->get('layout', '', 'string') : $layout; $id = empty($id) ? $jinput->getInt('id') : $id; $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); From 1f03db261ebef092e26118dad07844587804f1e7 Mon Sep 17 00:00:00 2001 From: Septdir Date: Mon, 23 Apr 2018 17:41:51 +0300 Subject: [PATCH 6/9] Fix send layout to Category associations helper --- components/com_content/helpers/association.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/com_content/helpers/association.php b/components/com_content/helpers/association.php index 272067705a959..cf8edc11bce70 100644 --- a/components/com_content/helpers/association.php +++ b/components/com_content/helpers/association.php @@ -78,7 +78,7 @@ public static function getAssociations($id = 0, $view = null, $layout = null) if ($view === 'category' || $view === 'categories') { - return self::getCategoryAssociations($id, 'com_content'); + return self::getCategoryAssociations($id, 'com_content', $layout); } return array(); From 0ead6d318c17c0c24c9f1acac2cd77f9fa244fbc Mon Sep 17 00:00:00 2001 From: Septdir Date: Mon, 23 Apr 2018 18:09:40 +0300 Subject: [PATCH 7/9] Fix spaces --- components/com_content/helpers/route.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/com_content/helpers/route.php b/components/com_content/helpers/route.php index 4f6faaf6709d2..3d685685069e4 100644 --- a/components/com_content/helpers/route.php +++ b/components/com_content/helpers/route.php @@ -19,10 +19,10 @@ abstract class ContentHelperRoute /** * Get the article route. * - * @param integer $id The route of the content item. - * @param integer $catid The category ID. - * @param integer $language The language code. - * @param string $layout The Article layout + * @param integer $id The route of the content item. + * @param integer $catid The category ID. + * @param integer $language The language code. + * @param string $layout The Article layout * * @return string The article route. * @@ -54,9 +54,9 @@ public static function getArticleRoute($id, $catid = 0, $language = 0, $layout = /** * Get the category route. * - * @param integer $catid The category ID. - * @param integer $language The language code. - * @param string $layout The category layout + * @param integer $catid The category ID. + * @param integer $language The language code. + * @param string $layout The category layout * * @return string The article route. * From 88f8e6ab7ade344db0110f344f427c7933269f4c Mon Sep 17 00:00:00 2001 From: Septdir Date: Tue, 24 Apr 2018 21:45:18 +0300 Subject: [PATCH 8/9] Remove query --- components/com_content/helpers/association.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/components/com_content/helpers/association.php b/components/com_content/helpers/association.php index cf8edc11bce70..e16c087d4ae1f 100644 --- a/components/com_content/helpers/association.php +++ b/components/com_content/helpers/association.php @@ -37,8 +37,6 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $view = $view === null ? $jinput->get('view') : $view; $layout = $layout === null ? $jinput->get('layout', '', 'string') : $layout; $id = empty($id) ? $jinput->getInt('id') : $id; - $user = JFactory::getUser(); - $groups = implode(',', $user->getAuthorisedViewLevels()); if ($view === 'article') { @@ -55,20 +53,7 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $arrId = explode(':', $item->id); $assocId = $arrId[0]; - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->qn('state')) - ->from($db->qn('#__content')) - ->where($db->qn('id') . ' = ' . (int) ($assocId)) - ->where('access IN (' . $groups . ')'); - $db->setQuery($query); - - $result = (int) $db->loadResult(); - - if ($result > 0) - { - $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language, $layout); - } + $return[$tag] = ContentHelperRoute::getArticleRoute($assocId, (int) $item->catid, $item->language, $layout); } } From 310000492e8593a122c28fe4698ddcb070536ca0 Mon Sep 17 00:00:00 2001 From: Septdir Date: Tue, 24 Apr 2018 22:04:54 +0300 Subject: [PATCH 9/9] Send correct id --- components/com_content/helpers/association.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/com_content/helpers/association.php b/components/com_content/helpers/association.php index e16c087d4ae1f..ea424be00d5bf 100644 --- a/components/com_content/helpers/association.php +++ b/components/com_content/helpers/association.php @@ -50,10 +50,7 @@ public static function getAssociations($id = 0, $view = null, $layout = null) { if ($item->language != JFactory::getLanguage()->getTag()) { - $arrId = explode(':', $item->id); - $assocId = $arrId[0]; - - $return[$tag] = ContentHelperRoute::getArticleRoute($assocId, (int) $item->catid, $item->language, $layout); + $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language, $layout); } }