miniflux-legacy/app/handlers/opml.php

35 lines
894 B
PHP
Raw Normal View History

2016-08-24 03:38:09 +02:00
<?php
2016-08-25 03:17:58 +02:00
namespace Miniflux\Handler\Opml;
2016-08-24 03:38:09 +02:00
2016-08-25 03:17:58 +02:00
use Miniflux\Model\Feed;
use Miniflux\Model\Group;
2016-08-24 03:38:09 +02:00
use PicoFeed\Serialization\Subscription;
use PicoFeed\Serialization\SubscriptionList;
use PicoFeed\Serialization\SubscriptionListBuilder;
function export_all_feeds()
{
$feeds = Feed\get_all();
$subscriptionList = SubscriptionList::create()->setTitle(t('Subscriptions'));
foreach ($feeds as $feed) {
$groups = Group\get_feed_groups($feed['id']);
$category = '';
if (!empty($groups)) {
$category = $groups[0]['title'];
}
$subscriptionList->addSubscription(Subscription::create()
->setTitle($feed['title'])
->setSiteUrl($feed['site_url'])
->setFeedUrl($feed['feed_url'])
->setCategory($category)
);
}
return SubscriptionListBuilder::create($subscriptionList)->build();
}