aboutsummaryrefslogtreecommitdiff
path: root/app/views/helpers/export/opml.phtml
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-03-29 20:18:57 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-03-29 20:18:57 +0100
commit9ea3819402746d8425d4a608f2d5f3c0f5bc29fb (patch)
treea4836c792d14e5489ebabe6e5d9f46e9b098ce93 /app/views/helpers/export/opml.phtml
parent7676a197a4767f735dabae6ad9cf40ef65e91aa7 (diff)
Better OPML import / export
- use a new OPML library (https://github.com/marienfressinaud/lib_opml) - import has been completely rewritten (far better!) - introduce addFeedObject and addCategoryObject (in DAO for the moment). Permit to add easily feeds and categories (check if they already exist in DB) - introduce html_chars_utf8 (wrap htmlspecialchars for UTF-8)
Diffstat (limited to 'app/views/helpers/export/opml.phtml')
-rw-r--r--app/views/helpers/export/opml.phtml43
1 files changed, 29 insertions, 14 deletions
diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml
index 2e66e5054..adbac904d 100644
--- a/app/views/helpers/export/opml.phtml
+++ b/app/views/helpers/export/opml.phtml
@@ -1,15 +1,30 @@
<?php
-require_once(LIB_PATH . '/lib_opml.php');
-
-echo '<?xml version="1.0" encoding="UTF-8" ?>';
-?>
-<!-- Generated by <?php echo Minz_Configuration::title (); ?> -->
-<opml version="2.0">
- <head>
- <title><?php echo Minz_Configuration::title (); ?> OPML Feed</title>
- <dateCreated><?php echo date('D, d M Y H:i:s'); ?></dateCreated>
- </head>
- <body>
-<?php echo opml_export ($this->categories); ?>
- </body>
-</opml>
+
+$opml_array = array(
+ 'head' => array(
+ 'title' => Minz_Configuration::title(),
+ 'dateCreated' => date('D, d M Y H:i:s')
+ ),
+ 'body' => array()
+);
+
+foreach ($this->categories as $key => $cat) {
+ $opml_array['body'][$key] = array(
+ 'text' => $cat['name'],
+ '@outlines' => array()
+ );
+
+ foreach ($cat['feeds'] as $feed) {
+ $opml_array['body'][$key]['@outlines'][] = array(
+ 'text' => $feed->name(),
+ 'type' => 'rss',
+ 'xmlUrl' => $feed->url(),
+ 'htmlUrl' => $feed->website(),
+ 'description' => htmlspecialchars(
+ $feed->description(), ENT_COMPAT, 'UTF-8'
+ )
+ );
+ }
+}
+
+echo libopml_render($opml_array);