]> git.mxchange.org Git - friendica.git/commitdiff
Add feedtest module
authorHypolite Petovan <mrpetovan@gmail.com>
Sat, 10 Mar 2018 17:43:34 +0000 (12:43 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Sat, 10 Mar 2018 17:43:34 +0000 (12:43 -0500)
mod/feedtest.php [new file with mode: 0644]
view/templates/feedtest.tpl [new file with mode: 0644]

diff --git a/mod/feedtest.php b/mod/feedtest.php
new file mode 100644 (file)
index 0000000..671ff5d
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @file_tag_list_to_file mod/feedtest.php
+ */
+
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Model\Contact;
+use Friendica\Protocol\Feed;
+use Friendica\Util\Network;
+
+require_once 'boot.php';
+require_once 'include/dba.php';
+require_once 'include/text.php';
+
+function feedtest_content(App $a)
+{
+       //$a->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 (file)
index 0000000..2147198
--- /dev/null
@@ -0,0 +1,30 @@
+<h2>Feed Test</h2>
+<form action="feedtest" method="get" class="panel panel-default">
+       <div class="panel-body">
+               <div class="form-group">
+                       {{include file="field_input.tpl" field=$url}}
+               </div>
+               <p><button type="submit" class="btn btn-primary">Submit</button></p>
+       </div>
+</form>
+
+{{if $result}}
+<div class="feedtest-result">
+       <div class="panel panel-default">
+               <div class="panel-heading">
+                       <h3 class="panel-title">Output Items</h3>
+               </div>
+               <div class="panel-body">
+                       <pre>{{$result.output}}</pre>
+               </div>
+       </div>
+       <div class="panel panel-default">
+               <div class="panel-heading">
+                       <h3 class="panel-title">Input Feed XML</h3>
+               </div>
+               <div class="panel-body">
+                       {{$result.input}}
+               </div>
+       </div>
+</div>
+{{/if}}
\ No newline at end of file