Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New Feature] Multilingual: Propagating existing associations if desired
- Loading branch information
1 parent
aa34c79
commit ffc424c
Showing
25 changed files
with
627 additions
and
20 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
administrator/components/com_categories/controllers/ajax.json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_categories | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* The categories controller for ajax requests | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class CategoriesControllerAjax extends JControllerLegacy | ||
{ | ||
/** | ||
* Method to fetch associations of a category | ||
* | ||
* The method assumes that the following http parameters are passed in an Ajax Get request: | ||
* token: the form token | ||
* assocId: the id of the category whose associations are to be returned | ||
* excludeLang: the association for this language is to be excluded | ||
* | ||
* @return null | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function fetchAssociations() | ||
{ | ||
if (!JSession::checkToken('get')) | ||
{ | ||
echo new JResponseJson(null, JText::_('JINVALID_TOKEN'), true); | ||
} | ||
else | ||
{ | ||
$input = JFactory::getApplication()->input; | ||
$extension = $input->get('extension'); | ||
|
||
$assocId = $input->getInt('assocId', 0); | ||
|
||
if ($assocId == 0) | ||
{ | ||
echo new JResponseJson(null, JText::_('JLIB_FORM_VALIDATE_FIELD_INVALID', "assocId"), true); | ||
|
||
return; | ||
} | ||
|
||
$excludeLang = $input->get('excludeLang', '', 'STRING'); | ||
|
||
$associations = JLanguageAssociations::getAssociations($extension, '#__categories', 'com_categories.item', (int) $assocId, 'id', 'alias', ''); | ||
|
||
unset($associations[$excludeLang]); | ||
|
||
// Add the title to each of the associated records | ||
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_categories/tables'); | ||
$categoryTable = JTable::getInstance('Category', 'JTable'); | ||
|
||
foreach($associations as $lang => $association) | ||
{ | ||
$categoryTable->load($association->id); | ||
$associations[$lang]->title = $categoryTable->title; | ||
} | ||
|
||
$message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE'); | ||
|
||
echo new JResponseJson($associations, $message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
administrator/components/com_contact/controllers/ajax.json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_contact | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* The contact controller for ajax requests | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class ContactControllerAjax extends JControllerLegacy | ||
{ | ||
/** | ||
* Method to fetch associations of a contact | ||
* | ||
* The method assumes that the following http parameters are passed in an Ajax Get request: | ||
* token: the form token | ||
* assocId: the id of the contact whose associations are to be returned | ||
* excludeLang: the association for this language is to be excluded | ||
* | ||
* @return null | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
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::_('JLIB_FORM_VALIDATE_FIELD_INVALID', "assocId"), true); | ||
|
||
return; | ||
} | ||
|
||
$excludeLang = $input->get('excludeLang', '', 'STRING'); | ||
|
||
$associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', (int) $assocId); | ||
|
||
unset($associations[$excludeLang]); | ||
|
||
// Add the title to each of the associated records | ||
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_contact/tables'); | ||
$contactTable = JTable::getInstance('Contact', 'ContactTable'); | ||
|
||
foreach($associations as $lang => $association) | ||
{ | ||
$contactTable->load($association->id); | ||
$associations[$lang]->title = $contactTable->name; | ||
} | ||
|
||
$message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE'); | ||
|
||
echo new JResponseJson($associations, $message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
administrator/components/com_content/controllers/ajax.json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_content | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* The article controller for ajax requests | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class ContentControllerAjax extends JControllerLegacy | ||
{ | ||
/** | ||
* Method to fetch associations of an article | ||
* | ||
* The method assumes that the following http parameters are passed in an Ajax Get request: | ||
* token: the form token | ||
* assocId: the id of the article whose associations are to be returned | ||
* excludeLang: the association for this language is to be excluded | ||
* | ||
* @return null | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
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::_('JLIB_FORM_VALIDATE_FIELD_INVALID', "assocId"), true); | ||
|
||
return; | ||
} | ||
|
||
$excludeLang = $input->get('excludeLang', '', 'STRING'); | ||
|
||
$associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', (int) $assocId); | ||
|
||
unset($associations[$excludeLang]); | ||
|
||
// Add the title to each of the associated records | ||
$contentTable = JTable::getInstance('Content', 'JTable'); | ||
|
||
foreach($associations as $lang => $association) | ||
{ | ||
$contentTable->load($association->id); | ||
$associations[$lang]->title = $contentTable->title; | ||
} | ||
|
||
$message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE'); | ||
|
||
echo new JResponseJson($associations, $message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.