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

[5.2] Replacing Fact::getLang() with Fact::getApp()->getLang() #43509

Open
wants to merge 2 commits into
base: 5.2-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Replacing Factory::getLanguage() with Factory::getApplication()->getL…
…anguage()
  • Loading branch information
Hackwar committed May 22, 2024
commit 384efdab1568d4f1e6efc132a9a7d95b4768823b
2 changes: 1 addition & 1 deletion administrator/components/com_admin/src/Model/HelpModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function &getPage()
public function getLangTag()
{
if (\is_null($this->lang_tag)) {
$this->lang_tag = Factory::getLanguage()->getTag();
$this->lang_tag = Factory::getApplication()->getLanguage()->getTag();

if (!is_dir(JPATH_BASE . '/help/' . $this->lang_tag)) {
// Use English as fallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public function validate($form, $data, $group = null)
*/
protected function preprocessForm(Form $form, $data, $group = 'content')
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$component = $this->getState('category.component');
$section = $this->getState('category.section');
$extension = Factory::getApplication()->getInput()->get('extension', null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ private function checkCompatibility($updateFileUrl, $joomlaTargetVersion)
protected function translateExtensionName(&$item)
{
// @todo: Cleanup duplicated code. from com_installer/src/Model/InstallerModel.php
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$path = $item->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE;

$extension = $item->element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected static function _load($module)
}

$app = Factory::getApplication();
$lang = Factory::getLanguage()->getTag();
$lang = Factory::getApplication()->getLanguage()->getTag();
$clientId = (int) $app->getClientId();

/** @var \Joomla\CMS\Cache\Controller\CallbackController $cache */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function loadTranslationFiles($extension)
return;
}

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$source = '';

switch (substr($extension, 0, 3)) {
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_menus/src/Model/ItemModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ public function getItem($pk = null)

if (isset($args['option'])) {
// Load the language file for the component.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($args['option'], JPATH_ADMINISTRATOR)
|| $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function populateState($ordering = 'a.lft', $direction = 'asc')

// Load mod_menu.ini file when client is administrator
if ($clientId == 1) {
Factory::getLanguage()->load('mod_menu', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('mod_menu', JPATH_ADMINISTRATOR);
}

$currentMenuType = $app->getUserState($this->context . '.menutype', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getReverseLookup()
*/
public function getTypeOptions()
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$list = [];

// Get the list of components.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public function getFiles()
$app = Factory::getApplication();
$client = ApplicationHelper::getClientInfo($template->client_id);
$path = Path::clean($client->path . '/templates/' . $template->element . '/');
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

// Load the core and/or local language file(s).
$lang->load('tpl_' . $template->element, $client->path)
Expand Down
2 changes: 1 addition & 1 deletion administrator/modules/mod_submenu/mod_submenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

if ($root && $root->hasChildren()) {
Factory::getLanguage()->load(
Factory::getApplication()->getLanguage()->load(
'mod_menu',
JPATH_ADMINISTRATOR,
Factory::getLanguage()->getTag(),
Expand Down
2 changes: 1 addition & 1 deletion administrator/modules/mod_submenu/src/Menu/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function preprocess($parent)
$app = Factory::getApplication();
$user = $app->getIdentity();
$children = $parent->getChildren();
$language = Factory::getLanguage();
$language = Factory::getApplication()->getLanguage();
$dispatcher = $app->getDispatcher();

/**
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/html/layouts/chromes/body.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="<?php echo $moduleClass; ?> module-wrapper">
<<?php echo $moduleTag; ?> class="card pt-3<?php echo $moduleClassSfx; ?>">
<?php if ($canEdit || $canChange) : ?>
<?php $dropdownPosition = Factory::getLanguage()->isRtl() ? 'start' : 'end'; ?>
<?php $dropdownPosition = Factory::getApplication()->getLanguage()->isRtl() ? 'start' : 'end'; ?>
<div class="module-actions dropdown">
<button type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn" id="dropdownMenuButton-<?php echo $id; ?>">
<span class="icon-cogs" aria-hidden="true"></span>
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/html/layouts/chromes/well.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<?php if ($canEdit || $canChange || $headerIcon || $module->showtitle) : ?>
<div class="card-header">
<?php if ($canEdit || $canChange) : ?>
<?php $dropdownPosition = Factory::getLanguage()->isRtl() ? 'start' : 'end'; ?>
<?php $dropdownPosition = Factory::getApplication()->getLanguage()->isRtl() ? 'start' : 'end'; ?>
<div class="module-actions dropdown">
<button type="button" data-bs-toggle="dropdown" data-bs-display="static" aria-haspopup="true" aria-expanded="false" class="btn" id="dropdownMenuButton-<?php echo $id; ?>">
<span class="icon-cogs" aria-hidden="true"></span>
Expand Down
2 changes: 1 addition & 1 deletion build/helpTOC.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in
$cleanMembers = array_unique($cleanMembers);

// Get the language object
$language = Factory::getLanguage();
$language = Factory::getApplication()->getLanguage();

// Load the admin com_admin language file
$language->load('com_admin', JPATH_ADMINISTRATOR);
Expand Down
4 changes: 2 additions & 2 deletions components/com_ajax/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
if (method_exists($class, $method . 'Ajax')) {
// Load language file for module
$basePath = JPATH_BASE;
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load('mod_' . $module, $basePath)
|| $lang->load('mod_' . $module, $basePath . '/modules/mod_' . $module);

Expand Down Expand Up @@ -179,7 +179,7 @@

if (method_exists($class, $method . 'Ajax')) {
// Load language file for template
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load('tpl_' . $template, $basePath)
|| $lang->load('tpl_' . $template, $basePath . '/templates/' . $template);

Expand Down
2 changes: 1 addition & 1 deletion components/com_banners/src/Model/BannersModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected function getListQuery()

// Filter by language
if ($this->getState('filter.language')) {
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
$query->whereIn($db->quoteName('a.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
}

$query->order($db->quoteName('a.sticky') . ' DESC, ' . ($randomise ? $query->rand() : $db->quoteName('a.ordering')));
Expand Down
4 changes: 2 additions & 2 deletions components/com_config/src/Model/ModulesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getForm($data = [], $loadData = true)
*/
protected function preprocessForm(Form $form, $data, $group = 'content')
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$module = $this->getState()->get('module.name');
$basePath = JPATH_BASE;

Expand Down Expand Up @@ -121,7 +121,7 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
*/
public function getPositions()
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$templateName = Factory::getApplication()->getTemplate();

// Load templateDetails.xml file
Expand Down
2 changes: 1 addition & 1 deletion components/com_config/src/Model/TemplatesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getForm($data = [], $loadData = true)
*/
protected function preprocessForm(Form $form, $data, $group = 'content')
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

$template = Factory::getApplication()->getTemplate();

Expand Down
4 changes: 2 additions & 2 deletions components/com_contact/src/Model/ContactModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function loadFormData()
$data = (array) Factory::getApplication()->getUserState('com_contact.contact.data', []);

if (empty($data['language']) && Multilanguage::isEnabled()) {
$data['language'] = Factory::getLanguage()->getTag();
$data['language'] = Factory::getApplication()->getLanguage()->getTag();
}

// Add contact catid to contact form data, so fields plugin can work properly
Expand Down Expand Up @@ -331,7 +331,7 @@ protected function buildContactExtendedData($contact)

// Filter per language if plugin published
if (Multilanguage::isEnabled()) {
$language = [Factory::getLanguage()->getTag(), '*'];
$language = [Factory::getApplication()->getLanguage()->getTag(), '*'];
$query->whereIn($db->quoteName('a.language'), $language, ParameterType::STRING);
}

Expand Down
2 changes: 1 addition & 1 deletion components/com_contact/src/Model/FeaturedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function getListQuery()

// Filter by language
if ($this->getState('filter.language')) {
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
$query->whereIn($db->quoteName('a.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
}

// Add the list ordering clause.
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/src/Helper/AssociationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function getAssociations($id = 0, $view = null, $layout = null)
$advClause[] = 'c2.access IN (' . $groups . ')';

// Filter by current language
$advClause[] = 'c2.language != ' . $db->quote(Factory::getLanguage()->getTag());
$advClause[] = 'c2.language != ' . $db->quote(Factory::getApplication()->getLanguage()->getTag());

if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
// Filter by start and end dates.
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/src/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getItem($pk = null)

// Filter by language
if ($this->getState('filter.language')) {
$query->whereIn($db->quoteName('a.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
$query->whereIn($db->quoteName('a.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
}

if (
Expand Down
2 changes: 1 addition & 1 deletion components/com_finder/src/Model/SearchModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected function getListQuery()

// Filter by language
if ($this->getState('filter.language')) {
$query->where('l.language IN (' . $db->quote(Factory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')');
$query->where('l.language IN (' . $db->quote(Factory::getApplication()->getLanguage()->getTag()) . ', ' . $db->quote('*') . ')');
}

// Get the result ordering and direction.
Expand Down
2 changes: 1 addition & 1 deletion components/com_finder/src/Model/SuggestionsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected function populateState($ordering = null, $direction = null)

// Set the query language
if (Multilanguage::isEnabled()) {
$lang = Factory::getLanguage()->getTag();
$lang = Factory::getApplication()->getLanguage()->getTag();
} else {
$lang = Helper::getDefaultLanguage();
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_users/src/Model/RegistrationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected function loadFormData()
$data = $this->getData();

if (Multilanguage::isEnabled() && empty($data->language)) {
$data->language = Factory::getLanguage()->getTag();
$data->language = Factory::getApplication()->getLanguage()->getTag();
}

$this->preprocessData('com_users.registration', $data);
Expand Down
2 changes: 1 addition & 1 deletion installation/src/Application/InstallationApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function debugLanguage()
return '';
}

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$output = '<h4>' . Text::_('JDEBUG_LANGUAGE_FILES_IN_ERROR') . '</h4>';

$errorfiles = $lang->getErrorFiles();
Expand Down
2 changes: 1 addition & 1 deletion installation/src/Controller/JSONController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function sendJsonResponse($response)
// Very crude workaround to give an error message when JSON is disabled
if (!\function_exists('json_encode') || !\function_exists('json_decode')) {
$this->app->setHeader('status', 500);
echo '{"token":"' . Session::getFormToken(true) . '","lang":"' . Factory::getLanguage()->getTag()
echo '{"token":"' . Session::getFormToken(true) . '","lang":"' . Factory::getApplication()->getLanguage()->getTag()
. '","error":true,"header":"' . Text::_('INSTL_HEADER_ERROR') . '","message":"' . Text::_('INSTL_WARNJSON') . '"}';

return;
Expand Down
2 changes: 1 addition & 1 deletion installation/src/Form/Field/Installation/LanguageField.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function getOptions()
$options = LanguageHelper::createLanguageListInstall($native);

// Fix wrongly set parentheses in RTL languages
if (Factory::getLanguage()->isRtl()) {
if (Factory::getApplication()->getLanguage()->isRtl()) {
foreach ($options as &$option) {
$option['text'] .= '&#x200E;';
}
Expand Down
2 changes: 1 addition & 1 deletion installation/src/Model/DatabaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function initialise(array $options, bool $select = true)
$options = ArrayHelper::toObject($options);

// Load the backend language files so that the DB error messages work.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$currentLang = $lang->getTag();

// Load the selected language
Expand Down
4 changes: 2 additions & 2 deletions installation/src/Model/SetupModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function storeOptions($options)

// Ensure that we have language
if (!isset($options['language']) || empty($options['language'])) {
$options['language'] = Factory::getLanguage()->getTag();
$options['language'] = Factory::getApplication()->getLanguage()->getTag();
}

// Store passwords as a separate key that is not used in the forms
Expand Down Expand Up @@ -224,7 +224,7 @@ public function validateDbConnection(array $options)
$options = ArrayHelper::toObject($options);

// Load the backend language files so that the DB error messages work.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$currentLang = $lang->getTag();

// Load the selected language
Expand Down
2 changes: 1 addition & 1 deletion installation/src/Response/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function __construct($data)
$this->token = Session::getFormToken(true);

// Get the language and send its tag along
$this->lang = Factory::getLanguage()->getTag();
$this->lang = Factory::getApplication()->getLanguage()->getTag();

// Get the message queue
$messages = Factory::getApplication()->getMessageQueue();
Expand Down
2 changes: 1 addition & 1 deletion layouts/joomla/content/readmore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

$params = $displayData['params'];
$item = $displayData['item'];
$direction = Factory::getLanguage()->isRtl() ? 'left' : 'right';
$direction = Factory::getApplication()->getLanguage()->isRtl() ? 'left' : 'right';
?>

<p class="readmore">
Expand Down
2 changes: 1 addition & 1 deletion layouts/joomla/toolbar/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
$htmlAttributes .= ' onclick="' . $onclick . '"';
}

$direction = Factory::getLanguage()->isRtl() ? 'dropdown-menu-end' : '';
$direction = Factory::getApplication()->getLanguage()->isRtl() ? 'dropdown-menu-end' : '';
?>
<joomla-toolbar-button <?php echo $idAttr . $taskAttr . $listAttr . $formAttr . $validate . $msgAttr; ?>>
<<?php echo $tagName; ?>
Expand Down
2 changes: 1 addition & 1 deletion layouts/joomla/toolbar/dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @var string $toggleSplit
*/

$direction = Factory::getLanguage()->isRtl() ? 'dropdown-menu-end' : '';
$direction = Factory::getApplication()->getLanguage()->isRtl() ? 'dropdown-menu-end' : '';

/**
* The dropdown class is also injected on the button from \Joomla\CMS\Toolbar\ToolbarButton::prepareOptions() and therefore we need the dropdown script whether we
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/CliApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function __construct(
}

$this->input = new \Joomla\CMS\Input\Cli();
$this->language = Factory::getLanguage();
$this->language = Factory::getApplication()->getLanguage();
$this->output = $output ?: new Stdout();
$this->cliInput = $cliInput ?: new CliInput();

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/WebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function loadDocument(Document $document = null)
*/
public function loadLanguage(Language $language = null)
{
$this->language = $language ?? Factory::getLanguage();
$this->language = $language ?? Factory::getApplication()->getLanguage();
OutputFilter::setLanguage($this->language);

return $this;
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Categories/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function __construct($options)
$options['access'] = $options['access'] ?? 'true';
$options['published'] = $options['published'] ?? 1;
$options['countItems'] = $options['countItems'] ?? 0;
$options['currentlang'] = Multilanguage::isEnabled() ? Factory::getLanguage()->getTag() : 0;
$options['currentlang'] = Multilanguage::isEnabled() ? Factory::getApplication()->getLanguage()->getTag() : 0;

$this->_options = $options;
}
Expand Down Expand Up @@ -327,7 +327,7 @@ protected function _load($id)
'(' . $db->quoteName('s.lft') . ' < ' . $db->quoteName('c.lft')
. ' AND ' . $db->quoteName('c.lft') . ' < ' . $db->quoteName('s.rgt')
. ' AND ' . $db->quoteName('c.language')
. ' IN (' . implode(',', $query->bindArray([Factory::getLanguage()->getTag(), '*'], ParameterType::STRING)) . '))'
. ' IN (' . implode(',', $query->bindArray([Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING)) . '))'
. ' OR (' . $db->quoteName('c.lft') . ' <= ' . $db->quoteName('s.lft')
. ' AND ' . $db->quoteName('s.rgt') . ' <= ' . $db->quoteName('c.rgt') . ')'
);
Expand All @@ -345,7 +345,7 @@ protected function _load($id)
$query->from($db->quoteName('#__categories', 'c'));

if ($app->isClient('site') && Multilanguage::isEnabled()) {
$query->whereIn($db->quoteName('c.language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
$query->whereIn($db->quoteName('c.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Component/ComponentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static function filterText($text)
public static function renderComponent($option, $params = [])
{
$app = Factory::getApplication();
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

if (!$app->isClient('api')) {
// Load template language files.
Expand Down
Loading