فهرست منبع

Fix issue #61 : amélioration import OPML

Marien Fressinaud 13 سال پیش
والد
کامیت
244026874a
2فایلهای تغییر یافته به همراه24 افزوده شده و 5 حذف شده
  1. 19 4
      app/controllers/feedController.php
  2. 5 1
      lib/lib_rss.php

+ 19 - 4
app/controllers/feedController.php

@@ -190,6 +190,7 @@ class feedController extends ActionController {
 			$nb_month_old = $this->view->conf->oldEntries ();
 			$date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
 
+			$error = false;
 			$i = 0;
 			foreach ($feeds as $feed) {
 				try {
@@ -207,17 +208,31 @@ class feedController extends ActionController {
 					);
 
 					if (!$feedDAO->searchByUrl ($values['url'])) {
-						$feedDAO->addFeed ($values);
+						if (!$feedDAO->addFeed ($values)) {
+							$error = true;
+						}
 					}
 				} catch (FeedException $e) {
+					$error = true;
 					Log::record ($e->getMessage (), Log::ERROR);
 				}
 			}
 
+			if ($error) {
+				$res = 'Les flux ont été importés mais des erreurs sont survenus';
+			} else {
+				$res = 'Les flux ont été importés';
+			}
+			$notif = array (
+				'type' => 'good',
+				'content' => $res
+			);
+			Session::_param ('notification', $notif);
+
 			Request::forward (array (
-				'c' => 'feed',
-				'a' => 'actualize'
-			));
+				'c' => 'configure',
+				'a' => 'importExport'
+			), true);
 		}
 	}
 

+ 5 - 1
lib/lib_rss.php

@@ -124,7 +124,11 @@ function opml_import ($xml) {
 			}
 			
 			if ($title) {
-				$cat = new Category ($title);
+				$catDAO = new CategoryDAO ();
+				$cat = $catDAO->searchByName ($title);
+				if ($cat === false) {
+					$cat = new Category ($title);
+				}
 				$categories[] = $cat;
 				
 				$feeds = array_merge ($feeds, getFeedsOutline ($outline, $cat->id ()));