Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/staging' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
LivioCavallo committed Aug 28, 2017
2 parents 043f017 + aafbe7d commit d8b5721
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 78 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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 . ')';
}
}

Expand Down
4 changes: 2 additions & 2 deletions administrator/language/en-GB/en-GB.plg_sampledata_blog.ini
Expand Up @@ -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.<br>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="<p>This tells you a bit about this blog and the person who writes it. </p><p>When you are logged in you will be able to edit this page by clicking on the edit icon.</p>"
Expand All @@ -26,7 +26,7 @@ PLG_SAMPLEDATA_BLOG_SAMPLEDATA_CONTENT_ARTICLE_5_INTROTEXT="<p>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"
Expand Down
2 changes: 1 addition & 1 deletion administrator/modules/mod_sampledata/tmpl/default.php
Expand Up @@ -37,7 +37,7 @@
</div>
<div class="span6">
<small>
<?php echo htmlspecialchars($item->description); ?>
<?php echo $item->description; ?>
</small>
</div>
</div>
Expand Down
Expand Up @@ -33,7 +33,7 @@
<?php endif; ?>

<?php // Display the 'no results' message and exit the template. ?>
<?php if ($this->total === 0) : ?>
<?php if (($this->total === 0) || ($this->total === null)) : ?>
<div id="search-result-empty">
<h2><?php echo JText::_('COM_FINDER_SEARCH_NO_RESULTS_HEADING'); ?></h2>
<?php $multilang = JFactory::getApplication()->getLanguageFilter() ? '_MULTILANG' : ''; ?>
Expand Down
23 changes: 22 additions & 1 deletion installation/controller/setdefaultlanguage.php
Expand Up @@ -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');

Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions installation/language/en-GB/en-GB.ini
Expand Up @@ -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 &quot;%s&quot; folder has already been deleted."
INSTL_COMPLETE_ERROR_FOLDER_DELETE="&quot;%s&quot; folder could not be deleted. Please manually delete the folder."
INSTL_COMPLETE_FOLDER_REMOVED="&quot;%s&quot; 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 &quot;%s&quot; 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. <br />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."
Expand Down
162 changes: 160 additions & 2 deletions installation/model/languages.php
Expand Up @@ -872,15 +872,15 @@ public function addMenuGroup($itemLanguage)
}

/**
* Add Menu Item.
* Add Featured Menu Item.
*
* @param stdClass $itemLanguage Language Object.
*
* @return JTable|boolean Menu Item Object. False otherwise.
*
* @since 3.2
*/
public function addMenuItem($itemLanguage)
public function addFeaturedMenuItem($itemLanguage)
{
// Add Menu Item.
$tableItem = JTable::getInstance('Menu', 'MenusTable');
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
16 changes: 12 additions & 4 deletions libraries/src/Table/Nested.php
Expand Up @@ -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');

Expand Down

0 comments on commit d8b5721

Please sign in to comment.