]> git.wh0rd.org - tt-rss.git/blobdiff - classes/article.php
move opml-specific get_feed_category to opml.php
[tt-rss.git] / classes / article.php
index 398132d1200b5b1f412f0e9dcdb8cf2984a7bcae..2e7a05e0bb1db7e125242adcef0b9182e5895d52 100644 (file)
@@ -30,7 +30,6 @@ class Article extends Handler_Protected {
                $id = $this->dbh->escape_string($_REQUEST["id"]);
                $cids = explode(",", $this->dbh->escape_string($_REQUEST["cids"]));
                $mode = $this->dbh->escape_string($_REQUEST["mode"]);
-               $omode = $this->dbh->escape_string($_REQUEST["omode"]);
 
                // in prefetch mode we only output requested cids, main article
                // just gets marked as read (it already exists in client cache)
@@ -42,12 +41,12 @@ class Article extends Handler_Protected {
                } else if ($mode == "zoom") {
                        array_push($articles, format_article($id, true, true));
                } else if ($mode == "raw") {
-                       if ($_REQUEST['html']) {
+                       if (isset($_REQUEST['html'])) {
                                header("Content-Type: text/html");
                                print '<link rel="stylesheet" type="text/css" href="css/tt-rss.css"/>';
                        }
 
-                       $article = format_article($id, false);
+                       $article = format_article($id, false, isset($_REQUEST["zoom"]));
                        print $article['content'];
                        return;
                }
@@ -89,6 +88,25 @@ class Article extends Handler_Protected {
                        $owner_uid) {
 
                $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash
+
+               if (!$content) {
+                       $pluginhost = new PluginHost();
+                       $pluginhost->load_all(PluginHost::KIND_ALL, $owner_uid);
+                       $pluginhost->load_data();
+
+                       $af_readability = $pluginhost->get_plugin("Af_Readability");
+
+                       if ($af_readability) {
+                               $enable_share_anything = $pluginhost->get($af_readability, "enable_share_anything");
+
+                               if ($enable_share_anything) {
+                                       $extracted_content = $af_readability->extract_content($url);
+
+                                       if ($extracted_content) $content = db_escape_string($extracted_content);
+                               }
+                       }
+               }
+
                $content_hash = sha1($content);
 
                if ($labels_str != "") {
@@ -108,7 +126,7 @@ class Article extends Handler_Protected {
 
                // only check for our user data here, others might have shared this with different content etc
                $result = db_query("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
-                       link = '$url' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
+                       guid = '$guid' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
 
                if (db_num_rows($result) != 0) {
                        $ref_id = db_fetch_result($result, 0, "id");
@@ -184,14 +202,14 @@ class Article extends Handler_Protected {
 
                $tags_str = join(", ", $tags);
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$param\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"article\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
+               print_hidden("id", "$param");
+               print_hidden("op", "article");
+               print_hidden("method", "setArticleTags");
 
                print "<table width='100%'><tr><td>";
 
                print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
-                       style='font-size : 12px; width : 100%' id=\"tags_str\"
+                       style='height : 100px; font-size : 12px; width : 98%' id=\"tags_str\"
                        name='tags_str'>$tags_str</textarea>
                <div class=\"autocomplete\" id=\"tags_choices\"
                                style=\"display:none\"></div>";
@@ -216,6 +234,18 @@ class Article extends Handler_Protected {
                        score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
 
                print json_encode(array("id" => $ids,
+                       "score" => (int)$score,
+                       "score_pic" => get_score_pic($score)));
+       }
+
+       function getScore() {
+               $id = $this->dbh->escape_string($_REQUEST['id']);
+
+               $result = $this->dbh->query("SELECT score FROM ttrss_user_entries WHERE ref_id = $id AND owner_uid = " . $_SESSION["uid"]);
+               $score = $this->dbh->fetch_result($result, 0, "score");
+
+               print json_encode(array("id" => $id,
+                       "score" => (int)$score,
                        "score_pic" => get_score_pic($score)));
        }
 
@@ -331,7 +361,7 @@ class Article extends Handler_Protected {
                                $labels = get_article_labels($id, $_SESSION["uid"]);
 
                                array_push($reply["info-for-headlines"],
-                               array("id" => $id, "labels" => format_article_labels($labels, $id)));
+                               array("id" => $id, "labels" => format_article_labels($labels)));
 
                        }
                }