@@ -26,8 +26,10 @@ |
||
26 | 26 | if ($error) { |
27 | 27 | foreach (libxml_get_errors() as $error) { |
28 | 28 | if ($error->level == LIBXML_ERR_FATAL) { |
29 | - if (!isset($this->error)) //currently only the first error is reported |
|
29 | + if (!isset($this->error)) { |
|
30 | + //currently only the first error is reported |
|
30 | 31 | $this->error = $this->format_error($error); |
32 | + } |
|
31 | 33 | $this->libxml_errors [] = $this->format_error($error); |
32 | 34 | } |
33 | 35 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | $er = error_reporting(E_ALL); |
25 | 25 | |
26 | 26 | switch (DB_TYPE) { |
27 | - case "mysql": |
|
28 | - $this->adapter = new Db_Mysqli(); |
|
29 | - break; |
|
30 | - case "pgsql": |
|
31 | - $this->adapter = new Db_Pgsql(); |
|
32 | - break; |
|
33 | - default: |
|
34 | - die("Unknown DB_TYPE: ".DB_TYPE); |
|
27 | + case "mysql": |
|
28 | + $this->adapter = new Db_Mysqli(); |
|
29 | + break; |
|
30 | + case "pgsql": |
|
31 | + $this->adapter = new Db_Pgsql(); |
|
32 | + break; |
|
33 | + default: |
|
34 | + die("Unknown DB_TYPE: ".DB_TYPE); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | if (!$this->adapter) { |
@@ -1364,35 +1364,35 @@ |
||
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | switch ($rule["type"]) { |
1367 | - case "title": |
|
1368 | - $match = @preg_match("/$reg_exp/iu", $title); |
|
1369 | - break; |
|
1370 | - case "content": |
|
1371 | - // we don't need to deal with multiline regexps |
|
1372 | - $content = preg_replace("/[\r\n\t]/", "", $content); |
|
1367 | + case "title": |
|
1368 | + $match = @preg_match("/$reg_exp/iu", $title); |
|
1369 | + break; |
|
1370 | + case "content": |
|
1371 | + // we don't need to deal with multiline regexps |
|
1372 | + $content = preg_replace("/[\r\n\t]/", "", $content); |
|
1373 | 1373 | |
1374 | - $match = @preg_match("/$reg_exp/iu", $content); |
|
1375 | - break; |
|
1376 | - case "both": |
|
1377 | - // we don't need to deal with multiline regexps |
|
1378 | - $content = preg_replace("/[\r\n\t]/", "", $content); |
|
1374 | + $match = @preg_match("/$reg_exp/iu", $content); |
|
1375 | + break; |
|
1376 | + case "both": |
|
1377 | + // we don't need to deal with multiline regexps |
|
1378 | + $content = preg_replace("/[\r\n\t]/", "", $content); |
|
1379 | 1379 | |
1380 | - $match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content)); |
|
1381 | - break; |
|
1382 | - case "link": |
|
1383 | - $match = @preg_match("/$reg_exp/iu", $link); |
|
1384 | - break; |
|
1385 | - case "author": |
|
1386 | - $match = @preg_match("/$reg_exp/iu", $author); |
|
1387 | - break; |
|
1388 | - case "tag": |
|
1389 | - foreach ($tags as $tag) { |
|
1390 | - if (@preg_match("/$reg_exp/iu", $tag)) { |
|
1391 | - $match = true; |
|
1392 | - break; |
|
1393 | - } |
|
1380 | + $match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content)); |
|
1381 | + break; |
|
1382 | + case "link": |
|
1383 | + $match = @preg_match("/$reg_exp/iu", $link); |
|
1384 | + break; |
|
1385 | + case "author": |
|
1386 | + $match = @preg_match("/$reg_exp/iu", $author); |
|
1387 | + break; |
|
1388 | + case "tag": |
|
1389 | + foreach ($tags as $tag) { |
|
1390 | + if (@preg_match("/$reg_exp/iu", $tag)) { |
|
1391 | + $match = true; |
|
1392 | + break; |
|
1394 | 1393 | } |
1395 | - break; |
|
1394 | + } |
|
1395 | + break; |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | if ($rule_inverse) { |
@@ -616,10 +616,15 @@ |
||
616 | 616 | Debug::log("link $entry_link", Debug::$LOG_VERBOSE); |
617 | 617 | Debug::log("language $entry_language", Debug::$LOG_VERBOSE); |
618 | 618 | |
619 | - if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp); ; |
|
619 | + if (!$entry_title) { |
|
620 | + $entry_title = date("Y-m-d H:i:s", $entry_timestamp); |
|
621 | + } |
|
622 | + ; |
|
620 | 623 | |
621 | 624 | $entry_content = $item->get_content(); |
622 | - if (!$entry_content) $entry_content = $item->get_description(); |
|
625 | + if (!$entry_content) { |
|
626 | + $entry_content = $item->get_description(); |
|
627 | + } |
|
623 | 628 | |
624 | 629 | if (Debug::get_loglevel() >= 3) { |
625 | 630 | print "content: "; |
@@ -765,101 +765,101 @@ |
||
765 | 765 | <a href="index.php"><?php echo __("Return to Tiny Tiny RSS") ?></a> |
766 | 766 | </form> |
767 | 767 | <?php |
768 | - } else { |
|
769 | - |
|
770 | - $rc = Feeds::subscribe_to_feed($feed_url); |
|
771 | - $feed_urls = false; |
|
772 | - |
|
773 | - switch ($rc['code']) { |
|
774 | - case 0: |
|
775 | - print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); |
|
776 | - break; |
|
777 | - case 1: |
|
778 | - print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); |
|
779 | - break; |
|
780 | - case 2: |
|
781 | - print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url)); |
|
782 | - break; |
|
783 | - case 3: |
|
784 | - print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url)); |
|
785 | - break; |
|
786 | - case 4: |
|
787 | - $feed_urls = $rc["feeds"]; |
|
788 | - break; |
|
789 | - case 5: |
|
790 | - print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url)); |
|
791 | - break; |
|
792 | - } |
|
768 | + } else { |
|
793 | 769 | |
794 | - if ($feed_urls) { |
|
770 | + $rc = Feeds::subscribe_to_feed($feed_url); |
|
771 | + $feed_urls = false; |
|
772 | + |
|
773 | + switch ($rc['code']) { |
|
774 | + case 0: |
|
775 | + print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); |
|
776 | + break; |
|
777 | + case 1: |
|
778 | + print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); |
|
779 | + break; |
|
780 | + case 2: |
|
781 | + print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url)); |
|
782 | + break; |
|
783 | + case 3: |
|
784 | + print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url)); |
|
785 | + break; |
|
786 | + case 4: |
|
787 | + $feed_urls = $rc["feeds"]; |
|
788 | + break; |
|
789 | + case 5: |
|
790 | + print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url)); |
|
791 | + break; |
|
792 | + } |
|
795 | 793 | |
796 | - print "<form action='public.php'>"; |
|
797 | - print "<input type='hidden' name='op' value='subscribe'>"; |
|
794 | + if ($feed_urls) { |
|
798 | 795 | |
799 | - print "<fieldset>"; |
|
800 | - print "<label style='display : inline'>".__("Multiple feed URLs found:")."</label>"; |
|
801 | - print "<select name='feed_url' dojoType='dijit.form.Select'>"; |
|
796 | + print "<form action='public.php'>"; |
|
797 | + print "<input type='hidden' name='op' value='subscribe'>"; |
|
802 | 798 | |
803 | - foreach ($feed_urls as $url => $name) { |
|
804 | - $url = htmlspecialchars($url); |
|
805 | - $name = htmlspecialchars($name); |
|
799 | + print "<fieldset>"; |
|
800 | + print "<label style='display : inline'>".__("Multiple feed URLs found:")."</label>"; |
|
801 | + print "<select name='feed_url' dojoType='dijit.form.Select'>"; |
|
806 | 802 | |
807 | - print "<option value=\"$url\">$name</option>"; |
|
808 | - } |
|
803 | + foreach ($feed_urls as $url => $name) { |
|
804 | + $url = htmlspecialchars($url); |
|
805 | + $name = htmlspecialchars($name); |
|
809 | 806 | |
810 | - print "</select>"; |
|
811 | - print "</fieldset>"; |
|
807 | + print "<option value=\"$url\">$name</option>"; |
|
808 | + } |
|
812 | 809 | |
813 | - print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>"; |
|
814 | - print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>"; |
|
810 | + print "</select>"; |
|
811 | + print "</fieldset>"; |
|
815 | 812 | |
816 | - print "</form>"; |
|
817 | - } |
|
813 | + print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>"; |
|
814 | + print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>"; |
|
818 | 815 | |
819 | - $tp_uri = get_self_url_prefix()."/prefs.php"; |
|
816 | + print "</form>"; |
|
817 | + } |
|
818 | + |
|
819 | + $tp_uri = get_self_url_prefix()."/prefs.php"; |
|
820 | 820 | |
821 | - if ($rc['code'] <= 2) { |
|
822 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
821 | + if ($rc['code'] <= 2) { |
|
822 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
823 | 823 | feed_url = ? AND owner_uid = ?"); |
824 | - $sth->execute([$feed_url, $_SESSION['uid']]); |
|
825 | - $row = $sth->fetch(); |
|
824 | + $sth->execute([$feed_url, $_SESSION['uid']]); |
|
825 | + $row = $sth->fetch(); |
|
826 | 826 | |
827 | - $feed_id = $row["id"]; |
|
828 | - } else { |
|
829 | - $feed_id = 0; |
|
830 | - } |
|
827 | + $feed_id = $row["id"]; |
|
828 | + } else { |
|
829 | + $feed_id = 0; |
|
830 | + } |
|
831 | 831 | |
832 | - if ($feed_id) { |
|
833 | - print "<form method='GET' action=\"$tp_uri\"> |
|
832 | + if ($feed_id) { |
|
833 | + print "<form method='GET' action=\"$tp_uri\"> |
|
834 | 834 | <input type='hidden' name='tab' value='feedConfig'> |
835 | 835 | <input type='hidden' name='method' value='editfeed'> |
836 | 836 | <input type='hidden' name='methodparam' value='$feed_id'> |
837 | 837 | <button dojoType='dijit.form.Button' class='alt-info' type='submit'>".__("Edit subscription options")."</button> |
838 | 838 | <a href='index.php'>".__("Return to Tiny Tiny RSS")."</a> |
839 | 839 | </form>"; |
840 | - } |
|
841 | - } |
|
840 | + } |
|
841 | + } |
|
842 | 842 | |
843 | - print "</div></div></body></html>"; |
|
843 | + print "</div></div></body></html>"; |
|
844 | 844 | |
845 | - } else { |
|
846 | - render_login_form(); |
|
847 | - } |
|
848 | - } |
|
845 | + } else { |
|
846 | + render_login_form(); |
|
847 | + } |
|
848 | + } |
|
849 | 849 | |
850 | - public function index() { |
|
851 | - header("Content-Type: text/plain"); |
|
852 | - print error_json(13); |
|
853 | - } |
|
850 | + public function index() { |
|
851 | + header("Content-Type: text/plain"); |
|
852 | + print error_json(13); |
|
853 | + } |
|
854 | 854 | |
855 | - public function forgotpass() { |
|
856 | - startup_gettext(); |
|
857 | - session_start(); |
|
855 | + public function forgotpass() { |
|
856 | + startup_gettext(); |
|
857 | + session_start(); |
|
858 | 858 | |
859 | - @$hash = clean($_REQUEST["hash"]); |
|
859 | + @$hash = clean($_REQUEST["hash"]); |
|
860 | 860 | |
861 | - header('Content-Type: text/html; charset=utf-8'); |
|
862 | - ?> |
|
861 | + header('Content-Type: text/html; charset=utf-8'); |
|
862 | + ?> |
|
863 | 863 | <!DOCTYPE html> |
864 | 864 | <html> |
865 | 865 | <head> |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | |
223 | 223 | $override_order = false; |
224 | 224 | switch (clean($_REQUEST["order_by"])) { |
225 | - case "title": |
|
226 | - $override_order = "ttrss_entries.title, date_entered, updated"; |
|
227 | - break; |
|
228 | - case "date_reverse": |
|
229 | - $override_order = "score DESC, date_entered, updated"; |
|
230 | - $skip_first_id_check = true; |
|
231 | - break; |
|
232 | - case "feed_dates": |
|
233 | - $override_order = "updated DESC"; |
|
234 | - break; |
|
225 | + case "title": |
|
226 | + $override_order = "ttrss_entries.title, date_entered, updated"; |
|
227 | + break; |
|
228 | + case "date_reverse": |
|
229 | + $override_order = "score DESC, date_entered, updated"; |
|
230 | + $skip_first_id_check = true; |
|
231 | + break; |
|
232 | + case "feed_dates": |
|
233 | + $override_order = "updated DESC"; |
|
234 | + break; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /* do not rely on params below */ |
@@ -263,32 +263,32 @@ discard block |
||
263 | 263 | $set_to = ""; |
264 | 264 | |
265 | 265 | switch ($field_raw) { |
266 | - case 0: |
|
267 | - $field = "marked"; |
|
268 | - $additional_fields = ",last_marked = NOW()"; |
|
269 | - break; |
|
270 | - case 1: |
|
271 | - $field = "published"; |
|
272 | - $additional_fields = ",last_published = NOW()"; |
|
273 | - break; |
|
274 | - case 2: |
|
275 | - $field = "unread"; |
|
276 | - $additional_fields = ",last_read = NOW()"; |
|
277 | - break; |
|
278 | - case 3: |
|
279 | - $field = "note"; |
|
266 | + case 0: |
|
267 | + $field = "marked"; |
|
268 | + $additional_fields = ",last_marked = NOW()"; |
|
269 | + break; |
|
270 | + case 1: |
|
271 | + $field = "published"; |
|
272 | + $additional_fields = ",last_published = NOW()"; |
|
273 | + break; |
|
274 | + case 2: |
|
275 | + $field = "unread"; |
|
276 | + $additional_fields = ",last_read = NOW()"; |
|
277 | + break; |
|
278 | + case 3: |
|
279 | + $field = "note"; |
|
280 | 280 | }; |
281 | 281 | |
282 | 282 | switch ($mode) { |
283 | - case 1: |
|
284 | - $set_to = "true"; |
|
285 | - break; |
|
286 | - case 0: |
|
287 | - $set_to = "false"; |
|
288 | - break; |
|
289 | - case 2: |
|
290 | - $set_to = "not $field"; |
|
291 | - break; |
|
283 | + case 1: |
|
284 | + $set_to = "true"; |
|
285 | + break; |
|
286 | + case 0: |
|
287 | + $set_to = "false"; |
|
288 | + break; |
|
289 | + case 2: |
|
290 | + $set_to = "not $field"; |
|
291 | + break; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | if ($field == "note") { |
@@ -192,11 +192,15 @@ |
||
192 | 192 | $feed_id = clean($_REQUEST["feed_id"]); |
193 | 193 | if ($feed_id !== "") { |
194 | 194 | |
195 | - if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
|
195 | + if (is_numeric($feed_id)) { |
|
196 | + $feed_id = (int) $feed_id; |
|
197 | + } |
|
196 | 198 | |
197 | 199 | $limit = (int) clean($_REQUEST["limit"]); |
198 | 200 | |
199 | - if (!$limit || $limit >= 200) $limit = 200; |
|
201 | + if (!$limit || $limit >= 200) { |
|
202 | + $limit = 200; |
|
203 | + } |
|
200 | 204 | |
201 | 205 | $offset = (int) clean($_REQUEST["skip"]); |
202 | 206 | $filter = clean($_REQUEST["filter"]); |
@@ -445,10 +445,12 @@ discard block |
||
445 | 445 | |
446 | 446 | if (!$hide_images) { |
447 | 447 | $encsize = ''; |
448 | - if ($entry['height'] > 0) |
|
449 | - $encsize .= ' height="'.intval($entry['height']).'"'; |
|
450 | - if ($entry['width'] > 0) |
|
451 | - $encsize .= ' width="'.intval($entry['width']).'"'; |
|
448 | + if ($entry['height'] > 0) { |
|
449 | + $encsize .= ' height="'.intval($entry['height']).'"'; |
|
450 | + } |
|
451 | + if ($entry['width'] > 0) { |
|
452 | + $encsize .= ' width="'.intval($entry['width']).'"'; |
|
453 | + } |
|
452 | 454 | $rv .= "<p><img |
453 | 455 | alt=\"".htmlspecialchars($entry["filename"])."\" |
454 | 456 | src=\"" .htmlspecialchars($entry["url"])."\" |
@@ -480,15 +482,17 @@ discard block |
||
480 | 482 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
481 | 483 | |
482 | 484 | foreach ($entries as $entry) { |
483 | - if ($entry["title"]) |
|
484 | - $title = " — ".truncate_string($entry["title"], 30); |
|
485 | - else |
|
486 | - $title = ""; |
|
487 | - |
|
488 | - if ($entry["filename"]) |
|
489 | - $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
490 | - else |
|
491 | - $filename = ""; |
|
485 | + if ($entry["title"]) { |
|
486 | + $title = " — ".truncate_string($entry["title"], 30); |
|
487 | + } else { |
|
488 | + $title = ""; |
|
489 | + } |
|
490 | + |
|
491 | + if ($entry["filename"]) { |
|
492 | + $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
493 | + } else { |
|
494 | + $filename = ""; |
|
495 | + } |
|
492 | 496 | |
493 | 497 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
494 | 498 | dojoType=\"dijit.MenuItem\">".$filename.$title."</div>"; |
@@ -176,12 +176,16 @@ |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | - if (!$tr_in_progress) $pdo->commit(); |
|
179 | + if (!$tr_in_progress) { |
|
180 | + $pdo->commit(); |
|
181 | + } |
|
180 | 182 | } |
181 | 183 | |
182 | 184 | public static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
183 | 185 | |
184 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
186 | + if (!$owner_uid) { |
|
187 | + $owner_uid = $_SESSION['uid']; |
|
188 | + } |
|
185 | 189 | |
186 | 190 | $pdo = Db::pdo(); |
187 | 191 |
@@ -1,210 +1,210 @@ |
||
1 | 1 | <?php |
2 | 2 | abstract class FeedItem_Common extends FeedItem { |
3 | - protected $elem; |
|
4 | - protected $xpath; |
|
5 | - protected $doc; |
|
6 | - |
|
7 | - public function __construct($elem, $doc, $xpath) { |
|
8 | - $this->elem = $elem; |
|
9 | - $this->xpath = $xpath; |
|
10 | - $this->doc = $doc; |
|
11 | - |
|
12 | - try { |
|
3 | + protected $elem; |
|
4 | + protected $xpath; |
|
5 | + protected $doc; |
|
6 | + |
|
7 | + public function __construct($elem, $doc, $xpath) { |
|
8 | + $this->elem = $elem; |
|
9 | + $this->xpath = $xpath; |
|
10 | + $this->doc = $doc; |
|
11 | + |
|
12 | + try { |
|
13 | 13 | |
14 | - $source = $elem->getElementsByTagName("source")->item(0); |
|
14 | + $source = $elem->getElementsByTagName("source")->item(0); |
|
15 | 15 | |
16 | - // we don't need <source> element |
|
17 | - if ($source) { |
|
18 | - $elem->removeChild($source); |
|
19 | - } |
|
20 | - } catch (DOMException $e) { |
|
21 | - // |
|
22 | - } |
|
23 | - } |
|
16 | + // we don't need <source> element |
|
17 | + if ($source) { |
|
18 | + $elem->removeChild($source); |
|
19 | + } |
|
20 | + } catch (DOMException $e) { |
|
21 | + // |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - public function get_element() { |
|
26 | - return $this->elem; |
|
27 | - } |
|
25 | + public function get_element() { |
|
26 | + return $this->elem; |
|
27 | + } |
|
28 | 28 | |
29 | - public function get_author() { |
|
30 | - $author = $this->elem->getElementsByTagName("author")->item(0); |
|
29 | + public function get_author() { |
|
30 | + $author = $this->elem->getElementsByTagName("author")->item(0); |
|
31 | 31 | |
32 | - if ($author) { |
|
33 | - $name = $author->getElementsByTagName("name")->item(0); |
|
32 | + if ($author) { |
|
33 | + $name = $author->getElementsByTagName("name")->item(0); |
|
34 | 34 | |
35 | - if ($name) { |
|
36 | - return clean($name->nodeValue); |
|
37 | - } |
|
38 | - |
|
39 | - $email = $author->getElementsByTagName("email")->item(0); |
|
40 | - |
|
41 | - if ($email) { |
|
42 | - return clean($email->nodeValue); |
|
43 | - } |
|
44 | - |
|
45 | - if ($author->nodeValue) { |
|
46 | - return clean($author->nodeValue); |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - $author_elems = $this->xpath->query("dc:creator", $this->elem); |
|
51 | - $authors = []; |
|
52 | - |
|
53 | - foreach ($author_elems as $author) { |
|
54 | - array_push($authors, clean($author->nodeValue)); |
|
55 | - } |
|
56 | - |
|
57 | - return implode(", ", $authors); |
|
58 | - } |
|
59 | - |
|
60 | - public function get_comments_url() { |
|
61 | - //RSS only. Use a query here to avoid namespace clashes (e.g. with slash). |
|
62 | - //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
|
63 | - $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
|
35 | + if ($name) { |
|
36 | + return clean($name->nodeValue); |
|
37 | + } |
|
38 | + |
|
39 | + $email = $author->getElementsByTagName("email")->item(0); |
|
40 | + |
|
41 | + if ($email) { |
|
42 | + return clean($email->nodeValue); |
|
43 | + } |
|
44 | + |
|
45 | + if ($author->nodeValue) { |
|
46 | + return clean($author->nodeValue); |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + $author_elems = $this->xpath->query("dc:creator", $this->elem); |
|
51 | + $authors = []; |
|
52 | + |
|
53 | + foreach ($author_elems as $author) { |
|
54 | + array_push($authors, clean($author->nodeValue)); |
|
55 | + } |
|
56 | + |
|
57 | + return implode(", ", $authors); |
|
58 | + } |
|
59 | + |
|
60 | + public function get_comments_url() { |
|
61 | + //RSS only. Use a query here to avoid namespace clashes (e.g. with slash). |
|
62 | + //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
|
63 | + $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
|
64 | 64 | |
65 | - if ($com_url) { |
|
66 | - return clean($com_url->nodeValue); |
|
67 | - } |
|
65 | + if ($com_url) { |
|
66 | + return clean($com_url->nodeValue); |
|
67 | + } |
|
68 | 68 | |
69 | - //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
|
70 | - //'text/html' for type is too restrictive? |
|
71 | - $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
|
72 | - |
|
73 | - if ($com_url) { |
|
74 | - return clean($com_url->nodeValue); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - public function get_comments_count() { |
|
79 | - //also query for ATE stuff here |
|
80 | - $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count"; |
|
81 | - $comments = $this->xpath->query($query, $this->elem)->item(0); |
|
82 | - |
|
83 | - if ($comments) { |
|
84 | - return clean($comments->nodeValue); |
|
85 | - } |
|
86 | - } |
|
69 | + //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
|
70 | + //'text/html' for type is too restrictive? |
|
71 | + $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
|
72 | + |
|
73 | + if ($com_url) { |
|
74 | + return clean($com_url->nodeValue); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + public function get_comments_count() { |
|
79 | + //also query for ATE stuff here |
|
80 | + $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count"; |
|
81 | + $comments = $this->xpath->query($query, $this->elem)->item(0); |
|
82 | + |
|
83 | + if ($comments) { |
|
84 | + return clean($comments->nodeValue); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | - // this is common for both Atom and RSS types and deals with various media: elements |
|
89 | - public function get_enclosures() { |
|
90 | - $encs = []; |
|
91 | - |
|
92 | - $enclosures = $this->xpath->query("media:content", $this->elem); |
|
88 | + // this is common for both Atom and RSS types and deals with various media: elements |
|
89 | + public function get_enclosures() { |
|
90 | + $encs = []; |
|
91 | + |
|
92 | + $enclosures = $this->xpath->query("media:content", $this->elem); |
|
93 | 93 | |
94 | - foreach ($enclosures as $enclosure) { |
|
95 | - $enc = new FeedEnclosure(); |
|
94 | + foreach ($enclosures as $enclosure) { |
|
95 | + $enc = new FeedEnclosure(); |
|
96 | 96 | |
97 | - $enc->type = clean($enclosure->getAttribute("type")); |
|
98 | - $enc->link = clean($enclosure->getAttribute("url")); |
|
99 | - $enc->length = clean($enclosure->getAttribute("length")); |
|
100 | - $enc->height = clean($enclosure->getAttribute("height")); |
|
101 | - $enc->width = clean($enclosure->getAttribute("width")); |
|
97 | + $enc->type = clean($enclosure->getAttribute("type")); |
|
98 | + $enc->link = clean($enclosure->getAttribute("url")); |
|
99 | + $enc->length = clean($enclosure->getAttribute("length")); |
|
100 | + $enc->height = clean($enclosure->getAttribute("height")); |
|
101 | + $enc->width = clean($enclosure->getAttribute("width")); |
|
102 | 102 | |
103 | - $medium = clean($enclosure->getAttribute("medium")); |
|
104 | - if (!$enc->type && $medium) { |
|
105 | - $enc->type = strtolower("$medium/generic"); |
|
106 | - } |
|
103 | + $medium = clean($enclosure->getAttribute("medium")); |
|
104 | + if (!$enc->type && $medium) { |
|
105 | + $enc->type = strtolower("$medium/generic"); |
|
106 | + } |
|
107 | 107 | |
108 | - $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
109 | - if ($desc) { |
|
110 | - $enc->title = clean($desc->nodeValue); |
|
111 | - } |
|
108 | + $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
109 | + if ($desc) { |
|
110 | + $enc->title = clean($desc->nodeValue); |
|
111 | + } |
|
112 | 112 | |
113 | - array_push($encs, $enc); |
|
114 | - } |
|
113 | + array_push($encs, $enc); |
|
114 | + } |
|
115 | 115 | |
116 | - $enclosures = $this->xpath->query("media:group", $this->elem); |
|
116 | + $enclosures = $this->xpath->query("media:group", $this->elem); |
|
117 | 117 | |
118 | - foreach ($enclosures as $enclosure) { |
|
119 | - $enc = new FeedEnclosure(); |
|
118 | + foreach ($enclosures as $enclosure) { |
|
119 | + $enc = new FeedEnclosure(); |
|
120 | 120 | |
121 | - $content = $this->xpath->query("media:content", $enclosure)->item(0); |
|
121 | + $content = $this->xpath->query("media:content", $enclosure)->item(0); |
|
122 | 122 | |
123 | - if ($content) { |
|
124 | - $enc->type = clean($content->getAttribute("type")); |
|
125 | - $enc->link = clean($content->getAttribute("url")); |
|
126 | - $enc->length = clean($content->getAttribute("length")); |
|
127 | - $enc->height = clean($content->getAttribute("height")); |
|
128 | - $enc->width = clean($content->getAttribute("width")); |
|
123 | + if ($content) { |
|
124 | + $enc->type = clean($content->getAttribute("type")); |
|
125 | + $enc->link = clean($content->getAttribute("url")); |
|
126 | + $enc->length = clean($content->getAttribute("length")); |
|
127 | + $enc->height = clean($content->getAttribute("height")); |
|
128 | + $enc->width = clean($content->getAttribute("width")); |
|
129 | 129 | |
130 | - $medium = clean($content->getAttribute("medium")); |
|
131 | - if (!$enc->type && $medium) { |
|
132 | - $enc->type = strtolower("$medium/generic"); |
|
133 | - } |
|
130 | + $medium = clean($content->getAttribute("medium")); |
|
131 | + if (!$enc->type && $medium) { |
|
132 | + $enc->type = strtolower("$medium/generic"); |
|
133 | + } |
|
134 | 134 | |
135 | - $desc = $this->xpath->query("media:description", $content)->item(0); |
|
136 | - if ($desc) { |
|
137 | - $enc->title = clean($desc->nodeValue); |
|
138 | - } else { |
|
139 | - $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
140 | - if ($desc) { |
|
141 | - $enc->title = clean($desc->nodeValue); |
|
142 | - } |
|
143 | - } |
|
135 | + $desc = $this->xpath->query("media:description", $content)->item(0); |
|
136 | + if ($desc) { |
|
137 | + $enc->title = clean($desc->nodeValue); |
|
138 | + } else { |
|
139 | + $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
140 | + if ($desc) { |
|
141 | + $enc->title = clean($desc->nodeValue); |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - array_push($encs, $enc); |
|
146 | - } |
|
147 | - } |
|
145 | + array_push($encs, $enc); |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
|
149 | + $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
|
150 | 150 | |
151 | - foreach ($enclosures as $enclosure) { |
|
152 | - $enc = new FeedEnclosure(); |
|
151 | + foreach ($enclosures as $enclosure) { |
|
152 | + $enc = new FeedEnclosure(); |
|
153 | 153 | |
154 | - $enc->type = "image/generic"; |
|
155 | - $enc->link = clean($enclosure->getAttribute("url")); |
|
156 | - $enc->height = clean($enclosure->getAttribute("height")); |
|
157 | - $enc->width = clean($enclosure->getAttribute("width")); |
|
154 | + $enc->type = "image/generic"; |
|
155 | + $enc->link = clean($enclosure->getAttribute("url")); |
|
156 | + $enc->height = clean($enclosure->getAttribute("height")); |
|
157 | + $enc->width = clean($enclosure->getAttribute("width")); |
|
158 | 158 | |
159 | - array_push($encs, $enc); |
|
160 | - } |
|
159 | + array_push($encs, $enc); |
|
160 | + } |
|
161 | 161 | |
162 | - return $encs; |
|
163 | - } |
|
162 | + return $encs; |
|
163 | + } |
|
164 | 164 | |
165 | - public function count_children($node) { |
|
166 | - return $node->getElementsByTagName("*")->length; |
|
167 | - } |
|
165 | + public function count_children($node) { |
|
166 | + return $node->getElementsByTagName("*")->length; |
|
167 | + } |
|
168 | 168 | |
169 | - public function subtree_or_text($node) { |
|
170 | - if ($this->count_children($node) == 0) { |
|
171 | - return $node->nodeValue; |
|
172 | - } else { |
|
173 | - return $node->c14n(); |
|
174 | - } |
|
175 | - } |
|
169 | + public function subtree_or_text($node) { |
|
170 | + if ($this->count_children($node) == 0) { |
|
171 | + return $node->nodeValue; |
|
172 | + } else { |
|
173 | + return $node->c14n(); |
|
174 | + } |
|
175 | + } |
|
176 | 176 | |
177 | - public static function normalize_categories($cats) { |
|
177 | + public static function normalize_categories($cats) { |
|
178 | 178 | |
179 | - $tmp = []; |
|
179 | + $tmp = []; |
|
180 | 180 | |
181 | - foreach ($cats as $rawcat) { |
|
182 | - $tmp = array_merge($tmp, explode(",", $rawcat)); |
|
183 | - } |
|
181 | + foreach ($cats as $rawcat) { |
|
182 | + $tmp = array_merge($tmp, explode(",", $rawcat)); |
|
183 | + } |
|
184 | 184 | |
185 | - $tmp = array_map(function($srccat) { |
|
186 | - $cat = clean(trim(mb_strtolower($srccat))); |
|
185 | + $tmp = array_map(function($srccat) { |
|
186 | + $cat = clean(trim(mb_strtolower($srccat))); |
|
187 | 187 | |
188 | - // we don't support numeric tags |
|
189 | - if (is_numeric($cat)) { |
|
190 | - $cat = 't:'.$cat; |
|
191 | - } |
|
188 | + // we don't support numeric tags |
|
189 | + if (is_numeric($cat)) { |
|
190 | + $cat = 't:'.$cat; |
|
191 | + } |
|
192 | 192 | |
193 | - $cat = preg_replace('/[,\'\"]/', "", $cat); |
|
193 | + $cat = preg_replace('/[,\'\"]/', "", $cat); |
|
194 | 194 | |
195 | - if (DB_TYPE == "mysql") { |
|
196 | - $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
|
197 | - } |
|
195 | + if (DB_TYPE == "mysql") { |
|
196 | + $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
|
197 | + } |
|
198 | 198 | |
199 | - if (mb_strlen($cat) > 250) { |
|
200 | - $cat = mb_substr($cat, 0, 250); |
|
201 | - } |
|
199 | + if (mb_strlen($cat) > 250) { |
|
200 | + $cat = mb_substr($cat, 0, 250); |
|
201 | + } |
|
202 | 202 | |
203 | - return $cat; |
|
204 | - }, $tmp); |
|
203 | + return $cat; |
|
204 | + }, $tmp); |
|
205 | 205 | |
206 | - asort($tmp); |
|
206 | + asort($tmp); |
|
207 | 207 | |
208 | - return array_unique($tmp); |
|
209 | - } |
|
208 | + return array_unique($tmp); |
|
209 | + } |
|
210 | 210 | } |
@@ -64,14 +64,14 @@ |
||
64 | 64 | $tmp = ''; |
65 | 65 | foreach (str_split($keys[$i]) as $c) { |
66 | 66 | switch ($c) { |
67 | - case '*': |
|
68 | - $tmp .= __('Shift').'+'; |
|
69 | - break; |
|
70 | - case '^': |
|
71 | - $tmp .= __('Ctrl').'+'; |
|
72 | - break; |
|
73 | - default: |
|
74 | - $tmp .= $c; |
|
67 | + case '*': |
|
68 | + $tmp .= __('Shift').'+'; |
|
69 | + break; |
|
70 | + case '^': |
|
71 | + $tmp .= __('Ctrl').'+'; |
|
72 | + break; |
|
73 | + default: |
|
74 | + $tmp .= $c; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | $keys[$i] = $tmp; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | if ($cur_section) { |
46 | 46 | print "<li> </li>"; |
47 | 47 | } |
48 | - print "<li><h3>" . $section . "</h3></li>"; |
|
48 | + print "<li><h3>".$section."</h3></li>"; |
|
49 | 49 | $cur_section = $section; |
50 | 50 | |
51 | 51 | foreach ($hotkeys as $action => $description) { |