aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/apiController.php
blob: 025908f3e3e4d045f00fae5c5e496e59e015c4da (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
43
44
45
46
<?php
  
class apiController extends ActionController {
	public function firstAction() {
		header('Content-type: application/json');

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

	public function getPublicFeedAction () {
		$entryDAO = new EntryDAO ();
		$entryDAO->_nbItemsPerPage (-1);

		$entries_tmp = $entryDAO->listPublic ('low_to_high');

		$entries = array ();
		foreach ($entries_tmp as $e) {
			$author = $e->author ();

			$notes = $e->notes ();
			if ($notes == '') {
				$feed = $e->feed (true);
				if($author != '') {
					$notes = Translate::t ('article_published_on_author', $feed->website (), $feed->name (), $author);
				} else {
					$notes = Translate::t ('article_published_on', $feed->website (), $feed->name ());
				}
			}

			$id = $e->id ();
			$entries[$id] = array ();
			$entries[$id]['title'] = $e->title ();
			$entries[$id]['content'] = $notes;
			$entries[$id]['date'] = $e->date (true);
			$entries[$id]['lastUpdate'] = $e->lastUpdate (true);
			$entries[$id]['tags'] = $e->tags ();
			$entries[$id]['url'] = $e->link ();
			$entries[$id]['type'] = 'url';
		}

		$this->view->entries = $entries;
	}

	public function getNbNotReadAction() {
	}
}