From 3d064c07a43ff5405a31d7908925ffb4979d446c Mon Sep 17 00:00:00 2001 From: Fotis Evangelou Date: Wed, 14 Mar 2018 13:24:17 +0200 Subject: [PATCH] Fixed issue https://github.com/getk2/k2-links-for-jce/issues/9 --- README.md | 2 +- plugins/jce/links-k2/k2links/k2.php | 14 +++++++------- plugins/jce/links-k2/k2links/tags.php | 12 ++++++------ plugins/jce/links-k2/k2links/users.php | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e5af483..96b8361 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This is a backend extension so a public demo or showcase is currently not availa This is a JCE extension and the only basic requirements to use it are: - JCE v2.6.x -- K2 v2.7.x or newer +- K2 v2.8.x - Joomla v3.x Support for Joomla 1.5 & 2.5 is no longer available. diff --git a/plugins/jce/links-k2/k2links/k2.php b/plugins/jce/links-k2/k2links/k2.php index f248ada..5a31b97 100644 --- a/plugins/jce/links-k2/k2links/k2.php +++ b/plugins/jce/links-k2/k2links/k2.php @@ -102,17 +102,18 @@ public static function _getK2Items($category_id = 0) // K2 2.x if (defined('K2_JVERSION')) { $db = JFactory::getDBO(); + $user = JFactory::getUser(); - $query = 'SELECT id, title, alias, CONCAT(' . $db->quoteName('introtext') . ',' . $db->quoteName('fulltext') . ') AS content FROM #__k2_items WHERE published = 1'; + $query = ' + SELECT id, title, alias, catid, CONCAT(' . $db->quoteName('introtext') . ',' . $db->quoteName('fulltext') . ') AS content FROM #__k2_items WHERE published = 1'; - $user = JFactory::getUser(); if (version_compare(JVERSION, '1.6.0', 'ge')) { $query .= ' AND `access` IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')'; } else { $query .= "\nAND `access` <=" . (int) $user->get('aid'); } - $query .= ' AND catid = ' . $db->Quote($category_id) . ' ORDER BY ordering ASC'; + $query .= ' AND catid = ' . $db->Quote($category_id) . ' ORDER BY id DESC'; $db->setQuery($query); $rows = $db->loadObjectList(); @@ -132,10 +133,11 @@ public static function _getK2Items($category_id = 0) public function getLinks($args) { $mainframe = JFactory::getApplication(); + $db = JFactory::getDBO(); $advlink = WFEditorPlugin::getInstance(); if (defined('K2_JVERSION')) { - require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php'; + require_once JPATH_SITE.'/components/com_k2/helpers/route.php'; } $items = array(); @@ -159,11 +161,9 @@ public function getLinks($args) $items[] = array('id' => $category->href, 'name' => $category->name, 'class' => 'folder content'); } foreach ($itemlist as $item) { - $item->href = K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid); + $item->href = K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias), $item->catid); $items[] = array('id' => $item->href, 'name' => $item->title, 'class' => 'file'); - $anchors = self::getAnchors($item->content); - foreach ($anchors as $anchor) { $items[] = array( 'id' => $item->href . '#' . $anchor, diff --git a/plugins/jce/links-k2/k2links/tags.php b/plugins/jce/links-k2/k2links/tags.php index 18c327d..f48b301 100644 --- a/plugins/jce/links-k2/k2links/tags.php +++ b/plugins/jce/links-k2/k2links/tags.php @@ -89,11 +89,11 @@ public static function _getK2Items($tag = '') $db = JFactory::getDBO(); $user = JFactory::getUser(); $query = "SELECT `i`.`id`, `i`.`title`, `i`.`alias`, `i`.`catid`, `c`.`alias` AS categoryAlias - FROM `#__k2_tags_xref` as `x` - INNER JOIN `#__k2_items` as `i` ON(`i`.`id` = `x`.`itemID`) - INNER JOIN `#__k2_tags` as `t` ON (`t`.`id` = `x`.`tagID`) - INNER JOIN `#__k2_categories` as `c` ON(`i`.`catid` = `c`.`id`) - WHERE `t`.`name` = ".$db->quote($tag); + FROM `#__k2_tags_xref` as `x` + INNER JOIN `#__k2_items` as `i` ON(`i`.`id` = `x`.`itemID`) + INNER JOIN `#__k2_tags` as `t` ON (`t`.`id` = `x`.`tagID`) + INNER JOIN `#__k2_categories` as `c` ON(`i`.`catid` = `c`.`id`) + WHERE `t`.`name` = ".$db->quote($tag); $query .= ' AND `i`.`published` = 1 AND `c`.`published` = 1 '; if (version_compare(JVERSION, '1.6.0', 'ge')) { $query .= ' AND `i`.`access` IN ('.implode(',', $user->getAuthorisedViewLevels()).')'; @@ -122,7 +122,7 @@ public function getLinks($args) $advlink = WFEditorPlugin::getInstance(); if (defined('K2_JVERSION')) { - require_once(JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php'); + require_once JPATH_SITE.'/components/com_k2/helpers/route.php'; } $items = array(); $view = isset($args->view) ? $args->view : ''; diff --git a/plugins/jce/links-k2/k2links/users.php b/plugins/jce/links-k2/k2links/users.php index 44546e6..3a0d7c7 100644 --- a/plugins/jce/links-k2/k2links/users.php +++ b/plugins/jce/links-k2/k2links/users.php @@ -117,8 +117,8 @@ public function getLinks($args) $advlink = WFEditorPlugin::getInstance(); if (defined('K2_JVERSION')) { - require_once(JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'utilities.php'); - require_once(JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php'); + require_once JPATH_SITE.'/components/com_k2/helpers/utilities.php'; + require_once JPATH_SITE.'/components/com_k2/helpers/route.php'; } $items = array();