- md5
- 0a0f1d63fedfd9465d45fde22fb8977d
- sha1
- e5a4ed0264957d524b7d25eb8ab741eba3390bae
- sha256
- ccd1f49ba7303a183ddfe50af8b979001793bfbd98af40e385182a8a16276588
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
<?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
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\LanguageHelper;
/**
* The newsfeed controller for ajax requests
*
* @since 3.9.0
*/
class NewsfeedsControllerAjax extends JControllerLegacy
{
/**
* Method to fetch associations of a newsfeed
*
* The method assumes that the following http parameters are passed in an Ajax Get request:
* token: the form token
* assocId: the id of the newsfeed whose associations are to be returned
* excludeLang: the association for this language is to be excluded
*
* @return null
*
* @since 3.9.0
*/
public function fetchAssociations()
{
if (!JSession::checkToken('get'))
{
echo new JResponseJson(null, JText::_('JINVALID_TOKEN'), true);
}
else
{
$input = JFactory::getApplication()->input;
$assocId = $input->getInt('assocId', 0);
if ($assocId == 0)
{
echo new JResponseJson(null, JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'assocId'), true);
return;
}
$excludeLang = $input->get('excludeLang', '', 'STRING');
$associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', (int) $assocId);
unset($associations[$excludeLang]);
// Add the title to each of the associated records
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_newsfeeds/tables');
$newsfeedsTable = JTable::getInstance('Newsfeed', 'NewsfeedsTable');
foreach ($associations as $lang => $association)
{
$newsfeedsTable->load($association->id);
$associations[$lang]->title = $newsfeedsTable->name;
}
$countContentLanguages = count(LanguageHelper::getContentLanguages(array(0, 1)));
if (count($associations) == 0)
{
$message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE');
}
elseif ($countContentLanguages > count($associations) + 2)
{
$tags = implode(', ', array_keys($associations));
$message = JText::sprintf('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME', $tags);
}
else
{
$message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL');
}
echo new JResponseJson($associations, $message);
}
}
}
The same content is in 26 releases, Joomla 3.9.2-rc to 3.9.14. See them all, or every version of this file.