]> git.wh0rd.org Git - tt-rss.git/commitdiff
start work on support for technorati tags, schema uses cascade deletes for pgsql
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Sep 2005 04:52:36 +0000 (05:52 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Sep 2005 04:52:36 +0000 (05:52 +0100)
backend.php
functions.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql

index 3442b862e1816c658835a68853eda724653a189b..19020ac8012f33edcad9eaf7ca9fc1f0b88626e5 100644 (file)
                                $ids = split(",", $_GET["ids"]);
 
                                foreach ($ids as $id) {
-                                       db_query($link, "BEGIN");
-                                       db_query($link, "DELETE FROM ttrss_entries WHERE feed_id = '$id'");
                                        db_query($link, "DELETE FROM ttrss_feeds WHERE id = '$id'");
-                                       db_query($link, "COMMIT");
                                        
                                        if (file_exists(ICONS_DIR . "/$id.ico")) {
                                                unlink(ICONS_DIR . "/$id.ico");
index c032364d7d4d16ed87ae427cc91608add53abb60..f4628a812a0c2d7c2a7a2597184ab9ac31a2220c 100644 (file)
                                                $result = db_query($link, $query);
                                        }
                                }
-                       }
 
-                       if ($result) {
-                               $result = db_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()");
+                               /* taaaags */
+                               // <a href="http://technorati.com/tag/Xorg" rel="tag">Xorg</a>, //
+
+                               $entry_tags = null;
+
+                               preg_match_all("/<a.*?rel=.tag.*?>([^>]+)<\/a>/i", $entry_content,
+                                       $entry_tags);
+
+                               $entry_tags = $entry_tags[1];
+
+                               if (count($entry_tags) > 0) {
+                               
+                                       $result = db_query($link, "SELECT id FROM ttrss_entries 
+                                               WHERE guid = '$entry_guid'");
+
+                                       if (!$result || db_num_rows($result) != 1) {
+                                               return;
+                                       }
+
+                                       $entry_id = db_fetch_result($result, 0, "id");
+                               
+                                       foreach ($entry_tags as $tag) {
+                                               $tag = db_escape_string(strtolower($tag));
+
+                                               $result = db_query($link, "SELECT id FROM ttrss_tags            
+                                                       WHERE tag_name = '$tag' AND post_id = '$entry_id' LIMIT 1");
+
+                                               if ($result && db_num_rows($result) == 0) {
+                                                       
+//                                                     print "tagging $entry_id as $tag<br>";
+
+                                                       db_query($link, "INSERT INTO ttrss_tags (tag_name,post_id)
+                                                               VALUES ('$tag', '$entry_id')");
+                                               }                                                       
+                                       }
+                               }
                        }
 
+                       db_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()");
+
                }
 
                db_query($link, "COMMIT");
index ae736cb6f266e8a9532186fa5b92d8268e340890..877421920134e47537488ccc10591b6a478df87e 100644 (file)
@@ -1,3 +1,4 @@
+drop table if exists ttrss_tags;
 drop table if exists ttrss_entries;
 drop table if exists ttrss_feeds;
 
@@ -69,3 +70,7 @@ create table ttrss_labels (id integer primary key auto_increment,
 insert into ttrss_labels (sql_exp,description) values ('unread = true', 
        'Unread articles');
 
+create table ttrss_tags (id integer primary key auto_increment, 
+       tag_name varchar(250) not null,
+       post_id integer references ttrss_entries(id)) TYPE=InnoDB;
+
index 31183173bd51e2e819f6f104954396456bed9fe8..3c084996f4ea85ab6650b874f0c575ab0dbc0048 100644 (file)
@@ -1,3 +1,4 @@
+drop table ttrss_tags;
 drop table ttrss_entries;
 drop table ttrss_feeds;
 
@@ -28,7 +29,7 @@ insert into ttrss_feeds (title,feed_url) values ('Technocrat.net',
        'http://syndication.technocrat.net/rss');
 
 create table ttrss_entries (id serial not null primary key, 
-       feed_id int references ttrss_feeds(id) not null, 
+       feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null, 
        updated timestamp not null, 
        title varchar(250) not null, 
        guid varchar(300) not null unique, 
@@ -68,3 +69,7 @@ create table ttrss_labels (id serial primary key,
 insert into ttrss_labels (sql_exp,description) values ('unread = true', 
        'Unread articles');
 
+create table ttrss_tags (id serial primary key, 
+       tag_name varchar(250) not null,
+       post_id integer references ttrss_entries(id) ON DELETE CASCADE not null);
+