Project

General

Profile

Bug #22478 » class.tslib_menu.php.patch

Administrator Admin, 2010-05-04 17:39

View differences:

typo3/sysext/cms/tslib/class.tslib_menu.php (working copy)
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.
......
}
/**
* 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.
......
}
}
}
// 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':
(3-3/3)