summaryrefslogtreecommitdiff
path: root/classes/article.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-02 15:16:38 +0300
committerAndrew Dolgov <[email protected]>2021-03-02 15:16:38 +0300
commit9ad4cbeecaed32e4106a7fef30bbe3d14195f78a (patch)
tree687b365d08a17cb2fb737dfc22f78197c62dde1e /classes/article.php
parentd6629ed18863f797d34ebdc65815d7af21cb8332 (diff)
wip separate handlersexp-separate-handlers
Diffstat (limited to 'classes/article.php')
-rwxr-xr-xclasses/article.php169
1 files changed, 3 insertions, 166 deletions
diff --git a/classes/article.php b/classes/article.php
index 648b1e2c1..b4dff4b33 100755
--- a/classes/article.php
+++ b/classes/article.php
@@ -1,29 +1,9 @@
<?php
-class Article extends Handler_Protected {
+class Article {
const ARTICLE_KIND_ALBUM = 1;
const ARTICLE_KIND_VIDEO = 2;
const ARTICLE_KIND_YOUTUBE = 3;
- function redirect() {
- $article = ORM::for_table('ttrss_entries')
- ->table_alias('e')
- ->join('ttrss_user_entries', [ 'ref_id', '=', 'e.id'], 'ue')
- ->where('ue.owner_uid', $_SESSION['uid'])
- ->find_one((int)$_REQUEST['id']);
-
- if ($article) {
- $article_url = UrlHelper::validate($article->link);
-
- if ($article_url) {
- header("Location: $article_url");
- return;
- }
- }
-
- header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
- print "Article not found or has an empty URL.";
- }
-
static function _create_published_article($title, $url, $content, $labels_str,
$owner_uid) {
@@ -158,137 +138,6 @@ class Article extends Handler_Protected {
return $rc;
}
- function printArticleTags() {
- $id = (int) clean($_REQUEST['id'] ?? 0);
-
- print json_encode(["id" => $id,
- "tags" => self::_get_tags($id)]);
- }
-
- function setScore() {
- $ids = array_map("intval", clean($_REQUEST['ids'] ?? []));
- $score = (int)clean($_REQUEST['score']);
-
- $ids_qmarks = arr_qmarks($ids);
-
- $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
- score = ? WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
-
- $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']]));
-
- print json_encode(["id" => $ids, "score" => $score]);
- }
-
- function setArticleTags() {
-
- $id = clean($_REQUEST["id"]);
-
- //$tags_str = clean($_REQUEST["tags_str"]);
- //$tags = array_unique(array_map('trim', explode(",", $tags_str)));
-
- $tags = FeedItem_Common::normalize_categories(explode(",", clean($_REQUEST["tags_str"])));
-
- $this->pdo->beginTransaction();
-
- $sth = $this->pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE
- ref_id = ? AND owner_uid = ? LIMIT 1");
- $sth->execute([$id, $_SESSION['uid']]);
-
- if ($row = $sth->fetch()) {
-
- $tags_to_cache = array();
-
- $int_id = $row['int_id'];
-
- $dsth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE
- post_int_id = ? AND owner_uid = ?");
- $dsth->execute([$int_id, $_SESSION['uid']]);
-
- $csth = $this->pdo->prepare("SELECT post_int_id FROM ttrss_tags
- WHERE post_int_id = ? AND owner_uid = ? AND tag_name = ?");
-
- $usth = $this->pdo->prepare("INSERT INTO ttrss_tags
- (post_int_id, owner_uid, tag_name)
- VALUES (?, ?, ?)");
-
- foreach ($tags as $tag) {
- $csth->execute([$int_id, $_SESSION['uid'], $tag]);
-
- if (!$csth->fetch()) {
- $usth->execute([$int_id, $_SESSION['uid'], $tag]);
- }
-
- array_push($tags_to_cache, $tag);
- }
-
- /* update tag cache */
-
- $tags_str = join(",", $tags_to_cache);
-
- $sth = $this->pdo->prepare("UPDATE ttrss_user_entries
- SET tag_cache = ? WHERE ref_id = ? AND owner_uid = ?");
- $sth->execute([$tags_str, $id, $_SESSION['uid']]);
- }
-
- $this->pdo->commit();
-
- // get latest tags from the database, original $tags is sometimes JSON-encoded as a hash ({}) - ???
- print json_encode(["id" => (int)$id, "tags" => $this->_get_tags($id)]);
- }
-
-
- /*function completeTags() {
- $search = clean($_REQUEST["search"]);
-
- $sth = $this->pdo->prepare("SELECT DISTINCT tag_name FROM ttrss_tags
- WHERE owner_uid = ? AND
- tag_name LIKE ? ORDER BY tag_name
- LIMIT 10");
-
- $sth->execute([$_SESSION['uid'], "$search%"]);
-
- print "<ul>";
- while ($line = $sth->fetch()) {
- print "<li>" . $line["tag_name"] . "</li>";
- }
- print "</ul>";
- }*/
-
- function assigntolabel() {
- return $this->_label_ops(true);
- }
-
- function removefromlabel() {
- return $this->_label_ops(false);
- }
-
- private function _label_ops($assign) {
- $reply = array();
-
- $ids = explode(",", clean($_REQUEST["ids"]));
- $label_id = clean($_REQUEST["lid"]);
-
- $label = Labels::find_caption($label_id, $_SESSION["uid"]);
-
- $reply["labels-for"] = [];
-
- if ($label) {
- foreach ($ids as $id) {
- if ($assign)
- Labels::add_article($id, $label, $_SESSION["uid"]);
- else
- Labels::remove_article($id, $label, $_SESSION["uid"]);
-
- array_push($reply["labels-for"],
- ["id" => (int)$id, "labels" => $this->_get_labels($id)]);
- }
- }
-
- $reply["message"] = "UPDATE_COUNTERS";
-
- print json_encode($reply);
- }
-
static function _format_enclosures($id,
$always_display_enclosures,
$article_content,
@@ -416,19 +265,6 @@ class Article extends Handler_Protected {
return $tags;
}
- function getmetadatabyid() {
- $article = ORM::for_table('ttrss_entries')
- ->join('ttrss_user_entries', ['ref_id', '=', 'id'], 'ue')
- ->where('ue.owner_uid', $_SESSION['uid'])
- ->find_one((int)$_REQUEST['id']);
-
- if ($article) {
- echo json_encode(["link" => $article->link, "title" => $article->title]);
- } else {
- echo json_encode([]);
- }
- }
-
static function _get_enclosures($id) {
$encs = ORM::for_table('ttrss_enclosures')
->where('post_id', $id)
@@ -666,4 +502,5 @@ class Article extends Handler_Protected {
return array_unique($rv);
}
-}
+
+} \ No newline at end of file