]> git.wh0rd.org Git - tt-rss.git/commitdiff
display slash:comments in view mode
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 10 Dec 2005 07:28:55 +0000 (08:28 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 10 Dec 2005 07:28:55 +0000 (08:28 +0100)
backend.php
functions.php

index a31afb61bae85228c38f4066bd283f27779d92d8..c087b3225ab5fb7066e17e9516e9eaf6836ab905 100644 (file)
 
                $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
                        SUBSTRING(updated,1,16) as updated,
-                       (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
+                       (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
+                       num_comments
                        FROM ttrss_entries,ttrss_user_entries
                        WHERE   id = '$id' AND ref_id = id");
 
                                $feed_icon = "&nbsp;";
                        }
 
-                       if ($line["comments"] && $line["link"] != $line["comments"]) {
+/*                     if ($line["comments"] && $line["link"] != $line["comments"]) {
                                $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
                        } else {
                                $entry_comments = "";
+                       } */
+
+                       $num_comments = $line["num_comments"];
+                       $entry_comments = "";
+
+                       if ($num_comments > 0) {
+                               if ($line["comments"]) {
+                                       $comments_url = $line["comments"];
+                               } else {
+                                       $comments_url = $line["link"];
+                               }
+                               $entry_comments = "(<a href=\"$comments_url\">$num_comments comments</a>)";
+                       } else {
+                               if ($line["comments"] && $line["link"] != $line["comments"]) {
+                                       $entry_comments = "(<a href=\"".$line["comments"]."\">Comments</a>)";
+                               }                               
                        }
 
                        print "<div class=\"postReply\">";
index 8b990740e1247f17faf00a1b12009e00a38cd04b..639ba3215f369d9badaa53884be4d20f24a22100 100644 (file)
                                $entry_link = db_escape_string($entry_link);
                                $entry_comments = db_escape_string($entry_comments);
 
+                               $num_comments = 0;
+
+                               if ($item["slash"]) {
+                                       $num_comments = db_escape_string($item["slash"]["comments"]);
+                               }
+
                                if (db_num_rows($result) == 0) {
 
                                        // base post entry does not exist, create it
                                                        content_hash,
                                                        no_orig_date,
                                                        date_entered,
-                                                       comments)
+                                                       comments,
+                                                       num_comments)
                                                VALUES
                                                        ('$entry_title', 
                                                        '$entry_guid', 
                                                        '$content_hash',
                                                        $no_orig_date, 
                                                        NOW(), 
-                                                       '$entry_comments')");
+                                                       '$entry_comments',
+                                                       '$num_comments')");
                                }
 
                                // now it should exist, if not - bad luck then
 
                                $result = db_query($link, "SELECT 
                                                id,content_hash,no_orig_date,title,
-                                               substring(updated,1,19) as updated
+                                               substring(updated,1,19) as updated,
+                                               num_comments
                                        FROM 
                                                ttrss_entries 
                                        WHERE guid = '$entry_guid'");
 
                                if (db_num_rows($result) == 1) {
 
-                                               // this will be used below in update handler
-                                               $orig_content_hash = db_fetch_result($result, 0, "content_hash");
-//                                             $orig_timestamp = strtotime(db_fetch_result($result, 0, "updated"));
-//                                             $orig_no_orig_date = db_fetch_result($result, 0, "no_orig_date");
-                                               $orig_title = db_fetch_result($result, 0, "title");
+                                       // this will be used below in update handler
+                                       $orig_content_hash = db_fetch_result($result, 0, "content_hash");
+                                       $orig_title = db_fetch_result($result, 0, "title");
+                                       $orig_num_comments = db_fetch_result($result, 0, "num_comments");
 
-                                               $ref_id = db_fetch_result($result, 0, "id");
+                                       $ref_id = db_fetch_result($result, 0, "id");
 
-                                               // check for user post link to main table
+                                       // check for user post link to main table
 
-                                               // do we allow duplicate posts with same GUID in different feeds?
-                                               if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid)) {
-                                                       $dupcheck_qpart = "AND feed_id = '$feed'";
-                                               } else { 
-                                                       $dupcheck_qpart = "";
-                                               }
+                                       // do we allow duplicate posts with same GUID in different feeds?
+                                       if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid)) {
+                                               $dupcheck_qpart = "AND feed_id = '$feed'";
+                                       } else { 
+                                               $dupcheck_qpart = "";
+                                       }
 
-//                                             error_reporting(0);
+//                                     error_reporting(0);
 
-                                               $filter_name = get_filter_name($entry_title, $entry_content, 
-                                                       $entry_link, $filters);
+                                       $filter_name = get_filter_name($entry_title, $entry_content, 
+                                               $entry_link, $filters);
 
-                                               if ($filter_name == "filter") {
-                                                       continue;
-                                               }
+                                       if ($filter_name == "filter") {
+                                               continue;
+                                       }
 
-//                                             error_reporting (DEFAULT_ERROR_LEVEL);
+//                                     error_reporting (DEFAULT_ERROR_LEVEL);
 
-                                               $result = db_query($link,
-                                                       "SELECT ref_id FROM ttrss_user_entries WHERE
-                                                               ref_id = '$ref_id' AND owner_uid = '$owner_uid'
-                                                               $dupcheck_qpart");
-
-                                               // okay it doesn't exist - create user entry
-                                               if (db_num_rows($result) == 0) {
-
-                                                       if ($filter_name != 'catchup') {
-                                                               $unread = 'true';
-                                                               $last_read_qpart = 'NULL';
-                                                       } else {
-                                                               $unread = 'false';
-                                                               $last_read_qpart = 'NOW()';
-                                                       }                                               
+                                       $result = db_query($link,
+                                               "SELECT ref_id FROM ttrss_user_entries WHERE
+                                                       ref_id = '$ref_id' AND owner_uid = '$owner_uid'
+                                                       $dupcheck_qpart");
+                                                       
+                                       // okay it doesn't exist - create user entry
+                                       if (db_num_rows($result) == 0) {
+
+                                               if ($filter_name != 'catchup') {
+                                                       $unread = 'true';
+                                                       $last_read_qpart = 'NULL';
+                                               } else {
+                                                       $unread = 'false';
+                                                       $last_read_qpart = 'NOW()';
+                                               }                                               
                                                
-                                                       $result = db_query($link,
-                                                               "INSERT INTO ttrss_user_entries 
-                                                                       (ref_id, owner_uid, feed_id, unread, last_read) 
-                                                               VALUES ('$ref_id', '$owner_uid', '$feed', $unread,
-                                                                       $last_read_qpart)");
-                                               }
-
+                                               $result = db_query($link,
+                                                       "INSERT INTO ttrss_user_entries 
+                                                               (ref_id, owner_uid, feed_id, unread, last_read) 
+                                                       VALUES ('$ref_id', '$owner_uid', '$feed', $unread,
+                                                               $last_read_qpart)");
+                                       }
+                                       
                                        $post_needs_update = false;
 
                                        if (get_pref($link, "UPDATE_POST_ON_CHECKSUM_CHANGE", $owner_uid) &&
                                                $post_needs_update = true;
                                        }
 
+                                       if ($orig_num_comments != $num_comments) {
+                                               $post_needs_update = true;
+                                       }
+
 //                                     this doesn't seem to be very reliable
 //
 //                                     if ($orig_timestamp != $entry_timestamp && !$orig_no_orig_date) {
 //                                             print "<!-- post $orig_title needs update : $post_needs_update -->";
 
                                                db_query($link, "UPDATE ttrss_entries 
-                                                       SET title = '$entry_title', content = '$entry_content'
+                                                       SET title = '$entry_title', content = '$entry_content',
+                                                               num_comments = '$num_comments'
                                                        WHERE id = '$ref_id'");
 
                                                db_query($link, "UPDATE ttrss_user_entries