aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/apiController.php
blob: 5ef0f5b03c71cd21d3913b5723303591a6be5c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
  
class apiController extends ActionController {
	public function firstAction() {
		header('Content-type: application/json');

		$this->view->_useLayout (false);
	}

	public function getFavoritesAction () {
		$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;
	}

	public function getNbNotReadAction() {
	}
}