diff options
Diffstat (limited to 'app/views/helpers/export/opml.phtml')
| -rw-r--r-- | app/views/helpers/export/opml.phtml | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml index d97641fd2..eb6f7523b 100644 --- a/app/views/helpers/export/opml.phtml +++ b/app/views/helpers/export/opml.phtml @@ -9,6 +9,7 @@ function feedsToOutlines($feeds, $excludeMutedFeeds = false): array { if ($feed->mute() && $excludeMutedFeeds) { continue; } + $outline = [ 'text' => htmlspecialchars_decode($feed->name(), ENT_QUOTES), 'type' => FreshRSS_Export_Service::TYPE_RSS_ATOM, @@ -16,49 +17,58 @@ function feedsToOutlines($feeds, $excludeMutedFeeds = false): array { 'htmlUrl' => htmlspecialchars_decode($feed->website(), ENT_QUOTES), 'description' => htmlspecialchars_decode($feed->description(), ENT_QUOTES), ]; + if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH) { $outline['type'] = FreshRSS_Export_Service::TYPE_HTML_XPATH; /** @var array<string,string> */ $xPathSettings = $feed->attributes('xpath'); - $outline['frss:xPathItem'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['item'] ?? null]; - $outline['frss:xPathItemTitle'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemTitle'] ?? null]; - $outline['frss:xPathItemContent'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemContent'] ?? null]; - $outline['frss:xPathItemUri'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemUri'] ?? null]; - $outline['frss:xPathItemAuthor'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemAuthor'] ?? null]; - $outline['frss:xPathItemTimestamp'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemTimestamp'] ?? null]; - $outline['frss:xPathItemTimeformat'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemTimeformat'] ?? null]; - $outline['frss:xPathItemThumbnail'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemThumbnail'] ?? null]; - $outline['frss:xPathItemCategories'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemCategories'] ?? null]; - $outline['frss:xPathItemUid'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $xPathSettings['itemUid'] ?? null]; + $outline['frss:xPathItem'] = $xPathSettings['item'] ?? null; + $outline['frss:xPathItemTitle'] = $xPathSettings['itemTitle'] ?? null; + $outline['frss:xPathItemContent'] = $xPathSettings['itemContent'] ?? null; + $outline['frss:xPathItemUri'] = $xPathSettings['itemUri'] ?? null; + $outline['frss:xPathItemAuthor'] = $xPathSettings['itemAuthor'] ?? null; + $outline['frss:xPathItemTimestamp'] = $xPathSettings['itemTimestamp'] ?? null; + $outline['frss:xPathItemTimeformat'] = $xPathSettings['itemTimeformat'] ?? null; + $outline['frss:xPathItemThumbnail'] = $xPathSettings['itemThumbnail'] ?? null; + $outline['frss:xPathItemCategories'] = $xPathSettings['itemCategories'] ?? null; + $outline['frss:xPathItemUid'] = $xPathSettings['itemUid'] ?? null; } + if (!empty($feed->filtersAction('read'))) { $filters = ''; foreach ($feed->filtersAction('read') as $filterRead) { $filters .= $filterRead->getRawInput() . "\n"; } $filters = trim($filters); - $outline['frss:filtersActionRead'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $filters]; + $outline['frss:filtersActionRead'] = $filters; } + if ($feed->pathEntries() != '') { - $outline['frss:cssFullContent'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => htmlspecialchars_decode($feed->pathEntries(), ENT_QUOTES)]; + $outline['frss:cssFullContent'] = htmlspecialchars_decode($feed->pathEntries(), ENT_QUOTES); } + if ($feed->attributes('path_entries_filter') != '') { - $outline['frss:cssFullContentFilter'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $feed->attributes('path_entries_filter')]; + $outline['frss:cssFullContentFilter'] = $feed->attributes('path_entries_filter'); } + $outlines[] = $outline; } + return $outlines; } /** @var FreshRSS_View $this */ -$opml_array = array( - 'head' => array( +$opml_array = [ + 'namespaces' => [ + 'frss' => FreshRSS_Export_Service::FRSS_NAMESPACE, + ], + 'head' => [ 'title' => FreshRSS_Context::$system_conf->title, - 'dateCreated' => date('D, d M Y H:i:s') - ), - 'body' => array() -); + 'dateCreated' => new DateTime(), + ], + 'body' => [], +]; if (!empty($this->categories)) { foreach ($this->categories as $key => $cat) { @@ -66,9 +76,11 @@ if (!empty($this->categories)) { 'text' => htmlspecialchars_decode($cat->name(), ENT_QUOTES), '@outlines' => feedsToOutlines($cat->feeds(), $this->excludeMutedFeeds), ]; + if ($cat->kind() === FreshRSS_Category::KIND_DYNAMIC_OPML) { - $outline['frss:opmlUrl'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $cat->attributes('opml_url')];; + $outline['frss:opmlUrl'] = $cat->attributes('opml_url'); } + $opml_array['body'][$key] = $outline; } } @@ -77,4 +89,5 @@ if (!empty($this->feeds)) { $opml_array['body'][] = feedsToOutlines($this->feeds, $this->excludeMutedFeeds); } -echo libopml_render($opml_array); +$libopml = new \marienfressinaud\LibOpml\LibOpml(true); +echo $libopml->render($opml_array); |
