Merge pull request #1206 from Alkarex/OPML-categories

Support for OPML 2.0 category attribute
pull/1209/head
Alexandre Alapetite 8 years ago committed by GitHub
commit 112b744665
  1. 2
      CHANGELOG.md
  2. 1
      README.fr.md
  3. 1
      README.md
  4. 31
      lib/lib_opml.php

@ -16,12 +16,14 @@
* Fixed scroll in log view [#1178](https://github.com/FreshRSS/FreshRSS/issues/1178) * Fixed scroll in log view [#1178](https://github.com/FreshRSS/FreshRSS/issues/1178)
* Fixed JavaScript bug when articles were not always marked as read [#1123](https://github.com/FreshRSS/FreshRSS/issues/1123) * Fixed JavaScript bug when articles were not always marked as read [#1123](https://github.com/FreshRSS/FreshRSS/issues/1123)
* Fixed Apache Etag issue that prevented caching [#1199](https://github.com/FreshRSS/FreshRSS/pull/1199) * Fixed Apache Etag issue that prevented caching [#1199](https://github.com/FreshRSS/FreshRSS/pull/1199)
* Fixed OPML import of categories [#1202](https://github.com/FreshRSS/FreshRSS/issues/1202)
* UI * UI
* Updated to jQuery 3.1.0 and several JavaScript fixes (e.g. drag & drop) [#1197](https://github.com/FreshRSS/FreshRSS/pull/1197) * Updated to jQuery 3.1.0 and several JavaScript fixes (e.g. drag & drop) [#1197](https://github.com/FreshRSS/FreshRSS/pull/1197)
* API * API
* Add API link in FreshRSS profile settings to ease set-up [#1186](https://github.com/FreshRSS/FreshRSS/pull/1186) * Add API link in FreshRSS profile settings to ease set-up [#1186](https://github.com/FreshRSS/FreshRSS/pull/1186)
* Mics. * Mics.
* JSHint of JavaScript code and better initialisation [#1196](https://github.com/FreshRSS/FreshRSS/pull/1196) * JSHint of JavaScript code and better initialisation [#1196](https://github.com/FreshRSS/FreshRSS/pull/1196)
* Updated credits, and images in README [#1201](https://github.com/FreshRSS/FreshRSS/issues/1201)
## 2016-07-23 FreshRSS 1.4.0 ## 2016-07-23 FreshRSS 1.4.0

@ -125,6 +125,7 @@ mysqldump -u utilisateur -p --databases freshrss > freshrss.sql
* [php-http-304](http://alexandre.alapetite.fr/doc-alex/php-http-304/) * [php-http-304](http://alexandre.alapetite.fr/doc-alex/php-http-304/)
* [jQuery](http://jquery.com/) * [jQuery](http://jquery.com/)
* [ArthurHoaro/favicon](https://github.com/ArthurHoaro/favicon) * [ArthurHoaro/favicon](https://github.com/ArthurHoaro/favicon)
* [lib_opml](https://github.com/marienfressinaud/lib_opml)
* [keyboard_shortcuts](http://www.openjs.com/scripts/events/keyboard_shortcuts/) * [keyboard_shortcuts](http://www.openjs.com/scripts/events/keyboard_shortcuts/)
* [flotr2](http://www.humblesoftware.com/flotr2) * [flotr2](http://www.humblesoftware.com/flotr2)

@ -125,6 +125,7 @@ mysqldump -u user -p --databases freshrss > freshrss.sql
* [php-http-304](http://alexandre.alapetite.fr/doc-alex/php-http-304/) * [php-http-304](http://alexandre.alapetite.fr/doc-alex/php-http-304/)
* [jQuery](http://jquery.com/) * [jQuery](http://jquery.com/)
* [ArthurHoaro/favicon](https://github.com/ArthurHoaro/favicon) * [ArthurHoaro/favicon](https://github.com/ArthurHoaro/favicon)
* [lib_opml](https://github.com/marienfressinaud/lib_opml)
* [keyboard_shortcuts](http://www.openjs.com/scripts/events/keyboard_shortcuts/) * [keyboard_shortcuts](http://www.openjs.com/scripts/events/keyboard_shortcuts/)
* [flotr2](http://www.humblesoftware.com/flotr2) * [flotr2](http://www.humblesoftware.com/flotr2)

@ -12,7 +12,7 @@
* *
* @author Marien Fressinaud <dev@marienfressinaud.fr> * @author Marien Fressinaud <dev@marienfressinaud.fr>
* @link https://github.com/marienfressinaud/lib_opml * @link https://github.com/marienfressinaud/lib_opml
* @version 0.2 * @version 0.2-FreshRSS~1.5.1
* @license public domain * @license public domain
* *
* Usages: * Usages:
@ -123,6 +123,32 @@ function libopml_parse_outline($outline_xml, $strict = true) {
return $outline; return $outline;
} }
/**
* Reformat the XML document as a hierarchy when
* the OPML 2.0 category attribute is used
*/
function preprocessing_categories($doc) {
$outline_categories = [];
$body = $doc->getElementsByTagName('body')->item(0);
$xpath = new DOMXpath($doc);
$outlines = $xpath->query('/opml/body/outline[@category]');
foreach ($outlines as $outline) {
$category = trim($outline->getAttribute('category'));
if ($category != '') {
$outline_categorie = null;
if (!isset($outline_categories[$category])) {
$outline_categorie = $doc->createElement('outline');
$outline_categorie->setAttribute('text', $category);
$body->insertBefore($outline_categorie, $body->firstChild);
$outline_categories[$category] = $outline_categorie;
} else {
$outline_categorie = $outline_categories[$category];
}
$outline->parentNode->removeChild($outline);
$outline_categorie->appendChild($outline);
}
}
}
/** /**
* Parse a string as a XML one and returns the corresponding array * Parse a string as a XML one and returns the corresponding array
@ -140,6 +166,9 @@ function libopml_parse_string($xml, $strict = true) {
$dom->loadXML($xml); $dom->loadXML($xml);
$dom->encoding = 'UTF-8'; $dom->encoding = 'UTF-8';
//Partial compatibility with the category attribute of OPML 2.0
preprocessing_categories($dom);
$opml = simplexml_import_dom($dom); $opml = simplexml_import_dom($dom);
if (!$opml) { if (!$opml) {

Loading…
Cancel
Save