diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index bdfd7d64f0008..f6ec404025873 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -1659,6 +1659,7 @@ public function deleteUnexistingFiles() '/libraries/cms/helper/route.php', '/libraries/cms/helper/tags.php', '/libraries/cms/helper/usergroups.php', + '/libraries/cms/html/html.php', '/libraries/cms/installer/adapter.php', '/libraries/cms/installer/extension.php', '/libraries/cms/installer/helper.php', 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/components/com_finder/helpers/indexer/indexer.php b/administrator/components/com_finder/helpers/indexer/indexer.php index ac7dfa794797d..ca7e2db5ba8f7 100644 --- a/administrator/components/com_finder/helpers/indexer/indexer.php +++ b/administrator/components/com_finder/helpers/indexer/indexer.php @@ -424,7 +424,7 @@ protected function tokenizeToDb($input, $context, $lang, $format) $string = substr($buffer, 0, $ls); // Adjust the buffer based on the last space for the next iteration and trim. - $buffer = JString::trim(substr($buffer, $ls)); + $buffer = StringHelper::trim(substr($buffer, $ls)); } // No space character was found. else 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/manifests/files/joomla.xml b/administrator/manifests/files/joomla.xml index 74787539f53b9..972c02ae734a4 100644 --- a/administrator/manifests/files/joomla.xml +++ b/administrator/manifests/files/joomla.xml @@ -6,7 +6,7 @@ www.joomla.org (C) 2005 - 2017 Open Source Matters. All rights reserved GNU General Public License version 2 or later; see LICENSE.txt - 3.8.0-beta4-dev + 3.8.0-beta5-dev August 2017 FILES_JOOMLA_XML_DESCRIPTION diff --git a/administrator/modules/mod_menu/menu.php b/administrator/modules/mod_menu/menu.php index 9a207249baf35..07b2222649dc4 100644 --- a/administrator/modules/mod_menu/menu.php +++ b/administrator/modules/mod_menu/menu.php @@ -36,7 +36,7 @@ class JAdminCssMenu * * @var Registry * - * @since __DEPLOY_VERSION__ + * @since 3.8.0 */ protected $params; @@ -45,7 +45,7 @@ class JAdminCssMenu * * @var bool * - * @since __DEPLOY_VERSION__ + * @since 3.8.0 */ protected $enabled; 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..c4ec1ebede03d 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 3.8.0 + */ + + 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 3.8.0 + */ + 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/classmap.php b/libraries/classmap.php index 6446aa53940ce..5a17a1e987bcc 100644 --- a/libraries/classmap.php +++ b/libraries/classmap.php @@ -419,3 +419,5 @@ JLoader::registerAlias('JObject', '\\Joomla\\CMS\\Object\\CMSObject', '5.0'); JLoader::registerAlias('JExtensionHelper', '\\Joomla\\CMS\\Extension\\ExtensionHelper', '5.0'); + +JLoader::registerAlias('JHtml', '\\Joomla\\CMS\\HTML\\HTMLHelper', '5.0'); diff --git a/libraries/joomla/observer/updater.php b/libraries/joomla/observer/updater.php index 0cc93b8bde6d3..55eeee7150282 100644 --- a/libraries/joomla/observer/updater.php +++ b/libraries/joomla/observer/updater.php @@ -56,7 +56,29 @@ public function __construct(JObservableInterface $observable) */ public function attachObserver(JObserverInterface $observer) { - $this->observers[get_class($observer)] = $observer; + $class = get_class($observer); + $this->observers[$class] = $observer; + + // Also register the alias + foreach (JLoader::getDeprecatedAliases() as $alias) + { + $realClass = trim($alias['new'], '\\'); + $aliasClass = trim($alias['old'], '\\'); + + // Check if we have an alias for the observer class + if ($realClass == $class) + { + // Register the alias + $this->observers[$aliasClass] = $observer; + } + + // Check if the observer class is an alias + if ($aliasClass == $class) + { + // Register the real class + $this->observers[$realClass] = $observer; + } + } } /** @@ -71,6 +93,8 @@ public function attachObserver(JObserverInterface $observer) */ public function detachObserver($observer) { + $observer = trim($observer, '\\'); + if (isset($this->observers[$observer])) { unset($this->observers[$observer]); @@ -88,12 +112,14 @@ public function detachObserver($observer) */ public function getObserverOfClass($observerClass) { + $observerClass = trim($observerClass, '\\'); + if (isset($this->observers[$observerClass])) { return $this->observers[$observerClass]; } - return; + return null; } /** diff --git a/libraries/src/Form/Field/MenuitemField.php b/libraries/src/Form/Field/MenuitemField.php index fd558234774b9..6648e08c13955 100644 --- a/libraries/src/Form/Field/MenuitemField.php +++ b/libraries/src/Form/Field/MenuitemField.php @@ -235,7 +235,7 @@ protected function getGroups() // Build the options array. foreach ($menu->links as $link) { - $levelPrefix = str_repeat('- ', $link->level - 1); + $levelPrefix = str_repeat('- ', max(0, $link->level - 1)); // Displays language code if not set to All if ($link->language !== '*') diff --git a/libraries/cms/html/html.php b/libraries/src/HTML/HTMLHelper.php similarity index 88% rename from libraries/cms/html/html.php rename to libraries/src/HTML/HTMLHelper.php index f60c655711d6c..1caf8f1874889 100644 --- a/libraries/cms/html/html.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -1,26 +1,32 @@ getBrowser(); $major = $navigator->getMajor(); $minor = $navigator->getMinor(); @@ -356,7 +362,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if ($relative) { // Get the template - $template = JFactory::getApplication()->getTemplate(); + $template = Factory::getApplication()->getTemplate(); // For each potential files foreach ($potential as $strip) @@ -364,7 +370,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec $files = array(); // Detect debug mode - if ($detect_debug && JFactory::getConfig()->get('debug')) + if ($detect_debug && Factory::getConfig()->get('debug')) { /* * Detect if we received a file in the format name.min.ext @@ -394,7 +400,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::base(true) . "/templates/$template/$folder/$file" . static::getMd5Version($path); + $includes[] = Uri::base(true) . "/templates/$template/$folder/$file" . static::getMd5Version($path); break; } @@ -417,7 +423,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/media/$extension/$element/$folder/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/media/$extension/$element/$folder/$file" . static::getMd5Version($path); break; } @@ -427,7 +433,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/media/$extension/$folder/$element/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/media/$extension/$folder/$element/$file" . static::getMd5Version($path); break; } @@ -437,7 +443,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/templates/$template/$folder/system/$element/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/templates/$template/$folder/system/$element/$file" . static::getMd5Version($path); break; } @@ -447,7 +453,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/media/system/$folder/$element/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/media/system/$folder/$element/$file" . static::getMd5Version($path); break; } @@ -459,7 +465,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/media/$extension/$folder/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/media/$extension/$folder/$file" . static::getMd5Version($path); break; } @@ -469,7 +475,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/templates/$template/$folder/system/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/templates/$template/$folder/system/$file" . static::getMd5Version($path); break; } @@ -479,7 +485,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/media/system/$folder/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/media/system/$folder/$file" . static::getMd5Version($path); break; } @@ -492,7 +498,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/media/system/$folder/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/media/system/$folder/$file" . static::getMd5Version($path); break; } @@ -509,7 +515,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec $files = array(); // Detect debug mode - if ($detect_debug && JFactory::getConfig()->get('debug')) + if ($detect_debug && Factory::getConfig()->get('debug')) { /* * Detect if we received a file in the format name.min.ext @@ -538,7 +544,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $includes[] = JUri::root(true) . "/$file" . static::getMd5Version($path); + $includes[] = Uri::root(true) . "/$file" . static::getMd5Version($path); break; } @@ -593,7 +599,7 @@ public static function image($file, $alt, $attribs = null, $relative = false, $r * * @return array|string|null nothing if $returnPath is false, null, path or array of path if specific CSS browser files were detected * - * @see JBrowser + * @see Browser * @since 1.5 * @deprecated 4.0 The (file, attribs, relative, pathOnly, detectBrowser, detectDebug) method signature is deprecated, * use (file, options, attributes) instead. @@ -603,7 +609,7 @@ public static function stylesheet($file, $options = array(), $attribs = array()) // B/C before 3.7.0 if (!is_array($attribs)) { - JLog::add('The stylesheet method signature used has changed, use (file, options, attributes) instead.', JLog::WARNING, 'deprecated'); + Log::add('The stylesheet method signature used has changed, use (file, options, attributes) instead.', Log::WARNING, 'deprecated'); $argList = func_get_args(); $options = array(); @@ -642,7 +648,7 @@ public static function stylesheet($file, $options = array(), $attribs = array()) } // If inclusion is required - $document = JFactory::getDocument(); + $document = Factory::getDocument(); foreach ($includes as $include) { @@ -665,7 +671,7 @@ public static function stylesheet($file, $options = array(), $attribs = array()) * * @return array|string|null Nothing if $returnPath is false, null, path or array of path if specific JavaScript browser files were detected * - * @see JHtml::stylesheet() + * @see HTMLHelper::stylesheet() * @since 1.5 * @deprecated 4.0 The (file, framework, relative, pathOnly, detectBrowser, detectDebug) method signature is deprecated, * use (file, options, attributes) instead. @@ -675,7 +681,7 @@ public static function script($file, $options = array(), $attribs = array()) // B/C before 3.7.0 if (!is_array($options)) { - JLog::add('The script method signature used has changed, use (file, options, attributes) instead.', JLog::WARNING, 'deprecated'); + Log::add('The script method signature used has changed, use (file, options, attributes) instead.', Log::WARNING, 'deprecated'); $argList = func_get_args(); $options = array(); @@ -722,7 +728,7 @@ public static function script($file, $options = array(), $attribs = array()) } // If inclusion is required - $document = JFactory::getDocument(); + $document = Factory::getDocument(); foreach ($includes as $include) { @@ -745,7 +751,7 @@ public static function script($file, $options = array(), $attribs = array()) * * @return void * - * @see JHtml::$formatOptions + * @see HTMLHelper::$formatOptions * @since 1.5 */ public static function setFormatOptions($options) @@ -776,14 +782,14 @@ public static function setFormatOptions($options) public static function date($input = 'now', $format = null, $tz = true, $gregorian = false) { // Get some system objects. - $config = JFactory::getConfig(); - $user = JFactory::getUser(); + $config = Factory::getConfig(); + $user = Factory::getUser(); // UTC date converted to user time zone. if ($tz === true) { // Get a date object based on UTC. - $date = JFactory::getDate($input, 'UTC'); + $date = Factory::getDate($input, 'UTC'); // Set the correct time zone based on the user configuration. $date->setTimezone($user->getTimezone()); @@ -792,35 +798,35 @@ public static function date($input = 'now', $format = null, $tz = true, $gregori elseif ($tz === false) { // Get a date object based on UTC. - $date = JFactory::getDate($input, 'UTC'); + $date = Factory::getDate($input, 'UTC'); // Set the correct time zone based on the server configuration. - $date->setTimezone(new DateTimeZone($config->get('offset'))); + $date->setTimezone(new \DateTimeZone($config->get('offset'))); } // No date conversion. elseif ($tz === null) { - $date = JFactory::getDate($input); + $date = Factory::getDate($input); } // UTC date converted to given time zone. else { // Get a date object based on UTC. - $date = JFactory::getDate($input, 'UTC'); + $date = Factory::getDate($input, 'UTC'); // Set the correct time zone based on the server configuration. - $date->setTimezone(new DateTimeZone($tz)); + $date->setTimezone(new \DateTimeZone($tz)); } // If no format is given use the default locale based format. if (!$format) { - $format = JText::_('DATE_FORMAT_LC1'); + $format = \JText::_('DATE_FORMAT_LC1'); } // $format is an existing language key - elseif (JFactory::getLanguage()->hasKey($format)) + elseif (Factory::getLanguage()->hasKey($format)) { - $format = JText::_($format); + $format = \JText::_($format); } if ($gregorian) @@ -932,8 +938,8 @@ public static function tooltipText($title = '', $content = '', $translate = true // Pass texts through JText if required. if ($translate) { - $title = JText::_($title); - $content = JText::_($content); + $title = \JText::_($title); + $content = \JText::_($content); } // Use only the content if no title is given. @@ -988,9 +994,9 @@ public static function tooltipText($title = '', $content = '', $translate = true */ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = array()) { - $tag = JFactory::getLanguage()->getTag(); - $calendar = JFactory::getLanguage()->getCalendar(); - $direction = strtolower(JFactory::getDocument()->getDirection()); + $tag = Factory::getLanguage()->getTag(); + $calendar = Factory::getLanguage()->getCalendar(); + $direction = strtolower(Factory::getDocument()->getDirection()); // Get the appropriate file for the current language date helper $helperPath = 'system/fields/calendar-locales/date/gregorian/date-helper.min.js'; @@ -1035,7 +1041,7 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri $singleHeader = ($singleHeader) ? "1" : "0"; // Format value when not nulldate ('0000-00-00 00:00:00'), otherwise blank it as it would result in 1970-01-01. - if ($value && $value !== JFactory::getDbo()->getNullDate() && strtotime($value) !== false) + if ($value && $value !== Factory::getDbo()->getNullDate() && strtotime($value) !== false) { $tz = date_default_timezone_get(); date_default_timezone_set('UTC'); @@ -1073,11 +1079,11 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri 'onchange' => $onchange, ); - return JLayoutHelper::render('joomla.form.field.calendar', $data, null, null); + return LayoutHelper::render('joomla.form.field.calendar', $data, null, null); } /** - * Add a directory where JHtml should search for helpers. You may + * Add a directory where HTMLHelper should search for helpers. You may * either pass a string or an array of directories. * * @param string $path A path to search. @@ -1093,7 +1099,7 @@ public static function addIncludePath($path = '') { if (!empty($dir) && !in_array($dir, static::$includePaths)) { - array_unshift(static::$includePaths, JPath::clean($dir)); + array_unshift(static::$includePaths, \JPath::clean($dir)); } } @@ -1112,9 +1118,9 @@ public static function addIncludePath($path = '') */ public static function getJSObject(array $array = array()) { - JLog::add( + Log::add( __METHOD__ . " is deprecated. Use json_encode() or \\Joomla\\Registry\\Registry::toString('json') instead.", - JLog::WARNING, + Log::WARNING, 'deprecated' ); 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/libraries/src/Version.php b/libraries/src/Version.php index 68b8690e45b3e..559af1bc50d6c 100644 --- a/libraries/src/Version.php +++ b/libraries/src/Version.php @@ -60,7 +60,7 @@ final class Version * @var string * @since 3.8.0 */ - const EXTRA_VERSION = 'beta4-dev'; + const EXTRA_VERSION = 'beta5-dev'; /** * Release version. @@ -78,7 +78,7 @@ final class Version * @since 3.5 * @deprecated 4.0 Use separated version constants instead */ - const DEV_LEVEL = '0-beta4-dev'; + const DEV_LEVEL = '0-beta5-dev'; /** * Development status. @@ -111,7 +111,7 @@ final class Version * @var string * @since 3.5 */ - const RELDATE = '22-August-2017'; + const RELDATE = '29-August-2017'; /** * Release time. 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'])) {