add catchall backend class

This commit is contained in:
Andrew Dolgov 2011-12-13 10:58:30 +04:00
parent 1f203144a2
commit 611efae712
5 changed files with 29 additions and 23 deletions

View File

@ -181,10 +181,6 @@
module_pref_instances($link); module_pref_instances($link);
break; // pref-instances break; // pref-instances
case "digestTest":
print_r(prepare_headlines_digest($link, $_SESSION["uid"]));
break; // digestTest
case "digestSend": case "digestSend":
send_headlines_digests($link); send_headlines_digests($link);
break; // digestSend break; // digestSend

View File

@ -1,20 +1,20 @@
<?php <?php
class Article extends Handler { class Article extends Handler {
function index() { function redirect() {
$id = db_escape_string($_REQUEST['id']); $id = db_escape_string($_REQUEST['id']);
$result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries $result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries
WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."' WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'
LIMIT 1"); LIMIT 1");
if (db_num_rows($result) == 1) { if (db_num_rows($result) == 1) {
$article_url = db_fetch_result($result, 0, 'link'); $article_url = db_fetch_result($result, 0, 'link');
$article_url = str_replace("\n", "", $article_url); $article_url = str_replace("\n", "", $article_url);
header("Location: $article_url"); header("Location: $article_url");
return; return;
} else { } else {
print_error(__("Article not found.")); print_error(__("Article not found."));
} }
@ -25,12 +25,12 @@ class Article extends Handler {
$cids = explode(",", db_escape_string($_REQUEST["cids"])); $cids = explode(",", db_escape_string($_REQUEST["cids"]));
$mode = db_escape_string($_REQUEST["mode"]); $mode = db_escape_string($_REQUEST["mode"]);
$omode = db_escape_string($_REQUEST["omode"]); $omode = db_escape_string($_REQUEST["omode"]);
// in prefetch mode we only output requested cids, main article // in prefetch mode we only output requested cids, main article
// just gets marked as read (it already exists in client cache) // just gets marked as read (it already exists in client cache)
$articles = array(); $articles = array();
if ($mode == "") { if ($mode == "") {
array_push($articles, format_article($this->link, $id, false)); array_push($articles, format_article($this->link, $id, false));
} else if ($mode == "zoom") { } else if ($mode == "zoom") {
@ -40,14 +40,14 @@ class Article extends Handler {
header("Content-Type: text/html"); header("Content-Type: text/html");
print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>'; print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
} }
$article = format_article($this->link, $id, false); $article = format_article($this->link, $id, false);
print $article['content']; print $article['content'];
return; return;
} }
catchupArticleById($this->link, $id, 0); catchupArticleById($this->link, $id, 0);
if (!$_SESSION["bw_limit"]) { if (!$_SESSION["bw_limit"]) {
foreach ($cids as $cid) { foreach ($cids as $cid) {
if ($cid) { if ($cid) {
@ -55,9 +55,9 @@ class Article extends Handler {
} }
} }
} }
print json_encode($articles); print json_encode($articles);
} }
} }

10
classes/backend.php Normal file
View File

@ -0,0 +1,10 @@
<?php
class Backend extends Handler {
function loading() {
header("Content-type: text/html");
print __("Loading, please wait...") . " " .
"<img src='images/indicator_tiny.gif'>";
}
}
?>

View File

@ -805,7 +805,7 @@ function tweet_article(id) {
var d = new Date(); var d = new Date();
var ts = d.getTime(); var ts = d.getTime();
var w = window.open('backend.php?op=loading', 'ttrss_tweet', var w = window.open('backend.php?op=backend&method=loading', 'ttrss_tweet',
"status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0"); "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {

View File

@ -1770,7 +1770,7 @@ function getLastVisibleHeadlineId() {
function openArticleInNewWindow(id) { function openArticleInNewWindow(id) {
toggleUnread(id, 0, false); toggleUnread(id, 0, false);
window.open("backend.php?op=article&id=" + id); window.open("backend.php?op=article&method=redirect&id=" + id);
} }
function isCdmMode() { function isCdmMode() {
@ -2003,7 +2003,7 @@ function tweetArticle(id) {
var d = new Date(); var d = new Date();
var ts = d.getTime(); var ts = d.getTime();
var w = window.open('backend.php?op=loading', 'ttrss_tweet', var w = window.open('backend.php?op=backend&method=loading', 'ttrss_tweet',
"status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0"); "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {