Index: typo3/sysext/cms/tslib/class.tslib_menu.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_menu.php (revision 8552) +++ typo3/sysext/cms/tslib/class.tslib_menu.php (working copy) @@ -195,6 +195,7 @@ var $WMextraScript; var $alternativeMenuTempArray=''; // Can be set to contain menu item arrays for sub-levels. var $nameAttribute = 'name'; // Will be 'id' in XHTML-mode + protected static $alternativeSortingField; /** * The initialization of the object. This just sets some internal variables. @@ -364,6 +365,29 @@ } /** + * Used by makeMenu() as compare function for supporting a correctly + * ordered menu taking into account locales. + * + * Uses strcoll() which takes locales into account, strcmp() doesn't. + * + * @param array Current record, that gets compared with the next record + * @param array Next record + * @return boolean + */ + public static function sortByField($currentRecord, $nextRecord) { + // default, if current record equals equals next record + $result = 0; + + if(strcoll($currentRecord[self::$alternativeSortingField], $nextRecord[self::$alternativeSortingField]) < 0) { + $result = -1; + } elseif(strcoll($currentRecord[self::$alternativeSortingField], $nextRecord[self::$alternativeSortingField]) > 0) { + $result = 1; + } + + return $result; + } + + /** * Creates the menu in the internal variables, ready for output. * Basically this will read the page records needed and fill in the internal $this->menuArr * Based on a hash of this array and some other variables the $this->result variable will be loaded either from cache OR by calling the generate() method of the class to create the menu for real. @@ -484,6 +508,18 @@ } } } + // if alternativeSortingField is set and current language is not default language + if($altSortField != 'sorting' && $GLOBALS['TSFE']->sys_language_uid != 0) { + $altSortFieldArray = explode(' ', $altSortField); + // share the alternative sorting field with the compare function + self::$alternativeSortingField = $altSortFieldArray[0]; + // call the custom sort function sortByKey(); + usort($temp, array('tslib_menu', 'sortByField')); + + if(isset($altSortFieldArray[1]) && ($altSortFieldArray[1] == 'desc' || $altSortFieldArray[1] == 'DESC')) { + $temp = array_reverse($temp); + } + } } break; case 'list':