- md5
- 206a365061b624ceaf403acd0d9049d3
- sha1
- 123a88080a6b87975ac94d5b51d558947f7aa7e5
- sha256
- 553e7d8ccbebf516457f8834bcda5347adc87f274e55605b03e256a916189afe
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
<?php
/**
* @package Joomla.Administrator
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Administrator\Helper;
defined('_JEXEC') or die;
use Joomla\CMS\Helper\ContentHelper;
/**
* Newsfeeds component helper.
*
* @since 1.6
*/
class NewsfeedsHelper extends ContentHelper
{
public static $extension = 'com_newsfeeds';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*/
public static function addSubmenu($vName)
{
\JHtmlSidebar::addEntry(
\JText::_('COM_NEWSFEEDS_SUBMENU_NEWSFEEDS'),
'index.php?option=com_newsfeeds&view=newsfeeds',
$vName == 'newsfeeds'
);
\JHtmlSidebar::addEntry(
\JText::_('COM_NEWSFEEDS_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_newsfeeds',
$vName == 'categories'
);
}
/**
* Adds Count Items for Category Manager.
*
* @param \stdClass[] &$items The banner category objects
*
* @return \stdClass[]
*
* @since 3.5
*/
public static function countItems(&$items)
{
$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('#__newsfeeds'))
->where('catid = ' . (int) $item->id)
->group('state');
$db->setQuery($query);
$newfeeds = $db->loadObjectList();
foreach ($newfeeds as $newsfeed)
{
if ($newsfeed->state == 1)
{
$item->count_published = $newsfeed->count;
}
if ($newsfeed->state == 0)
{
$item->count_unpublished = $newsfeed->count;
}
if ($newsfeed->state == 2)
{
$item->count_archived = $newsfeed->count;
}
if ($newsfeed->state == -2)
{
$item->count_trashed = $newsfeed->count;
}
}
}
return $items;
}
/**
* Adds Count Items for Tag Manager.
*
* @param \stdClass[] &$items The newsfeed tag objects
* @param string $extension The name of the active view.
*
* @return \stdClass[]
*
* @since 3.6
*/
public static function countTagItems(&$items, $extension)
{
$db = \JFactory::getDbo();
$parts = explode('.', $extension);
$section = null;
if (count($parts) > 1)
{
$section = $parts[1];
}
$join = $db->qn('#__newsfeeds') . ' AS c ON ct.content_item_id=c.id';
if ($section === 'category')
{
$join = $db->qn('#__categories') . ' AS c ON ct.content_item_id=c.id';
}
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', $join)
->group('state');
$db->setQuery($query);
$newsfeeds = $db->loadObjectList();
foreach ($newsfeeds as $newsfeed)
{
if ($newsfeed->state == 1)
{
$item->count_published = $newsfeed->count;
}
if ($newsfeed->state == 0)
{
$item->count_unpublished = $newsfeed->count;
}
if ($newsfeed->state == 2)
{
$item->count_archived = $newsfeed->count;
}
if ($newsfeed->state == -2)
{
$item->count_trashed = $newsfeed->count;
}
}
}
return $items;
}
}
No other release has this exact content. See every version of this file.