Переглянути джерело

Change feed order in a category (#3131)

Before, the sorting was not human readable. Lower-cased feed names were
displayed after upper-cased feed names.
Now, the sorting is human readable. The sorting is done without taking into
account the name case.

See #3128
Alexis Degrugillier 5 роки тому
батько
коміт
ee31722072
1 змінених файлів з 8 додано та 4 видалено
  1. 8 4
      app/Models/FeedDAO.php

+ 8 - 4
app/Models/FeedDAO.php

@@ -357,14 +357,18 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
 	}
 
 	public function listByCategory($cat) {
-		$sql = 'SELECT * FROM `_feed` WHERE category=? ORDER BY name';
+		$sql = 'SELECT * FROM `_feed` WHERE category=?';
 		$stm = $this->pdo->prepare($sql);
 
-		$values = array($cat);
+		$stm->execute(array($cat));
 
-		$stm->execute($values);
+		$feeds = self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC));
 
-		return self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC));
+		usort($feeds, function ($a, $b) {
+			return strnatcasecmp($a->name(), $b->name());
+		});
+
+		return $feeds;
 	}
 
 	public function countEntries($id) {