From e955834551d3ef496bd05c76826363d40b730ea4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 29 Jun 2010 14:26:10 +0400 Subject: support import and export of tt-rss preferences in OPML with DOMDocument OPML path --- modules/opml_domdoc.php | 51 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/opml_domdoc.php b/modules/opml_domdoc.php index 51b771337..72eeeb1d6 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; -- cgit v1.2.3