From c96225df6d6ba3aca0c6786c7f091f02c11d6e8d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 12 May 2013 16:51:45 +0200 Subject: Fix issue #84 : affichage erreur si fichier OPML invalide --- app/controllers/configureController.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 2f56da177..8500a4a04 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -218,14 +218,31 @@ class configureController extends ActionController { } elseif ($this->view->req == 'import' && Request::isPost ()) { if ($_FILES['file']['error'] == 0) { // on parse le fichier OPML pour récupérer les catégories et les flux associés - list ($categories, $feeds) = opml_import (file_get_contents ($_FILES['file']['tmp_name'])); - - // On redirige vers le controller feed qui va se charger d'insérer les flux en BDD - // les flux sont mis au préalable dans des variables de Request - Request::_param ('q', 'null'); - Request::_param ('categories', $categories); - Request::_param ('feeds', $feeds); - Request::forward (array ('c' => 'feed', 'a' => 'massiveImport')); + try { + list ($categories, $feeds) = opml_import ( + file_get_contents ($_FILES['file']['tmp_name']) + ); + + // On redirige vers le controller feed qui va se charger d'insérer les flux en BDD + // les flux sont mis au préalable dans des variables de Request + Request::_param ('q', 'null'); + Request::_param ('categories', $categories); + Request::_param ('feeds', $feeds); + Request::forward (array ('c' => 'feed', 'a' => 'massiveImport')); + } catch (OpmlException $e) { + Log::record ($e->getMessage (), Log::ERROR); + + $notif = array ( + 'type' => 'bad', + 'content' => Translate::t ('bad_opml_file') + ); + Session::_param ('notification', $notif); + + Request::forward (array ( + 'c' => 'configure', + 'a' => 'importExport' + ), true); + } } } -- cgit v1.2.3 From bf4552072418268470f81ba3883009da675800e4 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 12 May 2013 17:40:09 +0200 Subject: Fix issue #81 : Possibilité d'ajouter un flux dans une catégorie sur la page d'import / export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 8500a4a04..3b332de75 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -196,6 +196,9 @@ class configureController extends ActionController { } public function importExportAction () { + $catDAO = new CategoryDAO (); + $this->view->categories = $catDAO->listCategories (); + $this->view->req = Request::param ('q'); if ($this->view->req == 'export') { -- cgit v1.2.3 From 9e219cbf5014c8f4f52f3ca6722f7a20cdcc13dd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 12 May 2013 19:21:39 +0200 Subject: Fix issue #70 : lorsqu'on rencontre un problème avec un flux, on l'indique à l'utilisateur (couleur rouge) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 3 +-- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/layout/aside_feed.phtml | 2 +- app/layout/aside_flux.phtml | 2 +- app/models/Feed.php | 30 ++++++++++++++++++++++++++++++ app/views/configure/feed.phtml | 4 ++++ public/theme/freshrss.css | 3 +++ public/theme/global.css | 7 +++++++ 9 files changed, 49 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 77f1787d0..a41d7a33f 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -159,8 +159,7 @@ class feedController extends ActionController { $feedDAO->updateLastUpdate ($feed->id ()); } catch (FeedException $e) { Log::record ($e->getMessage (), Log::ERROR); - // TODO si on a une erreur ici, il faut mettre - // le flux à jour en BDD (error = 1) (issue #70) + $feedDAO->isInError ($feed->id ()); } // On arrête à 10 flux pour ne pas surcharger le serveur diff --git a/app/i18n/en.php b/app/i18n/en.php index c832a519f..3c3a1fbcc 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -114,6 +114,7 @@ return array ( 'or' => 'or', 'informations' => 'Informations', + 'feed_in_error' => 'This feed has encountered a problem. Please verify that it is always reachable.', 'website_url' => 'Website URL', 'feed_url' => 'Feed URL', 'number_articles' => 'Number of articles', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 165b183eb..d270c9b96 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -114,6 +114,7 @@ return array ( 'or' => 'ou', 'informations' => 'Informations', + 'feed_in_error' => 'Ce flux a rencontré un problème. Veuillez vérifier qu\'il est toujours accessible.', 'website_url' => 'URL du site', 'feed_url' => 'URL du flux', 'number_articles' => 'Nombre d\'articles', diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 158f012d0..4c56d12fc 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -43,7 +43,7 @@ feeds)) { ?> feeds as $feed) { ?> -
  • +
  • name (); ?> diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index d1fe6b759..449ffaff4 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -62,7 +62,7 @@
      get_f == $feed->id ()) { $f_active = true; } ?> -
    • +
    • diff --git a/app/models/Log.php b/app/models/Log.php new file mode 100644 index 000000000..5c280fa7a --- /dev/null +++ b/app/models/Log.php @@ -0,0 +1,47 @@ +date; + } + public function level () { + return $this->level; + } + public function info () { + return $this->information; + } + public function _date ($date) { + $this->date = $date; + } + public function _level ($level) { + $this->level = $level; + } + public function _info ($information) { + $this->information = $information; + } +} + +class LogDAO extends Model_txt { + public function __construct () { + parent::__construct (LOG_PATH . '/application.log', 'r+'); + } + + public function lister () { + $logs = array (); + + $i = 0; + while (($line = $this->readLine ()) !== false) { + $logs[$i] = new Log_Model (); + $logs[$i]->_date (preg_replace ("'\[(.*?)\] \[(.*?)\] --- (.*?)'U", "\\1", $line)); + $logs[$i]->_level (preg_replace ("'\[(.*?)\] \[(.*?)\] --- (.*?)'U", "\\2", $line)); + $logs[$i]->_info (preg_replace ("'\[(.*?)\] \[(.*?)\] --- (.*?)'U", "\\3", $line)); + $i++; + } + + return $logs; + } +} \ No newline at end of file diff --git a/app/views/helpers/logs_pagination.phtml b/app/views/helpers/logs_pagination.phtml new file mode 100755 index 000000000..0088dabc6 --- /dev/null +++ b/app/views/helpers/logs_pagination.phtml @@ -0,0 +1,47 @@ + + +nbPage > 1) { ?> +
        + +
      • + currentPage > 1) { ?> + « Début + +
      • + + currentPage - 1; ?> +
      • + currentPage > 1) { ?> + ‹ Précédent + +
      • + + currentPage - 2; $i <= $this->currentPage + 2; $i++) { ?> + 0 && $i <= $this->nbPage) { ?> + currentPage) { ?> + +
      • + +
      • + + + + + currentPage + 1; ?> +
      • + currentPage < $this->nbPage) { ?> + Suivant › + +
      • + nbPage; ?> +
      • + currentPage < $this->nbPage) { ?> + Fin » + +
      • +
      + diff --git a/app/views/index/logs.phtml b/app/views/index/logs.phtml new file mode 100644 index 000000000..c72a84c86 --- /dev/null +++ b/app/views/index/logs.phtml @@ -0,0 +1,21 @@ +
      + + +

      + + logsPaginator->items (); ?> + + +
      + logsPaginator->render ('logs_pagination.phtml', 'page'); ?> + + +
      date ())); ?>info (); ?>
      + + + logsPaginator->render ('logs_pagination.phtml','page'); ?> +
      + +

      + +
      \ No newline at end of file diff --git a/lib/minz/View.php b/lib/minz/View.php index 5c329c159..2bb747aa9 100755 --- a/lib/minz/View.php +++ b/lib/minz/View.php @@ -71,7 +71,7 @@ class View { } else { Log::record ('File doesn\'t exist : `' . $this->view_filename . '`', - Log::WARNING); + Log::NOTICE); } } diff --git a/lib/minz/dao/Model_txt.php b/lib/minz/dao/Model_txt.php index ad15c8b36..c9d5cfe77 100755 --- a/lib/minz/dao/Model_txt.php +++ b/lib/minz/dao/Model_txt.php @@ -27,7 +27,7 @@ class Model_txt { */ public function __construct ($nameFile, $mode = 'a+') { $this->filename = $nameFile; - $this->file = fopen ($this->filename, $mode); + $this->file = @fopen ($this->filename, $mode); if (!$this->file) { throw new FileNotExistException ( diff --git a/public/theme/freshrss.css b/public/theme/freshrss.css index f5d4f6a83..4919639af 100644 --- a/public/theme/freshrss.css +++ b/public/theme/freshrss.css @@ -349,14 +349,29 @@ } .pagination .item { display: table-cell; - border-top: 1px solid #aaa; line-height: 40px; } + .pagination .item.pager-current { + font-weight: bold; + font-size: 140%; + } + .pagination .item.pager-first, + .pagination .item.pager-previous, + .pagination .item.pager-next, + .pagination .item.pager-last { + width: 100px; + } .pagination .item a { display: block; color: #333; font-style: italic; } + .pagination:first-child .item { + border-bottom: 1px solid #aaa; + } + .pagination:last-child .item { + border-top: 1px solid #aaa; + } .loading { background: url("loader.gif") center center no-repeat; font-size: 0; @@ -421,6 +436,33 @@ vertical-align: middle; } +.logs { + border: 1px solid #aaa; +} + .logs .log { + padding: 5px 2%; + overflow: auto; + background: #fafafa; + border-bottom: 1px solid #999; + color: #333; + font-size: 90%; + } + .logs .log .date { + display: block; + } + .logs .log.error { + background: #fdd; + color: #844; + } + .logs .log.warning { + background: #ffe; + color: #c95; + } + .logs .log.notice { + background: #f4f4f4; + color: #aaa; + } + @media(max-width: 840px) { .header, .aside .btn-important, -- cgit v1.2.3 From 8cf9ee76504d2eabd969aff1760b4edb59dfb358 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Jun 2013 17:36:42 +0200 Subject: Fix issue #69 : ajout d'une option pour optimiser la BDD + correction bug script actualisation lorsque connexion paramétrée MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actualize_script.php | 1 + app/controllers/entryController.php | 19 +++++++++++++++++++ app/i18n/en.php | 4 ++++ app/i18n/fr.php | 4 ++++ app/models/Entry.php | 6 ++++++ app/views/configure/display.phtml | 11 +++++++++++ 6 files changed, 45 insertions(+) (limited to 'app/controllers') diff --git a/actualize_script.php b/actualize_script.php index 76bbe2e4f..7f72e419e 100755 --- a/actualize_script.php +++ b/actualize_script.php @@ -24,4 +24,5 @@ require (APP_PATH . '/App_FrontController.php'); $front_controller = new App_FrontController (); $front_controller->init (); +Session::_param('mail', true); // permet de se passer de la phase de connexion $front_controller->run (); diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index 9d6d9a944..c7e13f471 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -97,4 +97,23 @@ class entryController extends ActionController { } } } + + public function optimizeAction() { + // La table des entrées a tendance à grossir énormément + // Cette action permet d'optimiser cette table permettant de grapiller un peu de place + // Cette fonctionnalité n'est à appeler qu'occasionnellement + $entryDAO = new EntryDAO(); + $entryDAO->optimizeTable(); + + $notif = array ( + 'type' => 'good', + 'content' => Translate::t ('optimization_complete') + ); + Session::_param ('notification', $notif); + + Request::forward(array( + 'c' => 'configure', + 'a' => 'display' + ), true); + } } diff --git a/app/i18n/en.php b/app/i18n/en.php index dbb6b1bfe..e40be045a 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -78,6 +78,8 @@ return array ( 'category_emptied' => 'Category has been emptied', 'feed_deleted' => 'Feed has been deleted', + 'optimization_complete' => 'Optimization complete', + 'your_rss_feeds' => 'Your RSS feeds', 'your_favorites' => 'Your favorites', 'public' => 'Public', @@ -154,6 +156,8 @@ return array ( 'share' => 'Share', 'by_email' => 'By mail', 'on_shaarli' => 'On your Shaarli', + 'optimize_bdd' => 'Optimize database', + 'optimize_todo_sometimes' => 'To do occasionally to reduce size of database', 'article' => 'Article', 'title' => 'Title', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 75a76cc7a..69c7a8ffe 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -78,6 +78,8 @@ return array ( 'category_emptied' => 'La catégorie a été vidée', 'feed_deleted' => 'Le flux a été supprimé', + 'optimization_complete' => 'Optimisation terminée', + 'your_rss_feeds' => 'Vos flux RSS', 'your_favorites' => 'Vos favoris', 'public' => 'Public', @@ -154,6 +156,8 @@ return array ( 'share' => 'Partager', 'by_email' => 'Par mail', 'on_shaarli' => 'Sur votre Shaarli', + 'optimize_bdd' => 'Optimiser la base de données', + 'optimize_todo_sometimes' => 'À faire de temps en temps pour réduire la taille de la BDD', 'article' => 'Article', 'title' => 'Titre', diff --git a/app/models/Entry.php b/app/models/Entry.php index 050407390..6af3178ee 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -509,6 +509,12 @@ class EntryDAO extends Model_pdo { return $res[0]['count']; } + + public function optimizeTable() { + $sql = 'OPTIMIZE TABLE entry'; + $stm = $this->bd->prepare ($sql); + $stm->execute (); + } } class HelperEntry { diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index ea4fecd34..c46a02143 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -121,6 +121,17 @@ + +
      + +
      + + + + +
      +
      +
      -- cgit v1.2.3 From 48cfe1571ececb9fae0c361d9147690b04d310e0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 16 Jun 2013 20:48:56 +0200 Subject: Fix issue #67 : différentes vues implémentées + possibilité de choisir la vue par défaut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 3 +++ app/controllers/indexController.php | 8 +++++++- app/models/RSSConfiguration.php | 16 ++++++++++++++++ app/views/configure/display.phtml | 5 +++++ app/views/helpers/global_view.phtml | 6 +++++- 5 files changed, 36 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 4cfc1c085..9ed0ad1eb 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -140,6 +140,7 @@ class configureController extends ActionController { if (Request::isPost ()) { $language = Request::param ('language', 'en'); $nb = Request::param ('posts_per_page', 10); + $mode = Request::param ('view_mode', 'normal'); $view = Request::param ('default_view', 'all'); $display = Request::param ('display_posts', 'no'); $lazyload = Request::param ('lazyload', 'yes'); @@ -153,6 +154,7 @@ class configureController extends ActionController { $this->view->conf->_language ($language); $this->view->conf->_postsPerPage (intval ($nb)); + $this->view->conf->_viewMode ($mode); $this->view->conf->_defaultView ($view); $this->view->conf->_displayPosts ($display); $this->view->conf->_lazyload ($lazyload); @@ -169,6 +171,7 @@ class configureController extends ActionController { $values = array ( 'language' => $this->view->conf->language (), 'posts_per_page' => $this->view->conf->postsPerPage (), + 'view_mode' => $this->view->conf->viewMode (), 'default_view' => $this->view->conf->defaultView (), 'display_posts' => $this->view->conf->displayPosts (), 'lazyload' => $this->view->conf->lazyload (), diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 3f10720c2..a5a5501e7 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -6,13 +6,19 @@ class indexController extends ActionController { private $mode = 'all'; public function indexAction () { - if (Request::param ('output') == 'rss') { + $output = Request::param ('output'); + + if ($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/endless_mode.js')); + + if(!$output) { + Request::_param ('output', $this->view->conf->viewMode()); + } } $entryDAO = new EntryDAO (); diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index 6ebc30e8e..b188c0e65 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -7,6 +7,7 @@ class RSSConfiguration extends Model { ); private $language; private $posts_per_page; + private $view_mode; private $default_view; private $display_posts; private $lazyload; @@ -21,6 +22,7 @@ class RSSConfiguration extends Model { $confDAO = new RSSConfigurationDAO (); $this->_language ($confDAO->language); $this->_postsPerPage ($confDAO->posts_per_page); + $this->_viewMode ($confDAO->view_mode); $this->_defaultView ($confDAO->default_view); $this->_displayPosts ($confDAO->display_posts); $this->_lazyload ($confDAO->lazyload); @@ -41,6 +43,9 @@ class RSSConfiguration extends Model { public function postsPerPage () { return $this->posts_per_page; } + public function viewMode () { + return $this->view_mode; + } public function defaultView () { return $this->default_view; } @@ -91,6 +96,13 @@ class RSSConfiguration extends Model { $this->posts_per_page = 10; } } + public function _viewMode ($value) { + if ($value == 'global' || $value == 'reader') { + $this->view_mode = $value; + } else { + $this->view_mode = 'normal'; + } + } public function _defaultView ($value) { if ($value == 'not_read') { $this->default_view = 'not_read'; @@ -154,6 +166,7 @@ class RSSConfiguration extends Model { class RSSConfigurationDAO extends Model_array { public $language = 'en'; public $posts_per_page = 20; + public $view_mode = 'normal'; public $default_view = 'not_read'; public $display_posts = 'no'; public $lazyload = 'yes'; @@ -185,6 +198,9 @@ class RSSConfigurationDAO extends Model_array { if (isset ($this->array['posts_per_page'])) { $this->posts_per_page = $this->array['posts_per_page']; } + if (isset ($this->array['view_mode'])) { + $this->view_mode = $this->array['view_mode']; + } if (isset ($this->array['default_view'])) { $this->default_view = $this->array['default_view']; } diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index c46a02143..8484a7116 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -46,6 +46,11 @@
      +
      diff --git a/app/views/helpers/normal_view.phtml b/app/views/helpers/normal_view.phtml index eaf1e4276..126fa5a78 100644 --- a/app/views/helpers/normal_view.phtml +++ b/app/views/helpers/normal_view.phtml @@ -64,6 +64,21 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
        + conf) || is_logged ()) { ?> +
      • + isRead ()) { ?> +   + +   + + + isFavorite ()) { ?> +   + +   + +
      • +