Esempio n. 1
0
 /**
  * mark items as read. Allows one id or an array of ids
  * json
  *
  * @return void
  */
 public function mark()
 {
     if (\F3::get('PARAMS["item"]') != null) {
         $lastid = \F3::get('PARAMS["item"]');
     } else {
         if (isset($_POST['ids'])) {
             $lastid = $_POST['ids'];
         }
     }
     $itemDao = new \daos\Items();
     // validate id or ids
     if (!$itemDao->isValid('id', $lastid)) {
         $this->view->error('invalid id');
     }
     $itemDao->mark($lastid);
     $return = array('success' => true);
     // only for selfoss ui on mark all as read (update stats in navigation)
     if (isset($_POST['ajax'])) {
         // get new tag list with updated count values
         $tagController = new \controllers\Tags();
         $return['tags'] = $tagController->tagsListAsString();
         // get new sources list
         $sourcesController = new \controllers\Sources();
         $return['sources'] = $sourcesController->sourcesListAsString();
     }
     $this->view->jsonSuccess($return);
 }
Esempio n. 2
0
 /**
  * mark items as read. Allows one id or an array of ids
  * json
  *
  * @return void
  */
 public function mark()
 {
     $this->needsLoggedIn();
     if (\F3::get('PARAMS["item"]') != null) {
         $lastid = \F3::get('PARAMS["item"]');
     } else {
         if (isset($_POST['ids'])) {
             $lastid = $_POST['ids'];
         }
     }
     $itemDao = new \daos\Items();
     // validate id or ids
     if (!$itemDao->isValid('id', $lastid)) {
         $this->view->error('invalid id');
     }
     $itemDao->mark($lastid);
     $return = array('success' => true);
     $this->view->jsonSuccess($return);
 }
Esempio n. 3
0
 /**
  * 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();
 }