@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | **/ |
| 24 | 24 | |
| 25 | 25 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 26 | - return; |
|
| 26 | + return; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -52,75 +52,75 @@ discard block |
||
| 52 | 52 | * Introduction calculée |
| 53 | 53 | **/ |
| 54 | 54 | function filtre_introduction_dist($descriptif, $texte, $longueur, $connect, $suite = null) { |
| 55 | - // Si un descriptif est envoye, on l'utilise directement |
|
| 56 | - if (strlen($descriptif)) { |
|
| 57 | - return appliquer_traitement_champ($descriptif, 'introduction', '', array(), $connect); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - // De preference ce qui est marque <intro>...</intro> |
|
| 61 | - $intro = ''; |
|
| 62 | - $texte = preg_replace(",(</?)intro>,i", "\\1intro>", $texte); // minuscules |
|
| 63 | - while ($fin = strpos($texte, "</intro>")) { |
|
| 64 | - $zone = substr($texte, 0, $fin); |
|
| 65 | - $texte = substr($texte, $fin + strlen("</intro>")); |
|
| 66 | - if ($deb = strpos($zone, "<intro>") or substr($zone, 0, 7) == "<intro>") { |
|
| 67 | - $zone = substr($zone, $deb + 7); |
|
| 68 | - } |
|
| 69 | - $intro .= $zone; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // [12025] On ne *PEUT* pas couper simplement ici car c'est du texte brut, |
|
| 73 | - // qui inclus raccourcis et modeles |
|
| 74 | - // un simple <articlexx> peut etre ensuite transforme en 1000 lignes ... |
|
| 75 | - // par ailleurs le nettoyage des raccourcis ne tient pas compte |
|
| 76 | - // des surcharges et enrichissement de propre |
|
| 77 | - // couper doit se faire apres propre |
|
| 78 | - //$texte = nettoyer_raccourcis_typo($intro ? $intro : $texte, $connect); |
|
| 79 | - |
|
| 80 | - // Cependant pour des questions de perfs on coupe quand meme, en prenant |
|
| 81 | - // large et en se mefiant des tableaux #1323 |
|
| 82 | - |
|
| 83 | - if (strlen($intro)) { |
|
| 84 | - $texte = $intro; |
|
| 85 | - } else { |
|
| 86 | - if (strpos("\n" . $texte, "\n|") === false |
|
| 87 | - and strlen($texte) > 2.5 * $longueur |
|
| 88 | - ) { |
|
| 89 | - if (strpos($texte, "<multi") !== false) { |
|
| 90 | - $texte = extraire_multi($texte); |
|
| 91 | - } |
|
| 92 | - $texte = couper($texte, 2 * $longueur); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // ne pas tenir compte des notes |
|
| 97 | - if ($notes = charger_fonction('notes', 'inc', true)) { |
|
| 98 | - $notes('', 'empiler'); |
|
| 99 | - } |
|
| 100 | - // Supprimer les modèles avant le propre afin d'éviter qu'ils n'ajoutent du texte indésirable |
|
| 101 | - // dans l'introduction. |
|
| 102 | - $texte = supprime_img($texte, ''); |
|
| 103 | - $texte = appliquer_traitement_champ($texte, 'introduction', '', array(), $connect); |
|
| 104 | - |
|
| 105 | - if ($notes) { |
|
| 106 | - $notes('', 'depiler'); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if (is_null($suite) and defined('_INTRODUCTION_SUITE')) { |
|
| 110 | - $suite = _INTRODUCTION_SUITE; |
|
| 111 | - } |
|
| 112 | - $texte = couper($texte, $longueur, $suite); |
|
| 113 | - // comme on a coupe il faut repasser la typo (on a perdu les insecables) |
|
| 114 | - $texte = typo($texte, true, $connect, array()); |
|
| 115 | - |
|
| 116 | - // et reparagrapher si necessaire (coherence avec le cas descriptif) |
|
| 117 | - // une introduction a tojours un <p> |
|
| 118 | - if ($GLOBALS['toujours_paragrapher']) // Fermer les paragraphes |
|
| 119 | - { |
|
| 120 | - $texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $texte; |
|
| 55 | + // Si un descriptif est envoye, on l'utilise directement |
|
| 56 | + if (strlen($descriptif)) { |
|
| 57 | + return appliquer_traitement_champ($descriptif, 'introduction', '', array(), $connect); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + // De preference ce qui est marque <intro>...</intro> |
|
| 61 | + $intro = ''; |
|
| 62 | + $texte = preg_replace(",(</?)intro>,i", "\\1intro>", $texte); // minuscules |
|
| 63 | + while ($fin = strpos($texte, "</intro>")) { |
|
| 64 | + $zone = substr($texte, 0, $fin); |
|
| 65 | + $texte = substr($texte, $fin + strlen("</intro>")); |
|
| 66 | + if ($deb = strpos($zone, "<intro>") or substr($zone, 0, 7) == "<intro>") { |
|
| 67 | + $zone = substr($zone, $deb + 7); |
|
| 68 | + } |
|
| 69 | + $intro .= $zone; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // [12025] On ne *PEUT* pas couper simplement ici car c'est du texte brut, |
|
| 73 | + // qui inclus raccourcis et modeles |
|
| 74 | + // un simple <articlexx> peut etre ensuite transforme en 1000 lignes ... |
|
| 75 | + // par ailleurs le nettoyage des raccourcis ne tient pas compte |
|
| 76 | + // des surcharges et enrichissement de propre |
|
| 77 | + // couper doit se faire apres propre |
|
| 78 | + //$texte = nettoyer_raccourcis_typo($intro ? $intro : $texte, $connect); |
|
| 79 | + |
|
| 80 | + // Cependant pour des questions de perfs on coupe quand meme, en prenant |
|
| 81 | + // large et en se mefiant des tableaux #1323 |
|
| 82 | + |
|
| 83 | + if (strlen($intro)) { |
|
| 84 | + $texte = $intro; |
|
| 85 | + } else { |
|
| 86 | + if (strpos("\n" . $texte, "\n|") === false |
|
| 87 | + and strlen($texte) > 2.5 * $longueur |
|
| 88 | + ) { |
|
| 89 | + if (strpos($texte, "<multi") !== false) { |
|
| 90 | + $texte = extraire_multi($texte); |
|
| 91 | + } |
|
| 92 | + $texte = couper($texte, 2 * $longueur); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // ne pas tenir compte des notes |
|
| 97 | + if ($notes = charger_fonction('notes', 'inc', true)) { |
|
| 98 | + $notes('', 'empiler'); |
|
| 99 | + } |
|
| 100 | + // Supprimer les modèles avant le propre afin d'éviter qu'ils n'ajoutent du texte indésirable |
|
| 101 | + // dans l'introduction. |
|
| 102 | + $texte = supprime_img($texte, ''); |
|
| 103 | + $texte = appliquer_traitement_champ($texte, 'introduction', '', array(), $connect); |
|
| 104 | + |
|
| 105 | + if ($notes) { |
|
| 106 | + $notes('', 'depiler'); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if (is_null($suite) and defined('_INTRODUCTION_SUITE')) { |
|
| 110 | + $suite = _INTRODUCTION_SUITE; |
|
| 111 | + } |
|
| 112 | + $texte = couper($texte, $longueur, $suite); |
|
| 113 | + // comme on a coupe il faut repasser la typo (on a perdu les insecables) |
|
| 114 | + $texte = typo($texte, true, $connect, array()); |
|
| 115 | + |
|
| 116 | + // et reparagrapher si necessaire (coherence avec le cas descriptif) |
|
| 117 | + // une introduction a tojours un <p> |
|
| 118 | + if ($GLOBALS['toujours_paragrapher']) // Fermer les paragraphes |
|
| 119 | + { |
|
| 120 | + $texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $texte; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -155,59 +155,59 @@ discard block |
||
| 155 | 155 | * Code HTML de la pagination |
| 156 | 156 | **/ |
| 157 | 157 | function filtre_pagination_dist( |
| 158 | - $total, |
|
| 159 | - $nom, |
|
| 160 | - $position, |
|
| 161 | - $pas, |
|
| 162 | - $liste = true, |
|
| 163 | - $modele = '', |
|
| 164 | - $connect = '', |
|
| 165 | - $env = array() |
|
| 158 | + $total, |
|
| 159 | + $nom, |
|
| 160 | + $position, |
|
| 161 | + $pas, |
|
| 162 | + $liste = true, |
|
| 163 | + $modele = '', |
|
| 164 | + $connect = '', |
|
| 165 | + $env = array() |
|
| 166 | 166 | ) { |
| 167 | - static $ancres = array(); |
|
| 168 | - if ($pas < 1) { |
|
| 169 | - return ''; |
|
| 170 | - } |
|
| 171 | - $ancre = 'pagination' . $nom; // #pagination_articles |
|
| 172 | - $debut = 'debut' . $nom; // 'debut_articles' |
|
| 173 | - |
|
| 174 | - // n'afficher l'ancre qu'une fois |
|
| 175 | - if (!isset($ancres[$ancre])) { |
|
| 176 | - $bloc_ancre = $ancres[$ancre] = "<a id='" . $ancre . "' class='pagination_ancre'></a>"; |
|
| 177 | - } else { |
|
| 178 | - $bloc_ancre = ''; |
|
| 179 | - } |
|
| 180 | - // liste = false : on ne veut que l'ancre |
|
| 181 | - if (!$liste) { |
|
| 182 | - return $ancres[$ancre]; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $self = (empty($env['self']) ? self() : $env['self']); |
|
| 186 | - $pagination = array( |
|
| 187 | - 'debut' => $debut, |
|
| 188 | - 'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel |
|
| 189 | - 'total' => $total, |
|
| 190 | - 'position' => intval($position), |
|
| 191 | - 'pas' => $pas, |
|
| 192 | - 'nombre_pages' => floor(($total - 1) / $pas) + 1, |
|
| 193 | - 'page_courante' => floor(intval($position) / $pas) + 1, |
|
| 194 | - 'ancre' => $ancre, |
|
| 195 | - 'bloc_ancre' => $bloc_ancre |
|
| 196 | - ); |
|
| 197 | - if (is_array($env)) { |
|
| 198 | - $pagination = array_merge($env, $pagination); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // Pas de pagination |
|
| 202 | - if ($pagination['nombre_pages'] <= 1) { |
|
| 203 | - return ''; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - if ($modele) { |
|
| 207 | - $modele = '_' . $modele; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect); |
|
| 167 | + static $ancres = array(); |
|
| 168 | + if ($pas < 1) { |
|
| 169 | + return ''; |
|
| 170 | + } |
|
| 171 | + $ancre = 'pagination' . $nom; // #pagination_articles |
|
| 172 | + $debut = 'debut' . $nom; // 'debut_articles' |
|
| 173 | + |
|
| 174 | + // n'afficher l'ancre qu'une fois |
|
| 175 | + if (!isset($ancres[$ancre])) { |
|
| 176 | + $bloc_ancre = $ancres[$ancre] = "<a id='" . $ancre . "' class='pagination_ancre'></a>"; |
|
| 177 | + } else { |
|
| 178 | + $bloc_ancre = ''; |
|
| 179 | + } |
|
| 180 | + // liste = false : on ne veut que l'ancre |
|
| 181 | + if (!$liste) { |
|
| 182 | + return $ancres[$ancre]; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $self = (empty($env['self']) ? self() : $env['self']); |
|
| 186 | + $pagination = array( |
|
| 187 | + 'debut' => $debut, |
|
| 188 | + 'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel |
|
| 189 | + 'total' => $total, |
|
| 190 | + 'position' => intval($position), |
|
| 191 | + 'pas' => $pas, |
|
| 192 | + 'nombre_pages' => floor(($total - 1) / $pas) + 1, |
|
| 193 | + 'page_courante' => floor(intval($position) / $pas) + 1, |
|
| 194 | + 'ancre' => $ancre, |
|
| 195 | + 'bloc_ancre' => $bloc_ancre |
|
| 196 | + ); |
|
| 197 | + if (is_array($env)) { |
|
| 198 | + $pagination = array_merge($env, $pagination); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // Pas de pagination |
|
| 202 | + if ($pagination['nombre_pages'] <= 1) { |
|
| 203 | + return ''; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + if ($modele) { |
|
| 207 | + $modele = '_' . $modele; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -221,15 +221,15 @@ discard block |
||
| 221 | 221 | **/ |
| 222 | 222 | function lister_objets_avec_logos($type) { |
| 223 | 223 | |
| 224 | - $objet = objet_type($type); |
|
| 225 | - $ids = sql_allfetsel("L.id_objet", "spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document", "D.mode=".sql_quote('logoon')." AND L.objet=".sql_quote($objet)); |
|
| 226 | - if ($ids) { |
|
| 227 | - $ids = array_column($ids, 'id_objet'); |
|
| 228 | - return implode(',', $ids); |
|
| 229 | - } |
|
| 230 | - else { |
|
| 231 | - return "0"; |
|
| 232 | - } |
|
| 224 | + $objet = objet_type($type); |
|
| 225 | + $ids = sql_allfetsel("L.id_objet", "spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document", "D.mode=".sql_quote('logoon')." AND L.objet=".sql_quote($objet)); |
|
| 226 | + if ($ids) { |
|
| 227 | + $ids = array_column($ids, 'id_objet'); |
|
| 228 | + return implode(',', $ids); |
|
| 229 | + } |
|
| 230 | + else { |
|
| 231 | + return "0"; |
|
| 232 | + } |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | * Code HTML des notes |
| 246 | 246 | **/ |
| 247 | 247 | function calculer_notes() { |
| 248 | - $r = ''; |
|
| 249 | - if ($notes = charger_fonction('notes', 'inc', true)) { |
|
| 250 | - $r = $notes(array()); |
|
| 251 | - $notes('', 'depiler'); |
|
| 252 | - $notes('', 'empiler'); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return $r; |
|
| 248 | + $r = ''; |
|
| 249 | + if ($notes = charger_fonction('notes', 'inc', true)) { |
|
| 250 | + $r = $notes(array()); |
|
| 251 | + $notes('', 'depiler'); |
|
| 252 | + $notes('', 'empiler'); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return $r; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | * @return string |
| 270 | 270 | */ |
| 271 | 271 | function retrouver_rang_lien($objet_source, $ids, $objet_lie, $idl, $objet_lien){ |
| 272 | - $res = lister_objets_liens($objet_source, $objet_lie, $idl, $objet_lien); |
|
| 273 | - $res = array_column($res, 'rang_lien', $objet_source); |
|
| 272 | + $res = lister_objets_liens($objet_source, $objet_lie, $idl, $objet_lien); |
|
| 273 | + $res = array_column($res, 'rang_lien', $objet_source); |
|
| 274 | 274 | |
| 275 | - return (isset($res[$ids]) ? $res[$ids] : ''); |
|
| 275 | + return (isset($res[$ids]) ? $res[$ids] : ''); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
@@ -289,19 +289,19 @@ discard block |
||
| 289 | 289 | * @private |
| 290 | 290 | */ |
| 291 | 291 | function lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien) { |
| 292 | - static $liens = array(); |
|
| 293 | - if (!isset($liens["$objet_source-$objet-$id_objet-$objet_lien"])) { |
|
| 294 | - include_spip('action/editer_liens'); |
|
| 295 | - // quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source |
|
| 296 | - if ($objet_lien == $objet and $objet_lien !== $objet_source) { |
|
| 297 | - $res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*')); |
|
| 298 | - } else { |
|
| 299 | - $res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet)); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $liens["$objet_source-$objet-$id_objet-$objet_lien"] = $res; |
|
| 303 | - } |
|
| 304 | - return $liens["$objet_source-$objet-$id_objet-$objet_lien"]; |
|
| 292 | + static $liens = array(); |
|
| 293 | + if (!isset($liens["$objet_source-$objet-$id_objet-$objet_lien"])) { |
|
| 294 | + include_spip('action/editer_liens'); |
|
| 295 | + // quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source |
|
| 296 | + if ($objet_lien == $objet and $objet_lien !== $objet_source) { |
|
| 297 | + $res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*')); |
|
| 298 | + } else { |
|
| 299 | + $res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet)); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $liens["$objet_source-$objet-$id_objet-$objet_lien"] = $res; |
|
| 303 | + } |
|
| 304 | + return $liens["$objet_source-$objet-$id_objet-$objet_lien"]; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -315,23 +315,23 @@ discard block |
||
| 315 | 315 | * @return int|string |
| 316 | 316 | */ |
| 317 | 317 | function calculer_rang_smart($titre, $objet_source, $id, $env) { |
| 318 | - // Cas du #RANG utilisé dans #FORMULAIRE_EDITER_LIENS -> attraper le rang du lien |
|
| 319 | - // permet de voir le rang du lien si il y en a un en base, meme avant un squelette xxxx-lies.html ne gerant pas les liens |
|
| 320 | - if (isset($env['form']) and $env['form'] |
|
| 321 | - and isset($env['_objet_lien']) and $env['_objet_lien'] |
|
| 322 | - and (function_exists('lien_triables') or include_spip('action/editer_liens')) |
|
| 323 | - and $r = objet_associable($env['_objet_lien']) |
|
| 324 | - and list($p, $table_lien) = $r |
|
| 325 | - and lien_triables($table_lien) |
|
| 326 | - and isset($env['objet']) and $env['objet'] |
|
| 327 | - and isset($env['id_objet']) and $env['id_objet'] |
|
| 328 | - and $objet_source |
|
| 329 | - and $id = intval($id) |
|
| 330 | - ) { |
|
| 331 | - $rang = retrouver_rang_lien($objet_source, $id, $env['objet'], $env['id_objet'], $env['_objet_lien']); |
|
| 332 | - return ($rang ? $rang : ''); |
|
| 333 | - } |
|
| 334 | - return recuperer_numero($titre); |
|
| 318 | + // Cas du #RANG utilisé dans #FORMULAIRE_EDITER_LIENS -> attraper le rang du lien |
|
| 319 | + // permet de voir le rang du lien si il y en a un en base, meme avant un squelette xxxx-lies.html ne gerant pas les liens |
|
| 320 | + if (isset($env['form']) and $env['form'] |
|
| 321 | + and isset($env['_objet_lien']) and $env['_objet_lien'] |
|
| 322 | + and (function_exists('lien_triables') or include_spip('action/editer_liens')) |
|
| 323 | + and $r = objet_associable($env['_objet_lien']) |
|
| 324 | + and list($p, $table_lien) = $r |
|
| 325 | + and lien_triables($table_lien) |
|
| 326 | + and isset($env['objet']) and $env['objet'] |
|
| 327 | + and isset($env['id_objet']) and $env['id_objet'] |
|
| 328 | + and $objet_source |
|
| 329 | + and $id = intval($id) |
|
| 330 | + ) { |
|
| 331 | + $rang = retrouver_rang_lien($objet_source, $id, $env['objet'], $env['id_objet'], $env['_objet_lien']); |
|
| 332 | + return ($rang ? $rang : ''); |
|
| 333 | + } |
|
| 334 | + return recuperer_numero($titre); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @return string |
| 348 | 348 | */ |
| 349 | 349 | function tri_protege_champ($t) { |
| 350 | - return preg_replace(',[^\s\w.+\[\]],', '', $t); |
|
| 350 | + return preg_replace(',[^\s\w.+\[\]],', '', $t); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -360,34 +360,34 @@ discard block |
||
| 360 | 360 | * @return string |
| 361 | 361 | */ |
| 362 | 362 | function tri_champ_order($t, $from = null) { |
| 363 | - if (strncmp($t, 'multi ', 6) == 0) { |
|
| 364 | - return "multi"; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - $champ = $t; |
|
| 368 | - |
|
| 369 | - if (strncmp($t, 'num ', 4) == 0) { |
|
| 370 | - $champ = substr($t, 4); |
|
| 371 | - } |
|
| 372 | - // enlever les autres espaces non evacues par tri_protege_champ |
|
| 373 | - $champ = preg_replace(',\s,', '', $champ); |
|
| 374 | - |
|
| 375 | - if (is_array($from)) { |
|
| 376 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 377 | - foreach ($from as $idt => $table_sql) { |
|
| 378 | - if ($desc = $trouver_table($table_sql) |
|
| 379 | - and isset($desc['field'][$champ]) |
|
| 380 | - ) { |
|
| 381 | - $champ = "$idt.$champ"; |
|
| 382 | - break; |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - if (strncmp($t, 'num ', 4) == 0) { |
|
| 387 | - return "0+$champ"; |
|
| 388 | - } else { |
|
| 389 | - return $champ; |
|
| 390 | - } |
|
| 363 | + if (strncmp($t, 'multi ', 6) == 0) { |
|
| 364 | + return "multi"; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + $champ = $t; |
|
| 368 | + |
|
| 369 | + if (strncmp($t, 'num ', 4) == 0) { |
|
| 370 | + $champ = substr($t, 4); |
|
| 371 | + } |
|
| 372 | + // enlever les autres espaces non evacues par tri_protege_champ |
|
| 373 | + $champ = preg_replace(',\s,', '', $champ); |
|
| 374 | + |
|
| 375 | + if (is_array($from)) { |
|
| 376 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 377 | + foreach ($from as $idt => $table_sql) { |
|
| 378 | + if ($desc = $trouver_table($table_sql) |
|
| 379 | + and isset($desc['field'][$champ]) |
|
| 380 | + ) { |
|
| 381 | + $champ = "$idt.$champ"; |
|
| 382 | + break; |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + if (strncmp($t, 'num ', 4) == 0) { |
|
| 387 | + return "0+$champ"; |
|
| 388 | + } else { |
|
| 389 | + return $champ; |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -401,18 +401,18 @@ discard block |
||
| 401 | 401 | * @return string |
| 402 | 402 | */ |
| 403 | 403 | function tri_champ_select($t) { |
| 404 | - if (strncmp($t, 'multi ', 6) == 0) { |
|
| 405 | - $t = substr($t, 6); |
|
| 406 | - $t = preg_replace(',\s,', '', $t); |
|
| 407 | - $t = sql_multi($t, $GLOBALS['spip_lang']); |
|
| 408 | - |
|
| 409 | - return $t; |
|
| 410 | - } |
|
| 411 | - if (trim($t) == 'hasard') { |
|
| 412 | - return 'rand() AS hasard'; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - return "''"; |
|
| 404 | + if (strncmp($t, 'multi ', 6) == 0) { |
|
| 405 | + $t = substr($t, 6); |
|
| 406 | + $t = preg_replace(',\s,', '', $t); |
|
| 407 | + $t = sql_multi($t, $GLOBALS['spip_lang']); |
|
| 408 | + |
|
| 409 | + return $t; |
|
| 410 | + } |
|
| 411 | + if (trim($t) == 'hasard') { |
|
| 412 | + return 'rand() AS hasard'; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + return "''"; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -424,16 +424,16 @@ discard block |
||
| 424 | 424 | * @return string |
| 425 | 425 | */ |
| 426 | 426 | function formate_liste_critere_par_ordre_liste($valeurs, $serveur = ''){ |
| 427 | - if (!is_array($valeurs)){ |
|
| 428 | - return ''; |
|
| 429 | - } |
|
| 430 | - $f = sql_serveur('quote', $serveur, true); |
|
| 431 | - if (!is_string($f) or !$f){ |
|
| 432 | - return ''; |
|
| 433 | - } |
|
| 434 | - $valeurs = implode(',', array_map($f, array_unique($valeurs))); |
|
| 435 | - |
|
| 436 | - return $valeurs; |
|
| 427 | + if (!is_array($valeurs)){ |
|
| 428 | + return ''; |
|
| 429 | + } |
|
| 430 | + $f = sql_serveur('quote', $serveur, true); |
|
| 431 | + if (!is_string($f) or !$f){ |
|
| 432 | + return ''; |
|
| 433 | + } |
|
| 434 | + $valeurs = implode(',', array_map($f, array_unique($valeurs))); |
|
| 435 | + |
|
| 436 | + return $valeurs; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -456,20 +456,20 @@ discard block |
||
| 456 | 456 | * Valeur $defaut sinon. |
| 457 | 457 | **/ |
| 458 | 458 | function appliquer_filtre_sinon($arg, $filtre, $args, $defaut = '') { |
| 459 | - // Si c'est un filtre d'image, on utilise image_filtrer() |
|
| 460 | - // Attention : les 2 premiers arguments sont inversés dans ce cas |
|
| 461 | - if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 462 | - $args[1] = $args[0]; |
|
| 463 | - $args[0] = $filtre; |
|
| 464 | - return image_graver(image_filtrer($args)); |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - $f = chercher_filtre($filtre); |
|
| 468 | - if (!$f) { |
|
| 469 | - return $defaut; |
|
| 470 | - } |
|
| 471 | - array_shift($args); // enlever $arg |
|
| 472 | - array_shift($args); // enlever $filtre |
|
| 473 | - array_unshift($args, $arg); // remettre $arg |
|
| 474 | - return call_user_func_array($f, $args); |
|
| 459 | + // Si c'est un filtre d'image, on utilise image_filtrer() |
|
| 460 | + // Attention : les 2 premiers arguments sont inversés dans ce cas |
|
| 461 | + if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 462 | + $args[1] = $args[0]; |
|
| 463 | + $args[0] = $filtre; |
|
| 464 | + return image_graver(image_filtrer($args)); |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + $f = chercher_filtre($filtre); |
|
| 468 | + if (!$f) { |
|
| 469 | + return $defaut; |
|
| 470 | + } |
|
| 471 | + array_shift($args); // enlever $arg |
|
| 472 | + array_shift($args); // enlever $filtre |
|
| 473 | + array_unshift($args, $arg); // remettre $arg |
|
| 474 | + return call_user_func_array($f, $args); |
|
| 475 | 475 | } |