]> git.wh0rd.org Git - tt-rss.git/commitdiff
better label import category checking, filters import placeholder
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 27 Dec 2011 14:03:20 +0000 (18:03 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 27 Dec 2011 14:03:20 +0000 (18:03 +0400)
opml.php

index e8ae163a6b463de4b23f4920a2fd55919db17b3c..103ec0ba617772e15f2cd6b30c32e54e71c071cb 100644 (file)
--- a/opml.php
+++ b/opml.php
 
                                        $pref_name = db_escape_string($attributes->getNamedItem('pref-name')->nodeValue);
                                        $label_name = db_escape_string($attributes->getNamedItem('label-name')->nodeValue);
+                                       $filter_name = db_escape_string($attributes->getNamedItem('filter-name')->nodeValue);
 
                                        if ($cat_title && !$feed_url) {
 
-                                               if ($cat_title != "tt-rss-prefs" && $cat_title != 'tt-rss-labels') {
+                                               if ($cat_title != "tt-rss-prefs" && $cat_title != 'tt-rss-labels' && $cat_title != 'tt-rss-filters') {
 
                                                        db_query($link, "BEGIN");
 
                                        }
 
                                        if ($label_name) {
-                                               $fg_color = db_escape_string($attributes->getNamedItem('label-fg-color')->nodeValue);
-                                               $bg_color = db_escape_string($attributes->getNamedItem('label-bg-color')->nodeValue);
+                                               $parent_node = $outline->parentNode;
+
+                                               if ($parent_node && $parent_node->nodeName == "outline") {
+                                                       $cat_check = $parent_node->attributes->getNamedItem('title')->nodeValue;
+                                                       if ($cat_check == "tt-rss-labels") {
 
-                                               if (!label_find_id($link, $label_name, $_SESSION['uid'])) {
+                                                               $fg_color = db_escape_string($attributes->getNamedItem('label-fg-color')->nodeValue);
+                                                               $bg_color = db_escape_string($attributes->getNamedItem('label-bg-color')->nodeValue);
 
-                                                       printf("<li>".__("Adding label %s")."</li>", $label_name);
+                                                               if (!label_find_id($link, $label_name, $_SESSION['uid'])) {
+                                                                       printf("<li>".__("Adding label %s")."</li>", $label_name);
+                                                                       label_create($link, $label_name, $fg_color, $bg_color);
+                                                               } else {
+                                                                       printf("<li>".__("Duplicate label: %s")."</li>", $label_name);
+                                                               }
+                                                       }
+                                               }
+                                       }
 
-                                                       label_create($link, $label_name, $fg_color, $bg_color);
+                                       if ($filter_name) {
+                                               $parent_node = $outline->parentNode;
+
+                                               if ($parent_node && $parent_node->nodeName == "outline") {
+                                                       $cat_check = $parent_node->attributes->getNamedItem('title')->nodeValue;
+                                                       if ($cat_check == "tt-rss-filters") {
+                                                               $filter = json_decode($outline->nodeValue, true);
+
+                                                               if ($filter) {
+                                                                       /////
+
+
+                                                               }
+                                                       }
                                                }
                                        }