public function feed($object = false) { if ($object) { $feedDAO = new FreshRSS_FeedDAO(); return $feedDAO->searchById($this->feed); } else { return $this->feed; } }
public function feeds() { if ($this->feeds === null) { $feedDAO = new FreshRSS_FeedDAO(); $this->feeds = $feedDAO->listByCategory($this->id()); $this->nbFeed = 0; $this->nbNotRead = 0; foreach ($this->feeds as $feed) { $this->nbFeed++; $this->nbNotRead += $feed->nbNotRead(); } } return $this->feeds; }
public static function daoToCategoryPrepopulated($listDAO) { $list = array(); if (!is_array($listDAO)) { $listDAO = array($listDAO); } $previousLine = null; $feedsDao = array(); foreach ($listDAO as $line) { if ($previousLine['c_id'] != null && $line['c_id'] !== $previousLine['c_id']) { // End of the current category, we add it to the $list $cat = new FreshRSS_Category($previousLine['c_name'], FreshRSS_FeedDAO::daoToFeed($feedsDao, $previousLine['c_id'])); $cat->_id($previousLine['c_id']); $list[$previousLine['c_id']] = $cat; $feedsDao = array(); //Prepare for next category } $previousLine = $line; $feedsDao[] = $line; } // add the last category if ($previousLine != null) { $cat = new FreshRSS_Category($previousLine['c_name'], FreshRSS_FeedDAO::daoToFeed($feedsDao, $previousLine['c_id'])); $cat->_id($previousLine['c_id']); $list[$previousLine['c_id']] = $cat; } return $list; }
public function importExportAction() { require_once LIB_PATH . '/lib_opml.php'; $catDAO = new FreshRSS_CategoryDAO(); $this->view->categories = $catDAO->listCategories(); $this->view->req = Minz_Request::param('q'); if ($this->view->req == 'export') { Minz_View::_title('freshrss_feeds.opml'); $this->view->_useLayout(false); header('Content-Type: application/xml; charset=utf-8'); header('Content-disposition: attachment; filename=freshrss_feeds.opml'); $feedDAO = new FreshRSS_FeedDAO(); $catDAO = new FreshRSS_CategoryDAO(); $list = array(); foreach ($catDAO->listCategories() as $key => $cat) { $list[$key]['name'] = $cat->name(); $list[$key]['feeds'] = $feedDAO->listByCategory($cat->id()); } $this->view->categories = $list; } elseif ($this->view->req == 'import' && Minz_Request::isPost()) { if ($_FILES['file']['error'] == 0) { invalidateHttpCache(); // on parse le fichier OPML pour récupérer les catégories et les flux associés try { list($categories, $feeds) = opml_import(file_get_contents($_FILES['file']['tmp_name'])); // On redirige vers le controller feed qui va se charger d'insérer les flux en BDD // les flux sont mis au préalable dans des variables de Request Minz_Request::_param('q', 'null'); Minz_Request::_param('categories', $categories); Minz_Request::_param('feeds', $feeds); Minz_Request::forward(array('c' => 'feed', 'a' => 'massiveImport')); } catch (FreshRSS_Opml_Exception $e) { Minz_Log::record($e->getMessage(), Minz_Log::WARNING); $notif = array('type' => 'bad', 'content' => Minz_Translate::t('bad_opml_file')); Minz_Session::_param('notification', $notif); Minz_Request::forward(array('c' => 'configure', 'a' => 'importExport'), true); } } } $feedDAO = new FreshRSS_FeedDAO(); $this->view->feeds = $feedDAO->listFeeds(); // au niveau de la vue, permet de ne pas voir un flux sélectionné dans la liste $this->view->flux = false; Minz_View::prependTitle(Minz_Translate::t('import_export_opml') . ' · '); }
public function purgeAction() { @set_time_limit(300); $nb_month_old = max($this->view->conf->old_entries, 1); $date_min = time() - 3600 * 24 * 30 * $nb_month_old; $feedDAO = new FreshRSS_FeedDAO(); $feeds = $feedDAO->listFeedsOrderUpdate(); $nbTotal = 0; invalidateHttpCache(); foreach ($feeds as $feed) { $feedHistory = $feed->keepHistory(); if ($feedHistory == -2) { //default $feedHistory = $this->view->conf->keep_history_default; } if ($feedHistory >= 0) { $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, $feedHistory); if ($nb > 0) { $nbTotal += $nb; Minz_Log::record($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG); $feedDAO->updateLastUpdate($feed->id()); } } } invalidateHttpCache(); $notif = array('type' => 'good', 'content' => Minz_Translate::t('purge_completed', $nbTotal)); Minz_Session::_param('notification', $notif); Minz_Request::forward(array('c' => 'configure', 'a' => 'archiving'), true); }
public function nbNotRead() { if ($this->nbNotRead < 0) { $feedDAO = new FreshRSS_FeedDAO(); $this->nbNotRead = $feedDAO->countNotRead($this->id()); } return $this->nbNotRead; }
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; } }
public function actualizeAction() { header('Content-Type: text/javascript; charset=UTF-8'); $feedDAO = new FreshRSS_FeedDAO(); $this->view->feeds = $feedDAO->listFeedsOrderUpdate(); }
public function deleteAction() { if (Minz_Request::isPost()) { $type = Minz_Request::param('type', 'feed'); $id = Minz_Request::param('id'); $feedDAO = new FreshRSS_FeedDAO(); if ($type == 'category') { if ($feedDAO->deleteFeedByCategory($id)) { $notif = array('type' => 'good', 'content' => Minz_Translate::t('category_emptied')); //TODO: Delete old favicons } else { $notif = array('type' => 'bad', 'content' => Minz_Translate::t('error_occured')); } } else { if ($feedDAO->deleteFeed($id)) { $notif = array('type' => 'good', 'content' => Minz_Translate::t('feed_deleted')); //TODO: Delete old favicon } else { $notif = array('type' => 'bad', 'content' => Minz_Translate::t('error_occured')); } } Minz_Session::_param('notification', $notif); if ($type == 'category') { Minz_Request::forward(array('c' => 'configure', 'a' => 'categorize'), true); } else { Minz_Request::forward(array('c' => 'configure', 'a' => 'feed'), true); } } }