From: Andrew Dolgov Date: Tue, 29 Jun 2010 10:26:10 +0000 (+0400) Subject: support import and export of tt-rss preferences in OPML with DOMDocument OPML path X-Git-Tag: 1.4.3-proper~33 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e955834551d3ef496bd05c76826363d40b730ea4;hp=50e7dd7d01de742006ebbac9322bc775d0f564a3;p=tt-rss.git support import and export of tt-rss preferences in OPML with DOMDocument OPML path --- diff --git a/functions.php b/functions.php index 7320f0fa..4bf9cee4 100644 --- a/functions.php +++ b/functions.php @@ -824,10 +824,11 @@ $rss_1_date = $item['dc']['date']; $atom_date = $item['issued']; if (!$atom_date) $atom_date = $item['updated']; - + if ($atom_date != "") $entry_timestamp = parse_w3cdtf($atom_date); if ($rss_1_date != "") $entry_timestamp = parse_w3cdtf($rss_1_date); if ($rss_2_date != "") $entry_timestamp = strtotime($rss_2_date); + } if ($entry_timestamp == "" || $entry_timestamp == -1 || !$entry_timestamp) { diff --git a/modules/opml_domdoc.php b/modules/opml_domdoc.php index 51b77133..72eeeb1d 100644 --- a/modules/opml_domdoc.php +++ b/modules/opml_domdoc.php @@ -1,6 +1,8 @@ attributes->getNamedItem('xmlUrl')->nodeValue); $site_url = db_escape_string($outline->attributes->getNamedItem('htmlUrl')->nodeValue); + $pref_name = db_escape_string($outline->attributes->getNamedItem('pref-name')->nodeValue); + if ($cat_title && !$feed_url) { - db_query($link, "BEGIN"); + if ($cat_title != "tt-rss-prefs") { + + db_query($link, "BEGIN"); + + $result = db_query($link, "SELECT id FROM + ttrss_feed_categories WHERE title = '$cat_title' AND + owner_uid = '$owner_uid' LIMIT 1"); + + if (db_num_rows($result) == 0) { + + printf(__("
  • Adding category %s.
  • "), $cat_title); + + db_query($link, "INSERT INTO ttrss_feed_categories + (title,owner_uid) + VALUES ('$cat_title', '$owner_uid')"); + } + + db_query($link, "COMMIT"); + } + } - $result = db_query($link, "SELECT id FROM - ttrss_feed_categories WHERE title = '$cat_title' AND - owner_uid = '$owner_uid' LIMIT 1"); + // print "$active_category : $feed_title : $feed_url
    "; - if (db_num_rows($result) == 0) { + if ($pref_name) { + $parent_node = $outline->parentNode; - printf(__("
  • Adding category %s.
  • "), $cat_title); + if ($parent_node && $parent_node->nodeName == "outline") { + $cat_check = $parent_node->attributes->getNamedItem('title')->nodeValue; + if ($cat_check == "tt-rss-prefs") { + $pref_value = db_escape_string($outline->attributes->getNamedItem('value')->nodeValue); - db_query($link, "INSERT INTO ttrss_feed_categories - (title,owner_uid) - VALUES ('$cat_title', '$owner_uid')"); - } + printf("
  • ". + __("Setting preference key %s to %s")."
  • ", + $pref_name, $pref_value); - db_query($link, "COMMIT"); - } + set_pref($link, $pref_name, $pref_value); - // print "$active_category : $feed_title : $feed_url
    "; + } + } + } if (!$feed_title || !$feed_url) continue; diff --git a/opml.php b/opml.php index d808c8f9..d3a352fa 100644 --- a/opml.php +++ b/opml.php @@ -13,7 +13,11 @@ init_connection($link); function opml_export($link, $owner_uid, $hide_private_feeds=False) { - header("Content-type: application/xml+opml"); + if (!$_REQUEST["debug"]) { + header("Content-type: application/xml+opml"); + } else { + header("Content-type: text/xml"); + } print ""; print ""; @@ -88,6 +92,26 @@ print "\n"; } + # export tt-rss settings + + print ""; + + $result = db_query($link, "SELECT pref_name, value FROM ttrss_user_prefs WHERE + profile IS NULL AND owner_uid = " . $_SESSION["uid"]); + + while ($line = db_fetch_assoc($result)) { + + $name = $line["pref_name"]; + $value = htmlspecialchars($line["value"]); + + print ""; + + print ""; + + } + + print ""; + print ""; } @@ -125,10 +149,13 @@ login_sequence($link); $owner_uid = $_SESSION["uid"]; + header('Content-Type: text/html; charset=utf-8'); + print " ".__("OPML Utility")." +