]> git.wh0rd.org Git - tt-rss.git/commitdiff
reimplement OPML filter export
authorAndrew Dolgov <fox@fakecake.org>
Sat, 1 Sep 2012 19:33:56 +0000 (23:33 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Sat, 1 Sep 2012 19:33:56 +0000 (23:33 +0400)
classes/opml.php
include/functions.php

index 60d0d40e07fa129e5a597e9a62cd108d031fe3b5..1940250d313d41da6a55491d1b59daea35253e66 100644 (file)
@@ -159,39 +159,62 @@ class Opml extends Handler_Protected {
 
                        $out .= "</outline>";
 
-/*                     $out .= "<outline title=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
-
-                       $result = db_query($this->link, "SELECT filter_type,
-                                       reg_exp,
-                                       action_id,
-                                       enabled,
-                                       action_param,
-                                       inverse,
-                                       filter_param,
-                                       cat_filter,
-                                       ttrss_feeds.feed_url AS feed_url,
-                                       ttrss_feed_categories.title AS cat_title
-                                       FROM ttrss_filters
-                                               LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)
-                                               LEFT JOIN ttrss_feed_categories ON (ttrss_filters.cat_id = ttrss_feed_categories.id)
-                                       WHERE
-                                               ttrss_filters.owner_uid = " . $_SESSION['uid']);
+                       $out .= "<outline title=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
 
-                       while ($line = db_fetch_assoc($result)) {
-                               $name = htmlspecialchars($line['reg_exp']);
+                       $result = db_query($this->link, "SELECT * FROM ttrss_filters2
+                               WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY id");
 
+                       while ($line = db_fetch_assoc($result)) {
                                foreach (array('enabled', 'inverse', 'cat_filter') as $b) {
                                        $line[$b] = sql_bool_to_bool($line[$b]);
                                }
 
+                               $line["rules"] = array();
+                               $line["actions"] = array();
+
+                               $tmp_result = db_query($this->link, "SELECT * FROM ttrss_filters2_rules
+                                       WHERE filter_id = ".$line["id"]);
+
+                               while ($tmp_line = db_fetch_assoc($tmp_result)) {
+                                       unset($tmp_line["id"]);
+                                       unset($tmp_line["filter_id"]);
+
+                                       $cat_filter = sql_bool_to_bool($tmp_line["cat_filter"]);
+
+                                       if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
+                                               $tmp_line["feed"] = getFeedTitle($this->link,
+                                                       $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
+                                                       $cat_filter);
+                                       } else {
+                                               $tmp_line["feed"] = "";
+                                       }
+
+                                       unset($tmp_line["feed_id"]);
+                                       unset($tmp_line["cat_id"]);
+
+                                       array_push($line["rules"], $tmp_line);
+                               }
+
+                               $tmp_result = db_query($this->link, "SELECT * FROM ttrss_filters2_actions
+                                       WHERE filter_id = ".$line["id"]);
+
+                               while ($tmp_line = db_fetch_assoc($tmp_result)) {
+                                       unset($tmp_line["id"]);
+                                       unset($tmp_line["filter_id"]);
+
+                                       array_push($line["actions"], $tmp_line);
+                               }
+
+                               unset($line["id"]);
+                               unset($line["owner_uid"]);
                                $filter = json_encode($line);
 
-                               $out .= "<outline filter-name=\"$name\">$filter</outline>";
+                               $out .= "<outline filter-type=\"2\">$filter</outline>";
 
                        }
 
 
-                       $out .= "</outline>"; */
+                       $out .= "</outline>";
                }
 
                $out .= "</body></opml>";
index ac0276fc7607b180ece39b616d8d9d1af1d675ba..960cf996f3b9e7cce8db33ef00e58662281ae466 100644 (file)
 
        }
 
-       function getFeedIcon($id) {
+       function getFeedIcon($id, $cat) {
                switch ($id) {
                case 0:
                        return "images/archive.png";
                }
        }
 
-       function getFeedTitle($link, $id) {
-               if ($id == -1) {
+       function getFeedTitle($link, $id, $cat = false) {
+               if ($cat) {
+                       return getFeedCatTitle($link, $id);
+               } else if ($id == -1) {
                        return __("Starred articles");
                } else if ($id == -2) {
                        return __("Published articles");