diff options
| author | 2022-07-04 09:53:26 +0200 | |
|---|---|---|
| committer | 2022-07-04 09:53:26 +0200 | |
| commit | 509c8cae6381ec46af7c8303eb92fda6ce496a4a (patch) | |
| tree | 653f7f44df842f9d7135decd89467879a0098c50 /app/views/helpers/export/opml.phtml | |
| parent | 57d571230eeb2d3ede57e640b640f17c7a2298a2 (diff) | |
Dynamic OPML (#4407)
* Dynamic OPML draft
#fix https://github.com/FreshRSS/FreshRSS/issues/4191
* Export dynamic OPML
http://opml.org/spec2.opml#1629043127000
* Restart with simpler approach
* Minor revert
* Export dynamic OPML also for single feeds
* Special category type for importing dynamic OPML
* Parameter for excludeMutedFeeds
* Details
* More draft
* i18n
* Fix update
* Draft manual import working
* Working manual refresh
* Draft automatic update
* Working Web refresh + fixes
* Import/export dynamic OPML settings
* Annoying numerous lines in SQL logs
* Fix minor JavaScript error
* Fix auto adding new columns
* Add require
* Add missing 🗲
* Missing space
* Disable adding new feeds to dynamic categories
* Link from import
* i18n typo
* Improve theme icon function
* Fix pink-dark
Diffstat (limited to 'app/views/helpers/export/opml.phtml')
| -rw-r--r-- | app/views/helpers/export/opml.phtml | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml index 64c02c302..f99754138 100644 --- a/app/views/helpers/export/opml.phtml +++ b/app/views/helpers/export/opml.phtml @@ -1,21 +1,14 @@ <?php -/** @var FreshRSS_View $this */ -$opml_array = array( - 'head' => array( - 'title' => FreshRSS_Context::$system_conf->title, - 'dateCreated' => date('D, d M Y H:i:s') - ), - 'body' => array() -); - -foreach ($this->categories as $key => $cat) { - $opml_array['body'][$key] = array( - 'text' => htmlspecialchars_decode($cat->name(), ENT_QUOTES), - '@outlines' => array() - ); - - foreach ($cat->feeds() as $feed) { +/** + * @param array<FreshRSS_Feed> $feeds + */ +function feedsToOutlines($feeds, $excludeMutedFeeds = false): array { + $outlines = []; + foreach ($feeds as $feed) { + if ($feed->mute() && $excludeMutedFeeds) { + continue; + } $outline = [ 'text' => htmlspecialchars_decode($feed->name(), ENT_QUOTES), 'type' => FreshRSS_Export_Service::TYPE_RSS_ATOM, @@ -47,8 +40,36 @@ foreach ($this->categories as $key => $cat) { if ($feed->pathEntries() != '') { $outline['frss:cssFullContent'] = ['namespace' => FreshRSS_Export_Service::FRSS_NAMESPACE, 'value' => $feed->pathEntries()]; } - $opml_array['body'][$key]['@outlines'][] = $outline; + $outlines[] = $outline; } + return $outlines; +} + +/** @var FreshRSS_View $this */ + +$opml_array = array( + 'head' => array( + 'title' => FreshRSS_Context::$system_conf->title, + 'dateCreated' => date('D, d M Y H:i:s') + ), + 'body' => array() +); + +if (!empty($this->categories)) { + foreach ($this->categories as $key => $cat) { + $outline = [ + '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')];; + } + $opml_array['body'][$key] = $outline; + } +} + +if (!empty($this->feeds)) { + $opml_array['body'][] = feedsToOutlines($this->feeds, $this->excludeMutedFeeds); } echo libopml_render($opml_array); |
