diff options
| author | 2022-05-12 22:15:10 +0200 | |
|---|---|---|
| committer | 2022-05-12 22:15:10 +0200 | |
| commit | 4a87206f2898665e99953590536cedc6c5505f05 (patch) | |
| tree | 398f53769048460071194d398c61c7e847f22d7e /app/Services/ImportService.php | |
| parent | 9d1930d9adb4f56ae12209d3d01f4a1ed1af8503 (diff) | |
OPML export/import of some proprietary FreshRSS attributes (#4342)
* OPML export/import of some proprietary FreshRSS attributes
#fix https://github.com/FreshRSS/FreshRSS/issues/4077
And one of the TODOs of https://github.com/FreshRSS/FreshRSS/pull/4220
XPath options, CSS Selector, and action filters
* Bump library patch version
* OPML namespace + documentation
* Add example
Diffstat (limited to 'app/Services/ImportService.php')
| -rw-r--r-- | app/Services/ImportService.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 7d1bb1c7c..7e7cccfdb 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -148,6 +148,37 @@ class FreshRSS_Import_Service { $feed->_website($website); $feed->_description($description); + switch ($feed_elt['type'] ?? '') { + case FreshRSS_Export_Service::TYPE_HTML_XPATH: + $feed->_kind(FreshRSS_Feed::KIND_HTML_XPATH); + break; + case FreshRSS_Export_Service::TYPE_RSS_ATOM: + default: + $feed->_kind(FreshRSS_Feed::KIND_RSS); + break; + } + + $xPathSettings = []; + foreach ($feed_elt as $key => $value) { + if (is_array($value) && !empty($value['value']) && ($value['namespace'] ?? '') === FreshRSS_Export_Service::FRSS_NAMESPACE) { + switch ($key) { + case 'cssFullContent': $feed->_pathEntries($value['value']); break; + case 'filtersActionRead': $feed->_filtersAction('read', preg_split('/[\n\r]+/', $value['value'])); break; + case 'xPathItem': $xPathSettings['item'] = $value['value']; break; + case 'xPathItemTitle': $xPathSettings['itemTitle'] = $value['value']; break; + case 'xPathItemContent': $xPathSettings['itemContent'] = $value['value']; break; + case 'xPathItemUri': $xPathSettings['itemUri'] = $value['value']; break; + case 'xPathItemAuthor': $xPathSettings['itemAuthor'] = $value['value']; break; + case 'xPathItemTimestamp': $xPathSettings['itemTimestamp'] = $value['value']; break; + case 'xPathItemThumbnail': $xPathSettings['itemThumbnail'] = $value['value']; break; + case 'xPathItemCategories': $xPathSettings['itemCategories'] = $value['value']; break; + } + } + } + if (!empty($xPathSettings)) { + $feed->_attributes('xpath', $xPathSettings); + } + // Call the extension hook $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); if ($feed != null) { |
