]> git.wh0rd.org - tt-rss.git/commitdiff
fix OPML import handling uncategorized feeds, misc OPML touch-ups
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 25 Nov 2005 13:55:21 +0000 (14:55 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 25 Nov 2005 13:55:21 +0000 (14:55 +0100)
opml.css
opml.php

index 52d4a270f9d6219abfa972788d3a05c36a6b55c4..de17423947e4ad6a3f51faa4b91552ad6ed46d8e 100644 (file)
--- a/opml.css
+++ b/opml.css
@@ -7,23 +7,27 @@ body {
 
 h1 {
        font-size : 21pt;
-       background-color : #f0f0f0;
-       background-image : url("images/header.png");
-       background-position : top left;
-       background-repeat : repeat-x;
-       height : 50px;
-       padding-left : 80px;
-       padding-top : 30px;
        font-weight : bold;
+       padding : 10px 0px 10px 30px;
        color : black;
        border-width : 0px 0px 1px 0px;
        border-color : #c0c0c0;
        border-style : solid;
+       background-color : white;
+       background-image : url("images/vgrad_light.png");
+       background-position : bottom left;
+       background-repeat : repeat-x;
+}
 
+div.opmlBody {
+       margin : 30px;  
 }
 
-div {
-       margin : 30px;
+div.error {
+       background : #fff0f0;
+       border : 1px solid #c0c0c0;
+       padding : 5px;
+       font-size : x-small;
 }
 
 a {
index b7ad52252ef4ae78bea0bdf2f60f31bdbf154283..b9986cda6474606955530e4dcb9c76de62eab30b 100644 (file)
--- a/opml.php
+++ b/opml.php
@@ -83,8 +83,9 @@
                        <head>
                                <link rel=\"stylesheet\" href=\"opml.css\" type=\"text/css\">
                        </head>
-                       <body><h1>Importing OPML...</h1>
-                       <div>";
+                       <body>
+                       <h1>Importing OPML...</h1>
+                       <div class=\"opmlBody\">";
 
                if (WEB_DEMO_MODE) {
                        print "OPML import is disabled in demo-mode.";
 
                                        $outlines = $body->get_elements_by_tagname('outline');
 
-                                       $active_category = '';
-
                                        foreach ($outlines as $outline) {
-                                               $feed_title = $outline->get_attribute('text');
-                                               $cat_title = $outline->get_attribute('title');
-                                               $feed_url = $outline->get_attribute('xmlUrl');
+                                               $feed_title = db_escape_string($outline->get_attribute('text'));
+                                               $cat_title = db_escape_string($outline->get_attribute('title'));
+                                               $feed_url = db_escape_string($outline->get_attribute('xmlUrl'));
 
                                                if ($cat_title) {
-                                                       $active_category = $cat_title;
 
                                                        db_query($link, "BEGIN");
                                                        
 
                                                $cat_id = null;
 
-                                               if ($active_category) {
+                                               $parent_node = $outline->parent_node();
+
+                                               if ($parent_node && $parent_node->node_name() == "outline") {
+                                                       $element_category = $parent_node->get_attribute('title');
+                                               } else {
+                                                       $element_category = '';
+                                               }
+
+                                               if ($element_category) {
 
                                                        $result = db_query($link, "SELECT id FROM
-                                                                       ttrss_feed_categories WHERE title = '$active_category' AND
+                                                                       ttrss_feed_categories WHERE title = '$element_category' AND
                                                                        owner_uid = '$owner_uid' LIMIT 1");                                                             
 
                                                        if (db_num_rows($result) == 1) {        
                                                                        ('$feed_title', '$feed_url', '$owner_uid')";
 
                                                        }
-                                                       
+
                                                        db_query($link, $add_query);
                                                        
                                                        print "<b>Done.</b><br>";
                                        }
 
                                } else {
-                                       print "Error: can't find body element.";
+                                       print "<div class=\"error\">Error: can't find body element.</div>";
                                }
                        } else {
-                               print "Error while parsing document.";
+                               print "<div class=\"error\">Error while parsing document.</div>";
                        }
 
                } else {
-                       print "Error: please upload OPML file.";
+                       print "<div class=\"error\">Error: please upload OPML file.</div>";
                }
 
                print "<p><a class=\"button\" href=\"prefs.php\">