2018-03-10 18:43:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file_tag_list_to_file mod/feedtest.php
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Friendica\App;
|
|
|
|
use Friendica\Core\L10n;
|
2018-07-20 14:19:26 +02:00
|
|
|
use Friendica\Database\DBA;
|
2018-03-10 18:43:34 +01:00
|
|
|
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)
|
|
|
|
{
|
2018-03-11 00:53:20 +01:00
|
|
|
if (!local_user()) {
|
|
|
|
info(L10n::t('You must be logged in to use this module'));
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
2018-03-10 18:43:34 +01:00
|
|
|
$result = [];
|
|
|
|
if (!empty($_REQUEST['url'])) {
|
|
|
|
$url = $_REQUEST['url'];
|
|
|
|
|
2018-07-20 14:19:26 +02:00
|
|
|
$importer = DBA::selectFirst('user', [], ['uid' => local_user()]);
|
2018-03-10 18:43:34 +01:00
|
|
|
|
|
|
|
$contact_id = Contact::getIdForURL($url, local_user(), true);
|
|
|
|
|
2018-07-20 14:19:26 +02:00
|
|
|
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
|
2018-03-10 18:43:34 +01:00
|
|
|
|
2018-10-10 21:08:43 +02:00
|
|
|
$xml = Network::fetchUrl($contact['poll']);
|
2018-03-10 18:43:34 +01:00
|
|
|
|
|
|
|
$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;
|
|
|
|
}
|