diff options
| author | 2013-07-04 19:38:29 +0200 | |
|---|---|---|
| committer | 2013-07-04 19:38:29 +0200 | |
| commit | eb5f05304c253df90873b94ba52d7093115f3850 (patch) | |
| tree | 1152ab618aa5cf884a1f2f2e2d1926da4167a6be /app | |
| parent | 8dd5fd51f74a47e5c80052f27a74cdcd5dd044b9 (diff) | |
| parent | b5f233f6d524ca9f74e9d33bf5692a1a678d7fec (diff) | |
Merge branch 'dev'0.4.0
Diffstat (limited to 'app')
33 files changed, 833 insertions, 441 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php index 77261280e..637d61206 100644 --- a/app/App_FrontController.php +++ b/app/App_FrontController.php @@ -36,6 +36,7 @@ class App_FrontController extends FrontController { include (APP_PATH . '/models/Entry.php'); include (APP_PATH . '/models/EntriesGetter.php'); include (APP_PATH . '/models/RSSPaginator.php'); + include (APP_PATH . '/models/Log.php'); } private function loadParamsView () { @@ -56,6 +57,7 @@ class App_FrontController extends FrontController { View::appendScript ('https://login.persona.org/include.js'); } View::appendScript (Url::display ('/scripts/jquery.js')); + View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js')); View::appendScript (Url::display ('/scripts/notification.js')); } diff --git a/app/controllers/apiController.php b/app/controllers/apiController.php deleted file mode 100755 index 025908f3e..000000000 --- a/app/controllers/apiController.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -class apiController extends ActionController { - public function firstAction() { - header('Content-type: application/json'); - - $this->view->_useLayout (false); - } - - public function getPublicFeedAction () { - $entryDAO = new EntryDAO (); - $entryDAO->_nbItemsPerPage (-1); - - $entries_tmp = $entryDAO->listPublic ('low_to_high'); - - $entries = array (); - foreach ($entries_tmp as $e) { - $author = $e->author (); - - $notes = $e->notes (); - if ($notes == '') { - $feed = $e->feed (true); - if($author != '') { - $notes = Translate::t ('article_published_on_author', $feed->website (), $feed->name (), $author); - } else { - $notes = Translate::t ('article_published_on', $feed->website (), $feed->name ()); - } - } - - $id = $e->id (); - $entries[$id] = array (); - $entries[$id]['title'] = $e->title (); - $entries[$id]['content'] = $notes; - $entries[$id]['date'] = $e->date (true); - $entries[$id]['lastUpdate'] = $e->lastUpdate (true); - $entries[$id]['tags'] = $e->tags (); - $entries[$id]['url'] = $e->link (); - $entries[$id]['type'] = 'url'; - } - - $this->view->entries = $entries; - } - - public function getNbNotReadAction() { - } -} diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 2f56da177..ce53e1040 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -91,6 +91,7 @@ class configureController extends ActionController { $this->view->categories = $catDAO->listCategories (); if (Request::isPost () && $this->view->flux) { + $name = Request::param ('name', ''); $cat = Request::param ('category', 0); $path = Request::param ('path_entries', ''); $priority = Request::param ('priority', 0); @@ -103,6 +104,7 @@ class configureController extends ActionController { } $values = array ( + 'name' => $name, 'category' => $cat, 'pathEntries' => $path, 'priority' => $priority, @@ -138,35 +140,41 @@ 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'); $sort = Request::param ('sort_order', 'low_to_high'); $old = Request::param ('old_entries', 3); $mail = Request::param ('mail_login', false); $openArticle = Request::param ('mark_open_article', 'no'); $openSite = Request::param ('mark_open_site', 'no'); - $openPage = Request::param ('mark_open_page', 'no'); + $scroll = Request::param ('mark_scroll', 'no'); $urlShaarli = Request::param ('shaarli', ''); $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); $this->view->conf->_sortOrder ($sort); $this->view->conf->_oldEntries ($old); $this->view->conf->_mailLogin ($mail); $this->view->conf->_markWhen (array ( 'article' => $openArticle, 'site' => $openSite, - 'page' => $openPage, + 'scroll' => $scroll, )); $this->view->conf->_urlShaarli ($urlShaarli); $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 (), 'sort_order' => $this->view->conf->sortOrder (), 'old_entries' => $this->view->conf->oldEntries (), 'mail_login' => $this->view->conf->mailLogin (), @@ -196,6 +204,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') { @@ -218,14 +229,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); + } } } diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index 35f3150ea..c7e13f471 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -98,74 +98,22 @@ class entryController extends ActionController { } } - public function noteAction () { - View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); - - $not_found = false; - $entryDAO = new EntryDAO (); - $catDAO = new CategoryDAO (); - - $id = Request::param ('id'); - if ($id) { - $entry = $entryDAO->searchById ($id); - - if ($entry) { - $feed = $entry->feed (true); - - if (Request::isPost ()) { - $note = htmlspecialchars (Request::param ('note', '')); - $public = Request::param ('public', 'no'); - if ($public == 'yes') { - $public = true; - } else { - $public = false; - } - - $values = array ( - 'annotation' => $note, - 'is_public' => $public, - 'lastUpdate' => time () - ); - - if ($entryDAO->updateEntry ($id, $values)) { - $notif = array ( - 'type' => 'good', - 'content' => Translate::t ('updated') - ); - } else { - $notif = array ( - 'type' => 'bad', - 'content' => Translate::t ('error_occured') - ); - } - Session::_param ('notification', $notif); - Request::forward (array ( - 'c' => 'entry', - 'a' => 'note', - 'params' => array ( - 'id' => $id - ) - ), true); - } - } else { - $not_found = true; - } - } else { - $not_found = true; - } - - if ($not_found) { - Error::error ( - 404, - array ('error' => array (Translate::t ('page_not_found'))) - ); - } else { - $this->view->entry = $entry; - $this->view->cat_aside = $catDAO->listCategories (); - $this->view->nb_favorites = $entryDAO->countFavorites (); - $this->view->nb_total = $entryDAO->count (); - $this->view->get_c = $feed->category (); - $this->view->get_f = $feed->id (); - } + 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/controllers/feedController.php b/app/controllers/feedController.php index 77f1787d0..76da41c58 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 @@ -220,8 +219,8 @@ class feedController extends ActionController { $entryDAO = new EntryDAO (); $feedDAO = new FeedDAO (); - $categories = Request::param ('categories', array ()); - $feeds = Request::param ('feeds', array ()); + $categories = Request::param ('categories', array (), true); + $feeds = Request::param ('feeds', array (), true); // on ajoute les catégories en masse dans une fonction à part $this->addCategories ($categories); diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index f4f0b98b3..594d379fb 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -6,12 +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 (); @@ -138,6 +145,32 @@ class indexController extends ActionController { View::prependTitle (Translate::t ('about') . ' - '); } + public function logsAction () { + if (login_is_conf ($this->view->conf) && !is_logged ()) { + Error::error ( + 403, + array ('error' => array (Translate::t ('access_denied'))) + ); + } + + View::prependTitle (Translate::t ('logs') . ' - '); + + $logs = array(); + try { + $logDAO = new LogDAO (); + $logs = $logDAO->lister (); + $logs = array_reverse ($logs); + } catch(FileNotExistException $e) { + + } + + //gestion pagination + $page = Request::param ('page', 1); + $this->view->logsPaginator = new Paginator ($logs); + $this->view->logsPaginator->_nbItemsPerPage (50); + $this->view->logsPaginator->_currentPage ($page); + } + public function loginAction () { $this->view->_useLayout (false); diff --git a/app/i18n/en.php b/app/i18n/en.php index a78604c3e..648d70caf 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -37,6 +37,9 @@ return array ( 'before_one_day' => 'Before one day', 'before_one_week' => 'Before one week', 'display' => 'Display', + 'normal_view' => 'Normal view', + 'reader_view' => 'Reading view', + 'global_view' => 'Global view', 'show_all_articles' => 'Show all articles', 'show_not_reads' => 'Show only unread', 'older_first' => 'Oldest first', @@ -58,6 +61,7 @@ return array ( 'rss_feed_management' => 'RSS feeds management', 'configuration_updated' => 'Configuration has been updated', 'general_and_reading_management'=> 'General and reading management', + 'bad_opml_file' => 'Your OPML file is invalid', 'shortcuts_updated' => 'Shortcuts have been updated', 'shortcuts_management' => 'Shortcuts management', 'feeds_marked_read' => 'Feeds have been marked as read', @@ -77,6 +81,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', @@ -113,6 +119,7 @@ return array ( 'or' => 'or', 'informations' => 'Informations', + 'feed_in_error' => 'This feed has encountered a problem. Please verify that it is always reachable then actualize it.', 'website_url' => 'Website URL', 'feed_url' => 'Feed URL', 'number_articles' => 'Number of articles', @@ -142,20 +149,19 @@ return array ( 'default_view' => 'Default view', 'sort_order' => 'Sort order', 'display_articles_unfolded' => 'Show articles unfolded by default', + 'img_with_lazyload' => 'Use "lazy load" mode to load pictures', 'auto_read_when' => 'Mark automatically as read when', 'article_selected' => 'Article is selected', 'article_open_on_website' => 'Article is opened on its original website', - 'page_loaded' => 'Page is loaded', + 'scroll' => 'Page scrolls', 'your_shaarli' => 'Your Shaarli', 'sharing' => 'Sharing', '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', - 'note' => 'Note', - 'add_note' => 'Add a note', - 'update_note' => 'Update your note', - 'ask_public_article' => 'Public article?', 'article' => 'Article', 'title' => 'Title', 'author' => 'Author', @@ -187,6 +193,9 @@ return array ( 'credits' => 'Credits', 'credits_content' => 'Some design elements come from <a href="http://twitter.github.io/bootstrap/">Bootstrap</a> although FreshRSS doesn\'t use this framework. <a href="https://git.gnome.org/browse/gnome-icon-theme-symbolic">Icons</a> come from <a href="https://www.gnome.org/">GNOME project</a>. <em>Open Sans</em> font police used has been created by <a href="https://www.google.com/webfonts/specimen/Open+Sans">Steve Matteson</a>. Favicons are collected with <a href="https://getfavicon.appspot.com/">getFavicon API</a>. FreshRSS is based on <a href="https://github.com/marienfressinaud/MINZ">Minz</a>, a PHP framework.', + 'logs' => 'Logs', + 'logs_empty' => 'Log file is empty', + // DATE 'january' => 'january', 'february' => 'february', @@ -259,6 +268,7 @@ return array ( 'do_not_change_if_doubt' => 'Don\'t change if you doubt about it', 'bdd_conf_is_ok' => 'Database configuration has been saved.', + 'bdd_conf_is_ko' => 'Verify your database information.', 'host' => 'Host', 'username' => 'Username', 'password' => 'Password', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 33f094c21..714443f38 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -37,6 +37,9 @@ return array ( 'before_one_day' => 'Antérieurs à 1 jour', 'before_one_week' => 'Antérieurs à 1 semaine', 'display' => 'Affichage', + 'normal_view' => 'Vue normale', + 'reader_view' => 'Vue lecture', + 'global_view' => 'Vue globale', 'show_all_articles' => 'Afficher tous les articles', 'show_not_reads' => 'Afficher les non lus', 'older_first' => 'Plus anciens en premier', @@ -58,6 +61,7 @@ return array ( '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', + 'bad_opml_file' => 'Votre fichier OPML n\'est pas valide', 'shortcuts_updated' => 'Les raccourcis ont été mis à jour', 'shortcuts_management' => 'Gestion des raccourcis', 'feeds_marked_read' => 'Les flux ont été marqués comme lu', @@ -77,6 +81,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', @@ -113,6 +119,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 puis actualisez-le.', 'website_url' => 'URL du site', 'feed_url' => 'URL du flux', 'number_articles' => 'Nombre d\'articles', @@ -142,20 +149,19 @@ return array ( 'default_view' => 'Vue par défaut', 'sort_order' => 'Ordre de tri', 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', + 'img_with_lazyload' => 'Utiliser le mode "lazy load" pour charger les images', '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', + 'scroll' => 'Au défilement de la page', 'your_shaarli' => 'Votre Shaarli', 'sharing' => 'Partage', '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', - 'note' => 'Note', - 'add_note' => 'Ajouter une note', - 'update_note' => 'Modifier votre note', - 'ask_public_article' => 'Article public ?', 'article' => 'Article', 'title' => 'Titre', 'author' => 'Auteur', @@ -187,6 +193,9 @@ return array ( 'credits' => 'Crédits', 'credits_content' => 'Des éléments de design sont issus du <a href="http://twitter.github.io/bootstrap/">projet Bootstrap</a> bien que FreshRSS n\'utilise pas ce framework. Les <a href="https://git.gnome.org/browse/gnome-icon-theme-symbolic">icônes</a> sont issues du <a href="https://www.gnome.org/">projet GNOME</a>. La police <em>Open Sans</em> utilisée a été créée par <a href="https://www.google.com/webfonts/specimen/Open+Sans">Steve Matteson</a>. Les favicons sont récupérés grâce au site <a href="https://getfavicon.appspot.com/">getFavicon</a>. FreshRSS repose sur <a href="https://github.com/marienfressinaud/MINZ">Minz</a>, un framework PHP.', + 'logs' => 'Logs', + 'logs_empty' => 'Les logs sont vides', + // DATE 'january' => 'janvier', 'february' => 'février', @@ -259,6 +268,7 @@ return array ( 'do_not_change_if_doubt' => 'Laissez tel quel dans le doute', 'bdd_conf_is_ok' => 'La configuration de la base de données a été enregistrée.', + 'bdd_conf_is_ko' => 'Vérifiez les informations d\'accès à la base de données.', 'host' => 'Hôte', 'username' => 'Nom utilisateur', 'password' => 'Mot de passe', 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 @@ <?php if (!empty ($this->feeds)) { ?> <?php foreach ($this->feeds as $feed) { ?> - <li class="item<?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?>"> + <li class="item<?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?>"> <a href="<?php echo _url ('configure', 'feed', 'id', $feed->id ()); ?>"> <img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" /> <?php echo $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 @@ <ul class="feeds<?php echo $c_active ? ' active' : ''; ?>"> <?php foreach ($feeds as $feed) { ?> <?php $f_active = false; if ($this->get_f == $feed->id ()) { $f_active = true; } ?> - <li class="item<?php echo $f_active ? ' active' : ''; ?>"> + <li class="item<?php echo $f_active ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?>"> <div class="dropdown"> <div id="dropdown-<?php echo $feed->id(); ?>" class="dropdown-target"></div> <a class="dropdown-toggle" href="#dropdown-<?php echo $feed->id(); ?>"><i class="icon i_configure"></i></a> diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 628019c97..4131f8687 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -15,21 +15,26 @@ </div> <div class="item search"> - <?php - $params = Request::params (); - if (isset ($params['search'])) { - unset ($params['search']); - } - $url = array ( - 'c' => 'index', - 'a' => 'index', - 'params' => $params - ); - ?> - <form action="<?php echo Url::display ($url); ?>" method="get"> + <form action="<?php echo _url ('index', 'index'); ?>" method="get"> <div class="stick"> - <?php $s = Request::param ('search', ''); ?> - <input type="text" name="search" id="search" value="<?php echo $s; ?>" placeholder="<?php echo Translate::t ('search'); ?>" /> + <?php $search = Request::param ('search', ''); ?> + <input type="text" name="search" id="search" value="<?php echo $search; ?>" placeholder="<?php echo Translate::t ('search'); ?>" /> + + <?php $get = Request::param ('get', ''); ?> + <?php if($get != '') { ?> + <input type="hidden" name="get" value="<?php echo $get; ?>" /> + <?php } ?> + + <?php $order = Request::param ('order', ''); ?> + <?php if($order != '') { ?> + <input type="hidden" name="order" value="<?php echo $order; ?>" /> + <?php } ?> + + <?php $state = Request::param ('state', ''); ?> + <?php if($state != '') { ?> + <input type="hidden" name="state" value="<?php echo $state; ?>" /> + <?php } ?> + <button class="btn" type="submit"><i class="icon i_search"></i></button> </div> </form> @@ -49,6 +54,7 @@ <li class="item"><a href="<?php echo _url ('configure', 'shortcut'); ?>"><?php echo Translate::t ('shortcuts'); ?></a></li> <li class="separator"></li> <li class="item"><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Translate::t ('about'); ?></a></li> + <li class="item"><a href="<?php echo _url ('index', 'logs'); ?>"><?php echo Translate::t ('logs'); ?></a></li> </ul> </div> </div> diff --git a/app/layout/nav_entries.phtml b/app/layout/nav_entries.phtml new file mode 100644 index 000000000..101e7443e --- /dev/null +++ b/app/layout/nav_entries.phtml @@ -0,0 +1,5 @@ +<ul class="nav_entries"> + <li class="item"><a class="previous_entry" href="#"><i class="icon i_prev"></i></a></li> + <li class="item"><a href="#"><i class="icon i_up"></i></a></li> + <li class="item"><a class="next_entry" href="#"><i class="icon i_next"></i></a></li> +</ul>
\ No newline at end of file diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 3411f344b..d36814bee 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -59,43 +59,72 @@ <ul class="dropdown-menu"> <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> + <?php + $url_output = $url; + $actual_view = Request::param('output', 'normal'); + ?> + <?php if($actual_view != 'normal') { ?> + <li class="item"> + <?php $url_output['params']['output'] = 'normal'; ?> + <a class="view_normal" href="<?php echo Url::display ($url_output); ?>"> + <?php echo Translate::t ('normal_view'); ?> + </a> + </li> + <?php } if($actual_view != 'reader') { ?> + <li class="item"> + <?php $url_output['params']['output'] = 'reader'; ?> + <a class="view_normal" href="<?php echo Url::display ($url_output); ?>"> + <?php echo Translate::t ('reader_view'); ?> + </a> + </li> + <?php } if($actual_view != 'global') { ?> + <li class="item"> + <?php $url_output['params']['output'] = 'global'; ?> + <a class="view_normal" href="<?php echo Url::display ($url_output); ?>"> + <?php echo Translate::t ('global_view'); ?> + </a> + </li> + <?php } ?> + + <li class="separator"></li> + <li class="item"> <?php + $url_state = $url; if ($this->state == 'not_read') { - $url['params']['state'] = 'all'; + $url_state['params']['state'] = 'all'; ?> - <a class="print_all" href="<?php echo Url::display ($url); ?>"><?php echo Translate::t ('show_all_articles'); ?></a> + <a class="print_all" href="<?php echo Url::display ($url_state); ?>"> + <?php echo Translate::t ('show_all_articles'); ?> + </a> <?php } else { - $url['params']['state'] = 'not_read'; + $url_state['params']['state'] = 'not_read'; ?> - <a class="print_non_read" href="<?php echo Url::display ($url); ?>"><?php echo Translate::t ('show_not_reads'); ?></a> + <a class="print_non_read" href="<?php echo Url::display ($url_state); ?>"> + <?php echo Translate::t ('show_not_reads'); ?> + </a> <?php } ?> </li> + <li class="separator"></li> - <?php - $params = Request::params (); - if (isset ($params['search'])) { - $params['search'] = urlencode ($params['search']); - } - $url = array ( - 'c' => 'index', - 'a' => 'index', - 'params' => $params - ); - ?> <li class="item"> <?php + $url_order = $url; if ($this->order == 'low_to_high') { - $url['params']['order'] = 'high_to_low'; + $url_order['params']['order'] = 'high_to_low'; ?> - <a href="<?php echo Url::display ($url); ?>"><?php echo Translate::t ('older_first'); ?></a> + <a href="<?php echo Url::display ($url_order); ?>"> + <?php echo Translate::t ('older_first'); ?> + </a> <?php } else { - $url['params']['order'] = 'low_to_high'; + $url_order['params']['order'] = 'low_to_high'; ?> - <a href="<?php echo Url::display ($url); ?>"><?php echo Translate::t ('newer_first'); ?></a> + <a href="<?php echo Url::display ($url_order); ?>"> + <?php echo Translate::t ('newer_first'); ?> + </a> <?php } ?> </li> </ul> diff --git a/app/models/Category.php b/app/models/Category.php index 273559b1e..0c991588d 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -35,10 +35,10 @@ class Category extends Model { public function feeds () { if (is_null ($this->feeds)) { $feedDAO = new FeedDAO (); - return $feedDAO->listByCategory ($this->id ()); - } else { - return $this->feeds; + $this->feeds = $feedDAO->listByCategory ($this->id ()); } + + return $this->feeds; } public function _id ($value) { diff --git a/app/models/Entry.php b/app/models/Entry.php index f49e74239..6af3178ee 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -194,6 +194,29 @@ class Entry extends Model { } } + public function loadCompleteContent($pathEntries) { + // Gestion du contenu + // On cherche à récupérer les articles en entier... même si le flux ne le propose pas + if ($pathEntries) { + $entryDAO = new EntryDAO(); + $entry = $entryDAO->searchByGuid($this->feed, $this->guid); + + if($entry) { + // l'article existe déjà en BDD, en se contente de recharger ce contenu + $this->content = $entry->content(); + } else { + try { + // l'article n'est pas en BDD, on va le chercher sur le site + $this->content = get_content_by_parsing( + $this->link(), $pathEntries + ); + } catch (Exception $e) { + // rien à faire, on garde l'ancien contenu (requête a échoué) + } + } + } + } + public function toArray () { return array ( 'id' => $this->id (), @@ -239,7 +262,7 @@ class EntryDAO extends Model_pdo { return true; } else { $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); + Log::record ('SQL error : ' . $info[2], Log::NOTICE); return false; } } @@ -360,6 +383,27 @@ class EntryDAO extends Model_pdo { } } + public function searchByGuid ($feed_id, $id) { + // un guid est unique pour un flux donné + $sql = 'SELECT * FROM entry WHERE id_feed=? AND guid=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $feed_id, + $id + ); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + list ($entry, $next) = HelperEntry::daoToEntry ($res); + + if (isset ($entry[0])) { + return $entry[0]; + } else { + return false; + } + } + public function searchById ($id) { $sql = 'SELECT * FROM entry WHERE id=?'; $stm = $this->bd->prepare ($sql); @@ -465,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/models/Exception/FeedException.php b/app/models/Exception/FeedException.php index bc61e1736..bff297eb9 100644 --- a/app/models/Exception/FeedException.php +++ b/app/models/Exception/FeedException.php @@ -11,3 +11,9 @@ class BadUrlException extends FeedException { parent::__construct ('`' . $url . '` is not a valid URL'); } } + +class OpmlException extends FeedException { + public function __construct ($name_file) { + parent::__construct ('OPML file is invalid'); + } +} diff --git a/app/models/Feed.php b/app/models/Feed.php index 51c409b69..4c6a3d229 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -12,6 +12,7 @@ class Feed extends Model { private $priority = 10; private $pathEntries = ''; private $httpAuth = ''; + private $error = false; public function __construct ($url) { $this->_url ($url); @@ -69,6 +70,9 @@ class Feed extends Model { ); } } + public function inError () { + return $this->error; + } public function nbEntries () { $feedDAO = new FeedDAO (); return $feedDAO->countEntries ($this->id ()); @@ -138,6 +142,14 @@ class Feed extends Model { public function _httpAuth ($value) { $this->httpAuth = $value; } + public function _error ($value) { + if ($value) { + $value = true; + } else { + $value = false; + } + $this->error = $value; + } public function load () { if (!is_null ($this->url)) { @@ -204,18 +216,7 @@ class Feed extends Model { } } - // Gestion du contenu - // On cherche à récupérer les articles en entier... même si le flux ne le propose pas - $path = $this->pathEntries (); - if ($path) { - try { - $content = get_content_by_parsing ($item->get_permalink (), $path); - } catch (Exception $e) { - $content = $item->get_content (); - } - } else { - $content = $item->get_content (); - } + $content = $item->get_content (); $entry = new Entry ( $this->id (), @@ -227,6 +228,8 @@ class Feed extends Model { $date ? $date : time () ); $entry->_tags ($tags); + // permet de récupérer le contenu des flux tronqués + $entry->loadCompleteContent($this->pathEntries()); $entries[$entry->id ()] = $entry; } @@ -289,7 +292,7 @@ class FeedDAO extends Model_pdo { } public function updateLastUpdate ($id) { - $sql = 'UPDATE feed SET lastUpdate=? WHERE id=?'; + $sql = 'UPDATE feed SET lastUpdate=?, error=0 WHERE id=?'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -306,6 +309,23 @@ class FeedDAO extends Model_pdo { } } + public function isInError ($id) { + $sql = 'UPDATE feed SET error=1 WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $id + ); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function changeCategory ($idOldCat, $idNewCat) { $catDAO = new CategoryDAO (); $newCat = $catDAO->searchById ($idNewCat); @@ -470,6 +490,7 @@ class HelperFeed { $list[$key]->_priority ($dao['priority']); $list[$key]->_pathEntries ($dao['pathEntries']); $list[$key]->_httpAuth (base64_decode ($dao['httpAuth'])); + $list[$key]->_error ($dao['error']); if (isset ($dao['id'])) { $list[$key]->_id ($dao['id']); 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 @@ +<?php + +class Log_Model extends Model { + private $date; + private $level; + private $information; + + public function date () { + return $this->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/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index 00fe3fe52..dde120e4a 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -7,8 +7,10 @@ class RSSConfiguration extends Model { ); private $language; private $posts_per_page; + private $view_mode; private $default_view; private $display_posts; + private $lazyload; private $sort_order; private $old_entries; private $shortcuts = array (); @@ -20,8 +22,10 @@ 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); $this->_sortOrder ($confDAO->sort_order); $this->_oldEntries ($confDAO->old_entries); $this->_shortcuts ($confDAO->shortcuts); @@ -39,12 +43,18 @@ 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; } public function displayPosts () { return $this->display_posts; } + public function lazyload () { + return $this->lazyload; + } public function sortOrder () { return $this->sort_order; } @@ -66,8 +76,8 @@ class RSSConfiguration extends Model { public function markWhenSite () { return $this->mark_when['site']; } - public function markWhenPage () { - return $this->mark_when['page']; + public function markWhenScroll () { + return $this->mark_when['scroll']; } public function urlShaarli () { return $this->url_shaarli; @@ -80,12 +90,19 @@ class RSSConfiguration extends Model { $this->language = $value; } public function _postsPerPage ($value) { - if (is_int (intval ($value))) { + if (is_int (intval ($value)) && $value > 0) { $this->posts_per_page = $value; } else { $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'; @@ -100,6 +117,13 @@ class RSSConfiguration extends Model { $this->display_posts = 'no'; } } + public function _lazyload ($value) { + if ($value == 'no') { + $this->lazyload = 'no'; + } else { + $this->lazyload = 'yes'; + } + } public function _sortOrder ($value) { if ($value == 'high_to_low') { $this->sort_order = 'high_to_low'; @@ -108,7 +132,7 @@ class RSSConfiguration extends Model { } } public function _oldEntries ($value) { - if (is_int (intval ($value))) { + if (is_int (intval ($value)) && $value > 0) { $this->old_entries = $value; } else { $this->old_entries = 3; @@ -127,9 +151,19 @@ class RSSConfiguration extends Model { } } public function _markWhen ($values) { + if(!isset($values['article'])) { + $values['article'] = 'yes'; + } + if(!isset($values['site'])) { + $values['site'] = 'yes'; + } + if(!isset($values['scroll'])) { + $values['scroll'] = 'yes'; + } + $this->mark_when['article'] = $values['article']; $this->mark_when['site'] = $values['site']; - $this->mark_when['page'] = $values['page']; + $this->mark_when['scroll'] = $values['scroll']; } public function _urlShaarli ($value) { $this->url_shaarli = ''; @@ -142,8 +176,10 @@ 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'; public $sort_order = 'low_to_high'; public $old_entries = 3; public $shortcuts = array ( @@ -159,7 +195,7 @@ class RSSConfigurationDAO extends Model_array { public $mark_when = array ( 'article' => 'yes', 'site' => 'yes', - 'page' => 'no' + 'scroll' => 'no' ); public $url_shaarli = ''; @@ -172,12 +208,18 @@ 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']; } if (isset ($this->array['display_posts'])) { $this->display_posts = $this->array['display_posts']; } + if (isset ($this->array['lazyload'])) { + $this->lazyload = $this->array['lazyload']; + } if (isset ($this->array['sort_order'])) { $this->sort_order = $this->array['sort_order']; } diff --git a/app/views/api/getNbNotRead.phtml b/app/views/api/getNbNotRead.phtml deleted file mode 100644 index 31c58f6ca..000000000 --- a/app/views/api/getNbNotRead.phtml +++ /dev/null @@ -1,3 +0,0 @@ -<?php -echo json_encode($this->nb_not_read); - diff --git a/app/views/api/getPublicFeed.phtml b/app/views/api/getPublicFeed.phtml deleted file mode 100644 index 8eb0774f2..000000000 --- a/app/views/api/getPublicFeed.phtml +++ /dev/null @@ -1,3 +0,0 @@ -<?php -echo json_encode ($this->entries); -?> diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index be67896dc..7da5b2947 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -46,6 +46,11 @@ <div class="form-group"> <label class="group-name"><?php echo Translate::t ('default_view'); ?></label> <div class="group-controls"> + <select name="view_mode" id="view_mode"> + <option value="normal"<?php echo $this->conf->viewMode () == 'normal' ? ' selected="selected"' : ''; ?>><?php echo Translate::t ('normal_view'); ?></option> + <option value="reader"<?php echo $this->conf->viewMode () == 'reader' ? ' selected="selected"' : ''; ?>><?php echo Translate::t ('reader_view'); ?></option> + <option value="global"<?php echo $this->conf->viewMode () == 'global' ? ' selected="selected"' : ''; ?>><?php echo Translate::t ('global_view'); ?></option> + </select> <label class="radio" for="radio_all"> <input type="radio" name="default_view" id="radio_all" value="all"<?php echo $this->conf->defaultView () == 'all' ? ' checked="checked"' : ''; ?> /> <?php echo Translate::t ('show_all_articles'); ?> @@ -68,6 +73,20 @@ </div> <div class="form-group"> + <label class="group-name"><?php echo Translate::t ('img_with_lazyload'); ?></label> + <div class="group-controls"> + <label class="radio" for="lazyload_yes"> + <input type="radio" name="lazyload" id="lazyload_yes" value="yes"<?php echo $this->conf->lazyload () == 'yes' ? ' checked="checked"' : ''; ?> /> + <?php echo Translate::t ('yes'); ?><noscript> - <b><?php echo Translate::t ('javascript_should_be_activated'); ?></b></noscript> + </label> + <label class="radio" for="lazyload_no"> + <input type="radio" name="lazyload" id="lazyload_no" value="no"<?php echo $this->conf->lazyload () == 'no' ? ' checked="checked"' : ''; ?> /> + <?php echo Translate::t ('no'); ?> + </label> + </div> + </div> + + <div class="form-group"> <label class="group-name"><?php echo Translate::t ('display_articles_unfolded'); ?></label> <div class="group-controls"> <label class="radio" for="radio_yes"> @@ -92,9 +111,9 @@ <input type="checkbox" name="mark_open_site" id="check_open_site" value="yes"<?php echo $this->conf->markWhenSite () == 'yes' ? ' checked="checked"' : ''; ?> /> <?php echo Translate::t ('article_open_on_website'); ?> </label> - <label class="checkbox" for="check_open_page"> - <input type="checkbox" name="mark_open_page" id="check_open_page" value="yes"<?php echo $this->conf->markWhenPage () == 'yes' ? ' checked="checked"' : ''; ?> /> - <?php echo Translate::t ('page_loaded'); ?> + <label class="checkbox" for="check_scroll"> + <input type="checkbox" name="mark_scroll" id="check_scroll" value="yes"<?php echo $this->conf->markWhenScroll () == 'yes' ? ' checked="checked"' : ''; ?> /> + <?php echo Translate::t ('scroll'); ?> </label> </div> </div> @@ -107,6 +126,17 @@ </div> </div> + <legend><?php echo Translate::t ('advanced'); ?></legend> + <div class="form-group"> + <label class="group-name"></label> + <div class="group-controls"> + <a class="btn" href="<?php echo _url('entry', 'optimize'); ?>"> + <?php echo Translate::t('optimize_bdd'); ?> + </a> + <i class="icon i_help"></i> <?php echo Translate::t('optimize_todo_sometimes'); ?> + </div> + </div> + <div class="form-group form-actions"> <div class="group-controls"> <button type="submit" class="btn btn-important"><?php echo Translate::t ('save'); ?></button> diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 33483f72d..ec2ff3bdb 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -7,9 +7,19 @@ <h1><?php echo $this->flux->name (); ?></h1> <?php echo $this->flux->description (); ?> + <?php if ($this->flux->inError ()) { ?> + <p class="alert alert-error"><span class="alert-head"><?php echo Translate::t ('damn'); ?></span> <?php echo Translate::t ('feed_in_error'); ?></p> + <?php } ?> + <form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>"> <legend><?php echo Translate::t ('informations'); ?></legend> <div class="form-group"> + <label class="group-name" for="name"><?php echo Translate::t ('title'); ?></label> + <div class="group-controls"> + <input type="text" name="name" id="name" value="<?php echo $this->flux->name () ; ?>" /> + </div> + </div> + <div class="form-group"> <label class="group-name"><?php echo Translate::t ('website_url'); ?></label> <div class="group-controls"> <span class="control"><a target="_blank" href="<?php echo $this->flux->website (); ?>"><?php echo $this->flux->website (); ?></a></span> @@ -22,6 +32,14 @@ </div> </div> <div class="form-group"> + <label class="group-name"></label> + <div class="group-controls"> + <a class="btn" href="<?php echo _url ('feed', 'actualize', 'id', $this->flux->id ()); ?>"> + <i class="icon i_refresh"></i> <?php echo Translate::t('actualize'); ?> + </a> + </div> + </div> + <div class="form-group"> <label class="group-name"><?php echo Translate::t ('number_articles'); ?></label> <div class="group-controls"> <span class="control"><?php echo $this->flux->nbEntries (); ?></span> diff --git a/app/views/entry/note.phtml b/app/views/entry/note.phtml deleted file mode 100644 index 061060106..000000000 --- a/app/views/entry/note.phtml +++ /dev/null @@ -1,65 +0,0 @@ -<?php $this->partial ('aside_flux'); ?> - -<div class="post"> - <a href="<?php echo _url ('index', 'index'); ?>"><?php echo Translate::t ('back_to_rss_feeds'); ?></a> - - <form method="post" action="<?php echo _url ('entry', 'note', 'id', $this->entry->id ()); ?>"> - <legend><?php echo Translate::t ('note'); ?></legend> - - <div class="form-group"> - <label class="group-name" for="note"><?php echo Translate::t ('add_note'); ?></label> - <div class="group-controls"> - <textarea rows="5" cols="80" name="note" id="note"><?php echo $this->entry->notes (); ?></textarea> - </div> - </div> - <div class="form-group"> - <label class="group-name" for="public_note"><?php echo Translate::t ('ask_public_article'); ?></label> - <div class="group-controls"> - <label class="checkbox" for="public"> - <input type="checkbox" name="public" id="public" value="yes"<?php echo $this->entry->isPublic () ? ' checked="checked"' : ''; ?> /> <?php echo Translate::t ('yes'); ?> - </label> - </div> - </div> - - <div class="form-group form-actions"> - <div class="group-controls"> - <button type="submit" class="btn btn-important"><?php echo Translate::t ('save'); ?></button> - <button type="reset" class="btn"><?php echo Translate::t ('cancel'); ?></button> - </div> - </div> - - <legend><?php echo Translate::t ('article'); ?></legend> - - <div class="form-group"> - <label class="group-name"><?php echo Translate::t ('title'); ?></label> - <div class="group-controls"> - <span class="control"><a href="<?php echo $this->entry->link (); ?>"><?php echo $this->entry->title (); ?></a></span> - </div> - </div> - - <?php - $author = $this->entry->author (); - if ($author) { ?> - <div class="form-group"> - <label class="group-name"><?php echo Translate::t ('author'); ?></label> - <div class="group-controls"> - <span class="control"><?php echo $author; ?></span> - </div> - </div> - <?php } ?> - - <div class="form-group"> - <label class="group-name"><?php echo Translate::t ('publication_date'); ?></label> - <div class="group-controls"> - <span class="control"><?php echo $this->entry->date (); ?></span> - </div> - </div> - - <div class="form-group"> - <label class="group-name"><?php echo Translate::t ('article'); ?></label> - <div class="group-controls"> - <span class="control"><?php echo $this->entry->content (); ?></span> - </div> - </div> - </form> -</div> diff --git a/app/views/helpers/global_view.phtml b/app/views/helpers/global_view.phtml new file mode 100644 index 000000000..fff391cba --- /dev/null +++ b/app/views/helpers/global_view.phtml @@ -0,0 +1,37 @@ +<?php $this->partial ('nav_menu'); ?> + +<div id="stream" class="global"> +<?php + foreach ($this->cat_aside as $cat) { + $feeds = $cat->feeds (); + $catNotRead = $cat->nbNotRead (); + if (!empty ($feeds)) { +?> + <div class="category"> + <div class="cat_header"> + <a href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>"> + <?php echo $cat->name(); ?><?php echo $catNotRead > 0 ? ' (' . $catNotRead . ')' : ''; ?> + </a> + </div> + + <ul class="feeds"> + <?php foreach ($feeds as $feed) { ?> + <?php $not_read = $feed->nbNotRead (); ?> + <li class="item"> + <img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" /> + + <a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"> + <?php echo $not_read > 0 ? '<b>' : ''; ?> + <?php echo $feed->name(); ?> + <?php echo $not_read > 0 ? ' (' . $not_read . ')' : ''; ?> + <?php echo $not_read > 0 ? '</b>' : ''; ?> + </a> + </li> + <?php } ?> + </ul> + </div> +<?php + } + } +?> +</div>
\ 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 @@ +<?php + $c = Request::controllerName (); + $a = Request::actionName (); + $params = Request::params (); +?> + +<?php if ($this->nbPage > 1) { ?> +<ul class="pagination"> + <?php $params[$getteur] = 1; ?> + <li class="item pager-first"> + <?php if ($this->currentPage > 1) { ?> + <a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">« Début</a> + <?php } ?> + </li> + + <?php $params[$getteur] = $this->currentPage - 1; ?> + <li class="item pager-previous"> + <?php if ($this->currentPage > 1) { ?> + <a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">‹ Précédent</a> + <?php } ?> + </li> + + <?php for ($i = $this->currentPage - 2; $i <= $this->currentPage + 2; $i++) { ?> + <?php if($i > 0 && $i <= $this->nbPage) { ?> + <?php if ($i != $this->currentPage) { ?> + <?php $params[$getteur] = $i; ?> + <li class="item pager-item"><a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>"><?php echo $i; ?></a></li> + <?php } else { ?> + <li class="item pager-current"><?php echo $i; ?></li> + <?php } ?> + <?php } ?> + <?php } ?> + + <?php $params[$getteur] = $this->currentPage + 1; ?> + <li class="item pager-next"> + <?php if ($this->currentPage < $this->nbPage) { ?> + <a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">Suivant ›</a> + <?php } ?> + </li> + <?php $params[$getteur] = $this->nbPage; ?> + <li class="item pager-last"> + <?php if ($this->currentPage < $this->nbPage) { ?> + <a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>">Fin »</a> + <?php } ?> + </li> +</ul> +<?php } ?> diff --git a/app/views/helpers/normal_view.phtml b/app/views/helpers/normal_view.phtml new file mode 100644 index 000000000..126fa5a78 --- /dev/null +++ b/app/views/helpers/normal_view.phtml @@ -0,0 +1,131 @@ +<?php + +$this->partial ('aside_flux'); +$this->partial ('nav_menu'); + +if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { + $items = $this->entryPaginator->items (); +?> + +<div id="stream" class="normal"> + <?php + $display_today = true; + $display_yesterday = true; + $display_others = true; + ?> + <?php foreach ($items as $item) { ?> + + <?php if ($display_today && $item->isDay (Days::TODAY)) { ?> + <div class="day"><?php echo Translate::t ('today'); ?> - <?php echo timestamptodate (time (), false); ?></div> + <?php $display_today = false; } ?> + <?php if ($display_yesterday && $item->isDay (Days::YESTERDAY)) { ?> + <div class="day"><?php echo Translate::t ('yesterday'); ?> - <?php echo timestamptodate (time () - 86400, false); ?></div> + <?php $display_yesterday = false; } ?> + <?php if ($display_others && $item->isDay (Days::BEFORE_YESTERDAY)) { ?> + <div class="day"><?php echo Translate::t ('before_yesterday'); ?></div> + <?php $display_others = false; } ?> + + <div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>"> + <ul class="horizontal-list flux_header"> + <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> + <li class="item manage"> + <?php if (!$item->isRead ()) { ?> + <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 1); ?>"> </a> + <?php } else { ?> + <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 0); ?>"> </a> + <?php } ?> + + <?php if (!$item->isFavorite ()) { ?> + <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 1); ?>"> </a> + <?php } else { ?> + <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 0); ?>"> </a> + <?php } ?> + </li> + <?php } ?> + <?php $feed = $item->feed (true); ?> + <li class="item website"><a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"><img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" /> <span><?php echo $feed->name (); ?></span></a></li> + <li class="item title"><?php echo $item->title (); ?></li> + <li class="item date"><?php echo $item->date (); ?></li> + <li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"> </a></li> + </ul> + + <div class="flux_content"> + <div class="content"> + <h1 class="title"><?php echo $item->title (); ?></h1> + <?php $author = $item->author (); ?> + <?php echo $author != '' ? '<div class="author">' . Translate::t ('by_author', $author) . '</div>' : ''; ?> + <?php + if($this->conf->lazyload() == 'yes') { + echo lazyimg($item->content ()); + } else { + echo $item->content(); + } + ?> + </div> + + <ul class="horizontal-list bottom"> + <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> + <li class="item manage"> + <?php if (!$item->isRead ()) { ?> + <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 1); ?>"> </a> + <?php } else { ?> + <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 0); ?>"> </a> + <?php } ?> + + <?php if (!$item->isFavorite ()) { ?> + <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 1); ?>"> </a> + <?php } else { ?> + <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 0); ?>"> </a> + <?php } ?> + </li> + <?php } ?> + <li class="item"> + <div class="dropdown"> + <div id="dropdown-share-<?php echo $item->id ();?>" class="dropdown-target"></div> + <i class="icon i_share"></i> <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id ();?>"><?php echo Translate::t ('share'); ?></a> + + <ul class="dropdown-menu"> + <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> + + <li class="item"><a href="mailto:?subject=<?php echo $item->title (); ?>&body=J'ai trouvé cet article intéressant, tu peux le lire à cette adresse : <?php echo urlencode($item->link ()); ?>"><?php echo Translate::t ('by_email'); ?></a></li> + <?php + $shaarli = $this->conf->urlShaarli (); + if ($shaarli) { + ?> + <li class="item"><a target="_blank" href="<?php echo $shaarli . '?post=' . urlencode($item->link ()) . '&title=' . urlencode ($item->title ()) . '&source=bookmarklet'; ?>"><?php echo Translate::t ('on_shaarli'); ?></a></li> + <?php } ?> + </ul> + </div> + </li> + <?php $tags = $item->tags(); ?> + <?php if(!empty($tags)) { ?> + <li class="item"> + <div class="dropdown"> + <div id="dropdown-tags-<?php echo $item->id ();?>" class="dropdown-target"></div> + <i class="icon i_tag"></i> <a class="dropdown-toggle" href="#dropdown-tags-<?php echo $item->id ();?>"><?php echo Translate::t ('related_tags'); ?></a> + + <ul class="dropdown-menu"> + <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> + + <?php foreach($tags as $tag) { ?> + <li class="item"><a href="<?php echo _url ('index', 'index', 'search', urlencode ('#' . $tag)); ?>"><?php echo $tag; ?></a></li> + <?php } ?> + </ul> + </div> + </li> + <?php } ?> + </ul> + </div> + </div> + <?php } ?> + + <?php $this->entryPaginator->render ('pagination.phtml', 'next'); ?> +</div> + +<?php $this->partial ('nav_entries'); ?> + +<?php } else { ?> +<div class="alert alert-warn"> + <span class="alert-head"><?php echo Translate::t ('no_feed_to_display'); ?></span> +</div> +<?php } ?>
\ No newline at end of file diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml index f029f281a..80c0976ad 100755 --- a/app/views/helpers/pagination.phtml +++ b/app/views/helpers/pagination.phtml @@ -8,7 +8,7 @@ <li class="item pager-next"> <?php if ($this->next != '') { ?> <?php $params[$getteur] = $this->next; ?> - <a href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>"><?php echo Translate::t ('load_more'); ?></a> + <a id="load_more" href="<?php echo Url::display (array ('c' => $c, 'a' => $a, 'params' => $params)); ?>"><?php echo Translate::t ('load_more'); ?></a> <?php } else { ?> <?php echo Translate::t ('nothing_to_load'); ?> <?php } ?> diff --git a/app/views/helpers/reader_view.phtml b/app/views/helpers/reader_view.phtml new file mode 100644 index 000000000..cdca393b9 --- /dev/null +++ b/app/views/helpers/reader_view.phtml @@ -0,0 +1,45 @@ +<?php +$this->partial ('nav_menu'); + +if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { + $items = $this->entryPaginator->items (); +?> + +<div id="stream" class="reader"> + <?php foreach ($items as $item) { ?> + + <div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>"> + <div class="flux_content"> + <div class="content"> + <?php $feed = $item->feed (true); ?> + <a href="<?php echo $item->link (); ?>"> + <img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" /> <span><?php echo $feed->name (); ?></span> + </a> + <h1 class="title"><?php echo $item->title (); ?></h1> + + <div class="author"> + <?php $author = $item->author (); ?> + <?php echo $author != '' ? Translate::t ('by_author', $author) . ' - ' : ''; ?> + <?php echo $item->date (); ?> + </div> + + <?php + if($this->conf->lazyload() == 'yes') { + echo lazyimg($item->content ()); + } else { + echo $item->content(); + } + ?> + </div> + </div> + </div> + <?php } ?> + + <?php $this->entryPaginator->render ('pagination.phtml', 'next'); ?> +</div> + +<?php } else { ?> +<div class="alert alert-warn"> + <span class="alert-head"><?php echo Translate::t ('no_feed_to_display'); ?></span> +</div> +<?php } ?>
\ No newline at end of file diff --git a/app/views/helpers/rss.phtml b/app/views/helpers/rss_view.phtml index 83de6de2e..83de6de2e 100755 --- a/app/views/helpers/rss.phtml +++ b/app/views/helpers/rss_view.phtml diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 0e09f84df..46ff33b3a 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,120 +1,13 @@ <?php + $output = Request::param ('output', 'normal'); if ($output == 'rss') { - $this->renderHelper ('rss'); + $this->renderHelper ('rss_view'); +} elseif($output == 'reader') { + $this->renderHelper ('reader_view'); +} elseif($output == 'global') { + $this->renderHelper ('global_view'); } else { - $this->partial ('aside_flux'); - $this->partial ('nav_menu'); - - if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { - $items = $this->entryPaginator->items (); -?> - -<div id="stream"> - <?php - $display_today = true; - $display_yesterday = true; - $display_others = true; - ?> - <?php foreach ($items as $item) { ?> - - <?php if ($display_today && $item->isDay (Days::TODAY)) { ?> - <div class="day"><?php echo Translate::t ('today'); ?> - <?php echo timestamptodate (time (), false); ?></div> - <?php $display_today = false; } ?> - <?php if ($display_yesterday && $item->isDay (Days::YESTERDAY)) { ?> - <div class="day"><?php echo Translate::t ('yesterday'); ?> - <?php echo timestamptodate (time () - 86400, false); ?></div> - <?php $display_yesterday = false; } ?> - <?php if ($display_others && $item->isDay (Days::BEFORE_YESTERDAY)) { ?> - <div class="day"><?php echo Translate::t ('before_yesterday'); ?></div> - <?php $display_others = false; } ?> - - <div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>"> - <ul class="horizontal-list flux_header"> - <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> - <li class="item manage"> - <?php if (!$item->isRead ()) { ?> - <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 1); ?>"> </a> - <?php } else { ?> - <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 0); ?>"> </a> - <?php } ?> - - <?php if (!$item->isFavorite ()) { ?> - <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 1); ?>"> </a> - <?php } else { ?> - <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 0); ?>"> </a> - <?php } ?> - </li> - <?php } ?> - <?php $feed = $item->feed (true); ?> - <li class="item website"><a href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"><img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" /> <span><?php echo $feed->name (); ?></span></a></li> - <li class="item title"><?php echo $item->title (); ?></li> - <li class="item date"><?php echo $item->date (); ?></li> - <li class="item link"><a target="_blank" href="<?php echo $item->link (); ?>"> </a></li> - </ul> - - <div class="flux_content"> - <div class="content"> - <h1 class="title"><?php echo $item->title (); ?></h1> - <?php $author = $item->author (); ?> - <?php echo $author != '' ? '<div class="author">' . Translate::t ('by_author', $author) . '</div>' : ''; ?> - <?php echo $item->content (); ?> - </div> - - <ul class="horizontal-list bottom"> - <li class="item"> - <?php if ($item->notes () != '') { ?> - <i class="icon i_note"></i> <a class="note" href="<?php echo _url ('entry', 'note', 'id', $item->id ()); ?>"><?php echo Translate::t ('update_note'); ?></a> - <?php } else { ?> - <i class="icon i_note_empty"></i> <a class="note" href="<?php echo _url ('entry', 'note', 'id', $item->id ()); ?>"><?php echo Translate::t ('add_note'); ?></a> - <?php } ?> - </li> - <li class="item"> - <div class="dropdown"> - <div id="dropdown-share-<?php echo $item->id ();?>" class="dropdown-target"></div> - <i class="icon i_share"></i> <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id ();?>"><?php echo Translate::t ('share'); ?></a> - - <ul class="dropdown-menu"> - <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> - - <li class="item"><a href="mailto:?subject=<?php echo $item->title (); ?>&body=J'ai trouvé cet article intéressant, tu peux le lire à cette adresse : <?php echo urlencode($item->link ()); ?>"><?php echo Translate::t ('by_email'); ?></a></li> - <?php - $shaarli = $this->conf->urlShaarli (); - if ($shaarli) { - ?> - <li class="item"><a target="_blank" href="<?php echo $shaarli . '?post=' . urlencode($item->link ()) . '&title=' . urlencode ($item->title ()) . '&source=bookmarklet'; ?>"><?php echo Translate::t ('on_shaarli'); ?></a></li> - <?php } ?> - </ul> - </div> - </li> - <?php $tags = $item->tags(); ?> - <?php if(!empty($tags)) { ?> - <li class="item"> - <div class="dropdown"> - <div id="dropdown-tags-<?php echo $item->id ();?>" class="dropdown-target"></div> - <i class="icon i_tag"></i> <a class="dropdown-toggle" href="#dropdown-tags-<?php echo $item->id ();?>"><?php echo Translate::t ('related_tags'); ?></a> - - <ul class="dropdown-menu"> - <li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li> - - <?php foreach($tags as $tag) { ?> - <li class="item"><span><?php echo $tag; ?></span></li> - <?php } ?> - </ul> - </div> - </li> - <?php } ?> - </ul> - </div> - </div> - <?php } ?> - - <?php $this->entryPaginator->render ('pagination.phtml', 'next'); ?> -</div> - - <?php } else { ?> -<div class="alert alert-warn"> - <span class="alert-head"><?php echo Translate::t ('no_feed_to_display'); ?></span> -</div> - <?php } ?> -<?php } ?> + $this->renderHelper ('normal_view'); +}
\ No newline at end of file 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 @@ +<div class="post content"> + <a href="<?php echo _url ('index', 'index'); ?>"><?php echo Translate::t ('back_to_rss_feeds'); ?></a> + + <h1><?php echo Translate::t ('logs'); ?></h1> + + <?php $items = $this->logsPaginator->items (); ?> + + <?php if (!empty ($items)) { ?> + <div class="logs"> + <?php $this->logsPaginator->render ('logs_pagination.phtml', 'page'); ?> + + <?php foreach ($items as $log) { ?> + <div class="log <?php echo $log->level (); ?>"><span class="date"><?php echo date ('d/m/Y - H:i:s', strtotime ($log->date ())); ?></span><?php echo $log->info (); ?></div> + <?php } ?> + + <?php $this->logsPaginator->render ('logs_pagination.phtml','page'); ?> + </div> + <?php } else { ?> + <p class="alert alert-warn"><?php echo Translate::t ('logs_empty'); ?></p> + <?php } ?> +</div>
\ No newline at end of file diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index e6c882333..9226efe63 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -9,6 +9,16 @@ var hide_posts = false; $mark = $this->conf->markWhen (); ?> +function is_reader_mode() { + var stream = $("#stream.reader"); + return stream.html() != null; +} + +function is_normal_mode() { + var stream = $("#stream.normal"); + return stream.html() != null; +} + function redirect (url, new_tab) { if (url) { if (new_tab) { @@ -42,19 +52,20 @@ function toggleContent (new_active, old_active) { <?php } ?> } -var load = false; function mark_read (active, only_not_read) { if (active[0] === undefined || ( - only_not_read === true && !active.hasClass("not_read")) || - load === true) { + only_not_read === true && !active.hasClass("not_read"))) { return false; } - load = true; + if (active.hasClass ("not_read")) { + active.removeClass ("not_read"); + } else { + active.addClass ("not_read"); + } url = active.find ("a.read").attr ("href"); if (url === undefined) { - load = false; return false; } @@ -66,27 +77,16 @@ function mark_read (active, only_not_read) { res = jQuery.parseJSON(data); active.find ("a.read").attr ("href", res.url); - if (active.hasClass ("not_read")) { - active.removeClass ("not_read"); - } else { - active.addClass ("not_read"); - } - - load = false; }); } function mark_favorite (active) { - if (active[0] === undefined || - load === true) { + if (active[0] === undefined) { return false; } - load = true; - url = active.find ("a.bookmark").attr ("href"); if (url === undefined) { - load = false; return false; } @@ -103,34 +103,69 @@ function mark_favorite (active) { } else { active.addClass ("favorite"); } - - load = false; }); } +function prev_entry() { + old_active = $(".flux.active"); + last_active = $(".flux:last"); + new_active = old_active.prevAll (".flux:first"); + + if (new_active.hasClass("flux")) { + toggleContent (new_active, old_active); + } else if (old_active[0] === undefined && + new_active[0] === undefined) { + toggleContent (last_active, old_active); + } +} + +function next_entry() { + old_active = $(".flux.active"); + first_active = $(".flux:first"); + new_active = old_active.nextAll (".flux:first"); + + if (new_active.hasClass("flux")) { + toggleContent (new_active, old_active); + } else if (old_active[0] === undefined && + new_active[0] === undefined) { + toggleContent (first_active, old_active); + } +} + function init_img () { - $(".flux .content img").each (function () { - if ($(this).width () > ($("#stream .content").width()) / 2) { + $(".flux_content .content img").each (function () { + if ($(this).width () > ($(".flux_content .content").width()) / 2) { $(this).addClass("big"); } }); } -function init_posts () { - <?php if ($mark['page'] == 'yes') { ?> - if ($(".flux.not_read")[0] != undefined) { - url = $(".nav_menu a.read_all").attr ("href"); - redirect (url, false); - } - <?php } ?> +function inMarkViewport(flux) { + var top = flux.position().top; + var height = flux.height(); + var begin = top + 3 * height / 4; + var bot = top + height; + var windowTop = $(window).scrollTop(); + var windowBot = windowTop + $(window).height(); + + return (windowBot >= begin && windowBot <= bot); +} + +var lastScroll = 0; +function init_posts () { init_img (); + <?php if($this->conf->lazyload() == 'yes') { ?> + $(".flux .content img").lazyload(); + <?php } ?> if (hide_posts) { $(".flux:not(.active) .flux_content").hide (); } - $(".flux_header .item.title, .flux_header .item.date").click (function () { + var flux_header_toggle = $(".flux_header .item.title, .flux_header .item.date"); + flux_header_toggle.unbind('click'); // évite d'associer 2 fois le toggle + flux_header_toggle.click (function () { old_active = $(".flux.active"); new_active = $(this).parent ().parent (); @@ -160,9 +195,32 @@ function init_posts () { mark_read($(this).parent().parent().parent(), true); }); <?php } ?> + + <?php if ($mark['scroll'] == 'yes') { ?> + var flux = $('.flux'); + $(window).scroll(function() { + var windowTop = $(this).scrollTop(); + if(Math.abs(windowTop - lastScroll) <= 50) { + return; + } + lastScroll = windowTop; + + flux.each(function() { + if($(this).hasClass('not_read') && + $(this).children(".flux_content").is(':visible') && + inMarkViewport($(this))) { + mark_read($(this), true); + } + }); + }); + <?php } ?> } function init_column_categories () { + if(!is_normal_mode()) { + return; + } + $(".category").addClass ("stick"); $(".categories .category .btn:first-child").width ("160px"); $(".category").append ("<a class=\"btn dropdown-toggle\" href=\"#\"><i class=\"icon i_down\"></i></a>"); @@ -202,18 +260,7 @@ function init_shortcuts () { }); // Touches de navigation - shortcut.add("<?php echo $s['prev_entry']; ?>", function () { - old_active = $(".flux.active"); - last_active = $(".flux:last"); - new_active = old_active.prevAll (".flux:first"); - - if (new_active.hasClass("flux")) { - toggleContent (new_active, old_active); - } else if (old_active[0] === undefined && - new_active[0] === undefined) { - toggleContent (last_active, old_active); - } - }, { + shortcut.add("<?php echo $s['prev_entry']; ?>", prev_entry, { 'disable_in_input':true }); shortcut.add("shift+<?php echo $s['prev_entry']; ?>", function () { @@ -226,18 +273,7 @@ function init_shortcuts () { }, { 'disable_in_input':true }); - shortcut.add("<?php echo $s['next_entry']; ?>", function () { - old_active = $(".flux.active"); - first_active = $(".flux:first"); - new_active = old_active.nextAll (".flux:first"); - - if (new_active.hasClass("flux")) { - toggleContent (new_active, old_active); - } else if (old_active[0] === undefined && - new_active[0] === undefined) { - toggleContent (first_active, old_active); - } - }, { + shortcut.add("<?php echo $s['next_entry']; ?>", next_entry, { 'disable_in_input':true }); shortcut.add("shift+<?php echo $s['next_entry']; ?>", function () { @@ -277,8 +313,23 @@ function init_shortcuts () { }); } +function init_nav_entries() { + $('.nav_entries a.previous_entry').click(function() { + prev_entry(); + return false; + }); + $('.nav_entries a.next_entry').click(function() { + next_entry(); + return false; + }); +} + $(document).ready (function () { + if(is_reader_mode()) { + hide_posts = false; + } init_posts (); init_column_categories (); init_shortcuts (); + init_nav_entries(); }); |
