4
0
Эх сурвалжийг харах

Merge branch '163-export' into dev

Marien Fressinaud 12 жил өмнө
parent
commit
51a70ede02

+ 0 - 65
app/Controllers/configureController.php

@@ -210,71 +210,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 		Minz_View::prependTitle (Minz_Translate::t ('sharing') . ' · ');
 	}
 
-	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'])
-					);
-
-					// 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);
-
-					Minz_Request::forward (array (
-						'c' => 'configure',
-						'a' => 'importExport'
-					), 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') . ' · ');
-	}
-
 	public function shortcutAction () {
 		$list_keys = array ('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter',
 		                    'escape', 'f', 'g', 'h', 'home', 'i', 'insert', 'j', 'k', 'l', 'left',

+ 111 - 0
app/Controllers/importExportController.php

@@ -0,0 +1,111 @@
+<?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');
+	}
+
+	public function indexAction() {
+		$catDAO = new FreshRSS_CategoryDAO ();
+		$this->view->categories = $catDAO->listCategories ();
+
+		$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') . ' · ');
+	}
+
+	public function importAction() {
+		if (Minz_Request::isPost() && $_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'])
+				);
+
+				// 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 ('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);
+
+				Minz_Request::forward (array (
+					'c' => 'configure',
+					'a' => 'importExport'
+				), true);
+			}
+		}
+	}
+
+	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_all = Minz_Request::param('export_all', false);
+
+			// code 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->generate_opml());
+			}
+			if ($export_starred) {
+				$zip->addFromString('starred.json', $this->generate_articles('starred'));
+			}
+			if ($export_all) {
+				$zip->addFromString('all.json', $this->generate_articles('all'));
+			}
+
+			// Close and send to users
+			$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 generate_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;
+		return $this->view->helperToString('export/opml');
+	}
+
+	private function generate_articles($type) {
+		// TODO: we should get articles according to $type
+		return $this->view->helperToString('export/articles');
+	}
+}

+ 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');
 

+ 1 - 1
app/i18n/en.php

@@ -21,7 +21,7 @@ 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',
 
 	'subscription_management'	=> 'Subscriptions management',
 	'main_stream'			=> 'Main stream',

+ 1 - 1
app/i18n/fr.php

@@ -21,7 +21,7 @@ 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',
 
 	'subscription_management'	=> 'Gestion des abonnements',
 	'main_stream'			=> 'Flux principal',

+ 1 - 1
app/layout/aside_feed.phtml

@@ -44,7 +44,7 @@
 	</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>
+		<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' : ''; ?>">

+ 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 } ?>

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

@@ -0,0 +1,30 @@
+<?php
+    // TODO: A lot have to be done!
+    $username = Minz_Session::param('currentUser', '_');
+    $type_id = "TODO";
+    $title = Minz_Translate::t("TODO");
+    $entries = [];
+?>{
+    "id": "user/<?php echo str_replace("\"", "", $username); ?>/state/org.freshrss/<?php echo $type_id; ?>",
+    "title": "<?php echo addslashes($title); ?>",
+    "author": "<?php echo addslashes($username); ?>",
+    "items": [
+        <?php $i = 0; foreach($entries as $entry) { $i++;
+        echo $i > 1 ? ', ': ''; ?>{
+            "id": "<?php echo $entry->id(); ?>",
+            "categories": [<?php /* TODO */ ?>],
+            "title": "<?php echo addslashes($entry->title()); ?>",
+            "published": <?php echo $entry->date(true); ?>,
+            "updated": <?php echo $entry->date(true); ?>,
+            "content": "<?php echo addslashes($entry->content()); ?>",
+            "origin": {
+                <?php /* TODO */ ?>
+                "streamId": "",
+                "title": "",
+                "htmlUrl": "",
+                "feedUrl": ""
+            }
+        }
+        <?php } ?>
+    ]
+}

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

@@ -0,0 +1,15 @@
+<?php
+require_once(LIB_PATH . '/lib_opml.php');
+
+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>

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

@@ -0,0 +1,50 @@
+<?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>
+
+	<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>
+
+				<label class="checkbox" for="export_all">
+					<input type="checkbox" name="export_all" id="export_all" value="1" />
+					<?php echo Minz_Translate::t ('export_all'); ?>
+					<?php echo FreshRSS_Themes::icon('help'); ?> <?php echo Minz_Translate::t('export_all_is_long'); ?>
+				</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 ('export'); ?></button>
+			</div>
+		</div>
+	</form>
+</div>

+ 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__));
 

+ 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 - 9
lib/Minz/Configuration.php

@@ -30,7 +30,6 @@ 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
@@ -43,7 +42,6 @@ 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 $default_user = '';
@@ -90,9 +88,6 @@ 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;
 	}
@@ -176,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,
@@ -262,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'];

+ 34 - 51
lib/Minz/Dispatcher.php

@@ -14,70 +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) {
-		// 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');
-		}
-
-		$text = '';	//TODO: Clean this code
-		while (Minz_Request::$reseted) {
-			Minz_Request::$reseted = false;
+	public function run () {
+		do {
+			self::$needsReset = false;
 
 			try {
 				$this->createController ('FreshRSS_' . Minz_Request::controllerName () . '_Controller');
 				$this->controller->init ();
 				$this->controller->firstAction ();
-				$this->launchAction (
-					Minz_Request::actionName ()
-					. 'Action'
-				);
+				if (!self::$needsReset) {
+					$this->launchAction (
+						Minz_Request::actionName ()
+						. 'Action'
+					);
+				}
 				$this->controller->lastAction ();
 
-				if (!Minz_Request::$reseted) {
-					if ($ob) {
-						ob_start ();
-					}
+				if (!self::$needsReset) {
 					$this->controller->view ()->build ();
-					if ($ob) {
-						$text = ob_get_clean();
-					}
 				}
 			} 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;
 	}
 
 	/**
@@ -97,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 (
@@ -114,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;
-	}
 }

+ 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);
-	 }
-}

+ 3 - 10
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,7 +47,7 @@ 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

+ 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();
+		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

+ 1 - 1
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) {

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

+ 0 - 1
p/i/install.php

@@ -228,7 +228,6 @@ 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'],