From 764555ff8af2ca8f7aad5e882bbf837c6e65cbc7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 21 Mar 2013 14:48:47 +0400 Subject: rework update.php to use getopt; allow --task parameter --- classes/pluginhost.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 79544b01b..710435ae4 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -171,7 +171,7 @@ class PluginHost { } function add_command($command, $description, $sender) { - $command = "-" . str_replace("-", "_", strtolower($command)); + $command = str_replace("-", "_", strtolower($command)); $this->commands[$command] = array("description" => $description, "class" => $sender); @@ -201,7 +201,7 @@ class PluginHost { function run_commands($args) { foreach ($this->get_commands() as $command => $data) { - if (in_array($command, $args)) { + if (isset($args[$command])) { $command = str_replace("-", "", $command); $data["class"]->$command($args); } -- cgit v1.2.3-54-g00ecf From 33de3d37af24f870fe2477d5b358e6f4167077b6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 21 Mar 2013 15:37:08 +0400 Subject: make sure rendering image enclosures respect hide_image setting --- classes/feeds.php | 3 +-- include/functions.php | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'classes') diff --git a/classes/feeds.php b/classes/feeds.php index 79aaa8e55..b8ef1f544 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -637,8 +637,7 @@ class Feeds extends Handler_Protected { $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]); - $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures, - $line["content"]); + $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"])); $reply['content'] .= ""; diff --git a/include/functions.php b/include/functions.php index 7071765ba..72cca500e 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2952,6 +2952,7 @@ $result = db_query($link, "SELECT id,title,link,content,feed_id,comments,int_id, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url, + (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) as hide_images, num_comments, tag_cache, author, @@ -3133,7 +3134,7 @@ $rv['content'] .= $line["content"]; $rv['content'] .= format_article_enclosures($link, $id, - $always_display_enclosures, $line["content"]); + $always_display_enclosures, $line["content"], $line["hide_images"]); $rv['content'] .= ""; @@ -3596,7 +3597,7 @@ } function format_article_enclosures($link, $id, $always_display_enclosures, - $article_content) { + $article_content, $hide_images = false) { $result = get_article_enclosures($link, $id); $rv = ''; @@ -3646,10 +3647,16 @@ if (preg_match("/image/", $entry["type"]) || preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) { - $rv .= "

\"".htmlspecialchars($entry["filename"])."\"

"; + if (!$hide_images) { + $rv .= "

\"".htmlspecialchars($entry["filename"])."\"

"; + } else { + $rv .= "

" .htmlspecialchars($entry["url"]) . "

"; + } } } } -- cgit v1.2.3-54-g00ecf From b6604c96135303a546ff8dcfefdcd804ed4554a6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 21 Mar 2013 18:19:23 +0400 Subject: add HOOK_RENDER_ARTICLE_API (closes #608) --- classes/api.php | 5 +++++ classes/pluginhost.php | 1 + 2 files changed, 6 insertions(+) (limited to 'classes') diff --git a/classes/api.php b/classes/api.php index 5e7ec6573..b9168cf93 100644 --- a/classes/api.php +++ b/classes/api.php @@ -655,6 +655,11 @@ class API extends Handler { $headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]); + global $pluginhost; + foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) { + $headline_row = $p->hook_render_article_api($headline_row); + } + array_push($headlines, $headline_row); } diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 710435ae4..7dabd42a8 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -22,6 +22,7 @@ class PluginHost { const HOOK_RENDER_ARTICLE_CDM = 11; const HOOK_FEED_FETCHED = 12; const HOOK_SANITIZE = 13; + const HOOK_RENDER_ARTICLE_API = 14; const KIND_ALL = 1; const KIND_SYSTEM = 2; -- cgit v1.2.3-54-g00ecf