diff options
-rwxr-xr-x | classes/api.php | 14 | ||||
-rwxr-xr-x | classes/article.php | 69 | ||||
-rw-r--r-- | classes/digest.php | 4 | ||||
-rw-r--r-- | classes/feeditem.php | 2 | ||||
-rwxr-xr-x | classes/feeditem/atom.php | 4 | ||||
-rwxr-xr-x | classes/feeditem/common.php | 2 | ||||
-rwxr-xr-x | classes/feeditem/rss.php | 4 | ||||
-rwxr-xr-x | classes/feeds.php | 10 | ||||
-rwxr-xr-x | classes/handler/public.php | 18 | ||||
-rw-r--r-- | classes/labels.php | 2 | ||||
-rwxr-xr-x | classes/pluginhost.php | 2 | ||||
-rwxr-xr-x | classes/rpc.php | 6 | ||||
-rwxr-xr-x | classes/rssutils.php | 8 | ||||
-rw-r--r-- | js/Article.js | 2 | ||||
-rw-r--r-- | js/CommonFilters.js | 2 | ||||
-rw-r--r-- | plugins/note/init.php | 2 |
16 files changed, 62 insertions, 89 deletions
diff --git a/classes/api.php b/classes/api.php index 73e5c221a..4d1c15598 100755 --- a/classes/api.php +++ b/classes/api.php @@ -316,7 +316,7 @@ class API extends Handler { "guid" => $line["guid"], "title" => $line["title"], "link" => $line["link"], - "labels" => Article::get_article_labels($line['id']), + "labels" => Article::_get_labels($line['id']), "unread" => self::param_to_bool($line["unread"]), "marked" => self::param_to_bool($line["marked"]), "published" => self::param_to_bool($line["published"]), @@ -324,7 +324,7 @@ class API extends Handler { "author" => $line["author"], "updated" => (int) strtotime($line["updated"]), "feed_id" => $line["feed_id"], - "attachments" => Article::get_enclosures($line['id']), + "attachments" => Article::_get_enclosures($line['id']), "score" => (int)$line["score"], "feed_title" => $line["feed_title"], "note" => $line["note"], @@ -417,7 +417,7 @@ class API extends Handler { $sth->execute([$_SESSION['uid']]); if ($article_id) - $article_labels = Article::get_article_labels($article_id); + $article_labels = Article::_get_labels($article_id); else $article_labels = array(); @@ -489,7 +489,7 @@ class API extends Handler { $url = strip_tags(clean($_REQUEST["url"])); $content = strip_tags(clean($_REQUEST["content"])); - if (Article::create_published_article($title, $url, $content, "", $_SESSION["uid"])) { + if (Article::_create_published_article($title, $url, $content, "", $_SESSION["uid"])) { $this->wrap(self::STATUS_OK, array("status" => 'OK')); } else { $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed')); @@ -718,7 +718,7 @@ class API extends Handler { } } - if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); + if (!is_array($labels)) $labels = Article::_get_labels($line["id"]); $headline_row = array( "id" => (int)$line["id"], @@ -734,7 +734,7 @@ class API extends Handler { "tags" => $tags, ); - $enclosures = Article::get_enclosures($line['id']); + $enclosures = Article::_get_enclosures($line['id']); if ($include_attachments) $headline_row['attachments'] = $enclosures; @@ -775,7 +775,7 @@ class API extends Handler { if ($show_content) { $hook_object = ["headline" => &$headline_row]; - list ($flavor_image, $flavor_stream, $flavor_kind) = Article::get_article_image($enclosures, + list ($flavor_image, $flavor_stream, $flavor_kind) = Article::_get_image($enclosures, $line["content"], // unsanitized $line["site_url"]); diff --git a/classes/article.php b/classes/article.php index cc5d73b64..d177a8d6d 100755 --- a/classes/article.php +++ b/classes/article.php @@ -27,7 +27,7 @@ class Article extends Handler_Protected { } } - static function create_published_article($title, $url, $content, $labels_str, + static function _create_published_article($title, $url, $content, $labels_str, $owner_uid) { $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash @@ -165,7 +165,7 @@ class Article extends Handler_Protected { $id = (int) clean($_REQUEST['id'] ?? 0); print json_encode(["id" => $id, - "tags" => self::get_article_tags($id)]); + "tags" => self::_get_tags($id)]); } function setScore() { @@ -248,8 +248,8 @@ class Article extends Handler_Protected { $this->pdo->commit(); - $tags = self::get_article_tags($id); - $tags_str = $this->format_tags_string($tags); + $tags = self::_get_tags($id); + $tags_str = $this->_format_tags_html($tags); $tags_str_full = join(", ", $tags); if (!$tags_str_full) $tags_str_full = __("no tags"); @@ -277,14 +277,14 @@ class Article extends Handler_Protected { } function assigntolabel() { - return $this->labelops(true); + return $this->_label_ops(true); } function removefromlabel() { - return $this->labelops(false); + return $this->_label_ops(false); } - private function labelops($assign) { + private function _label_ops($assign) { $reply = array(); $ids = explode(",", clean($_REQUEST["ids"])); @@ -303,10 +303,10 @@ class Article extends Handler_Protected { else Labels::remove_article($id, $label, $_SESSION["uid"]); - $labels = $this->get_article_labels($id, $_SESSION["uid"]); + $labels = $this->_get_labels($id, $_SESSION["uid"]); array_push($reply["info-for-headlines"], - array("id" => $id, "labels" => $this->format_article_labels($labels))); + array("id" => $id, "labels" => $this->_format_labels_html($labels))); } } @@ -316,24 +316,12 @@ class Article extends Handler_Protected { print json_encode($reply); } - function getArticleFeed($id) { - $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries - WHERE ref_id = ? AND owner_uid = ?"); - $sth->execute([$id, $_SESSION['uid']]); - - if ($row = $sth->fetch()) { - return $row["feed_id"]; - } else { - return 0; - } - } - - static function format_enclosures($id, + static function _format_enclosures($id, $always_display_enclosures, $article_content, $hide_images = false) { - $enclosures = self::get_enclosures($id); + $enclosures = self::_get_enclosures($id); $rv = []; $enclosures_formatted = ""; @@ -389,7 +377,7 @@ class Article extends Handler_Protected { return $rv; } - static function get_article_tags($id, $owner_uid = 0, $tag_cache = false) { + static function _get_tags($id, $owner_uid = 0, $tag_cache = false) { $a_id = $id; @@ -439,7 +427,7 @@ class Article extends Handler_Protected { return $tags; } - static function format_tags_string($tags) { + static function _format_tags_html($tags) { if (!is_array($tags) || count($tags) == 0) { return __("no tags"); } else { @@ -459,7 +447,7 @@ class Article extends Handler_Protected { } } - static function format_article_labels($labels) { + static function _format_labels_html($labels) { if (!is_array($labels)) return ''; @@ -475,8 +463,7 @@ class Article extends Handler_Protected { } - static function format_article_note($id, $note, $allow_edit = true) { - + static function _format_note_html($id, $note, $allow_edit = true) { if ($allow_edit) { $onclick = "onclick='Plugins.Note.edit($id)'"; $note_class = 'editable'; @@ -491,7 +478,7 @@ class Article extends Handler_Protected { </div>"; } - function get_metadata_by_id() { + function getmetadatabyid() { $id = clean($_REQUEST['id']); $sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries @@ -506,7 +493,7 @@ class Article extends Handler_Protected { } } - static function get_enclosures($id) { + static function _get_enclosures($id) { $pdo = Db::pdo(); @@ -530,7 +517,7 @@ class Article extends Handler_Protected { return $rv; } - static function purge_orphans() { + static function _purge_orphans() { // purge orphaned posts in main content table @@ -549,7 +536,7 @@ class Article extends Handler_Protected { } } - static function catchupArticlesById($ids, $cmode, $owner_uid = false) { + static function _catchup_by_id($ids, $cmode, $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -574,21 +561,7 @@ class Article extends Handler_Protected { $sth->execute(array_merge($ids, [$owner_uid])); } - static function getLastArticleId() { - $pdo = Db::pdo(); - - $sth = $pdo->prepare("SELECT ref_id AS id FROM ttrss_user_entries - WHERE owner_uid = ? ORDER BY ref_id DESC LIMIT 1"); - $sth->execute([$_SESSION['uid']]); - - if ($row = $sth->fetch()) { - return $row['id']; - } else { - return -1; - } - } - - static function get_article_labels($id, $owner_uid = false) { + static function _get_labels($id, $owner_uid = false) { $rv = array(); if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -635,7 +608,7 @@ class Article extends Handler_Protected { return $rv; } - static function get_article_image($enclosures, $content, $site_url) { + static function _get_image($enclosures, $content, $site_url) { $article_image = ""; $article_stream = ""; diff --git a/classes/digest.php b/classes/digest.php index 7790424ca..77eb92c54 100644 --- a/classes/digest.php +++ b/classes/digest.php @@ -68,7 +68,7 @@ class Digest if ($rc && $do_catchup) { Debug::log("Marking affected articles as read..."); - Article::catchupArticlesById($affected_ids, 0, $line["id"]); + Article::_catchup_by_id($affected_ids, 0, $line["id"]); } } else { Debug::log("No headlines"); @@ -164,7 +164,7 @@ class Digest $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title']; } - $article_labels = Article::get_article_labels($line["ref_id"], $user_id); + $article_labels = Article::_get_labels($line["ref_id"], $user_id); $article_labels_formatted = ""; if (is_array($article_labels) && count($article_labels) > 0) { diff --git a/classes/feeditem.php b/classes/feeditem.php index 3a5e5dc09..e30df3086 100644 --- a/classes/feeditem.php +++ b/classes/feeditem.php @@ -9,7 +9,7 @@ abstract class FeedItem { abstract function get_comments_url(); abstract function get_comments_count(); abstract function get_categories(); - abstract function get_enclosures(); + abstract function _get_enclosures(); abstract function get_author(); abstract function get_language(); } diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index a03080981..3e092a048 100755 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -119,7 +119,7 @@ class FeedItem_Atom extends FeedItem_Common { return $this->normalize_categories($cats); } - function get_enclosures() { + function _get_enclosures() { $links = $this->elem->getElementsByTagName("link"); $encs = array(); @@ -138,7 +138,7 @@ class FeedItem_Atom extends FeedItem_Common { } } - $encs = array_merge($encs, parent::get_enclosures()); + $encs = array_merge($encs, parent::_get_enclosures()); return $encs; } diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php index 1e9d62228..f387e0779 100755 --- a/classes/feeditem/common.php +++ b/classes/feeditem/common.php @@ -78,7 +78,7 @@ abstract class FeedItem_Common extends FeedItem { } // this is common for both Atom and RSS types and deals with various media: elements - function get_enclosures() { + function _get_enclosures() { $encs = []; $enclosures = $this->xpath->query("media:content", $this->elem); diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 1f7953c51..f103ad787 100755 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -112,7 +112,7 @@ class FeedItem_RSS extends FeedItem_Common { return $this->normalize_categories($cats); } - function get_enclosures() { + function _get_enclosures() { $enclosures = $this->elem->getElementsByTagName("enclosure"); $encs = array(); @@ -129,7 +129,7 @@ class FeedItem_RSS extends FeedItem_Common { array_push($encs, $enc); } - $encs = array_merge($encs, parent::get_enclosures()); + $encs = array_merge($encs, parent::_get_enclosures()); return $encs; } diff --git a/classes/feeds.php b/classes/feeds.php index 6bf176261..10873d8ca 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -214,10 +214,10 @@ class Feeds extends Handler_Protected { } } - if (!is_array($labels)) $labels = Article::get_article_labels($id); + if (!is_array($labels)) $labels = Article::_get_labels($id); $labels_str = "<span class=\"HLLCTR-$id\">"; - $labels_str .= Article::format_article_labels($labels); + $labels_str .= Article::_format_labels_html($labels); $labels_str .= "</span>"; $line["labels"] = $labels_str; @@ -265,7 +265,7 @@ class Feeds extends Handler_Protected { $this->_mark_timestamp(" disk_cache_rewrite"); if ($line['note']) - $line['note'] = Article::format_article_note($id, $line['note']); + $line['note'] = Article::_format_note_html($id, $line['note']); else $line['note'] = ""; @@ -283,7 +283,7 @@ class Feeds extends Handler_Protected { $this->_mark_timestamp(" pre-enclosures"); - $line["enclosures"] = Article::format_enclosures($id, + $line["enclosures"] = Article::_format_enclosures($id, $line["always_display_enclosures"], $line["content"], $line["hide_images"]); @@ -303,7 +303,7 @@ class Feeds extends Handler_Protected { else $tags = false; - $line["tags_str"] = Article::format_tags_string($tags); + $line["tags_str"] = Article::_format_tags_html($tags); $this->_mark_timestamp(" tags"); diff --git a/classes/handler/public.php b/classes/handler/public.php index 98386cbf1..b11c8ba04 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -82,7 +82,7 @@ class Handler_Public extends Handler { while ($line = $result->fetch()) { $line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content"]), 100, '...')); - $line["tags"] = Article::get_article_tags($line["id"], $owner_uid); + $line["tags"] = Article::_get_tags($line["id"], $owner_uid); PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_QUERY_HEADLINES, function ($result) use (&$line) { @@ -131,7 +131,7 @@ class Handler_Public extends Handler { $tpl->addBlock('category'); } - $enclosures = Article::get_enclosures($line["id"]); + $enclosures = Article::_get_enclosures($line["id"]); if (count($enclosures) > 0) { foreach ($enclosures as $e) { @@ -151,7 +151,7 @@ class Handler_Public extends Handler { $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', null, true); } - list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $feed_site_url); + list ($og_image, $og_stream) = Article::_get_image($enclosures, $line['content'], $feed_site_url); $tpl->setVariable('ARTICLE_OG_IMAGE', $og_image, true); @@ -184,7 +184,7 @@ class Handler_Public extends Handler { while ($line = $result->fetch()) { $line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...')); - $line["tags"] = Article::get_article_tags($line["id"], $owner_uid); + $line["tags"] = Article::_get_tags($line["id"], $owner_uid); PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_QUERY_HEADLINES, function ($result) use (&$line) { @@ -218,7 +218,7 @@ class Handler_Public extends Handler { } } - $enclosures = Article::get_enclosures($line["id"]); + $enclosures = Article::_get_enclosures($line["id"]); if (count($enclosures) > 0) { $article['enclosures'] = array(); @@ -341,7 +341,7 @@ class Handler_Public extends Handler { if ($line = $sth->fetch()) { - $line["tags"] = Article::get_article_tags($id, $owner_uid, $line["tag_cache"]); + $line["tags"] = Article::_get_tags($id, $owner_uid, $line["tag_cache"]); unset($line["tag_cache"]); $line["content"] = Sanitizer::sanitize($line["content"], @@ -390,8 +390,8 @@ class Handler_Public extends Handler { $rv .= "</head>"; - $enclosures = Article::get_enclosures($line["id"]); - list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]); + $enclosures = Article::_get_enclosures($line["id"]); + list ($og_image, $og_stream) = Article::_get_image($enclosures, $line['content'], $line["site_url"]); if ($og_image) { $rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>"; @@ -573,7 +573,7 @@ class Handler_Public extends Handler { $content = strip_tags(clean($_REQUEST["content"])); $labels = strip_tags(clean($_REQUEST["labels"])); - Article::create_published_article($title, $url, $content, $labels, + Article::_create_published_article($title, $url, $content, $labels, $_SESSION["uid"]); print "<script type='text/javascript'>"; diff --git a/classes/labels.php b/classes/labels.php index 786091650..f72d7d84b 100644 --- a/classes/labels.php +++ b/classes/labels.php @@ -60,7 +60,7 @@ class Labels self::clear_cache($id); if (!$labels) - $labels = Article::get_article_labels($id); + $labels = Article::_get_labels($id); $labels = json_encode($labels); diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 42f7f6bf9..6f223ee11 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -47,7 +47,7 @@ class PluginHost { const HOOK_QUERY_HEADLINES = "hook_query_headlines"; // hook_query_headlines($row) (byref) const HOOK_HOUSE_KEEPING = "hook_house_keeping"; //*1 // GLOBAL: hook_house_keeping() const HOOK_SEARCH = "hook_search"; // hook_search($query) - const HOOK_FORMAT_ENCLOSURES = "hook_format_enclosures"; // hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images) (byref) + const HOOK_FORMAT_ENCLOSURES = "hook_format_enclosures"; // hook__format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images) (byref) const HOOK_SUBSCRIBE_FEED = "hook_subscribe_feed"; // hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) (byref) const HOOK_HEADLINES_BEFORE = "hook_headlines_before"; // hook_headlines_before($feed, $is_cat, $qfh_ret) const HOOK_RENDER_ENCLOSURE = "hook_render_enclosure"; // hook_render_enclosure($entry, $hide_images) diff --git a/classes/rpc.php b/classes/rpc.php index 206a93d60..7edc59921 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -119,7 +119,7 @@ class RPC extends Handler_Protected { WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); $sth->execute(array_merge($ids, [$_SESSION['uid']])); - Article::purge_orphans(); + Article::_purge_orphans(); print json_encode(array("message" => "UPDATE_COUNTERS")); } @@ -156,7 +156,7 @@ class RPC extends Handler_Protected { $ids = explode(",", clean($_REQUEST["ids"])); $cmode = (int)clean($_REQUEST["cmode"]); - Article::catchupArticlesById($ids, $cmode); + Article::_catchup_by_id($ids, $cmode); print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids)); } @@ -310,7 +310,7 @@ class RPC extends Handler_Protected { } // Purge orphans and cleanup tags - Article::purge_orphans(); + Article::_purge_orphans(); //cleanup_tags(14, 50000); if ($num_updated > 0) { diff --git a/classes/rssutils.php b/classes/rssutils.php index 0e90d8fe4..cd6f90859 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -723,9 +723,9 @@ class RSSUtils { if ($row = $sth->fetch()) { $base_entry_id = $row["id"]; $entry_stored_hash = $row["content_hash"]; - $article_labels = Article::get_article_labels($base_entry_id, $owner_uid); + $article_labels = Article::_get_labels($base_entry_id, $owner_uid); - $existing_tags = Article::get_article_tags($base_entry_id, $owner_uid); + $existing_tags = Article::_get_tags($base_entry_id, $owner_uid); $entry_tags = array_unique(array_merge($entry_tags, $existing_tags)); } else { $base_entry_id = false; @@ -739,7 +739,7 @@ class RSSUtils { $enclosures = array(); - $encs = $item->get_enclosures(); + $encs = $item->_get_enclosures(); if (is_array($encs)) { foreach ($encs as $e) { @@ -1636,7 +1636,7 @@ class RSSUtils { self::cleanup_feed_icons(); self::disable_failed_feeds(); - Article::purge_orphans(); + Article::_purge_orphans(); self::cleanup_counters_cache(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING); diff --git a/js/Article.js b/js/Article.js index 210427892..54883c2bf 100644 --- a/js/Article.js +++ b/js/Article.js @@ -123,7 +123,7 @@ const Article = { Article.setActive(0); }, displayUrl: function (id) { - const query = {op: "article", method: "get_metadata_by_id", id: id}; + const query = {op: "article", method: "getmetadatabyid", id: id}; xhrJson("backend.php", query, (reply) => { if (reply && reply.link) { diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 06e0410c7..5afffafdc 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -332,7 +332,7 @@ const Filters = { } else { - const query = {op: "article", method: "get_metadata_by_id", id: Article.getActive()}; + const query = {op: "article", method: "getmetadatabyid", id: Article.getActive()}; xhrPost("backend.php", query, (transport) => { const reply = JSON.parse(transport.responseText); diff --git a/plugins/note/init.php b/plugins/note/init.php index 3c2ca0075..d5b231190 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -65,7 +65,7 @@ class Note extends Plugin { WHERE ref_id = ? AND owner_uid = ?"); $sth->execute([$note, $id, $_SESSION['uid']]); - $formatted_note = Article::format_article_note($id, $note); + $formatted_note = Article::_format_note_html($id, $note); print json_encode(array("note" => $formatted_note, "raw_length" => mb_strlen($note))); |