start work on support for technorati tags, schema uses cascade deletes for pgsql
This commit is contained in:
parent
e9e4c6e23a
commit
eb36b4eb55
4 changed files with 49 additions and 7 deletions
|
@ -668,10 +668,7 @@
|
||||||
$ids = split(",", $_GET["ids"]);
|
$ids = split(",", $_GET["ids"]);
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
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, "DELETE FROM ttrss_feeds WHERE id = '$id'");
|
||||||
db_query($link, "COMMIT");
|
|
||||||
|
|
||||||
if (file_exists(ICONS_DIR . "/$id.ico")) {
|
if (file_exists(ICONS_DIR . "/$id.ico")) {
|
||||||
unlink(ICONS_DIR . "/$id.ico");
|
unlink(ICONS_DIR . "/$id.ico");
|
||||||
|
|
|
@ -269,11 +269,46 @@
|
||||||
$result = db_query($link, $query);
|
$result = db_query($link, $query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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')");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result) {
|
db_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()");
|
||||||
$result = db_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
drop table if exists ttrss_tags;
|
||||||
drop table if exists ttrss_entries;
|
drop table if exists ttrss_entries;
|
||||||
drop table if exists ttrss_feeds;
|
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',
|
insert into ttrss_labels (sql_exp,description) values ('unread = true',
|
||||||
'Unread articles');
|
'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;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
drop table ttrss_tags;
|
||||||
drop table ttrss_entries;
|
drop table ttrss_entries;
|
||||||
drop table ttrss_feeds;
|
drop table ttrss_feeds;
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ insert into ttrss_feeds (title,feed_url) values ('Technocrat.net',
|
||||||
'http://syndication.technocrat.net/rss');
|
'http://syndication.technocrat.net/rss');
|
||||||
|
|
||||||
create table ttrss_entries (id serial not null primary key,
|
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,
|
updated timestamp not null,
|
||||||
title varchar(250) not null,
|
title varchar(250) not null,
|
||||||
guid varchar(300) not null unique,
|
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',
|
insert into ttrss_labels (sql_exp,description) values ('unread = true',
|
||||||
'Unread articles');
|
'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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue