Page MenuHomeIn-Portal Phabricator

D335.id.diff
No OneTemporary

File Metadata

Created
Thu, May 8, 4:10 AM

D335.id.diff

Index: branches/5.2.x/core/units/helpers/navigation_bar.php
===================================================================
--- branches/5.2.x/core/units/helpers/navigation_bar.php
+++ branches/5.2.x/core/units/helpers/navigation_bar.php
@@ -271,44 +271,47 @@
/**
* Returns given category's parent path as array of id=>name elements
*
- * @return Array
- * @access protected
+ * @return array
*/
protected function getCategoryParentPath()
{
$main_category_id = $this->_getCurrentCategoryId();
+ // Don't query path for "Home" category.
if ( $main_category_id == 0 ) {
- // don't query path for "Home" category
- return Array ();
+ return array();
}
- $category_title = isset($this->_params['category_title']) ? $this->_params['category_title'] : 'Name';
- $cache_key = 'parent_paths_named[%CIDSerial:' . $main_category_id . '%]:' . $category_title;
+ $return_field = isset($this->_params['category_title']) ? $this->_params['category_title'] : 'Name';
+ $cache_key = 'parent_paths_named[%CIDSerial:' . $main_category_id . '%][%LangSerial%]:' . $return_field;
$cached_path = $this->Application->getCache($cache_key);
if ( $cached_path === false ) {
$parent_path = explode('|', substr($this->getParentPath($main_category_id), 1, -1));
- /** @var kMultiLanguage $ml_formatter */
- $ml_formatter = $this->Application->recallObject('kMultiLanguage');
+ /** @var kMultiLanguageHelper $ml_helper */
+ $ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
- $navbar_field = $ml_formatter->LangFieldName($category_title);
+ $select_fields = array();
+
+ foreach ( $ml_helper->getLanguages() as $language_id ) {
+ $select_fields[] = 'l' . $language_id . '_' . $return_field;
+ }
$id_field = $this->Application->getUnitOption('c', 'IDField');
$table_name = $this->Application->getUnitOption('c', 'TableName');
$this->Conn->nextQueryCachable = true;
- $sql = 'SELECT ' . $navbar_field . ', ' . $id_field . '
+ $sql = 'SELECT ' . implode(',', $select_fields) . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE ' . $id_field . ' IN (' . implode(',', $parent_path) . ')';
- $category_names = $this->Conn->GetCol($sql, $id_field);
+ $category_names = $this->Conn->Query($sql, $id_field);
- $cached_path = Array ();
+ $cached_path = array();
$skip_category = $this->Application->getBaseCategory();
if ( $category_names ) {
- foreach ($parent_path as $category_id) {
+ foreach ( $parent_path as $category_id ) {
if ( $category_id == $skip_category ) {
continue;
}
@@ -320,7 +323,20 @@
$this->Application->setCache($cache_key, $cached_path);
}
- return $cached_path;
+ $ret = array();
+ $current_language_id = $this->Application->GetVar('m_lang');
+ $primary_language_id = $this->Application->GetDefaultLanguageId();
+
+ foreach ( $cached_path as $category_id => $category_data ) {
+ if ( empty($category_data['l' . $current_language_id . '_' . $return_field]) ) {
+ $ret[$category_id] = $category_data['l' . $primary_language_id . '_' . $return_field];
+ }
+ else {
+ $ret[$category_id] = $category_data['l' . $current_language_id . '_' . $return_field];
+ }
+ }
+
+ return $ret;
}
/**

Event Timeline