Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1KB

  1. <?php
  2. /**
  3. * @file_tag_list_to_file mod/feedtest.php
  4. */
  5. use Friendica\App;
  6. use Friendica\Core\L10n;
  7. use Friendica\Core\Renderer;
  8. use Friendica\Database\DBA;
  9. use Friendica\Model\Contact;
  10. use Friendica\Protocol\Feed;
  11. use Friendica\Util\Network;
  12. function feedtest_content(App $a)
  13. {
  14. if (!local_user()) {
  15. info(L10n::t('You must be logged in to use this module'));
  16. return;
  17. };
  18. $result = [];
  19. if (!empty($_REQUEST['url'])) {
  20. $url = $_REQUEST['url'];
  21. $importer = DBA::selectFirst('user', [], ['uid' => local_user()]);
  22. $contact_id = Contact::getIdForURL($url, local_user(), true);
  23. $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
  24. $xml = Network::fetchUrl($contact['poll']);
  25. $dummy = null;
  26. $import_result = Feed::import($xml, $importer, $contact, $dummy, true);
  27. $result = [
  28. 'input' => text_highlight($xml, 'xml'),
  29. 'output' => var_export($import_result, true),
  30. ];
  31. }
  32. $tpl = Renderer::getMarkupTemplate('feedtest.tpl');
  33. $o = Renderer::replaceMacros($tpl, [
  34. '$url' => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
  35. '$result' => $result
  36. ]);
  37. return $o;
  38. }