From a6982216253d1356621916bb2b7734320fedec0d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 24 Apr 2013 22:14:49 +0200 Subject: Fix issue #55 : affichage des tags associés aux articles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/index/index.phtml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/views') diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 6889a8b51..ff7325996 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -89,6 +89,24 @@ if (isset ($this->entryPaginator)) { + tags(); ?> + +
  • + +
  • + -- cgit v1.2.3 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 +-- app/i18n/fr.php | 146 +++++++++++++++++++++++++++++++- app/layout/nav_menu.phtml | 2 +- app/views/configure/categorize.phtml | 20 ++--- app/views/configure/display.phtml | 54 ++++++------ app/views/configure/feed.phtml | 42 ++++----- app/views/configure/importExport.phtml | 12 +-- app/views/configure/shortcut.phtml | 30 +++---- app/views/entry/note.phtml | 24 +++--- app/views/error/index.phtml | 7 +- app/views/helpers/pagination.phtml | 14 ++- app/views/helpers/rss.phtml | 2 +- app/views/index/about.phtml | 24 +++--- app/views/index/index.phtml | 27 +++--- app/views/javascript/actualize.phtml | 2 +- 19 files changed, 327 insertions(+), 179 deletions(-) (limited to 'app/views') 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); diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 753a0d469..2ddac3066 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -1,6 +1,7 @@ 'Connexion', 'logout' => 'Déconnexion', 'search_on_title' => 'Rechercher sur les titres', @@ -29,14 +30,157 @@ return array ( 'actualize' => 'Actualiser', 'mark_read' => 'Marquer comme lu', + 'mark_favorite' => 'Mettre en favori', 'mark_all_read' => 'Tout marquer comme lu', 'mark_feed_read' => 'Marquer le flux comme lu', 'mark_cat_read' => 'Marquer la catégorie comme lue', 'before_one_day' => 'Antérieurs à 1 jour', 'before_one_week' => 'Antérieurs à 1 semaine', 'display' => 'Affichage', - 'show_all' => 'Tout afficher', + 'show_all_articles' => 'Afficher tous les articles', 'show_not_reads' => 'Afficher les non lus', 'older_first' => 'Plus anciens en premier', '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', + + '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', + + 'categories_updated' => 'Les catégories ont été mises à jour', + 'categories_management' => 'Gestion des catégories', + 'feed_updated' => 'Le flux a été mis à jour', + 'rss_feed_management' => 'Gestion des flux RSS', + 'configuration_updated' => 'La configuration a été mise à jour', + 'general_and_reading_management'=> 'Gestion générale et affichage', + 'shortcuts_updated' => 'Les raccourcis ont été mis à jour', + 'shortcuts_management' => 'Gestion des raccourcis', + 'feeds_marked_read' => 'Les flux ont été marqués comme lu', + 'updated' => 'Modifications enregistrées', + + 'already_subscribed' => 'Vous êtes déjà abonné à %s', + 'feed_added' => 'Le flux %s a bien été ajouté', + 'feed_not_added' => '%s n\' a pas pu être ajouté', + 'internal_problem_feed' => 'Un problème interne a été rencontré, le flux n\'a pas pu être ajouté', + 'invalid_url' => 'L\'url %s est invalide', + 'feed_actualized' => '%s a été mis à jour', + 'n_feeds_actualized' => '%d flux ont été mis à jour', + 'feeds_actualized' => 'Les flux ont été mis à jour', + 'no_feed_actualized' => 'Aucun flux n\'a pu être mis à jour', + 'feeds_imported_with_errors' => 'Les flux ont été importés mais des erreurs sont survenues', + 'feeds_imported' => 'Les flux ont été importés', + 'category_emptied' => 'La catégorie a été vidée', + 'feed_deleted' => 'Le flux a été supprimé', + + 'your_rss_feeds' => 'Vos flux RSS', + 'your_favorites' => 'Vos favoris', + 'public' => 'Public', + 'invalid_login' => 'L\'identifiant est invalide', + + // VIEWS + 'save' => 'Enregistrer', + 'delete' => 'Supprimer', + 'cancel' => 'Annuler', + + 'back_to_rss_feeds' => '← Retour à vos flux RSS', + 'feeds_moved_category_deleted' => 'Lors de la suppression d\'une catégorie, ses flux seront automatiquement classés dans %s.', + 'category_number' => 'Catégorie n°%d', + 'ask_empty' => 'Vider ?', + 'number_feeds' => '%d flux', + 'can_not_be_deleted' => 'Ne peut pas être supprimée', + 'add_category' => 'Ajouter une catégorie', + 'new_category' => 'Nouvelle catégorie', + + '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', + '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', + 'previous_article' => 'Passer à l\'article précédent', + 'shift_for_first' => '+ shift pour passer au premier article de la page', + 'next_page' => 'Passer à la page suivante', + 'previous_page' => 'Passer à la page précédente', + + 'file_to_import' => 'Fichier à importer', + 'import' => 'Importer', + 'export' => 'Exporter', + 'or' => 'ou', + + 'informations' => 'Informations', + 'website_url' => 'URL du site', + 'feed_url' => 'URL du flux', + 'number_articles' => 'Nombre d\'articles', + 'categorize' => 'Ranger dans une catégorie', + 'advanced' => 'Avancé', + 'show_in_all_flux' => 'Afficher dans le flux principal', + 'yes' => 'Oui', + '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_password' => 'Mot de passe HTTP', + 'blank_to_disable' => 'Laissez vide pour désactiver', + 'not_yet_implemented' => 'Pas encore implémenté', + 'access_protected_feeds' => 'La connexion permet d\'accéder aux flux protégés par une authentification HTTP', + 'no_selected_feed' => 'Aucun flux sélectionné.', + 'think_to_add' => 'Pensez à en ajouter !', + + 'general_configuration' => 'Configuration générale', + 'delete_articles_every' => 'Supprimer les articles tous les', + 'month' => 'mois', + 'persona_connection_email' => 'Adresse mail de connexion (utilise Persona)', + 'reading_configuration' => 'Configuration de lecture', + 'articles_per_page' => 'Nombre d\'articles par page', + 'default_view' => 'Vue par défaut', + 'sort_order' => 'Ordre de tri', + 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', + 'auto_read_when' => 'Marquer automatiquement comme lu lorsque', + 'article_selected' => 'L\'article est sélectionné', + 'article_open_on_website' => 'L\'article est ouvert sur le site d\'origine', + 'page_loaded' => 'La page est chargée', + 'your_shaarli' => 'Votre Shaarli', + 'sharing' => 'Partage', + 'share' => 'Partager', + 'by_email' => 'Par mail', + 'on_shaarli' => 'Sur votre Shaarli', + + 'note' => 'Note', + 'add_note' => 'Ajouter une note', + 'update_note' => 'Modifier votre note', + 'ask_public_article' => 'Article public ?', + 'article' => 'Article', + 'title' => 'Titre', + 'author' => 'Auteur', + 'publication_date' => 'Date de publication', + + 'newer' => 'plus récents', + 'older' => 'plus anciens', + + 'rss_feeds_of' => 'Flux RSS de %s', + + 'refresh' => 'Actualisation', + + 'today' => 'Aujourd\'hui', + 'yesterday' => 'Hier', + 'before_yesterday' => 'À partir d\'avant-hier', + 'by_author' => 'Par %s', + 'related_tags' => 'Tags associés', + 'no_feed_to_display' => 'Il n\'y a aucun flux à afficher.', + + 'about_freshrss' => 'À propos de FreshRSS', + 'project_website' => 'Site du projet', + 'lead_developer' => 'Développeur principal', + 'website' => 'Site Internet', + 'bugs_reports' => 'Rapports de bugs', + 'github_or_email' => 'sur Github ou par mail', + 'license' => 'Licence', + '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' => 'Crédits', + '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.', ); diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 02e340ca1..1ee935db9 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -47,7 +47,7 @@
  • mode == 'not_read') { ?> - + diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 660ddef20..b6ba5c3c7 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -1,23 +1,23 @@ partial ('aside_configure'); ?>
    - ← Retour à vos flux RSS +
    - Gestion des catégories - gestion des flux + - -

    Lors de la suppression d'une catégorie, ses flux seront automatiquement classés dans defaultCategory->name (); ?>.

    +

    defaultCategory->name ()); ?>

    categories as $cat) { $i++; ?>
    - Vider ? (nbFeed (); ?> flux) + (nbFeed ()); ?>) id () == $this->defaultCategory->id ()) { ?> - ne peut pas être supprimée +
    @@ -25,16 +25,16 @@
    - +
    - +
    - - + +
    diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 79fa4b43c..fcae83d9a 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -1,104 +1,104 @@ partial ('aside_configure'); ?>
    - ← Retour à vos flux RSS +
    - Configuration générale +
    - +
    - mois +
    - + conf->mailLogin (); ?>
    - - + +
    - Configuration de lecture +
    - +
    - +
    - +
    - +
    - +
    - Partage +
    - +
    - +
    - - + +
    diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index adea27e52..73b70ec4c 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -2,35 +2,35 @@ flux) { ?>
    - ← Retour à vos flux RSS +

    flux->name (); ?>

    flux->description (); ?>
    - Informations +
    - +
    - +
    - +
    flux->nbEntries (); ?>
    - Catégorie - gestion + -
    - +
    categories as $cat) { ?>
    - Avancé +
    - +
    - +
    - - Permet de récupérer les flux tronqués (attention, demande plus de temps !) + +
    - - + +
    -
    Aucun flux sélectionné. Pensez à en ajouter !
    +
    diff --git a/app/views/configure/importExport.phtml b/app/views/configure/importExport.phtml index 34bee4a07..4cc575356 100644 --- a/app/views/configure/importExport.phtml +++ b/app/views/configure/importExport.phtml @@ -14,12 +14,12 @@ partial ('aside_feed'); ?>
    - ← Retour à vos flux RSS +
    - Import / export au format OPML +
    - +
    @@ -27,9 +27,9 @@
    - - ou - Exporter + + +
    diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml index 86682465a..4c7884234 100644 --- a/app/views/configure/shortcut.phtml +++ b/app/views/configure/shortcut.phtml @@ -1,7 +1,7 @@ partial ('aside_configure'); ?>
    - ← Retour à vos flux RSS + list_keys as $key) { ?> @@ -12,57 +12,57 @@ conf->shortcuts (); ?>
    - Gestion des raccourcis + - +
    - +
    - + shift pour marquer tous les articles comme non lus +
    - +
    - +
    - +
    - + shift pour passer au dernier article de la page +
    - +
    - + shift pour passer au premier article de la page +
    - +
    - +
    @@ -70,8 +70,8 @@
    - - + +
    diff --git a/app/views/entry/note.phtml b/app/views/entry/note.phtml index 912d4846d..061060106 100644 --- a/app/views/entry/note.phtml +++ b/app/views/entry/note.phtml @@ -1,37 +1,37 @@ partial ('aside_flux'); ?>
    - ← Retour à vos flux RSS +
    - Note +
    - +
    - +
    - - + +
    - Article +
    - + @@ -41,7 +41,7 @@ $author = $this->entry->author (); if ($author) { ?>
    - +
    @@ -49,14 +49,14 @@
    - +
    entry->date (); ?>
    - +
    entry->content (); ?>
    diff --git a/app/views/error/index.phtml b/app/views/error/index.phtml index 21d298eb4..d5d090c72 100644 --- a/app/views/error/index.phtml +++ b/app/views/error/index.phtml @@ -1,7 +1,10 @@
    -
    +

    code; ?>

    -

    Revenir à l'accueil

    +

    +
    + +

    diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml index f91e3d95d..d5428d304 100755 --- a/app/views/helpers/pagination.phtml +++ b/app/views/helpers/pagination.phtml @@ -2,13 +2,23 @@ $c = Request::controllerName (); $a = Request::actionName (); $params = Request::params (); + + $conf = new RSSConfiguration (); + $order = Session::param ('order', $conf->sortOrder ()); + if ($order == 'low_to_high') { + $first_link = Translate::t ('newer'); + $second_link = Translate::t ('older'); + } else { + $first_link = Translate::t ('older'); + $second_link = Translate::t ('newer'); + } ?>
    • currentPage > 1) { ?> currentPage - 1; ?> - ‹ plus récents +   @@ -19,7 +29,7 @@
    • currentPage < $this->nbPage) { ?> currentPage + 1; ?> - plus anciens › +   diff --git a/app/views/helpers/rss.phtml b/app/views/helpers/rss.phtml index 1aa0ac44a..83de6de2e 100755 --- a/app/views/helpers/rss.phtml +++ b/app/views/helpers/rss.phtml @@ -3,7 +3,7 @@ <?php echo View::title(); ?> - Flux RSS de + GMT diff --git a/app/views/index/about.phtml b/app/views/index/about.phtml index 73f5f4001..7c228b581 100644 --- a/app/views/index/about.phtml +++ b/app/views/index/about.phtml @@ -1,24 +1,24 @@
      - ← Retour à vos flux RSS + -

      À propos de FreshRSS

      +

      -
      Url du projet
      +
      https://github.com/marienfressinaud/FreshRSS
      -
      Développeur principal
      -
      Marien Fressinaud - site Internet
      +
      +
      Marien Fressinaud -
      -
      Pour les rapports de bugs
      -
      sur Github ou par mail
      +
      +
      -
      Licence
      -
      AGPL 3
      +
      +
      -

      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.

      +

      -

      Crédits

      - 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. +

      +

      diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index ff7325996..5c6ab0376 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -22,13 +22,13 @@ if (isset ($this->entryPaginator)) { isDay (Days::TODAY)) { ?> -
      Aujourd'hui -
      +
      -
      isDay (Days::YESTERDAY)) { ?> -
      Hier -
      +
      -
      isDay (Days::BEFORE_YESTERDAY)) { ?> -
      À partir d'avant-hier
      +
      @@ -59,32 +59,32 @@ if (isset ($this->entryPaginator)) {

      title (); ?>

      author (); ?> - Par ' . $author . '
      ' : ''; ?> + ' . Translate::t ('by_author', $author) . '
      ' : ''; ?> content (); ?>
    • notes () != '') { ?> - Modifier votre note + - Ajouter une note +
    • @@ -94,12 +94,11 @@ if (isset ($this->entryPaginator)) {
    • -
      - Il n'y a aucun flux à afficher. + diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml index 16188422a..fa6e67ddb 100644 --- a/app/views/javascript/actualize.phtml +++ b/app/views/javascript/actualize.phtml @@ -6,7 +6,7 @@ feeds.push (" 'feed', 'a' => 'actualize', function initProgressBar (init) { if (init) { $("body").after ("\
      \ - Actualisation 0 / " + feeds.length + "
      \ + 0 / " + feeds.length + "
      \ \
      "); } else { -- cgit v1.2.3 From 81ea32d53e85b623356f56910b0a7aa9acf6bcd6 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 15:17:10 +0200 Subject: Gestion de la traduction pour les dates (bug #38) --- app/i18n/fr.php | 30 ++++++++++++++++++++++++++ app/views/index/index.phtml | 2 +- lib/lib_rss.php | 51 +++++---------------------------------------- 3 files changed, 36 insertions(+), 47 deletions(-) (limited to 'app/views') diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 2ddac3066..652ec2782 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -183,4 +183,34 @@ return array ( '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' => 'Crédits', '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' => 'janvier', + 'february' => 'février', + 'march' => 'mars', + 'april' => 'avril', + 'may' => 'mai', + 'june' => 'juin', + 'july' => 'juillet', + 'august' => 'août', + 'september' => 'septembre', + 'october' => 'octobre', + 'november' => 'novembre', + 'december' => 'décembre', + // format spécial pour la fonction date() + 'Jan' => '\j\a\n\v\i\e\r', + 'Feb' => '\f\é\v\r\i\e\r', + 'Mar' => '\m\a\r\s', + 'Apr' => '\a\v\r\i\l', + 'May' => '\m\a\i', + 'Jun' => '\j\u\i\n', + 'Jul' => '\j\u\i\l\l\e\t', + 'Aug' => '\a\o\û\t', + 'Sep' => '\s\e\p\t\e\m\b\r\e', + 'Oct' => '\o\c\t\o\b\r\e', + 'Nov' => '\n\o\v\e\m\b\r\e', + 'Dec' => '\d\é\c\e\m\b\r\e', + // format pour la fonction date(), %s permet d'indiquer le mois en toutes lettres + 'format_date' => 'd %s Y', + 'format_date_hour' => '\l\e d %s Y \à H\:i', ); diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 5c6ab0376..a7b67bcbc 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -51,7 +51,7 @@ if (isset ($this->entryPaginator)) { feed (true); ?>
    • name (); ?>
    • title (); ?>
    • -
    • le date (); ?>
    • +
    • date (); ?>
    diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 81a98590e..76c304064 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -20,55 +20,14 @@ function small_hash ($txt) { } function timestamptodate ($t, $hour = true) { - $jour = date ('d', $t); - $mois = date ('m', $t); - $annee = date ('Y', $t); - - switch ($mois) { - case 1: - $mois = 'janvier'; - break; - case 2: - $mois = 'février'; - break; - case 3: - $mois = 'mars'; - break; - case 4: - $mois = 'avril'; - break; - case 5: - $mois = 'mai'; - break; - case 6: - $mois = 'juin'; - break; - case 7: - $mois = 'juillet'; - break; - case 8: - $mois = 'août'; - break; - case 9: - $mois = 'septembre'; - break; - case 10: - $mois = 'octobre'; - break; - case 11: - $mois = 'novembre'; - break; - case 12: - $mois = 'décembre'; - break; - } - - $date = $jour . ' ' . $mois . ' ' . $annee; + $month = Translate::t (date('M', $t)); if ($hour) { - return $date . date (' \à H\:i', $t); + $date = Translate::t ('format_date_hour', $month); } else { - return $date; + $date = Translate::t ('format_date', $month); } + + return date ($date, $t); } function sortEntriesByDate ($entry1, $entry2) { -- 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/views') 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/views') 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 21dc4ceace513a0d6cd934f5fc4bb9cc643bb570 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 27 Apr 2013 22:33:14 +0200 Subject: Fix issue #64 : stockage des favicons en local --- app/layout/aside_feed.phtml | 2 +- app/layout/aside_flux.phtml | 2 +- app/models/Feed.php | 10 ++++++++++ app/views/index/index.phtml | 2 +- lib/lib_rss.php | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) (limited to 'app/views') diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 4be37868d..ec4993a70 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -43,7 +43,7 @@ feeds as $feed) { ?>
  • - + name (); ?>
  • diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 60fcbe457..d2e5341e3 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -87,7 +87,7 @@ nbNotRead (); ?> - + 0 ? '' : ''; ?> 0 ? '(' . $not_read . ') ' : ''; ?> diff --git a/app/models/Feed.php b/app/models/Feed.php index 08cf7425f..97cbe55d1 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -77,6 +77,16 @@ class Feed extends Model { $feedDAO = new FeedDAO (); return $feedDAO->countNotRead ($this->id ()); } + public function favicon () { + $file = '/data/favicons/' . $this->id () . '.ico'; + + $favicon_url = Url::display ($file); + if (!file_exists (PUBLIC_PATH . $file)) { + $favicon_url = dowload_favicon ($this->website (), $this->id ()); + } + + return $favicon_url; + } public function _id ($value) { $this->id = $value; diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index a7b67bcbc..c9be7169d 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -49,7 +49,7 @@ if (isset ($this->entryPaginator)) { feed (true); ?> -
  • name (); ?>
  • +
  • name (); ?>
  • title (); ?>
  • date (); ?>
  • diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 76c304064..e004b7498 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -152,3 +152,41 @@ function get_content_by_parsing ($url, $path) { throw new Exception (); } } + +/* Télécharge le favicon d'un site, le place sur le serveur et retourne l'URL */ +function dowload_favicon ($website, $id) { + $url = 'http://g.etfv.co/' . $website; + $favicons_dir = PUBLIC_PATH . '/data/favicons'; + $dest = $favicons_dir . '/' . $id . '.ico'; + $favicon_url = '/data/favicons/' . $id . '.ico'; + + if (!is_dir ($favicons_dir)) { + if (!mkdir ($favicons_dir, 0755, true)) { + return $url; + } + } + + if (!file_exists ($dest)) { + $c = curl_init ($url); + curl_setopt ($c, CURLOPT_HEADER, false); + curl_setopt ($c, CURLOPT_RETURNTRANSFER, true); + curl_setopt ($c, CURLOPT_BINARYTRANSFER, true); + $imgRaw = curl_exec ($c); + + if (curl_getinfo ($c, CURLINFO_HTTP_CODE) == 200) { + $file = fopen ($dest, 'w'); + if ($file === false) { + return $url; + } + + fwrite ($file, $imgRaw); + fclose ($file); + } else { + return $url; + } + + curl_close ($c); + } + + return $favicon_url; +} -- 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/views') 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 9820345eec3958e9df1b1f8daaaa776de0d333e5 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 29 Apr 2013 00:57:08 +0200 Subject: Revue de code pour la récupération des articles : ATTENTION GROS CHANGEMENTS, aucune garantie de stabilité et possibles régressions. La recherche dans le contenu des articles fonctionnent et possibilité de rechercher des tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/App_FrontController.php | 3 + app/controllers/indexController.php | 270 ++++++++----------- app/i18n/en.php | 6 +- app/i18n/fr.php | 6 +- app/layout/aside_flux.phtml | 19 +- app/layout/header.phtml | 15 +- app/layout/nav_menu.phtml | 56 +++- app/models/EntriesGetter.php | 144 +++++++++++ app/models/Entry.php | 328 +++++++----------------- app/models/Exception/EntriesGetterException.php | 7 + app/models/RSSPaginator.php | 27 ++ app/views/helpers/pagination.phtml | 29 +-- app/views/index/index.phtml | 9 +- 13 files changed, 466 insertions(+), 453 deletions(-) create mode 100644 app/models/EntriesGetter.php create mode 100644 app/models/Exception/EntriesGetterException.php create mode 100644 app/models/RSSPaginator.php (limited to 'app/views') diff --git a/app/App_FrontController.php b/app/App_FrontController.php index 8b515873a..77261280e 100644 --- a/app/App_FrontController.php +++ b/app/App_FrontController.php @@ -28,11 +28,14 @@ class App_FrontController extends FrontController { private function loadModels () { include (APP_PATH . '/models/Exception/FeedException.php'); + include (APP_PATH . '/models/Exception/EntriesGetterException.php'); include (APP_PATH . '/models/RSSConfiguration.php'); include (APP_PATH . '/models/Days.php'); include (APP_PATH . '/models/Category.php'); include (APP_PATH . '/models/Feed.php'); include (APP_PATH . '/models/Entry.php'); + include (APP_PATH . '/models/EntriesGetter.php'); + include (APP_PATH . '/models/RSSPaginator.php'); } private function loadParamsView () { diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index dfdcfde42..15cbd7edc 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -6,6 +6,10 @@ class indexController extends ActionController { private $mode = 'all'; public function indexAction () { + if (Request::param ('output', '') == 'rss') { + $this->view->_useLayout (false); + } + View::appendScript (Url::display ('/scripts/shortcut.js')); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); @@ -14,109 +18,125 @@ class indexController extends ActionController { $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); - $error = false; - - // pour optimiser - $page = Request::param ('page', 1); - $entryDAO->_nbItemsPerPage ($this->view->conf->postsPerPage ()); - $entryDAO->_currentPage ($page); - - // récupération de la catégorie/flux à filtrer - $this->initFilter (); - // Compte le nombre d'articles non lus en prenant en compte le filtre - $this->countNotRead (); - // mode de vue (tout ou seulement non lus) - $this->initCurrentMode (); - // ordre de listage des flux - $order = Session::param ('order', $this->view->conf->sortOrder ()); - // recherche sur les titres (pour le moment) - $search = Request::param ('search'); - - // 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 (Translate::t ('your_rss_feeds') . ' - '); - } elseif ($this->get['type'] == 'favoris') { - $entries = $entryDAO->listFavorites ($this->mode, $search, $order); - View::prependTitle (Translate::t ('your_favorites') . ' - '); - } elseif ($this->get['type'] == 'public') { - $entries = $entryDAO->listPublic ($this->mode, $search, $order); - View::prependTitle (Translate::t ('public') . ' - '); - } elseif ($this->get != false) { - if ($this->get['type'] == 'c') { - $cat = $catDAO->searchById ($this->get['filter']); - - if ($cat) { - $entries = $entryDAO->listByCategory ($this->get['filter'], $this->mode, $search, $order); - View::prependTitle ($cat->name () . ' - '); - } else { - $error = true; - } - } elseif ($this->get['type'] == 'f') { - $feed = $feedDAO->searchById ($this->get['filter']); - - if ($feed) { - $entries = $entryDAO->listByFeed ($this->get['filter'], $this->mode, $search, $order); - $this->view->get_c = $feed->category (); - View::prependTitle ($feed->name () . ' - '); - } else { - $error = true; + $this->view->cat_aside = $catDAO->listCategories (); + $this->view->nb_favorites = $entryDAO->countFavorites (); + $this->view->nb_total = $entryDAO->count (); + + $this->view->get_c = ''; + $this->view->get_f = ''; + + $type = $this->getType (); + $error = $this->checkAndProcessType ($type); + if (!$error) { + $this->view->state = $state = Request::param ('state', $this->view->conf->defaultView ()); + $filter = Request::param ('search', ''); + $this->view->order = $order = Request::param ('order', $this->view->conf->sortOrder ()); + $nb = Request::param ('nb', $this->view->conf->postsPerPage ()); + $first = Request::param ('next', ''); + + try { + $getter = new EntriesGetter ($type, $state, $filter, $order, $nb, $first); + $getter->execute (); + $entries = $getter->getPaginator (); + + if ($state == 'not_read' && $entries->isEmpty ()) { + $this->view->state = 'all'; + $getter->_state ('all'); + $getter->execute (); + $entries = $getter->getPaginator (); } - } else { - $error = true; + + $this->view->entryPaginator = $entries; + } catch(EntriesGetterException $e) { + Log::record ($e->getMessage (), Log::NOTICE); + Error::error ( + 404, + array ('error' => array (Translate::t ('page_not_found'))) + ); + } catch(CurrentPagePaginationException $e) { + Error::error ( + 404, + array ('error' => array (Translate::t ('page_not_found'))) + ); } } else { - $error = true; - } - - if ($error) { Error::error ( 404, array ('error' => array (Translate::t ('page_not_found'))) ); - } else { - $this->view->mode = $this->mode; - $this->view->order = $order; - - try { - $this->view->entryPaginator = $entryDAO->getPaginator ($entries); - } catch (CurrentPagePaginationException $e) { } - - $this->view->cat_aside = $catDAO->listCategories (); - $this->view->nb_favorites = $entryDAO->countFavorites (); - $this->view->nb_total = $entryDAO->count (); - - if (Request::param ('output', '') == 'rss') { - $this->view->_useLayout (false); - } } } - public function aboutAction () { - View::prependTitle (Translate::t ('about') . ' - '); - } - - public function changeModeAction () { - $mode = Request::param ('mode'); + /* + * Détermine le type d'article à récupérer : + * "tous", "favoris", "public", "catégorie" ou "flux" + */ + private function getType () { + $get = Request::param ('get', 'all'); + $typeGet = $get[0]; + $id = substr ($get, 2); - if ($mode == 'not_read') { - Session::_param ('mode', 'not_read'); - } else { - Session::_param ('mode', 'all'); + $type = null; + if ($get == 'all' || $get == 'favoris' || $get == 'public') { + $type = array ( + 'type' => $get, + 'id' => $get + ); + } elseif ($typeGet == 'f' || $typeGet == 'c') { + $type = array ( + 'type' => $typeGet, + 'id' => $id + ); } - Request::forward (array (), true); + return $type; } - public function changeOrderAction () { - $order = Request::param ('order'); - - if ($order == 'low_to_high') { - Session::_param ('order', 'low_to_high'); + /* + * Vérifie que la catégorie / flux sélectionné existe + * + Initialise correctement les variables de vue get_c et get_f + * + Initialise le titre + */ + private function checkAndProcessType ($type) { + if ($type['type'] == 'all') { + View::prependTitle (Translate::t ('your_rss_feeds') . ' - '); + $this->view->get_c = $type['type']; + return false; + } elseif ($type['type'] == 'favoris') { + View::prependTitle (Translate::t ('your_favorites') . ' - '); + $this->view->get_c = $type['type']; + return false; + } elseif ($type['type'] == 'public') { + View::prependTitle (Translate::t ('public') . ' - '); + $this->view->get_c = $type['type']; + return false; + } elseif ($type['type'] == 'c') { + $catDAO = new CategoryDAO (); + $cat = $catDAO->searchById ($type['id']); + if ($cat) { + View::prependTitle ($cat->name () . ' - '); + $this->view->get_c = $type['id']; + return false; + } else { + return true; + } + } elseif ($type['type'] == 'f') { + $feedDAO = new FeedDAO (); + $feed = $feedDAO->searchById ($type['id']); + if ($feed) { + View::prependTitle ($feed->name () . ' - '); + $this->view->get_f = $type['id']; + $this->view->get_c = $feed->category (); + return false; + } else { + return true; + } } else { - Session::_param ('order', 'high_to_low'); + return true; } + } - Request::forward (array (), true); + public function aboutAction () { + View::prependTitle (Translate::t ('about') . ' - '); } public function loginAction () { @@ -153,82 +173,4 @@ class indexController extends ActionController { $this->view->_useLayout (false); Session::_param ('mail'); } - - private function initFilter () { - $get = Request::param ('get'); - $this->view->get_c = false; - $this->view->get_f = false; - - $typeGet = $get[0]; - $filter = substr ($get, 2); - - if ($get == 'favoris') { - $this->view->get_c = $get; - - $this->get = array ( - 'type' => $get, - 'filter' => $get - ); - } elseif ($get == 'public') { - $this->view->get_c = $get; - - $this->get = array ( - 'type' => $get, - 'filter' => $get - ); - } elseif ($get == false) { - $this->get = array ( - 'type' => 'all', - 'filter' => 'all' - ); - } else { - if ($typeGet == 'f') { - $this->view->get_f = $filter; - - $this->get = array ( - 'type' => $typeGet, - 'filter' => $filter - ); - } elseif ($typeGet == 'c') { - $this->view->get_c = $filter; - - $this->get = array ( - 'type' => $typeGet, - 'filter' => $filter - ); - } else { - $this->get = false; - } - } - } - - private function countNotRead () { - $entryDAO = new EntryDAO (); - - if ($this->get != false) { - if ($this->get['type'] == 'all') { - $this->nb_not_read = $this->view->nb_not_read; - } elseif ($this->get['type'] == 'favoris') { - $this->nb_not_read = $entryDAO->countNotReadFavorites (); - } elseif ($this->get['type'] == 'c') { - $this->nb_not_read = $entryDAO->countNotReadByCat ($this->get['filter']); - } elseif ($this->get['type'] == 'f') { - $this->nb_not_read = $entryDAO->countNotReadByFeed ($this->get['filter']); - } - } - } - - private function initCurrentMode () { - $default_view = $this->view->conf->defaultView (); - $mode = Session::param ('mode'); - if ($mode == false) { - if ($default_view == 'not_read' && $this->nb_not_read < 1) { - $mode = 'all'; - } else { - $mode = $default_view; - } - } - - $this->mode = $mode; - } } diff --git a/app/i18n/en.php b/app/i18n/en.php index 1bb7c2213..a78604c3e 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -4,7 +4,7 @@ return array ( // LAYOUT 'login' => 'Login', 'logout' => 'Logout', - 'search_on_title' => 'Search (only on titles)', + 'search' => 'Search words or #tags', 'configuration' => 'Configuration', 'general_and_reading' => 'General and reading', @@ -161,8 +161,8 @@ return array ( 'author' => 'Author', 'publication_date' => 'Date of publication', - 'newer' => 'newer', - 'older' => 'older', + 'load_more' => 'Load more articles', + 'nothing_to_load' => 'There is no more articles', 'rss_feeds_of' => 'RSS feed of %s', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index c5bba9d07..33f094c21 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -4,7 +4,7 @@ return array ( // LAYOUT 'login' => 'Connexion', 'logout' => 'Déconnexion', - 'search_on_title' => 'Rechercher sur les titres', + 'search' => 'Rechercher un terme ou des #tags', 'configuration' => 'Configuration', 'general_and_reading' => 'Général et lecture', @@ -161,8 +161,8 @@ return array ( 'author' => 'Auteur', 'publication_date' => 'Date de publication', - 'newer' => 'plus récents', - 'older' => 'plus anciens', + 'load_more' => 'Charger plus d\'articles', + 'nothing_to_load' => 'Il n\'y a pas plus d\'article', 'rss_feeds_of' => 'Flux RSS de %s', diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index d2e5341e3..d1fe6b759 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -3,21 +3,16 @@ diff --git a/app/models/EntriesGetter.php b/app/models/EntriesGetter.php new file mode 100644 index 000000000..ca92804a7 --- /dev/null +++ b/app/models/EntriesGetter.php @@ -0,0 +1,144 @@ + 'all', + 'id' => 'all' + ); + private $state = 'all'; + private $filter = array ( + 'words' => array (), + 'tags' => array (), + ); + private $order = 'high_to_low'; + private $entries = array (); + + private $nb = 1; + private $first = ''; + private $next = ''; + + public function __construct ($type, $state, $filter, $order, $nb, $first = '') { + $this->_type ($type); + $this->_state ($state); + $this->_filter ($filter); + $this->_order ($order); + $this->nb = $nb; + $this->first = $first; + } + + public function type () { + return $this->type; + } + public function state () { + return $this->state; + } + public function filter () { + return $this->filter; + } + public function order () { + return $this->order; + } + public function entries () { + return $this->entries; + } + + public function _type ($value) { + if (!is_array ($value) || + !isset ($value['type']) || + !isset ($value['id'])) { + throw new EntriesGetterException ('Bad type line ' . __LINE__ . ' in file ' . __FILE__); + } + + $type = $value['type']; + $id = $value['id']; + + if ($type != 'all' && $type != 'favoris' && $type != 'public' && $type != 'c' && $type != 'f') { + throw new EntriesGetterException ('Bad type line ' . __LINE__ . ' in file ' . __FILE__); + } + + if (($type == 'all' || $type == 'favoris' || $type == 'public') && + ($type != $id)) { + throw new EntriesGetterException ('Bad type line ' . __LINE__ . ' in file ' . __FILE__); + } + + $this->type = $value; + } + public function _state ($value) { + if ($value != 'all' && $value != 'not_read' && $value != 'read') { + throw new EntriesGetterException ('Bad state line ' . __LINE__ . ' in file ' . __FILE__); + } + + $this->state = $value; + } + public function _filter ($value) { + $value = trim ($value); + $terms = explode (' ', $value); + + foreach ($terms as $word) { + if (!empty ($word) && $word[0] == '#' && isset ($word[1])) { + $tag = substr ($word, 1); + $this->filter['tags'][$tag] = $tag; + } elseif (!empty ($word)) { + $this->filter['words'][$word] = $word; + } + } + } + public function _order ($value) { + if ($value != 'high_to_low' && $value != 'low_to_high') { + throw new EntriesGetterException ('Bad order line ' . __LINE__ . ' in file ' . __FILE__); + } + + $this->order = $value; + } + + public function execute () { + $entryDAO = new EntryDAO (); + + HelperEntry::$nb = $this->nb; + HelperEntry::$first = $this->first; + HelperEntry::$filter = $this->filter; + + switch ($this->type['type']) { + case 'all': + list ($this->entries, $this->next) = $entryDAO->listEntries ( + $this->state, + $this->order + ); + break; + case 'favoris': + list ($this->entries, $this->next) = $entryDAO->listFavorites ( + $this->state, + $this->order + ); + break; + case 'public': + list ($this->entries, $this->next) = $entryDAO->listPublic ( + $this->state, + $this->order + ); + break; + case 'c': + list ($this->entries, $this->next) = $entryDAO->listByCategory ( + $this->type['id'], + $this->state, + $this->order + ); + break; + case 'f': + list ($this->entries, $this->next) = $entryDAO->listByFeed ( + $this->type['id'], + $this->state, + $this->order + ); + break; + default: + throw new EntriesGetterException ('Bad type line ' . __LINE__ . ' in file ' . __FILE__); + } + } + + public function getPaginator () { + $paginator = new RSSPaginator ($this->entries, $this->next); + + return $paginator; + } +} diff --git a/app/models/Entry.php b/app/models/Entry.php index 3daec5aa9..ef1c567e8 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -377,16 +377,11 @@ class EntryDAO extends Model_pdo { } } - public function listEntries ($mode, $search = false, $order = 'high_to_low') { - $where = ' WHERE priority > 0'; - if ($mode == 'not_read') { - $where .= ' AND is_read=0'; - } - - $values = array(); - if ($search) { - $values[] = '%'.$search.'%'; - $where .= ' AND title LIKE ?'; + public function listWhere ($where, $state, $order, $values = array ()) { + if ($state == 'not_read') { + $where .= ' AND is_read = 0'; + } elseif ($state == 'read') { + $where .= ' AND is_read = 1'; } if ($order == 'low_to_high') { @@ -395,181 +390,28 @@ class EntryDAO extends Model_pdo { $order = ''; } - $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where; - $stm = $this->bd->prepare ($sql); - $stm->execute ($values); - $res = $stm->fetchAll (PDO::FETCH_ASSOC); - $this->nbItems = $res[0]['count']; - - $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; - $fin = $this->nbItemsPerPage; - $sql = 'SELECT e.* FROM entry e' . ' INNER JOIN feed f ON e.id_feed = f.id' . $where - . ' ORDER BY date' . $order - . ' LIMIT ' . $deb . ', ' . $fin; + . ' ORDER BY date' . $order; $stm = $this->bd->prepare ($sql); $stm->execute ($values); return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); } - - public function listFavorites ($mode, $search = false, $order = 'high_to_low') { - $where = ' WHERE is_favorite=1'; - if ($mode == 'not_read') { - $where .= ' AND is_read=0'; - } - - $values = array(); - if ($search) { - $values[] = '%'.$search.'%'; - $where .= ' AND title LIKE ?'; - } - - if ($order == 'low_to_high') { - $order = ' DESC'; - } else { - $order = ''; - } - - $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; - $stm = $this->bd->prepare ($sql); - $stm->execute ($values); - $res = $stm->fetchAll (PDO::FETCH_ASSOC); - $this->nbItems = $res[0]['count']; - - if($this->nbItemsPerPage < 0) { - $sql = 'SELECT * FROM entry' . $where - . ' ORDER BY date' . $order; - } else { - $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; - $fin = $this->nbItemsPerPage; - - $sql = 'SELECT * FROM entry' . $where - . ' ORDER BY date' . $order - . ' LIMIT ' . $deb . ', ' . $fin; - } - $stm = $this->bd->prepare ($sql); - - $stm->execute ($values); - - return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); + public function listEntries ($state, $order = 'high_to_low') { + return $this->listWhere (' WHERE priority > 0', $state, $order); } - - public function listPublic ($mode, $search = false, $order = 'high_to_low') { - $where = ' WHERE is_public=1'; - if ($mode == 'not_read') { - $where .= ' AND is_read=0'; - } - - $values = array(); - if ($search) { - $values[] = '%'.$search.'%'; - $where .= ' AND title LIKE ?'; - } - - if ($order == 'low_to_high') { - $order = ' DESC'; - } else { - $order = ''; - } - - $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; - $stm = $this->bd->prepare ($sql); - $stm->execute ($values); - $res = $stm->fetchAll (PDO::FETCH_ASSOC); - $this->nbItems = $res[0]['count']; - - if($this->nbItemsPerPage < 0) { - $sql = 'SELECT * FROM entry' . $where - . ' ORDER BY date' . $order; - } else { - $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; - $fin = $this->nbItemsPerPage; - - $sql = 'SELECT * FROM entry' . $where - . ' ORDER BY date' . $order - . ' LIMIT ' . $deb . ', ' . $fin; - } - $stm = $this->bd->prepare ($sql); - - $stm->execute ($values); - - return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); + public function listFavorites ($state, $order = 'high_to_low') { + return $this->listWhere (' WHERE is_favorite = 1', $state, $order); } - - public function listByCategory ($cat, $mode, $search = false, $order = 'high_to_low') { - $where = ' WHERE category=?'; - if ($mode == 'not_read') { - $where .= ' AND is_read=0'; - } - - $values = array ($cat); - if ($search) { - $values[] = '%'.$search.'%'; - $where .= ' AND title LIKE ?'; - } - - if ($order == 'low_to_high') { - $order = ' DESC'; - } else { - $order = ''; - } - - $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where; - $stm = $this->bd->prepare ($sql); - $stm->execute ($values); - $res = $stm->fetchAll (PDO::FETCH_ASSOC); - $this->nbItems = $res[0]['count']; - - $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; - $fin = $this->nbItemsPerPage; - $sql = 'SELECT e.* FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where - . ' ORDER BY date' . $order - . ' LIMIT ' . $deb . ', ' . $fin; - - $stm = $this->bd->prepare ($sql); - - $stm->execute ($values); - - return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); + public function listPublic ($state, $order = 'high_to_low') { + return $this->listWhere (' WHERE is_public = 1', $state, $order); } - - public function listByFeed ($feed, $mode, $search = false, $order = 'high_to_low') { - $where = ' WHERE id_feed=?'; - if ($mode == 'not_read') { - $where .= ' AND is_read=0'; - } - - $values = array($feed); - if ($search) { - $values[] = '%'.$search.'%'; - $where .= ' AND title LIKE ?'; - } - - if ($order == 'low_to_high') { - $order = ' DESC'; - } else { - $order = ''; - } - - $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; - $stm = $this->bd->prepare ($sql); - $stm->execute ($values); - $res = $stm->fetchAll (PDO::FETCH_ASSOC); - $this->nbItems = $res[0]['count']; - - $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; - $fin = $this->nbItemsPerPage; - $sql = 'SELECT * FROM entry e' . $where - . ' ORDER BY date' . $order - . ' LIMIT ' . $deb . ', ' . $fin; - - $stm = $this->bd->prepare ($sql); - - $stm->execute ($values); - - return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); + public function listByCategory ($cat, $state, $order = 'high_to_low') { + return $this->listWhere (' WHERE category = ?', $state, $order, array ($cat)); + } + public function listByFeed ($feed, $state, $order = 'high_to_low') { + return $this->listWhere (' WHERE id_feed = ?', $state, $order, array ($feed)); } public function count () { @@ -580,7 +422,6 @@ class EntryDAO extends Model_pdo { return $res[0]['count']; } - public function countNotRead () { $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE is_read=0 AND priority > 0'; $stm = $this->bd->prepare ($sql); @@ -616,7 +457,6 @@ class EntryDAO extends Model_pdo { return $res[0]['count']; } - public function countFavorites () { $sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_favorite=1'; $stm = $this->bd->prepare ($sql); @@ -625,73 +465,103 @@ class EntryDAO extends Model_pdo { return $res[0]['count']; } +} - // gestion de la pagination directement via le DAO - private $nbItemsPerPage = 1; - private $currentPage = 1; - private $nbItems = 0; - public function _nbItemsPerPage ($value) { - $this->nbItemsPerPage = $value; - } - public function _currentPage ($value) { - $this->currentPage = $value; - } - public function currentPage () { - if ($this->currentPage < 1) { - return 1; +class HelperEntry { + public static $nb = 1; + public static $first = ''; + + public static $filter = array ( + 'words' => array (), + 'tags' => array (), + ); + + public static function daoToEntry ($listDAO) { + $list = array (); + + if (!is_array ($listDAO)) { + $listDAO = array ($listDAO); } - $maxPage = ceil ($this->nbItems / $this->nbItemsPerPage); - if ($this->currentPage > $maxPage) { - return $maxPage; + $count = 0; + $first_is_found = false; + $break_after = false; + $next = ''; + foreach ($listDAO as $key => $dao) { + $dao['content'] = unserialize (gzinflate (base64_decode ($dao['content']))); + $dao['tags'] = preg_split('/[\s#]/', $dao['tags']); + + if (self::tagsMatchEntry ($dao) && + self::searchMatchEntry ($dao)) { + if ($break_after) { + $next = $dao['id']; + break; + } + if ($first_is_found || $dao['id'] == self::$first || self::$first == '') { + $list[$key] = self::createEntry ($dao); + + $count++; + $first_is_found = true; + } + if ($count >= self::$nb) { + $break_after = true; + } + } } - return $this->currentPage; + unset ($listDAO); + return array ($list, $next); } - public function getPaginator ($entries) { - $paginator = new Paginator ($entries); - $paginator->_nbItems ($this->nbItems); - $paginator->_nbItemsPerPage ($this->nbItemsPerPage); - $paginator->_currentPage ($this->currentPage ()); + private static function createEntry ($dao) { + $entry = new Entry ( + $dao['id_feed'], + $dao['guid'], + $dao['title'], + $dao['author'], + $dao['content'], + $dao['link'], + $dao['date'], + $dao['is_read'], + $dao['is_favorite'], + $dao['is_public'] + ); - return $paginator; - } -} + $entry->_notes ($dao['annotation']); + $entry->_lastUpdate ($dao['lastUpdate']); + $entry->_tags ($dao['tags']); -class HelperEntry { - public static function daoToEntry ($listDAO, $mode = 'all', $favorite = false) { - $list = array (); + if (isset ($dao['id'])) { + $entry->_id ($dao['id']); + } - if (!is_array ($listDAO)) { - $listDAO = array ($listDAO); + return $entry; + } + + private static function tagsMatchEntry ($dao) { + $tags = self::$filter['tags']; + foreach ($tags as $tag) { + if (!in_array ($tag, $dao['tags'])) { + return false; + } } - foreach ($listDAO as $key => $dao) { - $list[$key] = new Entry ( - $dao['id_feed'], - $dao['guid'], - $dao['title'], - $dao['author'], - unserialize (gzinflate (base64_decode ($dao['content']))), - $dao['link'], - $dao['date'], - $dao['is_read'], - $dao['is_favorite'], - $dao['is_public'] - ); - - $tags = preg_split('/[\s#]/', $dao['tags']); - $list[$key]->_notes ($dao['annotation']); - $list[$key]->_lastUpdate ($dao['lastUpdate']); - $list[$key]->_tags ($tags); - - if (isset ($dao['id'])) { - $list[$key]->_id ($dao['id']); + return true; + } + private static function searchMatchEntry ($dao) { + $words = self::$filter['words']; + + foreach ($words as $word) { + $word = strtolower ($word); + if (strpos (strtolower ($dao['title']), $word) === false && + strpos (strtolower ($dao['content']), $word) === false && + strpos (strtolower ($dao['link']), $word) === false && + strpos (strtolower ($dao['annotation']), $word) === false) { + return false; } } - return $list; + return true; } } diff --git a/app/models/Exception/EntriesGetterException.php b/app/models/Exception/EntriesGetterException.php new file mode 100644 index 000000000..3a51bff7c --- /dev/null +++ b/app/models/Exception/EntriesGetterException.php @@ -0,0 +1,7 @@ +items = $items; + $this->next = $next; + } + + public function isEmpty () { + return empty ($this->items); + } + + public function items () { + return $this->items; + } + + public function render ($view, $getteur) { + $view = APP_PATH . '/views/helpers/'.$view; + + if (file_exists ($view)) { + include ($view); + } + } +} diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml index d5428d304..f029f281a 100755 --- a/app/views/helpers/pagination.phtml +++ b/app/views/helpers/pagination.phtml @@ -2,36 +2,15 @@ $c = Request::controllerName (); $a = Request::actionName (); $params = Request::params (); - - $conf = new RSSConfiguration (); - $order = Session::param ('order', $conf->sortOrder ()); - if ($order == 'low_to_high') { - $first_link = Translate::t ('newer'); - $second_link = Translate::t ('older'); - } else { - $first_link = Translate::t ('older'); - $second_link = Translate::t ('newer'); - } ?>
      -
    • - currentPage > 1) { ?> - currentPage - 1; ?> - - -   - -
    • - -
    • page currentPage; ?> / nbPage; ?>
    • -
    • - currentPage < $this->nbPage) { ?> - currentPage + 1; ?> - + next != '') { ?> + next; ?> + -   +
    diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index c9be7169d..c39775fd7 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -10,8 +10,8 @@ if (Request::param ('output', '') == 'rss') { partial ('nav_menu'); ?> entryPaginator)) { - $items = $this->entryPaginator->items (true); +if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { + $items = $this->entryPaginator->items (); ?>
    entryPaginator)) {
    - entryPaginator->render ('pagination.phtml', 'page'); ?> + entryPaginator->render ('pagination.phtml', 'next'); ?>
    - - -
    -- cgit v1.2.3 From 1c202b9364c766d1bd28a22a04b3f70077f23e84 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 May 2013 09:44:34 +0200 Subject: Correction code + ajout commentaires + à l'ajout d'un flux, on n'ajoute plus les trop vieux articles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 12 ++++++++---- app/controllers/indexController.php | 19 +++++++++---------- app/models/RSSPaginator.php | 2 ++ app/views/index/index.phtml | 24 ++++++++++++------------ 4 files changed, 31 insertions(+), 26 deletions(-) (limited to 'app/views') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index ebbf3259f..5173c3a2d 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -63,11 +63,16 @@ class feedController extends ActionController { $entryDAO = new EntryDAO (); $entries = $feed->entries (); + // on calcule la date des articles les plus anciens qu'on accepte + $nb_month_old = $this->view->conf->oldEntries (); + $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old); + // on ajoute les articles en masse sans vérification - // TODO vérification de la date pour ne pas ajouter de vieux articles foreach ($entries as $entry) { - $values = $entry->toArray (); - $entryDAO->addEntry ($values); + if ($entry->date (true) >= $date_min) { + $values = $entry->toArray (); + $entryDAO->addEntry ($values); + } } // ok, ajout terminé @@ -164,7 +169,6 @@ class feedController extends ActionController { } } - // TODO on peut peut-être trouver une meilleure place pour cette fonction ? $entryDAO->cleanOldEntries ($nb_month_old); $url = array (); diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 15cbd7edc..f4f0b98b3 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -6,14 +6,14 @@ class indexController extends ActionController { private $mode = 'all'; public function indexAction () { - if (Request::param ('output', '') == 'rss') { + if (Request::param ('output') == 'rss') { $this->view->_useLayout (false); + } else { + View::appendScript (Url::display ('/scripts/shortcut.js')); + View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); + View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); } - View::appendScript (Url::display ('/scripts/shortcut.js')); - View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); - View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); - $entryDAO = new EntryDAO (); $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); @@ -28,6 +28,7 @@ class indexController extends ActionController { $type = $this->getType (); $error = $this->checkAndProcessType ($type); if (!$error) { + // On récupère les différents éléments de filtrage $this->view->state = $state = Request::param ('state', $this->view->conf->defaultView ()); $filter = Request::param ('search', ''); $this->view->order = $order = Request::param ('order', $this->view->conf->sortOrder ()); @@ -35,10 +36,13 @@ class indexController extends ActionController { $first = Request::param ('next', ''); try { + // EntriesGetter permet de déporter la complexité du filtrage $getter = new EntriesGetter ($type, $state, $filter, $order, $nb, $first); $getter->execute (); $entries = $getter->getPaginator (); + // Si on a récupéré aucun article "non lus" + // on essaye de récupérer tous les articles if ($state == 'not_read' && $entries->isEmpty ()) { $this->view->state = 'all'; $getter->_state ('all'); @@ -53,11 +57,6 @@ class indexController extends ActionController { 404, array ('error' => array (Translate::t ('page_not_found'))) ); - } catch(CurrentPagePaginationException $e) { - Error::error ( - 404, - array ('error' => array (Translate::t ('page_not_found'))) - ); } } else { Error::error ( diff --git a/app/models/RSSPaginator.php b/app/models/RSSPaginator.php index 619b70380..7010291bc 100644 --- a/app/models/RSSPaginator.php +++ b/app/models/RSSPaginator.php @@ -1,5 +1,7 @@ renderHelper ('rss'); - return; -} -?> +$output = Request::param ('output', 'normal'); -partial ('aside_flux'); ?> - -partial ('nav_menu'); ?> +if ($output == 'rss') { + $this->renderHelper ('rss'); +} else { + $this->partial ('aside_flux'); + $this->partial ('nav_menu'); -entryPaginator) && !$this->entryPaginator->isEmpty ()) { - $items = $this->entryPaginator->items (); + if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { + $items = $this->entryPaginator->items (); ?> +
    entryPaginator) && !$this->entryPaginator->isEmpty ()) { entryPaginator->render ('pagination.phtml', 'next'); ?>
    - + +
    + -- cgit v1.2.3