Skip to content
Snippets Groups Projects
Commit 16c4d999 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Simplification du code

parent f3db537f
No related branches found
No related tags found
No related merge requests found
...@@ -101,28 +101,125 @@ if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_databa ...@@ -101,28 +101,125 @@ if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_databa
}else{ }else{
$disabled="disabled"; $disabled="disabled";
} }
if ($db->connected){
if ($db->connected)
{
?> ?>
<table border="0" cellpadding="1" cellspacing="0"> <table border="0" cellpadding="1" cellspacing="0">
<tr><td valign="top" class="label" colspan="3"><?php echo $langs->trans("CharsetChoice");?></td></tr> <tr><td valign="top" class="label" colspan="3"><?php echo $langs->trans("CharsetChoice");?></td></tr>
<tr> <tr>
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetClient"); ?></td> <td valign="top" class="label"><?php echo $langs->trans("CharacterSetClient"); ?></td>
<td valign="top" class="label"><select name="character_set_client"><option>ISO-8859-1</option><option>ISO-8859-15</option><option>UTF-8</option><option>cp866</option><option>cp1251</option><option>cp1252</option><option>KOI8-R</option><option>BIG5</option><option>GB2312</option><option>BIG5-HKSCS</option><option>Shift_JIS</option><option>EUC-JP</option></select></td> <td valign="top" class="label"><select name="character_set_client">
<option>ISO-8859-1</option>
<option>ISO-8859-15</option>
<option>UTF-8</option>
<option>cp866</option>
<option>cp1251</option>
<option>cp1252</option>
<option>KOI8-R</option>
<option>BIG5</option>
<option>GB2312</option>
<option>BIG5-HKSCS</option>
<option>Shift_JIS</option>
<option>EUC-JP</option>
</select></td>
<td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetClientComment"); ?></div></td> <td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetClientComment"); ?></div></td>
</tr> </tr>
<?php include($_POST["db_type"].'.php');?>
<?php <?php
}else{ $defaultCharacterSet=$db->getDefaultCharacterSetDatabase();
$defaultCollationConnection=$db->getDefaultCollationConnection();
$listOfCharacterSet=$db->getListOfCharacterSet();
$listOfCollation=$db->getListOfCollation();
if ($defaultCharacterSet)
{
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
<td valign="top" class="label">
<?php
if (sizeof($listOfCharacterSet))
{
print '<select name="character_set_database" '.$disabled.'>';
$selected="";
foreach ($listOfCharacterSet as $characterSet)
{
if ($defaultCharacterSet == $characterSet['charset'] )
{
$selected="selected";
}
else
{
$selected="";
}
print '<option value="'.$characterSet['charset'].'" '.$selected.'>'.$characterSet['charset'].' ('.$characterSet['description'].')</option>';
}
print '</select>';
}
else
{
print '<input name="character_set_database" '.$disabled.' value="'.$defaultCharacterSet.'">';
}
?>
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetDatabaseComment"); ?></div></td>
</tr>
<?php
}
if ($defaultCollationConnection)
{
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CollationConnection"); ?></td>
<td valign="top" class="label">
<?php
if (sizeof($listOfCollation))
{
print '<select name="collation_connection" '.$disabled.'>';
$selected="";
foreach ($listOfCollation as $collation)
{
if ($defaultCollationConnection == $collation['collation'])
{
$selected="selected";
}
else
{
$selected="";
}
print '<option value="'.$collation['collation'].'" '.$selected.'>'.$collation['collation'].'</option>';
}
print '</select>';
}
else
{
print '<input type="hidden" name="collation_connection" value="'.$collation['collation'].'">';
}
?>
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CollationConnectionComment"); ?></div></td>
</tr>
<?php
}
}
else
{
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on") if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
{ {
print 'Vous avez demandé la création du login Dolibarr "<b>'.$dolibarr_main_db_user.'</b>", mais pour cela, '; print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
print 'Dolibarr doit se connecter sur le serveur "<b>'.$dolibarr_main_db_host.'</b>" via le super utilisateur "<b>'.$userroot.'</b>".<br>'; print '<br>';
print 'La connexion ayant échoué, les paramètres du serveur ou du super utilisateur sont peut-etre incorrects.<br>'; print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>'; print $langs->trans("ErrorGoBackAndCorrectParameters");
}else{ $error++;
print 'La connexion ayant échoué, les paramètres de connexion de l\'utilisateur sont peut-etre incorrects.<br>'; }
print $langs->trans("ErrorGoBackAndCorrectParameters").'<br><br>'; else
{
print $db->lasterror();
print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++;
} }
} }
......
<?php
/* Copyright (C) 2004-2007 Cyrille de Lambert <cyrille.delambert@auguria.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
$listOfCharacterSet=$db->getListOfCharacterSet();
$listOfCollation=$db->getListOfCollation();
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
<td valign="top" class="label">
<?php
$listOfCharacterSet=$db->getListOfCharacterSet();
?>
<select name="character_set_database" <?php echo $disabled ?>>
<?php
$selected="";
foreach ($listOfCharacterSet as $characterSet) {
if ($db->getDefaultCharacterSetDatabase() ==$characterSet['charset'] ){
$selected="selected";
}else{
$selected="";
}
?>
<option value="<?php echo $characterSet['charset'];?>" <?php echo $selected;?>> <?php echo $characterSet['charset'];?> (<?php echo $characterSet['description'];?>)</option>
<?php
}
?>
</select>
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetDatabaseComment"); ?></div></td>
</tr>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CollationConnection"); ?></td>
<td valign="top" class="label">
<?php
$listOfCollation=$db->getListOfCollation();
?>
<select name="collation_connection" <?php echo $disabled ?>>
<?php
$selected="";
foreach ($listOfCollation as $collation) {
if ($db->getDefaultCollationConnection() ==$collation['collation'] ){
$selected="selected";
}else{
$selected="";
}
?>
<option value="<?php echo $collation['collation'];?>" <?php echo $selected;?>> <?php echo $collation['collation'];?></option>
<?php
}
?>
</select>
<?if ($disabled && $disabled=="disabled"){
?>
<input type="hidden" name="character_set_database" value="<?php echo $collation['charset'] ?>">
<input type="hidden" name="collation_connection" value="<?php echo $collation['collation'] ?>">
<?
}
?>
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CollationConnectionComment"); ?></div></td>
</tr>
\ No newline at end of file
<?php
/* Copyright (C) 2004-2007 Cyrille de Lambert <cyrille.delambert@auguria.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
$listOfCharacterSet=$db->getListOfCharacterSet();
$listOfCollation=$db->getListOfCollation();
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
<td valign="top" class="label">
<?php
$listOfCharacterSet=$db->getListOfCharacterSet();
?>
<select name="character_set_database" <?php echo $disabled ?>>
<?php
$selected="";
foreach ($listOfCharacterSet as $characterSet) {
if ($db->getDefaultCharacterSetDatabase() ==$characterSet['charset'] ){
$selected="selected";
}else{
$selected="";
}
?>
<option value="<?php echo $characterSet['charset'];?>" <?php echo $selected;?>> <?php echo $characterSet['charset'];?> (<?php echo $characterSet['description'];?>)</option>
<?php
}
?>
</select>
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetDatabaseComment"); ?></div></td>
</tr>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CollationConnection"); ?></td>
<td valign="top" class="label">
<?php
$listOfCollation=$db->getListOfCollation();
?>
<select name="collation_connection" <?php echo $disabled ?>>
<?php
$selected="";
foreach ($listOfCollation as $collation) {
if ($db->getDefaultCollationConnection() ==$collation['collation'] ){
$selected="selected";
}else{
$selected="";
}
?>
<option value="<?php echo $collation['collation'];?>" <?php echo $selected;?>> <?php echo $collation['collation'];?></option>
<?php
}
?>
</select>
<?if ($disabled && $disabled=="disabled"){
?>
<input type="hidden" name="character_set_database" value="<?php echo $db->getDefaultCharacterSetDatabase() ?>">
<input type="hidden" name="collation_connection" value="<?php echo $db->getDefaultCollationConnection() ?>">
<?
}
?>
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CollationConnectionComment"); ?></div></td>
</tr>
\ No newline at end of file
<?php
/* Copyright (C) 2004-2007 Cyrille de Lambert <cyrille.delambert@auguria.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
<td valign="top" class="label">
<input name="character_set_database" <?php echo $disabled ?> value="<?php echo $db->getDefaultCharacterSetDatabase()?>">
</td>
<td class="label"><div class="comment"><?php echo $langs->trans("CharacterSetDatabaseComment"); ?></div></td>
</tr>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment