Bug #19483 » class.tslib_menu.php.patch

Administrator Admin, 2010-08-10 14:36

View differences:

typo3/sysext/cms/tslib/class.tslib_menu.php (working copy)
195 195
	var $WMextraScript;
196 196
	var $alternativeMenuTempArray='';		// Can be set to contain menu item arrays for sub-levels.
197 197
	var $nameAttribute = 'name';			// Will be 'id' in XHTML-mode
198
	protected static $alternativeSortingField;
198 199

  
199 200
	/**
200 201
	 * The initialization of the object. This just sets some internal variables.
......
364 365
	}
365 366

  
366 367
	/**
368
	 * Used by makeMenu() as compare function for supporting a correctly
369
	 * ordered menu taking into account locales.
370
	 *
371
	 * Uses strcoll() which takes locales into account, strcmp() doesn't.
372
	 *
373
	 * @param	array	Current record, that gets compared with the next record
374
	 * @param	array	Next record
375
	 * @return	boolean
376
	 */
377
	public static function sortByField($currentRecord, $nextRecord) {
378
			// default, if current record equals equals next record
379
		$result = 0;
380

  
381
		if(strcoll($currentRecord[self::$alternativeSortingField], $nextRecord[self::$alternativeSortingField]) < 0) {
382
			$result = -1;
383
		} elseif(strcoll($currentRecord[self::$alternativeSortingField], $nextRecord[self::$alternativeSortingField]) > 0) {
384
			$result = 1;
385
		}
386

  
387
		return $result;
388
	}
389

  
390
	/**
367 391
	 * Creates the menu in the internal variables, ready for output.
368 392
	 * Basically this will read the page records needed and fill in the internal $this->menuArr
369 393
	 * 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 508
									}
485 509
								}
486 510
							}
511
								// if alternativeSortingField is set and current language is not default language
512
							if($altSortField != 'sorting' && $GLOBALS['TSFE']->sys_language_uid != 0) {
513
								$altSortFieldArray = explode(' ', $altSortField);
514
									// share the alternative sorting field with the compare function
515
								self::$alternativeSortingField = $altSortFieldArray[0];
516
									// call the custom sort function sortByKey();
517
								usort($temp, array('tslib_menu', 'sortByField'));
518

  
519
								if(isset($altSortFieldArray[1]) && ($altSortFieldArray[1] == 'desc' || $altSortFieldArray[1] == 'DESC')) {
520
									$temp = array_reverse($temp);
521
								}
522
							}
487 523
						}
488 524
					break;
489 525
					case 'list':
(2-2/2)