summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-02-10 13:52:39 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-02-10 13:52:39 +0100
commitf528d2c3152e35dcfe66b3bf87322decd847d49d (patch)
tree3844b2d815829dd6d687e0dc438e4f27e09b3f00 /app
parentc22fd80f993e82bdefd7c86fbf33c80bf72b9c49 (diff)
ajout export au format Uniflux
Diffstat (limited to 'app')
-rw-r--r--app/configuration/routes.php7
-rwxr-xr-xapp/controllers/apiController.php38
-rwxr-xr-xapp/models/Entry.php15
-rw-r--r--app/views/api/getFavorites.phtml3
4 files changed, 58 insertions, 5 deletions
diff --git a/app/configuration/routes.php b/app/configuration/routes.php
index fa8c29b3f..2f36daa67 100644
--- a/app/configuration/routes.php
+++ b/app/configuration/routes.php
@@ -44,6 +44,13 @@ return array (
'action' => 'main'
),
+ // API
+ array (
+ 'route' => '/api/get_favorites',
+ 'controller' => 'api',
+ 'action' => 'getFavorites'
+ ),
+
// Entry
array (
'route' => '/articles/marquer.php\?id=([\w\d\-_]{6})&lu=([\d]{1})',
diff --git a/app/controllers/apiController.php b/app/controllers/apiController.php
new file mode 100755
index 000000000..88b968cb9
--- /dev/null
+++ b/app/controllers/apiController.php
@@ -0,0 +1,38 @@
+<?php
+
+class apiController extends ActionController {
+ public function getFavoritesAction () {
+ header('Content-type: application/json');
+
+ $this->view->_useLayout (false);
+
+ $entryDAO = new EntryDAO ();
+ $entryDAO->_nbItemsPerPage (-1);
+
+ $entries_tmp = $entryDAO->listFavorites ('all', 'low_to_high');
+
+ $entries = array ();
+
+ foreach ($entries_tmp as $e) {
+ $author = $e->author ();
+ $feed = $e->feed (true);
+ $content = 'Article publiƩ initialement sur <a href="' . $feed->website () . '">' . $feed->name () . '</a>';
+ if($author != '') {
+ $content .= ' par ' . $author;
+ }
+ $content .= ', mis en favoris dans <a href="https://github.com/marienfressinaud/FreshRSS">FreshRSS</a>';
+
+ $id = $e->id ();
+ $entries[$id] = array ();
+ $entries[$id]['title'] = $e->title ();
+ $entries[$id]['content'] = $content;
+ $entries[$id]['date'] = $e->date (true);
+ $entries[$id]['lastUpdate'] = $e->date (true);
+ $entries[$id]['tags'] = array ();
+ $entries[$id]['url'] = $e->link ();
+ $entries[$id]['type'] = 'url';
+ }
+
+ $this->view->entries = $entries;
+ }
+}
diff --git a/app/models/Entry.php b/app/models/Entry.php
index d434e99f6..4cdcf8265 100755
--- a/app/models/Entry.php
+++ b/app/models/Entry.php
@@ -250,12 +250,17 @@ class EntryDAO extends Model_pdo {
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
$this->nbItems = $res[0]['count'];
- $deb = ($this->currentPage - 1) * $this->nbItemsPerPage;
- $fin = $this->nbItemsPerPage;
+ if($this->nbItemsPerPage < 0) {
+ $sql = 'SELECT * FROM entry' . $where
+ . ' ORDER BY date' . $order;
+ } else {
+ $deb = ($this->currentPage - 1) * $this->nbItemsPerPage;
+ $fin = $this->nbItemsPerPage;
- $sql = 'SELECT * FROM entry' . $where
- . ' ORDER BY date' . $order
- . ' LIMIT ' . $deb . ', ' . $fin;
+ $sql = 'SELECT * FROM entry' . $where
+ . ' ORDER BY date' . $order
+ . ' LIMIT ' . $deb . ', ' . $fin;
+ }
$stm = $this->bd->prepare ($sql);
$stm->execute ();
diff --git a/app/views/api/getFavorites.phtml b/app/views/api/getFavorites.phtml
new file mode 100644
index 000000000..8eb0774f2
--- /dev/null
+++ b/app/views/api/getFavorites.phtml
@@ -0,0 +1,3 @@
+<?php
+echo json_encode ($this->entries);
+?>