Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0]namespace administrator components com_languages #21058

Merged
merged 8 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

/**
* Languages Controller.
Expand Down Expand Up @@ -45,8 +47,8 @@ public function display($cachable = false, $urlparams = false)
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->setMessage(\JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
$this->setRedirect(\JRoute::_('index.php?option=com_languages&view=languages', false));
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error');
$this->setRedirect(Route::_('index.php?option=com_languages&view=languages', false));

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Language\Language;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\Installer;

/**
* Languages Controller.
Expand All @@ -27,7 +32,7 @@ class InstalledController extends BaseController
public function setDefault()
{
// Check for request forgeries.
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

$cid = $this->input->get('cid', '');
$model = $this->getModel('installed');
Expand All @@ -37,14 +42,14 @@ public function setDefault()
// 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);
$language = Factory::getLanguage();
$newLang = Language::getInstance($cid);
Factory::$language = $newLang;
Factory::getApplication()->loadLanguage($language = $newLang);
$newLang->load('com_languages', JPATH_ADMINISTRATOR);
}

$msg = \JText::_('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED');
$msg = Text::_('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED');
$type = 'message';
}
else
Expand All @@ -65,26 +70,26 @@ public function setDefault()
public function switchAdminLanguage()
{
// Check for request forgeries.
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));
Session::checkToken() or jexit(Text::_('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);
$info = Installer::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);
$language = Factory::getLanguage();
$newLang = Language::getInstance($cid);
Factory::$language = $newLang;
Factory::getApplication()->loadLanguage($language = $newLang);
$newLang->load('com_languages', JPATH_ADMINISTRATOR);

$msg = \JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
$msg = Text::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
$type = 'message';
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Factory;

/**
* Languages Override Controller
Expand All @@ -34,7 +38,7 @@ public function edit($key = null, $urlVar = null)
// Do not cache the response to this, its a redirect
$this->app->allowCache(false);

$app = \JFactory::getApplication();
$app = Factory::getApplication();
$cid = $this->input->post->get('cid', array(), 'array');
$context = "$this->option.edit.$this->context";

Expand All @@ -44,8 +48,8 @@ public function edit($key = null, $urlVar = null)
// Access check.
if (!$this->allowEdit())
{
$this->setMessage(\JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error');
$this->setRedirect(\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
$this->setMessage(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error');
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));

return;
}
Expand All @@ -67,7 +71,7 @@ public function edit($key = null, $urlVar = null)
public function save($key = null, $urlVar = null)
{
// Check for request forgeries.
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

$app = $this->app;
$model = $this->getModel();
Expand All @@ -81,8 +85,8 @@ public function save($key = null, $urlVar = null)
// Access check.
if (!$this->allowSave($data, 'id'))
{
$this->setMessage(\JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'), 'error');
$this->setRedirect(\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
$this->setMessage(Text::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'), 'error');
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));

return;
}
Expand Down Expand Up @@ -127,7 +131,7 @@ public function save($key = null, $urlVar = null)

// Redirect back to the edit screen.
$this->setRedirect(
\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false)
Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false)
);

return;
Expand All @@ -140,16 +144,16 @@ public function save($key = null, $urlVar = null)
$app->setUserState($context . '.data', $validData);

// Redirect back to the edit screen.
$this->setMessage(\JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'error');
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'error');
$this->setRedirect(
\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false)
Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false)
);

return;
}

// Add message of success.
$this->setMessage(\JText::_('COM_LANGUAGES_VIEW_OVERRIDE_SAVE_SUCCESS'));
$this->setMessage(Text::_('COM_LANGUAGES_VIEW_OVERRIDE_SAVE_SUCCESS'));

// Redirect the user and adjust session state based on the chosen task.
switch ($task)
Expand All @@ -160,7 +164,7 @@ public function save($key = null, $urlVar = null)

// Redirect back to the edit screen
$this->setRedirect(
\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($validData['key'], 'id'), false)
Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($validData['key'], 'id'), false)
);
break;

Expand All @@ -170,7 +174,7 @@ public function save($key = null, $urlVar = null)

// Redirect back to the edit screen
$this->setRedirect(
\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(null, 'id'), false)
Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(null, 'id'), false)
);
break;

Expand All @@ -179,7 +183,7 @@ public function save($key = null, $urlVar = null)
$app->setUserState($context . '.data', null);

// Redirect to the list screen.
$this->setRedirect(\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
break;
}
}
Expand All @@ -195,11 +199,11 @@ public function save($key = null, $urlVar = null)
*/
public function cancel($key = null)
{
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

$context = "$this->option.edit.$this->context";

$this->app->setUserState($context . '.data', null);
$this->setRedirect(\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;

/**
* Languages Overrides Controller.
Expand All @@ -37,14 +40,14 @@ class OverridesController extends AdminController
public function delete()
{
// Check for request forgeries.
\JSession::checkToken() or die(\JText::_('JINVALID_TOKEN'));
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));

// Get items to dlete from the request.
$cid = $this->input->get('cid', array(), 'array');

if (!is_array($cid) || count($cid) < 1)
{
$this->setMessage(\JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning');
$this->setMessage(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning');
}
else
{
Expand All @@ -54,15 +57,15 @@ public function delete()
// Remove the items.
if ($model->delete($cid))
{
$this->setMessage(\JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
$this->setMessage(Text::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
}
else
{
$this->setMessage($model->getError(), 'error');
}
}

$this->setRedirect(\JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}

/**
Expand All @@ -76,6 +79,6 @@ public function purge()
{
$model = $this->getModel('overrides');
$model->purge();
$this->setRedirect(\JRoute::_('index.php?option=com_languages&view=overrides', false));
$this->setRedirect(Route::_('index.php?option=com_languages&view=overrides', false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

/**
* Languages component helper.
*
Expand All @@ -30,17 +32,17 @@ class LanguagesHelper
public static function addSubmenu($vName, $client = 0)
{
\JHtmlSidebar::addEntry(
\JText::_('COM_LANGUAGES_SUBMENU_INSTALLED'),
Text::_('COM_LANGUAGES_SUBMENU_INSTALLED'),
'index.php?option=com_languages&view=installed',
$vName == 'installed'
);
\JHtmlSidebar::addEntry(
\JText::_('COM_LANGUAGES_SUBMENU_CONTENT'),
Text::_('COM_LANGUAGES_SUBMENU_CONTENT'),
'index.php?option=com_languages&view=languages',
$vName == 'languages'
);
\JHtmlSidebar::addEntry(
\JText::_('COM_LANGUAGES_SUBMENU_OVERRIDES'),
Text::_('COM_LANGUAGES_SUBMENU_OVERRIDES'),
'index.php?option=com_languages&view=overrides',
$vName == 'overrides'
);
Expand Down
Loading