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; } } } diff --git a/components/com_content/helpers/association.php b/components/com_content/helpers/association.php index 462dc0593fcb9..ea424be00d5bf 100644 --- a/components/com_content/helpers/association.php +++ b/components/com_content/helpers/association.php @@ -23,20 +23,20 @@ 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('layout', '', 'string') : $layout; $id = empty($id) ? $jinput->getInt('id') : $id; - $user = JFactory::getUser(); - $groups = implode(',', $user->getAuthorisedViewLevels()); if ($view === 'article') { @@ -50,23 +50,7 @@ public static function getAssociations($id = 0, $view = null) { if ($item->language != JFactory::getLanguage()->getTag()) { - $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); - } + $return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language, $layout); } } @@ -76,7 +60,7 @@ public static function getAssociations($id = 0, $view = null) if ($view === 'category' || $view === 'categories') { - return self::getCategoryAssociations($id, 'com_content'); + return self::getCategoryAssociations($id, 'com_content', $layout); } return array(); diff --git a/components/com_content/helpers/route.php b/components/com_content/helpers/route.php index 822d59dc54634..3d685685069e4 100644 --- a/components/com_content/helpers/route.php +++ b/components/com_content/helpers/route.php @@ -22,12 +22,13 @@ abstract class ContentHelperRoute * @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,6 +43,11 @@ public static function getArticleRoute($id, $catid = 0, $language = 0) $link .= '&lang=' . $language; } + if ($layout) + { + $link .= '&layout=' . $layout; + } + return $link; } @@ -50,12 +56,13 @@ public static function getArticleRoute($id, $catid = 0, $language = 0) * * @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) { @@ -79,10 +86,7 @@ public static function getCategoryRoute($catid, $language = 0) $link .= '&lang=' . $language; } - $jinput = JFactory::getApplication()->input; - $layout = $jinput->get('layout'); - - if ($layout !== '') + if ($layout) { $link .= '&layout=' . $layout; }