Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
#315: Apply joomla 3.6.5 changes in com:languages
Browse files Browse the repository at this point in the history
  • Loading branch information
allanpilarca committed Jan 16, 2017
1 parent 62bd3e9 commit cf7822e
Show file tree
Hide file tree
Showing 25 changed files with 1,079 additions and 619 deletions.
25 changes: 11 additions & 14 deletions app/administrator/components/com_languages/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* Languages Controller
* Languages Controller.
*
* @package Joomla.Administrator
* @subpackage com_languages
* @since 1.5
* @since 1.5
*/
class LanguagesController extends JControllerLegacy
{
Expand All @@ -27,23 +25,24 @@ class LanguagesController extends JControllerLegacy
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
* @param boolean $cachable If true, the view output will be cached.
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return LanguagesController This object to support chaining.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT.'/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_ADMINISTRATOR . '/components/com_languages/helpers/languages.php');

$view = $this->input->get('view', 'languages');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');

// Check for edit form.
if ($view == 'language' && $layout == 'edit' && !$this->checkEditId('com_languages.edit.language', $id)) {

if ($view == 'language' && $layout == 'edit' && !$this->checkEditId('com_languages.edit.language', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
Expand All @@ -52,8 +51,6 @@ public function display($cachable = false, $urlparams = false)
return false;
}

parent::display();

return $this;
return parent::display();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,44 @@
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* Languages Controller
* Languages Controller.
*
* @package Joomla.Administrator
* @subpackage com_languages
* @since 1.5
* @since 1.5
*/
class LanguagesControllerInstalled extends JControllerLegacy
{
/**
* task to set the default language
* Task to set the default language.
*
* @return void
*/
public function setDefault()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JInvalid_Token'));
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

$cid = $this->input->get('cid', '');
$model = $this->getModel('installed');

if ($model->publish($cid))
{
// Switching to the new administrator language for the message
if ($model->getState('client_id') == 1)
{
$language = JFactory::getLanguage();
$newLang = JLanguage::getInstance($cid);
JFactory::$language = $newLang;
JFactory::getApplication()->loadLanguage($language = $newLang);
$newLang->load('com_languages', JPATH_ADMINISTRATOR);
}

$msg = JText::_('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED');
$type = 'message';
}
Expand All @@ -39,7 +50,46 @@ public function setDefault()
$type = 'error';
}

$clientId = $model->getState('filter.client_id');
$this->setredirect('index.php?option=com_languages&view=installed&client='.$clientId, $msg, $type);
$clientId = $model->getState('client_id');
$this->setredirect('index.php?option=com_languages&view=installed&client=' . $clientId, $msg, $type);
}

/**
* Task to switch the administrator language.
*
* @return void
*/
public function switchAdminLanguage()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

$cid = $this->input->get('cid', '');
$model = $this->getModel('installed');

// Fetching the language name from the xx-XX.xml
$file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml';
$info = JInstaller::parseXMLInstallFile($file);
$languageName = $info['name'];

if ($model->switchAdminLanguage($cid))
{
// Switching to the new language for the message
$language = JFactory::getLanguage();
$newLang = JLanguage::getInstance($cid);
JFactory::$language = $newLang;
JFactory::getApplication()->loadLanguage($language = $newLang);
$newLang->load('com_languages', JPATH_ADMINISTRATOR);

$msg = JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
$type = 'message';
}
else
{
$msg = $this->getError();
$type = 'error';
}

$this->setredirect('index.php?option=com_languages&view=installed', $msg, $type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Expand All @@ -12,17 +12,15 @@
/**
* Languages list actions controller.
*
* @package Joomla.Administrator
* @subpackage com_languages
* @since 1.6
* @since 1.6
*/
class LanguagesControllerLanguage extends JControllerForm
{
/**
* Gets the URL arguments to append to an item redirect.
*
* @param int $recordId The primary key id for the item.
* @param string $key The name of the primary key variable.
* @param int $recordId The primary key id for the item.
* @param string $key The name of the primary key variable.
*
* @return string The arguments to append to the redirect URL.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* @package Joomla.Administrator
* @subpackage com_languages
* @since 1.6
* Languages controller Class.
*
* @since 1.6
*/
class LanguagesControllerLanguages extends JControllerAdmin
{
Expand All @@ -29,8 +29,7 @@ class LanguagesControllerLanguages extends JControllerAdmin
*/
public function getModel($name = 'Language', $prefix = 'LanguagesModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
return parent::getModel($name, $prefix, $config);
}

/**
Expand All @@ -45,22 +44,22 @@ public function saveOrderAjax()
$pks = $this->input->post->get('cid', array(), 'array');
$order = $this->input->post->get('order', array(), 'array');

// Sanitize the input
// Sanitize the input.
JArrayHelper::toInteger($pks);
JArrayHelper::toInteger($order);

// Get the model
// Get the model.
$model = $this->getModel();

// Save the ordering
// Save the ordering.
$return = $model->saveorder($pks, $order);

if ($return)
{
echo "1";
}

// Close the application
// Close the application.
JFactory::getApplication()->close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package Joomla.Administrator
* @subpackage com_languages
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Expand All @@ -12,44 +12,52 @@
/**
* Utility class working with languages
*
* @package Joomla.Administrator
* @subpackage com_languages
* @since 1.6
* @since 1.6
*/
abstract class JHtmlLanguages
{
/**
* Method to generate an information about the default language
* Method to generate an information about the default language.
*
* @param boolean $published is the language the default?
* @param boolean $published True if the language is the default.
*
* @return string html code
* @return string HTML code.
*/
public static function published($published)
{
if ($published)
{
return JHtml::_('image', 'menu/icon-16-default.png', JText::_('COM_LANGUAGES_HEADING_DEFAULT'), null, true);
}
else
if (!$published)
{
return ' ';
}

return JHtml::_('image', 'menu/icon-16-default.png', JText::_('COM_LANGUAGES_HEADING_DEFAULT'), null, true);
}

/**
* Method to generate an input radio button
* Method to generate an input radio button.
*
* @param integer $rowNum the row number
* @param string language tag
* @param integer $rowNum The row number.
* @param string $language Language tag.
*
* @return string html code
* @return string HTML code.
*/
public static function id($rowNum, $language)
{
return '<input type="radio" id="cb' . $rowNum . '" name="cid" value="' . htmlspecialchars($language) . '" onclick="Joomla.isChecked(this.checked);" title="' . ($rowNum + 1) . '"/>';
return '<input'
. ' type="radio"'
. ' id="cb' . $rowNum . '"'
. ' name="cid"'
. ' value="' . htmlspecialchars($language, ENT_COMPAT, 'UTF-8') . '"'
. ' onclick="Joomla.isChecked(this.checked);"'
. ' title="' . ($rowNum + 1) . '"'
. '/>';
}

/**
* Method to generate an array of clients.
*
* @return array of client objects.
*/
public static function clients()
{
return array(
Expand All @@ -61,19 +69,19 @@ public static function clients()
/**
* Returns an array of published state filter options.
*
* @return string The HTML code for the select tag
* @return string The HTML code for the select tag.
*
* @since 1.6
*/
public static function publishedOptions()
{
// Build the active state filter options.
$options = array();
$options[] = JHtml::_('select.option', '1', 'JPUBLISHED');
$options[] = JHtml::_('select.option', '0', 'JUNPUBLISHED');
$options[] = JHtml::_('select.option', '-2', 'JTRASHED');
$options[] = JHtml::_('select.option', '*', 'JALL');
$options = array();
$options[] = JHtml::_('select.option', '1', 'JPUBLISHED');
$options[] = JHtml::_('select.option', '0', 'JUNPUBLISHED');
$options[] = JHtml::_('select.option', '-2', 'JTRASHED');
$options[] = JHtml::_('select.option', '*', 'JALL');

return $options;
}

}
Loading

0 comments on commit cf7822e

Please sign in to comment.