/** * 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() { $itemsDao = new \daos\Items(); $return = array('all' => $itemsDao->numberOfItems(), 'unread' => $itemsDao->numberOfUnread(), 'starred' => $itemsDao->numberOfStarred()); $this->view->jsonSuccess($return); }
/** * 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); }
/** * load items * * @return html with items */ private function loadItems($options, $tags) { $tagColors = $this->convertTagsToAssocArray($tags); $itemDao = new \daos\Items(); $itemsHtml = ""; foreach ($itemDao->get($options) as $item) { // parse tags and assign tag colors $itemsTags = explode(",", $item['tags']); $item['tags'] = array(); foreach ($itemsTags as $tag) { $tag = trim($tag); if (strlen($tag) > 0 && isset($tagColors[$tag])) { $item['tags'][$tag] = $tagColors[$tag]; } } $this->view->item = $item; $itemsHtml .= $this->view->render('templates/item.phtml'); } if (strlen($itemsHtml) == 0) { $itemsHtml = '<div class="stream-empty">' . \F3::get('lang_no_entries') . '</div>'; } else { if ($itemDao->hasMore()) { $itemsHtml .= '<div class="stream-more"><span>' . \F3::get('lang_more') . '</span></div>'; } $itemsHtml .= '<div class="mark-these-read"><span>' . \F3::get('lang_markread') . '</span></div>'; } return $itemsHtml; }
/** * rss feed * * @return void */ public function rss() { $this->needsLoggedInOrPublicMode(); $feedWriter = new \RSS2FeedWriter(); $feedWriter->setTitle(\F3::get('rss_title')); $feedWriter->setLink($this->view->base); // get sources $sourceDao = new \daos\Sources(); $lastSourceId = 0; $lastSourceName = ""; // set options $options = array(); if (count($_GET) > 0) { $options = $_GET; } $options['items'] = \F3::get('rss_max_items'); if (\F3::get('PARAMS["tag"]') != null) { $options['tag'] = \F3::get('PARAMS["tag"]'); } if (\F3::get('PARAMS["type"]') != null) { $options['type'] = \F3::get('PARAMS["type"]'); } // get items $newestEntryDate = false; $lastid = -1; $itemDao = new \daos\Items(); foreach ($itemDao->get($options) as $item) { if ($newestEntryDate === false) { $newestEntryDate = $item['datetime']; } $newItem = $feedWriter->createNewItem(); // get Source Name if ($item['source'] != $lastSourceId) { foreach ($sourceDao->get() as $source) { if ($source['id'] == $item['source']) { $lastSourceId = $source['id']; $lastSourceName = $source['title']; break; } } } $newItem->setTitle(str_replace('&', '&', $this->UTF8entities($item['title'] . " (" . $lastSourceName . ")"))); @$newItem->setLink($item['link']); $newItem->setDate($item['datetime']); $newItem->setDescription(str_replace('"', '"', $item['content'])); // add tags in category node $itemsTags = explode(",", $item['tags']); foreach ($itemsTags as $tag) { $tag = trim($tag); if (strlen($tag) > 0) { $newItem->addElement('category', $tag); } } $feedWriter->addItem($newItem); $lastid = $item['id']; // mark as read if (\F3::get('rss_mark_as_read') == 1 && $lastid != -1) { $itemDao->mark($lastid); } } if ($newestEntryDate === false) { $newestEntryDate = date(\DATE_ATOM, time()); } $feedWriter->setChannelElement('updated', $newestEntryDate); $feedWriter->generateFeed(); }
/** * returns all sources with unread items * json * * @return void */ public function stats() { $itemDao = new \daos\Items(); // load sources $sourcesDao = new \daos\Sources(); $sources = $sourcesDao->get(); // get stats $result = array(); for ($i = 0; $i < count($sources); $i++) { $result[] = array('id' => $sources[$i]['id'], 'title' => $sources[$i]['title'], 'unread' => $itemDao->numberOfUnreadForSource($sources[$i]['id'])); } $this->view->jsonSuccess($result); }