From 19407e1ab6df2c239017fb20e47d6201bdaab223 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 13:40:48 +0200 Subject: Structure pour l'internationalisation terminée (voir bug #38) : il reste à faire la traduction en anglais notamment, rajouter une option pour changer la langue, détecter la langue préférée de l'utilisateur et voir si on peut migrer facilement l'installateur aussi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/apiController.php | 6 ++--- app/controllers/configureController.php | 28 ++++++++++----------- app/controllers/entryController.php | 10 ++++---- app/controllers/feedController.php | 44 ++++++++++++++------------------- app/controllers/indexController.php | 12 ++++----- 5 files changed, 46 insertions(+), 54 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/apiController.php b/app/controllers/apiController.php index bc08386b5..025908f3e 100755 --- a/app/controllers/apiController.php +++ b/app/controllers/apiController.php @@ -20,11 +20,11 @@ class apiController extends ActionController { $notes = $e->notes (); if ($notes == '') { $feed = $e->feed (true); - $notes = 'Article publié initialement sur ' . $feed->name () . ''; if($author != '') { - $notes .= ' par ' . $author; + $notes = Translate::t ('article_published_on_author', $feed->website (), $feed->name (), $author); + } else { + $notes = Translate::t ('article_published_on', $feed->website (), $feed->name ()); } - $notes .= ', mis en favoris dans FreshRSS'; } $id = $e->id (); diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 18a56c066..7e73fd2ba 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -5,7 +5,7 @@ class configureController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) + array ('error' => array (Translate::t ('access denied'))) ); } } @@ -48,7 +48,7 @@ class configureController extends ActionController { // notif $notif = array ( 'type' => 'good', - 'content' => 'Les catégories ont été mises à jour' + 'content' => Translate::t ('categories_updated') ); Session::_param ('notification', $notif); @@ -58,7 +58,7 @@ class configureController extends ActionController { $this->view->categories = $catDAO->listCategories (); $this->view->defaultCategory = $catDAO->getDefault (); - View::prependTitle ('Gestion des catégories - '); + View::prependTitle (Translate::t ('categories_management') . ' - '); } public function feedAction () { @@ -80,7 +80,7 @@ class configureController extends ActionController { if (!$this->view->flux) { Error::error ( 404, - array ('error' => array ('La page que vous cherchez n\'existe pas')) + array ('error' => array (Translate::t ('page_not_found'))) ); } else { $catDAO = new CategoryDAO (); @@ -102,12 +102,12 @@ class configureController extends ActionController { $notif = array ( 'type' => 'good', - 'content' => 'Le flux a été mis à jour' + 'content' => Translate::t ('feed_updated') ); } else { $notif = array ( 'type' => 'bad', - 'content' => 'Une erreur est survenue lors de la mise à jour' + 'content' => Translate::t ('error_occurred_update') ); } @@ -115,10 +115,10 @@ class configureController extends ActionController { Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true); } - View::prependTitle ('Gestion des flux RSS - ' . $this->view->flux->name () . ' - '); + View::prependTitle (Translate::t ('rss_feed_management') . ' - ' . $this->view->flux->name () . ' - '); } } else { - View::prependTitle ('Gestion des flux RSS - '); + View::prependTitle (Translate::t ('rss_feed_management') . ' - '); } } @@ -167,21 +167,21 @@ class configureController extends ActionController { // notif $notif = array ( 'type' => 'good', - 'content' => 'La configuration a été mise à jour' + 'content' => Translate::t ('configuration_updated') ); Session::_param ('notification', $notif); Request::forward (array ('c' => 'configure', 'a' => 'display'), true); } - View::prependTitle ('Gestion générale et affichage - '); + View::prependTitle (Translate::t ('general_and_reading_management') . ' - '); } public function importExportAction () { $this->view->req = Request::param ('q'); if ($this->view->req == 'export') { - View::_title ('feeds_opml.xml'); + View::_title ('feeds.opml'); $this->view->_useLayout (false); header('Content-Type: text/xml; charset=utf-8'); @@ -212,7 +212,7 @@ class configureController extends ActionController { $this->view->feeds = $feedDAO->listFeeds (); $this->view->flux = false; - View::prependTitle ('Importation et exportation OPML - '); + View::prependTitle (Translate::t ('import_export_opml') . ' - '); } public function shortcutAction () { @@ -251,13 +251,13 @@ class configureController extends ActionController { // notif $notif = array ( 'type' => 'good', - 'content' => 'Les raccourcis ont été mis à jour' + 'content' => Translate::t ('shortcuts_updated') ); Session::_param ('notification', $notif); Request::forward (array ('c' => 'configure', 'a' => 'shortcut'), true); } - View::prependTitle ('Gestion des raccourcis - '); + View::prependTitle (Translate::t ('shortcuts_management') . ' - '); } } diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index e3c4fe165..2ce260297 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -5,7 +5,7 @@ class entryController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) + array ('error' => array (Translate::t ('access denied'))) ); } @@ -63,7 +63,7 @@ class entryController extends ActionController { // notif $notif = array ( 'type' => 'good', - 'content' => 'Les flux ont été marqués comme lu' + 'content' => Translate::t ('feeds_marked_read') ); Session::_param ('notification', $notif); } else { @@ -130,12 +130,12 @@ class entryController extends ActionController { if ($entryDAO->updateEntry ($id, $values)) { $notif = array ( 'type' => 'good', - 'content' => 'Modifications enregistrées' + 'content' => Translate::t ('updated') ); } else { $notif = array ( 'type' => 'bad', - 'content' => 'Une erreur est survenue' + 'content' => Translate::t ('error_occured') ); } Session::_param ('notification', $notif); @@ -157,7 +157,7 @@ class entryController extends ActionController { if ($not_found) { Error::error ( 404, - array ('error' => array ('La page que vous cherchez n\'existe pas')) + array ('error' => array (Translate::t ('page_not_found'))) ); } else { $this->view->entry = $entry; diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index c67609d57..1232ddff4 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -10,7 +10,7 @@ class feedController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) + array ('error' => array (Translate::t ('access_denied'))) ); } else { if (Request::isPost ()) { @@ -37,7 +37,7 @@ class feedController extends ActionController { if ($feedDAO->searchByUrl ($values['url'])) { $notif = array ( 'type' => 'bad', - 'content' => 'Vous êtes déjà abonné à ' . $feed->name () . '' + 'content' => Translate::t ('already_subscribed', $feed->name ()) ); Session::_param ('notification', $notif); } elseif ($feedDAO->addFeed ($values)) { @@ -52,7 +52,7 @@ class feedController extends ActionController { // notif $notif = array ( 'type' => 'good', - 'content' => 'Le flux ' . $feed->name () . ' a bien été ajouté' + 'content' => Translate::t ('feed_added', $feed->name ()) ); Session::_param ('notification', $notif); $params['id'] = $feed->id (); @@ -60,7 +60,7 @@ class feedController extends ActionController { // notif $notif = array ( 'type' => 'bad', - 'content' => '' . $feed->name () . ' n\' a pas pu être ajouté' + 'content' => Translate::t ('feed_not_added', $feed->name ()) ); Session::_param ('notification', $notif); } @@ -68,22 +68,14 @@ class feedController extends ActionController { Log::record ($e->getMessage (), Log::ERROR); $notif = array ( 'type' => 'bad', - 'content' => 'Un problème interne a été rencontré, le flux n\'a pas pu être ajouté' - ); - Session::_param ('notification', $notif); - } catch (FileNotExistException $e) { - Log::record ($e->getMessage (), Log::ERROR); - // notif - $notif = array ( - 'type' => 'bad', - 'content' => 'Un problème de configuration a empêché l\'ajout du flux. Voir les logs pour plus d\'informations' + 'content' => Translate::t ('internal_problem_feed') ); Session::_param ('notification', $notif); } catch (Exception $e) { // notif $notif = array ( 'type' => 'bad', - 'content' => 'L\'url ' . $url . ' est invalide' + 'content' => Translate::t ('invalid_url', $url) ); Session::_param ('notification', $notif); } @@ -144,18 +136,18 @@ class feedController extends ActionController { $feed = reset ($feeds); $notif = array ( 'type' => 'good', - 'content' => '' . $feed->name () . ' a été mis à jour' + 'content' => Translate::t ('feed_actualized', $feed->name ()) ); $url['params'] = array ('get' => 'f_' . $feed->id ()); } elseif ($i > 0) { $notif = array ( 'type' => 'good', - 'content' => $i . ' flux ont été mis à jour' + 'content' => Translate::t ('n_feeds_actualized', $i) ); } else { $notif = array ( 'type' => 'bad', - 'content' => 'Aucun flux n\'a pu être mis à jour' + 'content' => Translate::t ('no_feed_actualized') ); } @@ -165,7 +157,7 @@ class feedController extends ActionController { } else { $notif = array ( 'type' => 'good', - 'content' => 'Les flux ont été mis à jour' + 'content' => Translate::t ('feeds_actualized') ); Session::_param ('notification', $notif); $this->view->_useLayout (false); @@ -176,7 +168,7 @@ class feedController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) + array ('error' => array (Translate::t ('access_denied'))) ); } else { $entryDAO = new EntryDAO (); @@ -219,9 +211,9 @@ class feedController extends ActionController { } if ($error) { - $res = 'Les flux ont été importés mais des erreurs sont survenus'; + $res = Translate::t ('feeds_imported_with_errors'); } else { - $res = 'Les flux ont été importés'; + $res = Translate::t ('feeds_imported'); } $notif = array ( 'type' => 'good', @@ -240,7 +232,7 @@ class feedController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page')) + array ('error' => array (Translate::t ('access_denied'))) ); } else { $type = Request::param ('type', 'feed'); @@ -251,24 +243,24 @@ class feedController extends ActionController { if ($feedDAO->deleteFeedByCategory ($id)) { $notif = array ( 'type' => 'good', - 'content' => 'La catégorie a été vidée' + 'content' => Translate::t ('category_emptied') ); } else { $notif = array ( 'type' => 'bad', - 'content' => 'Un problème est survenu' + 'content' => Translate::t ('error_occured') ); } } else { if ($feedDAO->deleteFeed ($id)) { $notif = array ( 'type' => 'good', - 'content' => 'Le flux a été supprimé' + 'content' => Translate::t ('feed_deleted') ); } else { $notif = array ( 'type' => 'bad', - 'content' => 'Un problème est survenu' + 'content' => Translate::t ('error_occured') ); } } diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 8fa911631..dfdcfde42 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -35,13 +35,13 @@ class indexController extends ActionController { // Récupère les flux par catégorie, favoris ou tous if ($this->get['type'] == 'all') { $entries = $entryDAO->listEntries ($this->mode, $search, $order); - View::prependTitle ('Vos flux RSS - '); + View::prependTitle (Translate::t ('your_rss_feeds') . ' - '); } elseif ($this->get['type'] == 'favoris') { $entries = $entryDAO->listFavorites ($this->mode, $search, $order); - View::prependTitle ('Vos favoris - '); + View::prependTitle (Translate::t ('your_favorites') . ' - '); } elseif ($this->get['type'] == 'public') { $entries = $entryDAO->listPublic ($this->mode, $search, $order); - View::prependTitle ('Public - '); + View::prependTitle (Translate::t ('public') . ' - '); } elseif ($this->get != false) { if ($this->get['type'] == 'c') { $cat = $catDAO->searchById ($this->get['filter']); @@ -72,7 +72,7 @@ class indexController extends ActionController { if ($error) { Error::error ( 404, - array ('error' => array ('La page que vous cherchez n\'existe pas')) + array ('error' => array (Translate::t ('page_not_found'))) ); } else { $this->view->mode = $this->mode; @@ -93,7 +93,7 @@ class indexController extends ActionController { } public function aboutAction () { - View::prependTitle ('À propos - '); + View::prependTitle (Translate::t ('about') . ' - '); } public function changeModeAction () { @@ -143,7 +143,7 @@ class indexController extends ActionController { } else { $res = array (); $res['status'] = 'failure'; - $res['reason'] = 'L\'identifiant est invalide'; + $res['reason'] = Translate::t ('invalid_login'); } $this->view->res = json_encode ($res); -- cgit v1.2.3 From 6efbedd1890b482a432254babc060713606ca6bf Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 14:15:41 +0200 Subject: Changement du nom du fichier lors de l'export des flux au format OPML --- app/controllers/configureController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 7e73fd2ba..748d236b7 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -185,7 +185,7 @@ class configureController extends ActionController { $this->view->_useLayout (false); header('Content-Type: text/xml; charset=utf-8'); - header('Content-disposition: attachment; filename=feeds_opml.xml'); + header('Content-disposition: attachment; filename=freshrss_feeds.opml'); $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); -- cgit v1.2.3 From 70e7d09b967b903aed4d97d7eb66800f395f838c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 16:16:49 +0200 Subject: Ajout fichier traduction en anglais (bug #38 --- app/controllers/configureController.php | 2 +- app/controllers/entryController.php | 2 +- app/i18n/en.php | 216 ++++++++++++++++++++++++++++++++ app/i18n/fr.php | 8 +- 4 files changed, 222 insertions(+), 6 deletions(-) create mode 100644 app/i18n/en.php (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 748d236b7..11b55f4b0 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -5,7 +5,7 @@ class configureController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array (Translate::t ('access denied'))) + array ('error' => array (Translate::t ('access_denied'))) ); } } diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index 2ce260297..35f3150ea 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -5,7 +5,7 @@ class entryController extends ActionController { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, - array ('error' => array (Translate::t ('access denied'))) + array ('error' => array (Translate::t ('access_denied'))) ); } diff --git a/app/i18n/en.php b/app/i18n/en.php new file mode 100644 index 000000000..23b2ae17b --- /dev/null +++ b/app/i18n/en.php @@ -0,0 +1,216 @@ + 'Login', + 'logout' => 'Logout', + 'search_on_title' => 'Search (only on titles)', + + 'configuration' => 'Configuration', + 'general_and_reading' => 'General and reading', + 'categories' => 'Categories', + 'category' => 'Catégory', + 'shortcuts' => 'Shortcuts', + 'about' => 'About', + + 'your_rss_feeds' => 'Your RSS feeds', + 'add_rss_feed' => 'Add a RSS feed', + 'no_rss_feed' => 'No RSS feed', + 'import_export_opml' => 'Import / export (OPML)', + + 'subscription_management' => 'Subscriptions management', + 'all_feeds' => 'All (%d)', + 'favorite_feeds' => 'Favorites (%d)', + 'not_read' => '%d unread', + 'not_reads' => '%d unread', + + 'filter' => 'Filter', + 'see_website' => 'See website', + 'administration' => 'Manage', + 'actualize' => 'Actualize', + + 'mark_read' => 'Mark as read', + 'mark_favorite' => 'Mark as favorite', + 'mark_all_read' => 'Mark all as read', + 'mark_feed_read' => 'Mark feed as read', + 'mark_cat_read' => 'Mark category as read', + 'before_one_day' => 'Before one day', + 'before_one_week' => 'Before one week', + 'display' => 'Display', + 'show_all_articles' => 'Show all articles', + 'show_not_reads' => 'Show only unread', + 'older_first' => 'Oldest first', + 'newer_first' => 'Newer first', + + // CONTROLLERS + 'article_published_on' => 'This article originally appeared on %s', + 'article_published_on_author' => 'This article originally appeared on %s by %s', + + 'access_denied' => 'You don\'t have permission to access this page', + 'page_not_found' => 'You are looking for a page which doesn\'t exist', + 'error_occurred' => 'An error occured', + 'error_occurred_update' => 'An error occured during update', + + 'categories_updated' => 'Categories have been updated', + 'categories_management' => 'Categories management', + 'feed_updated' => 'Feed has been updated', + 'rss_feed_management' => 'RSS feeds management', + 'configuration_updated' => 'Configuration has been updated', + 'general_and_reading_management'=> 'General and reading management', + 'shortcuts_updated' => 'Shortcuts have been updated', + 'shortcuts_management' => 'Shortcuts management', + 'feeds_marked_read' => 'Feeds have been marked as read', + 'updated' => 'Modifications have been updated', + + 'already_subscribed' => 'You have already subscribed to %s', + 'feed_added' => 'RSS feed %s has been added', + 'feed_not_added' => '%s could not be added', + 'internal_problem_feed' => 'An internal problem occured, RSS feed could not be added', + 'invalid_url' => 'URL %s is invalid', + 'feed_actualized' => '%s has been updated', + 'n_feeds_actualized' => '%d feeds have been updated', + 'feeds_actualized' => 'RSS feeds have been updated', + 'no_feed_actualized' => 'No RSS feed has been updated', + 'feeds_imported_with_errors' => 'Feeds have been imported but errors occured', + 'feeds_imported' => 'Feeds have been imported', + 'category_emptied' => 'Category has been emptied', + 'feed_deleted' => 'Feed has been deleted', + + 'your_rss_feeds' => 'Your RSS feeds', + 'your_favorites' => 'Your favorites', + 'public' => 'Public', + 'invalid_login' => 'Login is invalid', + + // VIEWS + 'save' => 'Save', + 'delete' => 'Delete', + 'cancel' => 'Cancel', + + 'back_to_rss_feeds' => '← Go back to your RSS feeds', + 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under %s.', + 'category_number' => 'Category n°%d', + 'ask_empty' => 'Clear ?', + 'number_feeds' => '%d feeds', + 'can_not_be_deleted' => 'Can not be deleted', + 'add_category' => 'Add a category', + 'new_category' => 'New category', + + 'javascript_for_shortcuts' => 'Javascript must be enabled in order to use shortcuts', + 'javascript_should_be_activated'=> 'Javascript must be enabled', + 'shift_for_all_read' => '+ shift to mark all articles as read', + 'see_on_website' => 'See article on its original website', + 'next_article' => 'Skip to the next article', + 'shift_for_last' => '+ shift to skip to the last article of page', + 'previous_article' => 'Skip to the previous article', + 'shift_for_first' => '+ shift to skip to the first article of page', + 'next_page' => 'Skip to the next page', + 'previous_page' => 'Skip to the previous page', + + 'file_to_import' => 'File to import', + 'import' => 'Import', + 'export' => 'Export', + 'or' => 'or', + + 'informations' => 'Informations', + 'website_url' => 'Website URL', + 'feed_url' => 'Feed URL', + 'number_articles' => 'Number of articles', + 'categorize' => 'Store in a category', + 'advanced' => 'Advanced', + 'show_in_all_flux' => 'Show in principal stream', + 'yes' => 'Yes', + 'no' => 'No', + 'css_path_on_website' => 'Articles CSS path on original website', + 'retrieve_truncated_feeds' => 'Retrieves truncated RSS feeds (attention, requires more time!)', + 'http_username' => 'HTTP username', + 'http_password' => 'HTTP password', + 'blank_to_disable' => 'Leave blank to disable', + 'not_yet_implemented' => 'Not yet implemented', + 'access_protected_feeds' => 'Connection allows to access HTTP protected RSS feeds', + 'no_selected_feed' => 'No feed selected.', + 'think_to_add' => 'Think to add RSS feeds!', + + 'general_configuration' => 'General configuration', + 'delete_articles_every' => 'Remove articles every', + 'month' => 'months', + 'persona_connection_email' => 'Login mail address (use Persona)', + 'reading_configuration' => 'Reading configuration', + 'articles_per_page' => 'Number of articles per page', + 'default_view' => 'Default view', + 'sort_order' => 'Sort order', + 'display_articles_unfolded' => 'Show articles unfolded by default', + 'auto_read_when' => 'Mark automatically as read when', + 'article_selected' => 'Article is selected', + 'article_open_on_website' => 'Article is opened on its original website', + 'page_loaded' => 'Page is loaded', + 'your_shaarli' => 'Your Shaarli', + 'sharing' => 'Sharing', + 'share' => 'Share', + 'by_email' => 'By mail', + 'on_shaarli' => 'On your Shaarli', + + 'note' => 'Note', + 'add_note' => 'Add a note', + 'update_note' => 'Update your note', + 'ask_public_article' => 'Public article?', + 'article' => 'Article', + 'title' => 'Title', + 'author' => 'Author', + 'publication_date' => 'Date of publication', + + 'newer' => 'newer', + 'older' => 'older', + + 'rss_feeds_of' => 'RSS feed of %s', + + 'refresh' => 'Refresh', + + 'today' => 'Today', + 'yesterday' => 'Yesterday', + 'before_yesterday' => 'Before yesterday', + 'by_author' => 'By %s', + 'related_tags' => 'Related tags', + 'no_feed_to_display' => 'No feed to show.', + + 'about_freshrss' => 'About FreshRSS', + 'project_website' => 'Project website', + 'lead_developer' => 'Lead developer', + 'website' => 'Website', + 'bugs_reports' => 'Bugs reports', + 'github_or_email' => 'on Github or by mail', + 'license' => 'License', + 'agpl3' => 'AGPL 3', + 'freshrss_description' => 'FreshRSS est un agrégateur de flux RSS à auto-héberger à l\'image de RSSLounge, TinyTinyRSS ou Leed. Il se veut léger et facile à prendre en main tout en étant un outil puissant et paramétrable. L\'objectif étant d\'offrir une alternative sérieuse au futur feu-Google Reader.', + 'credits' => 'Credits', + 'credits_content' => 'Des éléments de design sont issus du projet Bootstrap bien que FreshRSS n\'utilise pas ce framework. Les icônes sont issues du projet GNOME. La police Open Sans utilisée a été créée par Steve Matteson. Les favicons sont récupérés grâce au site getFavicon. FreshRSS repose sur Minz, un framework PHP.', + + // DATE + 'january' => 'january', + 'february' => 'february', + 'march' => 'march', + 'april' => 'april', + 'may' => 'may', + 'june' => 'june', + 'july' => 'july', + 'august' => 'august', + 'september' => 'september', + 'october' => 'october', + 'november' => 'november', + 'december' => 'décember', + // special format for date() function + 'Jan' => '\J\a\n\u\a\r\y', + 'Feb' => '\F\e\b\r\u\a\r\y', + 'Mar' => '\M\a\r\c\h', + 'Apr' => '\A\p\r\i\l', + 'May' => '\M\a\y', + 'Jun' => '\J\u\n\e', + 'Jul' => '\J\u\l\y', + 'Aug' => '\A\u\g\u\s\t', + 'Sep' => '\S\e\p\t\e\m\b\e\r', + 'Oct' => '\O\c\t\o\b\e\r', + 'Nov' => '\N\o\v\e\m\b\e\r', + 'Dec' => '\D\e\c\e\m\b\e\r', + // format for date() function, %s allows to indicate month in letter + 'format_date' => '%s dS Y', + 'format_date_hour' => '%s dS Y \a\t H\.i', +); diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 652ec2782..39208cef8 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -43,10 +43,10 @@ return array ( 'newer_first' => 'Plus récents en premier', // CONTROLLERS - 'article_published_on' => 'Article publié initialement sur %s, mis en favoris dans FreshRSS', - 'article_published_on_author' => 'Article publié initialement sur %s par %s, mis en favoris dans FreshRSS', + 'article_published_on' => 'Article publié initialement sur %s', + 'article_published_on_author' => 'Article publié initialement sur %s par %s', - 'access denied' => 'Vous n\'avez pas le droit d\'accéder à cette page', + 'access_denied' => 'Vous n\'avez pas le droit d\'accéder à cette page', 'page_not_found' => 'La page que vous cherchez n\'existe pas', 'error_occurred' => 'Une erreur est survenue', 'error_occurred_update' => 'Une erreur est survenue lors de la mise à jour', @@ -97,7 +97,7 @@ return array ( 'javascript_for_shortcuts' => 'Le javascript doit être activé pour pouvoir profiter des raccourcis', 'javascript_should_be_activated'=> 'Le javascript doit être activé', - 'shift_for_all_read' => '+ shift pour marquer tous les articles comme non lus', + 'shift_for_all_read' => '+ shift pour marquer tous les articles comme lus', 'see_on_website' => 'Voir l\'article sur le site d\'origine', 'next_article' => 'Passer à l\'article suivant', 'shift_for_last' => '+ shift pour passer au dernier article de la page', -- cgit v1.2.3 From 70d75f0cf5304c1f8ef121538f9e4e166bb7b755 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 16:45:16 +0200 Subject: Possibilité de choisir la langue à utiliser + fin traduction en anglais (bug #38) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/App_FrontController.php | 6 ++++-- app/controllers/configureController.php | 6 ++++++ app/i18n/en.php | 5 +++-- app/i18n/fr.php | 1 + app/models/RSSConfiguration.php | 26 ++++++++++++++++++++++++-- app/views/configure/display.phtml | 12 ++++++++++++ 6 files changed, 50 insertions(+), 6 deletions(-) (limited to 'app/controllers') diff --git a/app/App_FrontController.php b/app/App_FrontController.php index 177e83b66..8b515873a 100644 --- a/app/App_FrontController.php +++ b/app/App_FrontController.php @@ -11,12 +11,12 @@ class App_FrontController extends FrontController { $this->loadModels (); Session::init (); // lancement de la session doit se faire après chargement des modèles sinon bug (pourquoi ?) - Session::_param ('language', 'fr'); - Translate::init (); $this->loadParamsView (); $this->loadStylesAndScripts (); $this->loadNotifications (); + + Translate::init (); } private function loadLibs () { @@ -41,6 +41,8 @@ class App_FrontController extends FrontController { $entryDAO = new EntryDAO (); View::_param ('nb_not_read', $entryDAO->countNotRead ()); + + Session::_param ('language', $this->conf->language ()); } private function loadStylesAndScripts () { diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 11b55f4b0..81a8e97d7 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -124,6 +124,7 @@ class configureController extends ActionController { public function displayAction () { if (Request::isPost ()) { + $language = Request::param ('language', 'en'); $nb = Request::param ('posts_per_page', 10); $view = Request::param ('default_view', 'all'); $display = Request::param ('display_posts', 'no'); @@ -135,6 +136,7 @@ class configureController extends ActionController { $openPage = Request::param ('mark_open_page', 'no'); $urlShaarli = Request::param ('shaarli', ''); + $this->view->conf->_language ($language); $this->view->conf->_postsPerPage (intval ($nb)); $this->view->conf->_defaultView ($view); $this->view->conf->_displayPosts ($display); @@ -149,6 +151,7 @@ class configureController extends ActionController { $this->view->conf->_urlShaarli ($urlShaarli); $values = array ( + 'language' => $this->view->conf->language (), 'posts_per_page' => $this->view->conf->postsPerPage (), 'default_view' => $this->view->conf->defaultView (), 'display_posts' => $this->view->conf->displayPosts (), @@ -164,6 +167,9 @@ class configureController extends ActionController { Session::_param ('conf', $this->view->conf); Session::_param ('mail', $this->view->conf->mailLogin ()); + Session::_param ('language', $this->view->conf->language ()); + Translate::reset (); + // notif $notif = array ( 'type' => 'good', diff --git a/app/i18n/en.php b/app/i18n/en.php index 23b2ae17b..203904c9d 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -131,6 +131,7 @@ return array ( 'think_to_add' => 'Think to add RSS feeds!', 'general_configuration' => 'General configuration', + 'language' => 'Language', 'delete_articles_every' => 'Remove articles every', 'month' => 'months', 'persona_connection_email' => 'Login mail address (use Persona)', @@ -180,9 +181,9 @@ return array ( 'github_or_email' => 'on Github or by mail', 'license' => 'License', 'agpl3' => 'AGPL 3', - 'freshrss_description' => 'FreshRSS est un agrégateur de flux RSS à auto-héberger à l\'image de RSSLounge, TinyTinyRSS ou Leed. Il se veut léger et facile à prendre en main tout en étant un outil puissant et paramétrable. L\'objectif étant d\'offrir une alternative sérieuse au futur feu-Google Reader.', + 'freshrss_description' => 'FreshRSS is a RSS feeds aggregator to self-host like RSSLounge, TinyTinyRSS or Leed. It is light and easy to take in hand while being powerful and configurable tool. Objective is to provide a serious alternative to Google Reader.', 'credits' => 'Credits', - 'credits_content' => 'Des éléments de design sont issus du projet Bootstrap bien que FreshRSS n\'utilise pas ce framework. Les icônes sont issues du projet GNOME. La police Open Sans utilisée a été créée par Steve Matteson. Les favicons sont récupérés grâce au site getFavicon. FreshRSS repose sur Minz, un framework PHP.', + 'credits_content' => 'Some design elements come from Bootstrap although FreshRSS doesn\'t use this framework. Icons come from GNOME project. Open Sans font police used has been created by Steve Matteson. Favicons are collected with getFavicon API. FreshRSS is based on Minz, a PHP framework.', // DATE 'january' => 'january', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 39208cef8..0473a8f94 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -131,6 +131,7 @@ return array ( 'think_to_add' => 'Pensez à en ajouter !', 'general_configuration' => 'Configuration générale', + 'language' => 'Langue', 'delete_articles_every' => 'Supprimer les articles tous les', 'month' => 'mois', 'persona_connection_email' => 'Adresse mail de connexion (utilise Persona)', diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index ca56ec3a8..00fe3fe52 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -1,6 +1,11 @@ 'English', + 'fr' => 'Français', + ); + private $language; private $posts_per_page; private $default_view; private $display_posts; @@ -13,6 +18,7 @@ class RSSConfiguration extends Model { public function __construct () { $confDAO = new RSSConfigurationDAO (); + $this->_language ($confDAO->language); $this->_postsPerPage ($confDAO->posts_per_page); $this->_defaultView ($confDAO->default_view); $this->_displayPosts ($confDAO->display_posts); @@ -24,6 +30,12 @@ class RSSConfiguration extends Model { $this->_urlShaarli ($confDAO->url_shaarli); } + public function availableLanguages () { + return $this->available_languages; + } + public function language () { + return $this->language; + } public function postsPerPage () { return $this->posts_per_page; } @@ -60,7 +72,13 @@ class RSSConfiguration extends Model { public function urlShaarli () { return $this->url_shaarli; } - + + public function _language ($value) { + if (!isset ($this->available_languages[$value])) { + $value = 'en'; + } + $this->language = $value; + } public function _postsPerPage ($value) { if (is_int (intval ($value))) { $this->posts_per_page = $value; @@ -122,6 +140,7 @@ class RSSConfiguration extends Model { } class RSSConfigurationDAO extends Model_array { + public $language = 'en'; public $posts_per_page = 20; public $default_view = 'not_read'; public $display_posts = 'no'; @@ -146,7 +165,10 @@ class RSSConfigurationDAO extends Model_array { public function __construct () { parent::__construct (PUBLIC_PATH . '/data/Configuration.array.php'); - + + if (isset ($this->array['language'])) { + $this->language = $this->array['language']; + } if (isset ($this->array['posts_per_page'])) { $this->posts_per_page = $this->array['posts_per_page']; } diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index fcae83d9a..be67896dc 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -6,6 +6,18 @@
+
+ +
+ +
+
+
-- cgit v1.2.3 From 0e95494e29353a9ae31fb1196c6c9aaf556ae981 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 21:08:29 +0200 Subject: Fix issue #26 : possibilité de s'abonner à des flux derrière authentification HTTP + correction quelques traductions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 10 +++++++++- app/controllers/feedController.php | 12 +++++++++++- app/i18n/en.php | 7 ++++--- app/i18n/fr.php | 3 ++- app/layout/aside_feed.phtml | 8 ++++++++ app/models/Feed.php | 27 ++++++++++++++++++++++----- app/views/configure/feed.phtml | 11 ++++++----- 7 files changed, 62 insertions(+), 16 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 81a8e97d7..f4d1a38e7 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -90,11 +90,19 @@ class configureController extends ActionController { $cat = Request::param ('category', 0); $path = Request::param ('path_entries', ''); $priority = Request::param ('priority', 0); + $user = Request::param ('http_user', ''); + $pass = Request::param ('http_pass', ''); + + $httpAuth = ''; + if ($user != '' || $pass != '') { + $httpAuth = $user . ':' . $pass; + } $values = array ( 'category' => $cat, 'pathEntries' => $path, - 'priority' => $priority + 'priority' => $priority, + 'httpAuth' => $httpAuth ); if ($feedDAO->updateFeed ($id, $values)) { diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 1232ddff4..c235e8b0f 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -16,11 +16,20 @@ class feedController extends ActionController { if (Request::isPost ()) { $url = Request::param ('url_rss'); $cat = Request::param ('category'); + $user = Request::param ('username'); + $pass = Request::param ('password'); $params = array (); try { $feed = new Feed ($url); $feed->_category ($cat); + + $httpAuth = ''; + if ($user != '' || $pass != '') { + $httpAuth = $user . ':' . $pass; + } + $feed->_httpAuth ($httpAuth); + $feed->load (); $feedDAO = new FeedDAO (); @@ -31,7 +40,8 @@ class feedController extends ActionController { 'name' => $feed->name (), 'website' => $feed->website (), 'description' => $feed->description (), - 'lastUpdate' => time () + 'lastUpdate' => time (), + 'httpAuth' => $feed->httpAuth (), ); if ($feedDAO->searchByUrl ($values['url'])) { diff --git a/app/i18n/en.php b/app/i18n/en.php index 921f86ddc..1bb7c2213 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -9,7 +9,7 @@ return array ( 'configuration' => 'Configuration', 'general_and_reading' => 'General and reading', 'categories' => 'Categories', - 'category' => 'Catégory', + 'category' => 'Category', 'shortcuts' => 'Shortcuts', 'about' => 'About', @@ -88,7 +88,7 @@ return array ( 'cancel' => 'Cancel', 'back_to_rss_feeds' => '← Go back to your RSS feeds', - 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under %s.', + 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under %s.', 'category_number' => 'Category n°%d', 'ask_empty' => 'Clear ?', 'number_feeds' => '%d feeds', @@ -123,6 +123,7 @@ return array ( 'no' => 'No', 'css_path_on_website' => 'Articles CSS path on original website', 'retrieve_truncated_feeds' => 'Retrieves truncated RSS feeds (attention, requires more time!)', + 'http_authentication' => 'HTTP Authentication', 'http_username' => 'HTTP username', 'http_password' => 'HTTP password', 'blank_to_disable' => 'Leave blank to disable', @@ -198,7 +199,7 @@ return array ( 'september' => 'september', 'october' => 'october', 'november' => 'november', - 'december' => 'décember', + 'december' => 'december', // special format for date() function 'Jan' => '\J\a\n\u\a\r\y', 'Feb' => '\F\e\b\r\u\a\r\y', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 3178f3687..c5bba9d07 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -123,7 +123,8 @@ return array ( 'no' => 'Non', 'css_path_on_website' => 'Chemin CSS des articles sur le site d\'origine', 'retrieve_truncated_feeds' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)', - 'http_username' => 'Username HTTP', + 'http_authentication' => 'Authentification HTTP', + 'http_username' => 'Identifiant HTTP', 'http_password' => 'Mot de passe HTTP', 'blank_to_disable' => 'Laissez vide pour désactiver', 'not_yet_implemented' => 'Pas encore implémenté', diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index ff03b5552..4be37868d 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -21,6 +21,14 @@ + + +
  • + +
  • +
  • + +
  • diff --git a/app/models/Feed.php b/app/models/Feed.php index 222e22256..08cf7425f 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -59,9 +59,13 @@ class Feed extends Model { if ($raw) { return $this->httpAuth; } else { + $pos_colon = strpos ($this->httpAuth, ':'); + $user = substr ($this->httpAuth, 0, $pos_colon); + $pass = substr ($this->httpAuth, $pos_colon + 1); + return array ( - 'username' => '', - 'password' => '' + 'username' => $user, + 'password' => $pass ); } } @@ -134,7 +138,12 @@ class Feed extends Model { ); } else { $feed = new SimplePie (); - $feed->set_feed_url (preg_replace ('/&/', '&', $this->url)); + $url = preg_replace ('/&/', '&', $this->url); + if ($this->httpAuth != '') { + $url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url); + } + + $feed->set_feed_url ($url); $feed->set_cache_location (CACHE_PATH); $feed->init (); @@ -144,6 +153,9 @@ class Feed extends Model { $subscribe_url = $feed->subscribe_url (); if (!is_null ($subscribe_url) && $subscribe_url != $this->url) { + if ($this->httpAuth != '') { + $subscribe_url = preg_replace ('#((.+)://)((.+)@)(.+)#', '${1}${5}', $subscribe_url); + } $this->_url ($subscribe_url); } $title = $feed->get_title (); @@ -205,7 +217,7 @@ class Feed extends Model { class FeedDAO extends Model_pdo { public function addFeed ($valuesTmp) { - $sql = 'INSERT INTO feed (id, url, category, name, website, description, lastUpdate, priority, error) VALUES(?, ?, ?, ?, ?, ?, ?, 10, 0)'; + $sql = 'INSERT INTO feed (id, url, category, name, website, description, lastUpdate, priority, httpAuth, error) VALUES(?, ?, ?, ?, ?, ?, ?, 10, ?, 0)'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -216,6 +228,7 @@ class FeedDAO extends Model_pdo { $valuesTmp['website'], $valuesTmp['description'], $valuesTmp['lastUpdate'], + base64_encode ($valuesTmp['httpAuth']), ); if ($stm && $stm->execute ($values)) { @@ -231,6 +244,10 @@ class FeedDAO extends Model_pdo { $set = ''; foreach ($valuesTmp as $key => $v) { $set .= $key . '=?, '; + + if ($key == 'httpAuth') { + $valuesTmp[$key] = base64_encode ($v); + } } $set = substr ($set, 0, -2); @@ -408,7 +425,7 @@ class HelperFeed { $list[$key]->_lastUpdate ($dao['lastUpdate']); $list[$key]->_priority ($dao['priority']); $list[$key]->_pathEntries ($dao['pathEntries']); - $list[$key]->_httpAuth ($dao['httpAuth']); + $list[$key]->_httpAuth (base64_decode ($dao['httpAuth'])); if (isset ($dao['id'])) { $list[$key]->_id ($dao['id']); diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 73b70ec4c..0d9c5cae6 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -58,20 +58,21 @@
    - +
    @@ -82,5 +83,5 @@
    -
    +
    -- cgit v1.2.3 From 1bee8ad9a7c02c0f53d1f334467cb6d1e5044511 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 28 Apr 2013 14:18:34 +0200 Subject: Flux déplacés de catégories lors de la suppression de la leur (issue #28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 6 +++++- app/models/Feed.php | 24 ++++++++++++++++++++++++ app/views/configure/feed.phtml | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index f4d1a38e7..d6d210099 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -11,8 +11,11 @@ class configureController extends ActionController { } public function categorizeAction () { + $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); $catDAO->checkDefault (); + $defaultCategory = $catDAO->getDefault (); + $defaultId = $defaultCategory->id (); if (Request::isPost ()) { $cats = Request::param ('categories', array ()); @@ -27,7 +30,8 @@ class configureController extends ActionController { 'color' => $cat->color () ); $catDAO->updateCategory ($ids[$key], $values); - } elseif ($ids[$key] != '000000') { + } elseif ($ids[$key] != $defaultId) { + $feedDAO->changeCategory ($ids[$key], $defaultId); $catDAO->deleteCategory ($ids[$key]); } } diff --git a/app/models/Feed.php b/app/models/Feed.php index 97cbe55d1..e519a91cb 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -296,6 +296,30 @@ class FeedDAO extends Model_pdo { } } + public function changeCategory ($idOldCat, $idNewCat) { + $catDAO = new CategoryDAO (); + $newCat = $catDAO->searchById ($idNewCat); + if (!$newCat) { + $newCat = $catDAO->getDefault (); + } + + $sql = 'UPDATE feed SET category=? WHERE category=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $newCat->id (), + $idOldCat + ); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function deleteFeed ($id) { $sql = 'DELETE FROM feed WHERE id=?'; $stm = $this->bd->prepare ($sql); diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 0d9c5cae6..33483f72d 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -2,7 +2,7 @@ flux) { ?>
    - +

    flux->name (); ?>

    flux->description (); ?> -- cgit v1.2.3 From 864318bf68b28ff6340701bce24e25768164e138 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 28 Apr 2013 16:01:14 +0200 Subject: Meilleure gestion des erreurs lors de l'ajout d'un flux RSS + les vidéos apparaissent maintenant dans les articles + si connexion paramétrée l'actualisation des flux n'est plus permis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 332 ++++++++++++++++----------------- app/layout/nav_menu.phtml | 2 +- app/models/Exception/FeedException.php | 6 + app/models/Feed.php | 14 +- 4 files changed, 184 insertions(+), 170 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index c235e8b0f..b535e7bc4 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -2,96 +2,108 @@ class feedController extends ActionController { public function firstAction () { - $catDAO = new CategoryDAO (); - $catDAO->checkDefault (); - } - - public function addAction () { if (login_is_conf ($this->view->conf) && !is_logged ()) { Error::error ( 403, array ('error' => array (Translate::t ('access_denied'))) ); - } else { - if (Request::isPost ()) { - $url = Request::param ('url_rss'); - $cat = Request::param ('category'); - $user = Request::param ('username'); - $pass = Request::param ('password'); - $params = array (); - - try { - $feed = new Feed ($url); - $feed->_category ($cat); - - $httpAuth = ''; - if ($user != '' || $pass != '') { - $httpAuth = $user . ':' . $pass; - } - $feed->_httpAuth ($httpAuth); - - $feed->load (); - - $feedDAO = new FeedDAO (); - $values = array ( - 'id' => $feed->id (), - 'url' => $feed->url (), - 'category' => $feed->category (), - 'name' => $feed->name (), - 'website' => $feed->website (), - 'description' => $feed->description (), - 'lastUpdate' => time (), - 'httpAuth' => $feed->httpAuth (), - ); + } - if ($feedDAO->searchByUrl ($values['url'])) { - $notif = array ( - 'type' => 'bad', - 'content' => Translate::t ('already_subscribed', $feed->name ()) - ); - Session::_param ('notification', $notif); - } elseif ($feedDAO->addFeed ($values)) { - $entryDAO = new EntryDAO (); - $entries = $feed->entries (); - - foreach ($entries as $entry) { - $values = $entry->toArray (); - $entryDAO->addEntry ($values); - } - - // notif - $notif = array ( - 'type' => 'good', - 'content' => Translate::t ('feed_added', $feed->name ()) - ); - Session::_param ('notification', $notif); - $params['id'] = $feed->id (); - } else { - // notif - $notif = array ( - 'type' => 'bad', - 'content' => Translate::t ('feed_not_added', $feed->name ()) - ); - Session::_param ('notification', $notif); - } - } catch (FeedException $e) { - Log::record ($e->getMessage (), Log::ERROR); + $catDAO = new CategoryDAO (); + $catDAO->checkDefault (); + } + + public function addAction () { + if (Request::isPost ()) { + $url = Request::param ('url_rss'); + $cat = Request::param ('category'); + $user = Request::param ('username'); + $pass = Request::param ('password'); + $params = array (); + + try { + $feed = new Feed ($url); + $feed->_category ($cat); + + $httpAuth = ''; + if ($user != '' || $pass != '') { + $httpAuth = $user . ':' . $pass; + } + $feed->_httpAuth ($httpAuth); + + $feed->load (); + + $feedDAO = new FeedDAO (); + $values = array ( + 'id' => $feed->id (), + 'url' => $feed->url (), + 'category' => $feed->category (), + 'name' => $feed->name (), + 'website' => $feed->website (), + 'description' => $feed->description (), + 'lastUpdate' => time (), + 'httpAuth' => $feed->httpAuth (), + ); + + if ($feedDAO->searchByUrl ($values['url'])) { + // on est déjà abonné à ce flux $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('internal_problem_feed') + 'content' => Translate::t ('already_subscribed', $feed->name ()) ); Session::_param ('notification', $notif); - } catch (Exception $e) { - // notif + } elseif (!$feedDAO->addFeed ($values)) { + // problème au niveau de la base de données $notif = array ( 'type' => 'bad', - 'content' => Translate::t ('invalid_url', $url) + 'content' => Translate::t ('feed_not_added', $feed->name ()) ); Session::_param ('notification', $notif); - } + } else { + $entryDAO = new EntryDAO (); + $entries = $feed->entries (); - Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true); + // on ajoute les articles en masse sans vérification + foreach ($entries as $entry) { + $values = $entry->toArray (); + $entryDAO->addEntry ($values); + } + + // ok, ajout terminé + $notif = array ( + 'type' => 'good', + 'content' => Translate::t ('feed_added', $feed->name ()) + ); + Session::_param ('notification', $notif); + + // permet de rediriger vers la page de conf du flux + $params['id'] = $feed->id (); + } + } catch (BadUrlException $e) { + Log::record ($e->getMessage (), Log::ERROR); + $notif = array ( + 'type' => 'bad', + 'content' => Translate::t ('invalid_url', $url) + ); + Session::_param ('notification', $notif); + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + $notif = array ( + 'type' => 'bad', + 'content' => Translate::t ('internal_problem_feed') + ); + Session::_param ('notification', $notif); + } catch (FileNotExistException $e) { + // Répertoire de cache n'existe pas + Log::record ($e->getMessage (), Log::ERROR); + $notif = array ( + 'type' => 'bad', + 'content' => Translate::t ('internal_problem_feed') + ); + Session::_param ('notification', $notif); } + + Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true); } } @@ -175,114 +187,100 @@ class feedController extends ActionController { } public function massiveImportAction () { - if (login_is_conf ($this->view->conf) && !is_logged ()) { - Error::error ( - 403, - array ('error' => array (Translate::t ('access_denied'))) - ); - } else { - $entryDAO = new EntryDAO (); - $feedDAO = new FeedDAO (); - - $categories = Request::param ('categories', array ()); - $feeds = Request::param ('feeds', array ()); - - $this->addCategories ($categories); - - $nb_month_old = $this->view->conf->oldEntries (); - $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old); - - $error = false; - $i = 0; - foreach ($feeds as $feed) { - try { - $feed->load (); - - // Enregistrement du flux - $values = array ( - 'id' => $feed->id (), - 'url' => $feed->url (), - 'category' => $feed->category (), - 'name' => $feed->name (), - 'website' => $feed->website (), - 'description' => $feed->description (), - 'lastUpdate' => 0 - ); + $entryDAO = new EntryDAO (); + $feedDAO = new FeedDAO (); + + $categories = Request::param ('categories', array ()); + $feeds = Request::param ('feeds', array ()); + + $this->addCategories ($categories); + + $nb_month_old = $this->view->conf->oldEntries (); + $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old); + + $error = false; + $i = 0; + foreach ($feeds as $feed) { + try { + $feed->load (); - if (!$feedDAO->searchByUrl ($values['url'])) { - if (!$feedDAO->addFeed ($values)) { - $error = true; - } + // Enregistrement du flux + $values = array ( + 'id' => $feed->id (), + 'url' => $feed->url (), + 'category' => $feed->category (), + 'name' => $feed->name (), + 'website' => $feed->website (), + 'description' => $feed->description (), + 'lastUpdate' => 0 + ); + + if (!$feedDAO->searchByUrl ($values['url'])) { + if (!$feedDAO->addFeed ($values)) { + $error = true; } - } catch (FeedException $e) { - $error = true; - Log::record ($e->getMessage (), Log::ERROR); } + } catch (FeedException $e) { + $error = true; + Log::record ($e->getMessage (), Log::ERROR); } + } - if ($error) { - $res = Translate::t ('feeds_imported_with_errors'); - } else { - $res = Translate::t ('feeds_imported'); - } - $notif = array ( - 'type' => 'good', - 'content' => $res - ); - Session::_param ('notification', $notif); - - Request::forward (array ( - 'c' => 'configure', - 'a' => 'importExport' - ), true); + if ($error) { + $res = Translate::t ('feeds_imported_with_errors'); + } else { + $res = Translate::t ('feeds_imported'); } + $notif = array ( + 'type' => 'good', + 'content' => $res + ); + Session::_param ('notification', $notif); + + Request::forward (array ( + 'c' => 'configure', + 'a' => 'importExport' + ), true); } public function deleteAction () { - if (login_is_conf ($this->view->conf) && !is_logged ()) { - Error::error ( - 403, - array ('error' => array (Translate::t ('access_denied'))) - ); - } else { - $type = Request::param ('type', 'feed'); - $id = Request::param ('id'); + $type = Request::param ('type', 'feed'); + $id = Request::param ('id'); - $feedDAO = new FeedDAO (); - if ($type == 'category') { - if ($feedDAO->deleteFeedByCategory ($id)) { - $notif = array ( - 'type' => 'good', - 'content' => Translate::t ('category_emptied') - ); - } else { - $notif = array ( - 'type' => 'bad', - 'content' => Translate::t ('error_occured') - ); - } + $feedDAO = new FeedDAO (); + if ($type == 'category') { + if ($feedDAO->deleteFeedByCategory ($id)) { + $notif = array ( + 'type' => 'good', + 'content' => Translate::t ('category_emptied') + ); } else { - if ($feedDAO->deleteFeed ($id)) { - $notif = array ( - 'type' => 'good', - 'content' => Translate::t ('feed_deleted') - ); - } else { - $notif = array ( - 'type' => 'bad', - 'content' => Translate::t ('error_occured') - ); - } + $notif = array ( + 'type' => 'bad', + 'content' => Translate::t ('error_occured') + ); } - - Session::_param ('notification', $notif); - - if ($type == 'category') { - Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); + } else { + if ($feedDAO->deleteFeed ($id)) { + $notif = array ( + 'type' => 'good', + 'content' => Translate::t ('feed_deleted') + ); } else { - Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + $notif = array ( + 'type' => 'bad', + 'content' => Translate::t ('error_occured') + ); } } + + Session::_param ('notification', $notif); + + if ($type == 'category') { + Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true); + } else { + Request::forward (array ('c' => 'configure', 'a' => 'feed'), true); + } } private function addCategories ($categories) { diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 1ee935db9..ce124da11 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -1,6 +1,7 @@