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
Prev Previous commit
Additional occurences
  • Loading branch information
Hackwar committed May 22, 2024
commit 91152ad1413cc7c40cc5a7f5506e33a8c22fe91a
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct($form = null)
parent::__construct($form);

// Load the required language
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load('com_actionlogs', JPATH_ADMINISTRATOR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function loadTranslationFiles($extension)
return;
}

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

switch (substr($extension, 0, 3)) {
Expand Down Expand Up @@ -274,7 +274,7 @@ public static function getContentTypeLink($component, $contentType, $id, $urlVar
*/
public static function loadActionLogPluginsLanguage()
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$db = Factory::getDbo();

// Get all (both enabled and disabled) actionlog plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public static function getSupportedExtension($extensionName)

// Get the translated titles.
$languagePath = JPATH_ADMINISTRATOR . '/components/' . $extensionName;
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

$lang->load($extensionName . '.sys', JPATH_ADMINISTRATOR);
$lang->load($extensionName . '.sys', $languagePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function getOptions()
$section = (\count($parts) > 1) ? $parts[1] : null;

// Load component language files
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($component, JPATH_BASE)
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getOptions()
$items = $db->setQuery($query)->loadObjectList();

if ($items) {
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

foreach ($items as &$item) {
// Load language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static function loadLanguageForComponent($component)
return;
}

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

// Load the core file then
// Load extension-local file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getForm($data = [], $loadData = true)
return false;
}

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($option, JPATH_BASE)
|| $lang->load($option, JPATH_BASE . "/components/$option");

Expand Down Expand Up @@ -135,7 +135,7 @@ public function getComponent()
$option = $state->get('component.option');

// Load common and local language files.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($option, JPATH_BASE)
|| $lang->load($option, JPATH_BASE . "/components/$option");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function validateSection($section, $item = null)
*/
public function getContexts(): array
{
Factory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);

$contexts = [
'com_contact.contact' => Text::_('COM_CONTACT_FIELDS_CONTEXT_CONTACT'),
Expand Down Expand Up @@ -168,7 +168,7 @@ protected function getStateColumnForSection(string $section = null)
*/
public function getSchemaorgContexts(): array
{
Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_content', JPATH_ADMINISTRATOR);

$contexts = [
'com_contact.contact' => Text::_('COM_CONTACT'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function validateSection($section, $item = null)
*/
public function getContexts(): array
{
Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_content', JPATH_ADMINISTRATOR);

$contexts = [
'com_content.article' => Text::_('COM_CONTENT'),
Expand All @@ -195,7 +195,7 @@ public function getContexts(): array
*/
public function getSchemaorgContexts(): array
{
Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_content', JPATH_ADMINISTRATOR);

$contexts = [
'com_content.article' => Text::_('COM_CONTENT'),
Expand All @@ -213,7 +213,7 @@ public function getSchemaorgContexts(): array
*/
public function getWorkflowContexts(): array
{
Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_content', JPATH_ADMINISTRATOR);

$contexts = [
'com_content.article' => Text::_('COM_CONTENT'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function onPrepareForm(Form $form, $data)
$data = (array) $data;

// Make workflows translatable
Factory::getLanguage()->load('com_workflow', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_workflow', JPATH_ADMINISTRATOR);

$form->setFieldAttribute('workflow_id', 'default', 'inherit');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public function getTransitions()

try {
if (\count($stage_ids) || \count($workflow_ids)) {
Factory::getLanguage()->load('com_workflow', JPATH_ADMINISTRATOR);
Factory::getApplication()->getLanguage()->load('com_workflow', JPATH_ADMINISTRATOR);

$query = $db->getQuery(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static function loadLanguageFiles($typeAlias)

if (\is_array($aliasArray) && \count($aliasArray) == 2) {
$component = ($aliasArray[1] == 'category') ? 'com_categories' : $aliasArray[0];
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

/**
* Loading language file from the administrator/language directory then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getOptions()
$options = [];

if (\count($items)) {
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

$components = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getOptions()
$options = [];

if (\count($items)) {
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

$components = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public static function prepareForm($context, Form $form, $data)
if (!$label) {
$key = strtoupper($component . '_FIELDS_' . $section . '_LABEL');

if (!Factory::getLanguage()->hasKey($key)) {
if (!Factory::getApplication()->getLanguage()->hasKey($key)) {
$key = 'JGLOBAL_FIELDS';
}

Expand All @@ -447,7 +447,7 @@ public static function prepareForm($context, Form $form, $data)
if (!$description) {
$key = strtoupper($component . '_FIELDS_' . $section . '_DESC');

if (Factory::getLanguage()->hasKey($key)) {
if (Factory::getApplication()->getLanguage()->hasKey($key)) {
$description = $key;
}
}
Expand Down
6 changes: 3 additions & 3 deletions administrator/components/com_fields/src/Model/FieldModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,13 +1028,13 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
// Allow to override the default value label and description through the plugin
$key = 'PLG_FIELDS_' . strtoupper($dataObject->type) . '_DEFAULT_VALUE_LABEL';

if (Factory::getLanguage()->hasKey($key)) {
if (Factory::getApplication()->getLanguage()->hasKey($key)) {
$form->setFieldAttribute('default_value', 'label', $key);
}

$key = 'PLG_FIELDS_' . strtoupper($dataObject->type) . '_DEFAULT_VALUE_DESC';

if (Factory::getLanguage()->hasKey($key)) {
if (Factory::getApplication()->getLanguage()->hasKey($key)) {
$form->setFieldAttribute('default_value', 'description', $key);
}

Expand Down Expand Up @@ -1096,7 +1096,7 @@ function () use ($component, $section) {
}

if (file_exists($path)) {
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($component, JPATH_BASE);
$lang->load($component, JPATH_BASE . '/components/' . $component);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
$path = Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/models/forms/fieldgroup/' . $section . '.xml');

if (file_exists($path)) {
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load($component, JPATH_BASE);
$lang->load($component, JPATH_BASE . '/components/' . $component);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function getGroups()
*/
private function prepareLevel($parent, $parents)
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$entries = [];

foreach ($parents[$parent] as $item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ContenttypesField extends ListField
*/
public function getOptions()
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$options = [];

$db = $this->getDatabase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function branchLanguageTitle($branchName)
*/
public static function loadComponentLanguage()
{
Factory::getLanguage()->load('com_finder', JPATH_SITE);
Factory::getApplication()->getLanguage()->load('com_finder', JPATH_SITE);
}

/**
Expand Down Expand Up @@ -139,7 +139,7 @@ public static function loadPluginLanguage()
}

// Load generic language strings.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load('plg_content_finder', JPATH_ADMINISTRATOR);

// Load language file for each plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getData()
$db->setQuery($query);
$data->type_list = $db->loadObjectList();

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$plugins = PluginHelper::getPlugin('finder');

foreach ($plugins as $plugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function slider($options = [])
}

// Translate node titles if possible.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

foreach ($nodes as $nk => $nv) {
if (trim($nv->parent_title, '*') === 'Language') {
Expand Down Expand Up @@ -218,7 +218,7 @@ public function select($idxQuery, $options)

// Try to load the results from cache.
$cache = Factory::getCache('com_finder', '');
$cacheId = 'filter_select_' . serialize([$idxQuery->filter, $options, $groups, Factory::getLanguage()->getTag()]);
$cacheId = 'filter_select_' . serialize([$idxQuery->filter, $options, $groups, Factory::getApplication()->getLanguage()->getTag()]);

// Check the cached results.
if ($cache->contains($cacheId)) {
Expand Down Expand Up @@ -303,7 +303,7 @@ public function select($idxQuery, $options)

// Apply multilanguage filter
if (Multilanguage::isEnabled()) {
$language = [Factory::getLanguage()->getTag(), '*'];
$language = [Factory::getApplication()->getLanguage()->getTag(), '*'];
$query->whereIn($db->quoteName('t.language'), $language, ParameterType::STRING);
}

Expand All @@ -326,7 +326,7 @@ public function select($idxQuery, $options)
}

// Translate branch nodes if possible.
$language = Factory::getLanguage();
$language = Factory::getApplication()->getLanguage();
$root = [];

foreach ($branches[$bk]->nodes as $node_id => $node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function typeslist()
// Compile the options.
$options = [];

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

foreach ($rows as $row) {
$key = $lang->hasKey(LanguageHelper::branchPlural($row->text)) ? LanguageHelper::branchPlural($row->text) : $row->text;
Expand Down Expand Up @@ -92,7 +92,7 @@ public function mapslist()
}

// Translate.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

foreach ($branches as $branch) {
$key = LanguageHelper::branchPlural($branch->text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function explained(IndexerQuery $query)
// Process the taxonomy branches.
foreach ($query->filters as $branch => $nodes) {
// Process the taxonomy nodes.
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

foreach ($nodes as $title => $id) {
// Translate the title for Types
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_finder/tmpl/maps/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$branchFilter = $this->escape($this->state->get('filter.branch'));

Text::script('COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function loadTranslationFiles($uid, bool $steps = false)
return;
}

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

// The uid has an extension separator so we need to check the extension language files
if (strpos($uid, '.') > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected function _getList($query, $limitstart = 0, $limit = 0)
*/
protected function translate(&$items)
{
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();

foreach ($items as &$item) {
if (\strlen($item->manifest_cache) && $data = json_decode($item->manifest_cache)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setDefault()
if ($model->publish($cid)) {
// Switching to the new administrator language for the message
if ($model->getState('client_id') == 1) {
$language = Factory::getLanguage();
$language = Factory::getApplication()->getLanguage();
$newLang = Language::getInstance($cid);
Factory::$language = $newLang;
$this->app->loadLanguage($language = $newLang);
Expand Down Expand Up @@ -92,7 +92,7 @@ public function switchAdminLanguage()
if ($model->switchAdminLanguage($cid)) {
// Switching to the new language for the message
$languageName = $info['nativeName'];
$language = Factory::getLanguage();
$language = Factory::getApplication()->getLanguage();
$newLang = Language::getInstance($cid);
Factory::$language = $newLang;
$this->app->loadLanguage($language = $newLang);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function getData()
if (\is_null($this->data)) {
$this->data = [];

$isCurrentLanguageRtl = Factory::getLanguage()->isRtl();
$isCurrentLanguageRtl = Factory::getApplication()->getLanguage()->isRtl();
$params = ComponentHelper::getParams('com_languages');
$installedLanguages = LanguageHelper::getInstalledLanguages(null, true, true, null, null, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function getItems()

if (!isset($this->cache[$store])) {
$items = parent::getItems();
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$client = $this->state->get('filter.client_id');

if ($items) {
Expand Down
Loading