@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php |
2 | 2 | class Swap_JK extends Plugin { |
3 | 3 | |
4 | - private $host; |
|
4 | + private $host; |
|
5 | 5 | |
6 | - public function about() { |
|
7 | - return array(1.0, |
|
8 | - "Swap j and k hotkeys (for vi brethren)", |
|
9 | - "fox"); |
|
10 | - } |
|
6 | + public function about() { |
|
7 | + return array(1.0, |
|
8 | + "Swap j and k hotkeys (for vi brethren)", |
|
9 | + "fox"); |
|
10 | + } |
|
11 | 11 | |
12 | - public function init($host) { |
|
13 | - $this->host = $host; |
|
12 | + public function init($host) { |
|
13 | + $this->host = $host; |
|
14 | 14 | |
15 | - $host->add_hook($host::HOOK_HOTKEY_MAP, $this); |
|
16 | - } |
|
15 | + $host->add_hook($host::HOOK_HOTKEY_MAP, $this); |
|
16 | + } |
|
17 | 17 | |
18 | - public function hook_hotkey_map($hotkeys) { |
|
18 | + public function hook_hotkey_map($hotkeys) { |
|
19 | 19 | |
20 | - $hotkeys["j"] = "next_feed"; |
|
21 | - $hotkeys["k"] = "prev_feed"; |
|
20 | + $hotkeys["j"] = "next_feed"; |
|
21 | + $hotkeys["k"] = "prev_feed"; |
|
22 | 22 | |
23 | - return $hotkeys; |
|
24 | - } |
|
23 | + return $hotkeys; |
|
24 | + } |
|
25 | 25 | |
26 | - public function api_version() { |
|
27 | - return 2; |
|
28 | - } |
|
26 | + public function api_version() { |
|
27 | + return 2; |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
@@ -4,65 +4,65 @@ discard block |
||
4 | 4 | |
5 | 5 | class Af_Readability extends Plugin { |
6 | 6 | |
7 | - /* @var PluginHost $host */ |
|
8 | - private $host; |
|
7 | + /* @var PluginHost $host */ |
|
8 | + private $host; |
|
9 | 9 | |
10 | - public function about() { |
|
11 | - return array(1.0, |
|
12 | - "Try to inline article content using Readability", |
|
13 | - "fox"); |
|
14 | - } |
|
10 | + public function about() { |
|
11 | + return array(1.0, |
|
12 | + "Try to inline article content using Readability", |
|
13 | + "fox"); |
|
14 | + } |
|
15 | 15 | |
16 | - public function flags() { |
|
17 | - return array("needs_curl" => true); |
|
18 | - } |
|
16 | + public function flags() { |
|
17 | + return array("needs_curl" => true); |
|
18 | + } |
|
19 | 19 | |
20 | - public function save() { |
|
21 | - $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]); |
|
20 | + public function save() { |
|
21 | + $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]); |
|
22 | 22 | |
23 | - $this->host->set($this, "enable_share_anything", $enable_share_anything); |
|
23 | + $this->host->set($this, "enable_share_anything", $enable_share_anything); |
|
24 | 24 | |
25 | - echo __("Data saved."); |
|
26 | - } |
|
25 | + echo __("Data saved."); |
|
26 | + } |
|
27 | 27 | |
28 | - public function init($host) |
|
29 | - { |
|
30 | - $this->host = $host; |
|
28 | + public function init($host) |
|
29 | + { |
|
30 | + $this->host = $host; |
|
31 | 31 | |
32 | - if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
33 | - user_error("af_readability requires PHP 7.0", E_USER_WARNING); |
|
34 | - return; |
|
35 | - } |
|
32 | + if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
33 | + user_error("af_readability requires PHP 7.0", E_USER_WARNING); |
|
34 | + return; |
|
35 | + } |
|
36 | 36 | |
37 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
38 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
39 | - $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); |
|
40 | - $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); |
|
37 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
38 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
39 | + $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); |
|
40 | + $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); |
|
41 | 41 | |
42 | - // Note: we have to install the hook even if disabled because init() is being run before plugin data has loaded |
|
43 | - // so we can't check for our storage-set options here |
|
44 | - $host->add_hook($host::HOOK_GET_FULL_TEXT, $this); |
|
42 | + // Note: we have to install the hook even if disabled because init() is being run before plugin data has loaded |
|
43 | + // so we can't check for our storage-set options here |
|
44 | + $host->add_hook($host::HOOK_GET_FULL_TEXT, $this); |
|
45 | 45 | |
46 | - $host->add_filter_action($this, "action_inline", __("Inline content")); |
|
47 | - } |
|
46 | + $host->add_filter_action($this, "action_inline", __("Inline content")); |
|
47 | + } |
|
48 | 48 | |
49 | - public function hook_prefs_tab($args) { |
|
50 | - if ($args != "prefFeeds") return; |
|
49 | + public function hook_prefs_tab($args) { |
|
50 | + if ($args != "prefFeeds") return; |
|
51 | 51 | |
52 | - print "<div dojoType='dijit.layout.AccordionPane' |
|
52 | + print "<div dojoType='dijit.layout.AccordionPane' |
|
53 | 53 | title=\"<i class='material-icons'>extension</i> ".__('Readability settings (af_readability)')."\">"; |
54 | 54 | |
55 | - if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
56 | - print_error("This plugin requires PHP 7.0."); |
|
57 | - } else { |
|
55 | + if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
56 | + print_error("This plugin requires PHP 7.0."); |
|
57 | + } else { |
|
58 | 58 | |
59 | - print "<h2>" . __("Global settings") . "</h2>"; |
|
59 | + print "<h2>" . __("Global settings") . "</h2>"; |
|
60 | 60 | |
61 | - print_notice("Enable for specific feeds in the feed editor."); |
|
61 | + print_notice("Enable for specific feeds in the feed editor."); |
|
62 | 62 | |
63 | - print "<form dojoType='dijit.form.Form'>"; |
|
63 | + print "<form dojoType='dijit.form.Form'>"; |
|
64 | 64 | |
65 | - print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
65 | + print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
66 | 66 | evt.preventDefault(); |
67 | 67 | if (this.validate()) { |
68 | 68 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -76,212 +76,212 @@ discard block |
||
76 | 76 | } |
77 | 77 | </script>"; |
78 | 78 | |
79 | - print_hidden("op", "pluginhandler"); |
|
80 | - print_hidden("method", "save"); |
|
81 | - print_hidden("plugin", "af_readability"); |
|
79 | + print_hidden("op", "pluginhandler"); |
|
80 | + print_hidden("method", "save"); |
|
81 | + print_hidden("plugin", "af_readability"); |
|
82 | 82 | |
83 | - $enable_share_anything = $this->host->get($this, "enable_share_anything"); |
|
83 | + $enable_share_anything = $this->host->get($this, "enable_share_anything"); |
|
84 | 84 | |
85 | - print "<fieldset>"; |
|
86 | - print "<label class='checkbox'> "; |
|
87 | - print_checkbox("enable_share_anything", $enable_share_anything); |
|
88 | - print " " . __("Provide full-text services to core code (bookmarklets) and other plugins"); |
|
89 | - print "</label>"; |
|
90 | - print "</fieldset>"; |
|
85 | + print "<fieldset>"; |
|
86 | + print "<label class='checkbox'> "; |
|
87 | + print_checkbox("enable_share_anything", $enable_share_anything); |
|
88 | + print " " . __("Provide full-text services to core code (bookmarklets) and other plugins"); |
|
89 | + print "</label>"; |
|
90 | + print "</fieldset>"; |
|
91 | 91 | |
92 | - print_button("submit", __("Save"), "class='alt-primary'"); |
|
93 | - print "</form>"; |
|
92 | + print_button("submit", __("Save"), "class='alt-primary'"); |
|
93 | + print "</form>"; |
|
94 | 94 | |
95 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
96 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
95 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
96 | + if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
97 | 97 | |
98 | - $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
|
99 | - $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
98 | + $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
|
99 | + $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
100 | 100 | |
101 | - if (count($enabled_feeds) > 0) { |
|
102 | - print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; |
|
101 | + if (count($enabled_feeds) > 0) { |
|
102 | + print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>"; |
|
103 | 103 | |
104 | - print "<ul class='panel panel-scrollable list list-unstyled'>"; |
|
105 | - foreach ($enabled_feeds as $f) { |
|
106 | - print "<li><i class='material-icons'>rss_feed</i> <a href='#' |
|
104 | + print "<ul class='panel panel-scrollable list list-unstyled'>"; |
|
105 | + foreach ($enabled_feeds as $f) { |
|
106 | + print "<li><i class='material-icons'>rss_feed</i> <a href='#' |
|
107 | 107 | onclick='CommonDialogs.editFeed($f)'>". |
108 | - Feeds::getFeedTitle($f) . "</a></li>"; |
|
109 | - } |
|
110 | - print "</ul>"; |
|
111 | - } |
|
108 | + Feeds::getFeedTitle($f) . "</a></li>"; |
|
109 | + } |
|
110 | + print "</ul>"; |
|
111 | + } |
|
112 | 112 | |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | - print "</div>"; |
|
116 | - } |
|
115 | + print "</div>"; |
|
116 | + } |
|
117 | 117 | |
118 | - public function hook_prefs_edit_feed($feed_id) { |
|
119 | - print "<header>".__("Readability")."</header>"; |
|
120 | - print "<section>"; |
|
118 | + public function hook_prefs_edit_feed($feed_id) { |
|
119 | + print "<header>".__("Readability")."</header>"; |
|
120 | + print "<section>"; |
|
121 | 121 | |
122 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
123 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
122 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
123 | + if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
124 | 124 | |
125 | - $key = array_search($feed_id, $enabled_feeds); |
|
126 | - $checked = $key !== FALSE ? "checked" : ""; |
|
125 | + $key = array_search($feed_id, $enabled_feeds); |
|
126 | + $checked = $key !== FALSE ? "checked" : ""; |
|
127 | 127 | |
128 | - print "<fieldset>"; |
|
128 | + print "<fieldset>"; |
|
129 | 129 | |
130 | - print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_readability_enabled' |
|
130 | + print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_readability_enabled' |
|
131 | 131 | name='af_readability_enabled' $checked> ".__('Inline article content')."</label>"; |
132 | 132 | |
133 | - print "</fieldset>"; |
|
133 | + print "</fieldset>"; |
|
134 | 134 | |
135 | - print "</section>"; |
|
136 | - } |
|
135 | + print "</section>"; |
|
136 | + } |
|
137 | 137 | |
138 | - public function hook_prefs_save_feed($feed_id) { |
|
139 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
140 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
138 | + public function hook_prefs_save_feed($feed_id) { |
|
139 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
140 | + if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
141 | 141 | |
142 | - $enable = checkbox_to_sql_bool($_POST["af_readability_enabled"]); |
|
143 | - $key = array_search($feed_id, $enabled_feeds); |
|
142 | + $enable = checkbox_to_sql_bool($_POST["af_readability_enabled"]); |
|
143 | + $key = array_search($feed_id, $enabled_feeds); |
|
144 | 144 | |
145 | - if ($enable) { |
|
146 | - if ($key === FALSE) { |
|
147 | - array_push($enabled_feeds, $feed_id); |
|
148 | - } |
|
149 | - } else { |
|
150 | - if ($key !== FALSE) { |
|
151 | - unset($enabled_feeds[$key]); |
|
152 | - } |
|
153 | - } |
|
145 | + if ($enable) { |
|
146 | + if ($key === FALSE) { |
|
147 | + array_push($enabled_feeds, $feed_id); |
|
148 | + } |
|
149 | + } else { |
|
150 | + if ($key !== FALSE) { |
|
151 | + unset($enabled_feeds[$key]); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
156 | - } |
|
155 | + $this->host->set($this, "enabled_feeds", $enabled_feeds); |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
160 | - */ |
|
161 | - public function hook_article_filter_action($article, $action) { |
|
162 | - return $this->process_article($article); |
|
163 | - } |
|
158 | + /** |
|
159 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
160 | + */ |
|
161 | + public function hook_article_filter_action($article, $action) { |
|
162 | + return $this->process_article($article); |
|
163 | + } |
|
164 | 164 | |
165 | - public function extract_content($url) { |
|
165 | + public function extract_content($url) { |
|
166 | 166 | |
167 | - global $fetch_effective_url; |
|
167 | + global $fetch_effective_url; |
|
168 | 168 | |
169 | - $tmp = fetch_file_contents([ |
|
170 | - "url" => $url, |
|
171 | - "http_accept" => "text/*", |
|
172 | - "type" => "text/html"]); |
|
169 | + $tmp = fetch_file_contents([ |
|
170 | + "url" => $url, |
|
171 | + "http_accept" => "text/*", |
|
172 | + "type" => "text/html"]); |
|
173 | 173 | |
174 | - if ($tmp && mb_strlen($tmp) < 1024 * 500) { |
|
175 | - $tmpdoc = new DOMDocument("1.0", "UTF-8"); |
|
174 | + if ($tmp && mb_strlen($tmp) < 1024 * 500) { |
|
175 | + $tmpdoc = new DOMDocument("1.0", "UTF-8"); |
|
176 | 176 | |
177 | - if (!@$tmpdoc->loadHTML($tmp)) |
|
178 | - return false; |
|
177 | + if (!@$tmpdoc->loadHTML($tmp)) |
|
178 | + return false; |
|
179 | 179 | |
180 | - // this is the worst hack yet :( |
|
181 | - if (strtolower($tmpdoc->encoding) != 'utf-8') { |
|
182 | - $tmp = preg_replace("/<meta.*?charset.*?\/?>/i", "", $tmp); |
|
183 | - if (empty($tmpdoc->encoding)) { |
|
184 | - $tmp = mb_convert_encoding($tmp, 'utf-8'); |
|
185 | - } else { |
|
186 | - $tmp = mb_convert_encoding($tmp, 'utf-8', $tmpdoc->encoding); |
|
187 | - } |
|
188 | - } |
|
180 | + // this is the worst hack yet :( |
|
181 | + if (strtolower($tmpdoc->encoding) != 'utf-8') { |
|
182 | + $tmp = preg_replace("/<meta.*?charset.*?\/?>/i", "", $tmp); |
|
183 | + if (empty($tmpdoc->encoding)) { |
|
184 | + $tmp = mb_convert_encoding($tmp, 'utf-8'); |
|
185 | + } else { |
|
186 | + $tmp = mb_convert_encoding($tmp, 'utf-8', $tmpdoc->encoding); |
|
187 | + } |
|
188 | + } |
|
189 | 189 | |
190 | - try { |
|
191 | - $r = new Readability(new Configuration()); |
|
190 | + try { |
|
191 | + $r = new Readability(new Configuration()); |
|
192 | 192 | |
193 | - if ($r->parse($tmp)) { |
|
193 | + if ($r->parse($tmp)) { |
|
194 | 194 | |
195 | - $tmpxpath = new DOMXPath($r->getDOMDOcument()); |
|
196 | - $entries = $tmpxpath->query('(//a[@href]|//img[@src])'); |
|
195 | + $tmpxpath = new DOMXPath($r->getDOMDOcument()); |
|
196 | + $entries = $tmpxpath->query('(//a[@href]|//img[@src])'); |
|
197 | 197 | |
198 | - foreach ($entries as $entry) { |
|
199 | - if ($entry->hasAttribute("href")) { |
|
200 | - $entry->setAttribute("href", |
|
201 | - rewrite_relative_url($fetch_effective_url, $entry->getAttribute("href"))); |
|
198 | + foreach ($entries as $entry) { |
|
199 | + if ($entry->hasAttribute("href")) { |
|
200 | + $entry->setAttribute("href", |
|
201 | + rewrite_relative_url($fetch_effective_url, $entry->getAttribute("href"))); |
|
202 | 202 | |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | - if ($entry->hasAttribute("src")) { |
|
206 | - $entry->setAttribute("src", |
|
207 | - rewrite_relative_url($fetch_effective_url, $entry->getAttribute("src"))); |
|
205 | + if ($entry->hasAttribute("src")) { |
|
206 | + $entry->setAttribute("src", |
|
207 | + rewrite_relative_url($fetch_effective_url, $entry->getAttribute("src"))); |
|
208 | 208 | |
209 | - } |
|
210 | - } |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - return $r->getContent(); |
|
213 | - } |
|
212 | + return $r->getContent(); |
|
213 | + } |
|
214 | 214 | |
215 | - } catch (Exception $e) { |
|
216 | - return false; |
|
217 | - } |
|
218 | - } |
|
215 | + } catch (Exception $e) { |
|
216 | + return false; |
|
217 | + } |
|
218 | + } |
|
219 | 219 | |
220 | - return false; |
|
221 | - } |
|
220 | + return false; |
|
221 | + } |
|
222 | 222 | |
223 | - public function process_article($article) { |
|
223 | + public function process_article($article) { |
|
224 | 224 | |
225 | - $extracted_content = $this->extract_content($article["link"]); |
|
225 | + $extracted_content = $this->extract_content($article["link"]); |
|
226 | 226 | |
227 | - # let's see if there's anything of value in there |
|
228 | - $content_test = trim(strip_tags(sanitize($extracted_content))); |
|
227 | + # let's see if there's anything of value in there |
|
228 | + $content_test = trim(strip_tags(sanitize($extracted_content))); |
|
229 | 229 | |
230 | - if ($content_test) { |
|
231 | - $article["content"] = $extracted_content; |
|
232 | - } |
|
230 | + if ($content_test) { |
|
231 | + $article["content"] = $extracted_content; |
|
232 | + } |
|
233 | 233 | |
234 | - return $article; |
|
235 | - } |
|
234 | + return $article; |
|
235 | + } |
|
236 | 236 | |
237 | - public function hook_article_filter($article) { |
|
237 | + public function hook_article_filter($article) { |
|
238 | 238 | |
239 | - $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
240 | - if (!is_array($enabled_feeds)) return $article; |
|
239 | + $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
|
240 | + if (!is_array($enabled_feeds)) return $article; |
|
241 | 241 | |
242 | - $key = array_search($article["feed"]["id"], $enabled_feeds); |
|
243 | - if ($key === FALSE) return $article; |
|
242 | + $key = array_search($article["feed"]["id"], $enabled_feeds); |
|
243 | + if ($key === FALSE) return $article; |
|
244 | 244 | |
245 | - return $this->process_article($article); |
|
245 | + return $this->process_article($article); |
|
246 | 246 | |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | - public function hook_get_full_text($link) |
|
250 | - { |
|
251 | - $enable_share_anything = $this->host->get($this, "enable_share_anything"); |
|
249 | + public function hook_get_full_text($link) |
|
250 | + { |
|
251 | + $enable_share_anything = $this->host->get($this, "enable_share_anything"); |
|
252 | 252 | |
253 | - if ($enable_share_anything) { |
|
254 | - $extracted_content = $this->extract_content($link); |
|
253 | + if ($enable_share_anything) { |
|
254 | + $extracted_content = $this->extract_content($link); |
|
255 | 255 | |
256 | - # let's see if there's anything of value in there |
|
257 | - $content_test = trim(strip_tags(sanitize($extracted_content))); |
|
256 | + # let's see if there's anything of value in there |
|
257 | + $content_test = trim(strip_tags(sanitize($extracted_content))); |
|
258 | 258 | |
259 | - if ($content_test) { |
|
260 | - return $extracted_content; |
|
261 | - } |
|
262 | - } |
|
259 | + if ($content_test) { |
|
260 | + return $extracted_content; |
|
261 | + } |
|
262 | + } |
|
263 | 263 | |
264 | - return false; |
|
265 | - } |
|
264 | + return false; |
|
265 | + } |
|
266 | 266 | |
267 | - public function api_version() { |
|
268 | - return 2; |
|
269 | - } |
|
267 | + public function api_version() { |
|
268 | + return 2; |
|
269 | + } |
|
270 | 270 | |
271 | - private function filter_unknown_feeds($enabled_feeds) { |
|
272 | - $tmp = array(); |
|
271 | + private function filter_unknown_feeds($enabled_feeds) { |
|
272 | + $tmp = array(); |
|
273 | 273 | |
274 | - foreach ($enabled_feeds as $feed) { |
|
274 | + foreach ($enabled_feeds as $feed) { |
|
275 | 275 | |
276 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
|
277 | - $sth->execute([$feed, $_SESSION['uid']]); |
|
276 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
|
277 | + $sth->execute([$feed, $_SESSION['uid']]); |
|
278 | 278 | |
279 | - if ($row = $sth->fetch()) { |
|
280 | - array_push($tmp, $feed); |
|
281 | - } |
|
282 | - } |
|
279 | + if ($row = $sth->fetch()) { |
|
280 | + array_push($tmp, $feed); |
|
281 | + } |
|
282 | + } |
|
283 | 283 | |
284 | - return $tmp; |
|
285 | - } |
|
284 | + return $tmp; |
|
285 | + } |
|
286 | 286 | |
287 | 287 | } |
@@ -1,56 +1,56 @@ |
||
1 | 1 | <?php |
2 | 2 | class Bookmarklets extends Plugin { |
3 | - private $host; |
|
3 | + private $host; |
|
4 | 4 | |
5 | - function about() { |
|
5 | + function about() { |
|
6 | 6 | return array(1.0, |
7 | - "Easy feed subscription and web page sharing using bookmarklets", |
|
8 | - "fox", |
|
9 | - false, |
|
10 | - "https://git.tt-rss.org/fox/tt-rss/wiki/ShareAnything"); |
|
11 | - } |
|
7 | + "Easy feed subscription and web page sharing using bookmarklets", |
|
8 | + "fox", |
|
9 | + false, |
|
10 | + "https://git.tt-rss.org/fox/tt-rss/wiki/ShareAnything"); |
|
11 | + } |
|
12 | 12 | |
13 | - function init($host) { |
|
13 | + function init($host) { |
|
14 | 14 | $this->host = $host; |
15 | 15 | |
16 | 16 | $host->add_hook($host::HOOK_PREFS_TAB, $this); |
17 | - } |
|
17 | + } |
|
18 | 18 | |
19 | - function hook_prefs_tab($args) { |
|
19 | + function hook_prefs_tab($args) { |
|
20 | 20 | if ($args == "prefFeeds") { |
21 | 21 | |
22 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
22 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
23 | 23 | title=\"<i class='material-icons'>bookmark</i> ".__('Bookmarklets')."\">"; |
24 | 24 | |
25 | - print "<h3>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</h3>"; |
|
25 | + print "<h3>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</h3>"; |
|
26 | 26 | |
27 | - $bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url()); |
|
27 | + $bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url()); |
|
28 | 28 | |
29 | - $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); |
|
29 | + $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); |
|
30 | 30 | |
31 | - $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); |
|
31 | + $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); |
|
32 | 32 | |
33 | - print "<p><label class='dijitButton'>"; |
|
34 | - print "<a href=\"$bm_url\">" . __('Subscribe in Tiny Tiny RSS'). "</a>"; |
|
35 | - print "</label></p>"; |
|
33 | + print "<p><label class='dijitButton'>"; |
|
34 | + print "<a href=\"$bm_url\">" . __('Subscribe in Tiny Tiny RSS'). "</a>"; |
|
35 | + print "</label></p>"; |
|
36 | 36 | |
37 | - print "<h3>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</h3>"; |
|
37 | + print "<h3>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</h3>"; |
|
38 | 38 | |
39 | - print "<label class='dijitButton'>"; |
|
40 | - $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); |
|
41 | - print "<a href=\"$bm_url\">" . __('Share with Tiny Tiny RSS'). "</a>"; |
|
42 | - print "</label>"; |
|
39 | + print "<label class='dijitButton'>"; |
|
40 | + $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); |
|
41 | + print "<a href=\"$bm_url\">" . __('Share with Tiny Tiny RSS'). "</a>"; |
|
42 | + print "</label>"; |
|
43 | 43 | |
44 | - print "<button dojoType='dijit.form.Button' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ShareAnything\")'> |
|
44 | + print "<button dojoType='dijit.form.Button' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ShareAnything\")'> |
|
45 | 45 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
46 | 46 | |
47 | - print "</div>"; #pane |
|
47 | + print "</div>"; #pane |
|
48 | 48 | |
49 | - } |
|
50 | - } |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - public function api_version() { |
|
53 | - return 2; |
|
54 | - } |
|
52 | + public function api_version() { |
|
53 | + return 2; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
@@ -1,95 +1,95 @@ |
||
1 | 1 | <?php |
2 | 2 | class MailTo extends Plugin { |
3 | - private $host; |
|
3 | + private $host; |
|
4 | 4 | |
5 | - public function about() { |
|
6 | - return array(1.0, |
|
7 | - "Share article via email (using mailto: links, invoking your mail client)", |
|
8 | - "fox"); |
|
9 | - } |
|
5 | + public function about() { |
|
6 | + return array(1.0, |
|
7 | + "Share article via email (using mailto: links, invoking your mail client)", |
|
8 | + "fox"); |
|
9 | + } |
|
10 | 10 | |
11 | - public function init($host) { |
|
12 | - $this->host = $host; |
|
11 | + public function init($host) { |
|
12 | + $this->host = $host; |
|
13 | 13 | |
14 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
15 | - } |
|
14 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
15 | + } |
|
16 | 16 | |
17 | - public function get_js() { |
|
18 | - return file_get_contents(dirname(__FILE__) . "/init.js"); |
|
19 | - } |
|
17 | + public function get_js() { |
|
18 | + return file_get_contents(dirname(__FILE__) . "/init.js"); |
|
19 | + } |
|
20 | 20 | |
21 | - public function hook_article_button($line) { |
|
22 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
21 | + public function hook_article_button($line) { |
|
22 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
23 | 23 | onclick=\"Plugins.Mailto.send(".$line["id"].")\" |
24 | 24 | title='".__('Forward by email')."'>mail_outline</i>"; |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | - public function emailArticle() { |
|
27 | + public function emailArticle() { |
|
28 | 28 | |
29 | - $ids = explode(",", $_REQUEST['param']); |
|
30 | - $ids_qmarks = arr_qmarks($ids); |
|
29 | + $ids = explode(",", $_REQUEST['param']); |
|
30 | + $ids_qmarks = arr_qmarks($ids); |
|
31 | 31 | |
32 | - require_once "lib/MiniTemplator.class.php"; |
|
32 | + require_once "lib/MiniTemplator.class.php"; |
|
33 | 33 | |
34 | - $tpl = new MiniTemplator; |
|
34 | + $tpl = new MiniTemplator; |
|
35 | 35 | |
36 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
36 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
37 | 37 | |
38 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
39 | - //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
40 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
38 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
39 | + //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
40 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
41 | 41 | |
42 | 42 | |
43 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
43 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
44 | 44 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
45 | 45 | id IN ($ids_qmarks) AND owner_uid = ?"); |
46 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
46 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
47 | 47 | |
48 | - if (count($ids) > 1) { |
|
49 | - $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
50 | - } else { |
|
51 | - $subject = ""; |
|
52 | - } |
|
48 | + if (count($ids) > 1) { |
|
49 | + $subject = __("[Forwarded]") . " " . __("Multiple articles"); |
|
50 | + } else { |
|
51 | + $subject = ""; |
|
52 | + } |
|
53 | 53 | |
54 | - while ($line = $sth->fetch()) { |
|
54 | + while ($line = $sth->fetch()) { |
|
55 | 55 | |
56 | - if (!$subject) |
|
57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
56 | + if (!$subject) |
|
57 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
58 | 58 | |
59 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
60 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
59 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
60 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
61 | 61 | |
62 | - $tpl->addBlock('article'); |
|
63 | - } |
|
62 | + $tpl->addBlock('article'); |
|
63 | + } |
|
64 | 64 | |
65 | - $tpl->addBlock('email'); |
|
65 | + $tpl->addBlock('email'); |
|
66 | 66 | |
67 | - $content = ""; |
|
68 | - $tpl->generateOutputToString($content); |
|
67 | + $content = ""; |
|
68 | + $tpl->generateOutputToString($content); |
|
69 | 69 | |
70 | - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
71 | - "&body=".rawurlencode($content)); |
|
70 | + $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
71 | + "&body=".rawurlencode($content)); |
|
72 | 72 | |
73 | - print __("Clicking the following link to invoke your mail client:"); |
|
73 | + print __("Clicking the following link to invoke your mail client:"); |
|
74 | 74 | |
75 | - print "<div class='panel text-center'>"; |
|
76 | - print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
77 | - __("Forward selected article(s) by email.")."</a>"; |
|
78 | - print "</div>"; |
|
75 | + print "<div class='panel text-center'>"; |
|
76 | + print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
77 | + __("Forward selected article(s) by email.")."</a>"; |
|
78 | + print "</div>"; |
|
79 | 79 | |
80 | - print __("You should be able to edit the message before sending in your mail client."); |
|
80 | + print __("You should be able to edit the message before sending in your mail client."); |
|
81 | 81 | |
82 | - print "<p>"; |
|
82 | + print "<p>"; |
|
83 | 83 | |
84 | - print "<footer class='text-center'>"; |
|
85 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
86 | - print "</footer>"; |
|
84 | + print "<footer class='text-center'>"; |
|
85 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
86 | + print "</footer>"; |
|
87 | 87 | |
88 | - //return; |
|
89 | - } |
|
88 | + //return; |
|
89 | + } |
|
90 | 90 | |
91 | - public function api_version() { |
|
92 | - return 2; |
|
93 | - } |
|
91 | + public function api_version() { |
|
92 | + return 2; |
|
93 | + } |
|
94 | 94 | |
95 | 95 | } |
@@ -1,78 +1,78 @@ |
||
1 | 1 | <?php |
2 | 2 | class Note extends Plugin { |
3 | 3 | |
4 | - /* @var PluginHost $host */ |
|
5 | - private $host; |
|
4 | + /* @var PluginHost $host */ |
|
5 | + private $host; |
|
6 | 6 | |
7 | - public function about() { |
|
8 | - return array(1.0, |
|
9 | - "Adds support for setting article notes", |
|
10 | - "fox"); |
|
11 | - } |
|
7 | + public function about() { |
|
8 | + return array(1.0, |
|
9 | + "Adds support for setting article notes", |
|
10 | + "fox"); |
|
11 | + } |
|
12 | 12 | |
13 | - public function init($host) { |
|
14 | - $this->host = $host; |
|
13 | + public function init($host) { |
|
14 | + $this->host = $host; |
|
15 | 15 | |
16 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
17 | - } |
|
16 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
17 | + } |
|
18 | 18 | |
19 | - public function get_js() { |
|
20 | - return file_get_contents(dirname(__FILE__) . "/note.js"); |
|
21 | - } |
|
19 | + public function get_js() { |
|
20 | + return file_get_contents(dirname(__FILE__) . "/note.js"); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | - public function hook_article_button($line) { |
|
25 | - return "<i class='material-icons' onclick=\"Plugins.Note.edit(".$line["id"].")\" |
|
24 | + public function hook_article_button($line) { |
|
25 | + return "<i class='material-icons' onclick=\"Plugins.Note.edit(".$line["id"].")\" |
|
26 | 26 | style='cursor : pointer' title='".__('Edit article note')."'>note</i>"; |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - public function edit() { |
|
30 | - $param = $_REQUEST['param']; |
|
29 | + public function edit() { |
|
30 | + $param = $_REQUEST['param']; |
|
31 | 31 | |
32 | - $sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE |
|
32 | + $sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE |
|
33 | 33 | ref_id = ? AND owner_uid = ?"); |
34 | - $sth->execute([$param, $_SESSION['uid']]); |
|
34 | + $sth->execute([$param, $_SESSION['uid']]); |
|
35 | 35 | |
36 | - if ($row = $sth->fetch()) { |
|
36 | + if ($row = $sth->fetch()) { |
|
37 | 37 | |
38 | - $note = $row['note']; |
|
38 | + $note = $row['note']; |
|
39 | 39 | |
40 | - print_hidden("id", "$param"); |
|
41 | - print_hidden("op", "pluginhandler"); |
|
42 | - print_hidden("method", "setNote"); |
|
43 | - print_hidden("plugin", "note"); |
|
40 | + print_hidden("id", "$param"); |
|
41 | + print_hidden("op", "pluginhandler"); |
|
42 | + print_hidden("method", "setNote"); |
|
43 | + print_hidden("plugin", "note"); |
|
44 | 44 | |
45 | - print "<textarea dojoType='dijit.form.SimpleTextarea' |
|
45 | + print "<textarea dojoType='dijit.form.SimpleTextarea' |
|
46 | 46 | style='font-size : 12px; width : 98%; height: 100px;' |
47 | 47 | name='note'>$note</textarea>"; |
48 | 48 | |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - print "<footer class='text-center'>"; |
|
52 | - print "<button dojoType=\"dijit.form.Button\" |
|
51 | + print "<footer class='text-center'>"; |
|
52 | + print "<button dojoType=\"dijit.form.Button\" |
|
53 | 53 | onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> "; |
54 | - print "<button dojoType=\"dijit.form.Button\" |
|
54 | + print "<button dojoType=\"dijit.form.Button\" |
|
55 | 55 | onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>"; |
56 | - print "</footer>"; |
|
56 | + print "</footer>"; |
|
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - public function setNote() { |
|
61 | - $id = $_REQUEST["id"]; |
|
62 | - $note = trim(strip_tags($_REQUEST["note"])); |
|
60 | + public function setNote() { |
|
61 | + $id = $_REQUEST["id"]; |
|
62 | + $note = trim(strip_tags($_REQUEST["note"])); |
|
63 | 63 | |
64 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ? |
|
64 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ? |
|
65 | 65 | WHERE ref_id = ? AND owner_uid = ?"); |
66 | - $sth->execute([$note, $id, $_SESSION['uid']]); |
|
66 | + $sth->execute([$note, $id, $_SESSION['uid']]); |
|
67 | 67 | |
68 | - $formatted_note = Article::format_article_note($id, $note); |
|
68 | + $formatted_note = Article::format_article_note($id, $note); |
|
69 | 69 | |
70 | - print json_encode(array("note" => $formatted_note, |
|
71 | - "raw_length" => mb_strlen($note))); |
|
72 | - } |
|
70 | + print json_encode(array("note" => $formatted_note, |
|
71 | + "raw_length" => mb_strlen($note))); |
|
72 | + } |
|
73 | 73 | |
74 | - public function api_version() { |
|
75 | - return 2; |
|
76 | - } |
|
74 | + public function api_version() { |
|
75 | + return 2; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | } |
@@ -1,91 +1,91 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Tumblr_1280 extends Plugin { |
3 | - private $host; |
|
3 | + private $host; |
|
4 | 4 | |
5 | - public function about() { |
|
6 | - return array(1.0, |
|
7 | - "Replace Tumblr pictures and videos with largest size if available (requires CURL)", |
|
8 | - "fox"); |
|
9 | - } |
|
5 | + public function about() { |
|
6 | + return array(1.0, |
|
7 | + "Replace Tumblr pictures and videos with largest size if available (requires CURL)", |
|
8 | + "fox"); |
|
9 | + } |
|
10 | 10 | |
11 | - public function flags() { |
|
12 | - return array("needs_curl" => true); |
|
13 | - } |
|
11 | + public function flags() { |
|
12 | + return array("needs_curl" => true); |
|
13 | + } |
|
14 | 14 | |
15 | - public function init($host) { |
|
16 | - $this->host = $host; |
|
15 | + public function init($host) { |
|
16 | + $this->host = $host; |
|
17 | 17 | |
18 | - if (function_exists("curl_init")) { |
|
19 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
20 | - } |
|
21 | - } |
|
18 | + if (function_exists("curl_init")) { |
|
19 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
20 | + } |
|
21 | + } |
|
22 | 22 | |
23 | - public function hook_article_filter($article) { |
|
23 | + public function hook_article_filter($article) { |
|
24 | 24 | |
25 | - if (!function_exists("curl_init") || ini_get("open_basedir")) |
|
26 | - return $article; |
|
25 | + if (!function_exists("curl_init") || ini_get("open_basedir")) |
|
26 | + return $article; |
|
27 | 27 | |
28 | - $doc = new DOMDocument(); |
|
29 | - $doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
28 | + $doc = new DOMDocument(); |
|
29 | + $doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]); |
|
30 | 30 | |
31 | - $found = false; |
|
31 | + $found = false; |
|
32 | 32 | |
33 | - if ($doc) { |
|
34 | - $xpath = new DOMXpath($doc); |
|
33 | + if ($doc) { |
|
34 | + $xpath = new DOMXpath($doc); |
|
35 | 35 | |
36 | - $images = $xpath->query('(//img[contains(@src, \'media.tumblr.com\')])'); |
|
36 | + $images = $xpath->query('(//img[contains(@src, \'media.tumblr.com\')])'); |
|
37 | 37 | |
38 | - foreach ($images as $img) { |
|
39 | - $src = $img->getAttribute("src"); |
|
38 | + foreach ($images as $img) { |
|
39 | + $src = $img->getAttribute("src"); |
|
40 | 40 | |
41 | - $test_src = preg_replace("/_\d{3}.(jpg|gif|png)/", "_1280.$1", $src); |
|
41 | + $test_src = preg_replace("/_\d{3}.(jpg|gif|png)/", "_1280.$1", $src); |
|
42 | 42 | |
43 | - if ($src != $test_src) { |
|
43 | + if ($src != $test_src) { |
|
44 | 44 | |
45 | - $ch = curl_init($test_src); |
|
46 | - curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
47 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
48 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
49 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
50 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
51 | - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
45 | + $ch = curl_init($test_src); |
|
46 | + curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
47 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
48 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
49 | + curl_setopt($ch, CURLOPT_NOBODY, true); |
|
50 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
51 | + curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
52 | 52 | |
53 | - @$result = curl_exec($ch); |
|
54 | - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
53 | + @$result = curl_exec($ch); |
|
54 | + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
55 | 55 | |
56 | - if ($result && $http_code == 200) { |
|
57 | - $img->setAttribute("src", $test_src); |
|
58 | - $found = true; |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
56 | + if ($result && $http_code == 200) { |
|
57 | + $img->setAttribute("src", $test_src); |
|
58 | + $found = true; |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]'); |
|
63 | + $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]'); |
|
64 | 64 | |
65 | - foreach ($video_sources as $source) { |
|
66 | - $src = $source->getAttribute("src"); |
|
65 | + foreach ($video_sources as $source) { |
|
66 | + $src = $source->getAttribute("src"); |
|
67 | 67 | |
68 | - $new_src = preg_replace("/\/\d{3}$/", "", $src); |
|
68 | + $new_src = preg_replace("/\/\d{3}$/", "", $src); |
|
69 | 69 | |
70 | - if ($src != $new_src) { |
|
71 | - $source->setAttribute("src", $new_src); |
|
72 | - $found = true; |
|
73 | - } |
|
74 | - } |
|
70 | + if ($src != $new_src) { |
|
71 | + $source->setAttribute("src", $new_src); |
|
72 | + $found = true; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - if ($found) { |
|
77 | - $doc->removeChild($doc->firstChild); //remove doctype |
|
78 | - $article["content"] = $doc->saveHTML(); |
|
79 | - } |
|
80 | - } |
|
76 | + if ($found) { |
|
77 | + $doc->removeChild($doc->firstChild); //remove doctype |
|
78 | + $article["content"] = $doc->saveHTML(); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - return $article; |
|
82 | + return $article; |
|
83 | 83 | |
84 | - } |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - public function api_version() { |
|
88 | - return 2; |
|
89 | - } |
|
87 | + public function api_version() { |
|
88 | + return 2; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | class Close_Button extends Plugin { |
3 | - private $host; |
|
4 | - |
|
5 | - public function init($host) { |
|
6 | - $this->host = $host; |
|
7 | - |
|
8 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
9 | - } |
|
10 | - |
|
11 | - public function about() { |
|
12 | - return array(1.0, |
|
13 | - "Adds a button to close article panel", |
|
14 | - "fox"); |
|
15 | - } |
|
16 | - |
|
17 | - public function get_css() { |
|
18 | - return "i.icon-close-article { color : red; }"; |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
23 | - */ |
|
24 | - public function hook_article_button($line) { |
|
25 | - if (!get_pref("COMBINED_DISPLAY_MODE")) { |
|
26 | - $rv = "<i class='material-icons icon-close-article' |
|
3 | + private $host; |
|
4 | + |
|
5 | + public function init($host) { |
|
6 | + $this->host = $host; |
|
7 | + |
|
8 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
9 | + } |
|
10 | + |
|
11 | + public function about() { |
|
12 | + return array(1.0, |
|
13 | + "Adds a button to close article panel", |
|
14 | + "fox"); |
|
15 | + } |
|
16 | + |
|
17 | + public function get_css() { |
|
18 | + return "i.icon-close-article { color : red; }"; |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
23 | + */ |
|
24 | + public function hook_article_button($line) { |
|
25 | + if (!get_pref("COMBINED_DISPLAY_MODE")) { |
|
26 | + $rv = "<i class='material-icons icon-close-article' |
|
27 | 27 | style='cursor : pointer' onclick='Article.close()' |
28 | 28 | title='".__('Close article')."'>close</i>"; |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | - return $rv; |
|
32 | - } |
|
31 | + return $rv; |
|
32 | + } |
|
33 | 33 | |
34 | - public function api_version() { |
|
35 | - return 2; |
|
36 | - } |
|
34 | + public function api_version() { |
|
35 | + return 2; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -1,57 +1,57 @@ |
||
1 | 1 | <?php |
2 | 2 | class Auto_Assign_Labels extends Plugin { |
3 | 3 | |
4 | - /* @var PluginHost $host */ |
|
5 | - private $host; |
|
4 | + /* @var PluginHost $host */ |
|
5 | + private $host; |
|
6 | 6 | |
7 | - public function about() { |
|
8 | - return array(1.0, |
|
9 | - "Assign labels automatically based on article title, content, and tags", |
|
10 | - "fox"); |
|
11 | - } |
|
7 | + public function about() { |
|
8 | + return array(1.0, |
|
9 | + "Assign labels automatically based on article title, content, and tags", |
|
10 | + "fox"); |
|
11 | + } |
|
12 | 12 | |
13 | - public function init($host) { |
|
14 | - $this->host = $host; |
|
13 | + public function init($host) { |
|
14 | + $this->host = $host; |
|
15 | 15 | |
16 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
17 | - } |
|
16 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
17 | + } |
|
18 | 18 | |
19 | - public function get_all_labels_filter_format($owner_uid) { |
|
20 | - $rv = array(); |
|
19 | + public function get_all_labels_filter_format($owner_uid) { |
|
20 | + $rv = array(); |
|
21 | 21 | |
22 | - $sth = $this->pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = ?"); |
|
23 | - $sth->execute([$owner_uid]); |
|
22 | + $sth = $this->pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = ?"); |
|
23 | + $sth->execute([$owner_uid]); |
|
24 | 24 | |
25 | - while ($line = $sth->fetch()) { |
|
26 | - array_push($rv, array(Labels::label_to_feed_id($line["id"]), |
|
27 | - $line["caption"], $line["fg_color"], $line["bg_color"])); |
|
28 | - } |
|
25 | + while ($line = $sth->fetch()) { |
|
26 | + array_push($rv, array(Labels::label_to_feed_id($line["id"]), |
|
27 | + $line["caption"], $line["fg_color"], $line["bg_color"])); |
|
28 | + } |
|
29 | 29 | |
30 | - return $rv; |
|
31 | - } |
|
30 | + return $rv; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - public function hook_article_filter($article) { |
|
34 | + public function hook_article_filter($article) { |
|
35 | 35 | |
36 | - $owner_uid = $article["owner_uid"]; |
|
37 | - $labels = $this->get_all_labels_filter_format($owner_uid); |
|
38 | - $tags_str = join(",", $article["tags"]); |
|
36 | + $owner_uid = $article["owner_uid"]; |
|
37 | + $labels = $this->get_all_labels_filter_format($owner_uid); |
|
38 | + $tags_str = join(",", $article["tags"]); |
|
39 | 39 | |
40 | - foreach ($labels as $label) { |
|
41 | - $caption = preg_quote($label[1], "/"); |
|
40 | + foreach ($labels as $label) { |
|
41 | + $caption = preg_quote($label[1], "/"); |
|
42 | 42 | |
43 | - if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($article["content"]) . " " . $article["title"])) { |
|
43 | + if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($article["content"]) . " " . $article["title"])) { |
|
44 | 44 | |
45 | - if (!RSSUtils::labels_contains_caption($article["labels"], $caption)) { |
|
46 | - array_push($article["labels"], $label); |
|
47 | - } |
|
48 | - } |
|
49 | - } |
|
45 | + if (!RSSUtils::labels_contains_caption($article["labels"], $caption)) { |
|
46 | + array_push($article["labels"], $label); |
|
47 | + } |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - return $article; |
|
52 | - } |
|
51 | + return $article; |
|
52 | + } |
|
53 | 53 | |
54 | - public function api_version() { |
|
55 | - return 2; |
|
56 | - } |
|
54 | + public function api_version() { |
|
55 | + return 2; |
|
56 | + } |
|
57 | 57 | } |
@@ -1,84 +1,84 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Unburn extends Plugin { |
3 | - private $host; |
|
3 | + private $host; |
|
4 | 4 | |
5 | - public function about() { |
|
6 | - return array(1.0, |
|
7 | - "Resolves feedburner and similar feed redirector URLs (requires CURL)", |
|
8 | - "fox"); |
|
9 | - } |
|
5 | + public function about() { |
|
6 | + return array(1.0, |
|
7 | + "Resolves feedburner and similar feed redirector URLs (requires CURL)", |
|
8 | + "fox"); |
|
9 | + } |
|
10 | 10 | |
11 | - public function flags() { |
|
12 | - return array("needs_curl" => true); |
|
13 | - } |
|
11 | + public function flags() { |
|
12 | + return array("needs_curl" => true); |
|
13 | + } |
|
14 | 14 | |
15 | - public function init($host) { |
|
16 | - $this->host = $host; |
|
15 | + public function init($host) { |
|
16 | + $this->host = $host; |
|
17 | 17 | |
18 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
19 | - } |
|
18 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
19 | + } |
|
20 | 20 | |
21 | - public function hook_article_filter($article) { |
|
22 | - $owner_uid = $article["owner_uid"]; |
|
21 | + public function hook_article_filter($article) { |
|
22 | + $owner_uid = $article["owner_uid"]; |
|
23 | 23 | |
24 | - if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) |
|
25 | - return $article; |
|
24 | + if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) |
|
25 | + return $article; |
|
26 | 26 | |
27 | - if ((strpos($article["link"], "feedproxy.google.com") !== FALSE || |
|
28 | - strpos($article["link"], "/~r/") !== FALSE || |
|
29 | - strpos($article["link"], "feedsportal.com") !== FALSE)) { |
|
27 | + if ((strpos($article["link"], "feedproxy.google.com") !== FALSE || |
|
28 | + strpos($article["link"], "/~r/") !== FALSE || |
|
29 | + strpos($article["link"], "feedsportal.com") !== FALSE)) { |
|
30 | 30 | |
31 | - $ch = curl_init($article["link"]); |
|
31 | + $ch = curl_init($article["link"]); |
|
32 | 32 | |
33 | - curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
34 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
35 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
36 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
37 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
38 | - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
33 | + curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
34 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
35 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
36 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
37 | + curl_setopt($ch, CURLOPT_NOBODY, true); |
|
38 | + curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
39 | 39 | |
40 | - if (defined('_CURL_HTTP_PROXY')) { |
|
41 | - curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY); |
|
42 | - } |
|
40 | + if (defined('_CURL_HTTP_PROXY')) { |
|
41 | + curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY); |
|
42 | + } |
|
43 | 43 | |
44 | - @curl_exec($ch); |
|
44 | + @curl_exec($ch); |
|
45 | 45 | |
46 | - $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
|
46 | + $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
|
47 | 47 | |
48 | - curl_close($ch); |
|
48 | + curl_close($ch); |
|
49 | 49 | |
50 | - if ($real_url) { |
|
51 | - /* remove the rest of it */ |
|
50 | + if ($real_url) { |
|
51 | + /* remove the rest of it */ |
|
52 | 52 | |
53 | - $query = parse_url($real_url, PHP_URL_QUERY); |
|
53 | + $query = parse_url($real_url, PHP_URL_QUERY); |
|
54 | 54 | |
55 | - if ($query && strpos($query, "utm_source") !== FALSE) { |
|
56 | - $args = array(); |
|
57 | - parse_str($query, $args); |
|
55 | + if ($query && strpos($query, "utm_source") !== FALSE) { |
|
56 | + $args = array(); |
|
57 | + parse_str($query, $args); |
|
58 | 58 | |
59 | - foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) { |
|
60 | - if (isset($args[$param])) unset($args[$param]); |
|
61 | - } |
|
59 | + foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) { |
|
60 | + if (isset($args[$param])) unset($args[$param]); |
|
61 | + } |
|
62 | 62 | |
63 | - $new_query = http_build_query($args); |
|
63 | + $new_query = http_build_query($args); |
|
64 | 64 | |
65 | - if ($new_query != $query) { |
|
66 | - $real_url = str_replace("?$query", "?$new_query", $real_url); |
|
67 | - } |
|
68 | - } |
|
65 | + if ($new_query != $query) { |
|
66 | + $real_url = str_replace("?$query", "?$new_query", $real_url); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - $real_url = preg_replace("/\?$/", "", $real_url); |
|
70 | + $real_url = preg_replace("/\?$/", "", $real_url); |
|
71 | 71 | |
72 | - $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"]; |
|
73 | - $article["link"] = $real_url; |
|
74 | - } |
|
75 | - } |
|
72 | + $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"]; |
|
73 | + $article["link"] = $real_url; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - return $article; |
|
78 | - } |
|
77 | + return $article; |
|
78 | + } |
|
79 | 79 | |
80 | - public function api_version() { |
|
81 | - return 2; |
|
82 | - } |
|
80 | + public function api_version() { |
|
81 | + return 2; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |