diff --git a/administrator/components/com_categories/models/fields/categoryedit.php b/administrator/components/com_categories/models/fields/categoryedit.php index e530a36ff878d..a3b47f43c7051 100644 --- a/administrator/components/com_categories/models/fields/categoryedit.php +++ b/administrator/components/com_categories/models/fields/categoryedit.php @@ -145,7 +145,7 @@ protected function getOptions() $user = JFactory::getUser(); $query = $db->getQuery(true) - ->select('a.id AS value, a.title AS text, a.level, a.published, a.lft') + ->select('a.id AS value, a.title AS text, a.level, a.published, a.lft, a.language') ->from('#__categories AS a'); // Filter by the extension type @@ -232,16 +232,6 @@ protected function getOptions() } } - // Displays language code if not set to All - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('language')) - ->where($db->quoteName('id') . '=' . (int) $options[$i]->value) - ->from($db->quoteName('#__categories')); - - $db->setQuery($query); - $language = $db->loadResult(); - if ($options[$i]->level != 0) { $options[$i]->level = $options[$i]->level -1; @@ -256,9 +246,10 @@ protected function getOptions() $options[$i]->text = str_repeat('- ', $options[$i]->level) . '[' . $options[$i]->text . ']'; } - if ($language !== '*') + // Displays language code if not set to All + if ($options[$i]->language !== '*') { - $options[$i]->text = $options[$i]->text . ' (' . $language . ')'; + $options[$i]->text = $options[$i]->text . ' (' . $options[$i]->language . ')'; } } diff --git a/administrator/language/en-GB/en-GB.plg_sampledata_blog.ini b/administrator/language/en-GB/en-GB.plg_sampledata_blog.ini index bf7ff0ad55c3d..4fdf56592654f 100644 --- a/administrator/language/en-GB/en-GB.plg_sampledata_blog.ini +++ b/administrator/language/en-GB/en-GB.plg_sampledata_blog.ini @@ -4,7 +4,7 @@ ; Note : All ini files need to be saved as UTF-8 PLG_SAMPLEDATA_BLOG="Sample Data - Blog" -PLG_SAMPLEDATA_BLOG_OVERVIEW_DESC="Sample data which will set up a blog site." +PLG_SAMPLEDATA_BLOG_OVERVIEW_DESC="Sample data which will set up a blog site.
If the site is multilingual, the data will be tagged to the active backend language." PLG_SAMPLEDATA_BLOG_OVERVIEW_TITLE="Blog Sample data" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_0_FULLTEXT="" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_0_INTROTEXT="

This tells you a bit about this blog and the person who writes it.

When you are logged in you will be able to edit this page by clicking on the edit icon.

" @@ -26,7 +26,7 @@ PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_5_INTROTEXT="

Templates control PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_5_TITLE="Your Template" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_CATEGORY_0_TITLE="Blog" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_CATEGORY_1_TITLE="Help" -PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_ITEM_0_TITLE="Blog Home" +PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_ITEM_0_TITLE="Blog" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_ITEM_1_TITLE="About" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_ITEM_2_TITLE="Author Login" PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_ITEM_3_TITLE="Create a Post" diff --git a/administrator/modules/mod_sampledata/tmpl/default.php b/administrator/modules/mod_sampledata/tmpl/default.php index d4f37942e5b48..2e351f53c6072 100644 --- a/administrator/modules/mod_sampledata/tmpl/default.php +++ b/administrator/modules/mod_sampledata/tmpl/default.php @@ -37,7 +37,7 @@

- description); ?> + description; ?>
diff --git a/components/com_finder/views/search/tmpl/default_results.php b/components/com_finder/views/search/tmpl/default_results.php index a031d7bb2d273..30bdb05dcb7f5 100644 --- a/components/com_finder/views/search/tmpl/default_results.php +++ b/components/com_finder/views/search/tmpl/default_results.php @@ -33,7 +33,7 @@ -total === 0) : ?> +total === 0) || ($this->total === null)) : ?>

getLanguageFilter() ? '_MULTILANG' : ''; ?> diff --git a/installation/controller/setdefaultlanguage.php b/installation/controller/setdefaultlanguage.php index b59a01fdddf8c..bfc9f654cc914 100644 --- a/installation/controller/setdefaultlanguage.php +++ b/installation/controller/setdefaultlanguage.php @@ -130,7 +130,19 @@ public function execute() continue; } - if (!$tableMenuItem = $model->addMenuItem($siteLang)) + if (!$data['installLocalisedContent']) + { + if (!$tableMenuItem = $model->addFeaturedMenuItem($siteLang)) + { + $app->enqueueMessage(JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_CREATE_MENU_ITEM', $siteLang->name), 'warning'); + + continue; + } + + $groupedAssociations['com_menus.item'][$siteLang->language] = $tableMenuItem->id; + } + + if (!$tableMenuItem = $model->addAllCategoriesMenuItem($siteLang)) { $app->enqueueMessage(JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_CREATE_MENU_ITEM', $siteLang->name), 'warning'); @@ -157,6 +169,15 @@ public function execute() $groupedAssociations['com_categories.item'][$siteLang->language] = $tableCategory->id; + if (!$tableMenuItem = $model->addBlogMenuItem($siteLang, $tableCategory->id)) + { + $app->enqueueMessage(JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_CREATE_MENU_ITEM', $siteLang->name), 'warning'); + + continue; + } + + $groupedAssociations['com_menus.item'][$siteLang->language] = $tableMenuItem->id; + if (!$tableArticle = $model->addArticle($siteLang, $tableCategory->id)) { $app->enqueueMessage(JText::sprintf('INSTL_DEFAULTLANGUAGE_COULD_NOT_CREATE_ARTICLE', $frontend_lang), 'warning'); diff --git a/installation/language/en-GB/en-GB.ini b/installation/language/en-GB/en-GB.ini index 0a04584b1f251..c9d6fb6c70157 100644 --- a/installation/language/en-GB/en-GB.ini +++ b/installation/language/en-GB/en-GB.ini @@ -123,8 +123,8 @@ INSTL_EMAIL_NOT_SENT="Email could not be sent." ;Complete view INSTL_COMPLETE_ADMINISTRATION_LOGIN_DETAILS="Administration Login Details" INSTL_COMPLETE_ERROR_FOLDER_ALREADY_REMOVED="The "%s" folder has already been deleted." -INSTL_COMPLETE_ERROR_FOLDER_DELETE=""%s" folder could not be deleted. Please manually delete the folder." -INSTL_COMPLETE_FOLDER_REMOVED=""%s" folder removed." +INSTL_COMPLETE_ERROR_FOLDER_DELETE="\"%s\" folder could not be deleted. Please manually delete the folder." +INSTL_COMPLETE_FOLDER_REMOVED="\"%s\" folder removed." INSTL_COMPLETE_LANGUAGE_1="Joomla! in your own language and/or automatic basic native multilingual site creation" INSTL_COMPLETE_LANGUAGE_DESC="Before removing the "%s" folder you can install extra languages. If you want to add extra languages to your Joomla! application select the following button." INSTL_COMPLETE_LANGUAGE_DESC2="Note: you will need internet access for Joomla! to download and install the new languages.
Some server configurations won't allow Joomla! to install the languages. If this is your case, don't worry, you will be able to install them later using the Joomla! Administrator." diff --git a/installation/model/languages.php b/installation/model/languages.php index 6d12f62571ccd..5efe8198b8e4c 100644 --- a/installation/model/languages.php +++ b/installation/model/languages.php @@ -872,7 +872,7 @@ public function addMenuGroup($itemLanguage) } /** - * Add Menu Item. + * Add Featured Menu Item. * * @param stdClass $itemLanguage Language Object. * @@ -880,7 +880,7 @@ public function addMenuGroup($itemLanguage) * * @since 3.2 */ - public function addMenuItem($itemLanguage) + public function addFeaturedMenuItem($itemLanguage) { // Add Menu Item. $tableItem = JTable::getInstance('Menu', 'MenusTable'); @@ -943,6 +943,86 @@ public function addMenuItem($itemLanguage) return $tableItem; } + /** + * Add AllCategories Menu Item for new router. + * + * @param stdClass $itemLanguage Language Object. + * + * @return JTable|boolean Menu Item Object. False otherwise. + * + * @since __DEPLOY_VERSION__ + */ + + public function addAllCategoriesMenuItem($itemLanguage) + { + // Add Menu Item. + $tableItem = JTable::getInstance('Menu', 'MenusTable'); + + $newlanguage = new JLanguage($itemLanguage->language, false); + $newlanguage->load('joomla', JPATH_ADMINISTRATOR, $itemLanguage->language, true); + $title = $newlanguage->_('JCATEGORIES'); + $alias = 'allcategories_' . $itemLanguage->language; + + $menuItem = array( + 'title' => $title, + 'alias' => $alias, + 'menutype' => 'mainmenu-' . strtolower($itemLanguage->language), + 'type' => 'component', + 'link' => 'index.php?option=com_content&view=categories&id=0', + 'component_id' => 22, + 'published' => 1, + 'parent_id' => 1, + 'level' => 1, + 'home' => 0, + 'params' => '{"show_base_description":"","categories_description":"","maxLevelcat":"",' + . '"show_empty_categories_cat":"","show_subcat_desc_cat":"","show_cat_num_articles_cat":"",' + . '"show_category_title":"","show_description":"","show_description_image":"","maxLevel":"",' + . '"show_empty_categories":"","show_no_articles":"","show_subcat_desc":"","show_cat_num_articles":"",' + . '"num_leading_articles":"","num_intro_articles":"","num_columns":"","num_links":"",' + . '"multi_column_order":"","show_subcategory_content":"","orderby_pri":"","orderby_sec":"",' + . '"order_date":"","show_pagination_limit":"","filter_field":"","show_headings":"",' + . '"list_show_date":"","date_format":"","list_show_hits":"","list_show_author":"","display_num":"10",' + . '"show_pagination":"","show_pagination_results":"","show_title":"","link_titles":"",' + . '"show_intro":"","show_category":"","link_category":"","show_parent_category":"",' + . '"link_parent_category":"","show_author":"","link_author":"","show_create_date":"",' + . '"show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_vote":"",' + . '"show_readmore":"","show_readmore_title":"","show_icons":"","show_print_icon":"",' + . '"show_email_icon":"","show_hits":"","show_noauth":"","show_feed_link":"","feed_summary":"",' + . '"menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_image_css":"","menu_text":1,' + . '"menu_show":0,"page_title":"","show_page_heading":"","page_heading":"","pageclass_sfx":"",' + . '"menu-meta_description":"","menu-meta_keywords":"","robots":"","secure":0}', + 'language' => $itemLanguage->language, + ); + + // Bind the data. + if (!$tableItem->bind($menuItem)) + { + return false; + } + + $tableItem->setLocation($menuItem['parent_id'], 'last-child'); + + // Check the data. + if (!$tableItem->check()) + { + return false; + } + + // Store the data. + if (!$tableItem->store()) + { + return false; + } + + // Rebuild the tree path. + if (!$tableItem->rebuildPath($tableItem->id)) + { + return false; + } + + return $tableItem; + } + /** * Add Module Menu. * @@ -1218,6 +1298,84 @@ public function addArticle($itemLanguage, $categoryId) return $article; } + /** + * Add Blog Menu Item. + * + * @param stdClass $itemLanguage Language Object. + * @param int $categoryId The id of the category displayed by the blog. + * + * @return JTable|boolean Menu Item Object. False otherwise. + * + * @since __DEPLOY_VERSION__ + */ + public function addBlogMenuItem($itemLanguage, $categoryId) + { + // Add Menu Item. + $tableItem = JTable::getInstance('Menu', 'MenusTable'); + + $newlanguage = new JLanguage($itemLanguage->language, false); + $newlanguage->load('com_languages', JPATH_ADMINISTRATOR, $itemLanguage->language, true); + $title = $newlanguage->_('COM_LANGUAGES_HOMEPAGE'); + $alias = 'home_' . $itemLanguage->language; + + $menuItem = array( + 'title' => $title, + 'alias' => $alias, + 'menutype' => 'mainmenu-' . strtolower($itemLanguage->language), + 'type' => 'component', + 'link' => 'index.php?option=com_content&view=category&layout=blog&id=' . $categoryId, + 'component_id' => 22, + 'published' => 1, + 'parent_id' => 1, + 'level' => 1, + 'home' => 1, + 'params' => '{"layout_type":"blog","show_category_heading_title_text":"","show_category_title":"",' + . '"show_description":"","show_description_image":"","maxLevel":"","show_empty_categories":"",' + . '"show_no_articles":"","show_subcat_desc":"","show_cat_num_articles":"","show_cat_tags":"",' + . '"page_subheading":"","num_leading_articles":"1","num_intro_articles":"3","num_columns":"3",' + . '"num_links":"0","multi_column_order":"1","show_subcategory_content":"","orderby_pri":"",' + . '"orderby_sec":"front","order_date":"","show_pagination":"2","show_pagination_results":"1",' + . '"show_featured":"","show_title":"","link_titles":"","show_intro":"","info_block_position":"",' + . '"info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"",' + . '"link_parent_category":"","show_associations":"","show_author":"","link_author":"",' + . '"show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"",' + . '"show_vote":"","show_readmore":"","show_readmore_title":"","show_icons":"","show_print_icon":"",' + . '"show_email_icon":"","show_hits":"","show_tags":"","show_noauth":"","show_feed_link":"1",' + . '"feed_summary":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"",' + . '"menu_image_css":"","menu_text":1,"menu_show":1,"page_title":"","show_page_heading":"1",' + . '"page_heading":"","pageclass_sfx":"","menu-meta_description":"","menu-meta_keywords":"","robots":""}', + 'language' => $itemLanguage->language, + ); + + // Bind the data. + if (!$tableItem->bind($menuItem)) + { + return false; + } + + $tableItem->setLocation($menuItem['parent_id'], 'last-child'); + + // Check the data. + if (!$tableItem->check()) + { + return false; + } + + // Store the data. + if (!$tableItem->store()) + { + return false; + } + + // Rebuild the tree path. + if (!$tableItem->rebuildPath($tableItem->id)) + { + return false; + } + + return $tableItem; + } + /** * Create the language associations. * diff --git a/libraries/src/Table/Nested.php b/libraries/src/Table/Nested.php index 48f29a10c7995..672592e05bd82 100644 --- a/libraries/src/Table/Nested.php +++ b/libraries/src/Table/Nested.php @@ -1554,21 +1554,29 @@ protected function recursiveUpdatePublishedColumn($pk, $newState = null) * -2 <= 2 THEN -2 (If archived in trashed then trashed) */ + // Find node and all children keys + $query->select("c.$key") + ->from("$table AS node") + ->leftJoin("$table AS c ON node.lft <= c.lft AND c.rgt <= node.rgt") + ->where("node.$key = " . (int) $pk); + + $pks = $this->_db->setQuery($query)->loadColumn(); + // Prepare a list of correct published states. $subquery = (string) $query->clear() ->select("c2.$key AS newId") ->select("CASE WHEN MIN($newState) > 0 THEN MAX($newState) ELSE MIN($newState) END AS newPublished") - ->from("$table AS node") - ->innerJoin("$table AS c2 ON node.lft <= c2.lft AND c2.rgt <= node.rgt") + ->from("$table AS c2") ->innerJoin("$table AS p2 ON p2.lft <= c2.lft AND c2.rgt <= p2.rgt") - ->where("node.$key = " . (int) $pk) + ->where("c2.$key IN (" . implode(',', $pks) . ")") ->group("c2.$key"); // Update and cascade the publishing state. $query->clear() ->update("$table AS c") ->innerJoin("($subquery) AS c2 ON c2.newId = c.$key") - ->set("$published = c2.newPublished"); + ->set("$published = c2.newPublished") + ->where("c.$key IN (" . implode(',', $pks) . ")"); $this->_runQuery($query, 'JLIB_DATABASE_ERROR_STORE_FAILED'); diff --git a/plugins/sampledata/blog/blog.php b/plugins/sampledata/blog/blog.php index b294605c1d2f6..2036e925e00ed 100644 --- a/plugins/sampledata/blog/blog.php +++ b/plugins/sampledata/blog/blog.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +use Joomla\CMS\Language\Multilanguage; + /** * Sampledata - Blog Plugin * @@ -61,7 +63,7 @@ class PlgSampledataBlog extends JPlugin */ public function onSampledataGetOverview() { - $data = new stdClass; + $data = new stdClass; $data->name = $this->_name; $data->title = JText::_('PLG_SAMPLEDATA_BLOG_OVERVIEW_TITLE'); $data->description = JText::_('PLG_SAMPLEDATA_BLOG_OVERVIEW_DESC'); @@ -72,7 +74,7 @@ public function onSampledataGetOverview() } /** - * First step to enter the sampledata. + * First step to enter the sampledata. Content. * * @return array or void Will be converted into the JSON response to the module. * @@ -98,6 +100,10 @@ public function onAjaxSampledataApplyStep1() $access = (int) $this->app->get('access', 1); $user = JFactory::getUser(); + // Detect language to be used. + $language = Multilanguage::isEnabled() ? JFactory::getLanguage()->getTag() : '*'; + $langSuffix = ($language !== '*') ? ' (' . $language . ')' : ''; + // Add Include Paths. JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_content/models/', 'ContentModel'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_content/tables/'); @@ -107,7 +113,7 @@ public function onAjaxSampledataApplyStep1() // Create "blog" category. $categoryModel = JModelLegacy::getInstance('Category', 'CategoriesModel'); $catIds = array(); - $categoryTitle = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_CATEGORY_0_TITLE'); + $categoryTitle = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_CATEGORY_0_TITLE') . $langSuffix; $category = array( 'title' => $categoryTitle, 'parent_id' => 1, @@ -120,7 +126,7 @@ public function onAjaxSampledataApplyStep1() 'alias' => JApplicationHelper::stringURLSafe($categoryTitle), 'associations' => array(), 'description' => '', - 'language' => '*', + 'language' => $language, 'params' => '', ); @@ -144,7 +150,7 @@ public function onAjaxSampledataApplyStep1() $catIds[] = $categoryModel->getItem()->id; // Create "help" category. - $categoryTitle = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_CATEGORY_1_TITLE'); + $categoryTitle = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_CATEGORY_1_TITLE') . $langSuffix; $category = array( 'title' => $categoryTitle, 'parent_id' => 1, @@ -157,7 +163,7 @@ public function onAjaxSampledataApplyStep1() 'alias' => JApplicationHelper::stringURLSafe($categoryTitle), 'associations' => array(), 'description' => '', - 'language' => '*', + 'language' => $language, 'params' => '', ); @@ -181,8 +187,8 @@ public function onAjaxSampledataApplyStep1() $catIds[] = $categoryModel->getItem()->id; // Create Articles. - $articleModel = JModelLegacy::getInstance('Article', 'ContentModel'); - $articles = array( + $articleModel = JModelLegacy::getInstance('Article', 'ContentModel'); + $articles = array( array( 'catid' => $catIds[1], 'ordering' => 2, @@ -213,7 +219,7 @@ public function onAjaxSampledataApplyStep1() foreach ($articles as $i => $article) { // Set values from language strings. - $article['title'] = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_' . $i . '_TITLE'); + $article['title'] = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_' . $i . '_TITLE') . $langSuffix; $article['introtext'] = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_' . $i . '_INTROTEXT'); $article['fulltext'] = JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_' . $i . '_FULLTEXT'); @@ -221,7 +227,7 @@ public function onAjaxSampledataApplyStep1() $article['id'] = 0; $article['created_user_id'] = $user->id; $article['alias'] = JApplicationHelper::stringURLSafe($article['title']); - $article['language'] = '*'; + $article['language'] = $language; $article['associations'] = array(); $article['state'] = 1; $article['featured'] = 0; @@ -252,7 +258,7 @@ public function onAjaxSampledataApplyStep1() $this->app->setUserState('sampledata.blog.articles', $ids); $this->app->setUserState('sampledata.blog.articles.catids', $catIds); - $response = new stdClass; + $response = new stdClass; $response->success = true; $response->message = JText::_('PLG_SAMPLEDATA_BLOG_STEP1_SUCCESS'); @@ -275,13 +281,17 @@ public function onAjaxSampledataApplyStep2() if (!JComponentHelper::isEnabled('com_menus')) { - $response = array(); + $response = array(); $response['success'] = true; $response['message'] = JText::sprintf('PLG_SAMPLEDATA_BLOG_STEP_SKIPPED', 2, 'com_menus'); return $response; } + // Detect language to be used. + $language = Multilanguage::isEnabled() ? JFactory::getLanguage()->getTag() : '*'; + $langSuffix = ($language !== '*') ? ' (' . $language . ')' : ''; + // Create the menu types. $menuTable = JTable::getInstance('Type', 'JTableMenu'); $menuTypes = array(); @@ -290,7 +300,7 @@ public function onAjaxSampledataApplyStep2() { $menu = array( 'id' => 0, - 'title' => JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_MENU_' . $i . '_TITLE'), + 'title' => JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_MENU_' . $i . '_TITLE') . $langSuffix, 'description' => JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_MENU_' . $i . '_DESCRIPTION'), ); @@ -329,25 +339,16 @@ public function onAjaxSampledataApplyStep2() JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables/'); $this->menuItemModel = JModelLegacy::getInstance('Item', 'MenusModel'); - // Unset current "Home" menuitem since we set a new one. - $menuItemTable = JTable::getInstance('Menu', 'MenusTable'); - $menuItemTable->load( - array( - 'home' => 1, - 'language' => '*', - ) - ); - $menuItemTable->home = 0; - $menuItemTable->store(); + // Get previously entered categories ids + $catids = $this->app->getUserState('sampledata.blog.articles.catids'); // Insert menuitems level 1. $menuItems = array( array( 'menutype' => $menuTypes[0], 'title' => JText::_('PLG_SAMPLEDATA_BLOG_SAMPLEDATA_MENUS_ITEM_0_TITLE'), - 'link' => 'index.php?option=com_content&view=category&layout=blog&id=9', + 'link' => 'index.php?option=com_content&view=category&layout=blog&id=' . $catids[0], 'component_id' => 22, - 'home' => 1, 'params' => array( 'layout_type' => 'blog', 'show_category_title' => 0, @@ -581,6 +582,10 @@ public function onAjaxSampledataApplyStep3() return $response; } + // Detect language to be used. + $language = Multilanguage::isEnabled() ? JFactory::getLanguage()->getTag() : '*'; + $langSuffix = ($language !== '*') ? ' (' . $language . ')' : ''; + // Add Include Paths. JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_modules/models/', 'ModulesModelModule'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_modules/tables/'); @@ -846,33 +851,36 @@ public function onAjaxSampledataApplyStep3() 'module' => 'mod_feed', 'client_id' => 1, 'params' => array( - 'rssurl' => 'https://www.joomla.org/announcements/release-news.feed', - 'rssrtl' => 0, - 'rsstitle' => 1, - 'rssdesc' => 1, - 'rssimage' => 1, - 'rssitems' => 3, - 'rssitemdesc' => 1, - 'word_count' => 0, - 'layout' => '_:default', - 'cache' => 1, - 'cache_time' => 900, - 'module_tag' => 'div', - 'bootstrap_size' => 0, - 'header_tag' => 'h3', - 'style' => 0, + 'rssurl' => 'https://www.joomla.org/announcements/release-news.feed', + 'rssrtl' => 0, + 'rsstitle' => 1, + 'rssdesc' => 1, + 'rssimage' => 1, + 'rssitems' => 3, + 'rssitemdesc' => 1, + 'word_count' => 0, + 'layout' => '_:default', + 'cache' => 1, + 'cache_time' => 900, + 'module_tag' => 'div', + 'bootstrap_size' => 0, + 'header_tag' => 'h3', + 'style' => 0, ), ), ); foreach ($modules as $module) { + // Append language suffix to title. + $module['title'] .= $langSuffix; + // Set values which are always the same. - $module['id'] = 0; - $module['asset_id'] = 0; - $module['language'] = '*'; - $module['note'] = ''; - $module['published'] = 1; + $module['id'] = 0; + $module['asset_id'] = 0; + $module['language'] = $language; + $module['note'] = ''; + $module['published'] = 1; $module['assignment'] = 0; if (!isset($module['content'])) @@ -931,22 +939,30 @@ private function addMenuItems(array $menuItems, $level) $access = (int) $this->app->get('access', 1); $user = JFactory::getUser(); + // Detect language to be used. + $language = Multilanguage::isEnabled() ? JFactory::getLanguage()->getTag() : '*'; + $langSuffix = ($language !== '*') ? ' (' . $language . ')' : ''; + foreach ($menuItems as $menuItem) { // Reset item.id in model state. $this->menuItemModel->setState('item.id', 0); + // Append language suffix to title. + $menuItem['title'] .= $langSuffix; + // Set values which are always the same. $menuItem['id'] = 0; $menuItem['created_user_id'] = $user->id; $menuItem['alias'] = JApplicationHelper::stringURLSafe($menuItem['title']); $menuItem['published'] = 1; - $menuItem['language'] = '*'; + $menuItem['language'] = $language; $menuItem['note'] = ''; $menuItem['img'] = ''; $menuItem['associations'] = array(); $menuItem['client_id'] = 0; $menuItem['level'] = $level; + $menuItem['home'] = 0; // Set browserNav to default if not set if (!isset($menuItem['browserNav'])) @@ -972,12 +988,6 @@ private function addMenuItems(array $menuItems, $level) $menuItem['template_style_id'] = 0; } - // Set home if not set - if (!isset($menuItem['home'])) - { - $menuItem['home'] = 0; - } - // Set parent_id to root (1) if not set if (!isset($menuItem['parent_id'])) {