]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Poche.class.php
Merge pull request #387 from inthepoche/dev
[github/wallabag/wallabag.git] / inc / poche / Poche.class.php
index 4f70afb755c2a0188af55973ca7dd4ab5b7a4ee6..76a73be2b88e188500c3ad7affd11468e2a7dead 100644 (file)
@@ -333,7 +333,9 @@ class Poche
         switch ($action)
         {
             case 'add':
-                $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed');
+                $options = array('http' => array('user_agent' => 'poche'));
+                $context = stream_context_create($options);
+                $json = file_get_contents(Tools::getPocheUrl() . '/inc/3rdparty/makefulltextfeed.php?url='.urlencode($url->getUrl()).'&max=5&links=preserve&exc=&format=json&submit=Create+Feed', false, $context);
                 $content = json_decode($json, true);
                 $title = $content['rss']['channel']['item']['title'];
                 $body = $content['rss']['channel']['item']['description'];
@@ -806,34 +808,37 @@ class Poche
             $url = NULL;
             $favorite = FALSE;
             $archive = FALSE;
-            foreach ($value as $attr => $attr_value) {
-                if ($attr == 'article__url') {
-                    $url = new Url(base64_encode($attr_value));
-                }
-                $sequence = '';
-                if (STORAGE == 'postgres') {
-                    $sequence = 'entries_id_seq';
-                }
-                if ($attr_value == 'true') {
-                    if ($attr == 'favorite') {
-                        $favorite = TRUE;
+            foreach ($value as $item) {
+                foreach ($item as $attr => $value) {
+                    if ($attr == 'article__url') {
+                        $url = new Url(base64_encode($value));
                     }
-                    if ($attr == 'archive') {
-                        $archive = TRUE;
+                    $sequence = '';
+                    if (STORAGE == 'postgres') {
+                        $sequence = 'entries_id_seq';
+                    }
+                    if ($value == 'true') {
+                        if ($attr == 'favorite') {
+                            $favorite = TRUE;
+                        }
+                        if ($attr == 'archive') {
+                            $archive = TRUE;
+                        }
                     }
                 }
-            }
-            # we can add the url
-            if (!is_null($url) && $url->isCorrect()) {
-                $this->action('add', $url, 0, TRUE);
-                $count++;
-                if ($favorite) {
-                    $last_id = $this->store->getLastId($sequence);
-                    $this->action('toggle_fav', $url, $last_id, TRUE);
-                }
-                if ($archive) {
-                    $last_id = $this->store->getLastId($sequence);
-                    $this->action('toggle_archive', $url, $last_id, TRUE);
+
+                # we can add the url
+                if (!is_null($url) && $url->isCorrect()) {
+                    $this->action('add', $url, 0, TRUE);
+                    $count++;
+                    if ($favorite) {
+                        $last_id = $this->store->getLastId($sequence);
+                        $this->action('toggle_fav', $url, $last_id, TRUE);
+                    }
+                    if ($archive) {
+                        $last_id = $this->store->getLastId($sequence);
+                        $this->action('toggle_archive', $url, $last_id, TRUE);
+                    }
                 }
             }
         }
@@ -951,7 +956,7 @@ class Poche
         if (count($entries) > 0) {
             foreach ($entries as $entry) {
                 $newItem = $feed->createNewItem();
-                $newItem->setTitle(htmlentities($entry['title']));
+                $newItem->setTitle($entry['title']);
                 $newItem->setLink(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']);
                 $newItem->setDate(time());
                 $newItem->setDescription($entry['content']);