From 9e56646abcf5d3c99cc5b3b0ddd0c02b220087b7 Mon Sep 17 00:00:00 2001 From: Nicola Galgano Date: Sun, 12 Mar 2017 13:52:04 +0100 Subject: [PATCH] Add count and link to tagged items (#298) * Add count and link to tagged items [com_tags] - Add count and link to tagged items #10895 * added lang strings added lang strings * just added some spaces in the new code --- .../com_weblinks/helpers/weblinks.php | 56 +++++++++++++++++++ .../language/en-GB/en-GB.com_weblinks.sys.ini | 2 + 2 files changed, 58 insertions(+) diff --git a/src/administrator/components/com_weblinks/helpers/weblinks.php b/src/administrator/components/com_weblinks/helpers/weblinks.php index 01ff922..9b43e0c 100644 --- a/src/administrator/components/com_weblinks/helpers/weblinks.php +++ b/src/administrator/components/com_weblinks/helpers/weblinks.php @@ -92,4 +92,60 @@ class WeblinksHelper extends JHelperContent return $items; } + + /** + * Adds Count Items for Tag Manager. + * + * @param stdClass[] &$items The weblink tag objects + * @param string $extension The name of the active view. + * + * @return stdClass[] + * + * @since 3.7.0 + */ + public static function countTagItems(&$items, $extension) + { + $db = JFactory::getDbo(); + + foreach ($items as $item) + { + $item->count_trashed = 0; + $item->count_archived = 0; + $item->count_unpublished = 0; + $item->count_published = 0; + + $query = $db->getQuery(true); + $query->select('published as state, count(*) AS count') + ->from($db->qn('#__contentitem_tag_map') . 'AS ct ') + ->where('ct.tag_id = ' . (int) $item->id) + ->where('ct.type_alias =' . $db->q($extension)) + ->join('LEFT', $db->qn('#__categories') . ' AS c ON ct.content_item_id=c.id') + ->group('state'); + + $db->setQuery($query); + $weblinks = $db->loadObjectList(); + + foreach ($weblinks as $weblink) + { + if ($weblink->state == 1) + { + $item->count_published = $weblink->count; + } + if ($weblink->state == 0) + { + $item->count_unpublished = $weblink->count; + } + if ($weblink->state == 2) + { + $item->count_archived = $weblink->count; + } + if ($weblink->state == -2) + { + $item->count_trashed = $weblink->count; + } + } + } + + return $items; + } } diff --git a/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini b/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini index 144f9ba..bbc0da1 100644 --- a/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini +++ b/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini @@ -19,5 +19,7 @@ COM_WEBLINKS_FORM_VIEW_DEFAULT_DESC="Display a form to submit a web link in the COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default" COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link" COM_WEBLINKS_LINKS="Links" +COM_WEBLINKS_TAGS_WEBLINK="Web Link" +COM_WEBLINKS_TAGS_CATEGORY="Web Link Category" COM_WEBLINKS_XML_DESCRIPTION="Component for web links management."