alpha_full/admin/agencement/blocDroit/pages/items/reqItem/itemReqInsertAll.php
2026-04-06 22:58:51 +02:00

96 lines
4.8 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
// -----------------------------------------------------
// Formattage var
// -----------------------------------------------------
if (!empty($theMsg)) $theMsg = addslashes($theMsg); else $theMsg='-' ;
if (!empty($theItemNom))$theItemNom = addslashes($theItemNom);
if (!empty($theStyle))$theStyle = addslashes($theStyle);
$theStyle = htmlspecialchars($theStyle, ENT_QUOTES,"UTF-8",false);
$theItemNom=htmlspecialchars($theItemNom, ENT_QUOTES,"UTF-8",false);
$theMsg=htmlspecialchars($theMsg, ENT_QUOTES,"UTF-8",false);
// ----------------------------------------------------
// The class pas de #
// ----------------------------------------------------
if (substr ($theClasse,0,1)=='#') {$theClasse=substr($theClasse,1, strlen($theClasse) ); }
// -----------------------------------------------------
// Si Lien absolu
// -----------------------------------------------------
$absolu=$_SESSION['absolu'];
if ($absolu==1) {
if (!empty($theLien) && $theLien!="-") $theLien=str_replace("./",$prodServer,$theLien);
// ecrasera the lien
if (!empty($theLienExterne) && $theLienExterne!="-") $theLien=str_replace("./",$prodServer,$theLien);
if (!empty($theFichier)) $theFichier=str_replace("./",$prodServer,$theFichier);
}
// -----------------------------------------------------
// reqInsert
// -----------------------------------------------------
if ($theItemNom !='' && $theIdPage !='' && $theNewIdItem!='') {
for ($i=0; $i<($_SESSION['nbLgActives']); $i++) {
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['$tableLangueCode[' => $i, ']' => $tableLangueCode[$i],'$_SESSION[lgCouranteCode]' => $_SESSION['lgCouranteCode'], '$code langue pour google =' => ''], '');}
if ($tableLangueCode[$i] != $_SESSION['lgCouranteCode'] && $theMsg!='-') {
$theMsg= gTranslate($theMsg, strtolower( substr ($tableLangueCode[$i], 0, -1) ) );
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug (1,['theMsg translated' => $theMsg],''); }
}
// on rajoute la langue entre parenthèses dans le theItemNom
// on verifie qu'il y a une parenthèse ce qui veut dire que cela aurait déjà été fait
$test=strpos($theItemNom, "(" );
if ($test !=false ) $theItemNom = substr($theItemNom, 0, $test -1 );
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Modif 1 test=' => $test, ' theItemNom' => $theItemNom], '');}
// on verifie que cela aurait pas déjà été fait
$test=strpos($theItemNom, $_SESSION['lgCouranteLibelle'] );
if ($test === false ) $theItemNom = $theItemNom . ' ( ' .$tableLangueDesc[$i]. ' )';
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, [' theItemNom modifié' => $theItemNom], '');}
// la requête insert
$reqInsert="Insert into `pagesitem` values (0, " .$theIdPage. ", " .$theNewIdItem. ", '" .$theItemNom. "', " .$theOrdre. ", '" .$theVoletCss. "','" .$theClasse. "', '" .$theType. "', '" .$theFichier. "', '" .$theStyle. "', '" .$theMsg. "','" .$theLien. "', '" .$tableLangueCode[$i]. "' );";
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['REQ INSERT ITEM' => $reqInsert], 'itemReqInsertAll.php');}
$resConn='';
try {
$resConn=$idPdo->query($reqInsert);
} catch (Exception $e) {
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Exception:' => $e->getMessage(),'N° :' => $idPdo->errorInfo()[1]], '');}
$admMsgClass='ko';
$erreurSQL=1;
}
if ($resConn) {
// Recup du libelle exact pour le message de requete
// for ($l=0; $l<$_SESSION['nbLg']; $l++) {
// if ($lg==$tableLangueCode[$l]) $lDesc=$tableLangueDesc[$l];
// }
$forceLg =1;
include ("./agencement/blocDroit/pages/output/01-generationFichier.php");
if($retour !='') {
$admMsg .= 'Le contenu ' .$theItemNom. ' a bien été ajouté pour la langue ' . $tableLangueDesc[$i].'<br>';
// if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Le message à été traduit de la manière suivante :' => $theMsg], ''); }
$admMsg .='Le message à été traduit de la manière suivante :'.$theMsg.'<br>';
$admMsgClass='ok';
}
else {
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Erreur pour Le contenu' => $theItemNom, ' de la langue :' => $tableLangueDesc[$i] ], '');}
$admMsgClass='ko';
}
}
}
}
else {
if ($theItemNom =='') $admMsg .= 'Vous devez saisir le nom !<br>'; $admMsgClass='ko'; $erreurSQL=1;
if (isset($debug[2]) && $debug[2] == '1') {if ($theIdPage =='') $admMsg .= 'Le idPage vide dans itemReqInsert.<br>';}
$admMsgClass='ko';
$erreurSQL=1;
if ($theNewIdItem =='') $admMsg .= 'IdItem vide !.<br>';
}
?>