[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_content 6 * 7 * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Content\Administrator\Controller; 12 13 use Joomla\CMS\Language\Associations; 14 use Joomla\CMS\Language\LanguageHelper; 15 use Joomla\CMS\Language\Text; 16 use Joomla\CMS\MVC\Controller\BaseController; 17 use Joomla\CMS\Response\JsonResponse; 18 use Joomla\CMS\Session\Session; 19 use Joomla\CMS\Table\Table; 20 21 // phpcs:disable PSR1.Files.SideEffects 22 \defined('_JEXEC') or die; 23 // phpcs:enable PSR1.Files.SideEffects 24 25 /** 26 * The article controller for ajax requests 27 * 28 * @since 3.9.0 29 */ 30 class AjaxController extends BaseController 31 { 32 /** 33 * Method to fetch associations of an article 34 * 35 * The method assumes that the following http parameters are passed in an Ajax Get request: 36 * token: the form token 37 * assocId: the id of the article whose associations are to be returned 38 * excludeLang: the association for this language is to be excluded 39 * 40 * @return null 41 * 42 * @since 3.9.0 43 */ 44 public function fetchAssociations() 45 { 46 if (!Session::checkToken('get')) { 47 echo new JsonResponse(null, Text::_('JINVALID_TOKEN'), true); 48 } else { 49 $assocId = $this->input->getInt('assocId', 0); 50 51 if ($assocId == 0) { 52 echo new JsonResponse(null, Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'assocId'), true); 53 54 return; 55 } 56 57 $excludeLang = $this->input->get('excludeLang', '', 'STRING'); 58 59 $associations = Associations::getAssociations('com_content', '#__content', 'com_content.item', (int) $assocId); 60 61 unset($associations[$excludeLang]); 62 63 // Add the title to each of the associated records 64 $contentTable = Table::getInstance('Content', 'JTable'); 65 66 foreach ($associations as $lang => $association) { 67 $contentTable->load($association->id); 68 $associations[$lang]->title = $contentTable->title; 69 } 70 71 $countContentLanguages = count(LanguageHelper::getContentLanguages(array(0, 1), false)); 72 73 if (count($associations) == 0) { 74 $message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE'); 75 } elseif ($countContentLanguages > count($associations) + 2) { 76 $tags = implode(', ', array_keys($associations)); 77 $message = Text::sprintf('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME', $tags); 78 } else { 79 $message = Text::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL'); 80 } 81 82 echo new JsonResponse($associations, $message); 83 } 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |