Beispiel #1
0
 /**
  * Set the current $get attribute.
  *
  * Valid $get parameter are:
  *   - a
  *   - s
  *   - f_<feed id>
  *   - c_<category id>
  *
  * $name and $get_unread attributes are also updated as $next_get
  * Raise an exception if id or $get is invalid.
  */
 public static function _get($get)
 {
     $type = $get[0];
     $id = substr($get, 2);
     $nb_unread = 0;
     switch ($type) {
         case 'a':
             self::$current_get['all'] = true;
             self::$name = _t('index.feed.title');
             self::$get_unread = self::$total_unread;
             break;
         case 's':
             self::$current_get['starred'] = true;
             self::$name = _t('index.feed.title_fav');
             self::$get_unread = self::$total_starred['unread'];
             // Update state if favorite is not yet enabled.
             self::$state = self::$state | FreshRSS_Entry::STATE_FAVORITE;
             break;
         case 'f':
             // We try to find the corresponding feed.
             $feed = FreshRSS_CategoryDAO::findFeed(self::$categories, $id);
             if ($feed === null) {
                 $feedDAO = FreshRSS_Factory::createFeedDao();
                 $feed = $feedDAO->searchById($id);
                 if (!$feed) {
                     throw new FreshRSS_Context_Exception('Invalid feed: ' . $id);
                 }
             }
             self::$current_get['feed'] = $id;
             self::$current_get['category'] = $feed->category();
             self::$name = $feed->name();
             self::$get_unread = $feed->nbNotRead();
             break;
         case 'c':
             // We try to find the corresponding category.
             self::$current_get['category'] = $id;
             if (!isset(self::$categories[$id])) {
                 $catDAO = new FreshRSS_CategoryDAO();
                 $cat = $catDAO->searchById($id);
                 if (!$cat) {
                     throw new FreshRSS_Context_Exception('Invalid category: ' . $id);
                 }
             } else {
                 $cat = self::$categories[$id];
             }
             self::$name = $cat->name();
             self::$get_unread = $cat->nbNotRead();
             break;
         default:
             throw new FreshRSS_Context_Exception('Invalid getter: ' . $get);
     }
     self::_nextGet();
 }
 private function checkAndProcessType($getType, $getId)
 {
     switch ($getType) {
         case 'a':
             $this->view->currentName = Minz_Translate::t('your_rss_feeds');
             $this->nb_not_read_cat = $this->view->nb_not_read;
             $this->view->get_c = $getType;
             return true;
         case 's':
             $this->view->currentName = Minz_Translate::t('your_favorites');
             $this->nb_not_read_cat = $this->view->nb_favorites['unread'];
             $this->view->get_c = $getType;
             return true;
         case 'c':
             $cat = isset($this->view->cat_aside[$getId]) ? $this->view->cat_aside[$getId] : null;
             if ($cat === null) {
                 $catDAO = new FreshRSS_CategoryDAO();
                 $cat = $catDAO->searchById($getId);
             }
             if ($cat) {
                 $this->view->currentName = $cat->name();
                 $this->nb_not_read_cat = $cat->nbNotRead();
                 $this->view->get_c = $getId;
                 return true;
             } else {
                 return false;
             }
         case 'f':
             $feed = FreshRSS_CategoryDAO::findFeed($this->view->cat_aside, $getId);
             if (empty($feed)) {
                 $feedDAO = new FreshRSS_FeedDAO();
                 $feed = $feedDAO->searchById($getId);
             }
             if ($feed) {
                 $this->view->currentName = $feed->name();
                 $this->nb_not_read_cat = $feed->nbNotRead();
                 $this->view->get_f = $getId;
                 $this->view->get_c = $feed->category();
                 return true;
             } else {
                 return false;
             }
         default:
             return false;
     }
 }