diff options
| author | 2013-05-05 12:58:27 +0200 | |
|---|---|---|
| committer | 2013-05-05 12:58:27 +0200 | |
| commit | 99e8fc0ad67bf7ff14f53fd141fe57b96a107648 (patch) | |
| tree | 78b07eaa7fdc9bde1bf2ecd11e65f22afdcc8944 /public/install.php | |
| parent | 23dd73ddeec2473c3e8a3c517317e074ac53a1d8 (diff) | |
| parent | 22e9fb02f838e2b6ac8c5dd504fad0446c5807dc (diff) | |
Merge branch 'dev' into releases
Diffstat (limited to 'public/install.php')
| -rw-r--r-- | public/install.php | 232 |
1 files changed, 174 insertions, 58 deletions
diff --git a/public/install.php b/public/install.php index 7065e3a77..672bb4418 100644 --- a/public/install.php +++ b/public/install.php @@ -70,7 +70,66 @@ function writeArray ($f, $array) { } } +// gestion internationalisation +$translates = array (); +$actual = 'en'; +function initTranslate () { + global $translates; + global $actual; + + $l = getBetterLanguage ('en'); + if (isset ($_SESSION['language'])) { + $l = $_SESSION['language']; + } + $actual = $l; + + $file = APP_PATH . '/i18n/' . $actual . '.php'; + if (file_exists ($file)) { + $translates = include ($file); + } +} +function getBetterLanguage ($fallback) { + $available = availableLanguages (); + $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE']; + $language = strtolower (substr ($accept, 0, 2)); + + if (isset ($available[$language])) { + return $language; + } else { + return $fallback; + } +} +function availableLanguages () { + return array ( + 'en' => 'English', + 'fr' => 'Français' + ); +} +function _t ($key) { + global $translates; + $translate = $key; + if (isset ($translates[$key])) { + $translate = $translates[$key]; + } + + $args = func_get_args (); + unset($args[0]); + + return vsprintf ($translate, $args); +} + /*** SAUVEGARDES ***/ +function saveLanguage () { + if (!empty ($_POST)) { + if (!isset ($_POST['language'])) { + return false; + } + + $_SESSION['language'] = $_POST['language']; + + header ('Location: index.php?step=1'); + } +} function saveStep2 () { if (!empty ($_POST)) { if (empty ($_POST['sel']) || @@ -95,6 +154,7 @@ function saveStep2 () { writeLine ($f, '<?php'); writeLine ($f, 'return array ('); writeArray ($f, array ( + 'language' => $_SESSION['language'], 'old_entries' => $_SESSION['old_entries'], 'mail_login' => $_SESSION['mail_login'] )); @@ -149,10 +209,13 @@ function deleteInstall () { /*** VÉRIFICATIONS ***/ function checkStep () { + $s0 = checkStep0 (); $s1 = checkStep1 (); $s2 = checkStep2 (); $s3 = checkStep3 (); - if (STEP > 1 && $s1['all'] != 'ok') { + if (STEP > 0 && $s0['all'] != 'ok') { + header ('Location: index.php?step=0'); + } elseif (STEP > 1 && $s1['all'] != 'ok') { header ('Location: index.php?step=1'); } elseif (STEP > 2 && $s2['all'] != 'ok') { header ('Location: index.php?step=2'); @@ -160,6 +223,16 @@ function checkStep () { header ('Location: index.php?step=3'); } } +function checkStep0 () { + $languages = availableLanguages (); + $language = isset ($_SESSION['language']) && + isset ($languages[$_SESSION['language']]); + + return array ( + 'language' => $language ? 'ok' : 'ko', + 'all' => $language ? 'ok' : 'ko' + ); +} function checkStep1 () { $php = version_compare (PHP_VERSION, '5.1.0') >= 0; $minz = file_exists (LIB_PATH . '/minz'); @@ -234,64 +307,98 @@ function checkBD () { } /*** AFFICHAGE ***/ +function printStep0 () { + global $actual; +?> + <?php $s0 = checkStep0 (); if ($s0['all'] == 'ok') { ?> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('language_defined'); ?></p> + <?php } ?> + + <form action="index.php?step=0" method="post"> + <legend><?php echo _t ('choose_language'); ?></legend> + <div class="form-group"> + <label class="group-name" for="language"><?php echo _t ('language'); ?></label> + <div class="group-controls"> + <select name="language" id="language"> + <?php $languages = availableLanguages (); ?> + <?php foreach ($languages as $short => $lib) { ?> + <option value="<?php echo $short; ?>"<?php echo $actual == $short ? ' selected="selected"' : ''; ?>><?php echo $lib; ?></option> + <?php } ?> + </select> + </div> + </div> + + <div class="form-group form-actions"> + <div class="group-controls"> + <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button> + <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button> + <?php if ($s0['all'] == 'ok') { ?> + <a class="btn btn-important next-step" href="?step=1"><?php echo _t ('next_step'); ?></a> + <?php } ?> + </div> + </div> + </form> +<?php +} + function printStep1 () { $res = checkStep1 (); ?> - <noscript><p class="alert alert-warn"><span class="alert-head">Attention !</span> FreshRSS est plus agréable à utiliser avec le Javascript d'activé</p></noscript> + <noscript><p class="alert alert-warn"><span class="alert-head"><?php echo _t ('attention'); ?></span> <?php echo _t ('javascript_is_better'); ?></p></noscript> <?php if ($res['php'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Votre version de PHP est la <?php echo PHP_VERSION; ?> et est compatible avec FreshRSS</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('php_is_ok', PHP_VERSION); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Votre version de PHP est la <?php echo PHP_VERSION; ?>. Vous devriez avoir au moins la version 5.1.0</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('php_is_nok', PHP_VERSION, '5.1.0'); ?></p> <?php } ?> <?php if ($res['minz'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Vous disposez du framework Minz</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('minz_is_ok'); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Vous ne disposez pas de la librairie Minz. Vous devriez exécuter le script <em>build.sh</em> ou bien <a href="https://github.com/marienfressinaud/MINZ">la télécharger sur Github</a> et installer dans le répertoire <em><?php echo LIB_PATH . '/minz'; ?></em> le contenu de son répertoire <em>/lib</em>.</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('minz_is_nok', LIB_PATH . '/minz'); ?></p> <?php } ?> <?php $version = curl_version(); ?> <?php if ($res['curl'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Vous disposez de cURL dans sa version <?php echo $version['version']; ?></p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('curl_is_ok', $version['version']); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Vous ne disposez pas de cURL</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('curl_is_nok'); ?></p> <?php } ?> <?php if ($res['pdo-mysql'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Vous disposez de PDO et de son driver pour MySQL</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('pdomysql_is_ok'); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Vous ne disposez pas de PDO ou de son driver pour MySQL</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('pdomysql_is_nok'); ?></p> <?php } ?> <?php if ($res['cache'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Les droits sur le répertoire de cache sont bons</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('cache_is_ok'); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Veuillez vérifier les droits sur le répertoire <em><?php echo PUBLIC_PATH . '/../cache'; ?></em>. Le serveur HTTP doit être capable d'écrire dedans</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/../cache'); ?></p> <?php } ?> <?php if ($res['log'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Les droits sur le répertoire des logs sont bons</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('log_is_ok'); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Veuillez vérifier les droits sur le répertoire <em><?php echo PUBLIC_PATH . '/../log'; ?></em>. Le serveur HTTP doit être capable d'écrire dedans</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/../log'); ?></p> <?php } ?> <?php if ($res['configuration'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Les droits sur le répertoire de configuration sont bons</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('conf_is_ok'); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Veuillez vérifier les droits sur le répertoire <em><?php echo APP_PATH . '/configuration'; ?></em>. Le serveur HTTP doit être capable d'écrire dedans</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', APP_PATH . '/configuration'); ?></p> <?php } ?> <?php if ($res['data'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> Les droits sur le répertoire de data sont bons</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('data_is_ok'); ?></p> <?php } else { ?> - <p class="alert alert-error"><span class="alert-head">Arf !</span> Veuillez vérifier les droits sur le répertoire <em><?php echo PUBLIC_PATH . '/data'; ?></em>. Le serveur HTTP doit être capable d'écrire dedans</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('damn'); ?></span> <?php echo _t ('file_is_nok', PUBLIC_PATH . '/data'); ?></p> <?php } ?> <?php if ($res['all'] == 'ok') { ?> - <a class="btn btn-important next-step" href="?step=2">Passer à l'étape suivante</a> + <a class="btn btn-important next-step" href="?step=2"><?php echo _t ('next_step'); ?></a> <?php } else { ?> - Veuillez corriger les erreurs avant de passer à l'étape suivante. + <p class="alert alert-error"><?php echo _t ('fix_errors_before'); ?></p> <?php } ?> <?php } @@ -299,15 +406,15 @@ function printStep1 () { function printStep2 () { ?> <?php $s2 = checkStep2 (); if ($s2['all'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> La configuration générale a été enregistrée.</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('general_conf_is_ok'); ?></p> <?php } ?> <form action="index.php?step=2" method="post"> - <legend>Configuration générale</legend> + <legend><?php echo _t ('general_configuration'); ?></legend> <div class="form-group"> - <label class="group-name" for="sel">Chaîne aléatoire</label> + <label class="group-name" for="sel"><?php echo _t ('random_string'); ?></label> <div class="group-controls"> - <input type="text" id="sel" name="sel" value="<?php echo isset ($_SESSION['sel']) ? $_SESSION['sel'] : '123~abcdefghijklmnopqrstuvwxyz~321'; ?>" /> <i class="icon i_help"></i> Vous devriez changer cette valeur par n'importe quelle autre + <input type="text" id="sel" name="sel" value="<?php echo isset ($_SESSION['sel']) ? $_SESSION['sel'] : '123~abcdefghijklmnopqrstuvwxyz~321'; ?>" /> <i class="icon i_help"></i> <?php echo _t ('change_value'); ?> </div> </div> @@ -315,40 +422,40 @@ function printStep2 () { $url = substr ($_SERVER['PHP_SELF'], 0, -10); ?> <div class="form-group"> - <label class="group-name" for="base_url">Base de l'url</label> + <label class="group-name" for="base_url"><?php echo _t ('base_url'); ?></label> <div class="group-controls"> - <input type="text" id="base_url" name="base_url" value="<?php echo isset ($_SESSION['base_url']) ? $_SESSION['base_url'] : $url; ?>" /> <i class="icon i_help"></i> Laissez tel quel dans le doute + <input type="text" id="base_url" name="base_url" value="<?php echo isset ($_SESSION['base_url']) ? $_SESSION['base_url'] : $url; ?>" /> <i class="icon i_help"></i> <?php echo _t ('do_not_change_if_doubt'); ?> </div> </div> <div class="form-group"> - <label class="group-name" for="title">Titre</label> + <label class="group-name" for="title"><?php echo _t ('title'); ?></label> <div class="group-controls"> - <input type="text" id="title" name="title" value="<?php echo isset ($_SESSION['title']) ? $_SESSION['title'] : 'FreshRSS'; ?>" /> + <input type="text" id="title" name="title" value="<?php echo isset ($_SESSION['title']) ? $_SESSION['title'] : _t ('freshrss'); ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="old_entries">Supprimer les articles tous les</label> + <label class="group-name" for="old_entries"><?php echo _t ('delete_articles_every'); ?></label> <div class="group-controls"> - <input type="number" id="old_entries" name="old_entries" value="<?php echo isset ($_SESSION['old_entries']) ? $_SESSION['old_entries'] : '3'; ?>" /> mois + <input type="number" id="old_entries" name="old_entries" value="<?php echo isset ($_SESSION['old_entries']) ? $_SESSION['old_entries'] : '3'; ?>" /> <?php echo _t ('month'); ?> </div> </div> <div class="form-group"> - <label class="group-name" for="mail_login">Adresse mail de connexion (utilise <a href="https://persona.org/">Persona</a>)</label> + <label class="group-name" for="mail_login"><?php echo _t ('persona_connection_email'); ?></label> <div class="group-controls"> - <input type="email" id="mail_login" name="mail_login" value="<?php echo isset ($_SESSION['mail_login']) ? $_SESSION['mail_login'] : ''; ?>" placeholder="Laissez vide pour désactiver" /> - <noscript><b>nécessite que javascript soit activé</b></noscript> + <input type="email" id="mail_login" name="mail_login" value="<?php echo isset ($_SESSION['mail_login']) ? $_SESSION['mail_login'] : ''; ?>" placeholder="<?php echo _t ('blank_to_disable'); ?>" /> + <noscript><b><?php echo _t ('javascript_should_be_activated'); ?></b></noscript> </div> </div> <div class="form-group form-actions"> <div class="group-controls"> - <button type="submit" class="btn btn-important">Valider</button> - <button type="reset" class="btn">Annuler</button> + <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button> + <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button> <?php if ($s2['all'] == 'ok') { ?> - <a class="btn btn-important next-step" href="?step=3">Passer à l'étape suivante</a> + <a class="btn btn-important next-step" href="?step=3"><?php echo _t ('next_step'); ?></a> <?php } ?> </div> </div> @@ -359,34 +466,34 @@ function printStep2 () { function printStep3 () { ?> <?php $s3 = checkStep3 (); if ($s3['all'] == 'ok') { ?> - <p class="alert alert-success"><span class="alert-head">Ok !</span> La configuration de la base de données a été enregistrée.</p> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('ok'); ?></span> <?php echo _t ('bdd_conf_is_ok'); ?></p> <?php } ?> <form action="index.php?step=3" method="post"> - <legend>Configuration de la base de données</legend> + <legend><?php echo _t ('bdd_configuration'); ?></legend> <div class="form-group"> - <label class="group-name" for="host">Host</label> + <label class="group-name" for="host"><?php echo _t ('host'); ?></label> <div class="group-controls"> <input type="text" id="host" name="host" value="<?php echo isset ($_SESSION['bd_host']) ? $_SESSION['bd_host'] : 'localhost'; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="user">Username</label> + <label class="group-name" for="user"><?php echo _t ('username'); ?></label> <div class="group-controls"> <input type="text" id="user" name="user" value="<?php echo isset ($_SESSION['bd_user']) ? $_SESSION['bd_user'] : ''; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="pass">Password</label> + <label class="group-name" for="pass"><?php echo _t ('password'); ?></label> <div class="group-controls"> <input type="password" id="pass" name="pass" value="<?php echo isset ($_SESSION['bd_pass']) ? $_SESSION['bd_pass'] : ''; ?>" /> </div> </div> <div class="form-group"> - <label class="group-name" for="base">Base de données</label> + <label class="group-name" for="base"><?php echo _t ('bdd'); ?></label> <div class="group-controls"> <input type="text" id="base" name="base" value="<?php echo isset ($_SESSION['bd_name']) ? $_SESSION['bd_name'] : ''; ?>" /> </div> @@ -394,10 +501,10 @@ function printStep3 () { <div class="form-group form-actions"> <div class="group-controls"> - <button type="submit" class="btn btn-important">Valider</button> - <button type="reset" class="btn">Annuler</button> + <button type="submit" class="btn btn-important"><?php echo _t ('save'); ?></button> + <button type="reset" class="btn"><?php echo _t ('cancel'); ?></button> <?php if ($s3['all'] == 'ok') { ?> - <a class="btn btn-important next-step" href="?step=4">Passer à l'étape suivante</a> + <a class="btn btn-important next-step" href="?step=4"><?php echo _t ('next_step'); ?></a> <?php } ?> </div> </div> @@ -407,23 +514,27 @@ function printStep3 () { function printStep4 () { ?> - <p class="alert alert-success"><span class="alert-head">Félicitations !</span> L'installation s'est bien passée. Il faut maintenant supprimer le fichier <em>install.php</em> pour pouvoir accéder à FreshRSS... ou simplement cliquer sur le bouton ci-dessous ;)</p> - <a class="btn btn-important next-step" href="?step=5">Terminer l'installation</a> + <p class="alert alert-success"><span class="alert-head"><?php echo _t ('congratulations'); ?></span> <?php echo _t ('installation_is_ok'); ?></p> + <a class="btn btn-important next-step" href="?step=5"><?php echo _t ('finish_installation'); ?></a> <?php } function printStep5 () { ?> - <p class="alert alert-error"><span class="alert-head">Oups !</span> Quelque chose s'est mal passé, vous devriez supprimer le fichier <?php echo PUBLIC_PATH . '/install.php' ?> à la main.</p> + <p class="alert alert-error"><span class="alert-head"><?php echo _t ('oops'); ?></span> <?php echo _t ('install_not_deleted', PUBLIC_PATH . '/install.php'); ?></p> <?php } +initTranslate (); checkStep (); switch (STEP) { -case 1: +case 0: default: + saveLanguage (); + break; +case 1: break; case 2: saveStep2 (); @@ -443,7 +554,8 @@ case 5: <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0"> - <title>Installation - FreshRSS</title> + <title><?php echo _t ('freshrss_installation'); ?></title> + <link rel="stylesheet" type="text/css" media="all" href="theme/fallback.css" /> <link rel="stylesheet" type="text/css" media="all" href="theme/global.css" /> <link rel="stylesheet" type="text/css" media="all" href="theme/freshrss.css" /> </head> @@ -451,25 +563,29 @@ case 5: <div class="header"> <div class="item title"> - <h1><a href="index.php">FreshRSS</a></h1> - <h2>Installation - étape <?php echo STEP; ?></h2> + <h1><a href="index.php"><?php echo _t ('freshrss'); ?></a></h1> + <h2><?php echo _t ('installation_step', STEP); ?></h2> </div> </div> <div id="global"> <ul class="nav nav-list aside"> - <li class="nav-header">Étapes</li> - <li class="item<?php echo STEP == 1 ? ' active' : ''; ?>"><a href="?step=1">Vérifications</a></li> - <li class="item<?php echo STEP == 2 ? ' active' : ''; ?>"><a href="?step=2">Configuration générale</a></li> - <li class="item<?php echo STEP == 3 ? ' active' : ''; ?>"><a href="?step=3">Configuration de la base de données</a></li> - <li class="item<?php echo STEP == 4 ? ' active' : ''; ?>"><a href="?step=4">This is the end</a></li> + <li class="nav-header"><?php echo _t ('steps'); ?></li> + <li class="item<?php echo STEP == 0 ? ' active' : ''; ?>"><a href="?step=0"><?php echo _t ('language'); ?></a></li> + <li class="item<?php echo STEP == 1 ? ' active' : ''; ?>"><a href="?step=1"><?php echo _t ('checks'); ?></a></li> + <li class="item<?php echo STEP == 2 ? ' active' : ''; ?>"><a href="?step=2"><?php echo _t ('general_configuration'); ?></a></li> + <li class="item<?php echo STEP == 3 ? ' active' : ''; ?>"><a href="?step=3"><?php echo _t ('bdd_configuration'); ?></a></li> + <li class="item<?php echo STEP == 4 ? ' active' : ''; ?>"><a href="?step=4"><?php echo _t ('this_is_the_end'); ?></a></li> </ul> <div class="post"> <?php switch (STEP) { - case 1: + case 0: default: + printStep0 (); + break; + case 1: printStep1 (); break; case 2: |
