Exemple #1
0
 /**
  * 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);
 }
Exemple #2
0
 /**
  * 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->get();
     // load items
     $itemsHtml = $this->loadItems($options, $tags);
     $this->view->content = $itemsHtml;
     // load stats
     $itemsDao = new \daos\Items();
     $this->view->statsAll = $itemsDao->numberOfItems();
     $this->view->statsUnread = $itemsDao->numberOfUnread();
     $this->view->statsStarred = $itemsDao->numberOfStarred();
     // prepare tags display list
     $tagsController = new \controllers\Tags();
     $this->view->tags = $tagsController->renderTags($tags);
     // prepare sources display list
     $sourcesDao = new \daos\Sources();
     $sources = $sourcesDao->get();
     $sourcesController = new \controllers\Sources();
     $this->view->sources = $sourcesController->renderSources($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');
 }