Indentation du code
This commit is contained in:
parent
0bc998a749
commit
9c5216d230
@ -40,71 +40,71 @@ $cat->label = $_REQUEST["nom"];
|
|||||||
$cat->description = $_REQUEST["description"];
|
$cat->description = $_REQUEST["description"];
|
||||||
|
|
||||||
$new_cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array ();
|
$new_cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array ();
|
||||||
// tableau d'id de catégories
|
// tableau d'id de catégories
|
||||||
|
|
||||||
$old_objs_meres = $cat->get_meres ();
|
$old_objs_meres = $cat->get_meres ();
|
||||||
// tableau d'objets catégorie
|
// tableau d'objets catégorie
|
||||||
|
|
||||||
$old_cats_meres = array ();
|
$old_cats_meres = array ();
|
||||||
foreach ($old_objs_meres as $old_obj_mere)
|
foreach ($old_objs_meres as $old_obj_mere)
|
||||||
{ // transformation en tableau d'id
|
{ // transformation en tableau d'id
|
||||||
$old_cats_meres[] = $old_obj_mere->id;
|
$old_cats_meres[] = $old_obj_mere->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$asupprimer = array (); // tableaux des catégories mères
|
$asupprimer = array (); // tableaux des catégories mères
|
||||||
$aajouter = array (); // à ajouter ou à supprimer
|
$aajouter = array (); // à ajouter ou à supprimer
|
||||||
|
|
||||||
foreach ($old_cats_meres as $old_cat)
|
foreach ($old_cats_meres as $old_cat)
|
||||||
{
|
{
|
||||||
if (!in_array ($old_cat, $new_cats_meres))
|
if (!in_array ($old_cat, $new_cats_meres))
|
||||||
{
|
{
|
||||||
$asupprimer[] = new Categorie ($db, $old_cat);
|
$asupprimer[] = new Categorie ($db, $old_cat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($new_cats_meres as $new_cat)
|
foreach ($new_cats_meres as $new_cat)
|
||||||
{
|
{
|
||||||
if (!in_array ($new_cat, $old_cats_meres))
|
if (!in_array ($new_cat, $old_cats_meres))
|
||||||
{
|
{
|
||||||
$aajouter[] = new Categorie ($db, $new_cat);
|
$aajouter[] = new Categorie ($db, $new_cat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $cat->update ();
|
$res = $cat->update ();
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
{
|
{
|
||||||
print "<p>Impossible de modifier la catégorie ".$cat->label.".</p>";
|
print "<p>Impossible de modifier la catégorie ".$cat->label.".</p>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
print "<p>La catégorie ".$cat->label." a été modifiée avec succès.</p>";
|
||||||
|
|
||||||
|
foreach ($asupprimer as $old_mere)
|
||||||
|
{
|
||||||
|
$res = $old_mere->del_fille ($cat);
|
||||||
|
if ($res < 0)
|
||||||
{
|
{
|
||||||
print "<p>La catégorie ".$cat->label." a été modifiée avec succès.</p>";
|
print "<p>Impossible d'enlever la catégorie de \"".$old_mere->label."\" ($res).</p>\n";
|
||||||
|
|
||||||
foreach ($asupprimer as $old_mere)
|
|
||||||
{
|
|
||||||
$res = $old_mere->del_fille ($cat);
|
|
||||||
if ($res < 0)
|
|
||||||
{
|
|
||||||
print "<p>Impossible d'enlever la catégorie de \"".$old_mere->label."\" ($res).</p>\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<p>La catégorie ne fait plus partie de ".$old_mere->label.".</p>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($aajouter as $new_mere)
|
|
||||||
{
|
|
||||||
$res = $new_mere->add_fille ($cat);
|
|
||||||
if ($res < 0)
|
|
||||||
{
|
|
||||||
print "<p>Impossible d'ajouter la catégorie à \"".$new_mere->label."\" ($res).</p>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<p>La catégorie fait maintenant partie de ".$new_mere->label.".</p>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<p>La catégorie ne fait plus partie de ".$old_mere->label.".</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($aajouter as $new_mere)
|
||||||
|
{
|
||||||
|
$res = $new_mere->add_fille ($cat);
|
||||||
|
if ($res < 0)
|
||||||
|
{
|
||||||
|
print "<p>Impossible d'ajouter la catégorie à \"".$new_mere->label."\" ($res).</p>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<p>La catégorie fait maintenant partie de ".$new_mere->label.".</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user