]> git.wh0rd.org - tt-rss.git/blob - classes/article.php
add catchall backend class
[tt-rss.git] / classes / article.php
1 <?php
2 class Article extends Handler {
3
4 function redirect() {
5 $id = db_escape_string($_REQUEST['id']);
6
7 $result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries
8 WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'
9 LIMIT 1");
10
11 if (db_num_rows($result) == 1) {
12 $article_url = db_fetch_result($result, 0, 'link');
13 $article_url = str_replace("\n", "", $article_url);
14
15 header("Location: $article_url");
16 return;
17
18 } else {
19 print_error(__("Article not found."));
20 }
21 }
22
23 function view() {
24 $id = db_escape_string($_REQUEST["id"]);
25 $cids = explode(",", db_escape_string($_REQUEST["cids"]));
26 $mode = db_escape_string($_REQUEST["mode"]);
27 $omode = db_escape_string($_REQUEST["omode"]);
28
29 // in prefetch mode we only output requested cids, main article
30 // just gets marked as read (it already exists in client cache)
31
32 $articles = array();
33
34 if ($mode == "") {
35 array_push($articles, format_article($this->link, $id, false));
36 } else if ($mode == "zoom") {
37 array_push($articles, format_article($this->link, $id, true, true));
38 } else if ($mode == "raw") {
39 if ($_REQUEST['html']) {
40 header("Content-Type: text/html");
41 print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
42 }
43
44 $article = format_article($this->link, $id, false);
45 print $article['content'];
46 return;
47 }
48
49 catchupArticleById($this->link, $id, 0);
50
51 if (!$_SESSION["bw_limit"]) {
52 foreach ($cids as $cid) {
53 if ($cid) {
54 array_push($articles, format_article($this->link, $cid, false, false));
55 }
56 }
57 }
58
59 print json_encode($articles);
60
61 }
62
63 }