diff --git a/administrator/components/com_languages/Helper/MultilangstatusHelper.php b/administrator/components/com_languages/Helper/MultilangstatusHelper.php index bb5335f6326d0..1e1219ad5650a 100644 --- a/administrator/components/com_languages/Helper/MultilangstatusHelper.php +++ b/administrator/components/com_languages/Helper/MultilangstatusHelper.php @@ -36,9 +36,14 @@ public static function getHomes() $query = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__menu')) - ->where('home = 1') - ->where('published = 1') - ->where('client_id = 0'); + ->where( + [ + $db->quoteName('home') . ' = 1', + $db->quoteName('published') . ' = 1', + $db->quoteName('client_id') . ' = 0', + ] + ); + $db->setQuery($query); return $db->loadResult(); @@ -56,9 +61,14 @@ public static function getLangswitchers() $query = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__modules')) - ->where('module = ' . $db->quote('mod_languages')) - ->where('published = 1') - ->where('client_id = 0'); + ->where( + [ + $db->quoteName('module') . ' = ' . $db->quote('mod_languages'), + $db->quoteName('published') . ' = 1', + $db->quoteName('client_id') . ' = 0', + ] + ); + $db->setQuery($query); return $db->loadResult(); @@ -74,9 +84,14 @@ public static function getContentlangs() // Check for published Content Languages. $db = Factory::getDbo(); $query = $db->getQuery(true) - ->select('a.lang_code AS lang_code') - ->select('a.published AS published') - ->from('#__languages AS a'); + ->select( + [ + $db->quoteName('a.lang_code', 'lang_code'), + $db->quoteName('a.published', 'published'), + ] + ) + ->from($db->quoteName('#__languages', 'a')); + $db->setQuery($query); return $db->loadObjectList(); @@ -95,20 +110,24 @@ public static function getStatus() // Select all fields from the languages table. $query->select('a.*', 'l.home') - ->select('a.published AS published') - ->select('a.lang_code AS lang_code') - ->from('#__languages AS a'); + ->select($db->quoteName('a.published', 'published')) + ->select($db->quoteName('a.lang_code', 'lang_code')) + ->from($db->quoteName('#__languages', 'a')); // Select the language home pages. - $query->select('l.home AS home') - ->select('l.language AS home_language') - ->join('LEFT', '#__menu AS l ON l.language = a.lang_code AND l.home=1 AND l.published=1 AND l.language <> \'*\'') - ->select('e.enabled AS enabled') - ->select('e.element AS element') - ->join('LEFT', '#__extensions AS e ON e.element = a.lang_code') - ->where('e.client_id = 0') - ->where('e.enabled = 1') - ->where('e.state = 0'); + $query->select($db->quoteName('l.home', 'home')) + ->select($db->quoteName('l.published', 'home_published')) + ->join('LEFT', $db->quoteName('#__menu', 'l') . ' ON ' . $db->quoteName('l.language') . ' = ' . $db->quoteName('a.lang_code') . ' AND ' . $db->quoteName('l.home') . ' = 1 AND ' . $db->quoteName('l.language') . ' <> \'*\'') + ->select($db->quoteName('e.enabled', 'enabled')) + ->select($db->quoteName('e.element', 'element')) + ->join('LEFT', $db->quoteName('#__extensions', 'e'), $db->quoteName('e.element') . ' = ' . $db->quoteName('a.lang_code')) + ->where( + [ + $db->quoteName('e.client_id') . ' = 0', + $db->quoteName('e.enabled') . ' = 1', + $db->quoteName('e.state') . ' = 0', + ] + ); $db->setQuery($query); @@ -128,37 +147,49 @@ public static function getContacts() // Get the number of contact with all as language $alang = $db->getQuery(true) ->select('count(*)') - ->from('#__contact_details AS cd') - ->where('cd.user_id=u.id') - ->where('cd.published=1') - ->where('cd.language=' . $db->quote('*')); + ->from($db->quoteName('#__contact_details', 'cd')) + ->where( + [ + $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id'), + $db->quoteName('cd.published') . ' = 1', + $db->quoteName('cd.language') . ' = ' . $db->quote('*'), + ] + ); // Get the number of languages for the contact $slang = $db->getQuery(true) ->select('count(distinct(l.lang_code))') - ->from('#__languages as l') - ->join('LEFT', '#__contact_details AS cd ON cd.language=l.lang_code') - ->where('cd.user_id=u.id') - ->where('cd.published=1') - ->where('l.published=1'); + ->from($db->quoteName('#__languages', 'l')) + ->join('LEFT', $db->quoteName('#__contact_details', 'cd'), $db->quoteName('cd.language') . ' = ' . $db->quoteName('l.lang_code')) + ->where( + [ + $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id'), + $db->quoteName('cd.published') . ' = 1', + $db->quoteName('l.published') . ' = 1', + ] + ); // Get the number of multiple contact/language $mlang = $db->getQuery(true) ->select('count(*)') - ->from('#__languages as l') - ->join('LEFT', '#__contact_details AS cd ON cd.language=l.lang_code') - ->where('cd.user_id=u.id') - ->where('cd.published=1') - ->where('l.published=1') - ->group('l.lang_code') + ->from($db->quoteName('#__languages', 'l')) + ->join('LEFT', $db->quoteName('#__contact_details', 'cd'), $db->quoteName('cd.language') . ' = ' . $db->quoteName('l.lang_code')) + ->where( + [ + $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id'), + $db->quoteName('cd.published') . ' = 1', + $db->quoteName('l.published') . ' = 1', + ] + ) + ->group($db->quoteName('l.lang_code')) ->having('count(*) > 1'); // Get the contacts $query = $db->getQuery(true) ->select('u.name, (' . $alang . ') as alang, (' . $slang . ') as slang, (' . $mlang . ') as mlang') - ->from('#__users AS u') - ->join('LEFT', '#__contact_details AS cd ON cd.user_id=u.id') - ->where('EXISTS (SELECT 1 from #__content as c where c.created_by=u.id)') + ->from($db->quoteName('#__users', 'u')) + ->join('LEFT', $db->quoteName('#__contact_details', 'cd'), $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id')) + ->where('EXISTS (SELECT 1 FROM ' . $db->quoteName('#__content', 'c') . ' WHERE ' . $db->quoteName('c.created_by') . ' = ' . $db->quoteName('u.id') . ')') ->group('u.id, u.name'); $db->setQuery($query); @@ -199,10 +230,14 @@ public static function getDefaultHomeModule() $query = $db->getQuery(true) ->select($db->quoteName('menutype')) ->from($db->quoteName('#__menu')) - ->where($db->quoteName('home') . ' = ' . $db->quote('1')) - ->where($db->quoteName('published') . ' = ' . $db->quote('1')) - ->where($db->quoteName('client_id') . ' = ' . $db->quote('0')) - ->where($db->quoteName('language') . ' = ' . $db->quote('*')); + ->where( + [ + $db->quoteName('home') . ' = 1', + $db->quoteName('published') . ' = 1', + $db->quoteName('client_id') . ' = 0', + $db->quoteName('language') . ' = ' . $db->quote('*'), + ] + ); $db->setQuery($query); @@ -212,9 +247,13 @@ public static function getDefaultHomeModule() $query->clear() ->select($db->quoteName('title')) ->from($db->quoteName('#__modules')) - ->where($db->quoteName('module') . ' = ' . $db->quote('mod_menu')) - ->where($db->quoteName('published') . ' = ' . $db->quote('1')) - ->where($db->quoteName('client_id') . ' = ' . $db->quote('0')); + ->where( + [ + $db->quoteName('module') . ' = ' . $db->quote('mod_menu'), + $db->quoteName('published') . ' = 1', + $db->quoteName('client_id') . ' = 0', + ] + ); $db->setQuery($query); @@ -253,9 +292,13 @@ public static function getModule($moduleName, $instanceTitle = null) $query = $db->getQuery(true) ->select('id, title, module, position, content, showtitle, params') ->from($db->quoteName('#__modules')) - ->where($db->quoteName('module') . ' = ' . $db->quote($moduleName)) - ->where($db->quoteName('published') . ' = ' . $db->quote('1')) - ->where($db->quoteName('client_id') . ' = ' . $db->quote('0')); + ->where( + [ + $db->quoteName('module') . ' = ' . $db->quote($moduleName), + $db->quoteName('published') . ' = 1', + $db->quoteName('client_id') . ' = 0', + ] + ); if ($instanceTitle) { diff --git a/administrator/components/com_languages/View/Multilangstatus/HtmlView.php b/administrator/components/com_languages/View/Multilangstatus/HtmlView.php index 7cee6a2385b33..3465cf1bff03e 100644 --- a/administrator/components/com_languages/View/Multilangstatus/HtmlView.php +++ b/administrator/components/com_languages/View/Multilangstatus/HtmlView.php @@ -11,6 +11,7 @@ defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; @@ -41,6 +42,7 @@ public function display($tpl = null) $this->statuses = MultilangstatusHelper::getStatus(); $this->homepages = Multilanguage::getSiteHomePages(); $this->defaultHome = MultilangstatusHelper::getDefaultHomeModule(); + $this->default_lang = ComponentHelper::getParams('com_languages')->get('site', 'en-GB'); parent::display($tpl); } diff --git a/administrator/components/com_languages/tmpl/multilangstatus/default.php b/administrator/components/com_languages/tmpl/multilangstatus/default.php index b3ac082d94056..103805ca38877 100644 --- a/administrator/components/com_languages/tmpl/multilangstatus/default.php +++ b/administrator/components/com_languages/tmpl/multilangstatus/default.php @@ -11,9 +11,13 @@ use Joomla\CMS\Language\Text; -$notice_homes = $this->homes == 2 || $this->homes == 1 || $this->homes - 1 != count($this->contentlangs) && ($this->language_filter || $this->switchers != 0); -$notice_disabled = !$this->language_filter && ($this->homes > 1 || $this->switchers != 0); +$notice_disabled = !$this->language_filter && ($this->homes > 1 || $this->switchers != 0); $notice_switchers = !$this->switchers && ($this->homes > 1 || $this->language_filter); + +// Defining arrays +$content_languages = array_column($this->contentlangs, 'lang_code'); +$sitelangs = array_column($this->site_langs, 'element'); +$home_pages = array_column($this->homepages, 'language'); ?>
language_filter && $this->switchers == 0) : ?> @@ -31,20 +35,48 @@
- defaultHome == true) : ?> -
- - - + default_lang, $content_languages)) : ?> +
+ + + default_lang); ?>
+ + contentlangs as $contentlang) : ?> + lang_code == $this->default_lang && $contentlang->published != 1) : ?> +
+ + + default_lang); ?> +
+ + - + defaultHome == true) : ?>
- +
+ statuses as $status) : ?> + + lang_code && $status->published == 1 && $status->home_published != 1) : ?> +
+ + + lang_code, $status->lang_code); ?> +
+ + + lang_code && $status->published == 0 && $status->home_published != 1) : ?> +
+ + + lang_code, $status->lang_code); ?> +
+ +
@@ -60,7 +92,7 @@
contentlangs as $contentlang) : ?> - lang_code, $this->homepages) && (!array_key_exists($contentlang->lang_code, $this->site_langs) || !$contentlang->published)) : ?> + lang_code, $this->homepages) && (!array_key_exists($contentlang->lang_code, $this->site_langs) || $contentlang->published != 1)) : ?>
@@ -78,7 +110,7 @@
- lang_code); ?> + lang_code); ?>
@@ -96,13 +128,23 @@
+ + + +
+ + + +
+ + - - @@ -154,16 +196,16 @@
+ +
- - - - @@ -172,9 +214,9 @@ statuses as $status) : ?> element) : ?> - element) : ?> @@ -188,60 +230,58 @@ - lang_code && $status->published == 1) : ?> - - lang_code && $status->published == 0) : ?> - - lang_code && $status->published == -2) : ?> - - - - + + - home_language) : ?> - - - - + home_published == -2) : ?> + + + + + + + contentlangs as $contentlang) : ?> lang_code, $this->site_langs)) : ?> - @@ -257,6 +297,28 @@ + + + + + + + + + + +
+ + + +
+ element; ?> - + + + lang_code && $status->published == 1) : ?> - - - - - - - + lang_code && $status->published == 0) : ?> + + + lang_code && $status->published == -2) : ?> + + + - + + home_published == 1) : ?> - + home_published == 0) : ?> -
+ lang_code; ?> - + - published) : ?> + published == 1) : ?> - published && array_key_exists($contentlang->lang_code, $this->homepages)) : ?> + published == 0 && array_key_exists($contentlang->lang_code, $this->homepages)) : ?> - published) : ?> - + published == -2 && array_key_exists($contentlang->lang_code, $this->homepages)) : ?> +
+ + + + + + + + + + +
diff --git a/administrator/language/en-GB/com_languages.ini b/administrator/language/en-GB/com_languages.ini index cf4ffddaac4ed..189a1031fecbb 100644 --- a/administrator/language/en-GB/com_languages.ini +++ b/administrator/language/en-GB/com_languages.ini @@ -61,19 +61,22 @@ COM_LANGUAGES_MSG_DEFAULT_MULTILANG_SAVED="Default Language Saved. This does not COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS="The Administrator Language has been switched to "%s"." COM_LANGUAGES_MULTILANGSTATUS_CONTACTS_ERROR="Some of the contacts linked to the user %s are incorrect." COM_LANGUAGES_MULTILANGSTATUS_CONTACTS_ERROR_TIP="Warning! A user/author should have only one contact to which is assigned language 'All' OR one contact for each published Content Language." +COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_HOME_UNPUBLISHED="Both the %s Content Language and its Home page are unpublished. The language will not display on the site." +COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_MISSING="The %s Content Language has been deleted although the corresponding Site Language is enabled and a Home page is assigned to this language. The language will not display on the site." COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_PUBLISHED="Published Content Languages" -COM_LANGUAGES_MULTILANGSTATUS_DEFAULT_HOME_MODULE_PUBLISHED="This site is set as a multilingual site. The menu module displaying the Home menu item set to language "All" should not be published." -COM_LANGUAGES_MULTILANGSTATUS_ERROR_CONTENT_LANGUAGE="A Default Home page is assigned to the %s Content Language although a Site Language for this Content Language is not installed or enabled AND/OR the Content Language is not published." -COM_LANGUAGES_MULTILANGSTATUS_ERROR_CONTENT_LANGUAGE_TRASHED="The Content Language %s is trashed." -COM_LANGUAGES_MULTILANGSTATUS_ERROR_LANGUAGE_TAG="The Content Language tag %s does not match the Site Language tag. Check that the Site Language is installed and enabled and the correct language tag is used for the Content Language. Example: for English (en-GB) both tags should be 'en-GB'." -COM_LANGUAGES_MULTILANGSTATUS_HOMES_MISSING="This site is set as a multilingual site. One or more of the Default Home pages for the published Content languages are missing although the Language Filter plugin is enabled AND/OR one or more Language Switcher modules are published." +COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_TRASHED="The %s Content Language is trashed. The language will not display on the site." +COM_LANGUAGES_MULTILANGSTATUS_DEFAULT_HOME_MODULE_PUBLISHED="The menu module displaying the Home menu item set to language "All" should not be published." +COM_LANGUAGES_MULTILANGSTATUS_ERROR_CONTENT_LANGUAGE="A Default Home page is assigned to the %s Content Language although a Site Language for this Content Language is not installed or enabled AND/OR the Content Language is not published. The language will not display on the site." +COM_LANGUAGES_MULTILANGSTATUS_ERROR_DEFAULT_CONTENT_LANGUAGE="The Content Language for the %s default Site Language is unpublished or does not exist. If not corrected, the multilingual feature may not function properly or the site may not be reachable!" +COM_LANGUAGES_MULTILANGSTATUS_ERROR_LANGUAGE_TAG="The Content Language tag %s does not have a matching Site Language tag. Check that the Site Language is installed and enabled AND the correct language tag is used for the Content Language. Example: for English (en-GB) both tags should be 'en-GB'. The language will not display on the site." +COM_LANGUAGES_MULTILANGSTATUS_HOME_UNPUBLISHED="The Default Home page assigned to the %s Content Language is unpublished. The language will not display on the site." COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED="Published Default Home pages" COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED_ALL="1 assigned to language 'All'." COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED_INCLUDING_ALL="Published Default Home pages (including 1 assigned to language "All")." COM_LANGUAGES_MULTILANGSTATUS_LANGSWITCHER_PUBLISHED="Published Language Switcher Modules." -COM_LANGUAGES_MULTILANGSTATUS_LANGSWITCHER_UNPUBLISHED="This site is set as a multilingual site, at least one Language Switcher module set to language "All" has to be published. Disregard this message if you do not use a language switcher module but direct links." +COM_LANGUAGES_MULTILANGSTATUS_LANGSWITCHER_UNPUBLISHED="At least one Language Switcher module set to language "All" has to be published. Otherwise, it will be impossible to switch languages on the site. Disregard this message if you do not use a language switcher module but direct links." COM_LANGUAGES_MULTILANGSTATUS_LANGUAGEFILTER="Language Filter Plugin" -COM_LANGUAGES_MULTILANGSTATUS_LANGUAGEFILTER_DISABLED="This site is set as a multilingual site. The Language Filter plugin is not enabled although one or more Language Switcher modules AND/OR one or more specific Content language Default Home pages are published." +COM_LANGUAGES_MULTILANGSTATUS_LANGUAGEFILTER_DISABLED="The Language Filter plugin is not enabled although one or more Language Switcher modules AND/OR one or more specific Content language Default Home pages are published." COM_LANGUAGES_MULTILANGSTATUS_NONE="This site is not set as a multilingual site." COM_LANGUAGES_MULTILANGSTATUS_SITE_LANG_PUBLISHED="Enabled Site Languages" COM_LANGUAGES_MULTILANGSTATUS_USELESS_HOMES="This site is not set as a multilingual site.
Note: at least one Default Home page is assigned to a Content Language. This will not break a monolingual site but is useless."