TYPO3 CMS  TYPO3_6-2
ResourceUtility.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Utility;
3 
32  public static function recursiveFileListSortingHelper($elementA, $elementB) {
33  if (strpos($elementA, '/') === FALSE) {
34  // first element is a file
35  if (strpos($elementB, '/') === FALSE) {
36  $result = self::nameCompareSortingHelper($elementA, $elementB);
37  } else {
38  // second element is a directory => always sort it first
39  $result = 1;
40  }
41  } else {
42  // first element is a directory
43  if (strpos($elementB, '/') === FALSE) {
44  // second element is a file => always sort it last
45  $result = -1;
46  } else {
47  // both elements are directories => we have to recursively sort here
48  list($pathPartA, $elementA) = explode('/', $elementA, 2);
49  list($pathPartB, $elementB) = explode('/', $elementB, 2);
50 
51  if ($pathPartA === $pathPartB) {
52  // same directory => sort by subpaths
53  $result = self::recursiveFileListSortingHelper($elementA, $elementB);
54  } else {
55  // different directories => sort by current directories
56  $result = self::nameCompareSortingHelper($pathPartA, $pathPartB);
57  }
58  }
59  }
60 
61  return $result;
62  }
63 
72  static public function nameCompareSortingHelper($elementA, $elementB) {
73  $result = strnatcasecmp($elementA, $elementB);
74  if ($result === 0) {
75  // Both are same in case insensitive so it's ok to check then now unnaturally.
76  $result = strcmp($elementA, $elementB);
77  }
78 
79  return $result;
80  }
81 }
static nameCompareSortingHelper($elementA, $elementB)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
static recursiveFileListSortingHelper($elementA, $elementB)