Просмотр исходного кода

Sort by "sortTitle" in the all series list

Zachary Kotlarek 13 лет назад
Родитель
Сommit
dceff8549f
2 измененных файлов с 16 добавлено и 3 удалено
  1. 10 3
      web/includes/display.php
  2. 6 0
      web/includes/util.php

+ 10 - 3
web/includes/display.php

@@ -129,13 +129,20 @@ function printAllSeries() {
 	echo '</ul>';
 	echo '</div>';
 
+	# Sort by "sortTitle" -- an approximation of the Plex sort title
+	$sorted_series = array();
+	foreach ($all_series as $series => $seasons) {
+		$sorted_series[ $series ] = sortTitle($series);
+	}
+	asort($sorted_series);
+
 	# Display all series
 	echo '<ul data-role="listview" data-filter="true" data-autodividers="true" id="sortedList">';
-	foreach ($all_series as $series => $seasons) {
+	foreach ($sorted_series as $series => $sort) {
 
 		# Determine if the series has any monitored seasons
 		$monitored = false;
-		foreach ($seasons as $season => $status) {
+		foreach ($all_series[ $series ] as $season => $status) {
 			if ($status) {
 				$monitored = true;
 			}
@@ -145,7 +152,7 @@ function printAllSeries() {
 		if ($monitored) {
 			echo '<img src="tv.png" class="ui-li-icon ui-corner-none">';
 		}
-		echo htmlspecialchars($series);
+		echo htmlspecialchars($sort);
 		echo '<span class="ui-li-count">' . count($seasons) . '</span>';
 		echo '</a></li>';
 	}

+ 6 - 0
web/includes/util.php

@@ -41,4 +41,10 @@ function isJunk($path) {
 	return false;
 }
 
+function sortTitle($name) {
+	$name = preg_replace('/^The\s+/i', '', $name);
+	$name = preg_replace('/^A\s+/i', '', $name);
+	return $name;
+}
+
 ?>