Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F871861
D335.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, May 8, 4:10 AM
Size
3 KB
Mime Type
text/x-diff
Expires
Fri, May 9, 4:10 AM (11 h, 26 m)
Engine
blob
Format
Raw Data
Handle
617715
Attached To
D335: INP-1736 - Make "\kNavigationBar::getCategoryParentPath" method language-aware
D335.id.diff
View Options
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
Log In to Comment