Index: extensions/PHP_Optimisateur/index.php
===================================================================
--- extensions/PHP_Optimisateur/index.php	(revision 9515)
+++ extensions/PHP_Optimisateur/index.php	(revision 10337)
@@ -2,18 +2,26 @@
 /***************************************\
 |			PHP OPTIMISATEUR			|
-|			  Version 1.3.3				|
+|			  Version 1.4				|
 \***************************************/
 
 session_start();
 set_time_limit(7200);
+define('ROOT_DIR', dirname(__FILE__).'\\');
 
-$APPversion = '1.3';
+$APPversion = '1.4';
 $TIME_START = microtime(true);
 $ERRORS = array();
 $CONF = array();
-$PAGE_CONTENT = array(0=>null,1=>null,2=>null);
+$LOG = array();
+$PAGE = array(
+	'section' => 'home',
+	'header' => null,
+	'content' => null,
+	'msgs' => null,
+	'end' => null,
+);
 
 include('include/functions.php');
-$PAGE = (isset($_GET['page'])) ? $_GET['page'] : 'home';
+if (isset($_GET['page'])) $PAGE['section'] = $_GET['page'];
 
 
@@ -21,5 +29,5 @@
 ### CONFIGURATION ###
 if (!file_exists('config.xml')) {
-	$ERRORS['fatal']['ErrorConfigFile'] = true;
+	$ERRORS['fatal'][] = 'ErrorConfigFile';
 } else {
 	$CONF = load_config('config.xml');
@@ -27,45 +35,113 @@
 
 if (!file_exists('include/nconvert.exe')) {
-	$ERRORS['fatal']['ErrorNconvert'] = true;
+	$ERRORS['fatal'][] = 'ErrorNconvert';
+}
+
+$CONF = array_merge($CONF, GetLanguage());
+include('language/'.$CONF['user_lang'].'/common.lang.php');
+
+
+
+### PROCESSUS ###
+switch ($PAGE['section']) {
+	case 'home':
+		if (!isset($ERRORS['fatal'])) {
+			if (!file_exists($CONF['DIRsource'])) {
+				mkdir($CONF['DIRsource']);
+			}
+			if (!file_exists($CONF['DIRsortie'])) {
+				mkdir($CONF['DIRsortie']);
+			}
+			if (is_dir_empty($CONF['DIRsource'])) {
+				$ERRORS['fatal'][] = 'ErrorFolderIn';
+			}
+			if ($CONF['silentORNOT'] == 'block' AND !is_dir_empty($CONF['DIRsortie'])) {
+				$ERRORS['fatal'][] = 'ErrorFolderOut';
+			} else if ($CONF['silentORNOT'] == 'erase' AND !is_dir_empty($CONF['DIRsortie'])) {
+				$ERRORS['notice'][] = 'EraseFolderOut';
+			}
+		}
+		break;
+		
+	case 'setup':
+		if (isset($_POST['submit'])) {
+			include('include/save_config.php');
+		}
+		break;
+	
+	case 'process':
+		include('include/main.php');
+		break;
 }
 
 
 
-### HEADER ###
-$CONF = array_merge($CONF, GetLanguage());
-include('language/'.$CONF['user_lang'].'/'.$CONF['user_lang'].'.php');
-include('include/header.php');
+### AFFICHAGE ###
+switch ($PAGE['section']) {
+	case 'home':
+		include('include/display_config.php');
+		
+		if (isset($ERRORS['fatal'])) {
+			$PAGE['end'] .= '
+			<div class="generic link">
+				<a class="input-submit" href="index.php">'.l10n('Reload').'</a>
+				<a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
+			</div>';
 
+		} else {
+			$PAGE['end'] .= '
+			<div class="generic finish">
+				<span id="ready-text">'.l10n('Ready').'</span>
+				<span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
+			</div>
+			<div class="generic link">
+				<a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
+				<a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
+			</div>';
+		}
+		break;
+		
+	case 'setup':
+		if (isset($ERRORS['fatal'])) {
+			$PAGE['end'] .= '
+			<div class="generic link">
+				<a class="input-submit" href="index.php">'.l10n('Back').'</a>
+				<a class="input-submit" href="index.php?page=setup">'.l10n('Reload').'</a>
+			</div>';
 
+		} else {
+			include('include/setup.php');
+		}
+		break;
+	
+	case 'process':
+		### Affichage des fichiers traités et création du log ###
+		$nb_files = count($FilesSource);
+		$time = intval((microtime(true)-$TIME_START));
+		$logfile = print_log($nb_files, $time);
+		
+		$PAGE['content'] .= '
+		<div class="generic files">
+			<h2>'.l10n('Source files').'</h2>
+			<ul>';
+				foreach ($FilesSource as $value) {
+					$PAGE['content'] .= '<li>'.$value.'</li>';
+				}
+			$PAGE['content'] .= '</ul>
+			<i>'.l10n('%d files', $nb_files).'</i><br>
+			<b>Log :</b> <a href="logs/'.$logfile.'">'.$logfile.'</a>
+		</div>';
+		
 
-### PROCESSUS ###
-if ($PAGE == 'home') {
-	if (!isset($ERRORS['fatal'])) {
-		if (!file_exists($CONF['DIRsource'])) {
-			mkdir($CONF['DIRsource']);
-		}
-		if (!file_exists($CONF['DIRsortie'])) {
-			mkdir($CONF['DIRsortie']);
-		}
-		if (is_dir_empty($CONF['DIRsource'])) {
-			$ERRORS['fatal']['ErrorFolderIn'] = true;
-		}
-		if ($CONF['silentORNOT'] == 'block' AND !is_dir_empty($CONF['DIRsortie'])) {
-			$ERRORS['fatal']['ErrorFolderOut'] = true;
-		} else if ($CONF['silentORNOT'] == 'erase' AND !is_dir_empty($CONF['DIRsortie'])) {
-			$ERRORS['notice']['EraseFolderOut'] = true;
-		}
-	}
-	
-} else if ($PAGE == 'setup') {
-	if (isset($_GET['ErrorConfig'])) {
-		$ERRORS['notice']['ErrorConfig'] = true;
-	}
-	if (isset($_POST['DIRsource'])) {
-		include('include/save_config.php');
-	}
-	
-} else if ($PAGE = 'process') {
-	include('include/main.php');
+		unset($FilesSource);
+		unset($FilesSortie);
+		
+		$PAGE['end'] .= '
+		<div class="generic finish">'.l10n('Finish %d seconds', $time).'</div>
+		<div class="generic link">
+			<a class="input-submit" href="index.php">'.l10n('Back').'</a>
+			<a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
+		</div>';
+		break;
 }
 
@@ -73,81 +149,36 @@
 
 ### ERREURS ###
+// erreurs fatales
 if (isset($ERRORS['fatal'])) {
-	$PAGE_CONTENT[1] .= '<div class="generic error">';
-		foreach ($ERRORS['fatal'] as $key => $i) {
-			$PAGE_CONTENT[1] .= '<div>'.l10n('fatal.'.$key).'</div>';
+	$PAGE['msgs'] .= '<div class="generic error">';
+		foreach ($ERRORS['fatal'] as $key) {
+			$PAGE['msgs'] .= '<div>'.l10n('fatal.'.$key).'</div>';
 		}
-	$PAGE_CONTENT[1] .= '</div>';
+	$PAGE['msgs'] .= '</div>';
 }
+// informations
 if (isset($ERRORS['notice'])) {
-	$PAGE_CONTENT[1] .= '<div class="generic notice">';
-		foreach ($ERRORS['notice'] as $key => $i) {
-			$PAGE_CONTENT[1] .= '<div>'.l10n('notice.'.$key).'</div>';
+	$PAGE['msgs'] .= '<div class="generic notice">';
+		foreach ($ERRORS['notice'] as $key) {
+			$PAGE['msgs'] .= '<div>'.l10n('notice.'.$key).'</div>';
 		}
-	$PAGE_CONTENT[1] .= '</div>';
+	$PAGE['msgs'] .= '</div>';
+}
+// erreurs de configuration
+if (isset($ERRORS['conf'])) {
+	$PAGE['msgs'] .= '<div class="generic notice conf">';
+		foreach ($ERRORS['conf'] as $key) {
+			$PAGE['msgs'] .= '<div>'.l10n('notice.'.$key[1].' %s', '<i>'.$key[0].'</i>').'</div>';
+		}
+	$PAGE['msgs'] .= '</div>';
 }
 
 
 
-### AFFICHAGE ###
-if ($PAGE == 'home') {
-	if (isset($ERRORS['fatal'])) {
-		$PAGE_CONTENT[2] .= '
-		<div class="generic link">
-			<a class="input-submit" href="index.php">'.l10n('Back').'</a>
-			<a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
-		</div>';
-
-	} else {
-		include('include/display_config.php');
-		
-		$PAGE_CONTENT[2] .= '
-		<div class="generic finish">
-			<span id="ready-text">'.l10n('Ready').'</span>
-			<span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
-		</div>
-		<div class="generic link">
-			<a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
-			<a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
-		</div>';
-	}
-	
-} else if ($PAGE == 'setup') {
-	if (isset($ERRORS['fatal'])) {
-		$PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a></div>';
-
-	} else {
-		include('include/setup.php');
-	}
-	
-} else if ($PAGE = 'process') {
-	### Affichage des fichiers traités ###
-	$PAGE_CONTENT[0] .= '
-	<div class="generic files">
-		<h2>'.l10n('Source files').'</h2>
-		<ul>';
-			foreach ($FilesSource as $value) {
-				$PAGE_CONTENT[0] .= '<li>'.$value.'</li>';
-			}
-		$PAGE_CONTENT[0] .= '</ul>
-		<i>'.l10n('%d files', count($FilesSource)).'</i>
-	</div>';
-
-	unset($FilesSource);
-	unset($FilesSortie);
-	
-	$PAGE_CONTENT[2] .= '
-	<div class="generic finish">'.l10n('Finish %d seconds', intval((microtime(true)-$TIME_START))).'</div>
-	<div class="generic link">
-		<a class="input-submit" href="index.php">'.l10n('Back').'</a>
-		<a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
-	</div>';
-}
-
-
 ### FIN ###
-echo $PAGE_CONTENT[0];
-echo $PAGE_CONTENT[1];
-echo $PAGE_CONTENT[2];
+include('include/header.php');
+echo $PAGE['content'];
+echo $PAGE['msgs'];
+echo $PAGE['end'];
 
 echo '
