- md5
- cc8a7d911b0ffbb60a414ecacd281c19
- sha1
- ec643242854d0164a202dd006e264421a04f44f3
- sha256
- 39425ba76b1fa7cdac13a36ca446988ba0eadf42c312944c8966a0f2e94da9b2
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
<?php
/**
* @package Joomla.Administrator
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Administrator\Service\HTML;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
/**
* Utility class for creating HTML Grids.
*
* @since 1.5
*/
class AdministratorService
{
/**
* Get the associated language flags
*
* @param int $newsfeedid The item id to search associations
*
* @return string The language HTML
*
* @throws \Exception Throws a 500 Exception on Database failure
*/
public function association($newsfeedid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = Associations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $newsfeedid))
{
foreach ($associations as $tag => $associated)
{
$associations[$tag] = (int) $associated->id;
}
// Get the associated newsfeed items
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('c.id, c.name as title')
->select('l.sef as lang_sef, lang_code')
->from('#__newsfeeds as c')
->select('cat.title as category_title')
->join('LEFT', '#__categories as cat ON cat.id=c.catid')
->where('c.id IN (' . implode(',', array_values($associations)) . ')')
->where('c.id != ' . $newsfeedid)
->join('LEFT', '#__languages as l ON c.language=l.lang_code')
->select('l.image')
->select('l.title as language_title');
$db->setQuery($query);
try
{
$items = $db->loadObjectList('id');
}
catch (\RuntimeException $e)
{
throw new \Exception($e->getMessage(), 500);
}
if ($items)
{
foreach ($items as &$item)
{
$text = strtoupper($item->lang_sef);
$url = Route::_('index.php?option=com_newsfeeds&task=newsfeed.edit&id=' . (int) $item->id);
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
. htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br>' . Text::sprintf('JCATEGORY_SPRINTF', $item->category_title);
$classes = 'badge badge-secondary';
$item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '">' . $text . '</a>'
. '<div role="tooltip" id="tip' . (int) $item->id . '">' . $tooltip . '</div>';
}
}
$html = LayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
}
The same content is in 3 releases, Joomla 4.0.0-alpha10 to 4.0.0-alpha12. See them all, or every version of this file.