From 925f581f2864cbb35cdb8b344d0d29f2659707d4 Mon Sep 17 00:00:00 2001 From: patdenice Date: Mon, 3 Mar 2008 19:42:16 +0000 Subject: Install goes smarty. Get browser language directly. git-svn-id: http://piwigo.org/svn/trunk@2248 68402e56-0260-453c-a942-63ccdbb3a9ee --- install.php | 119 ++++++++++++---------------------------- language/en_UK/install.lang.php | 2 +- language/es_ES/install.lang.php | 2 +- language/fr_FR/install.lang.php | 2 +- template/yoga/install.tpl | 117 ++++++++++++++++++++------------------- 5 files changed, 98 insertions(+), 144 deletions(-) diff --git a/install.php b/install.php index f423842a1..b8dca9fdd 100644 --- a/install.php +++ b/install.php @@ -27,24 +27,6 @@ //----------------------------------------------------------- include define('PHPWG_ROOT_PATH','./'); -// -// Pick a language, any language ... -// -function language_select($default, $select_name = "language") -{ - $available_lang = get_languages('utf-8'); - - $lang_select = ''; - - return $lang_select; -} - /** * loads an sql file and executes all queries * @@ -209,13 +191,22 @@ include(PHPWG_ROOT_PATH . 'admin/include/functions.php'); include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php'); include(PHPWG_ROOT_PATH . 'include/template.php'); -if ( isset( $_REQUEST['language'] )) +if (isset($_GET['language'])) { - $language = strip_tags($_REQUEST['language']); + $language = strip_tags($_GET['language']); } else { $language = 'en_UK'; + // Try to get browser language + foreach (get_languages('utf-8') as $language_code => $language_name) + { + if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)) + { + $language = $language_code; + break; + } + } } load_language( 'common.lang', '', $language, false, 'utf-8' ); @@ -223,7 +214,7 @@ load_language( 'admin.lang', '', $language, false, 'utf-8' ); load_language( 'install.lang', '', $language, false, 'utf-8' ); //----------------------------------------------------- template initialization -$template=new Template(PHPWG_ROOT_PATH.'template/yoga'); +$template=new Template(PHPWG_ROOT_PATH.'template/yoga', 'clear'); $template->set_filenames( array('install'=>'install.tpl') ); $step = 1; //---------------------------------------------------------------- form analyze @@ -303,12 +294,7 @@ define(\'DB_COLLATE\', \'\'); { $html_content = htmlentities( $file_content, ENT_QUOTES ); $html_content = nl2br( $html_content ); - $template->assign_block_vars( - 'error_copy', - array( - 'FILE_CONTENT' => $html_content, - ) - ); + $template->assign('error_copy', $html_content); } @fputs($fp, $file_content, strlen($file_content)); @fclose($fp); @@ -380,80 +366,45 @@ define(\'DB_COLLATE\', \'\'); } } -$template->assign_vars( +//------------------------------------------------------ start template output +foreach (get_languages('utf-8') as $language_code => $language_name) +{ + if ($language == $language_code) + { + $template->assign('language_selection', $language_code); + } + $languages_options[$language_code] = $language_name; +} +$template->assign('language_options', $languages_options); + +$template->assign( array( + 'T_CONTENT_ENCODING' => 'utf-8', 'RELEASE'=>PHPWG_VERSION, - - 'L_BASE_TITLE'=>l10n('Initial_config'), - 'L_LANG_TITLE'=>l10n('Default_lang'), - 'L_DB_TITLE'=>l10n('step1_title'), - 'L_DB_HOST'=>l10n('step1_host'), - 'L_DB_HOST_INFO'=>l10n('step1_host_info'), - 'L_DB_USER'=>l10n('step1_user'), - 'L_DB_USER_INFO'=>l10n('step1_user_info'), - 'L_DB_PASS'=>l10n('step1_pass'), - 'L_DB_PASS_INFO'=>l10n('step1_pass_info'), - 'L_DB_NAME'=>l10n('step1_database'), - 'L_DB_NAME_INFO'=>l10n('step1_database_info'), - 'L_DB_PREFIX'=>l10n('step1_prefix'), - 'L_DB_PREFIX_INFO'=>l10n('step1_prefix_info'), - 'L_ADMIN_TITLE'=>l10n('step2_title'), - 'L_ADMIN'=>l10n('install_webmaster'), - 'L_ADMIN_INFO'=>l10n('install_webmaster_info'), - 'L_ADMIN_PASSWORD'=>l10n('step2_pwd'), - 'L_ADMIN_PASSWORD_INFO'=>l10n('step2_pwd_info'), - 'L_ADMIN_CONFIRM_PASSWORD'=>l10n('step2_pwd_conf'), - 'L_ADMIN_CONFIRM_PASSWORD_INFO'=>l10n('step2_pwd_conf_info'), - 'L_ADMIN_EMAIL'=>l10n('conf_mail_webmaster'), - 'L_ADMIN_EMAIL_INFO'=>l10n('conf_mail_webmaster_info'), - 'L_SUBMIT'=>l10n('Start_Install'), - 'L_INSTALL_HELP'=>sprintf(l10n('install_help'), 'http://forum.'.PHPWG_DOMAIN.'/'), - 'L_ERR_COPY'=>l10n('step1_err_copy'), - 'L_END_TITLE'=>l10n('install_end_title'), - 'L_END_MESSAGE'=>l10n('install_end_message'), - - 'F_ACTION'=>'install.php', + 'F_ACTION' => 'install.php?language=' . $language, 'F_DB_HOST'=>$dbhost, 'F_DB_USER'=>$dbuser, 'F_DB_NAME'=>$dbname, - 'F_DB_PREFIX' => ( - $table_prefix != DEFAULT_PREFIX_TABLE - ? $table_prefix - : DEFAULT_PREFIX_TABLE - ), + 'F_DB_PREFIX' => $table_prefix, 'F_ADMIN'=>$admin_name, 'F_ADMIN_EMAIL'=>$admin_mail, - 'F_LANG_SELECT'=>language_select($language), - - 'T_CONTENT_ENCODING' => 'utf-8' + 'L_INSTALL_HELP'=>sprintf(l10n('install_help'), 'http://forum.'.PHPWG_DOMAIN.'/'), )); //------------------------------------------------------ errors & infos display -if ( sizeof( $errors ) != 0 ) +if (count($errors) != 0) { - $template->assign_block_vars('errors',array()); - for ( $i = 0; $i < sizeof( $errors ); $i++ ) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); - } + $template->assign('errors', $errors); } -if ( sizeof( $infos ) != 0 ) +if (count($infos) != 0 ) { - $template->assign_block_vars('infos',array()); - for ( $i = 0; $i < sizeof( $infos ); $i++ ) - { - $template->assign_block_vars('infos.info',array('INFO'=>$infos[$i])); - } + $template->assign('infos', $infos); } -if ($step ==1) -{ - $template->assign_block_vars('install',array()); -} -else +if ($step == 1) { - $template->assign_block_vars('install_end',array()); + $template->assign('install', true); } //----------------------------------------------------------- html code display diff --git a/language/en_UK/install.lang.php b/language/en_UK/install.lang.php index d0e6f1139..e8564446c 100644 --- a/language/en_UK/install.lang.php +++ b/language/en_UK/install.lang.php @@ -40,7 +40,7 @@ $lang['step1_err_db'] = 'Connection to server succeed, but it was impossible to $lang['step1_err_server'] = 'Can\'t connect to server'; $lang['step1_err_copy_2'] = 'The next step of the installation is now possible'; $lang['step1_err_copy_next'] = 'next step'; -$lang['step1_err_copy'] = 'Copy the text between hyphens and paste it into the file "include/mysql.inc.php"(Warning : mysql.inc.php must only contain what is in blue, no line return or space character)'; +$lang['step1_err_copy'] = 'Copy the text in red between hyphens and paste it into the file "include/mysql.inc.php"(Warning : mysql.inc.php must only contain what is in blue, no line return or space character)'; $lang['step1_host'] = 'MySQL host'; $lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; diff --git a/language/es_ES/install.lang.php b/language/es_ES/install.lang.php index e64008f4c..8db63c8ab 100644 --- a/language/es_ES/install.lang.php +++ b/language/es_ES/install.lang.php @@ -58,7 +58,7 @@ $lang['step2_pwd'] = 'Palabra de paso'; $lang['step2_pwd_info'] = 'Debe quedar confidencial, permite acceder al tabla de administración.'; $lang['step2_pwd_conf'] = 'Palabra de paso [Confirmar]'; $lang['step2_pwd_conf_info'] = 'Comprobación'; -$lang['step1_err_copy'] = 'Copie el texto en azul entre las rayas y pegúelo en el fichero mysql.inc.php que se encuentra en el repertorio " include " a la base del lugar donde usted instaló a PhpWebGallery (el fichero mysql.inc.php debe contener SÓLO lo que está en azul entre las rayas, ninguna vuelta a la línea o espacio es autorizado)'; +$lang['step1_err_copy'] = 'Copie el texto en rojo entre las rayas y pegúelo en el fichero mysql.inc.php que se encuentra en el repertorio " include " a la base del lugar donde usted instaló a PhpWebGallery (el fichero mysql.inc.php debe contener SÓLO lo que está en azul entre las rayas, ninguna vuelta a la línea o espacio es autorizado)'; $lang['install_help'] = '¿ Necesidad de ayudante? Plantee su cuestión sobre él foro de PhpWebGallery.'; $lang['install_end_message'] = 'La configuración de la aplicación correctamente se celebró, coloca en la etapa próxima

Por medida de seguridad, gracias por suprimir el fichero "install.php"
diff --git a/language/fr_FR/install.lang.php b/language/fr_FR/install.lang.php index 03e891d4b..50c9312ef 100644 --- a/language/fr_FR/install.lang.php +++ b/language/fr_FR/install.lang.php @@ -57,7 +57,7 @@ $lang['step2_pwd'] = 'Mot de passe'; $lang['step2_pwd_info'] = 'Il doit rester confidentiel, il permet d\'accéder au panneau d\'administration.'; $lang['step2_pwd_conf'] = 'Mot de passe [ Confirmer ]'; $lang['step2_pwd_conf_info'] = 'Vérification'; -$lang['step1_err_copy'] = 'Copiez le texte en bleu entre les tirets et collez-le dans le fichier mysql.inc.php qui se trouve dans le répertoire "include" à la base de l\'endroit où vous avez installé PhpWebGallery (le fichier mysql.inc.php ne doit comporter QUE ce qui est en bleu entre les tirets, aucun retour à la ligne ou espace n\'est autorisé)'; +$lang['step1_err_copy'] = 'Copiez le texte en rouge entre les tirets et collez-le dans le fichier mysql.inc.php qui se trouve dans le répertoire "include" à la base de l\'endroit où vous avez installé PhpWebGallery (le fichier mysql.inc.php ne doit comporter QUE ce qui est en bleu entre les tirets, aucun retour à la ligne ou espace n\'est autorisé)'; $lang['install_help'] = 'Besoin d\'aide ? Posez votre question sur le forum de PhpWebGallery.'; $lang['install_end_message'] = 'La configuration de l\'application s\'est correctement déroulée, place à la prochaine étape

Par mesure de sécurité, merci de supprimer le fichier "install.php"
diff --git a/template/yoga/install.tpl b/template/yoga/install.tpl index 822c16374..691da9784 100644 --- a/template/yoga/install.tpl +++ b/template/yoga/install.tpl @@ -1,12 +1,13 @@ - +{* $Id$ *} - + -PhpWebGallery {RELEASE} +PhpWebGallery {$RELEASE} +{literal} +{/literal}
-
PhpWebGallery {RELEASE}
+
PhpWebGallery {$RELEASE}
- + {if isset($errors)} - - + {/if} + {if isset($infos)} - + {/if}
    - -
  • {errors.error.ERROR}
  • - + {foreach from=$errors item=error} +
  • {$error}
  • + {/foreach}
    - -
  • {infos.info.INFO}
  • - + {foreach from=$infos item=info} +
  • {$info}
  • + {/foreach}
- -{L_ERR_COPY} : +{if isset($error_copy)} +{'step1_err_copy'|@translate} :
-----------------------------------------------------
-
{error_copy.FILE_CONTENT}
+
{$error_copy}
-----------------------------------------------------
- - -
+{/if} + +{if isset($install)} + - + - + - + - - - + + + - - - + + + - + - + - - - + + + - - - + + + - + - - - + + + - + - + - + - + - - - + + + @@ -230,21 +235,19 @@ td.row {
{L_BASE_TITLE}{'Initial_config'|@translate}
{L_LANG_TITLE}{'Default_lang'|@translate} - {F_LANG_SELECT} +
 
{L_DB_TITLE}{'step1_title'|@translate}
{L_DB_HOST}{L_DB_HOST_INFO}{'step1_host'|@translate}{'step1_host_info'|@translate}
{L_DB_USER}{L_DB_USER_INFO}{'step1_user'|@translate}{'step1_user_info'|@translate}
{L_DB_PASS}{'step1_pass'|@translate} {L_DB_PASS_INFO}{'step1_pass_info'|@translate}
{L_DB_NAME}{L_DB_NAME_INFO}{'step1_database'|@translate}{'step1_database_info'|@translate}
{L_DB_PREFIX}{L_DB_PREFIX_INFO}{'step1_prefix'|@translate}{'step1_prefix_info'|@translate}
 
{L_ADMIN_TITLE}{'step2_title'|@translate}
{L_ADMIN}{L_ADMIN_INFO}{'install_webmaster'|@translate}{'install_webmaster_info'|@translate}
{L_ADMIN_PASSWORD}{'step2_pwd'|@translate} {L_ADMIN_PASSWORD_INFO}{'step2_pwd_info'|@translate}
{L_ADMIN_CONFIRM_PASSWORD}{'step2_pwd_conf'|@translate} {L_ADMIN_CONFIRM_PASSWORD_INFO}{'step2_pwd_conf_info'|@translate}
{L_ADMIN_EMAIL}{L_ADMIN_EMAIL_INFO}{'conf_mail_webmaster'|@translate}{'conf_mail_webmaster_info'|@translate}
 
- +
- - - +{else}
-{L_END_TITLE} +{'install_end_title'|@translate}
-{L_END_MESSAGE} +{'install_end_message'|@translate}
- +{/if}
-
{L_INSTALL_HELP}
+
{$L_INSTALL_HELP}
-- cgit v1.2.3