cleanup OPML import interface

This commit is contained in:
Andrew Dolgov 2005-12-01 07:10:39 +01:00
parent d998a8a8e0
commit 4e9f5c2420
2 changed files with 48 additions and 17 deletions

View file

@ -52,3 +52,19 @@ a {
color : black; color : black;
} }
a {
color : black;
text-decoration : none;
}
a:hover {
color : #5050aa;
}
ul {
list-style-type : none;
margin : 0px;
padding : 10px;
}

View file

@ -2,27 +2,32 @@
session_start(); session_start();
require_once "sanity_check.php"; require_once "sanity_check.php";
require_once "functions.php";
// FIXME there are some brackets issues here
$op = $_REQUEST["op"];
if ($op == "Export") {
header("Content-type: application/xml");
print "<?xml version=\"1.0\"?>";
}
require_once "config.php"; require_once "config.php";
require_once "db.php"; require_once "db.php";
require_once "db-prefs.php"; require_once "db-prefs.php";
$owner_uid = $_SESSION["uid"];
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (DB_TYPE == "pgsql") { if (DB_TYPE == "pgsql") {
pg_query($link, "set client_encoding = 'utf-8'"); pg_query($link, "set client_encoding = 'utf-8'");
} }
login_sequence($link);
$owner_uid = $_SESSION["uid"];
// FIXME there are some brackets issues here
$op = $_REQUEST["op"];
if (!$op) $op = "Export";
if ($op == "Export") {
header("Content-type: application/xml");
print "<?xml version=\"1.0\"?>";
}
if ($op == "Export") { if ($op == "Export") {
print "<opml version=\"1.0\">"; print "<opml version=\"1.0\">";
print "<head> print "<head>
@ -93,8 +98,9 @@
<link rel=\"stylesheet\" href=\"opml.css\" type=\"text/css\"> <link rel=\"stylesheet\" href=\"opml.css\" type=\"text/css\">
</head> </head>
<body> <body>
<h1>Importing OPML...</h1> <h1><img src=\"images/ttrss_logo.png\"></h1>
<div class=\"opmlBody\">"; <div class=\"opmlBody\">
<h2>Importing OPML...</h2>";
if (WEB_DEMO_MODE) { if (WEB_DEMO_MODE) {
print "OPML import is disabled in demo-mode."; print "OPML import is disabled in demo-mode.";
@ -117,10 +123,13 @@
$outlines = $body->get_elements_by_tagname('outline'); $outlines = $body->get_elements_by_tagname('outline');
print "<table>";
foreach ($outlines as $outline) { foreach ($outlines as $outline) {
$feed_title = db_escape_string($outline->get_attribute('text')); $feed_title = db_escape_string($outline->get_attribute('text'));
$cat_title = db_escape_string($outline->get_attribute('title')); $cat_title = db_escape_string($outline->get_attribute('title'));
$feed_url = db_escape_string($outline->get_attribute('xmlUrl')); $feed_url = db_escape_string($outline->get_attribute('xmlUrl'));
$site_url = db_escape_string($outline->get_attribute('htmlUrl'));
if ($cat_title && !$feed_url) { if ($cat_title && !$feed_url) {
@ -135,7 +144,8 @@
print "Adding category <b>$cat_title</b>...<br>"; print "Adding category <b>$cat_title</b>...<br>";
db_query($link, "INSERT INTO ttrss_feed_categories db_query($link, "INSERT INTO ttrss_feed_categories
(title,owner_uid) VALUES ('$cat_title', '$owner_uid')"); (title,owner_uid,site_url)
VALUES ('$cat_title', '$owner_uid', '$site_url')");
} }
db_query($link, "COMMIT"); db_query($link, "COMMIT");
@ -172,10 +182,11 @@
(title = '$feed_title' OR feed_url = '$feed_url') (title = '$feed_title' OR feed_url = '$feed_url')
AND owner_uid = '$owner_uid'"); AND owner_uid = '$owner_uid'");
print "Feed <b>$feed_title</b> ($feed_url)... "; print "<tr><td><a href='$site_url'><b>$feed_title</b></a></b>
(<a href=\"$feed_url\">rss</a>)</td>";
if (db_num_rows($result) > 0) { if (db_num_rows($result) > 0) {
print " Already imported.<br>"; print "<td>Already imported.</td>";
} else { } else {
if ($cat_id) { if ($cat_id) {
@ -192,12 +203,16 @@
db_query($link, $add_query); db_query($link, $add_query);
print "<b>Done.</b><br>"; print "<td><b>Done.</b></td>";
} }
print "</tr>";
db_query($link, "COMMIT"); db_query($link, "COMMIT");
} }
print "</table>";
} else { } else {
print "<div class=\"error\">Error: can't find body element.</div>"; print "<div class=\"error\">Error: can't find body element.</div>";
} }