par
Cyrano » 10 août 2006, 20:57
En utilisant une indentation correte, tu aurais pu trouver tout seul :
<!-- Corrigé -->
<?php
function edito($edito_type, $contents, $Xaff_jours, $Xaff_jour, $Xaff_nuit)
{
global $hlpfile, $language;
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
echo "<table width = \"100%\" cellspacing = \"2\" cellpadding = \"2\" border = \"0\"><tr><td class = \"HEADER\">\n";
echo adm_translate("Edito");
echo "</td></tr></table>\n";
echo "<br />\n";
if ($contents == "")
{
echo "</td></tr><tr><td align = \"center\">";
echo "<form action = \"admin.php?op = Edito_load\" method = \"post\">";
echo "<select class = \"TEXTBOX\" name = \"edito_type\" onChange = 'submit()'>";
echo "<option value = \"0\">".adm_translate("Modifier l'Editorial")." ...</option>\n";
echo "<option value = \"G\">".adm_translate("Modifier les news")."</option>\n";
echo "<option value = \"M\">".adm_translate("Modifier la page biographie Fr")."</option>\n";
echo "<option value = \"E\">".adm_translate("Modifier la page biographie En")."</option>\n";
echo "</select></form>";
}
else
{
if ($edito_type == "G")
{
$edito_typeL = " ".adm_translate("Modifier les news");
}
elseif ($edito_type == "M")
{
$edito_typeL = " ".adm_translate("Modifier la page biographie Fr");;
}
elseif ($edito_type == "E")
{
$edito_typeL = " ".adm_translate("Modifier la page biographie En");;
}
if (strpos($contents,"[/jour]")>0)
{
$contentJ = substr($contents,strpos($contents,"[jour]")+6,strpos($contents,"[/jour]")-6);
$contentN = substr($contents,strpos($contents,"[nuit]")+6,strpos($contents,"[/nuit]")-19-strlen($contentJ));
}
if (!$contentJ and !$contentN and !strpos($contents,"[/jour]"))
{
$contentJ = $contents;
}
echo "<b>".adm_translate("Edito")." :$edito_typeL</b>\n";
echo "<p align = \"center\">";
echo "<form action = \"admin.php\" method = \"post\" name = \"adminForm\">";
echo aff_editeur("XeditoJ","false");
echo "<br />";
echo "<textarea class = \"textbox\" name = \"XeditoJ\" rows = \"70\" cols = \"70\" style = \"width: 100%;\">\n";
echo htmlspecialchars($contentJ);
echo "</textarea><br /><br />\n";
echo adm_translate("Afficher pendant")." : <input class = \"TEXTBOX_STANDARD\" type = \"text\" name = \"aff_jours\" maxlength = \"3\" size = \"4\" value = \"$Xaff_jours\"> ".adm_translate("jour(s)")." :: ";
echo adm_translate("Le jour")." : <input type = \"checkbox\" name = \"aff_jour\" value = \"checked\" $Xaff_jour> / ".adm_translate("La nuit")." : <input type = \"checkbox\" name = \"aff_nuit\" value = \"checked\" $Xaff_nuit> - ";
echo "<input type = \"hidden\" name = \"op\" value = \"Edito_save\">";
echo "<input type = \"hidden\" name = \"edito_type\" value = \"$edito_type\">";
echo "<input class = \"BOUTON_STANDARD\" type = \"submit\" name = \"edito_confirm\" value = \"".adm_translate("Sauver les modifications")."\"> - \n";
echo "<a href = \"admin.php?op = Edito\" class = \"NOIR\">".adm_translate("Abandonner")."</a></p>\n";
echo "</form>\n";
}
CloseTable();
include ("footer.php");
}
?>
Mais une analyse plus poussé et un code revu et corrigé donnerait ceci :
<!-- Corrigé -->
<?php
function edito($edito_type, $contents, $Xaff_jours, $Xaff_jour, $Xaff_nuit)
{
global $hlpfile, $language;
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
?>
<table width="100%" cellspacing="2" cellpadding="2" border="0">
<tr>
<td class="HEADER">
<?php
echo adm_translate("Edito");
if ($contents == "")
{
?>
</td>
</tr>
<tr>
<td align="center">
<form action="admin.php?op = Edito_load" method="post">
<select class="TEXTBOX" name="edito_type" onChange='submit()'>
<option value="0"><?php echo( adm_translate("Modifier l'Editorial") ); ?> ...</option>
<option value="G"><?php echo( adm_translate("Modifier les news") ); ?></option>
<option value="M"><?php echo( adm_translate("Modifier la page biographie Fr") ); ?></option>
<option value="E"><?php echo( adm_translate("Modifier la page biographie En") ); ?></option>
</select>
</form>
<?php
}
else
{
if ($edito_type == "G")
{
$edito_typeL = " ".adm_translate("Modifier les news");
}
elseif ($edito_type == "M")
{
$edito_typeL=" ".adm_translate("Modifier la page biographie Fr");
}
elseif ($edito_type == "E")
{
$edito_typeL=" ".adm_translate("Modifier la page biographie En");
}
if (strpos($contents, "[/jour]") > 0)
{
$contentJ = substr($contents,strpos($contents,"[jour]") + 6, strpos($contents, "[/jour]") - 6);
$contentN = substr($contents,strpos($contents,"[nuit]") + 6, strpos($contents, "[/nuit]") - 19 - strlen($contentJ));
}
if (!$contentJ and !$contentN and !strpos($contents,"[/jour]"))
{
$contentJ = $contents;
}
?>
<b><?php echo( adm_translate("Edito") ); ?> : <?php echo($edito_typeL); ?></b>
<p align="center">
<form action="admin.php" method="post" name="adminForm">
<?php aff_editeur("XeditoJ","false"); ?>
<br />
<textarea class="textbox" name="XeditoJ" rows="70" cols="70" style="width: 100%;">
<?php htmlspecialchars($contentJ); ?>
</textarea><br />
<br />
<?php adm_translate("Afficher pendant") ?> :
<input class="TEXTBOX_STANDARD" type="text" name="aff_jours" maxlength="3" size="4" value="<?php echo($Xaff_jours); ?>"> <?php adm_translate("jour(s)") ?> ::
<?php echo adm_translate("Le jour") ?> :
<input type="checkbox" name="aff_jour" value="checked" <?php echo($Xaff_jour); ?>> / <?php echo( adm_translate("La nuit") ); ?> :
<input type="checkbox" name="aff_nuit" value="checked" <?php echo($Xaff_nuit); ?>> -
<input type="hidden" name="op" value="Edito_save">
<input type="hidden" name="edito_type" value="<?php echo($edito_type); ?>">
<input class="BOUTON_STANDARD" type="submit" name="edito_confirm" value="<?php echo( adm_translate("Sauver les modifications") ); ?>"> -
<a href="admin.php?op = Edito" class="NOIR"><?php adm_translate("Abandonner") ?></a></p>
</form>
<?php
}
?>
</td>
</tr>
</table>
<br />
<?php
CloseTable();
include ("footer.php");
}
?>
En utilisant une indentation correte, tu aurais pu trouver tout seul :
[php]<!-- Corrigé -->
<?php
function edito($edito_type, $contents, $Xaff_jours, $Xaff_jour, $Xaff_nuit)
{
global $hlpfile, $language;
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
echo "<table width = \"100%\" cellspacing = \"2\" cellpadding = \"2\" border = \"0\"><tr><td class = \"HEADER\">\n";
echo adm_translate("Edito");
echo "</td></tr></table>\n";
echo "<br />\n";
if ($contents == "")
{
echo "</td></tr><tr><td align = \"center\">";
echo "<form action = \"admin.php?op = Edito_load\" method = \"post\">";
echo "<select class = \"TEXTBOX\" name = \"edito_type\" onChange = 'submit()'>";
echo "<option value = \"0\">".adm_translate("Modifier l'Editorial")." ...</option>\n";
echo "<option value = \"G\">".adm_translate("Modifier les news")."</option>\n";
echo "<option value = \"M\">".adm_translate("Modifier la page biographie Fr")."</option>\n";
echo "<option value = \"E\">".adm_translate("Modifier la page biographie En")."</option>\n";
echo "</select></form>";
}
else
{
if ($edito_type == "G")
{
$edito_typeL = " ".adm_translate("Modifier les news");
}
elseif ($edito_type == "M")
{
$edito_typeL = " ".adm_translate("Modifier la page biographie Fr");;
}
elseif ($edito_type == "E")
{
$edito_typeL = " ".adm_translate("Modifier la page biographie En");;
}
if (strpos($contents,"[/jour]")>0)
{
$contentJ = substr($contents,strpos($contents,"[jour]")+6,strpos($contents,"[/jour]")-6);
$contentN = substr($contents,strpos($contents,"[nuit]")+6,strpos($contents,"[/nuit]")-19-strlen($contentJ));
}
if (!$contentJ and !$contentN and !strpos($contents,"[/jour]"))
{
$contentJ = $contents;
}
echo "<b>".adm_translate("Edito")." :$edito_typeL</b>\n";
echo "<p align = \"center\">";
echo "<form action = \"admin.php\" method = \"post\" name = \"adminForm\">";
echo aff_editeur("XeditoJ","false");
echo "<br />";
echo "<textarea class = \"textbox\" name = \"XeditoJ\" rows = \"70\" cols = \"70\" style = \"width: 100%;\">\n";
echo htmlspecialchars($contentJ);
echo "</textarea><br /><br />\n";
echo adm_translate("Afficher pendant")." : <input class = \"TEXTBOX_STANDARD\" type = \"text\" name = \"aff_jours\" maxlength = \"3\" size = \"4\" value = \"$Xaff_jours\"> ".adm_translate("jour(s)")." :: ";
echo adm_translate("Le jour")." : <input type = \"checkbox\" name = \"aff_jour\" value = \"checked\" $Xaff_jour> / ".adm_translate("La nuit")." : <input type = \"checkbox\" name = \"aff_nuit\" value = \"checked\" $Xaff_nuit> - ";
echo "<input type = \"hidden\" name = \"op\" value = \"Edito_save\">";
echo "<input type = \"hidden\" name = \"edito_type\" value = \"$edito_type\">";
echo "<input class = \"BOUTON_STANDARD\" type = \"submit\" name = \"edito_confirm\" value = \"".adm_translate("Sauver les modifications")."\"> - \n";
echo "<a href = \"admin.php?op = Edito\" class = \"NOIR\">".adm_translate("Abandonner")."</a></p>\n";
echo "</form>\n";
}
CloseTable();
include ("footer.php");
}
?>[/php]
Mais une analyse plus poussé et un code revu et corrigé donnerait ceci :
[php]<!-- Corrigé -->
<?php
function edito($edito_type, $contents, $Xaff_jours, $Xaff_jour, $Xaff_nuit)
{
global $hlpfile, $language;
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
?>
<table width="100%" cellspacing="2" cellpadding="2" border="0">
<tr>
<td class="HEADER">
<?php
echo adm_translate("Edito");
if ($contents == "")
{
?>
</td>
</tr>
<tr>
<td align="center">
<form action="admin.php?op = Edito_load" method="post">
<select class="TEXTBOX" name="edito_type" onChange='submit()'>
<option value="0"><?php echo( adm_translate("Modifier l'Editorial") ); ?> ...</option>
<option value="G"><?php echo( adm_translate("Modifier les news") ); ?></option>
<option value="M"><?php echo( adm_translate("Modifier la page biographie Fr") ); ?></option>
<option value="E"><?php echo( adm_translate("Modifier la page biographie En") ); ?></option>
</select>
</form>
<?php
}
else
{
if ($edito_type == "G")
{
$edito_typeL = " ".adm_translate("Modifier les news");
}
elseif ($edito_type == "M")
{
$edito_typeL=" ".adm_translate("Modifier la page biographie Fr");
}
elseif ($edito_type == "E")
{
$edito_typeL=" ".adm_translate("Modifier la page biographie En");
}
if (strpos($contents, "[/jour]") > 0)
{
$contentJ = substr($contents,strpos($contents,"[jour]") + 6, strpos($contents, "[/jour]") - 6);
$contentN = substr($contents,strpos($contents,"[nuit]") + 6, strpos($contents, "[/nuit]") - 19 - strlen($contentJ));
}
if (!$contentJ and !$contentN and !strpos($contents,"[/jour]"))
{
$contentJ = $contents;
}
?>
<b><?php echo( adm_translate("Edito") ); ?> : <?php echo($edito_typeL); ?></b>
<p align="center">
<form action="admin.php" method="post" name="adminForm">
<?php aff_editeur("XeditoJ","false"); ?>
<br />
<textarea class="textbox" name="XeditoJ" rows="70" cols="70" style="width: 100%;">
<?php htmlspecialchars($contentJ); ?>
</textarea><br />
<br />
<?php adm_translate("Afficher pendant") ?> :
<input class="TEXTBOX_STANDARD" type="text" name="aff_jours" maxlength="3" size="4" value="<?php echo($Xaff_jours); ?>"> <?php adm_translate("jour(s)") ?> ::
<?php echo adm_translate("Le jour") ?> :
<input type="checkbox" name="aff_jour" value="checked" <?php echo($Xaff_jour); ?>> / <?php echo( adm_translate("La nuit") ); ?> :
<input type="checkbox" name="aff_nuit" value="checked" <?php echo($Xaff_nuit); ?>> -
<input type="hidden" name="op" value="Edito_save">
<input type="hidden" name="edito_type" value="<?php echo($edito_type); ?>">
<input class="BOUTON_STANDARD" type="submit" name="edito_confirm" value="<?php echo( adm_translate("Sauver les modifications") ); ?>"> -
<a href="admin.php?op = Edito" class="NOIR"><?php adm_translate("Abandonner") ?></a></p>
</form>
<?php
}
?>
</td>
</tr>
</table>
<br />
<?php
CloseTable();
include ("footer.php");
}
?>[/php]