]> git.wh0rd.org - tt-rss.git/commitdiff
implement digestTest back
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 31 Jan 2012 12:27:51 +0000 (16:27 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 31 Jan 2012 12:27:51 +0000 (16:27 +0400)
misc digest updates and improvements

classes/backend.php
include/functions.php
include/rssfuncs.php
templates/digest_template_html.txt

index 19938344d78481f1e222aba7e6cfbc646e1d4ebd..4d1e99a613b8cfe07a1ecf089d8433e59e282965 100644 (file)
@@ -10,7 +10,17 @@ class Backend extends Handler {
        function digestSend() {
                define('PREFS_NO_CACHE', true);
 
-               send_headlines_digests($this->link, 100, true);
+               send_headlines_digests($this->link);
+       }
+
+       function digestTest() {
+               header("Content-type: text/html");
+
+               $rv = prepare_headlines_digest($this->link, $_SESSION['uid'], 1, 1000);
+
+               $rv[3] = "<pre>" . $rv[3] . "</pre>";
+
+               print_r($rv);
        }
 
        function help() {
index 0ef1d013fe7b4a5f086eec7600eca38af90f49d4..aaca70dae5c7ba9e76ce9f798ad2f8d3471a6eac 100644 (file)
         * @param integer $limit The maximum number of articles by digest.
         * @return boolean Return false if digests are not enabled.
         */
-       function send_headlines_digests($link, $limit = 100, $debug = true) {
+       function send_headlines_digests($link, $debug = false) {
 
                require_once 'lib/phpmailer/class.phpmailer.php';
 
                $user_limit = 15; // amount of users to process (e.g. emails to send out)
+               $limit = 1000; // maximum amount of headlines to include
 
                if ($debug) _debug("Sending digests, batch of max $user_limit users, headline limit = $limit");
 
 
        }
 
-       function prepare_headlines_digest($link, $user_id, $days = 1, $limit = 100) {
+       function prepare_headlines_digest($link, $user_id, $days = 1, $limit = 1000) {
 
                require_once "lib/MiniTemplator.class.php";
 
 
                $result = db_query($link, "SELECT ttrss_entries.title,
                                ttrss_feeds.title AS feed_title,
+                               ttrss_feed_categories.title AS cat_title,
                                date_updated,
                                ttrss_user_entries.ref_id,
                                link,
-                               SUBSTRING(content, 1, 120) AS excerpt,
+                               score,
+                               content,
                                ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                        FROM
                                ttrss_user_entries,ttrss_entries,ttrss_feeds
+                       LEFT JOIN
+                               ttrss_feed_categories ON (cat_id = ttrss_feed_categories.id)
                        WHERE
                                ref_id = ttrss_entries.id AND feed_id = ttrss_feeds.id
                                AND include_in_digest = true
                                AND $interval_query
                                AND ttrss_user_entries.owner_uid = $user_id
                                AND unread = true
-                       ORDER BY ttrss_feeds.title, date_updated DESC
+                               AND score >= 0
+                       ORDER BY ttrss_feed_categories.title, ttrss_feeds.title, score DESC, date_updated DESC
                        LIMIT $limit");
 
                $cur_feed_title = "";
                        $updated = make_local_datetime($link, $line['last_updated'], false,
                                $user_id);
 
+/*                     if ($line["score"] != 0) {
+                               if ($line["score"] > 0) $line["score"] = '+' . $line["score"];
+
+                               $line["title"] .= " (".$line['score'].")";
+                       } */
+
+                       if (get_pref($link, 'ENABLE_FEED_CATS', $user_id)) {
+                               if (!$line['cat_title']) $line['cat_title'] = __("Uncategorized");
+
+                               $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
+                       }
+
                        $tpl->setVariable('FEED_TITLE', $line["feed_title"]);
                        $tpl->setVariable('ARTICLE_TITLE', $line["title"]);
                        $tpl->setVariable('ARTICLE_LINK', $line["link"]);
                        $tpl->setVariable('ARTICLE_UPDATED', $updated);
                        $tpl->setVariable('ARTICLE_EXCERPT',
-                               truncate_string(strip_tags($line["excerpt"]), 100));
+                               truncate_string(strip_tags($line["content"]), 300));
+//                     $tpl->setVariable('ARTICLE_CONTENT',
+//                             strip_tags($article_content));
 
                        $tpl->addBlock('article');
 
index 51b7d7c33117ee33b09f5fd1db977e5a1a3b9744..03fc068ea68bde7d36fdb2a4a9a8be2e6cfd4318 100644 (file)
                }
 
                // Send feed digests by email if needed.
-               send_headlines_digests($link, 100, $debug);
+               send_headlines_digests($link, $debug);
 
        } // function update_daemon_common
 
index 5940a72fffb558d4df5d387e5a5294e41461fa4a..0759e8a056493d39256b1c322f8b979e3604bfba 100644 (file)
@@ -1,5 +1,6 @@
 <!-- $BeginBlock digest -->
 <h1 style='font-size : x-large'>New headlines for last 24 hours, as of ${CUR_DATE} ${CUR_TIME}</h1>
+<hr/>
 <!-- $BeginBlock feed -->
 <h2 style='font-size : large'>${FEED_TITLE}</h2>