From 17e0d6b6c1b742ae5546ab800bb5914676011403 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 10 Mar 2018 12:43:34 -0500 Subject: [PATCH] Add feedtest module --- mod/feedtest.php | 49 +++++++++++++++++++++++++++++++++++++ view/templates/feedtest.tpl | 30 +++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 mod/feedtest.php create mode 100644 view/templates/feedtest.tpl diff --git a/mod/feedtest.php b/mod/feedtest.php new file mode 100644 index 0000000000..671ff5df50 --- /dev/null +++ b/mod/feedtest.php @@ -0,0 +1,49 @@ +page['template'] = "wide-2-columns"; + $result = []; + if (!empty($_REQUEST['url'])) { + $url = $_REQUEST['url']; + + $importer = dba::selectFirst('user', [], ['uid' => local_user()]); + + $contact_id = Contact::getIdForURL($url, local_user(), true); + + $contact = dba::selectFirst('contact', [], ['id' => $contact_id]); + + $ret = Network::curl($contact['poll']); + $xml = $ret['body']; + + $dummy = null; + $import_result = Feed::import($xml, $importer, $contact, $dummy, true); + + $result = [ + 'input' => text_highlight($xml, 'xml'), + 'output' => var_export($import_result, true), + ]; + } + + $tpl = get_markup_template('feedtest.tpl'); + $o = replace_macros($tpl, [ + '$url' => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''], + '$result' => $result + ]); + + return $o; +} diff --git a/view/templates/feedtest.tpl b/view/templates/feedtest.tpl new file mode 100644 index 0000000000..2147198f1d --- /dev/null +++ b/view/templates/feedtest.tpl @@ -0,0 +1,30 @@ +

Feed Test

+
+
+
+ {{include file="field_input.tpl" field=$url}} +
+

+
+
+ +{{if $result}} +
+
+
+

Output Items

+
+
+
{{$result.output}}
+
+
+
+
+

Input Feed XML

+
+
+ {{$result.input}} +
+
+
+{{/if}} \ No newline at end of file -- 2.39.5