init.php 758 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class Af_Fontanka extends Plugin {
  3. function about() {
  4. return array(1.0,
  5. "Gets full text content from fontanka.ru RSS feed",
  6. "fox");
  7. }
  8. function init($host) {
  9. $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
  10. }
  11. function hook_article_filter($article) {
  12. if (strpos($article["link"], ".fontanka.ru") !== FALSE) {
  13. $tmp = fetch_file_contents(["url" => $article["link"]]);
  14. if ($tmp) {
  15. $doc = new DOMDocument("1.0", "UTF-8");
  16. if ([email protected]$doc->loadHTML($tmp))
  17. return false;
  18. $xpath = new DOMXPath($doc);
  19. $base_node = $xpath->query("//article")->item(0);
  20. if ($base_node) {
  21. $article["content"] = $doc->saveHTML($base_node);
  22. }
  23. }
  24. }
  25. return $article;
  26. }
  27. function api_version() {
  28. return 2;
  29. }
  30. }