Index: menu_helper.php
===================================================================
--- menu_helper.php	(revision 13756)
+++ menu_helper.php	(working copy)
@@ -286,24 +286,9 @@
 				}
 			}
 
-			$items = Array ();
-
 			// Sub-categories from current category
-			$sql = 'SELECT
-						c.CategoryId AS CategoryId,
-						CONCAT(\'c\', c.CategoryId) AS ItemId,
-						c.Priority AS ItemPriority,
-						' . $lang_part . '
+			$items = $this->getSubCategories( $parent['CategoryId'] );
 
-						IF(c.IsSystem, c.Template, CONCAT("id:", c.CategoryId)) AS ItemPath,
-						c.ParentPath AS ParentPath,
-						c.ParentId As ParentId,
-						\'cat\' AS ItemType,
-						c.IsMenu, c.IsSystem, c.ThemeId, c.UseExternalUrl, c.ExternalUrl, c.UseMenuIconUrl, c.MenuIconUrl
-					FROM ' . TABLE_PREFIX . 'Category AS c
-					WHERE (c.Status = ' . STATUS_ACTIVE . ') AND (c.ParentId = ' . $parent['CategoryId'] . ')';
-			$items = array_merge($items, $this->Conn->Query($sql, 'ItemId'));
-
 			// sort menu items
 			uasort($items, Array (&$this, '_menuSort'));
 
@@ -333,6 +318,51 @@
 			return $items;
 		}
 
+		function getSubCategories($parent_id)
+		{
+			static $items_by_parent = null;
+
+			if (!isset($items_by_parent)) {
+				$ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+				/* @var $ml_helper kMultiLanguageHelper */
+
+				$lang_part = '';
+				$items_by_parent = Array ();
+
+				for ($i = 1; $i <= $ml_helper->languageCount; $i++) {
+					$lang_part .= 'c.l' . $i . '_MenuTitle AS l' . $i . '_ItemName,' . "\n";
+				}
+
+				// Sub-categories from current category
+				$sql = 'SELECT
+							c.CategoryId AS CategoryId,
+							CONCAT(\'c\', c.CategoryId) AS ItemId,
+							c.Priority AS ItemPriority,
+							' . $lang_part . '
+
+							IF(c.IsSystem, c.Template, CONCAT("id:", c.CategoryId)) AS ItemPath,
+							c.ParentPath AS ParentPath,
+							c.ParentId As ParentId,
+							\'cat\' AS ItemType,
+							c.IsMenu, c.IsSystem, c.ThemeId, c.UseExternalUrl, c.ExternalUrl, c.UseMenuIconUrl, c.MenuIconUrl
+						FROM ' . TABLE_PREFIX . 'Category AS c
+						WHERE c.Status = ' . STATUS_ACTIVE;
+				$items = $this->Conn->Query($sql, 'ItemId');
+
+				foreach ($items as $item_id => $item_data) {
+					$item_parent_id = $item_data['ParentId'];
+
+					if ( !array_key_exists($item_parent_id, $items_by_parent) ) {
+						$items_by_parent[$item_parent_id] = Array ();
+					}
+
+					$items_by_parent[$item_parent_id][$item_id] = $item_data;
+				}
+			}
+
+			return array_key_exists($parent_id, $items_by_parent) ? $items_by_parent[$parent_id] : Array ();
+		}
+
 		/**
 		 * Method for sorting pages by priority in decending order
 		 *
