- md5
- db657505eaaf7280674ec8e608c32c94
- sha1
- b9f23e6fead80ea74e197687e6e013ef6f596de4
- sha256
- 5dccf2de42ed7ed67927f2dfcd34bc312eee91a2b8558802fc10bc5718b21172
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\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Table\Table;
/**
* The newsfeed controller for ajax requests
*
* @since 3.9.0
*/
class AjaxController extends BaseController
{
/**
* 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 (!Session::checkToken('get'))
{
echo new JsonResponse(null, Text::_('JINVALID_TOKEN'), true);
}
else
{
$assocId = $this->input->getInt('assocId', 0);
if ($assocId == 0)
{
echo new JsonResponse(null, Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'assocId'), true);
return;
}
$excludeLang = $this->input->get('excludeLang', '', 'STRING');
$associations = Associations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', (int) $assocId);
unset($associations[$excludeLang]);
// Add the title to each of the associated records
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_newsfeeds/tables');
$newsfeedsTable = Table::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 = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE');
}
elseif ($countContentLanguages > count($associations) + 2)
{
$tags = implode(', ', array_keys($associations));
$message = Text::sprintf('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME', $tags);
}
else
{
$message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL');
}
echo new JsonResponse($associations, $message);
}
}
}
The same content is in 5 releases, Joomla 4.0.0-alpha8 to 4.0.0-alpha12. See them all, or every version of this file.