Skip to content
Extraits de code Groupes Projets
Valider 58c8aed3 rédigé par ARNO*'s avatar ARNO*
Parcourir les fichiers

Fabrication d'un requête avec classement par un champ doté d'un <multi> (ou non).

parent 5d566fea
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -256,4 +256,31 @@ function calcul_mysql_in($val, $valeurs, $not='') { ...@@ -256,4 +256,31 @@ function calcul_mysql_in($val, $valeurs, $not='') {
return "($in_sql)"; return "($in_sql)";
} }
function creer_objet_multi ($objet, $lang) {
$retour = "(IF(INSTR(".$objet.", '<multi>') = 0 , ".
" TRIM(".$objet."), ".
" CONCAT( ".
" LEFT(".$objet.", INSTR(".$objet.", '<multi>')-1), ".
" IF( ".
" INSTR(TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))),'[".$lang."]') = 0, ".
" IF( ".
" TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))) REGEXP '^\\[[a-z\_]{2,}\\]', ".
" INSERT( ".
" TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))), ".
" 1, ".
" INSTR(TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))), ']'), ".
" '' ".
" ), ".
" TRIM(RIGHT(".$objet.", LENGTH(".$objet.") -(6+INSTR(".$objet.", '<multi>')))) ".
" ), ".
" TRIM(RIGHT(".$objet.", ( LENGTH(".$objet.") - (INSTR(".$objet.", '[".$lang."]')+ LENGTH('[".$lang."]')-1) ) )) ".
" ) ".
" ) ".
")) AS multi ";
return $retour;
}
?> ?>
...@@ -489,7 +489,8 @@ function afficher_tranches_requete(&$query, $colspan) { ...@@ -489,7 +489,8 @@ function afficher_tranches_requete(&$query, $colspan) {
$query = trim($query); $query = trim($query);
$query_count = eregi_replace('^(SELECT)[[:space:]].*[[:space:]](FROM)[[:space:]]', '\\1 COUNT(*) \\2 ', $query); $query_count = eregi_replace('^(SELECT)[[:space:]].*[[:space:]](FROM)[[:space:]]', '\\1 COUNT(*) \\2 ', $query);
$query_count = eregi_replace('ORDER[[:space:]]+BY.*$', '', $query);
list($num_rows) = spip_fetch_array(spip_query($query_count)); list($num_rows) = spip_fetch_array(spip_query($query_count));
if (!$num_rows) return; if (!$num_rows) return;
......
...@@ -183,7 +183,7 @@ while ($row_syndic = spip_fetch_array($result_syndic)){ ...@@ -183,7 +183,7 @@ while ($row_syndic = spip_fetch_array($result_syndic)){
// On boucle d'abord sur les groupes de mots // On boucle d'abord sur les groupes de mots
// //
$query_groupes = "SELECT * FROM spip_groupes_mots ORDER BY titre"; $query_groupes = "SELECT *, ".creer_objet_multi ("titre", "$spip_lang")." FROM spip_groupes_mots ORDER BY multi";
$result_groupes = spip_query($query_groupes); $result_groupes = spip_query($query_groupes);
while ($row_groupes = spip_fetch_array($result_groupes)) { while ($row_groupes = spip_fetch_array($result_groupes)) {
...@@ -239,7 +239,8 @@ while ($row_groupes = spip_fetch_array($result_groupes)) { ...@@ -239,7 +239,8 @@ while ($row_groupes = spip_fetch_array($result_groupes)) {
// //
// Afficher les mots-cles du groupe // Afficher les mots-cles du groupe
// //
$query = "SELECT * FROM spip_mots WHERE id_groupe = '$id_groupe' ORDER BY titre"; $query = "SELECT id_mot, titre, ".creer_objet_multi ("titre", "$spip_lang")." FROM spip_mots WHERE id_groupe = '$id_groupe' ORDER BY multi";
$tranches = afficher_tranches_requete($query, 3); $tranches = afficher_tranches_requete($query, 3);
$table = ''; $table = '';
...@@ -248,8 +249,6 @@ while ($row_groupes = spip_fetch_array($result_groupes)) { ...@@ -248,8 +249,6 @@ while ($row_groupes = spip_fetch_array($result_groupes)) {
echo "<div class='liste'>"; echo "<div class='liste'>";
echo "<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">"; echo "<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">";
echo $tranches;
$result = spip_query($query); $result = spip_query($query);
while ($row = spip_fetch_array($result)) { while ($row = spip_fetch_array($result)) {
...@@ -257,7 +256,8 @@ while ($row_groupes = spip_fetch_array($result_groupes)) { ...@@ -257,7 +256,8 @@ while ($row_groupes = spip_fetch_array($result_groupes)) {
$id_mot = $row['id_mot']; $id_mot = $row['id_mot'];
$titre_mot = $row['titre']; $titre_mot = $row['titre'];
$multi = $row['multi'];
if ($connect_statut == "0minirezo") if ($connect_statut == "0minirezo")
$aff_articles="prepa,prop,publie,refuse"; $aff_articles="prepa,prop,publie,refuse";
else else
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter