2019-03-01 09:50:31 +00:00
|
|
|
<?php
|
|
|
|
|
2019-05-18 19:05:13 +00:00
|
|
|
namespace Friendica\Module\Diagnostic;
|
2019-03-01 09:50:31 +00:00
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
|
|
|
use Friendica\Core\L10n;
|
|
|
|
use Friendica\Core\Renderer;
|
|
|
|
use Friendica\Model;
|
|
|
|
use Friendica\Protocol;
|
|
|
|
use Friendica\Util\Network;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests a given feed of a contact
|
|
|
|
*/
|
2019-05-18 19:05:13 +00:00
|
|
|
class Feed extends BaseModule
|
2019-03-01 09:50:31 +00:00
|
|
|
{
|
|
|
|
public static function init()
|
|
|
|
{
|
|
|
|
if (!local_user()) {
|
|
|
|
info(L10n::t('You must be logged in to use this module'));
|
|
|
|
self::getApp()->internalRedirect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function content()
|
|
|
|
{
|
|
|
|
$result = [];
|
|
|
|
if (!empty($_REQUEST['url'])) {
|
|
|
|
$url = $_REQUEST['url'];
|
|
|
|
|
|
|
|
$importer = Model\User::getById(local_user());
|
|
|
|
|
|
|
|
$contact_id = Model\Contact::getIdForURL($url, local_user(), true);
|
|
|
|
$contact = Model\Contact::getById($contact_id);
|
|
|
|
|
|
|
|
$xml = Network::fetchUrl($contact['poll']);
|
|
|
|
|
|
|
|
$dummy = null;
|
|
|
|
$import_result = Protocol\Feed::import($xml, $importer, $contact, $dummy, true);
|
|
|
|
|
|
|
|
$result = [
|
|
|
|
'input' => $xml,
|
|
|
|
'output' => var_export($import_result, true),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$tpl = Renderer::getMarkupTemplate('feedtest.tpl');
|
|
|
|
return Renderer::replaceMacros($tpl, [
|
|
|
|
'$url' => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
|
|
|
|
'$result' => $result
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|