diff options
| author | 2012-10-23 22:33:16 +0200 | |
|---|---|---|
| committer | 2012-10-23 22:33:16 +0200 | |
| commit | 5383f6206c6dfc7f2fe2376c12ce8879783e3506 (patch) | |
| tree | 5722d302bd43a0c74567e87aaf380f8ac11396e2 /app/controllers/feedController.php | |
| parent | fca236dc6d6ff6e09182c560f3566904cbc7a70a (diff) | |
ajout fonction importation fichiers OPMs OPML
Diffstat (limited to 'app/controllers/feedController.php')
| -rwxr-xr-x | app/controllers/feedController.php | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 0a56af2ac..789d2a901 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -96,16 +96,56 @@ class feedController extends ActionController { Request::forward (array (), true); } - public function massiveImport () { + public function massiveImportAction () { + $entryDAO = new EntryDAO (); $feedDAO = new FeedDAO (); + $catDAO = new CategoryDAO (); + + $categories = Request::param ('categories', array ()); $feeds = Request::param ('feeds', array ()); + foreach ($categories as $cat) { + $values = array ( + 'id' => $cat->id (), + 'name' => $cat->name (), + 'color' => $cat->color () + ); + $catDAO->addCategory ($values); + $catDAO->save (); + } + foreach ($feeds as $feed) { + $feed->load (); + $entries = $feed->entries (false); + $feed_entries = array (); + + // Chargement du flux + if ($entries !== false) { + foreach ($entries as $entry) { + $values = array ( + 'id' => $entry->id (), + 'guid' => $entry->guid (), + 'title' => $entry->title (), + 'author' => $entry->author (), + 'content' => $entry->content (), + 'link' => $entry->link (), + 'date' => $entry->date (true), + 'is_read' => $entry->isRead (), + 'is_favorite' => $entry->isFavorite (), + 'feed' => $feed->id () + ); + $entryDAO->addEntry ($values); + + $feed_entries[] = $entry->id (); + } + } + + // Enregistrement du flux $values = array ( 'id' => $feed->id (), 'url' => $feed->url (), 'category' => $feed->category (), - 'entries' => array (), + 'entries' => $feed_entries, 'name' => $feed->name (), 'website' => $feed->website (), 'description' => $feed->description (), |
