4
0
Эх сурвалжийг харах

Changement API : export (Uniflux) du flux public à la place du flux des favoris avec content = notes et gestion des tags

Marien Fressinaud 13 жил өмнө
parent
commit
1c57c2b7bd

+ 14 - 10
app/controllers/apiController.php

@@ -7,29 +7,33 @@ class apiController extends ActionController {
 		$this->view->_useLayout (false);
 	}
 
-	public function getFavoritesAction () {
+	public function getPublicFeedAction () {
 		$entryDAO = new EntryDAO ();
 		$entryDAO->_nbItemsPerPage (-1);
 
-		$entries_tmp = $entryDAO->listFavorites ('all', 'low_to_high');
+		$entries_tmp = $entryDAO->listPublic ('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;
+
+			$notes = $e->notes ();
+			if ($notes == '') {
+				$feed = $e->feed (true);
+				$notes = 'Article publié initialement sur <a href="' . $feed->website () . '">' . $feed->name () . '</a>';
+				if($author != '') {
+					$notes .= ' par ' . $author;
+				}
+				$notes .= ', mis en favoris dans <a href="https://github.com/marienfressinaud/FreshRSS">FreshRSS</a>';
 			}
-			$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]['content'] = $notes;
 			$entries[$id]['date'] = $e->date (true);
-			$entries[$id]['lastUpdate'] = $e->date (true);
-			$entries[$id]['tags'] = array ();
+			$entries[$id]['lastUpdate'] = $e->lastUpdate (true);
+			$entries[$id]['tags'] = $e->tags ();
 			$entries[$id]['url'] = $e->link ();
 			$entries[$id]['type'] = 'url';
 		}

+ 3 - 1
app/controllers/entryController.php

@@ -89,6 +89,7 @@ class entryController extends ActionController {
 			if ($entry != false) {
 				$values = array (
 					'is_favorite' => $is_fav,
+					'lastUpdate' => time ()
 				);
 
 				$entryDAO->updateEntry ($entry->id (), $values);
@@ -119,7 +120,8 @@ class entryController extends ActionController {
 
 					$values = array (
 						'annotation' => $note,
-						'is_public' => $public
+						'is_public' => $public,
+						'lastUpdate' => time ()
 					);
 
 					if ($entryDAO->updateEntry ($id, $values)) {

+ 17 - 0
app/models/Entry.php

@@ -442,6 +442,23 @@ class EntryDAO extends Model_pdo {
 		return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
 	}
 
+	public function listPublic ($order = 'high_to_low') {
+		$where = ' WHERE is_public=1';
+
+		if ($order == 'low_to_high') {
+			$order = ' DESC';
+		} else {
+			$order = '';
+		}
+
+		$sql = 'SELECT * FROM entry' . $where . ' ORDER BY date' . $order;
+
+		$stm = $this->bd->prepare ($sql);
+		$stm->execute ();
+
+		return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
+	}
+
 	public function listByCategory ($cat, $mode, $search = false, $order = 'high_to_low') {
 		$where = ' WHERE category=?';
 		if ($mode == 'not_read') {

+ 0 - 0
app/views/api/getFavorites.phtml → app/views/api/getPublicFeed.phtml