32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-12-25 09:50:00 +00:00

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
This commit is contained in:
Nicola Galgano 2017-03-12 13:52:04 +01:00 committed by zero-24
parent 4b7480f54a
commit 9e56646abc
2 changed files with 58 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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."