Procházet zdrojové kódy

Merge branch 'dev' into 320-template

Marien Fressinaud před 12 roky
rodič
revize
a86a51cca6
100 změnil soubory, kde provedl 3035 přidání a 1502 odebrání
  1. 32 0
      CHANGELOG
  2. 3 2
      README.md
  3. 36 89
      app/Controllers/configureController.php
  4. 6 1
      app/Controllers/entryController.php
  5. 57 94
      app/Controllers/feedController.php
  6. 390 0
      app/Controllers/importExportController.php
  7. 37 11
      app/Controllers/indexController.php
  8. 19 1
      app/Controllers/usersController.php
  9. 0 6
      app/Exceptions/OpmlException.php
  10. 16 3
      app/Models/CategoryDAO.php
  11. 44 33
      app/Models/Configuration.php
  12. 5 0
      app/Models/Entry.php
  13. 231 55
      app/Models/EntryDAO.php
  14. 8 7
      app/Models/Feed.php
  15. 51 5
      app/Models/FeedDAO.php
  16. 44 0
      app/Models/Share.php
  17. 2 0
      app/Models/Themes.php
  18. 0 1
      app/actualize_script.php
  19. 22 8
      app/i18n/en.php
  20. 21 7
      app/i18n/fr.php
  21. 4 1
      app/layout/aside_configure.phtml
  22. 14 3
      app/layout/aside_feed.phtml
  23. 2 2
      app/layout/aside_flux.phtml
  24. 3 2
      app/layout/header.phtml
  25. 19 11
      app/layout/layout.phtml
  26. 108 84
      app/layout/nav_menu.phtml
  27. 2 2
      app/views/configure/categorize.phtml
  28. 2 116
      app/views/configure/display.phtml
  29. 0 40
      app/views/configure/importExport.phtml
  30. 125 0
      app/views/configure/reading.phtml
  31. 31 44
      app/views/configure/sharing.phtml
  32. 8 1
      app/views/configure/shortcut.phtml
  33. 36 3
      app/views/configure/users.phtml
  34. 91 0
      app/views/feed/add.phtml
  35. 47 0
      app/views/helpers/export/articles.phtml
  36. 28 0
      app/views/helpers/export/opml.phtml
  37. 5 2
      app/views/helpers/javascript_vars.phtml
  38. 12 65
      app/views/helpers/view/normal_view.phtml
  39. 1 1
      app/views/helpers/view/rss_view.phtml
  40. 52 0
      app/views/importExport/index.phtml
  41. 4 2
      app/views/index/index.phtml
  42. 3 0
      constants.php
  43. 75 0
      data/shares.php
  44. 1 5
      lib/Minz/ActionController.php
  45. 0 116
      lib/Minz/Cache.php
  46. 29 31
      lib/Minz/Configuration.php
  47. 38 70
      lib/Minz/Dispatcher.php
  48. 24 8
      lib/Minz/Error.php
  49. 33 26
      lib/Minz/FrontController.php
  50. 17 0
      lib/Minz/Log.php
  51. 1 4
      lib/Minz/Request.php
  52. 0 60
      lib/Minz/Response.php
  53. 0 16
      lib/Minz/RouteNotFoundException.php
  54. 0 209
      lib/Minz/Router.php
  55. 4 11
      lib/Minz/Url.php
  56. 10 0
      lib/Minz/View.php
  57. 31 7
      lib/SimplePie/SimplePie.php
  58. 1 1
      lib/SimplePie/SimplePie/Author.php
  59. 1 1
      lib/SimplePie/SimplePie/Cache.php
  60. 1 1
      lib/SimplePie/SimplePie/Cache/Base.php
  61. 1 1
      lib/SimplePie/SimplePie/Cache/DB.php
  62. 1 1
      lib/SimplePie/SimplePie/Cache/File.php
  63. 5 7
      lib/SimplePie/SimplePie/Cache/Memcache.php
  64. 4 3
      lib/SimplePie/SimplePie/Cache/MySQL.php
  65. 1 1
      lib/SimplePie/SimplePie/Caption.php
  66. 1 1
      lib/SimplePie/SimplePie/Category.php
  67. 1 1
      lib/SimplePie/SimplePie/Content/Type/Sniffer.php
  68. 1 1
      lib/SimplePie/SimplePie/Copyright.php
  69. 1 1
      lib/SimplePie/SimplePie/Core.php
  70. 1 1
      lib/SimplePie/SimplePie/Credit.php
  71. 1 1
      lib/SimplePie/SimplePie/Decode/HTML/Entities.php
  72. 2 2
      lib/SimplePie/SimplePie/Enclosure.php
  73. 3 3
      lib/SimplePie/SimplePie/File.php
  74. 1 1
      lib/SimplePie/SimplePie/HTTP/Parser.php
  75. 1 1
      lib/SimplePie/SimplePie/IRI.php
  76. 3 3
      lib/SimplePie/SimplePie/Item.php
  77. 2 2
      lib/SimplePie/SimplePie/Locator.php
  78. 20 3
      lib/SimplePie/SimplePie/Misc.php
  79. 1 1
      lib/SimplePie/SimplePie/Net/IPv6.php
  80. 1 1
      lib/SimplePie/SimplePie/Parse/Date.php
  81. 1 1
      lib/SimplePie/SimplePie/Parser.php
  82. 1 1
      lib/SimplePie/SimplePie/Rating.php
  83. 1 1
      lib/SimplePie/SimplePie/Registry.php
  84. 1 1
      lib/SimplePie/SimplePie/Restriction.php
  85. 6 2
      lib/SimplePie/SimplePie/Sanitize.php
  86. 1 1
      lib/SimplePie/SimplePie/Source.php
  87. 1 1
      lib/SimplePie/SimplePie/XML/Declaration/Parser.php
  88. 1 1
      lib/SimplePie/SimplePie/gzdecode.php
  89. 194 83
      lib/lib_opml.php
  90. 17 2
      lib/lib_rss.php
  91. 4 0
      p/api/.htaccess
  92. 646 0
      p/api/greader.php
  93. 20 0
      p/api/index.html
  94. 1 1
      p/i/index.php
  95. 5 3
      p/i/install.php
  96. 0 1
      p/scripts/jquery.min.js
  97. 135 64
      p/scripts/main.js
  98. 32 21
      p/themes/Dark/freshrss.css
  99. 0 6
      p/themes/Dark/global.css
  100. 29 8
      p/themes/Flat/freshrss.css

+ 32 - 0
CHANGELOG

@@ -2,8 +2,40 @@
 
 ## 2014-0x-xx FreshRSS 0.8
 
+* API compatible with Google Reader API level 2
+	* FreshRSS can now be used from e.g.:
+		* (Android) News+ https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus.extension.google_reader
+		* (Android) EasyRSS https://github.com/Alkarex/EasyRSS
+
+
+## 2014-02-19 FreshRSS 0.7.1
+
 * Mise à jour des flux plus rapide grâce à une meilleure utilisation du cache
 	* Utilisation d’une signature MD5 du contenu intéressant pour les flux n’implémentant pas les requêtes conditionnelles
+* Modification des raccourcis
+	* "s" partage directement si un seul moyen de partage
+	* Moyens de partage accessibles par "1", "2", "3", etc.
+	* Premier article : Home ; Dernier article : End
+	* Ajout du déplacement au sein des catégories / flux (via modificateurs shift et alt)
+* UI
+	* Séparation des descriptions des raccourcis par groupes
+	* Revue rapide de la page de connexion
+	* Amélioration de l'affichage des notifications sur mobile
+* Revue du système de rafraîchissement des flux
+	* Meilleure gestion de la file de flux à rafraîchir en JSON
+	* Rafraîchissement uniquement pour les flux non rafraîchis récemment
+	* Possibilité donnée aux anonymes de rafraîchir les flux
+* SimplePie
+	* Mise à jour de la lib
+	* Corrige fuite de mémoire
+	* Meilleure tolérance aux flux invalides
+* Corrections divers
+	* Ne déplie plus l'article lors du clic sur l'icône lien externe
+	* Ne boucle plus à la fin de la navigation dans les articles
+	* Suppression du champ category.color inutile
+	* Corrige bug redirection infinie (Persona)
+	* Amélioration vérification de la requête POST
+	* Ajout d'un verrou lorsqu'une action mark_read ou mark_favorite est en cours
 
 
 ## 2014-01-29 FreshRSS 0.7

+ 3 - 2
README.md

@@ -27,7 +27,7 @@ Privilégiez pour cela des demandes sur GitHub
 * Serveur Web Apache2 ou Nginx (non testé sur les autres)
 * PHP 5.2.1+ (PHP 5.3.7+ recommandé)
 	* Requis : [PDO_MySQL](http://php.net/pdo-mysql), [cURL](http://php.net/curl), [LibXML](http://php.net/xml), [PCRE](http://php.net/pcre), [ctype](http://php.net/ctype)
-	* Recommandés : [JSON](http://php.net/json), [zlib](http://php.net/zlib), [mbstring](http://php.net/mbstring), [iconv](http://php.net/iconv)
+	* Recommandés : [JSON](http://php.net/json), [zlib](http://php.net/zlib), [mbstring](http://php.net/mbstring), [iconv](http://php.net/iconv), [Zip](http://php.net/zip)
 * MySQL 5.0.3+ (ou SQLite 3.7.4+ à venir)
 * Un navigateur Web récent tel Firefox 4+, Chrome, Opera, Safari, Internet Explorer 9+
 	* Fonctionne aussi sur mobile
@@ -42,7 +42,8 @@ Privilégiez pour cela des demandes sur GitHub
 5. Tout devrait fonctionner :) En cas de problème, n’hésitez pas à me contacter.
 
 # Contrôle d’accès
-Il est requis pour le mode multi-utilisateur, et recommandé dans tous les cas, de limiter l’accès à votre FreshRSS :
+Il est requis pour le mode multi-utilisateur, et recommandé dans tous les cas, de limiter l’accès à votre FreshRSS. Au choix :
+* En utilisant l’identification par formulaire (requiert JavaScript, et PHP 5.3.7+ recommandé – fonctionne avec certaines versions de PHP 5.3.3+)
 * En utilisant l’identification par [Mozilla Persona](https://login.persona.org/about) incluse dans FreshRSS
 * En utilisant un contrôle d’accès HTTP défini par votre serveur Web
 	* Voir par exemple la [documentation d’Apache sur l’authentification](http://httpd.apache.org/docs/trunk/howto/auth.html)

+ 36 - 89
app/Controllers/configureController.php

@@ -44,7 +44,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 					'name' => $cat->name (),
 				);
 
-				if ($catDAO->searchByName ($newCat) == false) {
+				if ($catDAO->searchByName ($newCat) == null) {
 					$catDAO->addCategory ($values);
 				}
 			}
@@ -62,7 +62,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 		$this->view->categories = $catDAO->listCategories (false);
 		$this->view->defaultCategory = $catDAO->getDefault ();
 		$this->view->feeds = $feedDAO->listFeeds ();
-		$this->view->flux = false;
 
 		Minz_View::prependTitle (Minz_Translate::t ('categories_management') . ' · ');
 	}
@@ -141,20 +140,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 	public function displayAction () {
 		if (Minz_Request::isPost()) {
 			$this->view->conf->_language(Minz_Request::param('language', 'en'));
-			$this->view->conf->_posts_per_page(Minz_Request::param('posts_per_page', 10));
-			$this->view->conf->_view_mode(Minz_Request::param('view_mode', 'normal'));
-			$this->view->conf->_default_view (Minz_Request::param('default_view', 'a'));
-			$this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false));
-			$this->view->conf->_display_posts(Minz_Request::param('display_posts', false));
-			$this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false));
-			$this->view->conf->_lazyload (Minz_Request::param('lazyload', false));
-			$this->view->conf->_sort_order(Minz_Request::param('sort_order', 'DESC'));
-			$this->view->conf->_mark_when (array(
-				'article' => Minz_Request::param('mark_open_article', false),
-				'site' => Minz_Request::param('mark_open_site', false),
-				'scroll' => Minz_Request::param('mark_scroll', false),
-				'reception' => Minz_Request::param('mark_upon_reception', false),
-			));
 			$themeId = Minz_Request::param('theme', '');
 			if ($themeId == '') {
 				$themeId = FreshRSS_Themes::defaultTheme;
@@ -187,22 +172,30 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 
 		$this->view->themes = FreshRSS_Themes::get();
 
-		Minz_View::prependTitle (Minz_Translate::t ('reading_configuration') . ' · ');
+		Minz_View::prependTitle (Minz_Translate::t ('display_configuration') . ' · ');
 	}
 
-	public function sharingAction () {
-		if (Minz_Request::isPost ()) {
-			$this->view->conf->_sharing (array(
-				'shaarli' => Minz_Request::param ('shaarli', false),
-				'wallabag' => Minz_Request::param ('wallabag', false),
-				'diaspora' => Minz_Request::param ('diaspora', false),
-				'twitter' => Minz_Request::param ('twitter', false),
-				'g+' => Minz_Request::param ('g+', false),
-				'facebook' => Minz_Request::param ('facebook', false),
-				'email' => Minz_Request::param ('email', false),
-				'print' => Minz_Request::param ('print', false),
+	public function readingAction () {
+		if (Minz_Request::isPost()) {
+			$this->view->conf->_posts_per_page(Minz_Request::param('posts_per_page', 10));
+			$this->view->conf->_view_mode(Minz_Request::param('view_mode', 'normal'));
+			$this->view->conf->_default_view (Minz_Request::param('default_view', 'a'));
+			$this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false));
+			$this->view->conf->_display_posts(Minz_Request::param('display_posts', false));
+			$this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false));
+			$this->view->conf->_lazyload (Minz_Request::param('lazyload', false));
+			$this->view->conf->_sticky_post (Minz_Request::param('sticky_post', false));
+			$this->view->conf->_sort_order(Minz_Request::param('sort_order', 'DESC'));
+			$this->view->conf->_mark_when (array(
+				'article' => Minz_Request::param('mark_open_article', false),
+				'site' => Minz_Request::param('mark_open_site', false),
+				'scroll' => Minz_Request::param('mark_scroll', false),
+				'reception' => Minz_Request::param('mark_upon_reception', false),
 			));
 			$this->view->conf->save();
+
+			Minz_Session::_param ('language', $this->view->conf->language);
+			Minz_Translate::reset ();
 			invalidateHttpCache();
 
 			$notif = array (
@@ -211,75 +204,29 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 			);
 			Minz_Session::_param ('notification', $notif);
 
-			Minz_Request::forward (array ('c' => 'configure', 'a' => 'sharing'), true);
+			Minz_Request::forward (array ('c' => 'configure', 'a' => 'reading'), true);
 		}
 
-		Minz_View::prependTitle (Minz_Translate::t ('sharing') . ' · ');
+		Minz_View::prependTitle (Minz_Translate::t ('reading_configuration') . ' · ');
 	}
 
-	public function importExportAction () {
-		require_once(LIB_PATH . '/lib_opml.php');
-		$catDAO = new FreshRSS_CategoryDAO ();
-		$this->view->categories = $catDAO->listCategories ();
-
-		$this->view->req = Minz_Request::param ('q');
-
-		if ($this->view->req == 'export') {
-			Minz_View::_title ('freshrss_feeds.opml');
-
-			$this->view->_useLayout (false);
-			header('Content-Type: application/xml; charset=utf-8');
-			header('Content-disposition: attachment; filename=freshrss_feeds.opml');
-
-			$feedDAO = new FreshRSS_FeedDAO ();
-			$catDAO = new FreshRSS_CategoryDAO ();
-
-			$list = array ();
-			foreach ($catDAO->listCategories () as $key => $cat) {
-				$list[$key]['name'] = $cat->name ();
-				$list[$key]['feeds'] = $feedDAO->listByCategory ($cat->id ());
-			}
-
-			$this->view->categories = $list;
-		} elseif ($this->view->req == 'import' && Minz_Request::isPost ()) {
-			if ($_FILES['file']['error'] == 0) {
-				invalidateHttpCache();
-				// on parse le fichier OPML pour récupérer les catégories et les flux associés
-				try {
-					list ($categories, $feeds) = opml_import (
-						file_get_contents ($_FILES['file']['tmp_name'])
-					);
+	public function sharingAction () {
+		if (Minz_Request::isPost ()) {
+			$params = Minz_Request::params();
+			$this->view->conf->_sharing ($params['share']);
+			$this->view->conf->save();
+			invalidateHttpCache();
 
-					// 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
-					Minz_Request::_param ('q', 'null');
-					Minz_Request::_param ('categories', $categories);
-					Minz_Request::_param ('feeds', $feeds);
-					Minz_Request::forward (array ('c' => 'feed', 'a' => 'massiveImport'));
-				} catch (FreshRSS_Opml_Exception $e) {
-					Minz_Log::record ($e->getMessage (), Minz_Log::WARNING);
-
-					$notif = array (
-						'type' => 'bad',
-						'content' => Minz_Translate::t ('bad_opml_file')
-					);
-					Minz_Session::_param ('notification', $notif);
+			$notif = array (
+				'type' => 'good',
+				'content' => Minz_Translate::t ('configuration_updated')
+			);
+			Minz_Session::_param ('notification', $notif);
 
-					Minz_Request::forward (array (
-						'c' => 'configure',
-						'a' => 'importExport'
-					), true);
-				}
-			}
+			Minz_Request::forward (array ('c' => 'configure', 'a' => 'sharing'), true);
 		}
 
-		$feedDAO = new FreshRSS_FeedDAO ();
-		$this->view->feeds = $feedDAO->listFeeds ();
-
-		// au niveau de la vue, permet de ne pas voir un flux sélectionné dans la liste
-		$this->view->flux = false;
-
-		Minz_View::prependTitle (Minz_Translate::t ('import_export_opml') . ' · ');
+		Minz_View::prependTitle (Minz_Translate::t ('sharing') . ' · ');
 	}
 
 	public function shortcutAction () {

+ 6 - 1
app/Controllers/entryController.php

@@ -100,6 +100,9 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
 			$entryDAO = new FreshRSS_EntryDAO();
 			$entryDAO->optimizeTable();
 
+			$feedDAO = new FreshRSS_FeedDAO();
+			$feedDAO->updateCachedValues();
+
 			invalidateHttpCache();
 
 			$notif = array (
@@ -137,11 +140,13 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
 				if ($nb > 0) {
 					$nbTotal += $nb;
 					Minz_Log::record($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG);
-					$feedDAO->updateLastUpdate($feed->id());
+					//$feedDAO->updateLastUpdate($feed->id());
 				}
 			}
 		}
 
+		$feedDAO->updateCachedValues();
+
 		invalidateHttpCache();
 
 		$notif = array(

+ 57 - 94
app/Controllers/feedController.php

@@ -22,14 +22,32 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 	}
 
 	public function addAction () {
-		@set_time_limit(300);
+		$url = Minz_Request::param('url_rss', false);
+
+		if ($url === false) {
+			Minz_Request::forward(array(
+				'c' => 'configure',
+				'a' => 'feed'
+			), true);
+		}
+
+		$feedDAO = new FreshRSS_FeedDAO ();
+		$this->catDAO = new FreshRSS_CategoryDAO ();
+		$this->catDAO->checkDefault ();
+
+		if (Minz_Request::isPost()) {
+			@set_time_limit(300);
 
-		if (Minz_Request::isPost ()) {
-			$this->catDAO = new FreshRSS_CategoryDAO ();
-			$this->catDAO->checkDefault ();
 
-			$url = Minz_Request::param ('url_rss');
 			$cat = Minz_Request::param ('category', false);
+			if ($cat === 'nc') {
+				$new_cat = Minz_Request::param ('new_category');
+				if (empty($new_cat['name'])) {
+					$cat = false;
+				} else {
+					$cat = $this->catDAO->addCategory($new_cat);
+				}
+			}
 			if ($cat === false) {
 				$def_cat = $this->catDAO->getDefault ();
 				$cat = $def_cat->id ();
@@ -52,7 +70,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 
 				$feed->load(true);
 
-				$feedDAO = new FreshRSS_FeedDAO ();
 				$values = array (
 					'url' => $feed->url (),
 					'category' => $feed->category (),
@@ -128,7 +145,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 				Minz_Log::record ($e->getMessage (), Minz_Log::WARNING);
 				$notif = array (
 					'type' => 'bad',
-					'content' => Minz_Translate::t ('internal_problem_feed')
+					'content' => Minz_Translate::t ('internal_problem_feed', Minz_Url::display(array('a' => 'logs')))
 				);
 				Minz_Session::_param ('notification', $notif);
 			} catch (Minz_FileNotExistException $e) {
@@ -136,7 +153,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 				$notif = array (
 					'type' => 'bad',
-					'content' => Minz_Translate::t ('internal_problem_feed')
+					'content' => Minz_Translate::t ('internal_problem_feed', Minz_Url::display(array('a' => 'logs')))
 				);
 				Minz_Session::_param ('notification', $notif);
 			}
@@ -146,6 +163,38 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 
 			Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true);
 		}
+
+		// GET request so we must ask confirmation to user
+		Minz_View::prependTitle(Minz_Translate::t('add_rss_feed') . ' · ');
+		$this->view->categories = $this->catDAO->listCategories();
+		$this->view->feed = new FreshRSS_Feed($url);
+		try {
+			// We try to get some more information about the feed
+			$this->view->feed->load(true);
+			$this->view->load_ok = true;
+		} catch (Exception $e) {
+			$this->view->load_ok = false;
+		}
+
+		$feed = $feedDAO->searchByUrl($this->view->feed->url());
+		if ($feed) {
+			// Already subscribe so we redirect to the feed configuration page
+			$notif = array(
+				'type' => 'bad',
+				'content' => Minz_Translate::t(
+					'already_subscribed', $feed->name()
+				)
+			);
+			Minz_Session::_param('notification', $notif);
+
+			Minz_Request::forward(array(
+				'c' => 'configure',
+				'a' => 'feed',
+				'params' => array(
+					'id' => $feed->id()
+				)
+			), true);
+		}
 	}
 
 	public function truncateAction () {
@@ -319,80 +368,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 		}
 	}
 
-	public function massiveImportAction () {
-		@set_time_limit(300);
-
-		$this->catDAO = new FreshRSS_CategoryDAO ();
-		$this->catDAO->checkDefault ();
-
-		$entryDAO = new FreshRSS_EntryDAO ();
-		$feedDAO = new FreshRSS_FeedDAO ();
-
-		$categories = Minz_Request::param ('categories', array (), true);
-		$feeds = Minz_Request::param ('feeds', array (), true);
-
-		// on ajoute les catégories en masse dans une fonction à part
-		$this->addCategories ($categories);
-
-		// on calcule la date des articles les plus anciens qu'on accepte
-		$nb_month_old = $this->view->conf->old_entries;
-		$date_min = time () - (3600 * 24 * 30 * $nb_month_old);
-
-		// la variable $error permet de savoir si une erreur est survenue
-		// Le but est de ne pas arrêter l'import même en cas d'erreur
-		// L'utilisateur sera mis au courant s'il y a eu des erreurs, mais
-		// ne connaîtra pas les détails. Ceux-ci seront toutefois logguées
-		$error = false;
-		$i = 0;
-		foreach ($feeds as $feed) {
-			try {
-				$values = array (
-					'id' => $feed->id (),
-					'url' => $feed->url (),
-					'category' => $feed->category (),
-					'name' => $feed->name (),
-					'website' => $feed->website (),
-					'description' => $feed->description (),
-					'lastUpdate' => 0,
-					'httpAuth' => $feed->httpAuth ()
-				);
-
-				// ajout du flux que s'il n'est pas déjà en BDD
-				if (!$feedDAO->searchByUrl ($values['url'])) {
-					$id = $feedDAO->addFeed ($values);
-					if ($id) {
-						$feed->_id ($id);
-						$feed->faviconPrepare();
-					} else {
-						$error = true;
-					}
-				}
-			} catch (FreshRSS_Feed_Exception $e) {
-				$error = true;
-				Minz_Log::record ($e->getMessage (), Minz_Log::WARNING);
-			}
-		}
-
-		if ($error) {
-			$res = Minz_Translate::t ('feeds_imported_with_errors');
-		} else {
-			$res = Minz_Translate::t ('feeds_imported');
-		}
-
-		$notif = array (
-			'type' => 'good',
-			'content' => $res
-		);
-		Minz_Session::_param ('notification', $notif);
-		Minz_Session::_param ('actualize_feeds', true);
-
-		// et on redirige vers la page d'accueil
-		Minz_Request::forward (array (
-			'c' => 'index',
-			'a' => 'index'
-		), true);
-	}
-
 	public function deleteAction () {
 		if (Minz_Request::isPost ()) {
 			$type = Minz_Request::param ('type', 'feed');
@@ -436,16 +411,4 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 			}
 		}
 	}
-
-	private function addCategories ($categories) {
-		foreach ($categories as $cat) {
-			if (!$this->catDAO->searchByName ($cat->name ())) {
-				$values = array (
-					'id' => $cat->id (),
-					'name' => $cat->name (),
-				);
-				$catDAO->addCategory ($values);
-			}
-		}
-	}
 }

+ 390 - 0
app/Controllers/importExportController.php

@@ -0,0 +1,390 @@
+<?php
+
+class FreshRSS_importExport_Controller extends Minz_ActionController {
+	public function firstAction() {
+		if (!$this->view->loginOk) {
+			Minz_Error::error(
+				403,
+				array('error' => array(Minz_Translate::t('access_denied')))
+			);
+		}
+
+		require_once(LIB_PATH . '/lib_opml.php');
+
+		$this->catDAO = new FreshRSS_CategoryDAO();
+		$this->entryDAO = new FreshRSS_EntryDAO();
+		$this->feedDAO = new FreshRSS_FeedDAO();
+	}
+
+	public function indexAction() {
+		$this->view->categories = $this->catDAO->listCategories();
+		$this->view->feeds = $this->feedDAO->listFeeds();
+
+		Minz_View::prependTitle(Minz_Translate::t('import_export') . ' · ');
+	}
+
+	public function importAction() {
+		if (Minz_Request::isPost() && $_FILES['file']['error'] == 0) {
+			@set_time_limit(300);
+
+			$file = $_FILES['file'];
+			$type_file = $this->guessFileType($file['name']);
+
+			$list_files = array(
+				'opml' => array(),
+				'json_starred' => array(),
+				'json_feed' => array()
+			);
+
+			// We try to list all files according to their type
+			// A zip file is first opened and then its files are listed
+			$list = array();
+			if ($type_file === 'zip') {
+				$zip = zip_open($file['tmp_name']);
+
+				while (($zipfile = zip_read($zip)) !== false) {
+					$type_zipfile = $this->guessFileType(
+						zip_entry_name($zipfile)
+					);
+
+					if ($type_file !== 'unknown') {
+						$list_files[$type_zipfile][] = zip_entry_read(
+							$zipfile,
+							zip_entry_filesize($zipfile)
+						);
+					}
+				}
+
+				zip_close($zip);
+			} elseif ($type_file !== 'unknown') {
+				$list_files[$type_file][] = file_get_contents(
+					$file['tmp_name']
+				);
+			}
+
+			// Import different files.
+			// OPML first(so categories and feeds are imported)
+			// Starred articles then so the "favourite" status is already set
+			// And finally all other files.
+			$error = false;
+			foreach ($list_files['opml'] as $opml_file) {
+				$error = $this->importOpml($opml_file);
+			}
+			foreach ($list_files['json_starred'] as $article_file) {
+				$error = $this->importArticles($article_file, true);
+			}
+			foreach ($list_files['json_feed'] as $article_file) {
+				$error = $this->importArticles($article_file);
+			}
+
+			// And finally, we get import status and redirect to the home page
+			$notif = null;
+			if ($error === true) {
+				$content_notif = Minz_Translate::t(
+					'feeds_imported_with_errors'
+				);
+			} else {
+				$content_notif = Minz_Translate::t(
+					'feeds_imported'
+				);
+			}
+
+			Minz_Session::_param('notification', array(
+				'type' => 'good',
+				'content' => $content_notif
+			));
+			Minz_Session::_param('actualize_feeds', true);
+
+			Minz_Request::forward(array(
+				'c' => 'index',
+				'a' => 'index'
+			), true);
+		}
+
+		// What are you doing? you have to call this controller
+		// with a POST request!
+		Minz_Request::forward(array(
+			'c' => 'importExport',
+			'a' => 'index'
+		));
+	}
+
+	private function guessFileType($filename) {
+		// A *very* basic guess file type function. Only based on filename
+		// That's could be improved but should be enough, at least for a first
+		// implementation.
+		// TODO: improve this function?
+
+		if (substr_compare($filename, '.zip', -4) === 0) {
+			return 'zip';
+		} elseif (substr_compare($filename, '.opml', -5) === 0 ||
+		          substr_compare($filename, '.xml', -4) === 0) {
+			return 'opml';
+		} elseif (strcmp($filename, 'starred.json') === 0) {
+			return 'json_starred';
+		} elseif (substr_compare($filename, '.json', -5) === 0 &&
+		          strpos($filename, 'feed_') === 0) {
+			return 'json_feed';
+		} else {
+			return 'unknown';
+		}
+	}
+
+	private function importOpml($opml_file) {
+		$opml_array = array();
+		try {
+			$opml_array = libopml_parse_string($opml_file);
+		} catch (LibOPML_Exception $e) {
+			Minz_Log::warning($e->getMessage());
+			return true;
+		}
+
+		$this->catDAO->checkDefault();
+
+		return $this->addOpmlElements($opml_array['body']);
+	}
+
+	private function addOpmlElements($opml_elements, $parent_cat = null) {
+		$error = false;
+		foreach ($opml_elements as $elt) {
+			$res = false;
+			if (isset($elt['xmlUrl'])) {
+				$res = $this->addFeedOpml($elt, $parent_cat);
+			} else {
+				$res = $this->addCategoryOpml($elt, $parent_cat);
+			}
+
+			if (!$error && $res) {
+				// oops: there is at least one error!
+				$error = $res;
+			}
+		}
+
+		return $error;
+	}
+
+	private function addFeedOpml($feed_elt, $parent_cat) {
+		if (is_null($parent_cat)) {
+			// This feed has no parent category so we get the default one
+			$parent_cat = $this->catDAO->getDefault()->name();
+		}
+
+		$cat = $this->catDAO->searchByName($parent_cat);
+
+		if (!$cat) {
+			return true;
+		}
+
+		// We get different useful information
+		$url = html_chars_utf8($feed_elt['xmlUrl']);
+		$name = html_chars_utf8($feed_elt['text']);
+		$website = '';
+		if (isset($feed_elt['htmlUrl'])) {
+			$website = html_chars_utf8($feed_elt['htmlUrl']);
+		}
+		$description = '';
+		if (isset($feed_elt['description'])) {
+			$description = html_chars_utf8($feed_elt['description']);
+		}
+
+		$error = false;
+		try {
+			// Create a Feed object and add it in DB
+			$feed = new FreshRSS_Feed($url);
+			$feed->_category($cat->id());
+			$feed->_name($name);
+			$feed->_website($website);
+			$feed->_description($description);
+
+			// addFeedObject checks if feed is already in DB so nothing else to
+			// check here
+			$id = $this->feedDAO->addFeedObject($feed);
+			$error = ($id === false);
+		} catch (FreshRSS_Feed_Exception $e) {
+			Minz_Log::warning($e->getMessage());
+			$error = true;
+		}
+
+		return $error;
+	}
+
+	private function addCategoryOpml($cat_elt, $parent_cat) {
+		// Create a new Category object
+		$cat = new FreshRSS_Category(html_chars_utf8($cat_elt['text']));
+
+		$id = $this->catDAO->addCategoryObject($cat);
+		$error = ($id === false);
+
+		if (isset($cat_elt['@outlines'])) {
+			// Our cat_elt contains more categories or more feeds, so we
+			// add them recursively.
+			// Note: FreshRSS does not support yet category arborescence
+			$res = $this->addOpmlElements($cat_elt['@outlines'], $cat->name());
+			if (!$error && $res) {
+				$error = true;
+			}
+		}
+
+		return $error;
+	}
+
+	private function importArticles($article_file, $starred = false) {
+		$article_object = json_decode($article_file, true);
+		if (is_null($article_object)) {
+			Minz_Log::warning('Try to import a non-JSON file');
+			return true;
+		}
+
+		$is_read = $this->view->conf->mark_when['reception'] ? 1 : 0;
+
+		$google_compliant = (
+			strpos($article_object['id'], 'com.google') !== false
+		);
+
+		$error = false;
+		foreach ($article_object['items'] as $item) {
+			$feed = $this->addFeedArticles($item['origin'], $google_compliant);
+			if (is_null($feed)) {
+				$error = true;
+				continue;
+			}
+
+			$author = isset($item['author']) ? $item['author'] : '';
+			$key_content = ($google_compliant && !isset($item['content'])) ?
+			               'summary' : 'content';
+			$tags = $item['categories'];
+			if ($google_compliant) {
+				$tags = array_filter($tags, function($var) {
+					return strpos($var, '/state/com.google') === false;
+				});
+			}
+
+			$entry = new FreshRSS_Entry(
+				$feed->id(), $item['id'], $item['title'], $author,
+				$item[$key_content]['content'], $item['alternate'][0]['href'],
+				$item['published'], $is_read, $starred
+			);
+			$entry->_tags($tags);
+
+			$id = $this->entryDAO->addEntryObject(
+				$entry, $this->view->conf, $feed->keepHistory()
+			);
+
+			if (!$error && ($id === false)) {
+				$error = true;
+			}
+		}
+
+		return $error;
+	}
+
+	private function addFeedArticles($origin, $google_compliant) {
+		$default_cat = $this->catDAO->getDefault();
+
+		$return = null;
+		$key = $google_compliant ? 'htmlUrl' : 'feedUrl';
+		$url = $origin[$key];
+		$name = $origin['title'];
+		$website = $origin['htmlUrl'];
+		$error = false;
+		try {
+			// Create a Feed object and add it in DB
+			$feed = new FreshRSS_Feed($url);
+			$feed->_category($default_cat->id());
+			$feed->_name($name);
+			$feed->_website($website);
+
+			// addFeedObject checks if feed is already in DB so nothing else to
+			// check here
+			$id = $this->feedDAO->addFeedObject($feed);
+
+			if ($id !== false) {
+				$feed->_id($id);
+				$return = $feed;
+			}
+		} catch (FreshRSS_Feed_Exception $e) {
+			Minz_Log::warning($e->getMessage());
+		}
+
+		return $return;
+	}
+
+	public function exportAction() {
+		if (Minz_Request::isPost()) {
+			$this->view->_useLayout(false);
+
+			$export_opml = Minz_Request::param('export_opml', false);
+			$export_starred = Minz_Request::param('export_starred', false);
+			$export_feeds = Minz_Request::param('export_feeds', false);
+
+			// From https://stackoverflow.com/questions/1061710/php-zip-files-on-the-fly
+			$file = tempnam('tmp', 'zip');
+			$zip = new ZipArchive();
+			$zip->open($file, ZipArchive::OVERWRITE);
+
+			// Stuff with content
+			if ($export_opml) {
+				$zip->addFromString(
+					'feeds.opml', $this->generateOpml()
+				);
+			}
+			if ($export_starred) {
+				$zip->addFromString(
+					'starred.json', $this->generateArticles('starred')
+				);
+			}
+			foreach ($export_feeds as $feed_id) {
+				$feed = $this->feedDAO->searchById($feed_id);
+				$zip->addFromString(
+					'feed_' . $feed->category() . '_' . $feed->id() . '.json',
+					$this->generateArticles('feed', $feed)
+				);
+			}
+
+			// Close and send to user
+			$zip->close();
+			header('Content-Type: application/zip');
+			header('Content-Length: ' . filesize($file));
+			header('Content-Disposition: attachment; filename="freshrss_export.zip"');
+			readfile($file);
+			unlink($file);
+		}
+	}
+
+	private function generateOpml() {
+		$list = array();
+		foreach ($this->catDAO->listCategories() as $key => $cat) {
+			$list[$key]['name'] = $cat->name();
+			$list[$key]['feeds'] = $this->feedDAO->listByCategory($cat->id());
+		}
+
+		$this->view->categories = $list;
+		return $this->view->helperToString('export/opml');
+	}
+
+	private function generateArticles($type, $feed = NULL) {
+		$this->view->categories = $this->catDAO->listCategories();
+
+		if ($type == 'starred') {
+			$this->view->list_title = Minz_Translate::t('starred_list');
+			$this->view->type = 'starred';
+			$unread_fav = $this->entryDAO->countUnreadReadFavorites();
+			$this->view->entries = $this->entryDAO->listWhere(
+				's', '', FreshRSS_Entry::STATE_ALL, 'ASC',
+				$unread_fav['all']
+			);
+		} elseif ($type == 'feed' && !is_null($feed)) {
+			$this->view->list_title = Minz_Translate::t(
+				'feed_list', $feed->name()
+			);
+			$this->view->type = 'feed/' . $feed->id();
+			$this->view->entries = $this->entryDAO->listWhere(
+				'f', $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC',
+				$this->view->conf->posts_per_page
+			);
+			$this->view->feed = $feed;
+		}
+
+		return $this->view->helperToString('export/articles');
+	}
+}

+ 37 - 11
app/Controllers/indexController.php

@@ -25,16 +25,14 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 			}
 		}
 
-		// construction of RSS url of this feed
 		$params = Minz_Request::params ();
-		$params['output'] = 'rss';
 		if (isset ($params['search'])) {
 			$params['search'] = urlencode ($params['search']);
 		}
 		if (!Minz_Configuration::allowAnonymous()) {
 			$params['token'] = $token;
 		}
-		$this->view->rss_url = array (
+		$this->view->url = array (
 			'c' => 'index',
 			'a' => 'index',
 			'params' => $params
@@ -84,20 +82,22 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 
 		// On récupère les différents éléments de filtrage
 		$this->view->state = $state = Minz_Request::param ('state', $this->view->conf->default_view);
+		$state_param = Minz_Request::param ('state', null);
 		$filter = Minz_Request::param ('search', '');
 		if (!empty($filter)) {
-			$state = 'all';	//Search always in read and unread articles
+			$state = FreshRSS_Entry::STATE_ALL;	//Search always in read and unread articles
 		}
 		$this->view->order = $order = Minz_Request::param ('order', $this->view->conf->sort_order);
 		$nb = Minz_Request::param ('nb', $this->view->conf->posts_per_page);
 		$first = Minz_Request::param ('next', '');
 
-		if ($state === 'not_read') {	//Any unread article in this category at all?
+		if ($state === FreshRSS_Entry::STATE_NOT_READ) {	//Any unread article in this category at all?
 			switch ($getType) {
 				case 'a':
 					$hasUnread = $this->view->nb_not_read > 0;
 					break;
 				case 's':
+					// This is deprecated. The favorite button does not exist anymore
 					$hasUnread = $this->view->nb_favorites['unread'] > 0;
 					break;
 				case 'c':
@@ -111,8 +111,8 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 					$hasUnread = true;
 					break;
 			}
-			if (!$hasUnread) {
-				$this->view->state = $state = 'all';
+			if (!$hasUnread && ($state_param === null)) {
+				$this->view->state = $state = FreshRSS_Entry::STATE_ALL;
 			}
 		}
 
@@ -125,14 +125,14 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 		$keepHistoryDefault = $this->view->conf->keep_history_default;
 
 		try {
-			$entries = $entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min, $keepHistoryDefault);
+			$entries = $entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min, true, $keepHistoryDefault);
 
 			// Si on a récupéré aucun article "non lus"
 			// on essaye de récupérer tous les articles
-			if ($state === 'not_read' && empty($entries)) {
+			if ($state === FreshRSS_Entry::STATE_NOT_READ && empty($entries) && ($state_param === null)) {
 				Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::DEBUG);
-				$this->view->state = 'all';
-				$entries = $entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter, $date_min, $keepHistoryDefault);
+				$this->view->state = FreshRSS_Entry::STATE_ALL;
+				$entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter, $date_min, true, $keepHistoryDefault);
 			}
 
 			if (count($entries) <= $nb) {
@@ -351,6 +351,32 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 			}
 			$this->view->_useLayout(false);
 			Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);
+		} elseif (Minz_Configuration::unsafeAutologinEnabled() && isset($_GET['u']) && isset($_GET['p'])) {
+			Minz_Session::_param('currentUser');
+			Minz_Session::_param('mail');
+			Minz_Session::_param('passwordHash');
+			$username = ctype_alnum($_GET['u']) ? $_GET['u'] : '';
+			$passwordPlain = $_GET['p'];
+			Minz_Request::_param('p');	//Discard plain-text password ASAP
+			$_GET['p'] = '';
+			if (!function_exists('password_verify')) {
+				include_once(LIB_PATH . '/password_compat.php');
+			}
+			try {
+				$conf = new FreshRSS_Configuration($username);
+				$s = $conf->passwordHash;
+				$ok = password_verify($passwordPlain, $s);
+				unset($passwordPlain);
+				if ($ok) {
+					Minz_Session::_param('currentUser', $username);
+					Minz_Session::_param('passwordHash', $s);
+				} else {
+					Minz_Log::record('Unsafe password mismatch for user ' . $username, Minz_Log::WARNING);
+				}
+			} catch (Minz_Exception $me) {
+				Minz_Log::record('Unsafe login failure: ' . $me->getMessage(), Minz_Log::WARNING);
+			}
+			Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);
 		} elseif (!Minz_Configuration::canLogIn()) {
 			Minz_Error::error (
 				403,

+ 19 - 1
app/Controllers/usersController.php

@@ -32,6 +32,18 @@ class FreshRSS_users_Controller extends Minz_ActionController {
 			}
 			Minz_Session::_param('passwordHash', $this->view->conf->passwordHash);
 
+			$passwordPlain = Minz_Request::param('apiPasswordPlain', false);
+			if ($passwordPlain != '') {
+				if (!function_exists('password_hash')) {
+					include_once(LIB_PATH . '/password_compat.php');
+				}
+				$passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST));
+				$passwordPlain = '';
+				$passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash);	//Compatibility with bcrypt.js
+				$ok &= ($passwordHash != '');
+				$this->view->conf->_apiPasswordHash($passwordHash);
+			}
+
 			if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
 				$this->view->conf->_mail_login(Minz_Request::param('mail_login', false));
 			}
@@ -57,13 +69,19 @@ class FreshRSS_users_Controller extends Minz_ActionController {
 				$anon_refresh = Minz_Request::param('anon_refresh', false);
 				$anon_refresh = ((bool)$anon_refresh) && ($anon_refresh !== 'no');
 				$auth_type = Minz_Request::param('auth_type', 'none');
+				$unsafe_autologin = Minz_Request::param('unsafe_autologin', false);
+				$api_enabled = Minz_Request::param('api_enabled', false);
 				if ($anon != Minz_Configuration::allowAnonymous() ||
 					$auth_type != Minz_Configuration::authType() ||
-					$anon_refresh != Minz_Configuration::allowAnonymousRefresh()) {
+					$anon_refresh != Minz_Configuration::allowAnonymousRefresh() ||
+					$unsafe_autologin != Minz_Configuration::unsafeAutologinEnabled() ||
+					$api_enabled != Minz_Configuration::apiEnabled()) {
 
 					Minz_Configuration::_authType($auth_type);
 					Minz_Configuration::_allowAnonymous($anon);
 					Minz_Configuration::_allowAnonymousRefresh($anon_refresh);
+					Minz_Configuration::_enableAutologin($unsafe_autologin);
+					Minz_Configuration::_enableApi($api_enabled);
 					$ok &= Minz_Configuration::writeFile();
 				}
 			}

+ 0 - 6
app/Exceptions/OpmlException.php

@@ -1,6 +0,0 @@
-<?php
-class FreshRSS_Opml_Exception extends FreshRSS_Feed_Exception {
-	public function __construct ($name_file) {
-		parent::__construct ('OPML file is invalid');
-	}
-}

+ 16 - 3
app/Models/CategoryDAO.php

@@ -18,6 +18,19 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
 		}
 	}
 
+	public function addCategoryObject($category) {
+		$cat = $this->searchByName($category->name());
+		if (!$cat) {
+			// Category does not exist yet in DB so we add it before continue
+			$values = array(
+				'name' => $category->name(),
+			);
+			return $this->addCategory($values);
+		}
+
+		return $cat->id();
+	}
+
 	public function updateCategory ($id, $valuesTmp) {
 		$sql = 'UPDATE `' . $this->prefix . 'category` SET name=? WHERE id=?';
 		$stm = $this->bd->prepare ($sql);
@@ -64,7 +77,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
 		if (isset ($cat[0])) {
 			return $cat[0];
 		} else {
-			return false;
+			return null;
 		}
 	}
 	public function searchByName ($name) {
@@ -80,7 +93,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
 		if (isset ($cat[0])) {
 			return $cat[0];
 		} else {
-			return false;
+			return null;
 		}
 	}
 
@@ -120,7 +133,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
 	public function checkDefault () {
 		$def_cat = $this->searchById (1);
 
-		if ($def_cat === false) {
+		if ($def_cat == null) {
 			$cat = new FreshRSS_Category (Minz_Translate::t ('default_category'));
 			$cat->_id (1);
 

+ 44 - 33
app/Models/Configuration.php

@@ -10,13 +10,15 @@ class FreshRSS_Configuration {
 		'mail_login' => '',
 		'token' => '',
 		'passwordHash' => '',	//CRYPT_BLOWFISH
+		'apiPasswordHash' => '',	//CRYPT_BLOWFISH
 		'posts_per_page' => 20,
 		'view_mode' => 'normal',
-		'default_view' => 'not_read',
+		'default_view' => FreshRSS_Entry::STATE_NOT_READ,
 		'auto_load_more' => true,
 		'display_posts' => false,
 		'onread_jump_next' => true,
 		'lazyload' => true,
+		'sticky_post' => true,
 		'sort_order' => 'DESC',
 		'anon_access' => false,
 		'mark_when' => array(
@@ -37,6 +39,7 @@ class FreshRSS_Configuration {
 			'collapse_entry' => 'c',
 			'load_more' => 'm',
 			'auto_share' => 's',
+			'focus_search' => 'a',
 		),
 		'topline_read' => true,
 		'topline_favorite' => true,
@@ -48,16 +51,7 @@ class FreshRSS_Configuration {
 		'bottomline_tags' => true,
 		'bottomline_date' => true,
 		'bottomline_link' => true,
-		'sharing' => array(
-			'shaarli' => '',
-			'wallabag' => '',
-			'diaspora' => '',
-			'twitter' => true,
-			'g+' => true,
-			'facebook' => true,
-			'email' => true,
-			'print' => true,
-		),
+		'sharing' => array(),
 	);
 
 	private $available_languages = array(
@@ -65,8 +59,10 @@ class FreshRSS_Configuration {
 		'fr' => 'Français',
 	);
 
-	public function __construct ($user) {
-		$this->filename = DATA_PATH . '/' . $user . '_user.php';
+	private $shares;
+
+	public function __construct($user) {
+		$this->filename = DATA_PATH . DIRECTORY_SEPARATOR . $user . '_user.php';
 
 		$data = @include($this->filename);
 		if (!is_array($data)) {
@@ -80,10 +76,20 @@ class FreshRSS_Configuration {
 			}
 		}
 		$this->data['user'] = $user;
+
+		$this->shares = DATA_PATH . DIRECTORY_SEPARATOR . 'shares.php';
+
+		$shares = @include($this->shares);
+		if (!is_array($shares)) {
+			throw new Minz_PermissionDeniedException($this->shares);
+		}
+
+		$this->data['shares'] = $shares;
 	}
 
 	public function save() {
 		@rename($this->filename, $this->filename . '.bak.php');
+		unset($this->data['shares']); // Remove shares because it is not intended to be stored in user configuration
 		if (file_put_contents($this->filename, "<?php\n return " . var_export($this->data, true) . ';', LOCK_EX) === false) {
 			throw new Minz_PermissionDeniedException($this->filename);
 		}
@@ -104,16 +110,6 @@ class FreshRSS_Configuration {
 		}
 	}
 
-	public function sharing($key = false) {
-		if ($key === false) {
-			return $this->data['sharing'];
-		}
-		if (isset($this->data['sharing'][$key])) {
-			return $this->data['sharing'][$key];
-		}
-		return false;
-	}
-
 	public function availableLanguages() {
 		return $this->available_languages;
 	}
@@ -136,7 +132,7 @@ class FreshRSS_Configuration {
 		}
 	}
 	public function _default_view ($value) {
-		$this->data['default_view'] = $value === 'all' ? 'all' : 'not_read';
+		$this->data['default_view'] = $value === FreshRSS_Entry::STATE_ALL ? FreshRSS_Entry::STATE_ALL : FreshRSS_Entry::STATE_NOT_READ;
 	}
 	public function _display_posts ($value) {
 		$this->data['display_posts'] = ((bool)$value) && $value !== 'no';
@@ -147,6 +143,9 @@ class FreshRSS_Configuration {
 	public function _lazyload ($value) {
 		$this->data['lazyload'] = ((bool)$value) && $value !== 'no';
 	}
+	public function _sticky_post($value) {
+		$this->data['sticky_post'] = ((bool)$value) && $value !== 'no';
+	}
 	public function _sort_order ($value) {
 		$this->data['sort_order'] = $value === 'ASC' ? 'ASC' : 'DESC';
 	}
@@ -168,6 +167,9 @@ class FreshRSS_Configuration {
 	public function _passwordHash ($value) {
 		$this->data['passwordHash'] = ctype_graph($value) && (strlen($value) >= 60) ? $value : '';
 	}
+	public function _apiPasswordHash ($value) {
+		$this->data['apiPasswordHash'] = ctype_graph($value) && (strlen($value) >= 60) ? $value : '';
+	}
 	public function _mail_login ($value) {
 		$value = filter_var($value, FILTER_VALIDATE_EMAIL);
 		if ($value) {
@@ -187,24 +189,33 @@ class FreshRSS_Configuration {
 		}
 	}
 	public function _sharing ($values) {
-		$are_url = array ('shaarli', 'wallabag', 'diaspora');
-		foreach ($values as $key => $value) {
-			if (in_array($key, $are_url)) {
+		$this->data['sharing'] = array();
+		foreach ($values as $value) {
+			if (!is_array($value)) {
+				continue;
+			}
+
+			// Verify URL and add default value when needed
+			if (isset($value['url'])) {
 				$is_url = (
-					filter_var ($value, FILTER_VALIDATE_URL) ||
+					filter_var ($value['url'], FILTER_VALIDATE_URL) ||
 					(version_compare(PHP_VERSION, '5.3.3', '<') &&
 						(strpos($value, '-') > 0) &&
 						($value === filter_var($value, FILTER_SANITIZE_URL)))
 				);  //PHP bug #51192
-
 				if (!$is_url) {
-					$value = '';
+					continue;
 				}
-			} elseif (!is_bool($value)) {
-				$value = true;
+			} else {
+				$value['url'] = null;
+			}
+
+			// Add a default name
+			if (empty($value['name'])) {
+				$value['name'] = $value['type'];
 			}
 
-			$this->data['sharing'][$key] = $value;
+			$this->data['sharing'][] = $value;
 		}
 	}
 	public function _theme($value) {

+ 5 - 0
app/Models/Entry.php

@@ -1,6 +1,11 @@
 <?php
 
 class FreshRSS_Entry extends Minz_Model {
+	const STATE_ALL = 0;
+	const STATE_READ = 1;
+	const STATE_NOT_READ = 2;
+	const STATE_FAVORITE = 4;
+	const STATE_NOT_FAVORITE = 8;
 
 	private $id = 0;
 	private $guid;

+ 231 - 55
app/Models/EntryDAO.php

@@ -35,11 +35,45 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 		}
 	}
 
-	public function markFavorite ($id, $is_favorite = true) {
+	public function addEntryObject($entry, $conf, $feedHistory) {
+		$existingGuids = array_fill_keys(
+			$this->listLastGuidsByFeed($entry->feed(), 20), 1
+		);
+
+		$nb_month_old = max($conf->old_entries, 1);
+		$date_min = time() - (3600 * 24 * 30 * $nb_month_old);
+
+		$eDate = $entry->date(true);
+
+		if ($feedHistory == -2) {
+			$feedHistory = $conf->keep_history_default;
+		}
+
+		if (!isset($existingGuids[$entry->guid()]) &&
+				($feedHistory != 0 || $eDate  >= $date_min)) {
+			$values = $entry->toArray();
+
+			$useDeclaredDate = empty($existingGuids);
+			$values['id'] = ($useDeclaredDate || $eDate < $date_min) ?
+				min(time(), $eDate) . uSecString() :
+				uTimeString();
+
+			return $this->addEntry($values);
+		}
+
+		// We don't return Entry object to avoid a research in DB
+		return -1;
+	}
+
+	public function markFavorite($ids, $is_favorite = true) {
+		if (!is_array($ids)) {
+			$ids = array($ids);
+		}
 		$sql = 'UPDATE `' . $this->prefix . 'entry` e '
 		     . 'SET e.is_favorite = ? '
-		     . 'WHERE e.id=?';
-		$values = array ($is_favorite ? 1 : 0, $id);
+		     . 'WHERE e.id IN (' . str_repeat('?,', count($ids) - 1). '?)';
+		$values = array ($is_favorite ? 1 : 0);
+		$values = array_merge($values, $ids);
 		$stm = $this->bd->prepare ($sql);
 		if ($stm && $stm->execute ($values)) {
 			return $stm->rowCount();
@@ -49,30 +83,79 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 			return false;
 		}
 	}
-	public function markRead ($id, $is_read = true) {
-		$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
-		     . 'SET e.is_read = ?,'
-		     . 'f.cache_nbUnreads=f.cache_nbUnreads' . ($is_read ? '-' : '+') . '1 '
-		     . 'WHERE e.id=?';
-		$values = array ($is_read ? 1 : 0, $id);
-		$stm = $this->bd->prepare ($sql);
-		if ($stm && $stm->execute ($values)) {
-			return $stm->rowCount();
+
+	public function markRead($ids, $is_read = true) {
+		if (is_array($ids)) {
+			if (count($ids) < 6) {	//Speed heuristics
+				$affected = 0;
+				foreach ($ids as $id) {
+					$affected += $this->markRead($id, $is_read);
+				}
+				return $affected;
+			}
+
+			$this->bd->beginTransaction();
+			$sql = 'UPDATE `' . $this->prefix . 'entry` e '
+				 . 'SET e.is_read = ? '
+				 . 'WHERE e.id IN (' . str_repeat('?,', count($ids) - 1). '?)';
+			$values = array($is_read ? 1 : 0);
+			$values = array_merge($values, $ids);
+			$stm = $this->bd->prepare($sql);
+			if (!($stm && $stm->execute($values))) {
+				$info = $stm->errorInfo();
+				Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR);
+				$this->bd->rollBack();
+				return false;
+			}
+			$affected = $stm->rowCount();
+
+			if ($affected > 0) {
+				$sql = 'UPDATE `' . $this->prefix . 'feed` f '
+				     . 'INNER JOIN ('
+				     .	'SELECT e.id_feed, '
+				     .	'COUNT(CASE WHEN e.is_read = 0 THEN 1 END) AS nbUnreads, '
+				     .	'COUNT(e.id) AS nbEntries '
+				     .	'FROM `' . $this->prefix . 'entry` e '
+				     .	'GROUP BY e.id_feed'
+				     . ') x ON x.id_feed=f.id '
+				     . 'SET f.cache_nbEntries=x.nbEntries, f.cache_nbUnreads=x.nbUnreads';
+				$stm = $this->bd->prepare($sql);
+				if (!($stm && $stm->execute())) {
+					$info = $stm->errorInfo();
+					Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR);
+					$this->bd->rollBack();
+					return false;
+				}
+			}
+
+			$this->bd->commit();
+			return $affected;
 		} else {
-			$info = $stm->errorInfo();
-			Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR);
-			return false;
+			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
+				 . 'SET e.is_read = ?,'
+				 . 'f.cache_nbUnreads=f.cache_nbUnreads' . ($is_read ? '-' : '+') . '1 '
+				 . 'WHERE e.id=?';
+			$values = array($is_read ? 1 : 0, $ids);
+			$stm = $this->bd->prepare($sql);
+			if ($stm && $stm->execute($values)) {
+				return $stm->rowCount();
+			} else {
+				$info = $stm->errorInfo();
+				Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR);
+				return false;
+			}
 		}
 	}
-	public function markReadEntries ($idMax = 0, $favorites = false) {
-		if ($idMax === 0) {
+
+	public function markReadEntries ($idMax = 0, $onlyFavorites = false, $priorityMin = 0) {
+		if ($idMax == 0) {
 			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
 			     . 'SET e.is_read = 1, f.cache_nbUnreads=0 '
-			     . 'WHERE e.is_read = 0 AND ';
-			if ($favorites) {
-				$sql .= 'e.is_favorite = 1';
-			} else {
-				$sql .= 'f.priority > 0';
+			     . 'WHERE e.is_read = 0';
+			if ($onlyFavorites) {
+				$sql .= ' AND e.is_favorite = 1';
+			} elseif ($priorityMin >= 0) {
+				$sql .= ' AND f.priority > ' . intval($priorityMin);
 			}
 			$stm = $this->bd->prepare ($sql);
 			if ($stm && $stm->execute ()) {
@@ -87,11 +170,11 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 
 			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
 			     . 'SET e.is_read = 1 '
-			     . 'WHERE e.is_read = 0 AND e.id <= ? AND ';
-			if ($favorites) {
-				$sql .= 'e.is_favorite = 1';
-			} else {
-				$sql .= 'f.priority > 0';
+			     . 'WHERE e.is_read = 0 AND e.id <= ?';
+			if ($onlyFavorites) {
+				$sql .= ' AND e.is_favorite = 1';
+			} elseif ($priorityMin >= 0) {
+				$sql .= ' AND f.priority > ' . intval($priorityMin);
 			}
 			$values = array ($idMax);
 			$stm = $this->bd->prepare ($sql);
@@ -126,8 +209,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 			return $affected;
 		}
 	}
+
 	public function markReadCat ($id, $idMax = 0) {
-		if ($idMax === 0) {
+		if ($idMax == 0) {
 			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
 			     . 'SET e.is_read = 1, f.cache_nbUnreads=0 '
 			     . 'WHERE f.category = ? AND e.is_read = 0';
@@ -181,8 +265,70 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 			return $affected;
 		}
 	}
+
+	public function markReadCatName($name, $idMax = 0) {
+		if ($idMax == 0) {
+			$sql = 'UPDATE `' . $this->prefix . 'entry` e '
+			     . 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
+			     . 'INNER JOIN `' . $this->prefix . 'category` c ON c.id = f.category '
+			     . 'SET e.is_read = 1, f.cache_nbUnreads=0 '
+			     . 'WHERE c.name = ?';
+			$values = array($name);
+			$stm = $this->bd->prepare($sql);
+			if ($stm && $stm->execute($values)) {
+				return $stm->rowCount();
+			} else {
+				$info = $stm->errorInfo();
+				Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR);
+				return false;
+			}
+		} else {
+			$this->bd->beginTransaction();
+
+			$sql = 'UPDATE `' . $this->prefix . 'entry` e '
+			     . 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
+			     . 'INNER JOIN `' . $this->prefix . 'category` c ON c.id = f.category '
+			     . 'SET e.is_read = 1 '
+			     . 'WHERE c.name = ? AND e.id <= ?';
+			$values = array($name, $idMax);
+			$stm = $this->bd->prepare($sql);
+			if (!($stm && $stm->execute($values))) {
+				$info = $stm->errorInfo();
+				Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR);
+				$this->bd->rollBack();
+				return false;
+			}
+			$affected = $stm->rowCount();
+
+			if ($affected > 0) {
+				$sql = 'UPDATE `' . $this->prefix . 'feed` f '
+			     . 'LEFT OUTER JOIN ('
+			     .	'SELECT e.id_feed, '
+			     .	'COUNT(*) AS nbUnreads '
+			     .	'FROM `' . $this->prefix . 'entry` e '
+			     .	'WHERE e.is_read = 0 '
+			     .	'GROUP BY e.id_feed'
+			     . ') x ON x.id_feed=f.id '
+			     . 'INNER JOIN `' . $this->prefix . 'category` c ON c.id = f.category '
+			     . 'SET f.cache_nbUnreads=COALESCE(x.nbUnreads, 0) '
+			     . 'WHERE c.name = ?';
+				$values = array($name);
+				$stm = $this->bd->prepare($sql);
+				if (!($stm && $stm->execute($values))) {
+					$info = $stm->errorInfo();
+					Minz_Log::record('SQL error : ' . $info[2], Minz_Log::ERROR);
+					$this->bd->rollBack();
+					return false;
+				}
+			}
+
+			$this->bd->commit();
+			return $affected;
+		}
+	}
+
 	public function markReadFeed ($id, $idMax = 0) {
-		if ($idMax === 0) {
+		if ($idMax == 0) {
 			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
 			     . 'SET e.is_read = 1, f.cache_nbUnreads=0 '
 			     . 'WHERE f.id=? AND e.is_read = 0';
@@ -244,7 +390,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 		$stm->execute ($values);
 		$res = $stm->fetchAll (PDO::FETCH_ASSOC);
 		$entries = self::daoToEntry ($res);
-		return isset ($entries[0]) ? $entries[0] : false;
+		return isset ($entries[0]) ? $entries[0] : null;
 	}
 
 	public function searchById ($id) {
@@ -257,10 +403,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 		$stm->execute ($values);
 		$res = $stm->fetchAll (PDO::FETCH_ASSOC);
 		$entries = self::daoToEntry ($res);
-		return isset ($entries[0]) ? $entries[0] : false;
+		return isset ($entries[0]) ? $entries[0] : null;
 	}
 
-	public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $keepHistoryDefault = 0) {
+	private function sqlListWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {
+		if (!$state) {
+			$state = FreshRSS_Entry::STATE_ALL;
+		}
 		$where = '';
 		$joinFeed = false;
 		$values = array();
@@ -269,7 +418,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 				$where .= 'f.priority > 0 ';
 				$joinFeed = true;
 				break;
-			case 's':
+			case 's':	//Deprecated: use $state instead
 				$where .= 'e1.is_favorite = 1 ';
 				break;
 			case 'c':
@@ -281,24 +430,30 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 				$where .= 'e1.id_feed = ? ';
 				$values[] = intval($id);
 				break;
+			case 'A':
+				$where .= '1 ';
+				break;
 			default:
 				throw new FreshRSS_EntriesGetter_Exception ('Bad type in Entry->listByType: [' . $type . ']!');
 		}
-		switch ($state) {
-			case 'all':
-				break;
-			case 'not_read':
+
+		if ($state & FreshRSS_Entry::STATE_NOT_READ) {
+			if (!($state & FreshRSS_Entry::STATE_READ)) {
 				$where .= 'AND e1.is_read = 0 ';
-				break;
-			case 'read':
-				$where .= 'AND e1.is_read = 1 ';
-				break;
-			case 'favorite':
+			}
+		}
+		elseif ($state & FreshRSS_Entry::STATE_READ) {
+			$where .= 'AND e1.is_read = 1 ';
+		}
+		if ($state & FreshRSS_Entry::STATE_FAVORITE) {
+			if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) {
 				$where .= 'AND e1.is_favorite = 1 ';
-				break;
-			default:
-				throw new FreshRSS_EntriesGetter_Exception ('Bad state in Entry->listByType: [' . $state . ']!');
+			}
+		}
+		elseif ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) {
+			$where .= 'AND e1.is_favorite = 0 ';
 		}
+
 		switch ($order) {
 			case 'DESC':
 			case 'ASC':
@@ -310,11 +465,15 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 			$where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' ';
 		}
 		if (($date_min > 0) && ($type !== 's')) {
-			$where .= 'AND (e1.id >= ' . $date_min . '000000 OR e1.is_read = 0 OR e1.is_favorite = 1 OR (f.keep_history <> 0';
-			if (intval($keepHistoryDefault) === 0) {
-				$where .= ' AND f.keep_history <> -2';	//default
+			$where .= 'AND (e1.id >= ' . $date_min . '000000';
+			if ($showOlderUnreadsorFavorites) {	//Lax date constraint
+				$where .= ' OR e1.is_read = 0 OR e1.is_favorite = 1 OR (f.keep_history <> 0';
+				if (intval($keepHistoryDefault) === 0) {
+					$where .= ' AND f.keep_history <> -2';	//default
+				}
+				$where .= ')';
 			}
-			$where .= ')) ';
+			$where .= ') ';
 			$joinFeed = true;
 		}
 		$search = '';
@@ -366,14 +525,22 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 			}
 		}
 
+		return array($values,
+			'SELECT e1.id FROM `' . $this->prefix . 'entry` e1 '
+			. ($joinFeed ? 'INNER JOIN `' . $this->prefix . 'feed` f ON e1.id_feed = f.id ' : '')
+			. 'WHERE ' . $where
+			. $search
+			. 'ORDER BY e1.id ' . $order
+			. ($limit > 0 ? ' LIMIT ' . $limit : ''));	//TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
+	}
+
+	public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {
+		list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault);
+
 		$sql = 'SELECT e.id, e.guid, e.title, e.author, UNCOMPRESS(e.content_bin) AS content, e.link, e.date, e.is_read, e.is_favorite, e.id_feed, e.tags '
 		     . 'FROM `' . $this->prefix . 'entry` e '
-		     . 'INNER JOIN (SELECT e1.id FROM `' . $this->prefix . 'entry` e1 '
-			     . ($joinFeed ? 'INNER JOIN `' . $this->prefix . 'feed` f ON e1.id_feed = f.id ' : '')
-			     . 'WHERE ' . $where
-			     . $search
-			     . 'ORDER BY e1.id ' . $order
-			     . ($limit > 0 ? ' LIMIT ' . $limit : '')	//TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
+		     . 'INNER JOIN ('
+		     . $sql
 		     . ') e2 ON e2.id = e.id '
 		     . 'ORDER BY e.id ' . $order;
 
@@ -383,6 +550,15 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 		return self::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
 	}
 
+	public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {	//For API
+		list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault);
+
+		$stm = $this->bd->prepare($sql);
+		$stm->execute($values);
+
+		return $stm->fetchAll(PDO::FETCH_COLUMN, 0);
+	}
+
 	public function listLastGuidsByFeed($id, $n) {
 		$sql = 'SELECT guid FROM `' . $this->prefix . 'entry` WHERE id_feed=? ORDER BY id DESC LIMIT ' . intval($n);
 		$stm = $this->bd->prepare ($sql);

+ 8 - 7
app/Models/Feed.php

@@ -210,8 +210,8 @@ class FreshRSS_Feed extends Minz_Model {
 				}
 
 				if ($loadDetails) {
-					$title = htmlspecialchars(html_only_entity_decode($feed->get_title()), ENT_COMPAT, 'UTF-8');
-					$this->_name ($title === null ? $this->url : $title);
+					$title = strtr(html_only_entity_decode($feed->get_title()), array('<' => '&lt;', '>' => '&gt;', '"' => '&quot;'));	//HTML to HTML-PRE	//ENT_COMPAT except &
+					$this->_name ($title == '' ? $this->url : $title);
 
 					$this->_website(html_only_entity_decode($feed->get_link()));
 					$this->_description(html_only_entity_decode($feed->get_description()));
@@ -254,11 +254,12 @@ class FreshRSS_Feed extends Minz_Model {
 			$elinks = array();
 			foreach ($item->get_enclosures() as $enclosure) {
 				$elink = $enclosure->get_link();
-				if (array_key_exists($elink, $elinks)) continue;
-				$elinks[$elink] = '1';
-				$mime = strtolower($enclosure->get_type());
-				if (strpos($mime, 'image/') === 0) {
-					$content .= '<br /><img src="' . $elink . '" alt="" />';
+				if (empty($elinks[$elink])) {
+					$elinks[$elink] = '1';
+					$mime = strtolower($enclosure->get_type());
+					if (strpos($mime, 'image/') === 0) {
+						$content .= '<br /><img src="' . $elink . '" alt="" />';
+					}
 				}
 			}
 

+ 51 - 5
app/Models/FeedDAO.php

@@ -24,6 +24,36 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		}
 	}
 
+	public function addFeedObject($feed) {
+		// TODO: not sure if we should write this method in DAO since DAO
+		// should not be aware about feed class
+
+		// Add feed only if we don't find it in DB
+		$feed_search = $this->searchByUrl($feed->url());
+		if (!$feed_search) {
+			$values = array(
+				'id' => $feed->id(),
+				'url' => $feed->url(),
+				'category' => $feed->category(),
+				'name' => $feed->name(),
+				'website' => $feed->website(),
+				'description' => $feed->description(),
+				'lastUpdate' => 0,
+				'httpAuth' => $feed->httpAuth()
+			);
+
+			$id = $this->addFeed($values);
+			if ($id) {
+				$feed->_id($id);
+				$feed->faviconPrepare();
+			}
+
+			return $id;
+		}
+
+		return $feed_search->id();
+	}
+
 	public function updateFeed ($id, $valuesTmp) {
 		$set = '';
 		foreach ($valuesTmp as $key => $v) {
@@ -170,7 +200,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if (isset ($feed[$id])) {
 			return $feed[$id];
 		} else {
-			return false;
+			return null;
 		}
 	}
 	public function searchByUrl ($url) {
@@ -186,7 +216,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		if (isset ($feed)) {
 			return $feed;
 		} else {
-			return false;
+			return null;
 		}
 	}
 
@@ -198,6 +228,22 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		return self::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC));
 	}
 
+	public function arrayFeedCategoryNames() {	//For API
+		$sql = 'SELECT f.id, f.name, c.name as c_name FROM `' . $this->prefix . 'feed` f '
+		     . 'INNER JOIN `' . $this->prefix . 'category` c ON c.id = f.category';
+		$stm = $this->bd->prepare ($sql);
+		$stm->execute ();
+		$res = $stm->fetchAll(PDO::FETCH_ASSOC);
+		$feedCategoryNames = array();
+		foreach ($res as $line) {
+			$feedCategoryNames[$line['id']] = array(
+				'name' => $line['name'],
+				'c_name' => $line['c_name'],
+			);
+		}
+		return $feedCategoryNames;
+	}
+
 	public function listFeedsOrderUpdate ($cacheDuration = 1500) {
 		$sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history '
 		     . 'FROM `' . $this->prefix . 'feed` '
@@ -229,6 +275,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 
 		return $res[0]['count'];
 	}
+
 	public function countNotRead ($id) {
 		$sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND is_read=0';
 		$stm = $this->bd->prepare ($sql);
@@ -238,6 +285,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 
 		return $res[0]['count'];
 	}
+
 	public function updateCachedValues () {	//For one single feed, call updateLastUpdate($id)
 		$sql = 'UPDATE `' . $this->prefix . 'feed` f '
 		     . 'INNER JOIN ('
@@ -250,9 +298,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
 		     . 'SET f.cache_nbEntries=x.nbEntries, f.cache_nbUnreads=x.nbUnreads';
 		$stm = $this->bd->prepare ($sql);
 
-		$values = array ($feed_id);
-
-		if ($stm && $stm->execute ($values)) {
+		if ($stm && $stm->execute()) {
 			return $stm->rowCount();
 		} else {
 			$info = $stm->errorInfo();

+ 44 - 0
app/Models/Share.php

@@ -0,0 +1,44 @@
+<?php
+
+class FreshRSS_Share {
+
+	static public function generateUrl($options, $selected, $link, $title) {
+		$share = $options[$selected['type']];
+		$matches = array(
+			'~URL~',
+			'~TITLE~',
+			'~LINK~',
+		);
+		$replaces = array(
+			$selected['url'],
+			self::transformData($title, self::getTransform($share, 'title')),
+			self::transformData($link, self::getTransform($share, 'link')),
+		);
+		$url = str_replace($matches, $replaces, $share['url']);
+		return $url;
+	}
+
+	static private function transformData($data, $transform) {
+		if (!is_array($transform)) {
+			return $data;
+		}
+		if (count($transform) === 0) {
+			return $data;
+		}
+		foreach ($transform as $action) {
+			$data = call_user_func($action, $data);
+		}
+		return $data;
+	}
+
+	static private function getTransform($options, $type) {
+		$transform = $options['transform'];
+
+		if (array_key_exists($type, $transform)) {
+			return $transform[$type];
+		}
+
+		return $transform;
+	}
+
+}

+ 2 - 0
app/Models/Themes.php

@@ -77,6 +77,7 @@ class FreshRSS_Themes extends Minz_Model {
 			'down' => '▽',
 			'favorite' => '★',
 			'help' => 'ⓘ',
+			'key' => '⚿',
 			'link' => '↗',
 			'login' => '🔒',
 			'logout' => '🔓',
@@ -84,6 +85,7 @@ class FreshRSS_Themes extends Minz_Model {
 			'non-starred' => '☆',
 			'prev' => '⏪',
 			'read' => '☑',
+			'rss' => '☄',
 			'unread' => '☐',
 			'refresh' => '🔃',	//↻
 			'search' => '🔍',

+ 0 - 1
app/actualize_script.php

@@ -28,7 +28,6 @@ foreach ($users as $myUser) {
 	$_SERVER['HTTP_HOST'] = '';
 
 	$freshRSS = new FreshRSS();
-	$freshRSS->_useOb(false);
 
 	Minz_Configuration::_authType('none');
 

+ 22 - 8
app/i18n/en.php

@@ -21,12 +21,13 @@ return array (
 	'your_rss_feeds'		=> 'Your RSS feeds',
 	'add_rss_feed'			=> 'Add a RSS feed',
 	'no_rss_feed'			=> 'No RSS feed',
-	'import_export_opml'		=> 'Import / export (OPML)',
+	'import_export'			=> 'Import / export',
+	'bookmark'			=> 'Subscribe (FreshRSS bookmark)',
 
 	'subscription_management'	=> 'Subscriptions management',
 	'main_stream'			=> 'Main stream',
 	'all_feeds'			=> 'All feeds',
-	'favorite_feeds'		=> 'Favourites (%d)',
+	'favorite_feeds'		=> 'Favourites (%s)',
 	'not_read'			=> '%d unread',
 	'not_reads'			=> '%d unread',
 
@@ -50,7 +51,8 @@ return array (
 	'show_all_articles'		=> 'Show all articles',
 	'show_not_reads'		=> 'Show only unread',
 	'show_read'			=> 'Show only read',
-	'show_favorite'			=> 'Show favorites',
+	'show_favorite'			=> 'Show only favorites',
+	'show_not_favorite'		=> 'Show all but favorites',
 	'older_first'			=> 'Oldest first',
 	'newer_first'			=> 'Newer first',
 
@@ -78,9 +80,8 @@ return array (
 	'sharing_management'		=> 'Sharing options management',
 	'bad_opml_file'			=> 'Your OPML file is invalid',
 	'shortcuts_updated'		=> 'Shortcuts have been updated',
-	'shortcuts_management'		=> 'Shortcuts management',
 	'shortcuts_navigation'		=> 'Navigation',
-	'shortcuts_navigation_help'	=> 'With the "Shift" modifier, navigation shortcuts apply on feeds.<br/>With the "Ctrl" modifier, navigation shortcuts apply on categories.',
+	'shortcuts_navigation_help'	=> 'With the "Shift" modifier, navigation shortcuts apply on feeds.<br/>With the "Alt" modifier, navigation shortcuts apply on categories.',
 	'shortcuts_article_action'	=> 'Article actions',
 	'shortcuts_other_action'	=> 'Other actions',
 	'feeds_marked_read'		=> 'Feeds have been marked as read',
@@ -89,7 +90,7 @@ return array (
 	'already_subscribed'		=> 'You have already subscribed to <em>%s</em>',
 	'feed_added'			=> 'RSS feed <em>%s</em> has been added',
 	'feed_not_added'		=> '<em>%s</em> could not be added',
-	'internal_problem_feed'		=> 'The RSS feed could not be added. Check FressRSS logs for details.',
+	'internal_problem_feed'		=> 'The RSS feed could not be added. <a href="%s">Check FressRSS logs</a> for details.',
 	'invalid_url'			=> 'URL <em>%s</em> is invalid',
 	'feed_actualized'		=> '<em>%s</em> has been updated',
 	'n_feeds_actualized'		=> '%d feeds have been updated',
@@ -136,10 +137,15 @@ return array (
 	'collapse_article'		=> 'Collapse',
 	'auto_share'			=> 'Share',
 	'auto_share_help'		=> 'If there is only one sharing mode, it is used. Else modes are accessible by their number.',
+	'focus_search'			=> 'Access search box',
 
-	'file_to_import'		=> 'File to import',
+	'file_to_import'		=> 'File to import<br />(OPML, Json or Zip)',
 	'import'			=> 'Import',
 	'export'			=> 'Export',
+	'export_opml'			=> 'Export list of feeds (OPML)',
+	'export_starred'		=> 'Export your favourites',
+	'starred_list'			=> 'List of favourite articles',
+	'feed_list'			=> 'List of %s articles',
 	'or'				=> 'or',
 
 	'informations'			=> 'Information',
@@ -166,6 +172,8 @@ return array (
 	'http_username'			=> 'HTTP username',
 	'http_password'			=> 'HTTP password',
 	'blank_to_disable'		=> 'Leave blank to disable',
+	'share_name'			=> 'Share name to display',
+	'share_url'			=> 'Share URL to use',
 	'not_yet_implemented'		=> 'Not yet implemented',
 	'access_protected_feeds'	=> 'Connection allows to access HTTP protected RSS feeds',
 	'no_selected_feed'		=> 'No feed selected.',
@@ -174,9 +182,12 @@ return array (
 	'current_user'			=> 'Current user',
 	'default_user'			=> 'Username of the default user <small>(maximum 16 alphanumeric characters)</small>',
 	'password_form'			=> 'Password<br /><small>(for the Web-form login method)</small>',
+	'password_api'			=> 'Password API<br /><small>(e.g., for mobile apps)</small>',
 	'persona_connection_email'	=> 'Login mail address<br /><small>(for <a href="https://persona.org/" rel="external">Mozilla Persona</a>)</small>',
 	'allow_anonymous'		=> 'Allow anonymous reading of the articles of the default user (%s)',
 	'allow_anonymous_refresh'	=> 'Allow anonymous refresh of the articles',
+	'unsafe_autologin'		=> 'Allow unsafe automatic login using the format: ',
+	'api_enabled'			=> 'Allow <abbr>API</abbr> access <small>(required for mobile apps)</small>',
 	'auth_token'			=> 'Authentication token',
 	'explain_token'			=> 'Allows to access RSS output of the default user without authentication.<br /><kbd>%s?output=rss&token=%s</kbd>',
 	'login_configuration'		=> 'Login',
@@ -202,6 +213,7 @@ return array (
 	'purge_completed'		=> 'Purge completed (%d articles deleted)',
 	'archiving_configuration_help'	=> 'More options are available in the individual stream settings',
 	'reading_configuration'		=> 'Reading',
+	'display_configuration'		=> 'Display',
 	'articles_per_page'		=> 'Number of articles per page',
 	'default_view'			=> 'Default view',
 	'sort_order'			=> 'Sort order',
@@ -209,10 +221,11 @@ return array (
 	'display_articles_unfolded'	=> 'Show articles unfolded by default',
 	'after_onread'			=> 'After “mark all as read”,',
 	'jump_next'			=> 'jump to next unread sibling (feed or category)',
-	'reading_icons'			=> 'Reading icons',
+	'article_icons'			=> 'Article icons',
 	'top_line'			=> 'Top line',
 	'bottom_line'			=> 'Bottom line',
 	'img_with_lazyload'		=> 'Use "lazy load" mode to load pictures',
+	'sticky_post'			=> 'Stick the article to the top when opened',
 	'auto_read_when'		=> 'Mark article as read…',
 	'article_selected'		=> 'when article is selected',
 	'article_open_on_website'	=> 'when article is opened on its original website',
@@ -230,6 +243,7 @@ return array (
 	'more_information'		=> 'More information',
 	'activate_sharing'		=> 'Activate sharing',
 	'shaarli'			=> 'Shaarli',
+	'blogotext'			=> 'Blogotext',
 	'wallabag'			=> 'wallabag',
 	'diaspora'			=> 'Diaspora*',
 	'twitter'			=> 'Twitter',

+ 21 - 7
app/i18n/fr.php

@@ -21,12 +21,13 @@ return array (
 	'your_rss_feeds'		=> 'Vos flux RSS',
 	'add_rss_feed'			=> 'Ajouter un flux RSS',
 	'no_rss_feed'			=> 'Aucun flux RSS',
-	'import_export_opml'		=> 'Importer / exporter (OPML)',
+	'import_export'			=> 'Importer / exporter',
+	'bookmark'			=> 'S’abonner (bookmark FreshRSS)',
 
 	'subscription_management'	=> 'Gestion des abonnements',
 	'main_stream'			=> 'Flux principal',
 	'all_feeds'			=> 'Tous les flux',
-	'favorite_feeds'		=> 'Favoris (%d)',
+	'favorite_feeds'		=> 'Favoris (%s)',
 	'not_read'			=> '%d non lu',
 	'not_reads'			=> '%d non lus',
 
@@ -51,6 +52,7 @@ return array (
 	'show_not_reads'		=> 'Afficher les non lus',
 	'show_read'			=> 'Afficher les lus',
 	'show_favorite'			=> 'Afficher les favoris',
+	'show_not_favorite'		=> 'Afficher tout sauf les favoris',
 	'older_first'			=> 'Plus anciens en premier',
 	'newer_first'			=> 'Plus récents en premier',
 
@@ -78,9 +80,8 @@ return array (
 	'sharing_management'		=> 'Gestion des options de partage',
 	'bad_opml_file'			=> 'Votre fichier OPML n’est pas valide',
 	'shortcuts_updated'		=> 'Les raccourcis ont été mis à jour',
-	'shortcuts_management'		=> 'Gestion des raccourcis',
 	'shortcuts_navigation'		=> 'Navigation',
-	'shortcuts_navigation_help'	=> 'Avec le modificateur "Shift", les raccourcis de navigation s’appliquent aux flux.<br/>Avec le modificateur "Ctrl", les raccourcis de navigation s’appliquent aux catégories.',
+	'shortcuts_navigation_help'	=> 'Avec le modificateur "Shift", les raccourcis de navigation s’appliquent aux flux.<br/>Avec le modificateur "Alt", les raccourcis de navigation s’appliquent aux catégories.',
 	'shortcuts_article_action'	=> 'Actions associées à l’article courant',
 	'shortcuts_other_action'	=> 'Autres actions',
 	'feeds_marked_read'		=> 'Les flux ont été marqués comme lus',
@@ -89,7 +90,7 @@ return array (
 	'already_subscribed'		=> 'Vous êtes déjà abonné à <em>%s</em>',
 	'feed_added'			=> 'Le flux <em>%s</em> a bien été ajouté',
 	'feed_not_added'		=> '<em>%s</em> n’a pas pu être ajouté',
-	'internal_problem_feed'		=> 'Le flux n’a pas pu être ajouté. Consulter les logs de FreshRSS pour plus de détails.',
+	'internal_problem_feed'		=> 'Le flux ne peut pas être ajouté. <a href="%s">Consulter les logs de FreshRSS</a> pour plus de détails.',
 	'invalid_url'			=> 'L’url <em>%s</em> est invalide',
 	'feed_actualized'		=> '<em>%s</em> a été mis à jour',
 	'n_feeds_actualized'		=> '%d flux ont été mis à jour',
@@ -136,10 +137,15 @@ return array (
 	'collapse_article'		=> 'Refermer',
 	'auto_share'			=> 'Partager',
 	'auto_share_help'		=> 'Si il n’y a qu’un mode de partage, celui ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.',
+	'focus_search'			=> 'Accéder à la recherche',
 
-	'file_to_import'		=> 'Fichier à importer',
+	'file_to_import'		=> 'Fichier à importer<br />(OPML, Json ou Zip)',
 	'import'			=> 'Importer',
 	'export'			=> 'Exporter',
+	'export_opml'			=> 'Exporter la liste des flux (OPML)',
+	'export_starred'		=> 'Exporter les favoris',
+	'starred_list'			=> 'Liste des articles favoris',
+	'feed_list'			=> 'Liste des articles de %s',
 	'or'				=> 'ou',
 
 	'informations'			=> 'Informations',
@@ -166,6 +172,8 @@ return array (
 	'http_username'			=> 'Identifiant HTTP',
 	'http_password'			=> 'Mot de passe HTTP',
 	'blank_to_disable'		=> 'Laissez vide pour désactiver',
+	'share_name'			=> 'Nom du partage à afficher',
+	'share_url'			=> 'URL du partage à utiliser',
 	'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é.',
@@ -173,10 +181,13 @@ return array (
 
 	'current_user'			=> 'Utilisateur actuel',
 	'password_form'			=> 'Mot de passe<br /><small>(pour connexion par formulaire)</small>',
+	'password_api'			=> 'Mot de passe API<br /><small>(ex. : pour applis mobiles)</small>',
 	'default_user'			=> 'Nom de l’utilisateur par défaut <small>(16 caractères alphanumériques maximum)</small>',
 	'persona_connection_email'	=> 'Adresse courriel de connexion<br /><small>(pour <a href="https://persona.org/" rel="external">Mozilla Persona</a>)</small>',
 	'allow_anonymous'		=> 'Autoriser la lecture anonyme des articles de l’utilisateur par défaut (%s)',
 	'allow_anonymous_refresh'	=> 'Autoriser le rafraîchissement anonyme des flux',
+	'unsafe_autologin'		=> 'Autoriser les connexion automatiques non-sûres au format : ',
+	'api_enabled'			=> 'Autoriser l’accès par <abbr>API</abbr> <small>(nécessaire pour les applis mobiles)</small>',
 	'auth_token'			=> 'Jeton d’identification',
 	'explain_token'			=> 'Permet d’accéder à la sortie RSS de l’utilisateur par défaut sans besoin de s’authentifier.<br /><kbd>%s?output=rss&token=%s</kbd>',
 	'login_configuration'		=> 'Identification',
@@ -202,6 +213,7 @@ return array (
 	'purge_completed'		=> 'Purge effectuée (%d articles supprimés)',
 	'archiving_configuration_help'	=> 'D’autres options sont disponibles dans la configuration individuelle des flux',
 	'reading_configuration'		=> 'Lecture',
+	'display_configuration'		=> 'Affichage',
 	'articles_per_page'		=> 'Nombre d’articles par page',
 	'default_view'			=> 'Vue par défaut',
 	'sort_order'			=> 'Ordre de tri',
@@ -209,10 +221,11 @@ return array (
 	'display_articles_unfolded'	=> 'Afficher les articles dépliés par défaut',
 	'after_onread'			=> 'Après “marquer tout comme lu”,',
 	'jump_next'			=> 'sauter au prochain voisin non lu (flux ou catégorie)',
-	'reading_icons'			=> 'Icônes de lecture',
+	'article_icons'			=> 'Icônes d’article',
 	'top_line'			=> 'Ligne du haut',
 	'bottom_line'			=> 'Ligne du bas',
 	'img_with_lazyload'		=> 'Utiliser le mode “chargement différé” pour les images',
+	'sticky_post'			=> 'Aligner l’article en haut quand il est ouvert',
 	'auto_read_when'		=> 'Marquer un article comme lu…',
 	'article_selected'		=> 'lorsque l’article est sélectionné',
 	'article_open_on_website'	=> 'lorsque l’article est ouvert sur le site d’origine',
@@ -230,6 +243,7 @@ return array (
 	'more_information'		=> 'Plus d’informations',
 	'activate_sharing'		=> 'Activer le partage',
 	'shaarli'			=> 'Shaarli',
+	'blogotext'			=> 'Blogotext',
 	'wallabag'			=> 'wallabag',
 	'diaspora'			=> 'Diaspora*',
 	'twitter'			=> 'Twitter',

+ 4 - 1
app/layout/aside_configure.phtml

@@ -1,7 +1,10 @@
 <ul class="nav nav-list aside">
 	<li class="nav-header"><?php echo Minz_Translate::t ('configuration'); ?></li>
 	<li class="item<?php echo Minz_Request::actionName () == 'display' ? ' active' : ''; ?>">
-		<a href="<?php echo _url ('configure', 'display'); ?>"><?php echo Minz_Translate::t ('reading_configuration'); ?></a>
+		<a href="<?php echo _url ('configure', 'display'); ?>"><?php echo Minz_Translate::t ('display_configuration'); ?></a>
+	</li>
+	<li class="item<?php echo Minz_Request::actionName () == 'reading' ? ' active' : ''; ?>">
+		<a href="<?php echo _url ('configure', 'reading'); ?>"><?php echo Minz_Translate::t ('reading_configuration'); ?></a>
 	</li>
 	<li class="item<?php echo Minz_Request::actionName () == 'archiving' ? ' active' : ''; ?>">
 		<a href="<?php echo _url ('configure', 'archiving'); ?>"><?php echo Minz_Translate::t ('archiving_configuration'); ?></a>

+ 14 - 3
app/layout/aside_feed.phtml

@@ -20,9 +20,14 @@
 							<?php echo $cat->name (); ?>
 						</option>
 						<?php } ?>
+						<option value="nc"><?php echo Minz_Translate::t ('new_category'); ?></option>
 						</select>
 					</li>
 
+					<li class="input" style="display:none">
+						<input type="text" name="new_category[name]" id="new_category_name" autocomplete="off" placeholder="<?php echo Minz_Translate::t ('new_category'); ?>" />
+					</li>
+
 					<li class="separator"></li>
 
 					<li class="dropdown-header"><?php echo Minz_Translate::t ('http_authentication'); ?></li>
@@ -38,8 +43,14 @@
 		</div>
 	</form></li>
 
-	<li class="item<?php echo Minz_Request::actionName () == 'importExport' ? ' active' : ''; ?>">
-		<a href="<?php echo _url ('configure', 'importExport'); ?>"><?php echo Minz_Translate::t ('import_export_opml'); ?></a>
+	<li class="item">
+		<a onclick="return false;" href="javascript:(function(){var%20url%20=%20location.href;window.open('<?php echo Minz_Url::display(array('c' => 'feed', 'a' => 'add'), 'html', true); ?>&amp;url_rss='+encodeURIComponent(url), '_blank');})();">
+			<?php echo Minz_Translate::t('bookmark'); ?>
+		</a>
+	</li>
+
+	<li class="item<?php echo Minz_Request::controllerName () == 'importExport' ? ' active' : ''; ?>">
+		<a href="<?php echo _url ('importExport', 'index'); ?>"><?php echo Minz_Translate::t ('import_export'); ?></a>
 	</li>
 
 	<li class="item<?php echo Minz_Request::actionName () == 'categorize' ? ' active' : ''; ?>">
@@ -51,7 +62,7 @@
 	<?php if (!empty ($this->feeds)) { ?>
 	<?php foreach ($this->feeds as $feed) { ?>
 	<?php $nbEntries = $feed->nbEntries (); ?>
-	<li class="item<?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?><?php echo $nbEntries == 0 ? ' empty' : ''; ?>">
+	<li class="item<?php echo (isset($this->flux) && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?><?php echo $nbEntries == 0 ? ' empty' : ''; ?>">
 		<a href="<?php echo _url ('configure', 'feed', 'id', $feed->id ()); ?>">
 			<img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="✇" />
 			<?php echo $feed->name (); ?>

+ 2 - 2
app/layout/aside_flux.phtml

@@ -20,7 +20,7 @@
 			}
 		?>
 		<li>
-			<div class="category all">
+			<div class="category all<?php echo $this->get_c == 'a' ? ' active' : ''; ?>">
 				<a data-unread="<?php echo formatNumber($this->nb_not_read); ?>" class="btn<?php echo $this->get_c == 'a' ? ' active' : ''; ?>" href="<?php echo Minz_Url::display($arUrl); ?>">
 					<?php echo FreshRSS_Themes::icon('all'); ?>
 					<?php echo Minz_Translate::t ('main_stream'); ?>
@@ -29,7 +29,7 @@
 		</li>
 
 		<li>
-			<div class="category favorites">
+			<div class="category favorites<?php echo $this->get_c == 's' ? ' active' : ''; ?>">
 				<a data-unread="<?php echo formatNumber($this->nb_favorites['unread']); ?>" class="btn<?php echo $this->get_c == 's' ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 's'; echo Minz_Url::display($arUrl); ?>">
 					<?php echo FreshRSS_Themes::icon('bookmark'); ?>
 					<?php echo Minz_Translate::t('favorite_feeds', formatNumber($this->nb_favorites['all'])); ?>

+ 3 - 2
app/layout/header.phtml

@@ -67,7 +67,8 @@ if (Minz_Configuration::canLogIn()) {
 			<ul class="dropdown-menu">
 				<li class="dropdown-close"><a href="#close">❌</a></li>
 				<li class="dropdown-header"><?php echo Minz_Translate::t ('configuration'); ?></li>
-				<li class="item"><a href="<?php echo _url ('configure', 'display'); ?>"><?php echo Minz_Translate::t ('reading_configuration'); ?></a></li>
+				<li class="item"><a href="<?php echo _url ('configure', 'display'); ?>"><?php echo Minz_Translate::t ('display_configuration'); ?></a></li>
+				<li class="item"><a href="<?php echo _url ('configure', 'reading'); ?>"><?php echo Minz_Translate::t ('reading_configuration'); ?></a></li>
 				<li class="item"><a href="<?php echo _url ('configure', 'archiving'); ?>"><?php echo Minz_Translate::t ('archiving_configuration'); ?></a></li>
 				<li class="item"><a href="<?php echo _url ('configure', 'sharing'); ?>"><?php echo Minz_Translate::t ('sharing'); ?></a></li>
 				<li class="item"><a href="<?php echo _url ('configure', 'shortcut'); ?>"><?php echo Minz_Translate::t ('shortcuts'); ?></a></li>
@@ -75,8 +76,8 @@ if (Minz_Configuration::canLogIn()) {
 				<li class="item"><a href="<?php echo _url ('configure', 'users'); ?>"><?php echo Minz_Translate::t ('users'); ?></a></li>
 				<li class="separator"></li>
 				<li class="item"><a href="<?php echo _url ('index', 'stats'); ?>"><?php echo Minz_Translate::t ('stats'); ?></a></li>
-				<li class="item"><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Minz_Translate::t ('about'); ?></a></li>
 				<li class="item"><a href="<?php echo _url ('index', 'logs'); ?>"><?php echo Minz_Translate::t ('logs'); ?></a></li>
+				<li class="item"><a href="<?php echo _url ('index', 'about'); ?>"><?php echo Minz_Translate::t ('about'); ?></a></li>
 				<?php
 				if (Minz_Configuration::canLogIn()) {
 					?><li class="separator"></li><?php

+ 19 - 11
app/layout/layout.phtml

@@ -3,42 +3,50 @@
 	<head>
 		<meta charset="UTF-8" />
 		<meta name="viewport" content="initial-scale=1.0" />
-		<?php echo self::headTitle (); ?>
-		<?php echo self::headStyle (); ?>
-		<?php echo self::headScript (); ?>
+		<?php echo self::headTitle(); ?>
+		<?php echo self::headStyle(); ?>
+		<?php echo self::headScript(); ?>
 		<script>//<![CDATA[
-<?php $this->renderHelper ('javascript_vars'); ?>
+<?php $this->renderHelper('javascript_vars'); ?>
 		//]]></script>
 <?php
 	if (!empty($this->nextId)) {
-		$params = Minz_Request::params ();
+		$params = Minz_Request::params();
 		$params['next'] = $this->nextId;
 ?>
-		<link id="prefetch" rel="next prefetch" href="<?php echo Minz_Url::display (array ('c' => Minz_Request::controllerName (), 'a' => Minz_Request::actionName (), 'params' => $params)); ?>" />
+		<link id="prefetch" rel="next prefetch" href="<?php echo Minz_Url::display(array('c' => Minz_Request::controllerName(), 'a' => Minz_Request::actionName(), 'params' => $params)); ?>" />
 <?php } ?>
 		<link rel="shortcut icon" type="image/x-icon" sizes="16x16 64x64" href="<?php echo Minz_Url::display('/favicon.ico'); ?>" />
 		<link rel="icon msapplication-TileImage apple-touch-icon" type="image/png" sizes="256x256" href="<?php echo Minz_Url::display('/themes/icons/favicon-256.png'); ?>" />
-<?php if (isset ($this->rss_url)) { ?>
-		<link rel="alternate" type="application/rss+xml" title="<?php echo $this->rss_title; ?>" href="<?php echo Minz_Url::display ($this->rss_url); ?>" />
+<?php
+	if (isset($this->url)) {
+		$rss_url = $this->url;
+		$rss_url['params']['output'] = 'rss';
+?>
+		<link rel="alternate" type="application/rss+xml" title="<?php echo $this->rss_title; ?>" href="<?php echo Minz_Url::display($rss_url); ?>" />
 <?php } ?>
 		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('starred', true); ?>">
 		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('non-starred', true); ?>">
 		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('read', true); ?>">
 		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('unread', true); ?>">
+		<link rel="apple-touch-icon" href="<?php echo Minz_Url::display('/themes/icons/apple-touch-icon.png'); ?>">
+		<meta name="apple-mobile-web-app-capable" content="yes" />
+		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
+		<meta name="apple-mobile-web-app-title" content="<?php echo Minz_Configuration::title(); ?>">
 		<meta name="msapplication-TileColor" content="#FFF" />
 		<meta name="robots" content="noindex,nofollow" />
 	</head>
 	<body class="<?php echo Minz_Request::param('output', 'normal'); ?>">
-<?php $this->partial ('header'); ?>
+<?php $this->partial('header'); ?>
 
 <div id="global">
-	<?php $this->render (); ?>
+	<?php $this->render(); ?>
 </div>
 
 <?php
 	$msg = '';
 	$status = 'closed';
-	if (isset ($this->notification)) {
+	if (isset($this->notification)) {
 		$msg = $this->notification['content'];
 		$status = $this->notification['type'];
 

+ 108 - 84
app/layout/nav_menu.phtml

@@ -6,11 +6,81 @@
 	<a class="btn toggle_aside" href="#aside_flux"><?php echo FreshRSS_Themes::icon('category'); ?></a>
 	<?php } ?>
 
-	<?php if ($this->loginOk || Minz_Configuration::allowAnonymousRefresh()) { ?>
-	<a id="actualize" class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><?php echo FreshRSS_Themes::icon('refresh'); ?></a>
-	<?php } ?>
-
 	<?php if ($this->loginOk) { ?>
+	<?php $url_state = $this->url;
+		if ($this->state & FreshRSS_Entry::STATE_READ) {
+			$url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_READ;
+			$checked = 'true';
+			$class = 'active';
+		} else {
+			$url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_READ;
+			$checked = 'false';
+			$class = '';
+		}
+	?>
+	<div class="stick">
+		<a id="toggle-read"
+		   class="btn <?php echo $class; ?>"
+		   aria-checked="<?php echo $checked; ?>"
+		   href="<?php echo Minz_Url::display ($url_state); ?>"
+		   title="<?php echo Minz_Translate::t ('show_read'); ?>">
+			<?php echo FreshRSS_Themes::icon('read'); ?>
+		</a>
+		<?php
+			if ($this->state & FreshRSS_Entry::STATE_NOT_READ) {
+				$url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_NOT_READ;
+				$checked = 'true';
+				$class = 'active';
+			} else {
+				$url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_NOT_READ;
+				$checked = 'false';
+				$class = '';
+			}
+		?>
+		<a id="toggle-unread"
+		   class="btn <?php echo $class; ?>"
+		   aria-checked="<?php echo $checked; ?>"
+		   href="<?php echo Minz_Url::display ($url_state); ?>"
+		   title="<?php echo Minz_Translate::t ('show_not_reads'); ?>">
+			<?php echo FreshRSS_Themes::icon('unread'); ?>
+		</a>
+		<?php
+			if ($this->state & FreshRSS_Entry::STATE_FAVORITE) {
+				$url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_FAVORITE;
+				$checked = 'true';
+				$class = 'active';
+			} else {
+				$url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_FAVORITE;
+				$checked = 'false';
+				$class = '';
+			}
+		?>
+		<a id="toggle-favorite"
+		   class="btn <?php echo $class; ?>"
+		   aria-checked="<?php echo $checked; ?>"
+		   href="<?php echo Minz_Url::display ($url_state); ?>"
+		   title="<?php echo Minz_Translate::t ('show_favorite'); ?>">
+			<?php echo FreshRSS_Themes::icon('starred'); ?>
+		</a>
+		<?php
+			if ($this->state & FreshRSS_Entry::STATE_NOT_FAVORITE) {
+				$url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_NOT_FAVORITE;
+				$checked = 'true';
+				$class = 'active';
+			} else {
+				$url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_NOT_FAVORITE;
+				$checked = 'false';
+				$class = '';
+			}
+		?>
+		<a id="toggle-not-favorite"
+		   class="btn <?php echo $class; ?>"
+		   aria-checked="<?php echo $checked; ?>"
+		   href="<?php echo Minz_Url::display ($url_state); ?>"
+		   title="<?php echo Minz_Translate::t ('show_not_favorite'); ?>">
+			<?php echo FreshRSS_Themes::icon('non-starred'); ?>
+		</a>
+	</div>
 	<?php
 		$get = false;
 		$string_mark = Minz_Translate::t ('mark_all_read');
@@ -61,8 +131,12 @@
 					break;
 			}
 		}
-		$p = isset($this->entries[0]) ? $this->entries[0] : null;
-		$idMax = $p === null ? '0' : $p->id();
+		if ($this->order === 'ASC') {
+			$idMax = 0;
+		} else {
+			$p = isset($this->entries[0]) ? $this->entries[0] : null;
+			$idMax = $p === null ? '0' : $p->id();
+		}
 
 		$arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('get' => $get, 'nextGet' => $nextGet, 'idMax' => $idMax));
 		$output = Minz_Request::param('output', '');
@@ -82,7 +156,7 @@
 			<ul class="dropdown-menu">
 				<li class="dropdown-close"><a href="#close">❌</a></li>
 
-				<li class="item"><a href="<?php echo $markReadUrl; ?>"><?php echo $string_mark; ?></a></li> 
+				<li class="item"><a href="<?php echo $markReadUrl; ?>"><?php echo $string_mark; ?></a></li>
 				<li class="separator"></li>
 <?php
 	$today = $this->today;
@@ -95,17 +169,6 @@
 	</div>
 	<?php } ?>
 
-	<?php
-		$params = Minz_Request::params ();
-		if (isset ($params['search'])) {
-			$params['search'] = urlencode ($params['search']);
-		}
-		$url = array (
-			'c' => 'index',
-			'a' => 'index',
-			'params' => $params
-		);
-	?>
 	<div class="dropdown" id="nav_menu_views">
 		<div id="dropdown-views" class="dropdown-target"></div>
 		<a class="dropdown-toggle btn" href="#dropdown-views"><?php echo Minz_Translate::t ('display'); ?> <?php echo FreshRSS_Themes::icon('down'); ?></a>
@@ -113,7 +176,7 @@
 			<li class="dropdown-close"><a href="#close">❌</a></li>
 
 			<?php
-				$url_output = $url;
+				$url_output = $this->url;
 				if ($actual_view !== 'normal') { ?>
 			<li class="item">
 				<?php $url_output['params']['output'] = 'normal'; ?>
@@ -136,71 +199,6 @@
 				</a>
 			</li>
 			<?php } ?>
-
-			<li class="separator"></li>
-
-			<?php
-				$url_state = $url;
-				$url_state['params']['state'] = 'all';
-			?>
-			<li class="item" role="checkbox" aria-checked="<?php echo ($this->state === 'all') ? 'true' :'false'; ?>">
-				<a class="print_all" href="<?php echo Minz_Url::display ($url_state); ?>">
-					<?php echo Minz_Translate::t ('show_all_articles'); ?>
-				</a>
-			</li>
-			<?php
-				$url_state['params']['state'] = 'not_read';
-			?>
-			<li class="item" role="checkbox" aria-checked="<?php echo ($this->state === 'not_read') ? 'true' :'false'; ?>">
-				<a class="print_non_read" href="<?php echo Minz_Url::display ($url_state); ?>">
-					<?php echo Minz_Translate::t ('show_not_reads'); ?>
-				</a>
-			</li>
-			<?php
-				$url_state['params']['state'] = 'read';
-			?>
-			<li class="item" role="checkbox" aria-checked="<?php echo ($this->state === 'read') ? 'true' :'false'; ?>">
-				<a class="print_read" href="<?php echo Minz_Url::display ($url_state); ?>">
-					<?php echo Minz_Translate::t ('show_read'); ?>
-				</a>
-			</li>
-			<?php
-				$url_state['params']['state'] = 'favorite';
-			?>
-			<li class="item" role="checkbox" aria-checked="<?php echo ($this->state === 'favorite') ? 'true' :'false'; ?>">
-				<a class="print_favorite" href="<?php echo Minz_Url::display ($url_state); ?>">
-					<?php echo Minz_Translate::t ('show_favorite'); ?>
-				</a>
-			</li>
-
-			<li class="separator"></li>
-
-			<li class="item">
-				<?php
-					$url_order = $url;
-					if ($this->order === 'DESC') {
-						$url_order['params']['order'] = 'ASC';
-				?>
-				<a href="<?php echo Minz_Url::display ($url_order); ?>">
-					<?php echo Minz_Translate::t ('older_first'); ?>
-				</a>
-				<?php
-					} else {
-						$url_order['params']['order'] = 'DESC';
-				?>
-				<a href="<?php echo Minz_Url::display ($url_order); ?>">
-					<?php echo Minz_Translate::t ('newer_first'); ?>
-				</a>
-				<?php } ?>
-			</li>
-
-			<li class="separator"></li>
-
-			<li class="item">
-				<a class="view_rss" target="_blank" href="<?php echo Minz_Url::display ($this->rss_url); ?>">
-					<?php echo Minz_Translate::t ('rss_view'); ?>
-				</a>
-			</li>
 		</ul>
 	</div>
 
@@ -225,4 +223,30 @@
 			<?php } ?>
 		</form>
 	</div>
+	
+	<?php
+		if ($this->order === 'DESC') {
+			$order = 'ASC';
+			$icon = 'up';
+			$title = 'older_first';
+		} else {
+			$order = 'DESC';
+			$icon = 'down';
+			$title = 'newer_first';
+		}
+		$url_order = $this->url;
+		$url_order['params']['order'] = $order;
+	?>
+	<a class="btn" href="<?php echo Minz_Url::display ($url_order); ?>" title="<?php echo Minz_Translate::t ($title); ?>">
+		<?php echo FreshRSS_Themes::icon($icon); ?>
+	</a>
+
+	<?php $url_output['params']['output'] = 'rss'; ?>
+	<a class="btn view_rss" target="_blank" href="<?php echo Minz_Url::display ($url_output); ?>" title="<?php echo Minz_Translate::t ('rss_view'); ?>">
+		<?php echo FreshRSS_Themes::icon('rss'); ?>
+	</a>
+	
+	<?php if ($this->loginOk || Minz_Configuration::allowAnonymousRefresh()) { ?>
+	<a id="actualize" class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><?php echo FreshRSS_Themes::icon('refresh'); ?></a>
+	<?php } ?>
 </div>

+ 2 - 2
app/views/configure/categorize.phtml

@@ -17,11 +17,11 @@
 				<input type="text" id="cat_<?php echo $cat->id (); ?>" name="categories[]" value="<?php echo $cat->name (); ?>" />
 
 				<?php if ($cat->nbFeed () > 0) { ?>
-				<a class="confirm" href="<?php echo _url ('feed', 'delete', 'id', $cat->id (), 'type', 'category'); ?>"><?php echo Minz_Translate::t ('ask_empty'); ?></a>
+				<button type="submit" class="btn btn-attention confirm" formaction="<?php echo _url ('feed', 'delete', 'id', $cat->id (), 'type', 'category'); ?>"><?php echo Minz_Translate::t ('ask_empty'); ?></button>
 				<?php } ?>
 				(<?php echo Minz_Translate::t ('number_feeds', $cat->nbFeed ()); ?>)
 
-				<?php if ($cat->id () == $this->defaultCategory->id ()) { ?>
+				<?php if ($cat->id () === $this->defaultCategory->id ()) { ?>
 				<?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t ('can_not_be_deleted'); ?>
 				<?php } ?>
 

+ 2 - 116
app/views/configure/display.phtml

@@ -4,7 +4,7 @@
 	<a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a>
 
 	<form method="post" action="<?php echo _url ('configure', 'display'); ?>">
-		<legend><?php echo Minz_Translate::t ('theme'); ?></legend>
+		<legend><?php echo Minz_Translate::t ('display_configuration'); ?></legend>
 
 		<div class="form-group">
 			<label class="group-name" for="language"><?php echo Minz_Translate::t ('language'); ?></label>
@@ -35,122 +35,8 @@
 			</div>
 		</div>
 
-		<div class="form-group form-actions">
-			<div class="group-controls">
-				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('save'); ?></button>
-				<button type="reset" class="btn"><?php echo Minz_Translate::t ('cancel'); ?></button>
-			</div>
-		</div>
-
-		<legend><?php echo Minz_Translate::t ('reading_configuration'); ?></legend>
-
-		<div class="form-group">
-			<label class="group-name" for="posts_per_page"><?php echo Minz_Translate::t ('articles_per_page'); ?></label>
-			<div class="group-controls">
-				<input type="number" id="posts_per_page" name="posts_per_page" value="<?php echo $this->conf->posts_per_page; ?>" />
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label class="group-name" for="sort_order"><?php echo Minz_Translate::t ('sort_order'); ?></label>
-			<div class="group-controls">
-				<select name="sort_order" id="sort_order">
-					<option value="DESC"<?php echo $this->conf->sort_order === 'DESC' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('newer_first'); ?></option>
-					<option value="ASC"<?php echo $this->conf->sort_order === 'ASC' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('older_first'); ?></option>
-				</select>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label class="group-name" for="view_mode"><?php echo Minz_Translate::t ('default_view'); ?></label>
-			<div class="group-controls">
-				<select name="view_mode" id="view_mode">
-					<option value="normal"<?php echo $this->conf->view_mode === 'normal' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('normal_view'); ?></option>
-					<option value="reader"<?php echo $this->conf->view_mode === 'reader' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('reader_view'); ?></option>
-					<option value="global"<?php echo $this->conf->view_mode === 'global' ? ' selected="selected"' : ''; ?>><?php echo Minz_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->default_view === 'all' ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('show_all_articles'); ?>
-				</label>
-				<label class="radio" for="radio_not_read">
-					<input type="radio" name="default_view" id="radio_not_read" value="not_read"<?php echo $this->conf->default_view === 'not_read' ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('show_not_reads'); ?>
-				</label>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<div class="group-controls">
-				<label class="checkbox" for="auto_load_more">
-					<input type="checkbox" name="auto_load_more" id="auto_load_more" value="1"<?php echo $this->conf->auto_load_more ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('auto_load_more'); ?>
-					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
-				</label>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<div class="group-controls">
-				<label class="checkbox" for="display_posts">
-					<input type="checkbox" name="display_posts" id="display_posts" value="1"<?php echo $this->conf->display_posts ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('display_articles_unfolded'); ?>
-					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
-				</label>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<div class="group-controls">
-				<label class="checkbox" for="lazyload">
-					<input type="checkbox" name="lazyload" id="lazyload" value="1"<?php echo $this->conf->lazyload ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('img_with_lazyload'); ?>
-					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
-				</label>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label class="group-name"><?php echo Minz_Translate::t ('auto_read_when'); ?></label>
-			<div class="group-controls">
-				<label class="checkbox" for="check_open_article">
-					<input type="checkbox" name="mark_open_article" id="check_open_article" value="1"<?php echo $this->conf->mark_when['article'] ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('article_selected'); ?>
-				</label>
-				<label class="checkbox" for="check_open_site">
-					<input type="checkbox" name="mark_open_site" id="check_open_site" value="1"<?php echo $this->conf->mark_when['site'] ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('article_open_on_website'); ?>
-				</label>
-				<label class="checkbox" for="check_scroll">
-					<input type="checkbox" name="mark_scroll" id="check_scroll" value="1"<?php echo $this->conf->mark_when['scroll'] ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('scroll'); ?>
-				</label>
-				<label class="checkbox" for="check_reception">
-					<input type="checkbox" name="mark_upon_reception" id="check_reception" value="1"<?php echo $this->conf->mark_when['reception'] ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('upon_reception'); ?>
-				</label>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label class="group-name"><?php echo Minz_Translate::t ('after_onread'); ?></label>
-			<div class="group-controls">
-				<label class="checkbox" for="onread_jump_next">
-					<input type="checkbox" name="onread_jump_next" id="onread_jump_next" value="1"<?php echo $this->conf->onread_jump_next ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('jump_next'); ?>
-				</label>
-			</div>
-		</div>
-
-		<div class="form-group form-actions">
-			<div class="group-controls">
-				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('save'); ?></button>
-				<button type="reset" class="btn"><?php echo Minz_Translate::t ('cancel'); ?></button>
-			</div>
-		</div>
-
-		<legend><?php echo Minz_Translate::t ('reading_icons'); ?></legend>
 		<div class="form-group">
+			<label class="group-name" for="theme"><?php echo Minz_Translate::t ('article_icons'); ?></label>
 			<table>
 				<thead>
 					<tr>

+ 0 - 40
app/views/configure/importExport.phtml

@@ -1,40 +0,0 @@
-<?php
-require_once(LIB_PATH . '/lib_opml.php');
-if ($this->req == 'export') {
-	echo '<?xml version="1.0" encoding="UTF-8" ?>';
-?>
-<!-- Generated by <?php echo Minz_Configuration::title (); ?> -->
-<opml version="2.0">
-	<head>
-		<title><?php echo Minz_Configuration::title (); ?> OPML Feed</title>
-		<dateCreated><?php echo date('D, d M Y H:i:s'); ?></dateCreated>
-	</head>
-	<body>
-<?php echo opml_export ($this->categories); ?>
-	</body>
-</opml>
-<?php } else { ?>
-<?php $this->partial ('aside_feed'); ?>
-
-<div class="post ">
-	<a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a>
-
-	<form method="post" action="<?php echo Minz_Url::display (array ('c' => 'configure', 'a' => 'importExport', 'params' => array ('q' => 'import'))); ?>" enctype="multipart/form-data">
-		<legend><?php echo Minz_Translate::t ('import_export_opml'); ?></legend>
-		<div class="form-group">
-			<label class="group-name" for="file"><?php echo Minz_Translate::t ('file_to_import'); ?></label>
-			<div class="group-controls">
-				<input type="file" name="file" id="file" />
-			</div>
-		</div>
-
-		<div class="form-group form-actions">
-			<div class="group-controls">
-				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('import'); ?></button>
-				<?php echo Minz_Translate::t ('or'); ?>
-				<a target="_blank" class="btn btn-important" href="<?php echo _url ('configure', 'importExport', 'q', 'export'); ?>"><?php echo Minz_Translate::t ('export'); ?></a>
-			</div>
-		</div>
-	</form>
-</div>
-<?php } ?>

+ 125 - 0
app/views/configure/reading.phtml

@@ -0,0 +1,125 @@
+<?php $this->partial ('aside_configure'); ?>
+
+<div class="post">
+	<a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a>
+
+	<form method="post" action="<?php echo _url ('configure', 'reading'); ?>">
+		<legend><?php echo Minz_Translate::t ('reading_configuration'); ?></legend>
+
+		<div class="form-group">
+			<label class="group-name" for="posts_per_page"><?php echo Minz_Translate::t ('articles_per_page'); ?></label>
+			<div class="group-controls">
+				<input type="number" id="posts_per_page" name="posts_per_page" value="<?php echo $this->conf->posts_per_page; ?>" />
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="sort_order"><?php echo Minz_Translate::t ('sort_order'); ?></label>
+			<div class="group-controls">
+				<select name="sort_order" id="sort_order">
+					<option value="DESC"<?php echo $this->conf->sort_order === 'DESC' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('newer_first'); ?></option>
+					<option value="ASC"<?php echo $this->conf->sort_order === 'ASC' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('older_first'); ?></option>
+				</select>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="view_mode"><?php echo Minz_Translate::t ('default_view'); ?></label>
+			<div class="group-controls">
+				<select name="view_mode" id="view_mode">
+					<option value="normal"<?php echo $this->conf->view_mode === 'normal' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('normal_view'); ?></option>
+					<option value="reader"<?php echo $this->conf->view_mode === 'reader' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('reader_view'); ?></option>
+					<option value="global"<?php echo $this->conf->view_mode === 'global' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('global_view'); ?></option>
+				</select>
+				<label class="radio" for="radio_all">
+					<input type="radio" name="default_view" id="radio_all" value="<?php echo FreshRSS_Entry::STATE_ALL; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_ALL ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('show_all_articles'); ?>
+				</label>
+				<label class="radio" for="radio_not_read">
+					<input type="radio" name="default_view" id="radio_not_read" value="<?php echo FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_NOT_READ ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('show_not_reads'); ?>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="auto_load_more">
+					<input type="checkbox" name="auto_load_more" id="auto_load_more" value="1"<?php echo $this->conf->auto_load_more ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('auto_load_more'); ?>
+					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="display_posts">
+					<input type="checkbox" name="display_posts" id="display_posts" value="1"<?php echo $this->conf->display_posts ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('display_articles_unfolded'); ?>
+					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="lazyload">
+					<input type="checkbox" name="lazyload" id="lazyload" value="1"<?php echo $this->conf->lazyload ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('img_with_lazyload'); ?>
+					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="sticky_post">
+					<input type="checkbox" name="sticky_post" id="sticky_post" value="1"<?php echo $this->conf->sticky_post ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('sticky_post'); ?>
+					<noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name"><?php echo Minz_Translate::t ('auto_read_when'); ?></label>
+			<div class="group-controls">
+				<label class="checkbox" for="check_open_article">
+					<input type="checkbox" name="mark_open_article" id="check_open_article" value="1"<?php echo $this->conf->mark_when['article'] ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('article_selected'); ?>
+				</label>
+				<label class="checkbox" for="check_open_site">
+					<input type="checkbox" name="mark_open_site" id="check_open_site" value="1"<?php echo $this->conf->mark_when['site'] ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('article_open_on_website'); ?>
+				</label>
+				<label class="checkbox" for="check_scroll">
+					<input type="checkbox" name="mark_scroll" id="check_scroll" value="1"<?php echo $this->conf->mark_when['scroll'] ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('scroll'); ?>
+				</label>
+				<label class="checkbox" for="check_reception">
+					<input type="checkbox" name="mark_upon_reception" id="check_reception" value="1"<?php echo $this->conf->mark_when['reception'] ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('upon_reception'); ?>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name"><?php echo Minz_Translate::t ('after_onread'); ?></label>
+			<div class="group-controls">
+				<label class="checkbox" for="onread_jump_next">
+					<input type="checkbox" name="onread_jump_next" id="onread_jump_next" value="1"<?php echo $this->conf->onread_jump_next ? ' checked="checked"' : ''; ?> />
+					<?php echo Minz_Translate::t ('jump_next'); ?>
+				</label>
+			</div>
+		</div>
+
+		<div class="form-group form-actions">
+			<div class="group-controls">
+				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('save'); ?></button>
+				<button type="reset" class="btn"><?php echo Minz_Translate::t ('cancel'); ?></button>
+			</div>
+		</div>
+
+	</form>
+</div>

+ 31 - 44
app/views/configure/sharing.phtml

@@ -3,54 +3,41 @@
 <div class="post">
 	<a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a>
 
-	<form method="post" action="<?php echo _url ('configure', 'sharing'); ?>">
+	<form method="post" action="<?php echo _url ('configure', 'sharing'); ?>"
+		data-simple='<div class="form-group"><label class="group-name">##label##</label><div class="group-controls"><a href="#" class="share remove"><?php echo FreshRSS_Themes::icon('close'); ?></a>
+			<input type="hidden" id="share_##key##_type" name="share[##key##][type]" value="##type##" /></div></div>'
+		data-advanced='<div class="form-group"><label class="group-name">##label##</label><div class="group-controls"><a href="#" class="share remove"><?php echo FreshRSS_Themes::icon('close'); ?></a>
+			<input type="hidden" id="share_##key##_type" name="share[##key##][type]" value="##type##" />
+			<input type="text" id="share_##key##_name" name="share[##key##][name]" class="extend" value="" placeholder="<?php echo Minz_Translate::t ('share_name'); ?>" size="64" />
+			<input type="url" id="share_##key##_url" name="share[##key##][url]" class="extend" value="" placeholder="<?php echo Minz_Translate::t ('share_url'); ?>" size="64" />
+			<?php echo FreshRSS_Themes::icon('help'); ?> <a target="_blank" href="##help##"><?php echo Minz_Translate::t ('more_information'); ?></a></div></div>'>
 		<legend><?php echo Minz_Translate::t ('sharing'); ?></legend>
-		<div class="form-group">
-			<label class="group-name" for="shaarli">
-				<?php echo Minz_Translate::t ('your_shaarli'); ?>
-			</label>
-			<div class="group-controls">
-				<input type="url" id="shaarli" name="shaarli" class="extend" value="<?php echo $this->conf->sharing ('shaarli'); ?>" placeholder="<?php echo Minz_Translate::t ('blank_to_disable'); ?>" size="64" />
-
-				<?php echo FreshRSS_Themes::icon('help'); ?> <a target="_blank" href="http://sebsauvage.net/wiki/doku.php?id=php:shaarli"><?php echo Minz_Translate::t ('more_information'); ?></a>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label class="group-name" for="wallabag">
-				<?php echo Minz_Translate::t ('your_wallabag'); ?>
-			</label>
-			<div class="group-controls">
-				<input type="url" id="wallabag" name="wallabag" class="extend" value="<?php echo $this->conf->sharing ('wallabag'); ?>" placeholder="<?php echo Minz_Translate::t ('blank_to_disable'); ?>" size="64" />
-
-				<?php echo FreshRSS_Themes::icon('help'); ?> <a target="_blank" href="http://www.wallabag.org"><?php echo Minz_Translate::t ('more_information'); ?></a>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label class="group-name" for="diaspora">
-				<?php echo Minz_Translate::t ('your_diaspora_pod'); ?>
-			</label>
-			<div class="group-controls">
-				<input type="url" id="diaspora" name="diaspora" class="extend" value="<?php echo $this->conf->sharing ('diaspora'); ?>" placeholder="<?php echo Minz_Translate::t ('blank_to_disable'); ?>" size="64" />
-
-				<?php echo FreshRSS_Themes::icon('help'); ?> <a target="_blank" href="https://diasporafoundation.org/"><?php echo Minz_Translate::t ('more_information'); ?></a>
+		<?php foreach ($this->conf->sharing as $key => $sharing): ?>
+			<?php $share = $this->conf->shares[$sharing['type']]; ?>
+			<div class="form-group">
+				<label class="group-name">
+					<?php echo Minz_Translate::t ($sharing['type']); ?>
+				</label>
+				<div class="group-controls">
+					<a href='#' class='share remove'><?php echo FreshRSS_Themes::icon('close'); ?></a>
+					<input type='hidden' id='share_<?php echo $key;?>_type' name="share[<?php echo $key;?>][type]" value='<?php echo $sharing['type']?>' />
+					<?php if ($share['form'] === 'advanced'):?>
+						<input type="text" id="share_<?php echo $key;?>_name" name="share[<?php echo $key;?>][name]" class="extend" value="<?php echo $sharing['name']?>" placeholder="<?php echo Minz_Translate::t ('share_name'); ?>" size="64" />
+						<input type="url" id="share_<?php echo $key;?>_url" name="share[<?php echo $key;?>][url]" class="extend" value="<?php echo $sharing['url']?>" placeholder="<?php echo Minz_Translate::t ('share_url'); ?>" size="64" />
+						<?php echo FreshRSS_Themes::icon('help'); ?> <a target="_blank" href="<?php echo $share['help']?>"><?php echo Minz_Translate::t ('more_information'); ?></a>
+					<?php endif;?>
+				</div>
 			</div>
-		</div>
+		<?php endforeach;?>
 
-		<div class="form-group">
-			<label class="group-name"><?php echo Minz_Translate::t ('activate_sharing'); ?></label>
+		<div class="form-group form-actions">
 			<div class="group-controls">
-				<?php
-					$services = array ('twitter', 'g+', 'facebook', 'email', 'print');
-
-					foreach ($services as $service) {
-				?>
-				<label class="checkbox" for="<?php echo $service; ?>">
-					<input type="checkbox" name="<?php echo $service; ?>" id="<?php echo $service; ?>" value="1"<?php echo $this->conf->sharing($service) ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ($service); ?>
-				</label>
-				<?php } ?>
+				<a href='#' class='share add'><?php echo FreshRSS_Themes::icon('add'); ?></a>
+				<select>
+					<?php foreach($this->conf->shares as $key => $params):?>
+						<option value='<?php echo $key?>' data-form='<?php echo $params['form']?>' data-help='<?php if (!empty($params['help'])) {echo $params['help'];}?>'><?php echo Minz_Translate::t($key) ?></option>
+					<?php endforeach; ?>
+				</select>
 			</div>
 		</div>
 

+ 8 - 1
app/views/configure/shortcut.phtml

@@ -12,7 +12,7 @@
 	<?php $s = $this->conf->shortcuts; ?>
 
 	<form method="post" action="<?php echo _url ('configure', 'shortcut'); ?>">
-		<legend><?php echo Minz_Translate::t ('shortcuts_management'); ?></legend>
+		<legend><?php echo Minz_Translate::t ('shortcuts'); ?></legend>
 
 		<noscript><p class="alert alert-error"><?php echo Minz_Translate::t ('javascript_for_shortcuts'); ?></p></noscript>
 
@@ -96,6 +96,13 @@
 			</div>
 		</div>
 
+		<div class="form-group">
+			<label class="group-name" for="focus_search_shortcut"><?php echo Minz_Translate::t ('focus_search'); ?></label>
+			<div class="group-controls">
+				<input type="text" id="focus_search_shortcut" name="shortcuts[focus_search]" list="keys" value="<?php echo $s['focus_search']; ?>" />
+			</div>
+		</div>
+
 		<div class="form-group form-actions">
 			<div class="group-controls">
 				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('save'); ?></button>

+ 36 - 3
app/views/configure/users.phtml

@@ -20,11 +20,22 @@
 		<div class="form-group">
 			<label class="group-name" for="passwordPlain"><?php echo Minz_Translate::t('password_form'); ?></label>
 			<div class="group-controls">
-				<input type="password" id="passwordPlain" name="passwordPlain" autocomplete="off" pattern=".{7,}" />
+				<input type="password" id="passwordPlain" name="passwordPlain" autocomplete="off" pattern=".{7,}" <?php echo cryptAvailable() ? '' : 'disabled="disabled" '; ?>/>
+				<a class="btn toggle-password"/><?php echo FreshRSS_Themes::icon('key'); ?></a>
 				<noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript>
 			</div>
 		</div>
 
+		<?php if (Minz_Configuration::apiEnabled()) { ?>
+		<div class="form-group">
+			<label class="group-name" for="apiPasswordPlain"><?php echo Minz_Translate::t('password_api'); ?></label>
+			<div class="group-controls">
+				<input type="password" id="apiPasswordPlain" name="apiPasswordPlain" autocomplete="off" pattern=".{7,}" <?php echo cryptAvailable() ? '' : 'disabled="disabled" '; ?>/>
+				<noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript>
+			</div>
+		</div>
+		<?php } ?>
+
 		<div class="form-group">
 			<label class="group-name" for="mail_login"><?php echo Minz_Translate::t('persona_connection_email'); ?></label>
 			<?php $mail = $this->conf->mail_login; ?>
@@ -52,7 +63,7 @@
 					<?php if (!in_array(Minz_Configuration::authType(), array('form', 'persona', 'http_auth', 'none'))) { ?>
 						<option selected="selected"></option>
 					<?php } ?>
-					<option value="form"<?php echo Minz_Configuration::authType() === 'form' ? ' selected="selected"' : '', version_compare(PHP_VERSION, '5.3', '<') ? ' disabled="disabled"' : ''; ?>><?php echo Minz_Translate::t('auth_form'); ?></option>
+					<option value="form"<?php echo Minz_Configuration::authType() === 'form' ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"'; ?>><?php echo Minz_Translate::t('auth_form'); ?></option>
 					<option value="persona"<?php echo Minz_Configuration::authType() === 'persona' ? ' selected="selected"' : '', $this->conf->mail_login == '' ? ' disabled="disabled"' : ''; ?>><?php echo Minz_Translate::t('auth_persona'); ?></option>
 					<option value="http_auth"<?php echo Minz_Configuration::authType() === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>><?php echo Minz_Translate::t('http_auth'); ?> (REMOTE_USER = '<?php echo httpAuthUser(); ?>')</option>
 					<option value="none"<?php echo Minz_Configuration::authType() === 'none' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t('auth_none'); ?></option>
@@ -80,18 +91,39 @@
 			</div>
 		</div>
 
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="unsafe_autologin">
+					<input type="checkbox" name="unsafe_autologin" id="unsafe_autologin" value="1"<?php echo Minz_Configuration::unsafeAutologinEnabled() ? ' checked="checked"' : '',
+						Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
+					<?php echo Minz_Translate::t('unsafe_autologin'); ?>
+					<kbd>p/i/?a=formLogin&amp;u=Alice&amp;p=1234</kbd>
+				</label>
+			</div>
+		</div>
+
 		<?php if (Minz_Configuration::canLogIn()) { ?>
 		<div class="form-group">
 			<label class="group-name" for="token"><?php echo Minz_Translate::t('auth_token'); ?></label>
 			<?php $token = $this->conf->token; ?>
 			<div class="group-controls">
-				<input type="text" id="token" name="token" value="<?php echo $token; ?>"  placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>"<?php
+				<input type="text" id="token" name="token" value="<?php echo $token; ?>" placeholder="<?php echo Minz_Translate::t('blank_to_disable'); ?>"<?php
 					echo Minz_Configuration::canLogIn() ? '' : ' disabled="disabled"'; ?> />
 				<?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('explain_token', Minz_Url::display(null, 'html', true), $token); ?>
 			</div>
 		</div>
 		<?php } ?>
 
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="api_enabled">
+					<input type="checkbox" name="api_enabled" id="api_enabled" value="1"<?php echo Minz_Configuration::apiEnabled() ? ' checked="checked"' : '',
+						Minz_Configuration::needsLogin() ? '' : ' disabled="disabled"'; ?> />
+					<?php echo Minz_Translate::t('api_enabled'); ?>
+				</label>
+			</div>
+		</div>
+
 		<div class="form-group form-actions">
 			<div class="group-controls">
 				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t('save'); ?></button>
@@ -147,6 +179,7 @@
 			<label class="group-name" for="new_user_passwordPlain"><?php echo Minz_Translate::t('password_form'); ?></label>
 			<div class="group-controls">
 				<input type="password" id="new_user_passwordPlain" name="new_user_passwordPlain" autocomplete="off" pattern=".{7,}" />
+				<a class="btn toggle-password"/><?php echo FreshRSS_Themes::icon('key'); ?></a>
 				<noscript><b><?php echo Minz_Translate::t('javascript_should_be_activated'); ?></b></noscript>
 			</div>
 		</div>

+ 91 - 0
app/views/feed/add.phtml

@@ -0,0 +1,91 @@
+<?php if ($this->feed) { ?>
+<div class="post">
+	<h1><?php echo Minz_Translate::t ('add_rss_feed'); ?></h1>
+
+	<?php if (!$this->load_ok) { ?>
+	<p class="alert alert-error"><span class="alert-head"><?php echo Minz_Translate::t('damn'); ?></span> <?php echo Minz_Translate::t('internal_problem_feed', _url('index', 'logs')); ?></p>
+	<?php } ?>
+
+	<form method="post" action="<?php echo _url('feed', 'add'); ?>" autocomplete="off">
+		<legend><?php echo Minz_Translate::t('informations'); ?></legend>
+		<?php if ($this->load_ok) { ?>
+		<div class="form-group">
+			<label class="group-name"><?php echo Minz_Translate::t('title'); ?></label>
+			<div class="group-controls">
+				<label><?php echo $this->feed->name() ; ?></label>
+			</div>
+		</div>
+
+		<?php $desc = $this->feed->description(); if ($desc != '') { ?>
+		<div class="form-group">
+			<label class="group-name"><?php echo Minz_Translate::t('feed_description'); ?></label>
+			<div class="group-controls">
+				<label><?php echo htmlspecialchars($desc, ENT_NOQUOTES, 'UTF-8'); ?></label>
+			</div>
+		</div>
+		<?php } ?>
+
+		<div class="form-group">
+			<label class="group-name"><?php echo Minz_Translate::t('website_url'); ?></label>
+			<div class="group-controls">
+				<label>
+				<?php echo $this->feed->website(); ?>
+				<a target="_blank" href="<?php echo $this->feed->website(); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a>
+				</label>
+			</div>
+		</div>
+		<?php } ?>
+
+		<div class="form-group">
+			<label class="group-name" for="url"><?php echo Minz_Translate::t('feed_url'); ?></label>
+			<div class="group-controls">
+				<input type="text" name="url_rss" id="url" class="extend" value="<?php echo $this->feed->url(); ?>" />
+				<a target="_blank" href="<?php echo $this->feed->url(); ?>"><?php echo FreshRSS_Themes::icon('link'); ?></a>
+				  <a class="btn" target="_blank" href="http://validator.w3.org/feed/check.cgi?url=<?php echo $this->feed->url(); ?>"><?php echo Minz_Translate::t('feed_validator'); ?></a>
+			</div>
+		</div>
+		<div class="form-group">
+			<label class="group-name" for="category"><?php echo Minz_Translate::t('category'); ?></label>
+			<div class="group-controls">
+				<select name="category" id="category">
+					<?php foreach ($this->categories as $cat) { ?>
+					<option value="<?php echo $cat->id(); ?>"<?php echo $cat->id() == 1 ? ' selected="selected"' : ''; ?>>
+						<?php echo $cat->name(); ?>
+					</option>
+					<?php } ?>
+					<option value="nc"><?php echo Minz_Translate::t('new_category'); ?></option>
+				</select>
+
+				<span style="display: none;">
+					<input type="text" name="new_category[name]" id="new_category_name" autocomplete="off" placeholder="<?php echo Minz_Translate::t('new_category'); ?>" />
+				</span>
+			</div>
+		</div>
+
+		<legend><?php echo Minz_Translate::t('http_authentication'); ?></legend>
+		<?php $auth = $this->feed->httpAuth(false); ?>
+		<div class="form-group">
+			<label class="group-name" for="http_user"><?php echo Minz_Translate::t('http_username'); ?></label>
+			<div class="group-controls">
+				<input type="text" name="http_user" id="http_user" class="extend" value="<?php echo $auth['username']; ?>" autocomplete="off" />
+			</div>
+
+			<label class="group-name" for="http_pass"><?php echo Minz_Translate::t('http_password'); ?></label>
+			<div class="group-controls">
+				<input type="password" name="http_pass" id="http_pass" class="extend" value="<?php echo $auth['password']; ?>" autocomplete="off" />
+			</div>
+
+			<div class="group-controls">
+				<?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('access_protected_feeds'); ?>
+			</div>
+		</div>
+
+		<div class="form-group form-actions">
+			<div class="group-controls">
+				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t('save'); ?></button>
+				<button type="reset" class="btn"><?php echo Minz_Translate::t('cancel'); ?></button>
+			</div>
+		</div>
+	</form>
+</div>
+<?php } ?>

+ 47 - 0
app/views/helpers/export/articles.phtml

@@ -0,0 +1,47 @@
+<?php
+    $username = Minz_Session::param('currentUser', '_');
+
+    $articles = array(
+        'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
+        'title' => $this->list_title,
+        'author' => $username,
+        'items' => array()
+    );
+
+    foreach ($this->entries as $entry) {
+        if (!isset($this->feed)) {
+            $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed ());
+        } else {
+            $feed = $this->feed;
+        }
+
+        $articles['items'][] = array(
+            'id' => $entry->guid(),
+            'categories' => array_values($entry->tags()),
+            'title' => $entry->title(),
+            'author' => $entry->author(),
+            'published' => $entry->date(true),
+            'updated' => $entry->date(true),
+            'alternate' => array(array(
+                'href' => $entry->link(),
+                'type' => 'text/html'
+            )),
+            'content' => array(
+                'content' => $entry->content()
+            ),
+            'origin' => array(
+                'streamId' => $feed->id(),
+                'title' => $feed->name(),
+                'htmlUrl' => $feed->website(),
+                'feedUrl' => $feed->url()
+            )
+        );
+    }
+
+    $options = 0;
+    if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
+        $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
+    }
+
+    echo json_encode($articles, $options);
+?>

+ 28 - 0
app/views/helpers/export/opml.phtml

@@ -0,0 +1,28 @@
+<?php
+
+$opml_array = array(
+	'head' => array(
+		'title' => Minz_Configuration::title(),
+		'dateCreated' => date('D, d M Y H:i:s')
+	),
+	'body' => array()
+);
+
+foreach ($this->categories as $key => $cat) {
+	$opml_array['body'][$key] = array(
+		'text' => $cat['name'],
+		'@outlines' => array()
+	);
+
+	foreach ($cat['feeds'] as $feed) {
+		$opml_array['body'][$key]['@outlines'][] = array(
+			'text' => htmlspecialchars_decode($feed->name()),
+			'type' => 'rss',
+			'xmlUrl' => $feed->url(),
+			'htmlUrl' => $feed->website(),
+			'description' => $feed->description()
+		);
+	}
+}
+
+echo libopml_render($opml_array);

+ 5 - 2
app/views/helpers/javascript_vars.phtml

@@ -5,12 +5,14 @@ echo '"use strict";', "\n";
 $mark = $this->conf->mark_when;
 echo 'var ',
 	'hide_posts=', ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'false' : 'true',
+	',display_order="', Minz_Request::param('order', $this->conf->sort_order), '"',
 	',auto_mark_article=', $mark['article'] ? 'true' : 'false',
 	',auto_mark_site=', $mark['site'] ? 'true' : 'false',
 	',auto_mark_scroll=', $mark['scroll'] ? 'true' : 'false',
 	',auto_load_more=', $this->conf->auto_load_more ? 'true' : 'false',
 	',full_lazyload=', $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'true' : 'false',
-	',does_lazyload=', $this->conf->lazyload ? 'true' : 'false';
+	',does_lazyload=', $this->conf->lazyload ? 'true' : 'false',
+	',sticky_post=', $this->conf->sticky_post ? 'true' : 'false';
 
 $s = $this->conf->shortcuts;
 echo ',shortcuts={',
@@ -23,7 +25,8 @@ echo ',shortcuts={',
 	'last_entry:"', $s['last_entry'], '",',
 	'collapse_entry:"', $s['collapse_entry'], '",',
 	'load_more:"', $s['load_more'], '",',
-	'auto_share:"', $s['auto_share'], '"',
+	'auto_share:"', $s['auto_share'], '",',
+	'focus_search:"', $s['focus_search'], '"',
 "},\n";
 
 if (Minz_Request::param ('output') === 'global') {

+ 12 - 65
app/views/helpers/view/normal_view.phtml

@@ -8,19 +8,10 @@ if (!empty($this->entries)) {
 	$display_yesterday = true;
 	$display_others = true;
 	if ($this->loginOk) {
-		$shaarli = $this->conf->sharing ('shaarli');
-		$wallabag = $this->conf->sharing ('wallabag');
-		$diaspora = $this->conf->sharing ('diaspora');
+		$sharing = $this->conf->sharing;
 	} else {
-		$shaarli = '';
-		$wallabag = '';
-		$diaspora = '';
+		$sharing = array();
 	}
-	$twitter = $this->conf->sharing ('twitter');
-	$google_plus = $this->conf->sharing ('g+');
-	$facebook = $this->conf->sharing ('facebook');
-	$email = $this->conf->sharing ('email');
-	$print = $this->conf->sharing ('print');
 	$hidePosts = !$this->conf->display_posts;
 	$lazyload = $this->conf->lazyload;
 	$topline_read = $this->conf->topline_read;
@@ -29,9 +20,7 @@ if (!empty($this->entries)) {
 	$topline_link = $this->conf->topline_link;
 	$bottomline_read = $this->conf->bottomline_read;
 	$bottomline_favorite = $this->conf->bottomline_favorite;
-	$bottomline_sharing = $this->conf->bottomline_sharing && (
-		$shaarli || $wallabag || $diaspora || $twitter ||
-		$google_plus || $facebook || $email || $print);
+	$bottomline_sharing = $this->conf->bottomline_sharing && (count($sharing));
 	$bottomline_tags = $this->conf->bottomline_tags;
 	$bottomline_date = $this->conf->bottomline_date;
 	$bottomline_link = $this->conf->bottomline_link;
@@ -39,7 +28,7 @@ if (!empty($this->entries)) {
 
 <div id="stream" class="normal<?php echo $hidePosts ? ' hide_posts' : ''; ?>"><?php
 	?><div id="new-article">
-		<a href="<?php echo _url('index', 'index'); ?>"><?php echo Minz_Translate::t ('new_article'); ?></a>
+		<a href="<?php echo Minz_Url::display ($this->url); ?>"><?php echo Minz_Translate::t ('new_article'); ?></a>
 	</div><?php
 	foreach ($this->entries as $item) {
 		if ($display_today && $item->isDay (FreshRSS_Days::TODAY, $this->today)) {
@@ -99,7 +88,7 @@ if (!empty($this->entries)) {
 
 		<div class="flux_content">
 			<div class="content">
-				<h1 class="title"><?php echo $item->title (); ?></h1>
+				<h1 class="title"><a target="_blank" href="<?php echo $item->link (); ?>"><?php echo $item->title (); ?></a></h1>
 				<?php
 					$author = $item->author ();
 					echo $author != '' ? '<div class="author">' . Minz_Translate::t ('by_author', $author) . '</div>' : '';
@@ -146,55 +135,13 @@ if (!empty($this->entries)) {
 
 						<ul class="dropdown-menu">
 							<li class="dropdown-close"><a href="#close">❌</a></li>
-							<?php if ($shaarli) { ?>
-							<li class="item share">
-								<a target="_blank" href="<?php echo $shaarli . '?post=' . $link . '&amp;title=' . $title . '&amp;source=FreshRSS'; ?>">
-									<?php echo Minz_Translate::t ('shaarli'); ?>
-								</a>
-							</li>
-							<?php } if ($wallabag) { ?>
-							<li class="item share">
-								<a target="_blank" href="<?php echo $wallabag . '?action=add&amp;url=' . base64_encode (urldecode($link)); ?>">
-									<?php echo Minz_Translate::t ('wallabag'); ?>
-								</a>
-							</li>
-							<?php } if ($diaspora) { ?>
-							<li class="item share">
-								<a target="_blank" href="<?php echo $diaspora . '/bookmarklet?url=' . $link . '&amp;title=' . $title; ?>">
-									<?php echo Minz_Translate::t ('diaspora'); ?>
-								</a>
-							</li>
-							<?php } if ($twitter) { ?>
-							<li class="item share">
-								<a target="_blank" href="https://twitter.com/share?url=<?php echo $link; ?>&amp;text=<?php echo $title; ?>">
-									<?php echo Minz_Translate::t ('twitter'); ?>
-								</a>
-							</li>
-							<?php } if ($google_plus) { ?>
-							<li class="item share">
-								<a target="_blank" href="https://plus.google.com/share?url=<?php echo $link; ?>">
-									<?php echo Minz_Translate::t ('g+'); ?>
-								</a>
-							</li>
-							<?php } if ($facebook) { ?>
-							<li class="item share">
-								<a target="_blank" href="https://www.facebook.com/sharer.php?u=<?php echo $link; ?>&amp;t=<?php echo $title; ?>">
-									<?php echo Minz_Translate::t ('facebook'); ?>
-								</a>
-							</li>
-							<?php } if ($email) { ?>
-							<li class="item share">
-								<a href="mailto:?subject=<?php echo urldecode($title); ?>&amp;body=<?php echo $link; ?>">
-									<?php echo Minz_Translate::t ('by_email'); ?>
-								</a>
-							</li>
-							<?php } if ($print) { ?>
-							<li class="item share">
-								<a href="#" class="print-article">
-									<?php echo Minz_Translate::t ('print'); ?>
-								</a>
-							</li>
-							<?php } ?>
+							<?php foreach ($sharing as $share) :?>
+								<li class="item share">
+									<a target="_blank" href="<?php echo FreshRSS_Share::generateUrl($this->conf->shares, $share, $item->link(), $item->title() . ' . ' . $feed->name())?>">
+										<?php echo Minz_Translate::t ($share['name']);?>
+									</a>
+								</li>
+							<?php endforeach;?>
 						</ul>
 					</div>
 					<?php } ?>

+ 1 - 1
app/views/helpers/view/rss_view.phtml

@@ -6,7 +6,7 @@
 		<description><?php echo Minz_Translate::t ('rss_feeds_of', $this->rss_title); ?></description>
 		<pubDate><?php echo date('D, d M Y H:i:s O'); ?></pubDate>
 		<lastBuildDate><?php echo gmdate('D, d M Y H:i:s'); ?> GMT</lastBuildDate>
-		<atom:link href="<?php echo Minz_Url::display ($this->rss_url, 'html', true); ?>" rel="self" type="application/rss+xml" />
+		<atom:link href="<?php echo Minz_Url::display ($this->url, 'html', true); ?>" rel="self" type="application/rss+xml" />
 <?php
 foreach ($this->entries as $item) {
 ?>

+ 52 - 0
app/views/importExport/index.phtml

@@ -0,0 +1,52 @@
+<?php $this->partial ('aside_feed'); ?>
+
+<div class="post ">
+	<a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a>
+
+	<form method="post" action="<?php echo _url('importExport', 'import'); ?>" enctype="multipart/form-data">
+		<legend><?php echo Minz_Translate::t ('import'); ?></legend>
+		<div class="form-group">
+			<label class="group-name" for="file"><?php echo Minz_Translate::t ('file_to_import'); ?></label>
+			<div class="group-controls">
+				<input type="file" name="file" id="file" />
+			</div>
+		</div>
+
+		<div class="form-group form-actions">
+			<div class="group-controls">
+				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('import'); ?></button>
+			</div>
+		</div>
+	</form>
+
+	<?php if (count($this->feeds) > 0) { ?>
+	<form method="post" action="<?php echo _url('importExport', 'export'); ?>">
+		<legend><?php echo Minz_Translate::t ('export'); ?></legend>
+		<div class="form-group">
+			<div class="group-controls">
+				<label class="checkbox" for="export_opml">
+					<input type="checkbox" name="export_opml" id="export_opml" value="1" checked="checked" />
+					<?php echo Minz_Translate::t ('export_opml'); ?>
+				</label>
+
+				<label class="checkbox" for="export_starred">
+					<input type="checkbox" name="export_starred" id="export_starred" value="1" checked="checked" />
+					<?php echo Minz_Translate::t ('export_starred'); ?>
+				</label>
+
+				<select name="export_feeds[]" size="<?php echo min(10, count($this->feeds)); ?>" multiple="multiple">
+					<?php foreach ($this->feeds as $feed) { ?>
+					<option value="<?php echo $feed->id(); ?>"><?php echo $feed->name(); ?></option>
+					<?php } ?>
+				</select>
+			</div>
+		</div>
+
+		<div class="form-group form-actions">
+			<div class="group-controls">
+				<button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('export'); ?></button>
+			</div>
+		</div>
+	</form>
+	<?php } ?>
+</div>

+ 4 - 2
app/views/index/index.phtml

@@ -3,12 +3,14 @@
 $output = Minz_Request::param ('output', 'normal');
 
 if ($this->loginOk || Minz_Configuration::allowAnonymous()) {
-	if ($output === 'rss') {
-		$this->renderHelper ('view/rss_view');
+	if ($output === 'normal') {
+		$this->renderHelper ('view/normal_view');
 	} elseif ($output === 'reader') {
 		$this->renderHelper ('view/reader_view');
 	} elseif ($output === 'global') {
 		$this->renderHelper ('view/global_view');
+	} elseif ($output === 'rss') {
+		$this->renderHelper ('view/rss_view');
 	} else {
 		Minz_Request::_param ('output', 'normal');
 		$output = 'normal';

+ 3 - 0
constants.php

@@ -2,6 +2,9 @@
 define('FRESHRSS_VERSION', '0.8-dev');
 define('FRESHRSS_WEBSITE', 'http://freshrss.org');
 
+// PHP text output compression http://php.net/ob_gzhandler (better to do it at Web server level)
+define('PHP_COMPRESSION', false);
+
 // Constantes de chemins
 define('FRESHRSS_PATH', dirname(__FILE__));
 

+ 75 - 0
data/shares.php

@@ -0,0 +1,75 @@
+<?php
+
+/*
+ * This is a configuration file. You shouldn't modify it unless you know what
+ * you are doing. If you want to add a share type, this is where you need to do
+ * it.
+ * 
+ * For each share there is different configuration options. Here is the description
+ * of those options:
+ *   - url is a mandatory option. It is a string representing the share URL. It
+ *     supports 3 different placeholders for custom data. The ~URL~ placeholder
+ *     represents the URL of the system used to share, it is configured by the
+ *     user. The ~LINK~ placeholder represents the link of the shared article.
+ *     The ~TITLE~ placeholder represents the title of the shared article.
+ *   - transform is an array of transformation to apply on links and titles
+ *   - help is a URL to a help page
+ */
+
+return array(
+	'shaarli' => array(
+		'url' => '~URL~?post=~LINK~&amp;title=~TITLE~&amp;source=FreshRSS',
+		'transform' => array('urlencode'),
+		'help' => 'http://sebsauvage.net/wiki/doku.php?id=php:shaarli',
+		'form' => 'advanced',
+	),
+	'blogotext' => array(
+		'url' => '~URL~/admin/links.php?url=~LINK~',
+		'transform' => array(),
+		'help' => 'http://lehollandaisvolant.net/blogotext/fr/',
+		'form' => 'advanced',
+	),
+	'wallabag' => array(
+		'url' => '~URL~?action=add&amp;url=~LINK~',
+		'transform' => array(
+			'link' => array('base64_encode'),
+			'title' => array(),
+		),
+		'help' => 'http://www.wallabag.org/',
+		'form' => 'advanced',
+	),
+	'diaspora' => array(
+		'url' => '~URL~/bookmarklet?url=~LINK~&amp;title=~TITLE~',
+		'transform' => array('urlencode'),
+		'help' => 'https://diasporafoundation.org/',
+		'form' => 'advanced',
+	),
+	'twitter' => array(
+		'url' => 'https://twitter.com/share?url=~LINK~&amp;text=~TITLE~',
+		'transform' => array('urlencode'),
+		'form' => 'simple',
+	),
+	'g+' => array(
+		'url' => 'https://plus.google.com/share?url=~LINK~',
+		'transform' => array('urlencode'),
+		'form' => 'simple',
+	),
+	'facebook' => array(
+		'url' => 'https://www.facebook.com/sharer.php?u=~LINK~&amp;t=~TITLE~',
+		'transform' => array('urlencode'),
+		'form' => 'simple',
+	),
+	'email' => array(
+		'url' => 'mailto:?subject=~TITLE~&amp;body=~LINK~',
+		'transform' => array(
+			'link' => array('urlencode'),
+			'title' => array(),
+		),
+		'form' => 'simple',
+	),
+	'print' => array(
+		'url' => '#',
+		'transform' => array(),
+		'form' => 'simple',
+	),
+);

+ 1 - 5
lib/Minz/ActionController.php

@@ -8,16 +8,12 @@
  * La classe ActionController représente le contrôleur de l'application
  */
 class Minz_ActionController {
-	protected $router;
 	protected $view;
 
 	/**
 	 * Constructeur
-	 * @param $controller nom du controller
-	 * @param $action nom de l'action à lancer
 	 */
-	public function __construct ($router) {
-		$this->router = $router;
+	public function __construct () {
 		$this->view = new Minz_View ();
 		$this->view->attributeParams ();
 	}

+ 0 - 116
lib/Minz/Cache.php

@@ -1,116 +0,0 @@
-<?php
-/** 
- * MINZ - Copyright 2011 Marien Fressinaud
- * Sous licence AGPL3 <http://www.gnu.org/licenses/>
-*/
-
-/**
- * La classe Cache permet de gérer facilement les pages en cache
- */
-class Minz_Cache {
-	/**
-	 * $expire timestamp auquel expire le cache de $url
-	 */
-	private $expire = 0;
-
-	/**
-	 * $file est le nom du fichier de cache
-	 */
-	private $file = '';
-
-	/**
-	 * $enabled permet de déterminer si le cache est activé
-	 */
-	private static $enabled = true;
-
-	/**
-	 * Constructeur
-	 */
-	public function __construct () {
-		$this->_fileName ();
-		$this->_expire ();
-	}
-
-	/**
-	 * Setteurs
-	 */
-	public function _fileName () {
-		$file = md5 (Minz_Request::getURI ());
-
-		$this->file = CACHE_PATH . '/'.$file;
-	}
-
-	public function _expire () {
-		if ($this->exist ()) {
-			$this->expire = filemtime ($this->file)
-			              + Minz_Configuration::delayCache ();
-		}
-	}
-
-	/**
-	 * Permet de savoir si le cache est activé
-	 * @return true si activé, false sinon
-	 */
-	public static function isEnabled () {
-		return Minz_Configuration::cacheEnabled () && self::$enabled;
-	}
-
-	/**
-	 * Active / désactive le cache
-	 */
-	public static function switchOn () {
-		self::$enabled = true;
-	}
-	public static function switchOff () {
-		self::$enabled = false;
-	}
-
-	/**
-	 * Détermine si le cache de $url a expiré ou non
-	 * @return true si il a expiré, false sinon
-	 */
-	public function expired () {
-		return time () > $this->expire;
-	}
-
-	/**
-	 * Affiche le contenu du cache
-	 * @print le code html du cache
-	 */
-	public function render () {
-		if ($this->exist ()) {
-			include ($this->file);
-		}
-	}
-
-	/**
-	 * Enregistre $html en cache
-	 * @param $html le html à mettre en cache
-	 */
-	public function cache ($html) {
-		file_put_contents ($this->file, $html);
-	}
-
-	/**
-	 * Permet de savoir si le cache existe
-	 * @return true si il existe, false sinon
-	 */
-	public function exist () {
-		return file_exists ($this->file);
-	}
-
-	/**
-	 * Nettoie le cache en supprimant tous les fichiers
-	 */
-	public static function clean () {
-		$files = opendir (CACHE_PATH);
-
-		while ($fic = readdir ($files)) {
-			if ($fic != '.' && $fic != '..') {
-				unlink (CACHE_PATH.'/'.$fic);
-			}
-		}
-
-		closedir ($files);
-	}
-}

+ 29 - 31
lib/Minz/Configuration.php

@@ -30,12 +30,9 @@ class Minz_Configuration {
 	 * définition des variables de configuration
 	 * $salt une chaîne de caractères aléatoires (obligatoire)
 	 * $environment gère le niveau d'affichage pour log et erreurs
-	 * $use_url_rewriting indique si on utilise l'url_rewriting
 	 * $base_url le chemin de base pour accéder à l'application
 	 * $title le nom de l'application
 	 * $language la langue par défaut de l'application
-	 * $cacheEnabled permet de savoir si le cache doit être activé
-	 * $delayCache la limite de cache
 	 * $db paramètres pour la base de données (tableau)
 	 *     - host le serveur de la base
 	 *     - user nom d'utilisateur
@@ -45,15 +42,14 @@ class Minz_Configuration {
 	private static $salt = '';
 	private static $environment = Minz_Configuration::PRODUCTION;
 	private static $base_url = '';
-	private static $use_url_rewriting = false;
 	private static $title = '';
 	private static $language = 'en';
-	private static $cache_enabled = false;
-	private static $delay_cache = 3600;
 	private static $default_user = '';
 	private static $allow_anonymous = false;
 	private static $allow_anonymous_refresh = false;
 	private static $auth_type = 'none';
+	private static $api_enabled = false;
+	private static $unsafe_autologin_enabled = false;
 
 	private static $db = array (
 		'type' => 'mysql',
@@ -92,21 +88,12 @@ class Minz_Configuration {
 	public static function baseUrl () {
 		return self::$base_url;
 	}
-	public static function useUrlRewriting () {
-		return self::$use_url_rewriting;
-	}
 	public static function title () {
 		return self::$title;
 	}
 	public static function language () {
 		return self::$language;
 	}
-	public static function cacheEnabled () {
-		return self::$cache_enabled;
-	}
-	public static function delayCache () {
-		return self::$delay_cache;
-	}
 	public static function dataBase () {
 		return self::$db;
 	}
@@ -131,6 +118,12 @@ class Minz_Configuration {
 	public static function canLogIn() {
 		return self::$auth_type === 'form' || self::$auth_type === 'persona';
 	}
+	public static function apiEnabled() {
+		return self::$api_enabled;
+	}
+	public static function unsafeAutologinEnabled() {
+		return self::$unsafe_autologin_enabled;
+	}
 
 	public static function _allowAnonymous($allow = false) {
 		self::$allow_anonymous = ((bool)$allow) && self::canLogIn();
@@ -151,6 +144,13 @@ class Minz_Configuration {
 		self::_allowAnonymous(self::$allow_anonymous);
 	}
 
+	public static function _enableApi($value = false) {
+		self::$api_enabled = (bool)$value;
+	}
+	public static function _enableAutologin($value = false) {
+		self::$unsafe_autologin_enabled = (bool)$value;
+	}
+
 	/**
 	 * Initialise les variables de configuration
 	 * @exception Minz_FileNotExistException si le CONF_PATH_NAME n'existe pas
@@ -171,7 +171,6 @@ class Minz_Configuration {
 		$ini_array = array(
 			'general' => array(
 				'environment' => self::environment(true),
-				'use_url_rewriting' => self::$use_url_rewriting,
 				'salt' => self::$salt,
 				'base_url' => self::$base_url,
 				'title' => self::$title,
@@ -179,6 +178,8 @@ class Minz_Configuration {
 				'allow_anonymous' => self::$allow_anonymous,
 				'allow_anonymous_refresh' => self::$allow_anonymous_refresh,
 				'auth_type' => self::$auth_type,
+				'api_enabled' => self::$api_enabled,
+				'unsafe_autologin_enabled' => self::$unsafe_autologin_enabled,
 			),
 			'db' => self::$db,
 		);
@@ -255,9 +256,6 @@ class Minz_Configuration {
 		if (isset ($general['base_url'])) {
 			self::$base_url = $general['base_url'];
 		}
-		if (isset ($general['use_url_rewriting'])) {
-			self::$use_url_rewriting = $general['use_url_rewriting'];
-		}
 
 		if (isset ($general['title'])) {
 			self::$title = $general['title'];
@@ -265,18 +263,6 @@ class Minz_Configuration {
 		if (isset ($general['language'])) {
 			self::$language = $general['language'];
 		}
-		if (isset ($general['cache_enabled'])) {
-			self::$cache_enabled = $general['cache_enabled'];
-			if (CACHE_PATH === false && self::$cache_enabled) {
-				throw new FileNotExistException (
-					'CACHE_PATH',
-					Minz_Exception::ERROR
-				);
-			}
-		}
-		if (isset ($general['delay_cache'])) {
-			self::$delay_cache = inval($general['delay_cache']);
-		}
 		if (isset ($general['default_user'])) {
 			self::$default_user = $general['default_user'];
 		}
@@ -295,6 +281,18 @@ class Minz_Configuration {
 				($general['allow_anonymous_refresh'] !== 'no')
 			);
 		}
+		if (isset ($general['api_enabled'])) {
+			self::$api_enabled = (
+				((bool)($general['api_enabled'])) &&
+				($general['api_enabled'] !== 'no')
+			);
+		}
+		if (isset ($general['unsafe_autologin_enabled'])) {
+			self::$unsafe_autologin_enabled = (
+				((bool)($general['unsafe_autologin_enabled'])) &&
+				($general['unsafe_autologin_enabled'] !== 'no')
+			);
+		}
 
 		// Base de données
 		if (isset ($ini_array['db'])) {

+ 38 - 70
lib/Minz/Dispatcher.php

@@ -14,85 +14,55 @@ class Minz_Dispatcher {
 
 	/* singleton */
 	private static $instance = null;
+	private static $needsReset;
 
-	private $router;
 	private $controller;
 
 	/**
 	 * Récupère l'instance du Dispatcher
 	 */
-	public static function getInstance ($router) {
+	public static function getInstance () {
 		if (self::$instance === null) {
-			self::$instance = new Minz_Dispatcher ($router);
+			self::$instance = new Minz_Dispatcher ();
 		}
 		return self::$instance;
 	}
 
-	/**
-	 * Constructeur
-	 */
-	private function __construct ($router) {
-		$this->router = $router;
-	}
-
 	/**
 	 * Lance le controller indiqué dans Request
 	 * Remplit le body de Response à partir de la Vue
 	 * @exception Minz_Exception
 	 */
-	public function run ($ob = true) {
-		$cache = new Minz_Cache();
-		// Le ob_start est dupliqué : sans ça il y a un bug sous Firefox
-		// ici on l'appelle avec 'ob_gzhandler', après sans.
-		// Vraisemblablement la compression fonctionne mais c'est sale
-		// J'ignore les effets de bord :(
-		if ($ob) {
-			ob_start ('ob_gzhandler');
-		}
+	public function run () {
+		do {
+			self::$needsReset = false;
 
-		if (Minz_Cache::isEnabled () && !$cache->expired ()) {
-			if ($ob) {
-				ob_start ();
-			}
-			$cache->render ();
-			if ($ob) {
-				$text = ob_get_clean();
-			}
-		} else {
-			$text = '';	//TODO: Clean this code
-			while (Minz_Request::$reseted) {
-				Minz_Request::$reseted = false;
-
-				try {
-					$this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');
-					$this->controller->init ();
-					$this->controller->firstAction ();
+			try {
+				$this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');
+				$this->controller->init ();
+				$this->controller->firstAction ();
+				if (!self::$needsReset) {
 					$this->launchAction (
 						Minz_Request::actionName ()
 						. 'Action'
 					);
-					$this->controller->lastAction ();
-
-					if (!Minz_Request::$reseted) {
-						if ($ob) {
-							ob_start ();
-						}
-						$this->controller->view ()->build ();
-						if ($ob) {
-							$text = ob_get_clean();
-						}
-					}
-				} catch (Minz_Exception $e) {
-					throw $e;
 				}
-			}
+				$this->controller->lastAction ();
 
-			if (Minz_Cache::isEnabled ()) {
-				$cache->cache ($text);
+				if (!self::$needsReset) {
+					$this->controller->view ()->build ();
+				}
+			} catch (Minz_Exception $e) {
+				throw $e;
 			}
-		}
+		} while (self::$needsReset);
+	}
 
-		Minz_Response::setBody ($text);
+	/**
+	 * Informe le contrôleur qu'il doit recommancer car la requête a été modifiée
+	 */
+	public static function reset() {
+		self::$needsReset = true;
 	}
 
 	/**
@@ -112,7 +82,7 @@ class Minz_Dispatcher {
 				Minz_Exception::ERROR
 			);
 		}
-		$this->controller = new $controller_name ($this->router);
+		$this->controller = new $controller_name ();
 
 		if (! ($this->controller instanceof Minz_ActionController)) {
 			throw new Minz_ControllerNotActionControllerException (
@@ -129,21 +99,19 @@ class Minz_Dispatcher {
 	 *  le controller
 	 */
 	private function launchAction ($action_name) {
-		if (!Minz_Request::$reseted) {
-			if (!is_callable (array (
-				$this->controller,
-				$action_name
-			))) {
-				throw new Minz_ActionException (
-					get_class ($this->controller),
-					$action_name,
-					Minz_Exception::ERROR
-				);
-			}
-			call_user_func (array (
-				$this->controller,
-				$action_name
-			));
+		if (!is_callable (array (
+			$this->controller,
+			$action_name
+		))) {
+			throw new Minz_ActionException (
+				get_class ($this->controller),
+				$action_name,
+				Minz_Exception::ERROR
+			);
 		}
+		call_user_func (array (
+			$this->controller,
+			$action_name
+		));
 	}
 }

+ 24 - 8
lib/Minz/Error.php

@@ -23,13 +23,32 @@ class Minz_Error {
 		$logs = self::processLogs ($logs);
 		$error_filename = APP_PATH . '/Controllers/errorController.php';
 
+		switch ($code) {
+			case 200 :
+				header('HTTP/1.1 200 OK');
+				break;
+			case 403 :
+				header('HTTP/1.1 403 Forbidden');
+				break;
+			case 404 :
+				header('HTTP/1.1 404 Not Found');
+				break;
+			case 500 :
+				header('HTTP/1.1 500 Internal Server Error');
+				break;
+			case 503 :
+				header('HTTP/1.1 503 Service Unavailable');
+				break;
+			default :
+				header('HTTP/1.1 500 Internal Server Error');
+		}
+
 		if (file_exists ($error_filename)) {
 			$params = array (
 				'code' => $code,
 				'logs' => $logs
 			);
 
-			Minz_Response::setHeader ($code);
 			if ($redirect) {
 				Minz_Request::forward (array (
 					'c' => 'error'
@@ -41,19 +60,16 @@ class Minz_Error {
 				), false);
 			}
 		} else {
-			$text = '<h1>An error occured</h1>'."\n";
+			echo '<h1>An error occured</h1>' . "\n";
 
 			if (!empty ($logs)) {
-				$text .= '<ul>'."\n";
+				echo '<ul>' . "\n";
 				foreach ($logs as $log) {
-					$text .= '<li>' . $log . '</li>'."\n";
+					echo '<li>' . $log . '</li>' . "\n";
 				}
-				$text .= '</ul>'."\n";
+				echo '</ul>' . "\n";
 			}
 
-			Minz_Response::setHeader ($code);
-			Minz_Response::setBody ($text);
-			Minz_Response::send ();
 			exit ();
 		}
 	}

+ 33 - 26
lib/Minz/FrontController.php

@@ -24,13 +24,10 @@
  */
 class Minz_FrontController {
 	protected $dispatcher;
-	protected $router;
-
-	private $useOb = true;
 
 	/**
 	 * Constructeur
-	 * Initialise le router et le dispatcher
+	 * Initialise le dispatcher, met à jour la Request
 	 */
 	public function __construct () {
 		if (LOG_PATH === false) {
@@ -42,29 +39,50 @@ class Minz_FrontController {
 
 			Minz_Request::init ();
 
-			$this->router = new Minz_Router ();
-			$this->router->init ();
-		} catch (Minz_RouteNotFoundException $e) {
-			Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
-			Minz_Error::error (
-				404,
-				array ('error' => array ($e->getMessage ()))
+			$url = $this->buildUrl();
+			$url['params'] = array_merge (
+				$url['params'],
+				Minz_Request::fetchPOST ()
 			);
+			Minz_Request::forward ($url);
 		} catch (Minz_Exception $e) {
 			Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
 			$this->killApp ($e->getMessage ());
 		}
 
-		$this->dispatcher = Minz_Dispatcher::getInstance ($this->router);
+		$this->dispatcher = Minz_Dispatcher::getInstance();
 	}
 
 	/**
-	 * Démarre l'application (lance le dispatcher et renvoie la réponse
+	 * Retourne un tableau représentant l'url passée par la barre d'adresses
+	 * @return tableau représentant l'url
+	 */
+	private function buildUrl() {
+		$url = array ();
+
+		$url['c'] = Minz_Request::fetchGET (
+			'c',
+			Minz_Request::defaultControllerName ()
+		);
+		$url['a'] = Minz_Request::fetchGET (
+			'a',
+			Minz_Request::defaultActionName ()
+		);
+		$url['params'] = Minz_Request::fetchGET ();
+
+		// post-traitement
+		unset ($url['params']['c']);
+		unset ($url['params']['a']);
+
+		return $url;
+	}
+
+	/**
+	 * Démarre l'application (lance le dispatcher et renvoie la réponse)
 	 */
 	public function run () {
 		try {
-			$this->dispatcher->run ($this->useOb);
-			Minz_Response::send ();
+			$this->dispatcher->run();
 		} catch (Minz_Exception $e) {
 			try {
 				Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
@@ -96,15 +114,4 @@ class Minz_FrontController {
 		}
 		exit ('### Application problem ###<br />'."\n".$txt);
 	}
-
-	public function useOb() {
-		return $this->useOb;
-	}
-
-	/**
-	 * Use ob_start('ob_gzhandler') or not.
-	 */
-	public function _useOb($ob) {
-		return $this->useOb = (bool)$ob;
-	}
 }

+ 17 - 0
lib/Minz/Log.php

@@ -80,4 +80,21 @@ class Minz_Log {
 		self::record($msg_get, Minz_Log::DEBUG, $file_name);
 		self::record($msg_post, Minz_Log::DEBUG, $file_name);
 	}
+
+	/**
+	 * Some helpers to Minz_Log::record() method
+	 * Parameters are the same of those of the record() method.
+	 */
+	public static function debug($msg, $file_name = null) {
+		self::record($msg, Minz_Log::DEBUG, $file_name);
+	}
+	public static function notice($msg, $file_name = null) {
+		self::record($msg, Minz_Log::NOTICE, $file_name);
+	}
+	public static function warning($msg, $file_name = null) {
+		self::record($msg, Minz_Log::WARNING, $file_name);
+	}
+	public static function error($msg, $file_name = null) {
+		self::record($msg, Minz_Log::ERROR, $file_name);
+	}
 }

+ 1 - 4
lib/Minz/Request.php

@@ -15,8 +15,6 @@ class Minz_Request {
 	private static $default_controller_name = 'index';
 	private static $default_action_name = 'index';
 
-	public static $reseted = true;
-
 	/**
 	 * Getteurs
 	 */
@@ -137,14 +135,13 @@ class Minz_Request {
 			header ('Location: ' . Minz_Url::display ($url, 'php'));
 			exit ();
 		} else {
-			self::$reseted = true;
-
 			self::_controllerName ($url['c']);
 			self::_actionName ($url['a']);
 			self::_params (array_merge (
 				self::$params,
 				$url['params']
 			));
+			Minz_Dispatcher::reset();
 		}
 	}
 

+ 0 - 60
lib/Minz/Response.php

@@ -1,60 +0,0 @@
-<?php
-/** 
- * MINZ - Copyright 2011 Marien Fressinaud
- * Sous licence AGPL3 <http://www.gnu.org/licenses/>
-*/
-
-/**
- * Response représente la requête http renvoyée à l'utilisateur
- */
-class Minz_Response {
-	private static $header = 'HTTP/1.0 200 OK';
-	private static $body = '';
-	
-	/**
-	 * Mets à jour le body de la Response
-	 * @param $text le texte à incorporer dans le body
-	 */
-	public static function setBody ($text) {
-		self::$body = $text;
-	}
-	
-	/**
-	 * Mets à jour le header de la Response
-	 * @param $code le code HTTP, valeurs possibles
-	 *	- 200 (OK)
-	 *	- 403 (Forbidden)
-	 *	- 404 (Forbidden)
-	 *	- 500 (Forbidden) -> par défaut si $code erroné
-	 *	- 503 (Forbidden)
-	 */
-	public static function setHeader ($code) {
-		switch ($code) {
-		case 200 :
-			self::$header = 'HTTP/1.0 200 OK';
-			break;
-		case 403 :
-			self::$header = 'HTTP/1.0 403 Forbidden';
-			break;
-		case 404 :
-			self::$header = 'HTTP/1.0 404 Not Found';
-			break;
-		case 500 :
-			self::$header = 'HTTP/1.0 500 Internal Server Error';
-			break;
-		case 503 :
-			self::$header = 'HTTP/1.0 503 Service Unavailable';
-			break;
-		default :
-			self::$header = 'HTTP/1.0 500 Internal Server Error';
-		}
-	}
-
-	/**
-	 * Envoie la Response à l'utilisateur
-	 */
-	public static function send () {
-		header (self::$header);
-		echo self::$body;
-	}
-}

+ 0 - 16
lib/Minz/RouteNotFoundException.php

@@ -1,16 +0,0 @@
-<?php
-class Minz_RouteNotFoundException extends Minz_Exception {
-	private $route;
-	
-	public function __construct ($route, $code = self::ERROR) {
-		$this->route = $route;
-		
-		$message = 'Route `' . $route . '` not found';
-		
-		parent::__construct ($message, $code);
-	}
-	
-	public function route () {
-		return $this->route;
-	}
-}

+ 0 - 209
lib/Minz/Router.php

@@ -1,209 +0,0 @@
-<?php
-/** 
- * MINZ - Copyright 2011 Marien Fressinaud
- * Sous licence AGPL3 <http://www.gnu.org/licenses/>
-*/
-
-/**
- * La classe Router gère le routage de l'application
- * Les routes sont définies dans APP_PATH.'/configuration/routes.php'
- */
-class Minz_Router {
-	const ROUTES_PATH_NAME = '/configuration/routes.php';
-
-	private $routes = array ();
-	
-	/**
-	 * Constructeur
-	 * @exception FileNotExistException si ROUTES_PATH_NAME n'existe pas
-	 *            et que l'on utilise l'url rewriting
-	 */
-	public function __construct () {
-		if (Minz_Configuration::useUrlRewriting ()) {
-			if (file_exists (APP_PATH . self::ROUTES_PATH_NAME)) {
-				$routes = include (
-					APP_PATH . self::ROUTES_PATH_NAME
-				);
-		
-				if (!is_array ($routes)) {
-					$routes = array ();
-				}
-				
-				$this->routes = array_map (
-					array ('Url', 'checkUrl'),
-					$routes
-				);
-			} else {
-				throw new Minz_FileNotExistException (
-					self::ROUTES_PATH_NAME,
-					Minz_Exception::ERROR
-				);
-			}
-		}
-	}
-	
-	/**
-	 * Initialise le Router en déterminant le couple Controller / Action
-	 * Mets à jour la Request
-	 * @exception RouteNotFoundException si l'uri n'est pas présente dans
-	 *          > la table de routage
-	 */
-	public function init () {
-		$url = array ();
-		
-		if (Minz_Configuration::useUrlRewriting ()) {
-			try {
-				$url = $this->buildWithRewriting ();
-			} catch (Minz_RouteNotFoundException $e) {
-				throw $e;
-			}
-		} else {
-			$url = $this->buildWithoutRewriting ();
-		}
-		
-		$url['params'] = array_merge (
-			$url['params'],
-			Minz_Request::fetchPOST ()
-		);
-		
-		Minz_Request::forward ($url);
-	}
-	
-	/**
-	 * Retourne un tableau représentant l'url passée par la barre d'adresses
-	 * Ne se base PAS sur la table de routage
-	 * @return tableau représentant l'url
-	 */
-	public function buildWithoutRewriting () {
-		$url = array ();
-		
-		$url['c'] = Minz_Request::fetchGET (
-			'c',
-			Minz_Request::defaultControllerName ()
-		);
-		$url['a'] = Minz_Request::fetchGET (
-			'a',
-			Minz_Request::defaultActionName ()
-		);
-		$url['params'] = Minz_Request::fetchGET ();
-		
-		// post-traitement
-		unset ($url['params']['c']);
-		unset ($url['params']['a']);
-		
-		return $url;
-	}
-	
-	/**
-	 * Retourne un tableau représentant l'url passée par la barre d'adresses
-	 * Se base sur la table de routage
-	 * @return tableau représentant l'url
-	 * @exception RouteNotFoundException si l'uri n'est pas présente dans
-	 *          > la table de routage
-	 */
-	public function buildWithRewriting () {
-		$url = array ();
-		$uri = Minz_Request::getURI ();
-		$find = false;
-		
-		foreach ($this->routes as $route) {
-			$regex = '*^' . $route['route'] . '$*';
-			if (preg_match ($regex, $uri, $matches)) {
-				$url['c'] = $route['controller'];
-				$url['a'] = $route['action'];
-				$url['params'] = $this->getParams (
-					$route['params'],
-					$matches
-				);
-				$find = true;
-				break;
-			}
-		}
-		
-		if (!$find && $uri != '/') {
-			throw new Minz_RouteNotFoundException (
-				$uri,
-				Minz_Exception::ERROR
-			);
-		}
-		
-		// post-traitement
-		$url = Minz_Url::checkUrl ($url);
-		
-		return $url;
-	}
-	
-	/**
-	 * Retourne l'uri d'une url en se basant sur la table de routage
-	 * @param l'url sous forme de tableau
-	 * @return l'uri formatée (string) selon une route trouvée
-	 */
-	public function printUriRewrited ($url) {
-		$route = $this->searchRoute ($url);
-		
-		if ($route !== false) {
-			return $this->replaceParams ($route, $url['params']);
-		}
-		
-		return '';
-	}
-	
-	/**
-	 * Recherche la route correspondante à une url
-	 * @param l'url sous forme de tableau
-	 * @return la route telle que spécifiée dans la table de routage,
-	 *         false si pas trouvée
-	 */
-	public function searchRoute ($url) {
-		foreach ($this->routes as $route) {
-			if ($route['controller'] == $url['c']
-			 && $route['action'] == $url['a']) {
-				// calcule la différence des tableaux de params
-				$params = array_flip ($route['params']);
-				$difference_params = array_diff_key (
-					$params,
-					$url['params']
-				);
-				
-				// vérifie que pas de différence
-				// et le cas où $params est vide et pas $url['params']
-				if (empty ($difference_params)
-				&& (!empty ($params) || empty ($url['params']))) {
-					return $route;
-				}
-			}
-		}
-		
-		return false;
-	}
-	
-	/**
-	 * Récupère un tableau dont
-	 * 	- les clés sont définies dans $params_route
-	 *	- les valeurs sont situées dans $matches
-	 * Le tableau $matches est décalé de +1 par rapport à $params_route
-	 */
-	private function getParams($params_route, $matches) {
-		$params = array ();
-		
-		for ($i = 0; $i < count ($params_route); $i++) {
-			$param = $params_route[$i];
-			$params[$param] = $matches[$i + 1];
-		}
-	
-		return $params;
-	}
-	
-	/**
-	 * Remplace les éléments de la route par les valeurs contenues dans $params
-	 */
-	private function replaceParams ($route, $params_replace) {
-		$uri = $route['route'];
-		$params = array();
-		foreach($route['params'] as $param) {
-			$uri = preg_replace('#\((.+)\)#U', $params_replace[$param], $uri, 1);
-		}
-
-		return stripslashes($uri);
-	 }
-}

+ 4 - 11
lib/Minz/Url.php

@@ -5,8 +5,7 @@
  */
 class Minz_Url {
 	/**
-	 * Affiche une Url formatée selon que l'on utilise l'url_rewriting ou non
-	 * si oui, on cherche dans la table de routage la correspondance pour formater
+	 * Affiche une Url formatée
 	 * @param $url l'url à formater définie comme un tableau :
 	 *                    $url['c'] = controller
 	 *                    $url['a'] = action
@@ -39,13 +38,7 @@ class Minz_Url {
 		}
 
 		if ($isArray) {
-			$router = new Minz_Router ();
-
-			if (Minz_Configuration::useUrlRewriting ()) {
-				$url_string .= $router->printUriRewrited ($url);
-			} else {
-				$url_string .= self::printUri ($url, $encodage);
-			}
+			$url_string .= self::printUri ($url, $encodage);
 		} else {
 			$url_string .= $url;
 		}
@@ -54,14 +47,14 @@ class Minz_Url {
 	}
 	
 	/**
-	 * Construit l'URI d'une URL sans url rewriting
+	 * Construit l'URI d'une URL
 	 * @param l'url sous forme de tableau
 	 * @param $encodage pour indiquer comment encoder les & (& ou &amp; pour html)
 	 * @return l'uri sous la forme ?key=value&key2=value2
 	 */
 	private static function printUri ($url, $encodage) {
 		$uri = '';
-		$separator = '/?';
+		$separator = '?';
 		
 		if($encodage == 'html') {
 			$and = '&amp;';

+ 10 - 0
lib/Minz/View.php

@@ -102,6 +102,16 @@ class Minz_View {
 		}
 	}
 
+	/**
+	 * Retourne renderHelper() dans une chaîne
+	 * @param $helper l'élément à traîter
+	 */
+	public function helperToString($helper) {
+		ob_start();
+		$this->renderHelper($helper);
+		return ob_get_clean();
+	}
+
 	/**
 	 * Permet de choisir si on souhaite utiliser le layout
 	 * @param $use true si on souhaite utiliser le layout, false sinon

+ 31 - 7
lib/SimplePie/SimplePie.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev-FreshRSS
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -50,7 +50,7 @@ define('SIMPLEPIE_NAME', 'SimplePie');
 /**
  * SimplePie Version
  */
-define('SIMPLEPIE_VERSION', '1.3.1');
+define('SIMPLEPIE_VERSION', '1.4-dev-FreshRSS');
 
 /**
  * SimplePie Build
@@ -602,7 +602,7 @@ class SimplePie
 	public $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
 
 	/**
-	 * @var array Stores the default attributes to add to differet tags by add_attributes().
+	 * @var array Stores the default attributes to add to different tags by add_attributes().
 	 * @see SimplePie::add_attributes()
 	 * @access private
 	 */
@@ -644,7 +644,7 @@ class SimplePie
 		if (func_num_args() > 0)
 		{
 			$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
-			trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.', $level);
+			trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_duration() directly.', $level);
 
 			$args = func_get_args();
 			switch (count($args)) {
@@ -1212,6 +1212,16 @@ class SimplePie
 		$this->item_limit = (int) $limit;
 	}
 
+	/**
+	 * Enable throwing exceptions
+	 *
+	 * @param boolean $enable Should we throw exceptions, or use the old-style error property?
+	 */
+	public function enable_exceptions($enable = true)
+	{
+		$this->enable_exceptions = $enable;
+	}
+
 	function cleanMd5($rss) {	//FreshRSS
 		return md5(preg_replace(array('#<(lastBuildDate|pubDate|updated|feedDate|dc:date|slash:comments)>[^<]+</\\1>#', '#<!--.+?-->#s'), '', $rss));
 	}
@@ -1321,7 +1331,7 @@ class SimplePie
 		// First check to see if input has been overridden.
 		if ($this->input_encoding !== false)
 		{
-			$encodings[] = strtoupper($this->input_encoding);
+			$encodings[] = strtoupper($this->input_encoding);	//FreshRSS
 		}
 
 		$application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
@@ -1345,7 +1355,7 @@ class SimplePie
 			{
 				if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
 				{
-					$encodings[] = strtoupper($charset[1]);
+					$encodings[] = strtoupper($charset[1]);	//FreshRSS
 				}
 				else
 				{
@@ -2012,7 +2022,21 @@ class SimplePie
 	 */
 	public function sanitize($data, $type, $base = '')
 	{
-		return $this->sanitize->sanitize($data, $type, $base);
+		try
+		{
+			return $this->sanitize->sanitize($data, $type, $base);
+		}
+		catch (SimplePie_Exception $e)
+		{
+			if (!$this->enable_exceptions)
+			{
+				$this->error = $e->getMessage();
+				$this->registry->call('Misc', 'error', array($this->error, E_USER_WARNING, $e->getFile(), $e->getLine()));
+				return '';
+			}
+
+			throw $e;
+		}
 	}
 
 	/**

+ 1 - 1
lib/SimplePie/SimplePie/Author.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Cache.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Cache/Base.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Cache/DB.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Cache/File.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 5 - 7
lib/SimplePie/SimplePie/Cache/Memcache.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -95,10 +95,8 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base
 				'prefix' => 'simplepie_',
 			),
 		);
-		$parsed = SimplePie_Cache::parse_URL($location);
-		$this->options['host'] = empty($parsed['host']) ? $this->options['host'] : $parsed['host'];
-		$this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port'];
-		$this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']);
+		$this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
+
 		$this->name = $this->options['extras']['prefix'] . md5("$name:$type");
 
 		$this->cache = new Memcache();
@@ -147,7 +145,7 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base
 
 		if ($data !== false)
 		{
-			// essentially ignore the mtime because Memcache expires on it's own
+			// essentially ignore the mtime because Memcache expires on its own
 			return time();
 		}
 
@@ -165,7 +163,7 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base
 
 		if ($data !== false)
 		{
-			return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->duration);
+			return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->options['extras']['timeout']);
 		}
 
 		return false;

+ 4 - 3
lib/SimplePie/SimplePie/Cache/MySQL.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -96,7 +96,8 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
 				'prefix' => '',
 			),
 		);
-		$this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
+		
+		$this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
 
 		// Path is prefixed with a "/"
 		$this->options['dbname'] = substr($this->options['path'], 1);
@@ -136,7 +137,7 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
 
 		if (!in_array($this->options['extras']['prefix'] . 'items', $db))
 		{
-			$query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');
+			$query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` MEDIUMBLOB CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');
 			if ($query === false)
 			{
 				$this->mysql = null;

+ 1 - 1
lib/SimplePie/SimplePie/Caption.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Category.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Content/Type/Sniffer.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Copyright.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Core.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Credit.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Decode/HTML/Entities.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 2 - 2
lib/SimplePie/SimplePie/Enclosure.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -942,7 +942,7 @@ class SimplePie_Enclosure
 	 * - `height` (integer): The height of the embedded media. Accepts any
 	 *    numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,
 	 *    and it is recommended that you use this default.
-	 * - `loop` (boolean): Do you want the media to loop when its done?
+	 * - `loop` (boolean): Do you want the media to loop when it's done?
 	 *    Defaults to `false`.
 	 * - `mediaplayer` (string): The location of the included
 	 *    `mediaplayer.swf` file. This allows for the playback of Flash Video

+ 3 - 3
lib/SimplePie/SimplePie/File.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -108,7 +108,7 @@ class SimplePie_File
 				curl_setopt($fp, CURLOPT_REFERER, $url);
 				curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
 				curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
-				curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, false);
+				curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, false);	//FreshRSS
 				if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
 				{
 					curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
@@ -284,7 +284,7 @@ class SimplePie_File
 		else
 		{
 			$this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
-			if (!$this->body = file_get_contents($url))
+			if (empty($url) || !($this->body = file_get_contents($url)))
 			{
 				$this->error = 'file_get_contents could not read the file';
 				$this->success = false;

+ 1 - 1
lib/SimplePie/SimplePie/HTTP/Parser.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/IRI.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 3 - 3
lib/SimplePie/SimplePie/Item.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -821,7 +821,7 @@ class SimplePie_Item
 			if (!empty($this->data['updated']['raw']))
 			{
 				$parser = $this->registry->call('Parse_Date', 'get');
-				$this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']);
+				$this->data['updated']['parsed'] = $parser->parse($this->data['updated']['raw']);
 			}
 			else
 			{
@@ -1080,7 +1080,7 @@ class SimplePie_Item
 	 *
 	 * @since Beta 2
 	 * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
-	 * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
+	 * @todo If an element exists at a level, but its value is empty, we should fall back to the value from the parent (if it exists).
 	 * @return array|null List of SimplePie_Enclosure items
 	 */
 	public function get_enclosures()

+ 2 - 2
lib/SimplePie/SimplePie/Locator.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -277,7 +277,7 @@ class SimplePie_Locator
 				$parsed = $this->registry->call('Misc', 'parse_url', array($href));
 				if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))
 				{
-					if ($this->base_location < $link->getLineNo())
+					if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo())
 					{
 						$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base));
 					}

+ 20 - 3
lib/SimplePie/SimplePie/Misc.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -128,7 +128,7 @@ class SimplePie_Misc
 						{
 							$attribs[$j][2] = $attribs[$j][1];
 						}
-						$return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
+						$return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');	//FreshRSS
 					}
 				}
 			}
@@ -142,7 +142,7 @@ class SimplePie_Misc
 		foreach ($element['attribs'] as $key => $value)
 		{
 			$key = strtolower($key);
-			$full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"';
+			$full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"';	//FreshRSS
 		}
 		if ($element['self_closing'])
 		{
@@ -228,6 +228,23 @@ class SimplePie_Misc
 		}
 	}
 
+	public static function array_merge_recursive($array1, $array2)
+	{
+		foreach ($array2 as $key => $value)
+		{
+			if (is_array($value))
+			{
+				$array1[$key] = SimplePie_Misc::array_merge_recursive($array1[$key], $value);
+			}
+			else
+			{
+				$array1[$key] = $value;
+			}            
+		}
+		
+		return $array1;
+	}
+
 	public static function parse_url($url)
 	{
 		$iri = new SimplePie_IRI($url);

+ 1 - 1
lib/SimplePie/SimplePie/Net/IPv6.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Parse/Date.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Parser.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Rating.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Registry.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/Restriction.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 6 - 2
lib/SimplePie/SimplePie/Sanitize.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon
@@ -267,6 +267,10 @@ class SimplePie_Sanitize
 			if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
 			{
 
+				if (!class_exists('DOMDocument'))
+				{
+					throw new SimplePie_Exception('DOMDocument not found, unable to use sanitizer');
+				}
 				$document = new DOMDocument();
 				$document->encoding = 'UTF-8';
 				$data = $this->preprocess($data, $type);
@@ -339,7 +343,7 @@ class SimplePie_Sanitize
 							}
 							else
 							{
-								$file = $this->registry->create('File', array($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen));
+								$file = $this->registry->create('File', array($img->getAttribute('src'), $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen));
 								$headers = $file->headers;
 
 								if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))

+ 1 - 1
lib/SimplePie/SimplePie/Source.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/XML/Declaration/Parser.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 1 - 1
lib/SimplePie/SimplePie/gzdecode.php

@@ -33,7 +33,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * @package SimplePie
- * @version 1.3.1
+ * @version 1.4-dev
  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  * @author Ryan Parman
  * @author Geoffrey Sneddon

+ 194 - 83
lib/lib_opml.php

@@ -1,23 +1,86 @@
 <?php
-function opml_export ($cats) {
-	$txt = '';
 
-	foreach ($cats as $cat) {
-		$txt .= '<outline text="' . $cat['name'] . '">' . "\n";
-
-		foreach ($cat['feeds'] as $feed) {
-			$txt .= "\t" . '<outline text="' . $feed->name () . '" type="rss" xmlUrl="' . $feed->url () . '" htmlUrl="' . $feed->website () . '" description="' . htmlspecialchars($feed->description(), ENT_COMPAT, 'UTF-8') . '" />' . "\n";
+/* *
+ * lib_opml is a free library to manage OPML format in PHP.
+ * It takes in consideration only version 2.0 (http://dev.opml.org/spec2.html).
+ * Basically it means "text" attribute for outline elements is required.
+ *
+ * lib_opml requires SimpleXML (http://php.net/manual/en/book.simplexml.php)
+ *
+ * Usages:
+ * > include('lib_opml.php');
+ * > $filename = 'my_opml_file.xml';
+ * > $opml_array = libopml_parse_file($filename);
+ * > print_r($opml_array);
+ *
+ * > $opml_string = [...];
+ * > $opml_array = libopml_parse_string($opml_string);
+ * > print_r($opml_array);
+ *
+ * > $opml_array = [...];
+ * > $opml_string = libopml_render($opml_array);
+ * > $opml_object = libopml_render($opml_array, true);
+ * > echo $opml_string;
+ * > print_r($opml_object);
+ *
+ * If parsing fails for any reason (e.g. not an XML string, does not match with
+ * the specifications), a LibOPML_Exception is raised.
+ *
+ * Author: Marien Fressinaud <dev@marienfressinaud.fr>
+ * Url: https://github.com/marienfressinaud/lib_opml
+ * Version: 0.1
+ * Date: 2014-03-29
+ * License: public domain
+ *
+ * */
+
+class LibOPML_Exception extends Exception {}
+
+
+// These elements are optional
+define('HEAD_ELEMENTS', serialize(array(
+	'title', 'dateCreated', 'dateModified', 'ownerName', 'ownerEmail',
+	'ownerId', 'docs', 'expansionState', 'vertScrollState', 'windowTop',
+	'windowLeft', 'windowBottom', 'windowRight'
+)));
+
+
+function libopml_parse_outline($outline_xml) {
+	$outline = array();
+
+	// An outline may contain any kind of attributes but "text" attribute is
+	// required !
+	$text_is_present = false;
+	foreach ($outline_xml->attributes() as $key => $value) {
+		$outline[$key] = (string)$value;
+
+		if ($key === 'text') {
+			$text_is_present = true;
 		}
+	}
 
-		$txt .= '</outline>' . "\n";
+	if (!$text_is_present) {
+		throw new LibOPML_Exception(
+			'Outline does not contain any text attribute'
+		);
 	}
 
-	return $txt;
+	foreach ($outline_xml->children() as $key => $value) {
+		// An outline may contain any number of outline children
+		if ($key === 'outline') {
+			$outline['@outlines'][] = libopml_parse_outline($value);
+		} else {
+			throw new LibOPML_Exception(
+				'Body can contain only outline elements'
+			);
+		}
+	}
+
+	return $outline;
 }
 
-function opml_import ($xml) {
-	$xml = html_only_entity_decode($xml);	//!\ Assume UTF-8
 
+function libopml_parse_string($xml) {
 	$dom = new DOMDocument();
 	$dom->recover = true;
 	$dom->strictErrorChecking = false;
@@ -27,94 +90,142 @@ function opml_import ($xml) {
 	$opml = simplexml_import_dom($dom);
 
 	if (!$opml) {
-		throw new FreshRSS_Opml_Exception ();
+		throw new LibOPML_Exception();
 	}
 
-	$catDAO = new FreshRSS_CategoryDAO();
-	$catDAO->checkDefault();
-	$defCat = $catDAO->getDefault();
+	$array = array(
+		'version' => (string)$opml['version'],
+		'head' => array(),
+		'body' => array()
+	);
+
+	// First, we get all "head" elements. Head is required but its sub-elements
+	// are optional.
+	foreach ($opml->head->children() as $key => $value) {
+		if (in_array($key, unserialize(HEAD_ELEMENTS), true)) {
+			$array['head'][$key] = (string)$value;
+		} else {
+			throw new LibOPML_Exception(
+				$key . 'is not part of OPML format'
+			);
+		}
+	}
 
-	$categories = array ();
-	$feeds = array ();
+	// Then, we get body oulines. Body must contain at least one outline
+	// element.
+	$at_least_one_outline = false;
+	foreach ($opml->body->children() as $key => $value) {
+		if ($key === 'outline') {
+			$at_least_one_outline = true;
+			$array['body'][] = libopml_parse_outline($value);
+		} else {
+			throw new LibOPML_Exception(
+				'Body can contain only outline elements'
+			);
+		}
+	}
+
+	if (!$at_least_one_outline) {
+		throw new LibOPML_Exception(
+			'Body must contain at least one outline element'
+		);
+	}
 
-	foreach ($opml->body->outline as $outline) {
-		if (!isset ($outline['xmlUrl'])) {
-			// Catégorie
-			$title = '';
+	return $array;
+}
 
-			if (isset ($outline['text'])) {
-				$title = (string) $outline['text'];
-			} elseif (isset ($outline['title'])) {
-				$title = (string) $outline['title'];
-			}
 
-			if ($title) {
-				// Permet d'éviter les soucis au niveau des id :
-				// ceux-ci sont générés en fonction de la date,
-				// un flux pourrait être dans une catégorie X avec l'id Y
-				// alors qu'il existe déjà la catégorie X mais avec l'id Z
-				// Y ne sera pas ajouté et le flux non plus vu que l'id
-				// de sa catégorie n'exisera pas
-				$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
-				$catDAO = new FreshRSS_CategoryDAO ();
-				$cat = $catDAO->searchByName ($title);
-				if ($cat === false) {
-					$cat = new FreshRSS_Category ($title);
-					$values = array (
-						'name' => $cat->name ()
-					);
-					$cat->_id ($catDAO->addCategory ($values));
-				}
-
-				$feeds = array_merge ($feeds, getFeedsOutline ($outline, $cat->id ()));
+function libopml_parse_file($filename) {
+	$file_content = file_get_contents($filename);
+
+	if ($file_content === false) {
+		throw new LibOPML_Exception(
+			$filename . ' cannot be found'
+		);
+	}
+
+	return libopml_parse_string($file_content);
+}
+
+
+function libopml_render_outline($parent_elt, $outline) {
+	// Outline MUST be an array!
+	if (!is_array($outline)) {
+		throw new LibOPML_Exception(
+			'Outline element must be defined as array'
+		);
+	}
+
+	$outline_elt = $parent_elt->addChild('outline');
+	$text_is_present = false;
+	foreach ($outline as $key => $value) {
+		// Only outlines can be an array and so we consider children are also
+		// outline elements.
+		if ($key === '@outlines' && is_array($value)) {
+			foreach ($value as $outline_child) {
+				libopml_render_outline($outline_elt, $outline_child);
 			}
+		} elseif (is_array($value)) {
+			throw new LibOPML_Exception(
+				'Type of outline elements cannot be array: ' . $key
+			);
 		} else {
-			// Flux rss sans catégorie, on récupère l'ajoute dans la catégorie par défaut
-			$feeds[] = getFeed ($outline, $defCat->id());
+			// Detect text attribute is present, that's good :)
+			if ($key === 'text') {
+				$text_is_present = true;
+			}
+
+			$outline_elt->addAttribute($key, $value);
 		}
 	}
 
-	return array ($categories, $feeds);
+	if (!$text_is_present) {
+		throw new LibOPML_Exception(
+			'You must define at least a text element for all outlines'
+		);
+	}
 }
 
-/**
- * import all feeds of a given outline tag
- */
-function getFeedsOutline ($outline, $cat_id) {
-	$feeds = array ();
 
-	foreach ($outline->children () as $child) {
-		if (isset ($child['xmlUrl'])) {
-			$feeds[] = getFeed ($child, $cat_id);
-		} else {
-			$feeds = array_merge(
-				$feeds,
-				getFeedsOutline ($child, $cat_id)
-			);
+function libopml_render($array, $as_xml_object = false) {
+	$opml = new SimpleXMLElement('<opml version="2.0"></opml>');
+
+	// Create head element. $array['head'] is optional but head element will
+	// exist in the final XML object.
+	$head = $opml->addChild('head');
+	if (isset($array['head'])) {
+		foreach ($array['head'] as $key => $value) {
+			if (in_array($key, unserialize(HEAD_ELEMENTS), true)) {
+				$head->addChild($key, $value);
+			}
 		}
 	}
 
-	return $feeds;
-}
+	// Check body is set and contains at least one element
+	if (!isset($array['body'])) {
+		throw new LibOPML_Exception(
+			'$array must contain a body element'
+		);
+	}
+	if (count($array['body']) <= 0) {
+		throw new LibOPML_Exception(
+			'Body element must contain at least one element (array)'
+		);
+	}
 
-function getFeed ($outline, $cat_id) {
-	$url = (string) $outline['xmlUrl'];
-	$url = htmlspecialchars($url, ENT_COMPAT, 'UTF-8');
-	$title = '';
-	if (isset ($outline['text'])) {
-		$title = (string) $outline['text'];
-	} elseif (isset ($outline['title'])) {
-		$title = (string) $outline['title'];
-	}
-	$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
-	$feed = new FreshRSS_Feed ($url);
-	$feed->_category ($cat_id);
-	$feed->_name ($title);
-	if (isset($outline['htmlUrl'])) {
-		$feed->_website(htmlspecialchars((string)$outline['htmlUrl'], ENT_COMPAT, 'UTF-8'));
-	}
-	if (isset($outline['description'])) {
-		$feed->_description(sanitizeHTML((string)$outline['description']));
-	}
-	return $feed;
+	// Create outline elements
+	$body = $opml->addChild('body');
+	foreach ($array['body'] as $outline) {
+		libopml_render_outline($body, $outline);
+	}
+
+	// And return the final result
+	if ($as_xml_object) {
+		return $opml;
+	} else {
+		$dom = dom_import_simplexml($opml)->ownerDocument;
+		$dom->formatOutput = true;
+		$dom->encoding = 'UTF-8';
+		return $dom->saveXML();
+	}
 }

+ 17 - 2
lib/lib_rss.php

@@ -27,7 +27,7 @@ function classAutoloader($class) {
 				include(APP_PATH . '/Models/' . $components[1] . '.php');
 				return;
 			case 3:	//Controllers, Exceptions
-				include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php');
+				@include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php');
 				return;
 		}
 	} elseif (strpos($class, 'Minz') === 0) {
@@ -219,7 +219,7 @@ function invalidateHttpCache() {
 }
 
 function usernameFromPath($userPath) {
-	if (preg_match('%/([a-z0-9]{1,16})_user\.php$%', $userPath, $matches)) {
+	if (preg_match('%/([A-Za-z0-9]{1,16})_user\.php$%', $userPath, $matches)) {
 		return $matches[1];
 	} else {
 		return '';
@@ -233,3 +233,18 @@ function listUsers() {
 function httpAuthUser() {
 	return isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '';
 }
+
+function cryptAvailable() {
+	if (version_compare(PHP_VERSION, '5.3.3', '>=')) {
+		try {
+			$hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG';
+			return $hash === @crypt('password', $hash);
+		} catch (Exception $e) {
+		}
+	}
+	return false;
+}
+
+function html_chars_utf8($str) {
+	return htmlspecialchars($str, ENT_COMPAT, 'UTF-8');
+}

+ 4 - 0
p/api/.htaccess

@@ -0,0 +1,4 @@
+<IfModule mod_rewrite.c>
+	RewriteEngine on
+	RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+</IfModule>

+ 646 - 0
p/api/greader.php

@@ -0,0 +1,646 @@
+<?php
+/**
+== Description ==
+Server-side API compatible with Google Reader API layer 2
+	for the FreshRSS project http://freshrss.org
+
+== Credits ==
+* 2014-03: Released by Alexandre Alapetite http://alexandre.alapetite.fr
+	under GNU AGPL 3 license http://www.gnu.org/licenses/agpl-3.0.html
+
+== Documentation ==
+* http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
+* http://web.archive.org/web/20130718025427/http://undoc.in/
+* http://ranchero.com/downloads/GoogleReaderAPI-2009.pdf
+* http://code.google.com/p/google-reader-api/w/list
+* http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/
+* https://github.com/noinnion/newsplus/blob/master/extensions/GoogleReaderCloneExtension/src/com/noinnion/android/newsplus/extension/google_reader/GoogleReaderClient.java
+* https://github.com/ericmann/gReader-Library/blob/master/greader.class.php
+* https://github.com/devongovett/reader
+* https://github.com/theoldreader/api
+*/
+
+require('../../constants.php');
+require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+
+$ORIGINAL_INPUT = file_get_contents('php://input');
+
+if (PHP_INT_SIZE < 8) {	//32-bit
+	function dec2hex($dec) {
+		return str_pad(gmp_strval(gmp_init($dec, 10), 16), 16, '0', STR_PAD_LEFT);
+	}
+	function hex2dec($hex) {
+		return gmp_strval(gmp_init($hex, 16), 10);
+	}
+} else {	//64-bit
+	function dec2hex($dec) {	//http://code.google.com/p/google-reader-api/wiki/ItemId
+		return str_pad(dechex($dec), 16, '0', STR_PAD_LEFT);
+	}
+	function hex2dec($hex) {
+		return hexdec($hex);
+	}
+}
+
+function headerVariable($headerName, $varName) {
+	$header = '';
+	$upName = 'HTTP_' . strtoupper($headerName);
+	if (isset($_SERVER[$upName])) {
+		$header = $_SERVER[$upName];
+	} elseif (function_exists('getallheaders')) {
+		$ALL_HEADERS = getallheaders();
+		if (isset($ALL_HEADERS[$headerName])) {
+			$header = $ALL_HEADERS[$headerName];
+		}
+	}
+	parse_str($header, $pairs);
+	return isset($pairs[$varName]) ? $pairs[$varName] : null;
+}
+
+function multiplePosts($name) {	//https://bugs.php.net/bug.php?id=51633
+	global $ORIGINAL_INPUT;
+	$inputs = explode('&', $ORIGINAL_INPUT);
+	$result = array();
+	$prefix = $name . '=';
+	$prefixLength = strlen($prefix);
+	foreach ($inputs as $input) {
+		if (strpos($input, $prefix) === 0) {
+			$result[] = urldecode(substr($input, $prefixLength));
+		}
+	}
+	return $result;
+}
+
+class MyPDO extends Minz_ModelPdo {
+	function prepare($sql) {
+		return $this->bd->prepare(str_replace('%_', $this->prefix, $sql));
+	}
+}
+
+function logMe($text) {
+	file_put_contents(LOG_PATH . '/api.log', $text, FILE_APPEND);
+}
+
+function debugInfo() {
+	if (function_exists('getallheaders')) {
+		$ALL_HEADERS = getallheaders();
+	} else {	//nginx	http://php.net/getallheaders#84262
+		$ALL_HEADERS = '';
+		foreach ($_SERVER as $name => $value) {
+			if (substr($name, 0, 5) === 'HTTP_') {
+				$ALL_HEADERS[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
+			}
+		}
+	}
+	global $ORIGINAL_INPUT;
+	return print_r(array('date' => date('c'), 'headers' => $ALL_HEADERS, '_SERVER' => $_SERVER, '_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, 'INPUT' => $ORIGINAL_INPUT), true);
+}
+
+function badRequest() {
+	logMe("badRequest()\n");
+	logMe(debugInfo());
+	header('HTTP/1.1 400 Bad Request');
+	header('Content-Type: text/plain; charset=UTF-8');
+	die('Bad Request!');
+}
+
+function unauthorized() {
+	logMe("unauthorized()\n");
+	logMe(debugInfo());
+	header('HTTP/1.1 401 Unauthorized');
+	header('Content-Type: text/plain; charset=UTF-8');
+	header('Google-Bad-Token: true');
+	die('Unauthorized!');
+}
+
+function notImplemented() {
+	logMe("notImplemented()\n");
+	logMe(debugInfo());
+	header('HTTP/1.1 501 Not Implemented');
+	header('Content-Type: text/plain; charset=UTF-8');
+	die('Not Implemented!');
+}
+
+function serviceUnavailable() {
+	logMe("serviceUnavailable()\n");
+	header('HTTP/1.1 503 Service Unavailable');
+	header('Content-Type: text/plain; charset=UTF-8');
+	die('Service Unavailable!');
+}
+
+function checkCompatibility() {
+	logMe("checkCompatibility()\n");
+	header('Content-Type: text/plain; charset=UTF-8');
+	if (PHP_INT_SIZE < 8 && !function_exists('gmp_init')) {
+		die('FAIL 64-bit or GMP extension!');
+	}
+	if ((!array_key_exists('HTTP_AUTHORIZATION', $_SERVER)) &&	//Apache mod_rewrite trick should be fine
+		(empty($_SERVER['SERVER_SOFTWARE']) || (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') === false)) &&	//nginx should be fine
+		((!function_exists('getallheaders')) || (stripos(php_sapi_name(), 'cgi') !== false))) {	//Main problem is Apache/CGI mode
+		die('FAIL getallheaders! (probably)');
+	}
+	echo 'PASS';
+	exit();
+}
+
+function authorizationToUserConf() {
+	$headerAuth = headerVariable('Authorization', 'GoogleLogin_auth');	//Input is 'GoogleLogin auth', but PHP replaces spaces by '_'	http://php.net/language.variables.external
+	if ($headerAuth != '') {
+		$headerAuthX = explode('/', $headerAuth, 2);
+		if (count($headerAuthX) === 2) {
+			$user = $headerAuthX[0];
+			if (ctype_alnum($user)) {
+				try {
+					$conf = new FreshRSS_Configuration($user);
+				} catch (Exception $e) {
+					logMe($e->getMessage() . "\n");
+					unauthorized();
+				}
+				if ($headerAuthX[1] === sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash)) {
+					return $conf;
+				} else {
+					logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1] . "\n");
+					Minz_Log::record('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1], Minz_Log::WARNING);
+					unauthorized();
+				}
+			} else {
+				badRequest();
+			}
+		}
+	}
+	return null;
+}
+
+function clientLogin($email, $pass) {	//http://web.archive.org/web/20130604091042/http://undoc.in/clientLogin.html
+	logMe('clientLogin(' . $email . ")\n");
+	if (ctype_alnum($email)) {
+		if (!function_exists('password_verify')) {
+			include_once(LIB_PATH . '/password_compat.php');
+		}
+		try {
+			$conf = new FreshRSS_Configuration($email);
+		} catch (Exception $e) {
+			logMe($e->getMessage() . "\n");
+			Minz_Log::record('Invalid API user ' . $email, Minz_Log::WARNING);
+			unauthorized();
+		}
+		if ($conf->apiPasswordHash != '' && password_verify($pass, $conf->apiPasswordHash)) {
+			header('Content-Type: text/plain; charset=UTF-8');
+			$auth = $email . '/' . sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash);
+			echo 'SID=', $auth, "\n",
+				'Auth=', $auth, "\n";
+			exit();
+		} else {
+			Minz_Log::record('Password API mismatch for user ' . $email, Minz_Log::WARNING);
+			unauthorized();
+		}
+	} else {
+		badRequest();
+	}
+	die();
+}
+
+function token($conf) {
+//http://blog.martindoms.com/2009/08/15/using-the-google-reader-api-part-1/
+//https://github.com/ericmann/gReader-Library/blob/master/greader.class.php
+	logMe('token('. $conf->user . ")\n");	//TODO: Implement real token that expires
+	$token = str_pad(sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash), 57, 'Z');	//Must have 57 characters
+	echo $token, "\n";
+	exit();
+}
+
+function checkToken($conf, $token) {
+//http://code.google.com/p/google-reader-api/wiki/ActionToken
+	logMe('checkToken(' . $token . ")\n");
+	if ($token === str_pad(sha1(Minz_Configuration::salt() . $conf->user . $conf->apiPasswordHash), 57, 'Z')) {
+		return true;
+	}
+	unauthorized();
+}
+
+function tagList() {
+	logMe("tagList()\n");
+	header('Content-Type: application/json; charset=UTF-8');
+
+	$pdo = new MyPDO();
+	$stm = $pdo->prepare('SELECT c.name FROM `%_category` c');
+	$stm->execute();
+	$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
+
+	$tags = array(
+		array('id' => 'user/-/state/com.google/starred'),
+		//array('id' => 'user/-/state/com.google/broadcast', 'sortid' => '2'),
+	);
+
+	foreach ($res as $cName) {
+		$tags[] = array(
+			'id' => 'user/-/label/' . $cName,
+			//'sortid' => $cName,
+		);
+	}
+
+	echo json_encode(array('tags' => $tags)), "\n";
+	exit();
+}
+
+function subscriptionList() {
+	logMe("subscriptionList()\n");
+	header('Content-Type: application/json; charset=UTF-8');
+
+	$pdo = new MyPDO();
+	$stm = $pdo->prepare('SELECT f.id, f.name, f.url, f.website, c.id as c_id, c.name as c_name FROM `%_feed` f
+		INNER JOIN `%_category` c ON c.id = f.category');
+	$stm->execute();
+	$res = $stm->fetchAll(PDO::FETCH_ASSOC);
+
+	$subscriptions = array();
+
+	foreach ($res as $line) {
+		$subscriptions[] = array(
+			'id' => 'feed/' . $line['id'],
+			'title' => $line['name'],
+			'categories' => array(
+				array(
+					'id' => 'user/-/label/' . $line['c_name'],
+					'label' => $line['c_name'],
+				),
+			),
+			//'sortid' => $line['name'],
+			//'firstitemmsec' => 0,
+			'url' => $line['url'],
+			'htmlUrl' => $line['website'],
+			//'iconUrl' => '',
+		);
+	}
+
+	echo json_encode(array('subscriptions' => $subscriptions)), "\n";
+	exit();
+}
+
+function unreadCount() {	//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#unread-count
+	logMe("unreadCount()\n");
+	header('Content-Type: application/json; charset=UTF-8');
+
+	$totalUnreads = 0;
+	$totalLastUpdate = 0;
+
+	$categoryDAO = new FreshRSS_CategoryDAO();
+	foreach ($categoryDAO->listCategories(true, true) as $cat) {
+		$catLastUpdate = 0;
+		foreach ($cat->feeds() as $feed) {
+			$lastUpdate = $feed->lastUpdate();
+			$unreadcounts[] = array(
+				'id' => 'feed/' . $feed->id(),
+				'count' => $feed->nbNotRead(),
+				'newestItemTimestampUsec' => $lastUpdate . '000000',
+			);
+			if ($catLastUpdate < $lastUpdate) {
+				$catLastUpdate = $lastUpdate;
+			}
+		}
+		$unreadcounts[] = array(
+			'id' => 'user/-/label/' . $cat->name(),
+			'count' => $cat->nbNotRead(),
+			'newestItemTimestampUsec' => $catLastUpdate . '000000',
+		);
+		$totalUnreads += $cat->nbNotRead();
+		if ($totalLastUpdate < $catLastUpdate) {
+			$totalLastUpdate = $catLastUpdate;
+		}
+	}
+
+	$unreadcounts[] = array(
+		'id' => 'user/-/state/com.google/reading-list',
+		'count' => $totalUnreads,
+		'newestItemTimestampUsec' => $totalLastUpdate . '000000',
+	);
+
+	echo json_encode(array(
+		'max' => $totalUnreads,
+		'unreadcounts' => $unreadcounts,
+	)), "\n";
+	exit();
+}
+
+function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation) {
+//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
+//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
+	logMe("streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation)\n");
+	header('Content-Type: application/json; charset=UTF-8');
+
+	$feedDAO = new FreshRSS_FeedDAO();
+	$arrayFeedCategoryNames = $feedDAO->arrayFeedCategoryNames();
+
+	switch ($path) {
+		case 'reading-list':
+			$type = 'A';
+			break;
+		case 'starred':
+			$type = 's';
+			break;
+		case 'feed':
+			$type = 'f';
+			break;
+		case 'label':
+			$type = 'c';
+			$categoryDAO = new FreshRSS_CategoryDAO();
+			$cat = $categoryDAO->searchByName($include_target);
+			$include_target = $cat == null ? -1 : $cat->id();
+			break;
+		default:
+			$type = 'A';
+			break;
+	}
+
+	switch ($exclude_target) {
+		case 'user/-/state/com.google/read':
+			$state = FreshRSS_Entry::STATE_NOT_READ;
+			break;
+		default:
+			$state = FreshRSS_Entry::STATE_ALL;
+			break;
+	}
+
+	if (!empty($continuation)) {
+		$count++;	//Shift by one element
+	}
+
+	$entryDAO = new FreshRSS_EntryDAO();
+	$entries = $entryDAO->listWhere($type, $include_target, $state, $order === 'o' ? 'ASC' : 'DESC', $count, $continuation, '', $start_time);
+
+	$items = array();
+	foreach ($entries as $entry) {
+		$f_id = $entry->feed();
+		if (isset($arrayFeedCategoryNames[$f_id])) {
+			$c_name = $arrayFeedCategoryNames[$f_id]['c_name'];
+			$f_name = $arrayFeedCategoryNames[$f_id]['name'];
+		} else {
+			$c_name = '_';
+			$f_name = '_';
+		}
+		$item = array(
+			'id' => /*'tag:google.com,2005:reader/item/' .*/ dec2hex($entry->id()),	//64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId
+			'crawlTimeMsec' => substr($entry->id(), 0, -3),
+			'timestampUsec' => $entry->id(),	//EasyRSS
+			'published' => $entry->date(true),
+			'title' => $entry->title(),
+			'summary' => array('content' => $entry->content()),
+			'alternate' => array(
+				array('href' => $entry->link()),
+			),
+			'categories' => array(
+				'user/-/state/com.google/reading-list',
+				'user/-/label/' . $c_name,
+			),
+			'origin' => array(
+				'streamId' => 'feed/' . $f_id,
+				'title' => $f_name,	//EasyRSS
+				//'htmlUrl' => $line['f_website'],
+			),
+		);
+		if ($entry->author() != '') {
+			$item['author'] = $entry->author();
+		}
+		if ($entry->isRead()) {
+			$item['categories'][] = 'user/-/state/com.google/read';
+		}
+		if ($entry->isFavorite()) {
+			$item['categories'][] = 'user/-/state/com.google/starred';
+		}
+		$items[] = $item;
+	}
+
+	if (!empty($continuation)) {
+		array_shift($items);	//Discard first element that was already sent in the previous response
+	}
+
+	$response = array(
+		'id' => 'user/-/state/com.google/reading-list',
+		'updated' => time(),
+		'items' => $items,
+	);
+	if ((count($entries) >= $count) && (!empty($entry))) {
+		$response['continuation'] = $entry->id();
+	}
+
+	echo json_encode($response), "\n";
+	exit();
+}
+
+function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target) {
+//http://code.google.com/p/google-reader-api/wiki/ApiStreamItemsIds
+//http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
+//http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed
+	logMe("streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target)\n");
+
+	$type = 'A';
+	$id = '';
+	if ($streamId === 'user/-/state/com.google/reading-list') {
+		$type = 'A';
+	} elseif ('user/-/state/com.google/starred') {
+		$type = 's';
+	} elseif (strpos($streamId, 'feed/') === 0) {
+		$type = 'f';
+		$id = basename($streamId);
+	} elseif (strpos($streamId, 'user/-/label/') === 0) {
+		$type = 'c';
+		$c_name = basename($streamId);
+		$categoryDAO = new FreshRSS_CategoryDAO();
+		$cat = $categoryDAO->searchByName($c_name);
+		$id = $cat == null ? -1 : $cat->id();
+	}
+
+	switch ($exclude_target) {
+		case 'user/-/state/com.google/read':
+			$state = FreshRSS_Entry::STATE_NOT_READ;
+			break;
+		default:
+			$state = FreshRSS_Entry::STATE_ALL;
+			break;
+	}
+
+	$entryDAO = new FreshRSS_EntryDAO();
+	$ids = $entryDAO->listIdsWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', '', $start_time);
+
+	$itemRefs = array();
+	foreach ($ids as $id) {
+		$itemRefs[] = array(
+			'id' => $id,	//64-bit decimal
+		);
+	}
+
+	echo json_encode(array(
+		'itemRefs' => $itemRefs,
+	)), "\n";
+	exit();
+}
+
+function editTag($e_ids, $a, $r) {
+	logMe("editTag()\n");
+
+	foreach ($e_ids as $i => $e_id) {
+		$e_ids[$i] = hex2dec(basename($e_id));	//Strip prefix 'tag:google.com,2005:reader/item/'
+	}
+
+	$entryDAO = new FreshRSS_EntryDAO();
+
+	switch ($a) {
+		case 'user/-/state/com.google/read':
+			$entryDAO->markRead($e_ids, true);
+			break;
+		case 'user/-/state/com.google/starred':
+			$entryDAO->markFavorite($e_ids, true);
+			break;
+		/*case 'user/-/state/com.google/tracking-kept-unread':
+			break;
+		case 'user/-/state/com.google/like':
+			break;
+		case 'user/-/state/com.google/broadcast':
+			break;*/
+	}
+	switch ($r) {
+		case 'user/-/state/com.google/read':
+			$entryDAO->markRead($e_ids, false);
+			break;
+		case 'user/-/state/com.google/starred':
+			$entryDAO->markFavorite($e_ids, false);
+			break;
+	}
+
+	echo 'OK';
+	exit();
+}
+
+function markAllAsRead($streamId, $olderThanId) {
+	logMe("markAllAsRead($streamId, $olderThanId)\n");
+	$entryDAO = new FreshRSS_EntryDAO();
+	if (strpos($streamId, 'feed/') === 0) {
+		$f_id = basename($streamId);
+		$entryDAO->markReadFeed($f_id, $olderThanId);
+	} elseif (strpos($streamId, 'user/-/label/') === 0) {
+		$c_name = basename($streamId);
+		$entryDAO->markReadCatName($c_name, $olderThanId);
+	} elseif ($streamId === 'user/-/state/com.google/reading-list') {
+		$entryDAO->markReadEntries($olderThanId, false, -1);
+	}
+
+	echo 'OK';
+	exit();
+}
+
+logMe('----------------------------------------------------------------'."\n");
+//logMe(debugInfo());
+
+$pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_INFO']);
+$pathInfos = explode('/', $pathInfo);
+
+Minz_Configuration::init();
+
+if (!Minz_Configuration::apiEnabled()) {
+	serviceUnavailable();
+}
+
+Minz_Session::init('FreshRSS');
+
+$conf = authorizationToUserConf();
+$user = $conf == null ? '' : $conf->user;
+
+logMe('User => ' . $user . "\n");
+
+Minz_Session::_param('currentUser', $user);
+
+if (count($pathInfos) < 3) {
+	badRequest();
+}
+elseif ($pathInfos[1] === 'accounts') {
+	if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd'])) {
+		clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']);
+	}
+}
+elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) {
+	if ($user == '') {
+		unauthorized();
+	}
+	$timestamp = isset($_GET['ck']) ? intval($_GET['ck']) : 0;	//ck=[unix timestamp] : Use the current Unix time here, helps Google with caching.
+	switch ($pathInfos[4]) {
+		case 'stream':
+			$exclude_target = isset($_GET['xt']) ? $_GET['xt'] : '';	//xt=[exclude target] : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests).
+			$count = isset($_GET['n']) ? intval($_GET['n']) : 20;	//n=[integer] : The maximum number of results to return.
+			$order = isset($_GET['r']) ? $_GET['r'] : 'd';	//r=[d|n|o] : Sort order of item results. d or n gives items in descending date order, o in ascending order.
+			$start_time = isset($_GET['ot']) ? intval($_GET['ot']) : 0;	//ot=[unix timestamp] : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned.
+			$continuation = isset($_GET['c']) ? $_GET['c'] : '';	//Continuation token. If a StreamContents response does not represent all items in a timestamp range, it will have a continuation attribute. The same request can be re-issued with the value of that attribute put in this parameter to get more items
+			if (isset($pathInfos[5]) && $pathInfos[5] === 'contents' && isset($pathInfos[6])) {
+				if (isset($pathInfos[7])) {
+					if ($pathInfos[6] === 'feed') {
+						$include_target = $pathInfos[7];
+						StreamContents($pathInfos[6], $include_target, $start_time, $count, $order, $exclude_target, $continuation);
+					} elseif ($pathInfos[6] === 'user' && isset($pathInfos[8]) && isset($pathInfos[9])) {
+						if ($pathInfos[8] === 'state') {
+							if ($pathInfos[9] === 'com.google' && isset($pathInfos[10])) {
+								if ($pathInfos[10] === 'reading-list' || $pathInfos[10] === 'starred') {
+									$include_target = '';
+									streamContents($pathInfos[10], $include_target, $start_time, $count, $order, $exclude_target, $continuation);
+								}
+							}
+						} elseif ($pathInfos[8] === 'label') {
+							$include_target = $pathInfos[9];
+							streamContents($pathInfos[8], $include_target, $start_time, $count, $order, $exclude_target, $continuation);
+						}
+					}
+				} else {	//EasyRSS
+					$include_target = '';
+					streamContents('reading-list', $include_target, $start_time, $count, $order, $exclude_target, $continuation);
+				}
+			} elseif ($pathInfos[5] === 'items') {
+				if ($pathInfos[6] === 'ids' && isset($_GET['s'])) {
+					$streamId = $_GET['s'];	//StreamId for which to fetch the item IDs. The parameter may be repeated to fetch the item IDs from multiple streams at once (more efficient from a backend perspective than multiple requests).
+					streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target);
+				}
+			}
+			break;
+		case 'tag':
+			if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
+				$output = isset($_GET['output']) ? $_GET['output'] : '';
+				if ($output !== 'json') notImplemented();
+				tagList($_GET['output']);
+			}
+			break;
+		case 'subscription':
+			if (isset($pathInfos[5]) && $pathInfos[5] === 'list') {
+				$output = isset($_GET['output']) ? $_GET['output'] : '';
+				if ($output !== 'json') notImplemented();
+				subscriptionList($_GET['output']);
+			}
+			break;
+		case 'unread-count':
+			$output = isset($_GET['output']) ? $_GET['output'] : '';
+			if ($output !== 'json') notImplemented();
+			$all = isset($_GET['all']) ? $_GET['all'] : '';
+			unreadCount($all);
+			break;
+		case 'edit-tag':	//http://blog.martindoms.com/2010/01/20/using-the-google-reader-api-part-3/
+			$token = isset($_POST['T']) ? trim($_POST['T']) : '';
+			checkToken($conf, $token);
+			$a = isset($_POST['a']) ? $_POST['a'] : '';	//Add:	user/-/state/com.google/read	user/-/state/com.google/starred
+			$r = isset($_POST['r']) ? $_POST['r'] : '';	//Remove:	user/-/state/com.google/read	user/-/state/com.google/starred
+			$e_ids = multiplePosts('i');	//item IDs
+			editTag($e_ids, $a, $r);
+			break;
+		case 'mark-all-as-read':
+			$token = isset($_POST['T']) ? trim($_POST['T']) : '';
+			checkToken($conf, $token);
+			$streamId = $_POST['s'];	//StreamId
+			$ts = isset($_POST['ts']) ? $_POST['ts'] : '0';	//Older than timestamp in nanoseconds
+			if (!ctype_digit($ts)) {
+				$ts = '0';
+			}
+			markAllAsRead($streamId, $ts);
+			break;
+		case 'token':
+			Token($conf);
+			break;
+	}
+} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {
+	checkCompatibility();
+}
+
+badRequest();

+ 20 - 0
p/api/index.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<title>FreshRSS API</title>
+<meta name="robots" content="noindex" />
+<link rel="start" href="../i/" />
+</head>
+
+<body>
+<h1>FreshRSS API</h1>
+
+<h2>Google Reader compatible API</h2>
+<ul>
+<li><a href="greader.php/check%2Fcompatibility" rel="nofollow">Check full server configuration (with <code>%2F</code> support)</a></li>
+<li><a href="greader.php/check/compatibility" rel="nofollow">Check partial server configuration (without <code>%2F</code> support)</a></li>
+</ul>
+
+</body>
+</html>

+ 1 - 1
p/i/index.php

@@ -35,7 +35,7 @@ if (file_exists ('install.php')) {
 			@filemtime(LOG_PATH . '/' . $currentUser . '.log'),
 			@filemtime(DATA_PATH . '/config.php')
 		);
-		if (httpConditional($dateLastModification, 0, 0, false, false, true)) {
+		if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
 			exit();	//No need to send anything
 		}
 	}

+ 5 - 3
p/i/install.php

@@ -228,13 +228,15 @@ function saveStep3 () {
 		$ini_array = array(
 			'general' => array(
 				'environment' => empty($_SESSION['environment']) ? 'production' : $_SESSION['environment'],
-				'use_url_rewriting' => false,
 				'salt' => $_SESSION['salt'],
 				'base_url' => '',
 				'title' => $_SESSION['title'],
 				'default_user' => $_SESSION['default_user'],
 				'auth_type' => $_SESSION['auth_type'],
 				'allow_anonymous' => isset($_SESSION['allow_anonymous']) ? $_SESSION['allow_anonymous'] : false,
+				'allow_anonymous_refresh' => false,
+				'unsafe_autologin_enabled' => false,
+				'api_enabled' => false,
 			),
 			'db' => array(
 				'type' => $_SESSION['bd_type'],
@@ -837,7 +839,7 @@ function printStep2 () {
 					<?php if (!in_array($_SESSION['auth_type'], array('form', 'persona', 'http_auth', 'none'))) { ?>
 						<option selected="selected"></option>
 					<?php } ?>
-					<option value="form"<?php echo $_SESSION['auth_type'] === 'form' ? ' selected="selected"' : '', version_compare(PHP_VERSION, '5.3', '<') ? ' disabled="disabled"' : ''; ?>><?php echo _t('auth_form'); ?></option>
+					<option value="form"<?php echo $_SESSION['auth_type'] === 'form' ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"'; ?>><?php echo _t('auth_form'); ?></option>
 					<option value="persona"<?php echo $_SESSION['auth_type'] === 'persona' ? ' selected="selected"' : ''; ?>><?php echo _t('auth_persona'); ?></option>
 					<option value="http_auth"<?php echo $_SESSION['auth_type'] === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : ''; ?>><?php echo _t('http_auth'); ?> (REMOTE_USER = '<?php echo httpAuthUser(); ?>')</option>
 					<option value="none"<?php echo $_SESSION['auth_type'] === 'none' ? ' selected="selected"' : ''; ?>><?php echo _t('auth_none'); ?></option>
@@ -911,7 +913,7 @@ function printStep3 () {
 		<div class="form-group">
 			<label class="group-name" for="user"><?php echo _t ('username'); ?></label>
 			<div class="group-controls">
-				<input type="text" id="user" name="user" maxlength="16" pattern="[0-9A-Za-z_]{1,16}" value="<?php echo isset ($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?>" />
+				<input type="text" id="user" name="user" maxlength="16" pattern="[0-9A-Za-z_.-]{1,16}" value="<?php echo isset ($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?>" />
 			</div>
 		</div>
 

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
p/scripts/jquery.min.js


+ 135 - 64
p/scripts/main.js

@@ -1,6 +1,7 @@
 "use strict";
 var $stream = null,
-	isCollapsed = true;
+	isCollapsed = true,
+	shares = 0;
 
 function is_normal_mode() {
 	return $stream.hasClass('normal');
@@ -206,14 +207,10 @@ function mark_favorite(active) {
 }
 
 function toggleContent(new_active, old_active) {
-	old_active.removeClass("active");
-
 	if (new_active.length === 0) {
 		return;
 	}
 
-	old_active.removeClass("current");
-
 	if (does_lazyload) {
 		new_active.find('img[data-original], iframe[data-original]').each(function () {
 			this.setAttribute('src', this.getAttribute('data-original'));
@@ -225,7 +222,10 @@ function toggleContent(new_active, old_active) {
 		if (isCollapsed) {
 			new_active.addClass("active");
 		}
+		old_active.removeClass("active current");
 		new_active.addClass("current");
+	} else {
+		new_active.toggleClass('active');
 	}
 
 	var box_to_move = "html,body",
@@ -235,28 +235,27 @@ function toggleContent(new_active, old_active) {
 		relative_move = true;
 	}
 
-	var new_pos = new_active.position().top,
-		old_scroll = $(box_to_move).scrollTop();
-	if (hide_posts) {
+	if (sticky_post) {
+		var new_pos = new_active.position().top - new_active.children('.flux_header').outerHeight(),
+			old_scroll = $(box_to_move).scrollTop();
 
-		new_pos = new_active.position().top;
-		old_scroll = $(box_to_move).scrollTop();
+		if (hide_posts) {
+			if (relative_move) {
+				new_pos += old_scroll;
+			}
 
-		if (relative_move) {
-			new_pos += old_scroll;
-		}
+			if (old_active[0] !== new_active[0]) {
+				new_active.children(".flux_content").first().each(function () {
+					$(box_to_move).scrollTop(new_pos).scrollTop();
+				});
+			}
+		} else {
+			if (relative_move) {
+				new_pos += old_scroll;
+			}
 
-		if (old_active[0] !== new_active[0]) {
-			new_active.children(".flux_content").first().each(function () {
-				$(box_to_move).scrollTop(new_pos).scrollTop();
-			});
-		}
-	} else {
-		if (relative_move) {
-			new_pos += old_scroll;
+			$(box_to_move).scrollTop(new_pos).scrollTop();
 		}
-
-		$(box_to_move).scrollTop(new_pos).scrollTop();
 	}
 
 	if (auto_mark_article) {
@@ -275,73 +274,83 @@ function next_entry() {
 		new_active = old_active.length === 0 ? $(".flux:first") : old_active.nextAll(".flux:first");
 	toggleContent(new_active, old_active);
 
-	if (!auto_load_more) {
-		var last_active = $(".flux:last");
-		if (last_active.attr("id") === new_active.attr("id")) {
-			load_more_posts();
-		}
+	if (new_active.nextAll().length < 3) {
+		load_more_posts();
 	}
 }
 
 function prev_feed() {
-	if ($('li.active').length > 0) {
-		var pf = $('li.active').prev().find('a.feed');
-		if (pf.length > 0) {
-			pf[0].click();
-		}
+	var active_feed = $("#aside_flux .feeds li.active");
+	if (active_feed.length > 0) {
+		active_feed.prev().find('a.feed').each(function(){this.click();});
 	} else {
-		first_feed();
+		last_feed();
 	}
 }
 
 function next_feed() {
-	if ($('li.active').length > 0) {
-		var nf = $('li.active').next().find('a.feed');
-		if (nf.length > 0) {
-			nf[0].click();
-		}
+	var active_feed = $("#aside_flux .feeds li.active");
+	if (active_feed.length > 0) {
+		active_feed.next().find('a.feed').each(function(){this.click();});
 	} else {
-		last_feed();
+		first_feed();
 	}
 }
 
 function first_feed() {
-	$('.feeds.active li').first().find('a')[1].click();
+	var feed = $("#aside_flux .feeds.active li:first");
+	if (feed.length > 0) {
+		feed.find('a')[1].click();
+	}
 }
 
 function last_feed() {
-	$('.feeds.active li').last().find('a')[1].click();
+	var feed = $("#aside_flux .feeds.active li:last");
+	if (feed.length > 0) {
+		feed.find('a')[1].click();
+	}
 }
 
 function prev_category() {
-	if ($('div.active').length > 0) {
-		var pc = $('div.active').parent('li').prev().find('div.stick a.btn');
-		if (pc.length > 0) {
-			pc[0].click();
-			return;
+	var active_cat = $("#aside_flux .category.stick.active");
+
+	if (active_cat.length > 0) {
+		var prev_cat = active_cat.parent('li').prev().find('.category.stick a.btn');
+		if (prev_cat.length > 0) {
+			prev_cat[0].click();
 		}
 	} else {
-		first_category();
+		last_category();
 	}
+	return;
 }
 
 function next_category() {
-	if ($('div.active').length > 0) {
-		var nc = $('div.active').parent('li').next().find('div.stick a.btn');
-		if (nc.length > 0) {
-			nc[0].click();
+	var active_cat = $("#aside_flux .category.stick.active");
+
+	if (active_cat.length > 0) {
+		var next_cat = active_cat.parent('li').next().find('.category.stick a.btn');
+		if (next_cat.length > 0) {
+			next_cat[0].click();
 		}
 	} else {
-		last_category();
+		first_category();
 	}
+	return;
 }
 
 function first_category() {
-	$('div.category.stick').first().find('a.btn')[0].click();
+	var cat = $("#aside_flux .category.stick:first");
+	if (cat.length > 0) {
+		cat.find('a.btn')[0].click();
+	}
 }
 
 function last_category() {
-	$('div.category.stick').last().find('a.btn')[0].click();
+	var cat = $("#aside_flux .category.stick:last");
+	if (cat.length > 0) {
+		cat.find('a.btn')[0].click();
+	}
 }
 
 function collapse_entry() {
@@ -558,21 +567,21 @@ function init_shortcuts() {
 		'disable_in_input': true
 	});
 	// Touches de navigation pour les categories
-	shortcut.add("ctrl+" + shortcuts.prev_entry, prev_category, {
+	shortcut.add("alt+" + shortcuts.prev_entry, prev_category, {
 		'disable_in_input': true
 	});
-	shortcut.add("ctrl+" + shortcuts.next_entry, next_category, {
+	shortcut.add("alt+" + shortcuts.next_entry, next_category, {
 		'disable_in_input': true
 	});
-	shortcut.add("ctrl+" + shortcuts.first_entry, first_category, {
+	shortcut.add("alt+" + shortcuts.first_entry, first_category, {
 		'disable_in_input': true
 	});
-	shortcut.add("ctrl+" + shortcuts.last_entry, last_category, {
+	shortcut.add("alt+" + shortcuts.last_entry, last_category, {
 		'disable_in_input': true
 	});
 
 	shortcut.add(shortcuts.go_website, function () {
-		var url_website = $(".flux.current .link a").attr("href");
+		var url_website = $('.flux.current > .flux_header > .title > a').attr("href");
 
 		if (auto_mark_site) {
 			$(".flux.current").each(function () {
@@ -590,11 +599,17 @@ function init_shortcuts() {
 	}, {
 		'disable_in_input': true
 	});
+
+	shortcut.add(shortcuts.focus_search, function () {
+		focus_search();
+	}, {
+		'disable_in_input': true
+	});
 }
 
 function init_stream(divStream) {
-	divStream.on('click', '.flux_header', function (e) {	//flux_header_toggle
-		if ($(e.target).closest('.item.website, .item.link').length > 0) {
+	divStream.on('click', '.flux_header,.flux_content', function (e) {	//flux_toggle
+		if ($(e.target).closest('.content, .item.website, .item.link').length > 0) {
 			return;
 		}
 		var old_active = $(".flux.current"),
@@ -761,7 +776,11 @@ function load_more_posts() {
 	$.get(url_load_more, function (data) {
 		box_load_more.children('.flux:last').after($('#stream', data).children('.flux, .day'));
 		$('.pagination').replaceWith($('.pagination', data));
-		$('#bigMarkAsRead').attr('href', $('#nav_menu_read_all>a').attr('href'));
+		if (display_order === 'ASC') {
+			$('#nav_menu_read_all>a').attr('href', $('#bigMarkAsRead').attr('href'));
+		} else {
+			$('#bigMarkAsRead').attr('href', $('#nav_menu_read_all>a').attr('href'));
+		}
 
 		$('[id^=day_]').each(function (i) {
 			var ids = $('[id="' + this.id + '"]');
@@ -778,6 +797,10 @@ function load_more_posts() {
 	});
 }
 
+function focus_search() {
+	$('#search').focus();
+}
+
 function init_load_more(box) {
 	box_load_more = box;
 
@@ -928,7 +951,7 @@ function init_confirm_action() {
 }
 
 function init_print_action() {
-	$('.print-article').click(function () {
+	$('.item.share > a[href="#"]').click(function () {
 		var content = "<html><head><style>"
 			+ "body { font-family: Serif; text-align: justify; }"
 			+ "a { color: #000; text-decoration: none; }"
@@ -948,6 +971,50 @@ function init_print_action() {
 	});
 }
 
+function init_share_observers() {
+	shares = $('.form-group:not(".form-actions")').length;
+
+	$('.post').on('click', '.share.remove', function(e) {
+		e.preventDefault();
+		$(this).parents('.form-group').remove();
+	});
+
+	$('.share.add').on('click', function(e) {
+		e.preventDefault();
+		var opt = $(this).siblings('select').find(':selected');
+		var row = $(this).parents('form').data(opt.data('form'));
+		row = row.replace('##label##', opt.html(), 'g');
+		row = row.replace('##type##', opt.val(), 'g');
+		row = row.replace('##help##', opt.data('help'), 'g');
+		row = row.replace('##key##', shares, 'g');
+		$(this).parents('.form-actions').before(row);
+		shares++;
+	});
+}
+
+function init_feed_observers() {
+	$('select[id="category"]').on('change', function() {
+		var detail = $('#new_category_name').parent();
+		if ($(this).val() === 'nc') {
+			detail.show();
+			detail.find('input').focus();
+		} else {
+			detail.hide();
+		}
+	});
+}
+
+function init_password_observers() {
+	$('input[type="password"] + a.btn.toggle-password').on('click', function(e) {
+		e.preventDefault();
+		var passwordField = $(this).siblings('input[type="password"]');
+		passwordField.attr('type', 'text');
+		setTimeout(function() {
+			passwordField.attr('type', 'password');
+		}, 2000);
+	});
+}
+
 function init_all() {
 	if (!(window.$ && window.url_freshrss && ((!full_lazyload) || $.fn.lazyload))) {
 		if (window.console) {
@@ -977,6 +1044,10 @@ function init_all() {
 		init_shortcuts();
 		init_print_action();
 		window.setInterval(refreshUnreads, 120000);
+	} else {
+		init_share_observers();
+		init_feed_observers();
+		init_password_observers();
 	}
 
 	if (window.console) {

+ 32 - 21
p/themes/Dark/freshrss.css

@@ -88,6 +88,10 @@
 		.nav_menu .search {
 			display:none;
 		}
+		.nav_menu .btn[aria-checked="true"]{
+			border-color: #2f2f2f;
+			box-shadow: 0 0 10px 3px #2f2f2f inset;
+		}
 
 .favicon {
 	height: 16px;
@@ -290,7 +294,7 @@
 		.flux .item.title {
 			background: inherit;
 		}
-			.flux .item.title a {
+			.flux .title a {
 				color: #888;
 				outline: none;
 			}
@@ -354,13 +358,15 @@
 			font-size: 120%;
 		}
 			#stream.global .btn:not([data-unread="0"]) {
-				font-weight:bold;
+				background: #34495e;
+				color: #fff;
+				font-weight: bold;
 			}
 			#stream.global .btn:first-child:not([data-unread="0"]):after {
 				top: 0; right: 5px;
 				border: 0;
 				background: none;
-				color: #666;
+				color: #fff;
 				font-weight: bold;
 				box-shadow: none;
 			}
@@ -504,10 +510,10 @@
 			font-style: italic;
 		}
 	.pagination:first-child .item {
-		border-bottom: 1px solid #aaa;
+		border-bottom: 1px solid #2f2f2f;
 	}
 	.pagination:last-child .item {
-		border-top: 1px solid #aaa;
+		border-top: 1px solid #2f2f2f;
 	}
 
 #nav_entries {
@@ -570,35 +576,25 @@
 	box-shadow: 0 0 5px #666;
 	background: #1a1a1a;
 	color: #888;
+	border: 1px solid #f4f899;
 	font-weight: bold;
 	z-index: 10;
 }
 	#notification.closed {
 		display: none;
 	}
-	#notification.good {
-		border:1px solid #f4f899;
-	}
-	#notification.bad {
-		border:1px solid #f4a899;
-	}
 	#notification a.close {
+		position: absolute;
+		top: -10px; right: -10px;
 		display: inline-block;
 		width: 16px;
 		height: 16px;
-		float: right;
-		margin: -20px -20px 0 0;
 		padding: 5px;
 		background: #1a1a1a;
 		border-radius: 50px;
 		line-height: 16px;
-	}
-	#notification.good a.close{
 		border:1px solid #f4f899;
 	}
-	#notification.bad a.close{
-		border:1px solid #f4a899;
-	}
 
 .toggle_aside, .btn.toggle_aside {
 	display: none;
@@ -780,10 +776,25 @@ select.number option {
 		text-shadow: none;
 	}
 
-	.notification,
+	#notification,
 	.actualizeProgress {
-		left: 10px;
-		right: 10px;
+		top: 0;
+		left: 0;
+		right: 0;
+		border-radius: 0;
+		border: none;
+		border-bottom: 1px solid #f4f899;
+	}
+	#notification a.close {
+		left: 0; right: 0;
+		top: 0; bottom: 0;
+		width: auto;
+		height: auto;
+		background: transparent;
+		border: none;
+	}
+	#notification a.close .icon {
+		display: none;
 	}
 }
 

+ 0 - 6
p/themes/Dark/global.css

@@ -416,12 +416,6 @@ input, select, textarea {
 				background: #26303F;
 				color: #888;
 			}
-				.dropdown-menu > .item[aria-checked="true"] > a:before {
-					content: '✓ ';
-					font-weight: bold;
-					margin: 0 0 0 -1.2em;
-					padding: 0 0.2em 0 0;
-				}
 				.dropdown-menu > .item:hover > a {
 					color: #888;
 					text-decoration: none;

+ 29 - 8
p/themes/Flat/freshrss.css

@@ -87,6 +87,10 @@ body {
 		.nav_menu .search {
 			display:none;
 		}
+		.nav_menu .btn[aria-checked="true"]{
+			background-color: #2980B9;
+			border-bottom-color: #3498DB;
+		}
 
 .favicon {
 	height: 16px;
@@ -286,7 +290,7 @@ body {
 		.flux .item.title {
 			background: inherit;
 		}
-			.flux .item.title a {
+			.flux .title a {
 				color: #333;
 				outline: none;
 			}
@@ -350,13 +354,15 @@ body {
 			font-size: 120%;
 		}
 			#stream.global .btn:not([data-unread="0"]) {
-				font-weight:bold;
+				background: #3498db;
+				color: #fff;
+				font-weight: bold;
 			}
 			#stream.global .btn:first-child:not([data-unread="0"]):after {
 				top: 0; right: 5px;
 				border: 0;
 				background: none;
-				color: #333;
+				color: #fff;
 				font-weight: bold;
 				box-shadow: none;
 			}
@@ -587,11 +593,11 @@ body {
 		color: #fff;
 	}
 	#notification a.close {
+		position: absolute;
+		top: -6px; right: -6px;
 		display: inline-block;
 		width: 16px;
 		height: 16px;
-		float: right;
-		margin: -16px -16px 0 0;
 		padding: 5px;
 		border-radius: 3px;
 		line-height: 16px;
@@ -788,10 +794,25 @@ select.number option {
 		text-shadow: none;
 	}
 
-	.notification,
+	#notification,
 	.actualizeProgress {
-		left: 10px;
-		right: 10px;
+		top: 0;
+		left: 0;
+		right: 0;
+		border-radius: 0;
+	}
+	#notification a.close,
+	#notification.good a.close,
+	#notification.bad a.close {
+		left: 0; right: 0;
+		top: 0; bottom: 0;
+		width: auto;
+		height: auto;
+		background: transparent;
+		border: none;
+	}
+	#notification a.close .icon {
+		display: none;
 	}
 }
 

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů