/** * returns current basic stats * json * * @return void */ public function stats() { $this->needsLoggedInOrPublicMode(); $itemsDao = new \daos\Items(); $stats = $itemsDao->stats(); $stats['unread'] -= $itemsDao->numberOfUnreadForTag("#"); $tagsDao = new \daos\Tags(); $tags = $tagsDao->getWithUnread(); if ($tagsDao->hasTag("#")) { foreach ($tags as $tag) { if (strcmp($tag["tag"], "#") !== 0) { continue; } $stats['unread'] -= $tag["unread"]; } } if (array_key_exists('tags', $_GET) && $_GET['tags'] == 'true') { $tagsDao = new \daos\Tags(); $tagsController = new \controllers\Tags(); $stats['tagshtml'] = $tagsController->renderTags($tagsDao->getWithUnread()); } if (array_key_exists('sources', $_GET) && $_GET['sources'] == 'true') { $sourcesDao = new \daos\Sources(); $sourcesController = new \controllers\Sources(); $stats['sourceshtml'] = $sourcesController->renderSources($sourcesDao->getWithUnread()); } $this->view->jsonSuccess($stats); }
/** * returns all tags * html * * @return void */ public function listTags() { $tagsDao = new \daos\Tags(); $tags = $tagsDao->get(); $itemsDao = new \daos\Items(); for ($i = 0; $i < count($tags); $i++) { $tags[$i]['unread'] = $itemsDao->numberOfUnreadForTag($tags[$i]['tag']); } $this->view->jsonSuccess($tags); }