Sfoglia il codice sorgente

Better OPML import of feeds in multiple categories (#3286)

#fix https://github.com/FreshRSS/FreshRSS/issues/3284
Helps https://github.com/FreshRSS/FreshRSS/issues/1989

In OPMLs files in which feeds are listed several times, favour the
version in a category instead of in no category.
Alexandre Alapetite 5 anni fa
parent
commit
4f74215199
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      app/Controllers/importExportController.php

+ 7 - 0
app/Controllers/importExportController.php

@@ -251,6 +251,13 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
 		$nb_cats = count($this->catDAO->listCategories(false));
 		$limits = FreshRSS_Context::$system_conf->limits;
 
+		//Sort with categories first
+		usort($opml_elements, function ($a, $b) {
+			return strcmp(
+				(isset($a['xmlUrl']) ? 'Z' : 'A') . $a['text'],
+				(isset($b['xmlUrl']) ? 'Z' : 'A') . $b['text']);
+		});
+
 		foreach ($opml_elements as $elt) {
 			if (isset($elt['xmlUrl'])) {
 				// If xmlUrl exists, it means it is a feed