diff options
| author | 2012-10-23 22:33:16 +0200 | |
|---|---|---|
| committer | 2012-10-23 22:33:16 +0200 | |
| commit | 5383f6206c6dfc7f2fe2376c12ce8879783e3506 (patch) | |
| tree | 5722d302bd43a0c74567e87aaf380f8ac11396e2 /app | |
| parent | fca236dc6d6ff6e09182c560f3566904cbc7a70a (diff) | |
ajout fonction importation fichiers OPMs OPML
Diffstat (limited to 'app')
| -rwxr-xr-x | app/controllers/configureController.php | 8 | ||||
| -rwxr-xr-x | app/controllers/entryController.php | 2 | ||||
| -rwxr-xr-x | app/controllers/feedController.php | 44 | ||||
| -rw-r--r-- | app/views/configure/importExport.phtml | 2 |
4 files changed, 48 insertions, 8 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index e61eb3872..00bc571da 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -110,12 +110,12 @@ class configureController extends ActionController { $this->view->categories = $list; } elseif ($this->view->req == 'import' && Request::isPost ()) { if ($_FILES['file']['error'] == 0) { - $content = file_get_contents ($_FILES['file']['tmp_name']); - $feeds = opml_import ($content); + list ($categories, $feeds) = opml_import (file_get_contents ($_FILES['file']['tmp_name'])); - Request::_param ('q'); + Request::_param ('q', 'null'); + Request::_param ('categories', $categories); Request::_param ('feeds', $feeds); - Request::forward (array ('c' => 'feed', 'a' => 'massiveInsert')); + Request::forward (array ('c' => 'feed', 'a' => 'massiveImport')); } } } diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index 9ae7bcd07..a99038068 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -26,7 +26,7 @@ class entryController extends ActionController { $entryDAO = new EntryDAO (); if ($id == false) { - $entries = $entryDAO->listNotReadEntries (); + $entries = $entryDAO->listEntries ('not_read'); } else { $entry = $entryDAO->searchById ($id); $entries = $entry !== false ? array ($entry) : array (); 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 (), diff --git a/app/views/configure/importExport.phtml b/app/views/configure/importExport.phtml index 7f2fbd7c5..add78d1e1 100644 --- a/app/views/configure/importExport.phtml +++ b/app/views/configure/importExport.phtml @@ -14,7 +14,7 @@ <form method="post" action="<?php echo Url::display (array ('c' => 'configure', 'a' => 'importExport', 'params' => array ('q' => 'import'))); ?>" enctype="multipart/form-data"> <h1>Exporter au format OPML</h1> - <a class="button" href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'importExport', 'params' => array ('q' => 'export'))); ?>">Exporter</a> + <button formaction="<?php echo Url::display (array ('c' => 'configure', 'a' => 'importExport', 'params' => array ('q' => 'export'))); ?>">Exporter</button> <h1>Importer au format OPML</h1> <label for="file">Fichier</label> |
