/** * returns all tags * html * * @return void */ public function listTags() { $this->needsLoggedInOrPublicMode(); $tagsDao = new \daos\Tags(); $tags = $tagsDao->getWithUnread(); $this->view->jsonSuccess($tags); }
/** * home site * html * * @return void */ public function home() { // check login $this->authentication(); // parse params $options = array(); if (\F3::get('homepage') != '') { $options = array('type' => \F3::get('homepage')); } // use ajax given params? if (count($_GET) > 0) { $options = $_GET; } // get search param if (isset($options['search']) && strlen($options['search']) > 0) { $this->view->search = $options['search']; } // load tags $tagsDao = new \daos\Tags(); $tags = $tagsDao->getWithUnread(); // load items $itemsHtml = $this->loadItems($options, $tags); $this->view->content = $itemsHtml; // load stats $itemsDao = new \daos\Items(); $stats = $itemsDao->stats(); $this->view->statsAll = $stats['total']; $this->view->statsUnread = $stats['unread']; $this->view->statsStarred = $stats['starred']; if ($tagsDao->hasTag("#")) { foreach ($tags as $tag) { if (strcmp($tag["tag"], "#") !== 0) { continue; } $this->view->statsUnread -= $tag["unread"]; } } // prepare tags display list $tagsController = new \controllers\Tags(); $this->view->tags = $tagsController->renderTags($tags); if (isset($options['sourcesNav']) && $options['sourcesNav'] == 'true') { // prepare sources display list $sourcesDao = new \daos\Sources(); $sources = $sourcesDao->getWithUnread(); $sourcesController = new \controllers\Sources(); $this->view->sources = $sourcesController->renderSources($sources); } else { $this->view->sources = ''; } // ajax call = only send entries and statistics not full template if (isset($options['ajax'])) { $this->view->jsonSuccess(array("entries" => $this->view->content, "all" => $this->view->statsAll, "unread" => $this->view->statsUnread, "starred" => $this->view->statsStarred, "tags" => $this->view->tags, "sources" => $this->view->sources)); } // show as full html page $this->view->publicMode = \F3::get('auth')->isLoggedin() !== true && \F3::get('public') == 1; $this->view->loggedin = \F3::get('auth')->isLoggedin() === true; echo $this->view->render('templates/home.phtml'); }
/** * 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); }
/** * 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 current basic stats * json * * @return void */ public function stats() { $this->needsLoggedInOrPublicMode(); $itemsDao = new \daos\Items(); $stats = $itemsDao->stats(); 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); }
/** * delete source * json * * @return void */ public function remove() { $this->needsLoggedIn(); $id = \F3::get('PARAMS["id"]'); $sourceDao = new \daos\Sources(); if (!$sourceDao->isValid('id', $id)) { $this->view->error('invalid id given'); } $sourceDao->delete($id); // cleanup tags $tagsDao = new \daos\Tags(); $allTags = $sourceDao->getAllTags(); $tagsDao->cleanup($allTags); $this->view->jsonSuccess(array('success' => true)); }