コード例 #1
0
ファイル: Items.php プロジェクト: gabor-udvari/selfoss
 /**
  * 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);
 }
コード例 #2
0
ファイル: Index.php プロジェクト: dled/selfoss
 /**
  * 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');
 }
コード例 #3
0
ファイル: Items.php プロジェクト: dled/selfoss
 /**
  * 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);
 }
コード例 #4
0
ファイル: Items.php プロジェクト: nijave/selfoss
 /**
  * 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);
 }
コード例 #5
0
ファイル: Sources.php プロジェクト: ZMOM1031/selfoss
 /**
  * render spouts params
  * json
  *
  * @return void
  */
 public function write()
 {
     $this->needsLoggedIn();
     $sourcesDao = new \daos\Sources();
     // read data
     parse_str(\F3::get('BODY'), $data);
     if (!isset($data['title'])) {
         $this->view->jsonError(array('title' => 'no data for title given'));
     }
     if (!isset($data['spout'])) {
         $this->view->jsonError(array('spout' => 'no data for spout given'));
     }
     // clean up title and tag data to prevent XSS
     $title = htmlspecialchars($data['title']);
     $tags = htmlspecialchars($data['tags']);
     $spout = $data['spout'];
     $filter = $data['filter'];
     $isAjax = isset($data['ajax']);
     unset($data['title']);
     unset($data['spout']);
     unset($data['filter']);
     unset($data['tags']);
     unset($data['ajax']);
     $spout = str_replace("_", "\\", $spout);
     // check if source already exists
     $id = \F3::get('PARAMS["id"]');
     $sourceExists = $sourcesDao->isValid('id', $id);
     // load password value if not changed for spouts containing passwords
     if ($sourceExists) {
         $spoutLoader = new \helpers\SpoutLoader();
         $spoutInstance = $spoutLoader->get($spout);
         foreach ($spoutInstance->params as $spoutParamName => $spoutParam) {
             if ($spoutParam['type'] == 'password' && empty($data[$spoutParamName])) {
                 if (!isset($oldSource)) {
                     $oldSource = $sourcesDao->get($id);
                     $oldParams = json_decode(html_entity_decode($oldSource['params']), true);
                 }
                 $data[$spoutParamName] = $oldParams[$spoutParamName];
             }
         }
     }
     $validation = $sourcesDao->validate($title, $spout, $data);
     if ($validation !== true) {
         $this->view->error(json_encode($validation));
     }
     // add/edit source
     if (!$sourceExists) {
         $id = $sourcesDao->add($title, $tags, $filter, $spout, $data);
     } else {
         $sourcesDao->edit($id, $title, $tags, $filter, $spout, $data);
     }
     // autocolor tags
     $tagsDao = new \daos\Tags();
     $tags = explode(",", $tags);
     foreach ($tags as $tag) {
         $tagsDao->autocolorTag(trim($tag));
     }
     // cleanup tags
     $tagsDao->cleanup($sourcesDao->getAllTags());
     $return = array('success' => true, 'id' => $id);
     // only for selfoss ui (update stats in navigation)
     if ($isAjax) {
         // 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);
 }
コード例 #6
0
ファイル: Sources.php プロジェクト: gabor-udvari/selfoss
 /**
  * render spouts params
  * json
  *
  * @return void
  */
 public function write()
 {
     $sourcesDao = new \daos\Sources();
     // read data
     parse_str(\F3::get('BODY'), $data);
     if (!isset($data['title'])) {
         $this->view->jsonError(array('title' => 'no data for title given'));
     }
     if (!isset($data['spout'])) {
         $this->view->jsonError(array('spout' => 'no data for spout given'));
     }
     // clean up title and tag data to prevent XSS
     $title = htmlspecialchars($data['title']);
     $tags = htmlspecialchars($data['tags']);
     $spout = $data['spout'];
     $isAjax = isset($data['ajax']);
     unset($data['title']);
     unset($data['spout']);
     unset($data['tags']);
     unset($data['ajax']);
     $spout = str_replace("_", "\\", $spout);
     $validation = $sourcesDao->validate($title, $spout, $data);
     if ($validation !== true) {
         $this->view->error(json_encode($validation));
     }
     // add/edit source
     $id = \F3::get('PARAMS["id"]');
     if (!$sourcesDao->isValid('id', $id)) {
         $id = $sourcesDao->add($title, $tags, $spout, $data);
     } else {
         $sourcesDao->edit($id, $title, $tags, $spout, $data);
     }
     // autocolor tags
     $tagsDao = new \daos\Tags();
     $tags = explode(",", $tags);
     foreach ($tags as $tag) {
         $tagsDao->autocolorTag(trim($tag));
     }
     // cleanup tags
     $tagsDao->cleanup($sourcesDao->getAllTags());
     $return = array('success' => true, 'id' => $id);
     // only for selfoss ui (update stats in navigation)
     if ($isAjax) {
         // 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);
 }