aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/feedController.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-03-30 14:28:13 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-03-30 14:28:13 +0200
commit779afe9c4ee00f8099a423e1fceee40197a90cfa (patch)
treeabfe8682ba0032711e0eba53eb615a248943a1bd /app/Controllers/feedController.php
parent9ea3819402746d8425d4a608f2d5f3c0f5bc29fb (diff)
Import of articles is implemented!
- Remove massiveImportAction and addCategories from FeedController - Fix typo for some methods (camelCase) - addCategoryObject and addFeedObject return id if corresponding object already exists in DB - introduce addEntryObject. Return -1 if Entry already exist (in order to keep quite good performances) - Complete importArticles method Need some more tests + better performance
Diffstat (limited to 'app/Controllers/feedController.php')
-rwxr-xr-xapp/Controllers/feedController.php88
1 files changed, 0 insertions, 88 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 43435d99d..95c9c1e9c 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -327,82 +327,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
- public function massiveImportAction () {
- # TODO: this function has moved to importExportController.php
- # I keep it for the moment but should be deleted in a near future.
- @set_time_limit(300);
-
- $this->catDAO = new FreshRSS_CategoryDAO ();
- $this->catDAO->checkDefault ();
-
- $entryDAO = new FreshRSS_EntryDAO ();
- $feedDAO = new FreshRSS_FeedDAO ();
-
- $categories = Minz_Request::param ('categories', array (), true);
- $feeds = Minz_Request::param ('feeds', array (), true);
-
- // on ajoute les catégories en masse dans une fonction à part
- $this->addCategories ($categories);
-
- // on calcule la date des articles les plus anciens qu'on accepte
- $nb_month_old = $this->view->conf->old_entries;
- $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
-
- // la variable $error permet de savoir si une erreur est survenue
- // Le but est de ne pas arrêter l'import même en cas d'erreur
- // L'utilisateur sera mis au courant s'il y a eu des erreurs, mais
- // ne connaîtra pas les détails. Ceux-ci seront toutefois logguées
- $error = false;
- $i = 0;
- foreach ($feeds as $feed) {
- try {
- $values = array (
- 'id' => $feed->id (),
- 'url' => $feed->url (),
- 'category' => $feed->category (),
- 'name' => $feed->name (),
- 'website' => $feed->website (),
- 'description' => $feed->description (),
- 'lastUpdate' => 0,
- 'httpAuth' => $feed->httpAuth ()
- );
-
- // ajout du flux que s'il n'est pas déjà en BDD
- if (!$feedDAO->searchByUrl ($values['url'])) {
- $id = $feedDAO->addFeed ($values);
- if ($id) {
- $feed->_id ($id);
- $feed->faviconPrepare();
- } else {
- $error = true;
- }
- }
- } catch (FreshRSS_Feed_Exception $e) {
- $error = true;
- Minz_Log::record ($e->getMessage (), Minz_Log::WARNING);
- }
- }
-
- if ($error) {
- $res = Minz_Translate::t ('feeds_imported_with_errors');
- } else {
- $res = Minz_Translate::t ('feeds_imported');
- }
-
- $notif = array (
- 'type' => 'good',
- 'content' => $res
- );
- Minz_Session::_param ('notification', $notif);
- Minz_Session::_param ('actualize_feeds', true);
-
- // et on redirige vers la page d'accueil
- Minz_Request::forward (array (
- 'c' => 'index',
- 'a' => 'index'
- ), true);
- }
-
public function deleteAction () {
if (Minz_Request::isPost ()) {
$type = Minz_Request::param ('type', 'feed');
@@ -446,16 +370,4 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
}
-
- private function addCategories ($categories) {
- foreach ($categories as $cat) {
- if (!$this->catDAO->searchByName ($cat->name ())) {
- $values = array (
- 'id' => $cat->id (),
- 'name' => $cat->name (),
- );
- $catDAO->addCategory ($values);
- }
- }
- }
}