@@ -9,13 +9,13 @@ |
||
| 9 | 9 | <h1>Index des icones de <a href='https://www.spip.net'>Spip</a></h1> |
| 10 | 10 | <table> |
| 11 | 11 | <?php |
| 12 | - $myDir = opendir('.'); |
|
| 13 | - while ($file = readdir($myDir)) { |
|
| 14 | - if (preg_match(',\.(png|gif)$,i', $file)) { |
|
| 15 | - echo " <tr><td>$file</td><td><img src='$file' alt='$file' /></td></tr>\n"; |
|
| 16 | - } |
|
| 17 | - } |
|
| 18 | - ?> |
|
| 12 | + $myDir = opendir('.'); |
|
| 13 | + while ($file = readdir($myDir)) { |
|
| 14 | + if (preg_match(',\.(png|gif)$,i', $file)) { |
|
| 15 | + echo " <tr><td>$file</td><td><img src='$file' alt='$file' /></td></tr>\n"; |
|
| 16 | + } |
|
| 17 | + } |
|
| 18 | + ?> |
|
| 19 | 19 | </table> |
| 20 | 20 | </center> |
| 21 | 21 | </body> |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | // https://code.spip.net/@req_sqlite3_dist |
| 24 | 24 | function req_sqlite3_dist($addr, $port, $login, $pass, $db = '', $prefixe = '') { |
| 25 | - return req_sqlite_dist($addr, $port, $login, $pass, $db, $prefixe, $sqlite_version = 3); |
|
| 25 | + return req_sqlite_dist($addr, $port, $login, $pass, $db, $prefixe, $sqlite_version = 3); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | // https://code.spip.net/@spip_sqlite3_constantes |
| 30 | 30 | function spip_sqlite3_constantes() { |
| 31 | - if (!defined('SPIP_SQLITE3_ASSOC')) { |
|
| 32 | - define('SPIP_SQLITE3_ASSOC', PDO::FETCH_ASSOC); |
|
| 33 | - define('SPIP_SQLITE3_NUM', PDO::FETCH_NUM); |
|
| 34 | - define('SPIP_SQLITE3_BOTH', PDO::FETCH_BOTH); |
|
| 35 | - } |
|
| 31 | + if (!defined('SPIP_SQLITE3_ASSOC')) { |
|
| 32 | + define('SPIP_SQLITE3_ASSOC', PDO::FETCH_ASSOC); |
|
| 33 | + define('SPIP_SQLITE3_NUM', PDO::FETCH_NUM); |
|
| 34 | + define('SPIP_SQLITE3_BOTH', PDO::FETCH_BOTH); |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function spip_versions_sqlite3() { |
| 39 | - return _sqlite_charger_version(3) ? 3 : false; |
|
| 39 | + return _sqlite_charger_version(3) ? 3 : false; |
|
| 40 | 40 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -23,333 +23,333 @@ discard block |
||
| 23 | 23 | **/ |
| 24 | 24 | class ValidateurXML { |
| 25 | 25 | |
| 26 | - // https://code.spip.net/@validerElement |
|
| 27 | - public function validerElement($phraseur, $name, $attrs) { |
|
| 28 | - if (!($p = isset($this->dtc->elements[$name]))) { |
|
| 29 | - if ($p = strpos($name, ':')) { |
|
| 30 | - $name = substr($name, $p + 1); |
|
| 31 | - $p = isset($this->dtc->elements[$name]); |
|
| 32 | - } |
|
| 33 | - if (!$p) { |
|
| 34 | - coordonnees_erreur($this, " <b>$name</b> : " |
|
| 35 | - . _T('zxml_inconnu_balise')); |
|
| 36 | - |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - // controler les filles illegitimes, ca suffit |
|
| 41 | - $depth = $this->depth; |
|
| 42 | - $ouvrant = $this->ouvrant; |
|
| 43 | - #spip_log("trouve $name apres " . $ouvrant[$depth]); |
|
| 44 | - if (isset($ouvrant[$depth])) { |
|
| 45 | - if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) { |
|
| 46 | - $pere = $r[1]; |
|
| 47 | - #spip_log("pere $pere"); |
|
| 48 | - if (isset($this->dtc->elements[$pere])) { |
|
| 49 | - $fils = $this->dtc->elements[$pere]; |
|
| 50 | - #spip_log("rejeton $name fils " . @join(',',$fils)); |
|
| 51 | - if (!($p = @in_array($name, $fils))) { |
|
| 52 | - if ($p = strpos($name, ':')) { |
|
| 53 | - $p = substr($name, $p + 1); |
|
| 54 | - $p = @in_array($p, $fils); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - if (!$p) { |
|
| 58 | - $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]); |
|
| 59 | - coordonnees_erreur($this, " <b>$name</b> " |
|
| 60 | - . _T('zxml_non_fils') |
|
| 61 | - . ' <b>' |
|
| 62 | - . $pere |
|
| 63 | - . '</b>' |
|
| 64 | - . (!$bons_peres ? '' |
|
| 65 | - : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>'))); |
|
| 66 | - } elseif ($this->dtc->regles[$pere][0] == '/') { |
|
| 67 | - $frat = substr($depth, 2); |
|
| 68 | - if (!isset($this->fratrie[$frat])) { |
|
| 69 | - $this->fratrie[$frat] = ''; |
|
| 70 | - } |
|
| 71 | - $this->fratrie[$frat] .= "$name "; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - // Init de la suite des balises a memoriser si regle difficile |
|
| 77 | - if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') { |
|
| 78 | - $this->fratrie[$depth] = ''; |
|
| 79 | - } |
|
| 80 | - if (isset($this->dtc->attributs[$name])) { |
|
| 81 | - foreach ($this->dtc->attributs[$name] as $n => $v) { |
|
| 82 | - if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) { |
|
| 83 | - coordonnees_erreur($this, " <b>$n</b>" |
|
| 84 | - . ' : ' |
|
| 85 | - . _T('zxml_obligatoire_attribut') |
|
| 86 | - . " <b>$name</b>"); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // https://code.spip.net/@validerAttribut |
|
| 93 | - public function validerAttribut($phraseur, $name, $val, $bal) { |
|
| 94 | - // Si la balise est inconnue, eviter d'insister |
|
| 95 | - if (!isset($this->dtc->attributs[$bal])) { |
|
| 96 | - return; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $a = $this->dtc->attributs[$bal]; |
|
| 100 | - if (!isset($a[$name])) { |
|
| 101 | - $bons = join(', ', array_keys($a)); |
|
| 102 | - if ($bons) { |
|
| 103 | - $bons = " title=' " . |
|
| 104 | - _T('zxml_connus_attributs') . |
|
| 105 | - ' : ' . |
|
| 106 | - $bons . |
|
| 107 | - "'"; |
|
| 108 | - } |
|
| 109 | - $bons .= " style='font-weight: bold'"; |
|
| 110 | - coordonnees_erreur($this, " <b>$name</b> " |
|
| 111 | - . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de') |
|
| 112 | - . " <a$bons>$bal</a> (" |
|
| 113 | - . _T('zxml_survoler') |
|
| 114 | - . ")"); |
|
| 115 | - } else { |
|
| 116 | - $type = $a[$name][0]; |
|
| 117 | - if (!preg_match('/^\w+$/', $type)) { |
|
| 118 | - $this->valider_motif($phraseur, $name, $val, $bal, $type); |
|
| 119 | - } else { |
|
| 120 | - if (method_exists($this, $f = 'validerAttribut_' . $type)) { |
|
| 121 | - $this->$f($phraseur, $name, $val, $bal); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - # else spip_log("$type type d'attribut inconnu"); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) { |
|
| 129 | - $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) { |
|
| 133 | - $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // https://code.spip.net/@validerAttribut_ID |
|
| 137 | - public function validerAttribut_ID($phraseur, $name, $val, $bal) { |
|
| 138 | - if (isset($this->ids[$val])) { |
|
| 139 | - list($l, $c) = $this->ids[$val]; |
|
| 140 | - coordonnees_erreur($this, " <p><b>$val</b> " |
|
| 141 | - . _T('zxml_valeur_attribut') |
|
| 142 | - . " <b>$name</b> " |
|
| 143 | - . _T('zxml_de') |
|
| 144 | - . " <b>$bal</b> " |
|
| 145 | - . _T('zxml_vu') |
|
| 146 | - . " (L$l,C$c)"); |
|
| 147 | - } else { |
|
| 148 | - $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID); |
|
| 149 | - $this->ids[$val] = array(xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // https://code.spip.net/@validerAttribut_IDREF |
|
| 154 | - public function validerAttribut_IDREF($phraseur, $name, $val, $bal) { |
|
| 155 | - $this->idrefs[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // https://code.spip.net/@validerAttribut_IDREFS |
|
| 159 | - public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) { |
|
| 160 | - $this->idrefss[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // https://code.spip.net/@valider_motif |
|
| 164 | - public function valider_motif($phraseur, $name, $val, $bal, $motif) { |
|
| 165 | - if (!preg_match($motif, $val)) { |
|
| 166 | - coordonnees_erreur($this, "<b>$val</b> " |
|
| 167 | - . _T('zxml_valeur_attribut') |
|
| 168 | - . " <b>$name</b> " |
|
| 169 | - . _T('zxml_de') |
|
| 170 | - . " <b>$bal</b> " |
|
| 171 | - . _T('zxml_non_conforme') |
|
| 172 | - . "</p><p>" |
|
| 173 | - . "<b>" . $motif . "</b>"); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // https://code.spip.net/@valider_idref |
|
| 178 | - public function valider_idref($nom, $ligne, $col) { |
|
| 179 | - if (!isset($this->ids[$nom])) { |
|
| 180 | - $this->err[] = array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // https://code.spip.net/@valider_passe2 |
|
| 185 | - public function valider_passe2() { |
|
| 186 | - if (!$this->err) { |
|
| 187 | - foreach ($this->idrefs as $idref) { |
|
| 188 | - list($nom, $ligne, $col) = $idref; |
|
| 189 | - $this->valider_idref($nom, $ligne, $col); |
|
| 190 | - } |
|
| 191 | - foreach ($this->idrefss as $idref) { |
|
| 192 | - list($noms, $ligne, $col) = $idref; |
|
| 193 | - foreach (preg_split('/\s+/', $noms) as $nom) { |
|
| 194 | - $this->valider_idref($nom, $ligne, $col); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // https://code.spip.net/@debutElement |
|
| 201 | - public function debutElement($phraseur, $name, $attrs) { |
|
| 202 | - if ($this->dtc->elements) { |
|
| 203 | - $this->validerElement($phraseur, $name, $attrs); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - if ($f = $this->process['debut']) { |
|
| 207 | - $f($this, $name, $attrs); |
|
| 208 | - } |
|
| 209 | - $depth = $this->depth; |
|
| 210 | - $this->debuts[$depth] = strlen($this->res); |
|
| 211 | - foreach ($attrs as $k => $v) { |
|
| 212 | - $this->validerAttribut($phraseur, $k, $v, $name); |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - // https://code.spip.net/@finElement |
|
| 217 | - public function finElement($phraseur, $name) { |
|
| 218 | - $depth = $this->depth; |
|
| 219 | - $contenu = $this->contenu; |
|
| 220 | - |
|
| 221 | - $n = strlen($this->res); |
|
| 222 | - $c = strlen(trim($contenu[$depth])); |
|
| 223 | - $k = $this->debuts[$depth]; |
|
| 224 | - |
|
| 225 | - $regle = isset($this->dtc->regles[$name]) ? $this->dtc->regles[$name] : false; |
|
| 226 | - $vide = ($regle == 'EMPTY'); |
|
| 227 | - // controler que les balises devant etre vides le sont |
|
| 228 | - if ($vide) { |
|
| 229 | - if ($n <> ($k + $c)) { |
|
| 230 | - coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise')); |
|
| 231 | - } |
|
| 232 | - // pour les regles PCDATA ou iteration de disjonction, tout est fait |
|
| 233 | - } elseif ($regle and ($regle != '*')) { |
|
| 234 | - if ($regle == '+') { |
|
| 235 | - // iteration de disjonction non vide: 1 balise au - |
|
| 236 | - if ($n == $k) { |
|
| 237 | - coordonnees_erreur($this, "<p>\n<b>$name</b> " |
|
| 238 | - . _T('zxml_vide_balise')); |
|
| 239 | - } |
|
| 240 | - } else { |
|
| 241 | - $f = isset($this->fratrie[substr($depth, 2)]) ? $this->fratrie[substr($depth, 2)] : null; |
|
| 242 | - if (is_null($f) or !preg_match($regle, $f)) { |
|
| 243 | - coordonnees_erreur($this, |
|
| 244 | - " <p>\n<b>$name</b> " |
|
| 245 | - . _T('zxml_succession_fils_incorrecte') |
|
| 246 | - . ' : <b>' |
|
| 247 | - . $f |
|
| 248 | - . '</b>'); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - } |
|
| 253 | - if ($f = $this->process['fin']) { |
|
| 254 | - $f($this, $name, $vide); |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - // https://code.spip.net/@textElement |
|
| 259 | - public function textElement($phraseur, $data) { |
|
| 260 | - if (trim($data)) { |
|
| 261 | - $d = $this->depth; |
|
| 262 | - $d = $this->ouvrant[$d]; |
|
| 263 | - preg_match('/^\s*(\S+)/', $d, $m); |
|
| 264 | - if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) { |
|
| 265 | - coordonnees_erreur($this, " <p><b>" . $m[1] . "</b> " |
|
| 266 | - . _T('zxml_nonvide_balise') // message a affiner |
|
| 267 | - ); |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - if ($f = $this->process['text']) { |
|
| 271 | - $f($this, $data); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - public function piElement($phraseur, $target, $data) { |
|
| 276 | - if ($f = $this->process['pi']) { |
|
| 277 | - $f($this, $target, $data); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - // Denonciation des entitees XML inconnues |
|
| 282 | - // Pour contourner le bug de conception de SAX qui ne signale pas si elles |
|
| 283 | - // sont dans un attribut, les entites les plus frequentes ont ete |
|
| 284 | - // transcodees au prealable (sauf & < > " que SAX traite correctement). |
|
| 285 | - // On ne les verra donc pas passer a cette etape, contrairement a ce que |
|
| 286 | - // le source de la page laisse legitimement supposer. |
|
| 287 | - |
|
| 288 | - // https://code.spip.net/@defautElement |
|
| 289 | - public function defaultElement($phraseur, $data) { |
|
| 290 | - if (!preg_match('/^<!--/', $data) |
|
| 291 | - and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER)) |
|
| 292 | - ) { |
|
| 293 | - foreach ($r as $m) { |
|
| 294 | - list($t, $e) = $m; |
|
| 295 | - if (!isset($this->dtc->entites[$e])) { |
|
| 296 | - coordonnees_erreur($this, " <b>$e</b> " |
|
| 297 | - . _T('zxml_inconnu_entite') |
|
| 298 | - . ' ' |
|
| 299 | - ); |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - if (isset($this->process['default']) and ($f = $this->process['default'])) { |
|
| 304 | - $f($this, $data); |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - // https://code.spip.net/@phraserTout |
|
| 309 | - public function phraserTout($phraseur, $data) { |
|
| 310 | - xml_parsestring($this, $data); |
|
| 311 | - |
|
| 312 | - if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) { |
|
| 313 | - $this->err[] = array('DOCTYPE ?', 0, 0); |
|
| 314 | - } else { |
|
| 315 | - $this->valider_passe2($this); |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Constructeur |
|
| 321 | - * |
|
| 322 | - * @param array $process ? |
|
| 323 | - **/ |
|
| 324 | - public function __construct($process = array()) { |
|
| 325 | - if (is_array($process)) { |
|
| 326 | - $this->process = $process; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - public $ids = array(); |
|
| 331 | - public $idrefs = array(); |
|
| 332 | - public $idrefss = array(); |
|
| 333 | - public $debuts = array(); |
|
| 334 | - public $fratrie = array(); |
|
| 335 | - |
|
| 336 | - public $dtc = null; |
|
| 337 | - public $sax = null; |
|
| 338 | - public $depth = ""; |
|
| 339 | - public $entete = ''; |
|
| 340 | - public $page = ''; |
|
| 341 | - public $res = ""; |
|
| 342 | - public $err = array(); |
|
| 343 | - public $contenu = array(); |
|
| 344 | - public $ouvrant = array(); |
|
| 345 | - public $reperes = array(); |
|
| 346 | - public $process = array( |
|
| 347 | - 'debut' => 'xml_debutElement', |
|
| 348 | - 'fin' => 'xml_finElement', |
|
| 349 | - 'text' => 'xml_textElement', |
|
| 350 | - 'pi' => 'xml_piElement', |
|
| 351 | - 'default' => 'xml_defaultElement' |
|
| 352 | - ); |
|
| 26 | + // https://code.spip.net/@validerElement |
|
| 27 | + public function validerElement($phraseur, $name, $attrs) { |
|
| 28 | + if (!($p = isset($this->dtc->elements[$name]))) { |
|
| 29 | + if ($p = strpos($name, ':')) { |
|
| 30 | + $name = substr($name, $p + 1); |
|
| 31 | + $p = isset($this->dtc->elements[$name]); |
|
| 32 | + } |
|
| 33 | + if (!$p) { |
|
| 34 | + coordonnees_erreur($this, " <b>$name</b> : " |
|
| 35 | + . _T('zxml_inconnu_balise')); |
|
| 36 | + |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + // controler les filles illegitimes, ca suffit |
|
| 41 | + $depth = $this->depth; |
|
| 42 | + $ouvrant = $this->ouvrant; |
|
| 43 | + #spip_log("trouve $name apres " . $ouvrant[$depth]); |
|
| 44 | + if (isset($ouvrant[$depth])) { |
|
| 45 | + if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) { |
|
| 46 | + $pere = $r[1]; |
|
| 47 | + #spip_log("pere $pere"); |
|
| 48 | + if (isset($this->dtc->elements[$pere])) { |
|
| 49 | + $fils = $this->dtc->elements[$pere]; |
|
| 50 | + #spip_log("rejeton $name fils " . @join(',',$fils)); |
|
| 51 | + if (!($p = @in_array($name, $fils))) { |
|
| 52 | + if ($p = strpos($name, ':')) { |
|
| 53 | + $p = substr($name, $p + 1); |
|
| 54 | + $p = @in_array($p, $fils); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + if (!$p) { |
|
| 58 | + $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]); |
|
| 59 | + coordonnees_erreur($this, " <b>$name</b> " |
|
| 60 | + . _T('zxml_non_fils') |
|
| 61 | + . ' <b>' |
|
| 62 | + . $pere |
|
| 63 | + . '</b>' |
|
| 64 | + . (!$bons_peres ? '' |
|
| 65 | + : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>'))); |
|
| 66 | + } elseif ($this->dtc->regles[$pere][0] == '/') { |
|
| 67 | + $frat = substr($depth, 2); |
|
| 68 | + if (!isset($this->fratrie[$frat])) { |
|
| 69 | + $this->fratrie[$frat] = ''; |
|
| 70 | + } |
|
| 71 | + $this->fratrie[$frat] .= "$name "; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + // Init de la suite des balises a memoriser si regle difficile |
|
| 77 | + if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') { |
|
| 78 | + $this->fratrie[$depth] = ''; |
|
| 79 | + } |
|
| 80 | + if (isset($this->dtc->attributs[$name])) { |
|
| 81 | + foreach ($this->dtc->attributs[$name] as $n => $v) { |
|
| 82 | + if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) { |
|
| 83 | + coordonnees_erreur($this, " <b>$n</b>" |
|
| 84 | + . ' : ' |
|
| 85 | + . _T('zxml_obligatoire_attribut') |
|
| 86 | + . " <b>$name</b>"); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // https://code.spip.net/@validerAttribut |
|
| 93 | + public function validerAttribut($phraseur, $name, $val, $bal) { |
|
| 94 | + // Si la balise est inconnue, eviter d'insister |
|
| 95 | + if (!isset($this->dtc->attributs[$bal])) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $a = $this->dtc->attributs[$bal]; |
|
| 100 | + if (!isset($a[$name])) { |
|
| 101 | + $bons = join(', ', array_keys($a)); |
|
| 102 | + if ($bons) { |
|
| 103 | + $bons = " title=' " . |
|
| 104 | + _T('zxml_connus_attributs') . |
|
| 105 | + ' : ' . |
|
| 106 | + $bons . |
|
| 107 | + "'"; |
|
| 108 | + } |
|
| 109 | + $bons .= " style='font-weight: bold'"; |
|
| 110 | + coordonnees_erreur($this, " <b>$name</b> " |
|
| 111 | + . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de') |
|
| 112 | + . " <a$bons>$bal</a> (" |
|
| 113 | + . _T('zxml_survoler') |
|
| 114 | + . ")"); |
|
| 115 | + } else { |
|
| 116 | + $type = $a[$name][0]; |
|
| 117 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 118 | + $this->valider_motif($phraseur, $name, $val, $bal, $type); |
|
| 119 | + } else { |
|
| 120 | + if (method_exists($this, $f = 'validerAttribut_' . $type)) { |
|
| 121 | + $this->$f($phraseur, $name, $val, $bal); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + # else spip_log("$type type d'attribut inconnu"); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) { |
|
| 129 | + $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) { |
|
| 133 | + $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // https://code.spip.net/@validerAttribut_ID |
|
| 137 | + public function validerAttribut_ID($phraseur, $name, $val, $bal) { |
|
| 138 | + if (isset($this->ids[$val])) { |
|
| 139 | + list($l, $c) = $this->ids[$val]; |
|
| 140 | + coordonnees_erreur($this, " <p><b>$val</b> " |
|
| 141 | + . _T('zxml_valeur_attribut') |
|
| 142 | + . " <b>$name</b> " |
|
| 143 | + . _T('zxml_de') |
|
| 144 | + . " <b>$bal</b> " |
|
| 145 | + . _T('zxml_vu') |
|
| 146 | + . " (L$l,C$c)"); |
|
| 147 | + } else { |
|
| 148 | + $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID); |
|
| 149 | + $this->ids[$val] = array(xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // https://code.spip.net/@validerAttribut_IDREF |
|
| 154 | + public function validerAttribut_IDREF($phraseur, $name, $val, $bal) { |
|
| 155 | + $this->idrefs[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // https://code.spip.net/@validerAttribut_IDREFS |
|
| 159 | + public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) { |
|
| 160 | + $this->idrefss[] = array($val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // https://code.spip.net/@valider_motif |
|
| 164 | + public function valider_motif($phraseur, $name, $val, $bal, $motif) { |
|
| 165 | + if (!preg_match($motif, $val)) { |
|
| 166 | + coordonnees_erreur($this, "<b>$val</b> " |
|
| 167 | + . _T('zxml_valeur_attribut') |
|
| 168 | + . " <b>$name</b> " |
|
| 169 | + . _T('zxml_de') |
|
| 170 | + . " <b>$bal</b> " |
|
| 171 | + . _T('zxml_non_conforme') |
|
| 172 | + . "</p><p>" |
|
| 173 | + . "<b>" . $motif . "</b>"); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // https://code.spip.net/@valider_idref |
|
| 178 | + public function valider_idref($nom, $ligne, $col) { |
|
| 179 | + if (!isset($this->ids[$nom])) { |
|
| 180 | + $this->err[] = array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // https://code.spip.net/@valider_passe2 |
|
| 185 | + public function valider_passe2() { |
|
| 186 | + if (!$this->err) { |
|
| 187 | + foreach ($this->idrefs as $idref) { |
|
| 188 | + list($nom, $ligne, $col) = $idref; |
|
| 189 | + $this->valider_idref($nom, $ligne, $col); |
|
| 190 | + } |
|
| 191 | + foreach ($this->idrefss as $idref) { |
|
| 192 | + list($noms, $ligne, $col) = $idref; |
|
| 193 | + foreach (preg_split('/\s+/', $noms) as $nom) { |
|
| 194 | + $this->valider_idref($nom, $ligne, $col); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // https://code.spip.net/@debutElement |
|
| 201 | + public function debutElement($phraseur, $name, $attrs) { |
|
| 202 | + if ($this->dtc->elements) { |
|
| 203 | + $this->validerElement($phraseur, $name, $attrs); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + if ($f = $this->process['debut']) { |
|
| 207 | + $f($this, $name, $attrs); |
|
| 208 | + } |
|
| 209 | + $depth = $this->depth; |
|
| 210 | + $this->debuts[$depth] = strlen($this->res); |
|
| 211 | + foreach ($attrs as $k => $v) { |
|
| 212 | + $this->validerAttribut($phraseur, $k, $v, $name); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + // https://code.spip.net/@finElement |
|
| 217 | + public function finElement($phraseur, $name) { |
|
| 218 | + $depth = $this->depth; |
|
| 219 | + $contenu = $this->contenu; |
|
| 220 | + |
|
| 221 | + $n = strlen($this->res); |
|
| 222 | + $c = strlen(trim($contenu[$depth])); |
|
| 223 | + $k = $this->debuts[$depth]; |
|
| 224 | + |
|
| 225 | + $regle = isset($this->dtc->regles[$name]) ? $this->dtc->regles[$name] : false; |
|
| 226 | + $vide = ($regle == 'EMPTY'); |
|
| 227 | + // controler que les balises devant etre vides le sont |
|
| 228 | + if ($vide) { |
|
| 229 | + if ($n <> ($k + $c)) { |
|
| 230 | + coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise')); |
|
| 231 | + } |
|
| 232 | + // pour les regles PCDATA ou iteration de disjonction, tout est fait |
|
| 233 | + } elseif ($regle and ($regle != '*')) { |
|
| 234 | + if ($regle == '+') { |
|
| 235 | + // iteration de disjonction non vide: 1 balise au - |
|
| 236 | + if ($n == $k) { |
|
| 237 | + coordonnees_erreur($this, "<p>\n<b>$name</b> " |
|
| 238 | + . _T('zxml_vide_balise')); |
|
| 239 | + } |
|
| 240 | + } else { |
|
| 241 | + $f = isset($this->fratrie[substr($depth, 2)]) ? $this->fratrie[substr($depth, 2)] : null; |
|
| 242 | + if (is_null($f) or !preg_match($regle, $f)) { |
|
| 243 | + coordonnees_erreur($this, |
|
| 244 | + " <p>\n<b>$name</b> " |
|
| 245 | + . _T('zxml_succession_fils_incorrecte') |
|
| 246 | + . ' : <b>' |
|
| 247 | + . $f |
|
| 248 | + . '</b>'); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + } |
|
| 253 | + if ($f = $this->process['fin']) { |
|
| 254 | + $f($this, $name, $vide); |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + // https://code.spip.net/@textElement |
|
| 259 | + public function textElement($phraseur, $data) { |
|
| 260 | + if (trim($data)) { |
|
| 261 | + $d = $this->depth; |
|
| 262 | + $d = $this->ouvrant[$d]; |
|
| 263 | + preg_match('/^\s*(\S+)/', $d, $m); |
|
| 264 | + if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) { |
|
| 265 | + coordonnees_erreur($this, " <p><b>" . $m[1] . "</b> " |
|
| 266 | + . _T('zxml_nonvide_balise') // message a affiner |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + if ($f = $this->process['text']) { |
|
| 271 | + $f($this, $data); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + public function piElement($phraseur, $target, $data) { |
|
| 276 | + if ($f = $this->process['pi']) { |
|
| 277 | + $f($this, $target, $data); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + // Denonciation des entitees XML inconnues |
|
| 282 | + // Pour contourner le bug de conception de SAX qui ne signale pas si elles |
|
| 283 | + // sont dans un attribut, les entites les plus frequentes ont ete |
|
| 284 | + // transcodees au prealable (sauf & < > " que SAX traite correctement). |
|
| 285 | + // On ne les verra donc pas passer a cette etape, contrairement a ce que |
|
| 286 | + // le source de la page laisse legitimement supposer. |
|
| 287 | + |
|
| 288 | + // https://code.spip.net/@defautElement |
|
| 289 | + public function defaultElement($phraseur, $data) { |
|
| 290 | + if (!preg_match('/^<!--/', $data) |
|
| 291 | + and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER)) |
|
| 292 | + ) { |
|
| 293 | + foreach ($r as $m) { |
|
| 294 | + list($t, $e) = $m; |
|
| 295 | + if (!isset($this->dtc->entites[$e])) { |
|
| 296 | + coordonnees_erreur($this, " <b>$e</b> " |
|
| 297 | + . _T('zxml_inconnu_entite') |
|
| 298 | + . ' ' |
|
| 299 | + ); |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + if (isset($this->process['default']) and ($f = $this->process['default'])) { |
|
| 304 | + $f($this, $data); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + // https://code.spip.net/@phraserTout |
|
| 309 | + public function phraserTout($phraseur, $data) { |
|
| 310 | + xml_parsestring($this, $data); |
|
| 311 | + |
|
| 312 | + if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) { |
|
| 313 | + $this->err[] = array('DOCTYPE ?', 0, 0); |
|
| 314 | + } else { |
|
| 315 | + $this->valider_passe2($this); |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Constructeur |
|
| 321 | + * |
|
| 322 | + * @param array $process ? |
|
| 323 | + **/ |
|
| 324 | + public function __construct($process = array()) { |
|
| 325 | + if (is_array($process)) { |
|
| 326 | + $this->process = $process; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + public $ids = array(); |
|
| 331 | + public $idrefs = array(); |
|
| 332 | + public $idrefss = array(); |
|
| 333 | + public $debuts = array(); |
|
| 334 | + public $fratrie = array(); |
|
| 335 | + |
|
| 336 | + public $dtc = null; |
|
| 337 | + public $sax = null; |
|
| 338 | + public $depth = ""; |
|
| 339 | + public $entete = ''; |
|
| 340 | + public $page = ''; |
|
| 341 | + public $res = ""; |
|
| 342 | + public $err = array(); |
|
| 343 | + public $contenu = array(); |
|
| 344 | + public $ouvrant = array(); |
|
| 345 | + public $reperes = array(); |
|
| 346 | + public $process = array( |
|
| 347 | + 'debut' => 'xml_debutElement', |
|
| 348 | + 'fin' => 'xml_finElement', |
|
| 349 | + 'text' => 'xml_textElement', |
|
| 350 | + 'pi' => 'xml_piElement', |
|
| 351 | + 'default' => 'xml_defaultElement' |
|
| 352 | + ); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | **/ |
| 361 | 361 | function xml_valider_dist($page, $apply = false, $process = false, $doctype = '', $charset = null) { |
| 362 | - $f = new ValidateurXML($process); |
|
| 363 | - $sax = charger_fonction('sax', 'xml'); |
|
| 362 | + $f = new ValidateurXML($process); |
|
| 363 | + $sax = charger_fonction('sax', 'xml'); |
|
| 364 | 364 | |
| 365 | - return $sax($page, $apply, $f, $doctype, $charset); |
|
| 365 | + return $sax($page, $apply, $f, $doctype, $charset); |
|
| 366 | 366 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | . $pere |
| 63 | 63 | . '</b>' |
| 64 | 64 | . (!$bons_peres ? '' |
| 65 | - : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>'))); |
|
| 65 | + : ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'.$bons_peres.'</b></p>'))); |
|
| 66 | 66 | } elseif ($this->dtc->regles[$pere][0] == '/') { |
| 67 | 67 | $frat = substr($depth, 2); |
| 68 | 68 | if (!isset($this->fratrie[$frat])) { |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | if (!isset($a[$name])) { |
| 101 | 101 | $bons = join(', ', array_keys($a)); |
| 102 | 102 | if ($bons) { |
| 103 | - $bons = " title=' " . |
|
| 104 | - _T('zxml_connus_attributs') . |
|
| 105 | - ' : ' . |
|
| 106 | - $bons . |
|
| 103 | + $bons = " title=' ". |
|
| 104 | + _T('zxml_connus_attributs'). |
|
| 105 | + ' : '. |
|
| 106 | + $bons. |
|
| 107 | 107 | "'"; |
| 108 | 108 | } |
| 109 | 109 | $bons .= " style='font-weight: bold'"; |
| 110 | 110 | coordonnees_erreur($this, " <b>$name</b> " |
| 111 | - . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de') |
|
| 111 | + . _T('zxml_inconnu_attribut').' '._T('zxml_de') |
|
| 112 | 112 | . " <a$bons>$bal</a> (" |
| 113 | 113 | . _T('zxml_survoler') |
| 114 | 114 | . ")"); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | if (!preg_match('/^\w+$/', $type)) { |
| 118 | 118 | $this->valider_motif($phraseur, $name, $val, $bal, $type); |
| 119 | 119 | } else { |
| 120 | - if (method_exists($this, $f = 'validerAttribut_' . $type)) { |
|
| 120 | + if (method_exists($this, $f = 'validerAttribut_'.$type)) { |
|
| 121 | 121 | $this->$f($phraseur, $name, $val, $bal); |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -170,14 +170,14 @@ discard block |
||
| 170 | 170 | . " <b>$bal</b> " |
| 171 | 171 | . _T('zxml_non_conforme') |
| 172 | 172 | . "</p><p>" |
| 173 | - . "<b>" . $motif . "</b>"); |
|
| 173 | + . "<b>".$motif."</b>"); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // https://code.spip.net/@valider_idref |
| 178 | 178 | public function valider_idref($nom, $ligne, $col) { |
| 179 | 179 | if (!isset($this->ids[$nom])) { |
| 180 | - $this->err[] = array(" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col); |
|
| 180 | + $this->err[] = array(" <p><b>$nom</b> "._T('zxml_inconnu_id'), $ligne, $col); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | // controler que les balises devant etre vides le sont |
| 228 | 228 | if ($vide) { |
| 229 | 229 | if ($n <> ($k + $c)) { |
| 230 | - coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise')); |
|
| 230 | + coordonnees_erreur($this, " <p><b>$name</b> "._T('zxml_nonvide_balise')); |
|
| 231 | 231 | } |
| 232 | 232 | // pour les regles PCDATA ou iteration de disjonction, tout est fait |
| 233 | 233 | } elseif ($regle and ($regle != '*')) { |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $d = $this->ouvrant[$d]; |
| 263 | 263 | preg_match('/^\s*(\S+)/', $d, $m); |
| 264 | 264 | if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) { |
| 265 | - coordonnees_erreur($this, " <p><b>" . $m[1] . "</b> " |
|
| 265 | + coordonnees_erreur($this, " <p><b>".$m[1]."</b> " |
|
| 266 | 266 | . _T('zxml_nonvide_balise') // message a affiner |
| 267 | 267 | ); |
| 268 | 268 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | public function phraserTout($phraseur, $data) { |
| 310 | 310 | xml_parsestring($this, $data); |
| 311 | 311 | |
| 312 | - if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) { |
|
| 312 | + if (!$this->dtc or preg_match(',^'._MESSAGE_DOCTYPE.',', $data)) { |
|
| 313 | 313 | $this->err[] = array('DOCTYPE ?', 0, 0); |
| 314 | 314 | } else { |
| 315 | 315 | $this->valider_passe2($this); |
@@ -1472,10 +1472,12 @@ discard block |
||
| 1472 | 1472 | if ($crit->cond) { |
| 1473 | 1473 | $pred = calculer_argument_precedent($idb, $col, $boucles); |
| 1474 | 1474 | $where = array("'?'", $pred, $where, "''"); |
| 1475 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1475 | + if ($where_complement) { |
|
| 1476 | + // condition annexe du type "AND (objet='article')" |
|
| 1476 | 1477 | { |
| 1477 | 1478 | $where_complement = array("'?'", $pred, $where_complement, "''"); |
| 1478 | 1479 | } |
| 1480 | + } |
|
| 1479 | 1481 | } |
| 1480 | 1482 | if ($crit->exclus) { |
| 1481 | 1483 | if (!preg_match(",^L[0-9]+[.],", $arg)) { |
@@ -1496,10 +1498,12 @@ discard block |
||
| 1496 | 1498 | } |
| 1497 | 1499 | |
| 1498 | 1500 | $boucles[$idb]->where[] = $where; |
| 1499 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1501 | + if ($where_complement) { |
|
| 1502 | + // condition annexe du type "AND (objet='article')" |
|
| 1500 | 1503 | { |
| 1501 | 1504 | $boucles[$idb]->where[] = $where_complement; |
| 1502 | 1505 | } |
| 1506 | + } |
|
| 1503 | 1507 | } |
| 1504 | 1508 | |
| 1505 | 1509 | // https://code.spip.net/@critere_IN_cas |
@@ -1892,17 +1896,21 @@ discard block |
||
| 1892 | 1896 | ); |
| 1893 | 1897 | } |
| 1894 | 1898 | $where = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where); |
| 1895 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1899 | + if ($where_complement) { |
|
| 1900 | + // condition annexe du type "AND (objet='article')" |
|
| 1896 | 1901 | { |
| 1897 | 1902 | $where_complement = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where_complement); |
| 1898 | 1903 | } |
| 1904 | + } |
|
| 1899 | 1905 | } |
| 1900 | 1906 | |
| 1901 | 1907 | $boucles[$idb]->where[] = $where; |
| 1902 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1908 | + if ($where_complement) { |
|
| 1909 | + // condition annexe du type "AND (objet='article')" |
|
| 1903 | 1910 | { |
| 1904 | 1911 | $boucles[$idb]->where[] = $where_complement; |
| 1905 | 1912 | } |
| 1913 | + } |
|
| 1906 | 1914 | } |
| 1907 | 1915 | |
| 1908 | 1916 | |
@@ -2013,8 +2021,7 @@ discard block |
||
| 2013 | 2021 | // Champ joker * des iterateurs DATA qui accepte tout |
| 2014 | 2022 | if (@array_key_exists('*', $desc['field'])) { |
| 2015 | 2023 | $desc['field'][$col_vraie ? $col_vraie : $col] = ''; // on veut pas de cast INT par defaut car le type peut etre n'importe quoi dans les boucles DATA |
| 2016 | - } |
|
| 2017 | - else { |
|
| 2024 | + } else { |
|
| 2018 | 2025 | $r = calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table); |
| 2019 | 2026 | if (!$r) { |
| 2020 | 2027 | return ''; |
@@ -2056,8 +2063,7 @@ discard block |
||
| 2056 | 2063 | . ((isset($r[2]) and $r[2]) ? $r[2] : ",''") |
| 2057 | 2064 | . ",'" . addslashes($type_cast_quote) . "'"; |
| 2058 | 2065 | $val[0] = "sql_quote($r)"; |
| 2059 | - } |
|
| 2060 | - elseif(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2066 | + } elseif(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2061 | 2067 | and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
| 2062 | 2068 | $val[0] = substr($val[0], 0, -strlen($r[0])) . "'" . addslashes($type_cast_quote) . "')"; |
| 2063 | 2069 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | **/ |
| 44 | 44 | function critere_racine_dist($idb, &$boucles, $crit) { |
| 45 | 45 | |
| 46 | - $not = $crit->not; |
|
| 47 | - $boucle = &$boucles[$idb]; |
|
| 48 | - $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
|
| 49 | - $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 50 | - 'id_parent'; |
|
| 46 | + $not = $crit->not; |
|
| 47 | + $boucle = &$boucles[$idb]; |
|
| 48 | + $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
|
| 49 | + $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 50 | + 'id_parent'; |
|
| 51 | 51 | |
| 52 | - $c = array("'='", "'$boucle->id_table." . "$id_parent'", 0); |
|
| 53 | - $boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c); |
|
| 52 | + $c = array("'='", "'$boucle->id_table." . "$id_parent'", 0); |
|
| 53 | + $boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | * @return void |
| 68 | 68 | **/ |
| 69 | 69 | function critere_exclus_dist($idb, &$boucles, $crit) { |
| 70 | - $not = $crit->not; |
|
| 71 | - $boucle = &$boucles[$idb]; |
|
| 72 | - $id = $boucle->primary; |
|
| 73 | - |
|
| 74 | - if ($not or !$id) { |
|
| 75 | - return (array('zbug_critere_inconnu', array('critere' => $not . $crit->op))); |
|
| 76 | - } |
|
| 77 | - $arg = kwote(calculer_argument_precedent($idb, $id, $boucles)); |
|
| 78 | - $boucle->where[] = array("'!='", "'$boucle->id_table." . "$id'", $arg); |
|
| 70 | + $not = $crit->not; |
|
| 71 | + $boucle = &$boucles[$idb]; |
|
| 72 | + $id = $boucle->primary; |
|
| 73 | + |
|
| 74 | + if ($not or !$id) { |
|
| 75 | + return (array('zbug_critere_inconnu', array('critere' => $not . $crit->op))); |
|
| 76 | + } |
|
| 77 | + $arg = kwote(calculer_argument_precedent($idb, $id, $boucles)); |
|
| 78 | + $boucle->where[] = array("'!='", "'$boucle->id_table." . "$id'", $arg); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -95,73 +95,73 @@ discard block |
||
| 95 | 95 | * @return void |
| 96 | 96 | **/ |
| 97 | 97 | function critere_doublons_dist($idb, &$boucles, $crit) { |
| 98 | - $boucle = &$boucles[$idb]; |
|
| 99 | - $primary = $boucle->primary; |
|
| 100 | - |
|
| 101 | - // la table nécessite une clé primaire, non composée |
|
| 102 | - if (!$primary or strpos($primary, ',')) { |
|
| 103 | - return (array('zbug_doublon_sur_table_sans_cle_primaire')); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $not = ($crit->not ? '' : 'NOT'); |
|
| 107 | - |
|
| 108 | - // le doublon s'applique sur un type de boucle (article) |
|
| 109 | - $nom = "'" . $boucle->type_requete . "'"; |
|
| 110 | - |
|
| 111 | - // compléter le nom avec un nom précisé {doublons nom} |
|
| 112 | - // on obtient $nom = "'article' . 'nom'" |
|
| 113 | - if (isset($crit->param[0])) { |
|
| 114 | - $nom .= "." . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // code qui déclarera l'index du stockage de nos doublons (pour éviter une notice PHP) |
|
| 118 | - $init_comment = "\n\n\t// Initialise le(s) critère(s) doublons\n"; |
|
| 119 | - $init_code = "\tif (!isset(\$doublons[\$d = $nom])) { \$doublons[\$d] = ''; }\n"; |
|
| 120 | - |
|
| 121 | - // on crée un sql_in avec la clé primaire de la table |
|
| 122 | - // et la collection des doublons déjà emmagasinés dans le tableau |
|
| 123 | - // $doublons et son index, ici $nom |
|
| 124 | - |
|
| 125 | - // debut du code "sql_in('articles.id_article', " |
|
| 126 | - $debut_in = "sql_in('" . $boucle->id_table . '.' . $primary . "', "; |
|
| 127 | - // lecture des données du doublon "$doublons[$doublon_index[] = " |
|
| 128 | - // Attention : boucle->doublons désigne une variable qu'on affecte |
|
| 129 | - $debut_doub = '$doublons[' . (!$not ? '' : ($boucle->doublons . "[]= ")); |
|
| 130 | - |
|
| 131 | - // le debut complet du code des doublons |
|
| 132 | - $debut_doub = $debut_in . $debut_doub; |
|
| 133 | - |
|
| 134 | - // nom du doublon "('article' . 'nom')]" |
|
| 135 | - $fin_doub = "($nom)]"; |
|
| 136 | - |
|
| 137 | - // si on trouve un autre critère doublon, |
|
| 138 | - // on fusionne pour avoir un seul IN, et on s'en va ! |
|
| 139 | - foreach ($boucle->where as $k => $w) { |
|
| 140 | - if (strpos($w[0], $debut_doub) === 0) { |
|
| 141 | - // fusionner le sql_in (du where) |
|
| 142 | - $boucle->where[$k][0] = $debut_doub . $fin_doub . ' . ' . substr($w[0], strlen($debut_in)); |
|
| 143 | - // fusionner l'initialisation (du hash) pour faire plus joli |
|
| 144 | - $x = strpos($boucle->hash, $init_comment); |
|
| 145 | - $len = strlen($init_comment); |
|
| 146 | - $boucle->hash = |
|
| 147 | - substr($boucle->hash, 0, $x + $len) . $init_code . substr($boucle->hash, $x + $len); |
|
| 148 | - |
|
| 149 | - return; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // mettre l'ensemble dans un tableau pour que ce ne soit pas vu comme une constante |
|
| 154 | - $boucle->where[] = array($debut_doub . $fin_doub . ", '" . $not . "')"); |
|
| 155 | - |
|
| 156 | - // déclarer le doublon s'il n'existe pas encore |
|
| 157 | - $boucle->hash .= $init_comment . $init_code; |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - # la ligne suivante avait l'intention d'eviter une collecte deja faite |
|
| 161 | - # mais elle fait planter une boucle a 2 critere doublons: |
|
| 162 | - # {!doublons A}{doublons B} |
|
| 163 | - # (de http://article.gmane.org/gmane.comp.web.spip.devel/31034) |
|
| 164 | - # if ($crit->not) $boucle->doublons = ""; |
|
| 98 | + $boucle = &$boucles[$idb]; |
|
| 99 | + $primary = $boucle->primary; |
|
| 100 | + |
|
| 101 | + // la table nécessite une clé primaire, non composée |
|
| 102 | + if (!$primary or strpos($primary, ',')) { |
|
| 103 | + return (array('zbug_doublon_sur_table_sans_cle_primaire')); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $not = ($crit->not ? '' : 'NOT'); |
|
| 107 | + |
|
| 108 | + // le doublon s'applique sur un type de boucle (article) |
|
| 109 | + $nom = "'" . $boucle->type_requete . "'"; |
|
| 110 | + |
|
| 111 | + // compléter le nom avec un nom précisé {doublons nom} |
|
| 112 | + // on obtient $nom = "'article' . 'nom'" |
|
| 113 | + if (isset($crit->param[0])) { |
|
| 114 | + $nom .= "." . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // code qui déclarera l'index du stockage de nos doublons (pour éviter une notice PHP) |
|
| 118 | + $init_comment = "\n\n\t// Initialise le(s) critère(s) doublons\n"; |
|
| 119 | + $init_code = "\tif (!isset(\$doublons[\$d = $nom])) { \$doublons[\$d] = ''; }\n"; |
|
| 120 | + |
|
| 121 | + // on crée un sql_in avec la clé primaire de la table |
|
| 122 | + // et la collection des doublons déjà emmagasinés dans le tableau |
|
| 123 | + // $doublons et son index, ici $nom |
|
| 124 | + |
|
| 125 | + // debut du code "sql_in('articles.id_article', " |
|
| 126 | + $debut_in = "sql_in('" . $boucle->id_table . '.' . $primary . "', "; |
|
| 127 | + // lecture des données du doublon "$doublons[$doublon_index[] = " |
|
| 128 | + // Attention : boucle->doublons désigne une variable qu'on affecte |
|
| 129 | + $debut_doub = '$doublons[' . (!$not ? '' : ($boucle->doublons . "[]= ")); |
|
| 130 | + |
|
| 131 | + // le debut complet du code des doublons |
|
| 132 | + $debut_doub = $debut_in . $debut_doub; |
|
| 133 | + |
|
| 134 | + // nom du doublon "('article' . 'nom')]" |
|
| 135 | + $fin_doub = "($nom)]"; |
|
| 136 | + |
|
| 137 | + // si on trouve un autre critère doublon, |
|
| 138 | + // on fusionne pour avoir un seul IN, et on s'en va ! |
|
| 139 | + foreach ($boucle->where as $k => $w) { |
|
| 140 | + if (strpos($w[0], $debut_doub) === 0) { |
|
| 141 | + // fusionner le sql_in (du where) |
|
| 142 | + $boucle->where[$k][0] = $debut_doub . $fin_doub . ' . ' . substr($w[0], strlen($debut_in)); |
|
| 143 | + // fusionner l'initialisation (du hash) pour faire plus joli |
|
| 144 | + $x = strpos($boucle->hash, $init_comment); |
|
| 145 | + $len = strlen($init_comment); |
|
| 146 | + $boucle->hash = |
|
| 147 | + substr($boucle->hash, 0, $x + $len) . $init_code . substr($boucle->hash, $x + $len); |
|
| 148 | + |
|
| 149 | + return; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // mettre l'ensemble dans un tableau pour que ce ne soit pas vu comme une constante |
|
| 154 | + $boucle->where[] = array($debut_doub . $fin_doub . ", '" . $not . "')"); |
|
| 155 | + |
|
| 156 | + // déclarer le doublon s'il n'existe pas encore |
|
| 157 | + $boucle->hash .= $init_comment . $init_code; |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + # la ligne suivante avait l'intention d'eviter une collecte deja faite |
|
| 161 | + # mais elle fait planter une boucle a 2 critere doublons: |
|
| 162 | + # {!doublons A}{doublons B} |
|
| 163 | + # (de http://article.gmane.org/gmane.comp.web.spip.devel/31034) |
|
| 164 | + # if ($crit->not) $boucle->doublons = ""; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -182,14 +182,14 @@ discard block |
||
| 182 | 182 | * @return void |
| 183 | 183 | **/ |
| 184 | 184 | function critere_lang_select_dist($idb, &$boucles, $crit) { |
| 185 | - if (!isset($crit->param[1][0]) or !($param = $crit->param[1][0]->texte)) { |
|
| 186 | - $param = 'oui'; |
|
| 187 | - } |
|
| 188 | - if ($crit->not) { |
|
| 189 | - $param = ($param == 'oui') ? 'non' : 'oui'; |
|
| 190 | - } |
|
| 191 | - $boucle = &$boucles[$idb]; |
|
| 192 | - $boucle->lang_select = $param; |
|
| 185 | + if (!isset($crit->param[1][0]) or !($param = $crit->param[1][0]->texte)) { |
|
| 186 | + $param = 'oui'; |
|
| 187 | + } |
|
| 188 | + if ($crit->not) { |
|
| 189 | + $param = ($param == 'oui') ? 'non' : 'oui'; |
|
| 190 | + } |
|
| 191 | + $boucle = &$boucles[$idb]; |
|
| 192 | + $boucle->lang_select = $param; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -211,18 +211,18 @@ discard block |
||
| 211 | 211 | * @return void |
| 212 | 212 | **/ |
| 213 | 213 | function critere_debut_dist($idb, &$boucles, $crit) { |
| 214 | - list($un, $deux) = $crit->param; |
|
| 215 | - $un = $un[0]->texte; |
|
| 216 | - $deux = $deux[0]->texte; |
|
| 217 | - if ($deux) { |
|
| 218 | - $boucles[$idb]->limit = 'intval($Pile[0]["debut' . |
|
| 219 | - $un . |
|
| 220 | - '"]) . ",' . |
|
| 221 | - $deux . |
|
| 222 | - '"'; |
|
| 223 | - } else { |
|
| 224 | - calculer_critere_DEFAUT_dist($idb, $boucles, $crit); |
|
| 225 | - } |
|
| 214 | + list($un, $deux) = $crit->param; |
|
| 215 | + $un = $un[0]->texte; |
|
| 216 | + $deux = $deux[0]->texte; |
|
| 217 | + if ($deux) { |
|
| 218 | + $boucles[$idb]->limit = 'intval($Pile[0]["debut' . |
|
| 219 | + $un . |
|
| 220 | + '"]) . ",' . |
|
| 221 | + $deux . |
|
| 222 | + '"'; |
|
| 223 | + } else { |
|
| 224 | + calculer_critere_DEFAUT_dist($idb, $boucles, $crit); |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
@@ -256,57 +256,57 @@ discard block |
||
| 256 | 256 | **/ |
| 257 | 257 | function critere_pagination_dist($idb, &$boucles, $crit) { |
| 258 | 258 | |
| 259 | - $boucle = &$boucles[$idb]; |
|
| 260 | - // definition de la taille de la page |
|
| 261 | - $pas = !isset($crit->param[0][0]) ? "''" |
|
| 262 | - : calculer_liste(array($crit->param[0][0]), $idb, $boucles, $boucle->id_parent); |
|
| 263 | - |
|
| 264 | - if (!preg_match(_CODE_QUOTE, $pas, $r)) { |
|
| 265 | - $pas = "((\$a = intval($pas)) ? \$a : 10)"; |
|
| 266 | - } else { |
|
| 267 | - $r = intval($r[2]); |
|
| 268 | - $pas = strval($r ? $r : 10); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - // Calcul du nommage de la pagination si il existe. |
|
| 272 | - // La nouvelle syntaxe {pagination 20, nom} est prise en compte et privilégiée mais on reste |
|
| 273 | - // compatible avec l'ancienne car certains cas fonctionnent correctement |
|
| 274 | - $type = "'$idb'"; |
|
| 275 | - // Calcul d'un nommage spécifique de la pagination si précisé. |
|
| 276 | - // Syntaxe {pagination 20, nom} |
|
| 277 | - if (isset($crit->param[0][1])) { |
|
| 278 | - $type = calculer_liste(array($crit->param[0][1]), $idb, $boucles, $boucle->id_parent); |
|
| 279 | - } // Ancienne syntaxe {pagination 20 nom} pour compatibilité |
|
| 280 | - elseif (isset($crit->param[1][0])) { |
|
| 281 | - $type = calculer_liste(array($crit->param[1][0]), $idb, $boucles, $boucle->id_parent); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - $debut = ($type[0] !== "'") ? "'debut'.$type" : ("'debut" . substr($type, 1)); |
|
| 285 | - $boucle->modificateur['debut_nom'] = $type; |
|
| 286 | - $partie = |
|
| 287 | - // tester si le numero de page demande est de la forme '@yyy' |
|
| 288 | - 'isset($Pile[0][' . $debut . ']) ? $Pile[0][' . $debut . '] : _request(' . $debut . ");\n" |
|
| 289 | - . "\tif(substr(\$debut_boucle,0,1)=='@'){\n" |
|
| 290 | - . "\t\t" . '$debut_boucle = $Pile[0][' . $debut . '] = quete_debut_pagination(\'' . $boucle->primary . '\',$Pile[0][\'@' . $boucle->primary . '\'] = substr($debut_boucle,1),' . $pas . ',$iter);' . "\n" |
|
| 291 | - . "\t\t" . '$iter->seek(0);' . "\n" |
|
| 292 | - . "\t}\n" |
|
| 293 | - . "\t" . '$debut_boucle = intval($debut_boucle)'; |
|
| 294 | - |
|
| 295 | - $boucle->hash .= ' |
|
| 259 | + $boucle = &$boucles[$idb]; |
|
| 260 | + // definition de la taille de la page |
|
| 261 | + $pas = !isset($crit->param[0][0]) ? "''" |
|
| 262 | + : calculer_liste(array($crit->param[0][0]), $idb, $boucles, $boucle->id_parent); |
|
| 263 | + |
|
| 264 | + if (!preg_match(_CODE_QUOTE, $pas, $r)) { |
|
| 265 | + $pas = "((\$a = intval($pas)) ? \$a : 10)"; |
|
| 266 | + } else { |
|
| 267 | + $r = intval($r[2]); |
|
| 268 | + $pas = strval($r ? $r : 10); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + // Calcul du nommage de la pagination si il existe. |
|
| 272 | + // La nouvelle syntaxe {pagination 20, nom} est prise en compte et privilégiée mais on reste |
|
| 273 | + // compatible avec l'ancienne car certains cas fonctionnent correctement |
|
| 274 | + $type = "'$idb'"; |
|
| 275 | + // Calcul d'un nommage spécifique de la pagination si précisé. |
|
| 276 | + // Syntaxe {pagination 20, nom} |
|
| 277 | + if (isset($crit->param[0][1])) { |
|
| 278 | + $type = calculer_liste(array($crit->param[0][1]), $idb, $boucles, $boucle->id_parent); |
|
| 279 | + } // Ancienne syntaxe {pagination 20 nom} pour compatibilité |
|
| 280 | + elseif (isset($crit->param[1][0])) { |
|
| 281 | + $type = calculer_liste(array($crit->param[1][0]), $idb, $boucles, $boucle->id_parent); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + $debut = ($type[0] !== "'") ? "'debut'.$type" : ("'debut" . substr($type, 1)); |
|
| 285 | + $boucle->modificateur['debut_nom'] = $type; |
|
| 286 | + $partie = |
|
| 287 | + // tester si le numero de page demande est de la forme '@yyy' |
|
| 288 | + 'isset($Pile[0][' . $debut . ']) ? $Pile[0][' . $debut . '] : _request(' . $debut . ");\n" |
|
| 289 | + . "\tif(substr(\$debut_boucle,0,1)=='@'){\n" |
|
| 290 | + . "\t\t" . '$debut_boucle = $Pile[0][' . $debut . '] = quete_debut_pagination(\'' . $boucle->primary . '\',$Pile[0][\'@' . $boucle->primary . '\'] = substr($debut_boucle,1),' . $pas . ',$iter);' . "\n" |
|
| 291 | + . "\t\t" . '$iter->seek(0);' . "\n" |
|
| 292 | + . "\t}\n" |
|
| 293 | + . "\t" . '$debut_boucle = intval($debut_boucle)'; |
|
| 294 | + |
|
| 295 | + $boucle->hash .= ' |
|
| 296 | 296 | $command[\'pagination\'] = array((isset($Pile[0][' . $debut . ']) ? $Pile[0][' . $debut . '] : null), ' . $pas . ');'; |
| 297 | 297 | |
| 298 | - $boucle->total_parties = $pas; |
|
| 299 | - calculer_parties($boucles, $idb, $partie, 'p+'); |
|
| 300 | - // ajouter la cle primaire dans le select pour pouvoir gerer la pagination referencee par @id |
|
| 301 | - // sauf si pas de primaire, ou si primaire composee |
|
| 302 | - // dans ce cas, on ne sait pas gerer une pagination indirecte |
|
| 303 | - $t = $boucle->id_table . '.' . $boucle->primary; |
|
| 304 | - if ($boucle->primary |
|
| 305 | - and !preg_match('/[,\s]/', $boucle->primary) |
|
| 306 | - and !in_array($t, $boucle->select) |
|
| 307 | - ) { |
|
| 308 | - $boucle->select[] = $t; |
|
| 309 | - } |
|
| 298 | + $boucle->total_parties = $pas; |
|
| 299 | + calculer_parties($boucles, $idb, $partie, 'p+'); |
|
| 300 | + // ajouter la cle primaire dans le select pour pouvoir gerer la pagination referencee par @id |
|
| 301 | + // sauf si pas de primaire, ou si primaire composee |
|
| 302 | + // dans ce cas, on ne sait pas gerer une pagination indirecte |
|
| 303 | + $t = $boucle->id_table . '.' . $boucle->primary; |
|
| 304 | + if ($boucle->primary |
|
| 305 | + and !preg_match('/[,\s]/', $boucle->primary) |
|
| 306 | + and !in_array($t, $boucle->select) |
|
| 307 | + ) { |
|
| 308 | + $boucle->select[] = $t; |
|
| 309 | + } |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | |
@@ -328,24 +328,24 @@ discard block |
||
| 328 | 328 | **/ |
| 329 | 329 | function critere_recherche_dist($idb, &$boucles, $crit) { |
| 330 | 330 | |
| 331 | - $boucle = &$boucles[$idb]; |
|
| 331 | + $boucle = &$boucles[$idb]; |
|
| 332 | 332 | |
| 333 | - if (!$boucle->primary or strpos($boucle->primary, ',')) { |
|
| 334 | - erreur_squelette(_T('zbug_critere_sur_table_sans_cle_primaire', array('critere' => 'recherche')), $boucle); |
|
| 333 | + if (!$boucle->primary or strpos($boucle->primary, ',')) { |
|
| 334 | + erreur_squelette(_T('zbug_critere_sur_table_sans_cle_primaire', array('critere' => 'recherche')), $boucle); |
|
| 335 | 335 | |
| 336 | - return; |
|
| 337 | - } |
|
| 336 | + return; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - if (isset($crit->param[0])) { |
|
| 340 | - $quoi = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 341 | - } else { |
|
| 342 | - $quoi = '(isset($Pile[0]["recherche"])?$Pile[0]["recherche"]:(isset($GLOBALS["recherche"])?$GLOBALS["recherche"]:""))'; |
|
| 343 | - } |
|
| 339 | + if (isset($crit->param[0])) { |
|
| 340 | + $quoi = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 341 | + } else { |
|
| 342 | + $quoi = '(isset($Pile[0]["recherche"])?$Pile[0]["recherche"]:(isset($GLOBALS["recherche"])?$GLOBALS["recherche"]:""))'; |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - $_modificateur = var_export($boucle->modificateur, true); |
|
| 346 | - $boucle->hash .= ' |
|
| 345 | + $_modificateur = var_export($boucle->modificateur, true); |
|
| 346 | + $boucle->hash .= ' |
|
| 347 | 347 | // RECHERCHE' |
| 348 | - . ($crit->cond ? ' |
|
| 348 | + . ($crit->cond ? ' |
|
| 349 | 349 | if (!strlen(' . $quoi . ')){ |
| 350 | 350 | list($rech_select, $rech_where) = array("0 as points",""); |
| 351 | 351 | } else' : '') . ' |
@@ -356,21 +356,21 @@ discard block |
||
| 356 | 356 | '; |
| 357 | 357 | |
| 358 | 358 | |
| 359 | - $t = $boucle->id_table . '.' . $boucle->primary; |
|
| 360 | - if (!in_array($t, $boucles[$idb]->select)) { |
|
| 361 | - $boucle->select[] = $t; |
|
| 362 | - } # pour postgres, neuneu ici |
|
| 363 | - // jointure uniquement sur le serveur principal |
|
| 364 | - // (on ne peut joindre une table d'un serveur distant avec la table des resultats du serveur principal) |
|
| 365 | - if (!$boucle->sql_serveur) { |
|
| 366 | - $boucle->join['resultats'] = array("'" . $boucle->id_table . "'", "'id'", "'" . $boucle->primary . "'"); |
|
| 367 | - $boucle->from['resultats'] = 'spip_resultats'; |
|
| 368 | - } |
|
| 369 | - $boucle->select[] = '$rech_select'; |
|
| 370 | - //$boucle->where[]= "\$rech_where?'resultats.id=".$boucle->id_table.".".$boucle->primary."':''"; |
|
| 371 | - |
|
| 372 | - // et la recherche trouve |
|
| 373 | - $boucle->where[] = '$rech_where?$rech_where:\'\''; |
|
| 359 | + $t = $boucle->id_table . '.' . $boucle->primary; |
|
| 360 | + if (!in_array($t, $boucles[$idb]->select)) { |
|
| 361 | + $boucle->select[] = $t; |
|
| 362 | + } # pour postgres, neuneu ici |
|
| 363 | + // jointure uniquement sur le serveur principal |
|
| 364 | + // (on ne peut joindre une table d'un serveur distant avec la table des resultats du serveur principal) |
|
| 365 | + if (!$boucle->sql_serveur) { |
|
| 366 | + $boucle->join['resultats'] = array("'" . $boucle->id_table . "'", "'id'", "'" . $boucle->primary . "'"); |
|
| 367 | + $boucle->from['resultats'] = 'spip_resultats'; |
|
| 368 | + } |
|
| 369 | + $boucle->select[] = '$rech_select'; |
|
| 370 | + //$boucle->where[]= "\$rech_where?'resultats.id=".$boucle->id_table.".".$boucle->primary."':''"; |
|
| 371 | + |
|
| 372 | + // et la recherche trouve |
|
| 373 | + $boucle->where[] = '$rech_where?$rech_where:\'\''; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -387,25 +387,25 @@ discard block |
||
| 387 | 387 | * @return void |
| 388 | 388 | **/ |
| 389 | 389 | function critere_traduction_dist($idb, &$boucles, $crit) { |
| 390 | - $boucle = &$boucles[$idb]; |
|
| 391 | - $prim = $boucle->primary; |
|
| 392 | - $table = $boucle->id_table; |
|
| 393 | - $arg = kwote(calculer_argument_precedent($idb, 'id_trad', $boucles)); |
|
| 394 | - $dprim = kwote(calculer_argument_precedent($idb, $prim, $boucles)); |
|
| 395 | - $boucle->where[] = |
|
| 396 | - array( |
|
| 397 | - "'OR'", |
|
| 398 | - array( |
|
| 399 | - "'AND'", |
|
| 400 | - array("'='", "'$table.id_trad'", 0), |
|
| 401 | - array("'='", "'$table.$prim'", $dprim) |
|
| 402 | - ), |
|
| 403 | - array( |
|
| 404 | - "'AND'", |
|
| 405 | - array("'>'", "'$table.id_trad'", 0), |
|
| 406 | - array("'='", "'$table.id_trad'", $arg) |
|
| 407 | - ) |
|
| 408 | - ); |
|
| 390 | + $boucle = &$boucles[$idb]; |
|
| 391 | + $prim = $boucle->primary; |
|
| 392 | + $table = $boucle->id_table; |
|
| 393 | + $arg = kwote(calculer_argument_precedent($idb, 'id_trad', $boucles)); |
|
| 394 | + $dprim = kwote(calculer_argument_precedent($idb, $prim, $boucles)); |
|
| 395 | + $boucle->where[] = |
|
| 396 | + array( |
|
| 397 | + "'OR'", |
|
| 398 | + array( |
|
| 399 | + "'AND'", |
|
| 400 | + array("'='", "'$table.id_trad'", 0), |
|
| 401 | + array("'='", "'$table.$prim'", $dprim) |
|
| 402 | + ), |
|
| 403 | + array( |
|
| 404 | + "'AND'", |
|
| 405 | + array("'>'", "'$table.id_trad'", 0), |
|
| 406 | + array("'='", "'$table.id_trad'", $arg) |
|
| 407 | + ) |
|
| 408 | + ); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -423,17 +423,17 @@ discard block |
||
| 423 | 423 | * @return void |
| 424 | 424 | **/ |
| 425 | 425 | function critere_origine_traduction_dist($idb, &$boucles, $crit) { |
| 426 | - $boucle = &$boucles[$idb]; |
|
| 427 | - $prim = $boucle->primary; |
|
| 428 | - $table = $boucle->id_table; |
|
| 429 | - |
|
| 430 | - $c = |
|
| 431 | - array( |
|
| 432 | - "'OR'", |
|
| 433 | - array("'='", "'$table." . "id_trad'", "'$table.$prim'"), |
|
| 434 | - array("'='", "'$table.id_trad'", "'0'") |
|
| 435 | - ); |
|
| 436 | - $boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c); |
|
| 426 | + $boucle = &$boucles[$idb]; |
|
| 427 | + $prim = $boucle->primary; |
|
| 428 | + $table = $boucle->id_table; |
|
| 429 | + |
|
| 430 | + $c = |
|
| 431 | + array( |
|
| 432 | + "'OR'", |
|
| 433 | + array("'='", "'$table." . "id_trad'", "'$table.$prim'"), |
|
| 434 | + array("'='", "'$table.id_trad'", "'0'") |
|
| 435 | + ); |
|
| 436 | + $boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | |
@@ -450,20 +450,20 @@ discard block |
||
| 450 | 450 | **/ |
| 451 | 451 | function critere_meme_parent_dist($idb, &$boucles, $crit) { |
| 452 | 452 | |
| 453 | - $boucle = &$boucles[$idb]; |
|
| 454 | - $arg = kwote(calculer_argument_precedent($idb, 'id_parent', $boucles)); |
|
| 455 | - $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
|
| 456 | - $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 457 | - 'id_parent'; |
|
| 458 | - $mparent = $boucle->id_table . '.' . $id_parent; |
|
| 453 | + $boucle = &$boucles[$idb]; |
|
| 454 | + $arg = kwote(calculer_argument_precedent($idb, 'id_parent', $boucles)); |
|
| 455 | + $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
|
| 456 | + $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 457 | + 'id_parent'; |
|
| 458 | + $mparent = $boucle->id_table . '.' . $id_parent; |
|
| 459 | 459 | |
| 460 | - if ($boucle->type_requete == 'rubriques' or isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'])) { |
|
| 461 | - $boucle->where[] = array("'='", "'$mparent'", $arg); |
|
| 460 | + if ($boucle->type_requete == 'rubriques' or isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'])) { |
|
| 461 | + $boucle->where[] = array("'='", "'$mparent'", $arg); |
|
| 462 | 462 | |
| 463 | - } // le cas FORUMS est gere dans le plugin forum, dans la fonction critere_FORUMS_meme_parent_dist() |
|
| 464 | - else { |
|
| 465 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . ' ' . $boucle->type_requete))); |
|
| 466 | - } |
|
| 463 | + } // le cas FORUMS est gere dans le plugin forum, dans la fonction critere_FORUMS_meme_parent_dist() |
|
| 464 | + else { |
|
| 465 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op . ' ' . $boucle->type_requete))); |
|
| 466 | + } |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | |
@@ -494,37 +494,37 @@ discard block |
||
| 494 | 494 | **/ |
| 495 | 495 | function critere_branche_dist($idb, &$boucles, $crit) { |
| 496 | 496 | |
| 497 | - $not = $crit->not; |
|
| 498 | - $boucle = &$boucles[$idb]; |
|
| 499 | - // prendre en priorite un identifiant en parametre {branche XX} |
|
| 500 | - if (isset($crit->param[0])) { |
|
| 501 | - $arg = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 502 | - // sinon on le prend chez une boucle parente |
|
| 503 | - } else { |
|
| 504 | - $arg = kwote(calculer_argument_precedent($idb, 'id_rubrique', $boucles), $boucle->sql_serveur, 'int NOT NULL'); |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - //Trouver une jointure |
|
| 508 | - $champ = "id_rubrique"; |
|
| 509 | - $desc = $boucle->show; |
|
| 510 | - //Seulement si necessaire |
|
| 511 | - if (!array_key_exists($champ, $desc['field'])) { |
|
| 512 | - $cle = trouver_jointure_champ($champ, $boucle); |
|
| 513 | - $trouver_table = charger_fonction("trouver_table", "base"); |
|
| 514 | - $desc = $trouver_table($boucle->from[$cle]); |
|
| 515 | - if (count(trouver_champs_decomposes($champ, $desc)) > 1) { |
|
| 516 | - $decompose = decompose_champ_id_objet($champ); |
|
| 517 | - $champ = array_shift($decompose); |
|
| 518 | - $boucle->where[] = array("'='", _q($cle . "." . reset($decompose)), '"' . sql_quote(end($decompose)) . '"'); |
|
| 519 | - } |
|
| 520 | - } else { |
|
| 521 | - $cle = $boucle->id_table; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - $c = "sql_in('$cle" . ".$champ', calcul_branche_in($arg)" |
|
| 525 | - . ($not ? ", 'NOT'" : '') . ")"; |
|
| 526 | - $boucle->where[] = !$crit->cond ? $c : |
|
| 527 | - ("($arg ? $c : " . ($not ? "'0=1'" : "'1=1'") . ')'); |
|
| 497 | + $not = $crit->not; |
|
| 498 | + $boucle = &$boucles[$idb]; |
|
| 499 | + // prendre en priorite un identifiant en parametre {branche XX} |
|
| 500 | + if (isset($crit->param[0])) { |
|
| 501 | + $arg = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 502 | + // sinon on le prend chez une boucle parente |
|
| 503 | + } else { |
|
| 504 | + $arg = kwote(calculer_argument_precedent($idb, 'id_rubrique', $boucles), $boucle->sql_serveur, 'int NOT NULL'); |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + //Trouver une jointure |
|
| 508 | + $champ = "id_rubrique"; |
|
| 509 | + $desc = $boucle->show; |
|
| 510 | + //Seulement si necessaire |
|
| 511 | + if (!array_key_exists($champ, $desc['field'])) { |
|
| 512 | + $cle = trouver_jointure_champ($champ, $boucle); |
|
| 513 | + $trouver_table = charger_fonction("trouver_table", "base"); |
|
| 514 | + $desc = $trouver_table($boucle->from[$cle]); |
|
| 515 | + if (count(trouver_champs_decomposes($champ, $desc)) > 1) { |
|
| 516 | + $decompose = decompose_champ_id_objet($champ); |
|
| 517 | + $champ = array_shift($decompose); |
|
| 518 | + $boucle->where[] = array("'='", _q($cle . "." . reset($decompose)), '"' . sql_quote(end($decompose)) . '"'); |
|
| 519 | + } |
|
| 520 | + } else { |
|
| 521 | + $cle = $boucle->id_table; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + $c = "sql_in('$cle" . ".$champ', calcul_branche_in($arg)" |
|
| 525 | + . ($not ? ", 'NOT'" : '') . ")"; |
|
| 526 | + $boucle->where[] = !$crit->cond ? $c : |
|
| 527 | + ("($arg ? $c : " . ($not ? "'0=1'" : "'1=1'") . ')'); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | /** |
@@ -540,15 +540,15 @@ discard block |
||
| 540 | 540 | **/ |
| 541 | 541 | function critere_logo_dist($idb, &$boucles, $crit) { |
| 542 | 542 | |
| 543 | - $boucle = &$boucles[$idb]; |
|
| 544 | - $not = ($crit->not ? 'NOT' : ''); |
|
| 545 | - $serveur = $boucle->sql_serveur; |
|
| 543 | + $boucle = &$boucles[$idb]; |
|
| 544 | + $not = ($crit->not ? 'NOT' : ''); |
|
| 545 | + $serveur = $boucle->sql_serveur; |
|
| 546 | 546 | |
| 547 | - $c = "sql_in('" . |
|
| 548 | - $boucle->id_table . '.' . $boucle->primary |
|
| 549 | - . "', lister_objets_avec_logos('" . $boucle->primary . "'), '$not', '$serveur')"; |
|
| 547 | + $c = "sql_in('" . |
|
| 548 | + $boucle->id_table . '.' . $boucle->primary |
|
| 549 | + . "', lister_objets_avec_logos('" . $boucle->primary . "'), '$not', '$serveur')"; |
|
| 550 | 550 | |
| 551 | - $boucle->where[] = $c; |
|
| 551 | + $boucle->where[] = $c; |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | |
@@ -570,31 +570,31 @@ discard block |
||
| 570 | 570 | * @return void |
| 571 | 571 | **/ |
| 572 | 572 | function critere_fusion_dist($idb, &$boucles, $crit) { |
| 573 | - if ($t = isset($crit->param[0])) { |
|
| 574 | - $t = $crit->param[0]; |
|
| 575 | - if ($t[0]->type == 'texte') { |
|
| 576 | - $t = $t[0]->texte; |
|
| 577 | - if (preg_match("/^(.*)\.(.*)$/", $t, $r)) { |
|
| 578 | - $t = table_objet_sql($r[1]); |
|
| 579 | - $t = array_search($t, $boucles[$idb]->from); |
|
| 580 | - if ($t) { |
|
| 581 | - $t .= '.' . $r[2]; |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - } else { |
|
| 585 | - $t = '".' |
|
| 586 | - . calculer_critere_arg_dynamique($idb, $boucles, $t) |
|
| 587 | - . '."'; |
|
| 588 | - } |
|
| 589 | - } |
|
| 590 | - if ($t) { |
|
| 591 | - $boucles[$idb]->group[] = $t; |
|
| 592 | - if (!in_array($t, $boucles[$idb]->select)) { |
|
| 593 | - $boucles[$idb]->select[] = $t; |
|
| 594 | - } |
|
| 595 | - } else { |
|
| 596 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . ' ?'))); |
|
| 597 | - } |
|
| 573 | + if ($t = isset($crit->param[0])) { |
|
| 574 | + $t = $crit->param[0]; |
|
| 575 | + if ($t[0]->type == 'texte') { |
|
| 576 | + $t = $t[0]->texte; |
|
| 577 | + if (preg_match("/^(.*)\.(.*)$/", $t, $r)) { |
|
| 578 | + $t = table_objet_sql($r[1]); |
|
| 579 | + $t = array_search($t, $boucles[$idb]->from); |
|
| 580 | + if ($t) { |
|
| 581 | + $t .= '.' . $r[2]; |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + } else { |
|
| 585 | + $t = '".' |
|
| 586 | + . calculer_critere_arg_dynamique($idb, $boucles, $t) |
|
| 587 | + . '."'; |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | + if ($t) { |
|
| 591 | + $boucles[$idb]->group[] = $t; |
|
| 592 | + if (!in_array($t, $boucles[$idb]->select)) { |
|
| 593 | + $boucles[$idb]->select[] = $t; |
|
| 594 | + } |
|
| 595 | + } else { |
|
| 596 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op . ' ?'))); |
|
| 597 | + } |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | * @return void |
| 615 | 615 | **/ |
| 616 | 616 | function critere_fusion_supprimer_dist($idb, &$boucles, $crit){ |
| 617 | - $boucles[$idb]->group = array(); |
|
| 617 | + $boucles[$idb]->group = array(); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
@@ -651,45 +651,45 @@ discard block |
||
| 651 | 651 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 652 | 652 | */ |
| 653 | 653 | function critere_collecte_dist($idb, &$boucles, $crit) { |
| 654 | - if (isset($crit->param[0])) { |
|
| 655 | - $_coll = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 656 | - $boucle = $boucles[$idb]; |
|
| 657 | - $boucle->modificateur['collate'] = "($_coll ?' COLLATE '.$_coll:'')"; |
|
| 658 | - $n = count($boucle->order); |
|
| 659 | - if ($n && (strpos($boucle->order[$n - 1], 'COLLATE') === false)) { |
|
| 660 | - // l'instruction COLLATE doit être placée avant ASC ou DESC |
|
| 661 | - // notamment lors de l'utilisation `{!par xxx}{collate yyy}` |
|
| 662 | - if ( |
|
| 663 | - (false !== $i = strpos($boucle->order[$n - 1], 'ASC')) |
|
| 664 | - OR (false !== $i = strpos($boucle->order[$n - 1], 'DESC')) |
|
| 665 | - ) { |
|
| 666 | - $boucle->order[$n - 1] = substr_replace($boucle->order[$n - 1], "' . " . $boucle->modificateur['collate'] . " . ' ", $i, 0); |
|
| 667 | - } else { |
|
| 668 | - $boucle->order[$n - 1] .= " . " . $boucle->modificateur['collate']; |
|
| 669 | - } |
|
| 670 | - } |
|
| 671 | - } else { |
|
| 672 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . " " . count($boucles[$idb]->order)))); |
|
| 673 | - } |
|
| 654 | + if (isset($crit->param[0])) { |
|
| 655 | + $_coll = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 656 | + $boucle = $boucles[$idb]; |
|
| 657 | + $boucle->modificateur['collate'] = "($_coll ?' COLLATE '.$_coll:'')"; |
|
| 658 | + $n = count($boucle->order); |
|
| 659 | + if ($n && (strpos($boucle->order[$n - 1], 'COLLATE') === false)) { |
|
| 660 | + // l'instruction COLLATE doit être placée avant ASC ou DESC |
|
| 661 | + // notamment lors de l'utilisation `{!par xxx}{collate yyy}` |
|
| 662 | + if ( |
|
| 663 | + (false !== $i = strpos($boucle->order[$n - 1], 'ASC')) |
|
| 664 | + OR (false !== $i = strpos($boucle->order[$n - 1], 'DESC')) |
|
| 665 | + ) { |
|
| 666 | + $boucle->order[$n - 1] = substr_replace($boucle->order[$n - 1], "' . " . $boucle->modificateur['collate'] . " . ' ", $i, 0); |
|
| 667 | + } else { |
|
| 668 | + $boucle->order[$n - 1] .= " . " . $boucle->modificateur['collate']; |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | + } else { |
|
| 672 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op . " " . count($boucles[$idb]->order)))); |
|
| 673 | + } |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // https://code.spip.net/@calculer_critere_arg_dynamique |
| 677 | 677 | function calculer_critere_arg_dynamique($idb, &$boucles, $crit, $suffix = '') { |
| 678 | - $boucle = $boucles[$idb]; |
|
| 679 | - $alt = "('" . $boucle->id_table . '.\' . $x' . $suffix . ')'; |
|
| 680 | - $var = '$champs_' . $idb; |
|
| 681 | - $desc = (strpos($boucle->in, "static $var =") !== false); |
|
| 682 | - if (!$desc) { |
|
| 683 | - $desc = $boucle->show['field']; |
|
| 684 | - $desc = implode(',', array_map('_q', array_keys($desc))); |
|
| 685 | - $boucles[$idb]->in .= "\n\tstatic $var = array(" . $desc . ");"; |
|
| 686 | - } |
|
| 687 | - if ($desc) { |
|
| 688 | - $alt = "(in_array(\$x, $var) ? $alt :(\$x$suffix))"; |
|
| 689 | - } |
|
| 690 | - $arg = calculer_liste($crit, $idb, $boucles, $boucle->id_parent); |
|
| 691 | - |
|
| 692 | - return "((\$x = preg_replace(\"/\\W/\",'', $arg)) ? $alt : '')"; |
|
| 678 | + $boucle = $boucles[$idb]; |
|
| 679 | + $alt = "('" . $boucle->id_table . '.\' . $x' . $suffix . ')'; |
|
| 680 | + $var = '$champs_' . $idb; |
|
| 681 | + $desc = (strpos($boucle->in, "static $var =") !== false); |
|
| 682 | + if (!$desc) { |
|
| 683 | + $desc = $boucle->show['field']; |
|
| 684 | + $desc = implode(',', array_map('_q', array_keys($desc))); |
|
| 685 | + $boucles[$idb]->in .= "\n\tstatic $var = array(" . $desc . ");"; |
|
| 686 | + } |
|
| 687 | + if ($desc) { |
|
| 688 | + $alt = "(in_array(\$x, $var) ? $alt :(\$x$suffix))"; |
|
| 689 | + } |
|
| 690 | + $arg = calculer_liste($crit, $idb, $boucles, $boucle->id_parent); |
|
| 691 | + |
|
| 692 | + return "((\$x = preg_replace(\"/\\W/\",'', $arg)) ? $alt : '')"; |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 729 | 729 | */ |
| 730 | 730 | function critere_par_dist($idb, &$boucles, $crit) { |
| 731 | - return critere_parinverse($idb, $boucles, $crit); |
|
| 731 | + return critere_parinverse($idb, $boucles, $crit); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | /** |
@@ -750,93 +750,93 @@ discard block |
||
| 750 | 750 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 751 | 751 | */ |
| 752 | 752 | function critere_parinverse($idb, &$boucles, $crit) { |
| 753 | - $boucle = &$boucles[$idb]; |
|
| 754 | - |
|
| 755 | - $sens = $collecte = ''; |
|
| 756 | - if ($crit->not) { |
|
| 757 | - $sens = " . ' DESC'"; |
|
| 758 | - } |
|
| 759 | - if (isset($boucle->modificateur['collate'])) { |
|
| 760 | - $collecte = ' . ' . $boucle->modificateur['collate']; |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - // Pour chaque paramètre du critère |
|
| 764 | - foreach ($crit->param as $tri) { |
|
| 765 | - $order = $fct = ''; |
|
| 766 | - // tris specifiés dynamiquement {par #ENV{tri}} |
|
| 767 | - if ($tri[0]->type != 'texte') { |
|
| 768 | - // calculer le order dynamique qui verifie les champs |
|
| 769 | - $order = calculer_critere_arg_dynamique($idb, $boucles, $tri, $sens); |
|
| 770 | - // ajouter 'hasard' comme possibilité de tri dynamique |
|
| 771 | - calculer_critere_par_hasard($idb, $boucles, $crit); |
|
| 772 | - } |
|
| 773 | - // tris textuels {par titre} |
|
| 774 | - else { |
|
| 775 | - $par = array_shift($tri); |
|
| 776 | - $par = $par->texte; |
|
| 777 | - |
|
| 778 | - // tris de la forme {par expression champ} tel que {par num titre} ou {par multi titre} |
|
| 779 | - if (preg_match(",^(\w+)[\s]+(.*)$,", $par, $m)) { |
|
| 780 | - $expression = trim($m[1]); |
|
| 781 | - $champ = trim($m[2]); |
|
| 782 | - if (function_exists($f = 'calculer_critere_par_expression_' . $expression)) { |
|
| 783 | - $order = $f($idb, $boucles, $crit, $tri, $champ); |
|
| 784 | - } else { |
|
| 785 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - // tris de la forme {par champ} ou {par FONCTION(champ)} |
|
| 789 | - } elseif (preg_match(",^" . CHAMP_SQL_PLUS_FONC . '$,is', $par, $match)) { |
|
| 790 | - // {par FONCTION(champ)} |
|
| 791 | - if (count($match) > 2) { |
|
| 792 | - $par = substr($match[2], 1, -1); |
|
| 793 | - $fct = $match[1]; |
|
| 794 | - } |
|
| 795 | - // quelques cas spécifiques {par hasard}, {par date} |
|
| 796 | - if ($par == 'hasard') { |
|
| 797 | - $order = calculer_critere_par_hasard($idb, $boucles, $crit); |
|
| 798 | - } elseif ($par == 'date' and !empty($boucle->show['date'])) { |
|
| 799 | - $order = "'" . $boucle->id_table . "." . $boucle->show['date'] . "'"; |
|
| 800 | - } else { |
|
| 801 | - // cas général {par champ}, {par table.champ}, ... |
|
| 802 | - $order = calculer_critere_par_champ($idb, $boucles, $crit, $par); |
|
| 803 | - } |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - // on ne sait pas traiter… |
|
| 807 | - else { |
|
| 808 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 809 | - } |
|
| 810 | - |
|
| 811 | - // En cas d'erreur de squelette retournée par une fonction |
|
| 812 | - if (is_array($order)) { |
|
| 813 | - return $order; |
|
| 814 | - } |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - if (preg_match('/^\'([^"]*)\'$/', $order, $m)) { |
|
| 818 | - $t = $m[1]; |
|
| 819 | - if (strpos($t, '.') and !in_array($t, $boucle->select)) { |
|
| 820 | - $boucle->select[] = $t; |
|
| 821 | - } |
|
| 822 | - } else { |
|
| 823 | - $sens = ''; |
|
| 824 | - } |
|
| 825 | - |
|
| 826 | - if ($fct) { |
|
| 827 | - if (preg_match("/^\s*'(.*)'\s*$/", $order, $r)) { |
|
| 828 | - $order = "'$fct(" . $r[1] . ")'"; |
|
| 829 | - } else { |
|
| 830 | - $order = "'$fct(' . $order . ')'"; |
|
| 831 | - } |
|
| 832 | - } |
|
| 833 | - $t = $order . $collecte . $sens; |
|
| 834 | - if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) { |
|
| 835 | - $t = $r[1] . $r[2]; |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - $boucle->order[] = $t; |
|
| 839 | - } |
|
| 753 | + $boucle = &$boucles[$idb]; |
|
| 754 | + |
|
| 755 | + $sens = $collecte = ''; |
|
| 756 | + if ($crit->not) { |
|
| 757 | + $sens = " . ' DESC'"; |
|
| 758 | + } |
|
| 759 | + if (isset($boucle->modificateur['collate'])) { |
|
| 760 | + $collecte = ' . ' . $boucle->modificateur['collate']; |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + // Pour chaque paramètre du critère |
|
| 764 | + foreach ($crit->param as $tri) { |
|
| 765 | + $order = $fct = ''; |
|
| 766 | + // tris specifiés dynamiquement {par #ENV{tri}} |
|
| 767 | + if ($tri[0]->type != 'texte') { |
|
| 768 | + // calculer le order dynamique qui verifie les champs |
|
| 769 | + $order = calculer_critere_arg_dynamique($idb, $boucles, $tri, $sens); |
|
| 770 | + // ajouter 'hasard' comme possibilité de tri dynamique |
|
| 771 | + calculer_critere_par_hasard($idb, $boucles, $crit); |
|
| 772 | + } |
|
| 773 | + // tris textuels {par titre} |
|
| 774 | + else { |
|
| 775 | + $par = array_shift($tri); |
|
| 776 | + $par = $par->texte; |
|
| 777 | + |
|
| 778 | + // tris de la forme {par expression champ} tel que {par num titre} ou {par multi titre} |
|
| 779 | + if (preg_match(",^(\w+)[\s]+(.*)$,", $par, $m)) { |
|
| 780 | + $expression = trim($m[1]); |
|
| 781 | + $champ = trim($m[2]); |
|
| 782 | + if (function_exists($f = 'calculer_critere_par_expression_' . $expression)) { |
|
| 783 | + $order = $f($idb, $boucles, $crit, $tri, $champ); |
|
| 784 | + } else { |
|
| 785 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + // tris de la forme {par champ} ou {par FONCTION(champ)} |
|
| 789 | + } elseif (preg_match(",^" . CHAMP_SQL_PLUS_FONC . '$,is', $par, $match)) { |
|
| 790 | + // {par FONCTION(champ)} |
|
| 791 | + if (count($match) > 2) { |
|
| 792 | + $par = substr($match[2], 1, -1); |
|
| 793 | + $fct = $match[1]; |
|
| 794 | + } |
|
| 795 | + // quelques cas spécifiques {par hasard}, {par date} |
|
| 796 | + if ($par == 'hasard') { |
|
| 797 | + $order = calculer_critere_par_hasard($idb, $boucles, $crit); |
|
| 798 | + } elseif ($par == 'date' and !empty($boucle->show['date'])) { |
|
| 799 | + $order = "'" . $boucle->id_table . "." . $boucle->show['date'] . "'"; |
|
| 800 | + } else { |
|
| 801 | + // cas général {par champ}, {par table.champ}, ... |
|
| 802 | + $order = calculer_critere_par_champ($idb, $boucles, $crit, $par); |
|
| 803 | + } |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + // on ne sait pas traiter… |
|
| 807 | + else { |
|
| 808 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 809 | + } |
|
| 810 | + |
|
| 811 | + // En cas d'erreur de squelette retournée par une fonction |
|
| 812 | + if (is_array($order)) { |
|
| 813 | + return $order; |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + if (preg_match('/^\'([^"]*)\'$/', $order, $m)) { |
|
| 818 | + $t = $m[1]; |
|
| 819 | + if (strpos($t, '.') and !in_array($t, $boucle->select)) { |
|
| 820 | + $boucle->select[] = $t; |
|
| 821 | + } |
|
| 822 | + } else { |
|
| 823 | + $sens = ''; |
|
| 824 | + } |
|
| 825 | + |
|
| 826 | + if ($fct) { |
|
| 827 | + if (preg_match("/^\s*'(.*)'\s*$/", $order, $r)) { |
|
| 828 | + $order = "'$fct(" . $r[1] . ")'"; |
|
| 829 | + } else { |
|
| 830 | + $order = "'$fct(' . $order . ')'"; |
|
| 831 | + } |
|
| 832 | + } |
|
| 833 | + $t = $order . $collecte . $sens; |
|
| 834 | + if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) { |
|
| 835 | + $t = $r[1] . $r[2]; |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + $boucle->order[] = $t; |
|
| 839 | + } |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -850,13 +850,13 @@ discard block |
||
| 850 | 850 | * @return string Clause pour le Order by |
| 851 | 851 | */ |
| 852 | 852 | function calculer_critere_par_hasard($idb, &$boucles, $crit) { |
| 853 | - $boucle = &$boucles[$idb]; |
|
| 854 | - // Si ce n'est fait, ajouter un champ 'hasard' dans le select |
|
| 855 | - $parha = "rand() AS hasard"; |
|
| 856 | - if (!in_array($parha, $boucle->select)) { |
|
| 857 | - $boucle->select[] = $parha; |
|
| 858 | - } |
|
| 859 | - return "'hasard'"; |
|
| 853 | + $boucle = &$boucles[$idb]; |
|
| 854 | + // Si ce n'est fait, ajouter un champ 'hasard' dans le select |
|
| 855 | + $parha = "rand() AS hasard"; |
|
| 856 | + if (!in_array($parha, $boucle->select)) { |
|
| 857 | + $boucle->select[] = $parha; |
|
| 858 | + } |
|
| 859 | + return "'hasard'"; |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | /** |
@@ -880,24 +880,24 @@ discard block |
||
| 880 | 880 | * @return string Clause pour le Order by |
| 881 | 881 | */ |
| 882 | 882 | function calculer_critere_par_expression_num($idb, &$boucles, $crit, $tri, $champ) { |
| 883 | - $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
|
| 884 | - if (is_array($_champ)) { |
|
| 885 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " num $champ")); |
|
| 886 | - } |
|
| 887 | - $boucle = &$boucles[$idb]; |
|
| 888 | - $texte = '0+' . $_champ; |
|
| 889 | - $suite = calculer_liste($tri, $idb, $boucles, $boucle->id_parent); |
|
| 890 | - if ($suite !== "''") { |
|
| 891 | - $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; |
|
| 892 | - } |
|
| 893 | - $asnum = 'num' . ($boucle->order ? count($boucle->order) : ""); |
|
| 894 | - $boucle->select[] = $texte . " AS $asnum"; |
|
| 895 | - |
|
| 896 | - $orderassinum = calculer_critere_par_expression_sinum($idb, $boucles, $crit, $tri, $champ); |
|
| 897 | - $orderassinum = trim($orderassinum, "'"); |
|
| 898 | - |
|
| 899 | - $order = "'$orderassinum, $asnum'"; |
|
| 900 | - return $order; |
|
| 883 | + $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
|
| 884 | + if (is_array($_champ)) { |
|
| 885 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " num $champ")); |
|
| 886 | + } |
|
| 887 | + $boucle = &$boucles[$idb]; |
|
| 888 | + $texte = '0+' . $_champ; |
|
| 889 | + $suite = calculer_liste($tri, $idb, $boucles, $boucle->id_parent); |
|
| 890 | + if ($suite !== "''") { |
|
| 891 | + $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; |
|
| 892 | + } |
|
| 893 | + $asnum = 'num' . ($boucle->order ? count($boucle->order) : ""); |
|
| 894 | + $boucle->select[] = $texte . " AS $asnum"; |
|
| 895 | + |
|
| 896 | + $orderassinum = calculer_critere_par_expression_sinum($idb, $boucles, $crit, $tri, $champ); |
|
| 897 | + $orderassinum = trim($orderassinum, "'"); |
|
| 898 | + |
|
| 899 | + $order = "'$orderassinum, $asnum'"; |
|
| 900 | + return $order; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -918,35 +918,35 @@ discard block |
||
| 918 | 918 | * @return string Clause pour le Order by |
| 919 | 919 | */ |
| 920 | 920 | function calculer_critere_par_expression_sinum($idb, &$boucles, $crit, $tri, $champ) { |
| 921 | - $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
|
| 922 | - if (is_array($_champ)) { |
|
| 923 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " sinum $champ")); |
|
| 924 | - } |
|
| 925 | - $boucle = &$boucles[$idb]; |
|
| 926 | - $texte = '0+' . $_champ; |
|
| 927 | - $suite = calculer_liste($tri, $idb, $boucles, $boucle->id_parent); |
|
| 928 | - if ($suite !== "''") { |
|
| 929 | - $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; |
|
| 930 | - } |
|
| 931 | - |
|
| 932 | - $as = false; |
|
| 933 | - $select = "CASE ( $texte ) WHEN 0 THEN 1 ELSE 0 END AS "; |
|
| 934 | - foreach ($boucle->select as $s) { |
|
| 935 | - if (strpos($s, $select) === 0) { |
|
| 936 | - $as = trim(substr($s, strlen($select))); |
|
| 937 | - if (!preg_match(",\W,", $as)) { |
|
| 938 | - break; |
|
| 939 | - } |
|
| 940 | - $as = false; |
|
| 941 | - } |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - if (!$as) { |
|
| 945 | - $as = 'sinum' . ($boucle->order ? count($boucle->order) : ""); |
|
| 946 | - $boucle->select[] = $select . $as; |
|
| 947 | - } |
|
| 948 | - $order = "'$as'"; |
|
| 949 | - return $order; |
|
| 921 | + $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
|
| 922 | + if (is_array($_champ)) { |
|
| 923 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " sinum $champ")); |
|
| 924 | + } |
|
| 925 | + $boucle = &$boucles[$idb]; |
|
| 926 | + $texte = '0+' . $_champ; |
|
| 927 | + $suite = calculer_liste($tri, $idb, $boucles, $boucle->id_parent); |
|
| 928 | + if ($suite !== "''") { |
|
| 929 | + $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; |
|
| 930 | + } |
|
| 931 | + |
|
| 932 | + $as = false; |
|
| 933 | + $select = "CASE ( $texte ) WHEN 0 THEN 1 ELSE 0 END AS "; |
|
| 934 | + foreach ($boucle->select as $s) { |
|
| 935 | + if (strpos($s, $select) === 0) { |
|
| 936 | + $as = trim(substr($s, strlen($select))); |
|
| 937 | + if (!preg_match(",\W,", $as)) { |
|
| 938 | + break; |
|
| 939 | + } |
|
| 940 | + $as = false; |
|
| 941 | + } |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + if (!$as) { |
|
| 945 | + $as = 'sinum' . ($boucle->order ? count($boucle->order) : ""); |
|
| 946 | + $boucle->select[] = $select . $as; |
|
| 947 | + } |
|
| 948 | + $order = "'$as'"; |
|
| 949 | + return $order; |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | |
@@ -966,14 +966,14 @@ discard block |
||
| 966 | 966 | * @return string Clause pour le Order by |
| 967 | 967 | */ |
| 968 | 968 | function calculer_critere_par_expression_multi($idb, &$boucles, $crit, $tri, $champ) { |
| 969 | - $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
|
| 970 | - if (is_array($_champ)) { |
|
| 971 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " multi $champ")); |
|
| 972 | - } |
|
| 973 | - $boucle = &$boucles[$idb]; |
|
| 974 | - $boucle->select[] = "\".sql_multi('" . $_champ . "', \$GLOBALS['spip_lang']).\""; |
|
| 975 | - $order = "'multi'"; |
|
| 976 | - return $order; |
|
| 969 | + $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
|
| 970 | + if (is_array($_champ)) { |
|
| 971 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " multi $champ")); |
|
| 972 | + } |
|
| 973 | + $boucle = &$boucles[$idb]; |
|
| 974 | + $boucle->select[] = "\".sql_multi('" . $_champ . "', \$GLOBALS['spip_lang']).\""; |
|
| 975 | + $order = "'multi'"; |
|
| 976 | + return $order; |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -992,56 +992,56 @@ discard block |
||
| 992 | 992 | * @return array|string |
| 993 | 993 | */ |
| 994 | 994 | function calculer_critere_par_champ($idb, &$boucles, $crit, $par, $raw = false) { |
| 995 | - $boucle = &$boucles[$idb]; |
|
| 996 | - $desc = $boucle->show; |
|
| 997 | - |
|
| 998 | - // le champ existe dans la table, pas de souci (le plus commun) |
|
| 999 | - if (isset($desc['field'][$par])) { |
|
| 1000 | - $par = $boucle->id_table . "." . $par; |
|
| 1001 | - } |
|
| 1002 | - // le champ est peut être une jointure |
|
| 1003 | - else { |
|
| 1004 | - $table = $table_alias = false; // toutes les tables de jointure possibles |
|
| 1005 | - $champ = $par; |
|
| 1006 | - |
|
| 1007 | - // le champ demandé est une exception de jointure {par titre_mot} |
|
| 1008 | - if (isset($GLOBALS['exceptions_des_jointures'][$par])) { |
|
| 1009 | - list($table, $champ) = $GLOBALS['exceptions_des_jointures'][$par]; |
|
| 1010 | - } // la table de jointure est explicitement indiquée {par truc.muche} |
|
| 1011 | - elseif (preg_match("/^([^,]*)\.(.*)$/", $par, $r)) { |
|
| 1012 | - list(, $table, $champ) = $r; |
|
| 1013 | - $table_alias = $table; // c'est peut-être un alias de table {par L1.titre} |
|
| 1014 | - $table = table_objet_sql($table); |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - // Si on connait la table d'arrivée, on la demande donc explicitement |
|
| 1018 | - // Sinon on cherche le champ dans les tables possibles de jointures |
|
| 1019 | - // Si la table est déjà dans le from, on la réutilise. |
|
| 1020 | - if ($infos = chercher_champ_dans_tables($champ, $boucle->from, $boucle->sql_serveur, $table)) { |
|
| 1021 | - $par = $infos['alias'] . "." . $champ; |
|
| 1022 | - } elseif ( |
|
| 1023 | - $boucle->jointures_explicites |
|
| 1024 | - and $alias = trouver_jointure_champ($champ, $boucle, explode(' ', $boucle->jointures_explicites), false, $table) |
|
| 1025 | - ) { |
|
| 1026 | - $par = $alias . "." . $champ; |
|
| 1027 | - } elseif ($alias = trouver_jointure_champ($champ, $boucle, $boucle->jointures, false, $table)) { |
|
| 1028 | - $par = $alias . "." . $champ; |
|
| 1029 | - // en spécifiant directement l'alias {par L2.titre} (situation hasardeuse tout de même) |
|
| 1030 | - } elseif ( |
|
| 1031 | - $table_alias |
|
| 1032 | - and isset($boucle->from[$table_alias]) |
|
| 1033 | - and $infos = chercher_champ_dans_tables($champ, $boucle->from, $boucle->sql_serveur, $boucle->from[$table_alias]) |
|
| 1034 | - ) { |
|
| 1035 | - $par = $infos['alias'] . "." . $champ; |
|
| 1036 | - } elseif ($table) { |
|
| 1037 | - // On avait table + champ, mais on ne les a pas trouvés |
|
| 1038 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 1039 | - } else { |
|
| 1040 | - // Sinon tant pis, ca doit etre un champ synthetise (cf points) |
|
| 1041 | - } |
|
| 1042 | - } |
|
| 1043 | - |
|
| 1044 | - return $raw ? $par : "'$par'"; |
|
| 995 | + $boucle = &$boucles[$idb]; |
|
| 996 | + $desc = $boucle->show; |
|
| 997 | + |
|
| 998 | + // le champ existe dans la table, pas de souci (le plus commun) |
|
| 999 | + if (isset($desc['field'][$par])) { |
|
| 1000 | + $par = $boucle->id_table . "." . $par; |
|
| 1001 | + } |
|
| 1002 | + // le champ est peut être une jointure |
|
| 1003 | + else { |
|
| 1004 | + $table = $table_alias = false; // toutes les tables de jointure possibles |
|
| 1005 | + $champ = $par; |
|
| 1006 | + |
|
| 1007 | + // le champ demandé est une exception de jointure {par titre_mot} |
|
| 1008 | + if (isset($GLOBALS['exceptions_des_jointures'][$par])) { |
|
| 1009 | + list($table, $champ) = $GLOBALS['exceptions_des_jointures'][$par]; |
|
| 1010 | + } // la table de jointure est explicitement indiquée {par truc.muche} |
|
| 1011 | + elseif (preg_match("/^([^,]*)\.(.*)$/", $par, $r)) { |
|
| 1012 | + list(, $table, $champ) = $r; |
|
| 1013 | + $table_alias = $table; // c'est peut-être un alias de table {par L1.titre} |
|
| 1014 | + $table = table_objet_sql($table); |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + // Si on connait la table d'arrivée, on la demande donc explicitement |
|
| 1018 | + // Sinon on cherche le champ dans les tables possibles de jointures |
|
| 1019 | + // Si la table est déjà dans le from, on la réutilise. |
|
| 1020 | + if ($infos = chercher_champ_dans_tables($champ, $boucle->from, $boucle->sql_serveur, $table)) { |
|
| 1021 | + $par = $infos['alias'] . "." . $champ; |
|
| 1022 | + } elseif ( |
|
| 1023 | + $boucle->jointures_explicites |
|
| 1024 | + and $alias = trouver_jointure_champ($champ, $boucle, explode(' ', $boucle->jointures_explicites), false, $table) |
|
| 1025 | + ) { |
|
| 1026 | + $par = $alias . "." . $champ; |
|
| 1027 | + } elseif ($alias = trouver_jointure_champ($champ, $boucle, $boucle->jointures, false, $table)) { |
|
| 1028 | + $par = $alias . "." . $champ; |
|
| 1029 | + // en spécifiant directement l'alias {par L2.titre} (situation hasardeuse tout de même) |
|
| 1030 | + } elseif ( |
|
| 1031 | + $table_alias |
|
| 1032 | + and isset($boucle->from[$table_alias]) |
|
| 1033 | + and $infos = chercher_champ_dans_tables($champ, $boucle->from, $boucle->sql_serveur, $boucle->from[$table_alias]) |
|
| 1034 | + ) { |
|
| 1035 | + $par = $infos['alias'] . "." . $champ; |
|
| 1036 | + } elseif ($table) { |
|
| 1037 | + // On avait table + champ, mais on ne les a pas trouvés |
|
| 1038 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 1039 | + } else { |
|
| 1040 | + // Sinon tant pis, ca doit etre un champ synthetise (cf points) |
|
| 1041 | + } |
|
| 1042 | + } |
|
| 1043 | + |
|
| 1044 | + return $raw ? $par : "'$par'"; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | /** |
@@ -1055,11 +1055,11 @@ discard block |
||
| 1055 | 1055 | * @return string Champ pour le compilateur si trouvé, tel que "'alias.champ'", sinon vide. |
| 1056 | 1056 | */ |
| 1057 | 1057 | function critere_par_joint($table, $champ, &$boucle) { |
| 1058 | - $t = array_search($table, $boucle->from); |
|
| 1059 | - if (!$t) { |
|
| 1060 | - $t = trouver_jointure_champ($champ, $boucle); |
|
| 1061 | - } |
|
| 1062 | - return !$t ? '' : ("'" . $t . '.' . $champ . "'"); |
|
| 1058 | + $t = array_search($table, $boucle->from); |
|
| 1059 | + if (!$t) { |
|
| 1060 | + $t = trouver_jointure_champ($champ, $boucle); |
|
| 1061 | + } |
|
| 1062 | + return !$t ? '' : ("'" . $t . '.' . $champ . "'"); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | /** |
@@ -1084,33 +1084,33 @@ discard block |
||
| 1084 | 1084 | */ |
| 1085 | 1085 | function critere_inverse_dist($idb, &$boucles, $crit) { |
| 1086 | 1086 | |
| 1087 | - $boucle = &$boucles[$idb]; |
|
| 1088 | - // Classement par ordre inverse |
|
| 1089 | - if ($crit->not) { |
|
| 1090 | - critere_parinverse($idb, $boucles, $crit); |
|
| 1091 | - } else { |
|
| 1092 | - $order = "' DESC'"; |
|
| 1093 | - // Classement par ordre inverse fonction eventuelle de #ENV{...} |
|
| 1094 | - if (isset($crit->param[0])) { |
|
| 1095 | - $critere = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 1096 | - $order = "(($critere)?' DESC':'')"; |
|
| 1097 | - } |
|
| 1098 | - |
|
| 1099 | - $n = count($boucle->order); |
|
| 1100 | - if (!$n) { |
|
| 1101 | - if (isset($boucle->default_order[0])) { |
|
| 1102 | - $boucle->default_order[0] .= ' . " DESC"'; |
|
| 1103 | - } else { |
|
| 1104 | - $boucle->default_order[] = ' DESC'; |
|
| 1105 | - } |
|
| 1106 | - } else { |
|
| 1107 | - $t = $boucle->order[$n - 1] . " . $order"; |
|
| 1108 | - if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) { |
|
| 1109 | - $t = $r[1] . $r[2]; |
|
| 1110 | - } |
|
| 1111 | - $boucle->order[$n - 1] = $t; |
|
| 1112 | - } |
|
| 1113 | - } |
|
| 1087 | + $boucle = &$boucles[$idb]; |
|
| 1088 | + // Classement par ordre inverse |
|
| 1089 | + if ($crit->not) { |
|
| 1090 | + critere_parinverse($idb, $boucles, $crit); |
|
| 1091 | + } else { |
|
| 1092 | + $order = "' DESC'"; |
|
| 1093 | + // Classement par ordre inverse fonction eventuelle de #ENV{...} |
|
| 1094 | + if (isset($crit->param[0])) { |
|
| 1095 | + $critere = calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 1096 | + $order = "(($critere)?' DESC':'')"; |
|
| 1097 | + } |
|
| 1098 | + |
|
| 1099 | + $n = count($boucle->order); |
|
| 1100 | + if (!$n) { |
|
| 1101 | + if (isset($boucle->default_order[0])) { |
|
| 1102 | + $boucle->default_order[0] .= ' . " DESC"'; |
|
| 1103 | + } else { |
|
| 1104 | + $boucle->default_order[] = ' DESC'; |
|
| 1105 | + } |
|
| 1106 | + } else { |
|
| 1107 | + $t = $boucle->order[$n - 1] . " . $order"; |
|
| 1108 | + if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) { |
|
| 1109 | + $t = $r[1] . $r[2]; |
|
| 1110 | + } |
|
| 1111 | + $boucle->order[$n - 1] = $t; |
|
| 1112 | + } |
|
| 1113 | + } |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | /** |
@@ -1121,138 +1121,138 @@ discard block |
||
| 1121 | 1121 | * @return array|string |
| 1122 | 1122 | */ |
| 1123 | 1123 | function critere_par_ordre_liste_dist($idb, &$boucles, $crit){ |
| 1124 | - $boucle = &$boucles[$idb]; |
|
| 1124 | + $boucle = &$boucles[$idb]; |
|
| 1125 | 1125 | |
| 1126 | - $sens = $collecte = ''; |
|
| 1127 | - if ($crit->not){ |
|
| 1128 | - $sens = " . ' DESC'"; |
|
| 1129 | - } |
|
| 1126 | + $sens = $collecte = ''; |
|
| 1127 | + if ($crit->not){ |
|
| 1128 | + $sens = " . ' DESC'"; |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - $crit2 = clone $crit; |
|
| 1132 | - $crit2->not = false; |
|
| 1133 | - $crit2->param = [reset($crit->param)]; |
|
| 1134 | - $res = critere_parinverse($idb, $boucles, $crit2); |
|
| 1131 | + $crit2 = clone $crit; |
|
| 1132 | + $crit2->not = false; |
|
| 1133 | + $crit2->param = [reset($crit->param)]; |
|
| 1134 | + $res = critere_parinverse($idb, $boucles, $crit2); |
|
| 1135 | 1135 | |
| 1136 | - // erreur ? |
|
| 1137 | - if (is_array($res)){ |
|
| 1138 | - return $res; |
|
| 1139 | - } |
|
| 1136 | + // erreur ? |
|
| 1137 | + if (is_array($res)){ |
|
| 1138 | + return $res; |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | - $_order = array_pop($boucle->order); |
|
| 1141 | + $_order = array_pop($boucle->order); |
|
| 1142 | 1142 | |
| 1143 | - $_liste = calculer_liste($crit->param[1], array(), $boucles, $boucles[$idb]->id_parent); |
|
| 1144 | - $boucle->order[] = "'FIELD(' . $_order . ',' . ((\$zl=formate_liste_critere_par_ordre_liste($_liste,'" . $boucle->sql_serveur . "')) ? \$zl : '0').')'$sens"; |
|
| 1143 | + $_liste = calculer_liste($crit->param[1], array(), $boucles, $boucles[$idb]->id_parent); |
|
| 1144 | + $boucle->order[] = "'FIELD(' . $_order . ',' . ((\$zl=formate_liste_critere_par_ordre_liste($_liste,'" . $boucle->sql_serveur . "')) ? \$zl : '0').')'$sens"; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | |
| 1148 | 1148 | // https://code.spip.net/@critere_agenda_dist |
| 1149 | 1149 | function critere_agenda_dist($idb, &$boucles, $crit) { |
| 1150 | - $params = $crit->param; |
|
| 1151 | - |
|
| 1152 | - if (count($params) < 1) { |
|
| 1153 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " ?")); |
|
| 1154 | - } |
|
| 1155 | - |
|
| 1156 | - $boucle = &$boucles[$idb]; |
|
| 1157 | - $parent = $boucle->id_parent; |
|
| 1158 | - $fields = $boucle->show['field']; |
|
| 1159 | - |
|
| 1160 | - $date = array_shift($params); |
|
| 1161 | - $type = array_shift($params); |
|
| 1162 | - |
|
| 1163 | - // la valeur $type doit etre connue a la compilation |
|
| 1164 | - // donc etre forcement reduite a un litteral unique dans le source |
|
| 1165 | - $type = is_object($type[0]) ? $type[0]->texte : null; |
|
| 1166 | - |
|
| 1167 | - // La valeur date doit designer un champ de la table SQL. |
|
| 1168 | - // Si c'est un litteral unique dans le source, verifier a la compil, |
|
| 1169 | - // sinon synthetiser le test de verif pour execution ulterieure |
|
| 1170 | - // On prendra arbitrairement le premier champ si test negatif. |
|
| 1171 | - if ((count($date) == 1) and ($date[0]->type == 'texte')) { |
|
| 1172 | - $date = $date[0]->texte; |
|
| 1173 | - if (!isset($fields[$date])) { |
|
| 1174 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " " . $date)); |
|
| 1175 | - } |
|
| 1176 | - } else { |
|
| 1177 | - $a = calculer_liste($date, $idb, $boucles, $parent); |
|
| 1178 | - $noms = array_keys($fields); |
|
| 1179 | - $defaut = $noms[0]; |
|
| 1180 | - $noms = join(" ", $noms); |
|
| 1181 | - # bien laisser 2 espaces avant $nom pour que strpos<>0 |
|
| 1182 | - $cond = "(\$a=strval($a))AND\nstrpos(\" $noms \",\" \$a \")"; |
|
| 1183 | - $date = "'.(($cond)\n?\$a:\"$defaut\").'"; |
|
| 1184 | - } |
|
| 1185 | - $annee = $params ? array_shift($params) : ""; |
|
| 1186 | - $annee = "\n" . 'sprintf("%04d", ($x = ' . |
|
| 1187 | - calculer_liste($annee, $idb, $boucles, $parent) . |
|
| 1188 | - ') ? $x : date("Y"))'; |
|
| 1189 | - |
|
| 1190 | - $mois = $params ? array_shift($params) : ""; |
|
| 1191 | - $mois = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1192 | - calculer_liste($mois, $idb, $boucles, $parent) . |
|
| 1193 | - ') ? $x : date("m"))'; |
|
| 1194 | - |
|
| 1195 | - $jour = $params ? array_shift($params) : ""; |
|
| 1196 | - $jour = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1197 | - calculer_liste($jour, $idb, $boucles, $parent) . |
|
| 1198 | - ') ? $x : date("d"))'; |
|
| 1199 | - |
|
| 1200 | - $annee2 = $params ? array_shift($params) : ""; |
|
| 1201 | - $annee2 = "\n" . 'sprintf("%04d", ($x = ' . |
|
| 1202 | - calculer_liste($annee2, $idb, $boucles, $parent) . |
|
| 1203 | - ') ? $x : date("Y"))'; |
|
| 1204 | - |
|
| 1205 | - $mois2 = $params ? array_shift($params) : ""; |
|
| 1206 | - $mois2 = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1207 | - calculer_liste($mois2, $idb, $boucles, $parent) . |
|
| 1208 | - ') ? $x : date("m"))'; |
|
| 1209 | - |
|
| 1210 | - $jour2 = $params ? array_shift($params) : ""; |
|
| 1211 | - $jour2 = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1212 | - calculer_liste($jour2, $idb, $boucles, $parent) . |
|
| 1213 | - ') ? $x : date("d"))'; |
|
| 1214 | - |
|
| 1215 | - $date = $boucle->id_table . ".$date"; |
|
| 1216 | - |
|
| 1217 | - $quote_end = ",'" . $boucle->sql_serveur . "','text'"; |
|
| 1218 | - if ($type == 'jour') { |
|
| 1219 | - $boucle->where[] = array( |
|
| 1220 | - "'='", |
|
| 1221 | - "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1222 | - ("sql_quote($annee . $mois . $jour$quote_end)") |
|
| 1223 | - ); |
|
| 1224 | - } elseif ($type == 'mois') { |
|
| 1225 | - $boucle->where[] = array( |
|
| 1226 | - "'='", |
|
| 1227 | - "'DATE_FORMAT($date, \'%Y%m\')'", |
|
| 1228 | - ("sql_quote($annee . $mois$quote_end)") |
|
| 1229 | - ); |
|
| 1230 | - } elseif ($type == 'semaine') { |
|
| 1231 | - $boucle->where[] = array( |
|
| 1232 | - "'AND'", |
|
| 1233 | - array( |
|
| 1234 | - "'>='", |
|
| 1235 | - "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1236 | - ("date_debut_semaine($annee, $mois, $jour)") |
|
| 1237 | - ), |
|
| 1238 | - array( |
|
| 1239 | - "'<='", |
|
| 1240 | - "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1241 | - ("date_fin_semaine($annee, $mois, $jour)") |
|
| 1242 | - ) |
|
| 1243 | - ); |
|
| 1244 | - } elseif (count($crit->param) > 2) { |
|
| 1245 | - $boucle->where[] = array( |
|
| 1246 | - "'AND'", |
|
| 1247 | - array( |
|
| 1248 | - "'>='", |
|
| 1249 | - "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1250 | - ("sql_quote($annee . $mois . $jour$quote_end)") |
|
| 1251 | - ), |
|
| 1252 | - array("'<='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("sql_quote($annee2 . $mois2 . $jour2$quote_end)")) |
|
| 1253 | - ); |
|
| 1254 | - } |
|
| 1255 | - // sinon on prend tout |
|
| 1150 | + $params = $crit->param; |
|
| 1151 | + |
|
| 1152 | + if (count($params) < 1) { |
|
| 1153 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " ?")); |
|
| 1154 | + } |
|
| 1155 | + |
|
| 1156 | + $boucle = &$boucles[$idb]; |
|
| 1157 | + $parent = $boucle->id_parent; |
|
| 1158 | + $fields = $boucle->show['field']; |
|
| 1159 | + |
|
| 1160 | + $date = array_shift($params); |
|
| 1161 | + $type = array_shift($params); |
|
| 1162 | + |
|
| 1163 | + // la valeur $type doit etre connue a la compilation |
|
| 1164 | + // donc etre forcement reduite a un litteral unique dans le source |
|
| 1165 | + $type = is_object($type[0]) ? $type[0]->texte : null; |
|
| 1166 | + |
|
| 1167 | + // La valeur date doit designer un champ de la table SQL. |
|
| 1168 | + // Si c'est un litteral unique dans le source, verifier a la compil, |
|
| 1169 | + // sinon synthetiser le test de verif pour execution ulterieure |
|
| 1170 | + // On prendra arbitrairement le premier champ si test negatif. |
|
| 1171 | + if ((count($date) == 1) and ($date[0]->type == 'texte')) { |
|
| 1172 | + $date = $date[0]->texte; |
|
| 1173 | + if (!isset($fields[$date])) { |
|
| 1174 | + return array('zbug_critere_inconnu', array('critere' => $crit->op . " " . $date)); |
|
| 1175 | + } |
|
| 1176 | + } else { |
|
| 1177 | + $a = calculer_liste($date, $idb, $boucles, $parent); |
|
| 1178 | + $noms = array_keys($fields); |
|
| 1179 | + $defaut = $noms[0]; |
|
| 1180 | + $noms = join(" ", $noms); |
|
| 1181 | + # bien laisser 2 espaces avant $nom pour que strpos<>0 |
|
| 1182 | + $cond = "(\$a=strval($a))AND\nstrpos(\" $noms \",\" \$a \")"; |
|
| 1183 | + $date = "'.(($cond)\n?\$a:\"$defaut\").'"; |
|
| 1184 | + } |
|
| 1185 | + $annee = $params ? array_shift($params) : ""; |
|
| 1186 | + $annee = "\n" . 'sprintf("%04d", ($x = ' . |
|
| 1187 | + calculer_liste($annee, $idb, $boucles, $parent) . |
|
| 1188 | + ') ? $x : date("Y"))'; |
|
| 1189 | + |
|
| 1190 | + $mois = $params ? array_shift($params) : ""; |
|
| 1191 | + $mois = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1192 | + calculer_liste($mois, $idb, $boucles, $parent) . |
|
| 1193 | + ') ? $x : date("m"))'; |
|
| 1194 | + |
|
| 1195 | + $jour = $params ? array_shift($params) : ""; |
|
| 1196 | + $jour = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1197 | + calculer_liste($jour, $idb, $boucles, $parent) . |
|
| 1198 | + ') ? $x : date("d"))'; |
|
| 1199 | + |
|
| 1200 | + $annee2 = $params ? array_shift($params) : ""; |
|
| 1201 | + $annee2 = "\n" . 'sprintf("%04d", ($x = ' . |
|
| 1202 | + calculer_liste($annee2, $idb, $boucles, $parent) . |
|
| 1203 | + ') ? $x : date("Y"))'; |
|
| 1204 | + |
|
| 1205 | + $mois2 = $params ? array_shift($params) : ""; |
|
| 1206 | + $mois2 = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1207 | + calculer_liste($mois2, $idb, $boucles, $parent) . |
|
| 1208 | + ') ? $x : date("m"))'; |
|
| 1209 | + |
|
| 1210 | + $jour2 = $params ? array_shift($params) : ""; |
|
| 1211 | + $jour2 = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1212 | + calculer_liste($jour2, $idb, $boucles, $parent) . |
|
| 1213 | + ') ? $x : date("d"))'; |
|
| 1214 | + |
|
| 1215 | + $date = $boucle->id_table . ".$date"; |
|
| 1216 | + |
|
| 1217 | + $quote_end = ",'" . $boucle->sql_serveur . "','text'"; |
|
| 1218 | + if ($type == 'jour') { |
|
| 1219 | + $boucle->where[] = array( |
|
| 1220 | + "'='", |
|
| 1221 | + "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1222 | + ("sql_quote($annee . $mois . $jour$quote_end)") |
|
| 1223 | + ); |
|
| 1224 | + } elseif ($type == 'mois') { |
|
| 1225 | + $boucle->where[] = array( |
|
| 1226 | + "'='", |
|
| 1227 | + "'DATE_FORMAT($date, \'%Y%m\')'", |
|
| 1228 | + ("sql_quote($annee . $mois$quote_end)") |
|
| 1229 | + ); |
|
| 1230 | + } elseif ($type == 'semaine') { |
|
| 1231 | + $boucle->where[] = array( |
|
| 1232 | + "'AND'", |
|
| 1233 | + array( |
|
| 1234 | + "'>='", |
|
| 1235 | + "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1236 | + ("date_debut_semaine($annee, $mois, $jour)") |
|
| 1237 | + ), |
|
| 1238 | + array( |
|
| 1239 | + "'<='", |
|
| 1240 | + "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1241 | + ("date_fin_semaine($annee, $mois, $jour)") |
|
| 1242 | + ) |
|
| 1243 | + ); |
|
| 1244 | + } elseif (count($crit->param) > 2) { |
|
| 1245 | + $boucle->where[] = array( |
|
| 1246 | + "'AND'", |
|
| 1247 | + array( |
|
| 1248 | + "'>='", |
|
| 1249 | + "'DATE_FORMAT($date, \'%Y%m%d\')'", |
|
| 1250 | + ("sql_quote($annee . $mois . $jour$quote_end)") |
|
| 1251 | + ), |
|
| 1252 | + array("'<='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("sql_quote($annee2 . $mois2 . $jour2$quote_end)")) |
|
| 1253 | + ); |
|
| 1254 | + } |
|
| 1255 | + // sinon on prend tout |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | |
@@ -1277,33 +1277,33 @@ discard block |
||
| 1277 | 1277 | * @return void |
| 1278 | 1278 | **/ |
| 1279 | 1279 | function calculer_critere_parties($idb, &$boucles, $crit) { |
| 1280 | - $boucle = &$boucles[$idb]; |
|
| 1281 | - $a1 = $crit->param[0]; |
|
| 1282 | - $a2 = $crit->param[1]; |
|
| 1283 | - $op = $crit->op; |
|
| 1284 | - |
|
| 1285 | - list($a11, $a12) = calculer_critere_parties_aux($idb, $boucles, $a1); |
|
| 1286 | - list($a21, $a22) = calculer_critere_parties_aux($idb, $boucles, $a2); |
|
| 1287 | - |
|
| 1288 | - if (($op == ',') && (is_numeric($a11) && (is_numeric($a21)))) { |
|
| 1289 | - $boucle->limit = $a11 . ',' . $a21; |
|
| 1290 | - } else { |
|
| 1291 | - // 3 dans {1/3}, {2,3} ou {1,n-3} |
|
| 1292 | - $boucle->total_parties = ($a21 != 'n') ? $a21 : $a22; |
|
| 1293 | - // 2 dans {2/3}, {2,5}, {n-2,1} |
|
| 1294 | - $partie = ($a11 != 'n') ? $a11 : $a12; |
|
| 1295 | - $mode = (($op == '/') ? '/' : |
|
| 1296 | - (($a11 == 'n') ? '-' : '+') . (($a21 == 'n') ? '-' : '+')); |
|
| 1297 | - // cas simple {0,#ENV{truc}} compilons le en LIMIT : |
|
| 1298 | - if ($a11 !== 'n' and $a21 !== 'n' and $mode == "++" and $op == ',') { |
|
| 1299 | - $boucle->limit = |
|
| 1300 | - (is_numeric($a11) ? "'$a11'" : $a11) |
|
| 1301 | - . ".','." |
|
| 1302 | - . (is_numeric($a21) ? "'$a21'" : $a21); |
|
| 1303 | - } else { |
|
| 1304 | - calculer_parties($boucles, $idb, $partie, $mode); |
|
| 1305 | - } |
|
| 1306 | - } |
|
| 1280 | + $boucle = &$boucles[$idb]; |
|
| 1281 | + $a1 = $crit->param[0]; |
|
| 1282 | + $a2 = $crit->param[1]; |
|
| 1283 | + $op = $crit->op; |
|
| 1284 | + |
|
| 1285 | + list($a11, $a12) = calculer_critere_parties_aux($idb, $boucles, $a1); |
|
| 1286 | + list($a21, $a22) = calculer_critere_parties_aux($idb, $boucles, $a2); |
|
| 1287 | + |
|
| 1288 | + if (($op == ',') && (is_numeric($a11) && (is_numeric($a21)))) { |
|
| 1289 | + $boucle->limit = $a11 . ',' . $a21; |
|
| 1290 | + } else { |
|
| 1291 | + // 3 dans {1/3}, {2,3} ou {1,n-3} |
|
| 1292 | + $boucle->total_parties = ($a21 != 'n') ? $a21 : $a22; |
|
| 1293 | + // 2 dans {2/3}, {2,5}, {n-2,1} |
|
| 1294 | + $partie = ($a11 != 'n') ? $a11 : $a12; |
|
| 1295 | + $mode = (($op == '/') ? '/' : |
|
| 1296 | + (($a11 == 'n') ? '-' : '+') . (($a21 == 'n') ? '-' : '+')); |
|
| 1297 | + // cas simple {0,#ENV{truc}} compilons le en LIMIT : |
|
| 1298 | + if ($a11 !== 'n' and $a21 !== 'n' and $mode == "++" and $op == ',') { |
|
| 1299 | + $boucle->limit = |
|
| 1300 | + (is_numeric($a11) ? "'$a11'" : $a11) |
|
| 1301 | + . ".','." |
|
| 1302 | + . (is_numeric($a21) ? "'$a21'" : $a21); |
|
| 1303 | + } else { |
|
| 1304 | + calculer_parties($boucles, $idb, $partie, $mode); |
|
| 1305 | + } |
|
| 1306 | + } |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | /** |
@@ -1331,63 +1331,63 @@ discard block |
||
| 1331 | 1331 | * @return void |
| 1332 | 1332 | **/ |
| 1333 | 1333 | function calculer_parties(&$boucles, $id_boucle, $debut, $mode) { |
| 1334 | - $total_parties = $boucles[$id_boucle]->total_parties; |
|
| 1335 | - |
|
| 1336 | - preg_match(",([+-/p])([+-/])?,", $mode, $regs); |
|
| 1337 | - list(, $op1, $op2) = array_pad($regs, 3, null); |
|
| 1338 | - $nombre_boucle = "\$Numrows['$id_boucle']['total']"; |
|
| 1339 | - // {1/3} |
|
| 1340 | - if ($op1 == '/') { |
|
| 1341 | - $pmoins1 = is_numeric($debut) ? ($debut - 1) : "($debut-1)"; |
|
| 1342 | - $totpos = is_numeric($total_parties) ? ($total_parties) : |
|
| 1343 | - "($total_parties ? $total_parties : 1)"; |
|
| 1344 | - $fin = "ceil(($nombre_boucle * $debut )/$totpos) - 1"; |
|
| 1345 | - $debut = !$pmoins1 ? 0 : "ceil(($nombre_boucle * $pmoins1)/$totpos);"; |
|
| 1346 | - } else { |
|
| 1347 | - // cas {n-1,x} |
|
| 1348 | - if ($op1 == '-') { |
|
| 1349 | - $debut = "$nombre_boucle - $debut;"; |
|
| 1350 | - } |
|
| 1351 | - |
|
| 1352 | - // cas {x,n-1} |
|
| 1353 | - if ($op2 == '-') { |
|
| 1354 | - $fin = '$debut_boucle + ' . $nombre_boucle . ' - ' |
|
| 1355 | - . (is_numeric($total_parties) ? ($total_parties + 1) : |
|
| 1356 | - ($total_parties . ' - 1')); |
|
| 1357 | - } else { |
|
| 1358 | - // {x,1} ou {pagination} |
|
| 1359 | - $fin = '$debut_boucle' |
|
| 1360 | - . (is_numeric($total_parties) ? |
|
| 1361 | - (($total_parties == 1) ? "" : (' + ' . ($total_parties - 1))) : |
|
| 1362 | - ('+' . $total_parties . ' - 1')); |
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - // {pagination}, gerer le debut_xx=-1 pour tout voir |
|
| 1366 | - if ($op1 == 'p') { |
|
| 1367 | - $debut .= ";\n \$debut_boucle = ((\$tout=(\$debut_boucle == -1))?0:(\$debut_boucle))"; |
|
| 1368 | - $debut .= ";\n \$debut_boucle = max(0,min(\$debut_boucle,floor(($nombre_boucle-1)/($total_parties))*($total_parties)))"; |
|
| 1369 | - $fin = "(\$tout ? $nombre_boucle : $fin)"; |
|
| 1370 | - } |
|
| 1371 | - } |
|
| 1372 | - |
|
| 1373 | - // Notes : |
|
| 1374 | - // $debut_boucle et $fin_boucle sont les indices SQL du premier |
|
| 1375 | - // et du dernier demandes dans la boucle : 0 pour le premier, |
|
| 1376 | - // n-1 pour le dernier ; donc total_boucle = 1 + debut - fin |
|
| 1377 | - // Utiliser min pour rabattre $fin_boucle sur total_boucle. |
|
| 1378 | - |
|
| 1379 | - $boucles[$id_boucle]->mode_partie = "\n\t" |
|
| 1380 | - . '$debut_boucle = ' . $debut . ";\n " |
|
| 1381 | - . "\$debut_boucle = intval(\$debut_boucle);\n " |
|
| 1382 | - . '$fin_boucle = min(' . $fin . ", \$Numrows['$id_boucle']['total'] - 1);\n " |
|
| 1383 | - . '$Numrows[\'' . $id_boucle . "']['grand_total'] = \$Numrows['$id_boucle']['total'];\n " |
|
| 1384 | - . '$Numrows[\'' . $id_boucle . '\']["total"] = max(0,$fin_boucle - $debut_boucle + 1);' |
|
| 1385 | - . "\n\tif (\$debut_boucle>0" |
|
| 1386 | - . " AND \$debut_boucle < \$Numrows['$id_boucle']['grand_total']" |
|
| 1387 | - . " AND \$iter->seek(\$debut_boucle,'continue'))" |
|
| 1388 | - . "\n\t\t\$Numrows['$id_boucle']['compteur_boucle'] = \$debut_boucle;\n\t"; |
|
| 1389 | - |
|
| 1390 | - $boucles[$id_boucle]->partie = " |
|
| 1334 | + $total_parties = $boucles[$id_boucle]->total_parties; |
|
| 1335 | + |
|
| 1336 | + preg_match(",([+-/p])([+-/])?,", $mode, $regs); |
|
| 1337 | + list(, $op1, $op2) = array_pad($regs, 3, null); |
|
| 1338 | + $nombre_boucle = "\$Numrows['$id_boucle']['total']"; |
|
| 1339 | + // {1/3} |
|
| 1340 | + if ($op1 == '/') { |
|
| 1341 | + $pmoins1 = is_numeric($debut) ? ($debut - 1) : "($debut-1)"; |
|
| 1342 | + $totpos = is_numeric($total_parties) ? ($total_parties) : |
|
| 1343 | + "($total_parties ? $total_parties : 1)"; |
|
| 1344 | + $fin = "ceil(($nombre_boucle * $debut )/$totpos) - 1"; |
|
| 1345 | + $debut = !$pmoins1 ? 0 : "ceil(($nombre_boucle * $pmoins1)/$totpos);"; |
|
| 1346 | + } else { |
|
| 1347 | + // cas {n-1,x} |
|
| 1348 | + if ($op1 == '-') { |
|
| 1349 | + $debut = "$nombre_boucle - $debut;"; |
|
| 1350 | + } |
|
| 1351 | + |
|
| 1352 | + // cas {x,n-1} |
|
| 1353 | + if ($op2 == '-') { |
|
| 1354 | + $fin = '$debut_boucle + ' . $nombre_boucle . ' - ' |
|
| 1355 | + . (is_numeric($total_parties) ? ($total_parties + 1) : |
|
| 1356 | + ($total_parties . ' - 1')); |
|
| 1357 | + } else { |
|
| 1358 | + // {x,1} ou {pagination} |
|
| 1359 | + $fin = '$debut_boucle' |
|
| 1360 | + . (is_numeric($total_parties) ? |
|
| 1361 | + (($total_parties == 1) ? "" : (' + ' . ($total_parties - 1))) : |
|
| 1362 | + ('+' . $total_parties . ' - 1')); |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + // {pagination}, gerer le debut_xx=-1 pour tout voir |
|
| 1366 | + if ($op1 == 'p') { |
|
| 1367 | + $debut .= ";\n \$debut_boucle = ((\$tout=(\$debut_boucle == -1))?0:(\$debut_boucle))"; |
|
| 1368 | + $debut .= ";\n \$debut_boucle = max(0,min(\$debut_boucle,floor(($nombre_boucle-1)/($total_parties))*($total_parties)))"; |
|
| 1369 | + $fin = "(\$tout ? $nombre_boucle : $fin)"; |
|
| 1370 | + } |
|
| 1371 | + } |
|
| 1372 | + |
|
| 1373 | + // Notes : |
|
| 1374 | + // $debut_boucle et $fin_boucle sont les indices SQL du premier |
|
| 1375 | + // et du dernier demandes dans la boucle : 0 pour le premier, |
|
| 1376 | + // n-1 pour le dernier ; donc total_boucle = 1 + debut - fin |
|
| 1377 | + // Utiliser min pour rabattre $fin_boucle sur total_boucle. |
|
| 1378 | + |
|
| 1379 | + $boucles[$id_boucle]->mode_partie = "\n\t" |
|
| 1380 | + . '$debut_boucle = ' . $debut . ";\n " |
|
| 1381 | + . "\$debut_boucle = intval(\$debut_boucle);\n " |
|
| 1382 | + . '$fin_boucle = min(' . $fin . ", \$Numrows['$id_boucle']['total'] - 1);\n " |
|
| 1383 | + . '$Numrows[\'' . $id_boucle . "']['grand_total'] = \$Numrows['$id_boucle']['total'];\n " |
|
| 1384 | + . '$Numrows[\'' . $id_boucle . '\']["total"] = max(0,$fin_boucle - $debut_boucle + 1);' |
|
| 1385 | + . "\n\tif (\$debut_boucle>0" |
|
| 1386 | + . " AND \$debut_boucle < \$Numrows['$id_boucle']['grand_total']" |
|
| 1387 | + . " AND \$iter->seek(\$debut_boucle,'continue'))" |
|
| 1388 | + . "\n\t\t\$Numrows['$id_boucle']['compteur_boucle'] = \$debut_boucle;\n\t"; |
|
| 1389 | + |
|
| 1390 | + $boucles[$id_boucle]->partie = " |
|
| 1391 | 1391 | if (\$Numrows['$id_boucle']['compteur_boucle'] <= \$debut_boucle) continue; |
| 1392 | 1392 | if (\$Numrows['$id_boucle']['compteur_boucle']-1 > \$fin_boucle) break;"; |
| 1393 | 1393 | } |
@@ -1404,26 +1404,26 @@ discard block |
||
| 1404 | 1404 | * @return array Valeur de l'élément (peut être une expression PHP), Nombre soustrait |
| 1405 | 1405 | **/ |
| 1406 | 1406 | function calculer_critere_parties_aux($idb, &$boucles, $param) { |
| 1407 | - if ($param[0]->type != 'texte') { |
|
| 1408 | - $a1 = calculer_liste(array($param[0]), $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 1409 | - if (isset($param[1]->texte)) { |
|
| 1410 | - preg_match(',^ *(-([0-9]+))? *$,', $param[1]->texte, $m); |
|
| 1411 | - |
|
| 1412 | - return array("intval($a1)", ((isset($m[2]) and $m[2]) ? $m[2] : 0)); |
|
| 1413 | - } else { |
|
| 1414 | - return array("intval($a1)", 0); |
|
| 1415 | - } |
|
| 1416 | - } else { |
|
| 1417 | - preg_match(',^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$,', $param[0]->texte, $m); |
|
| 1418 | - $a1 = $m[1]; |
|
| 1419 | - if (empty($m[3])) { |
|
| 1420 | - return array($a1, 0); |
|
| 1421 | - } elseif (!empty($m[4])) { |
|
| 1422 | - return array($a1, $m[4]); |
|
| 1423 | - } else { |
|
| 1424 | - return array($a1, calculer_liste(array($param[1]), $idb, $boucles, $boucles[$idb]->id_parent)); |
|
| 1425 | - } |
|
| 1426 | - } |
|
| 1407 | + if ($param[0]->type != 'texte') { |
|
| 1408 | + $a1 = calculer_liste(array($param[0]), $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 1409 | + if (isset($param[1]->texte)) { |
|
| 1410 | + preg_match(',^ *(-([0-9]+))? *$,', $param[1]->texte, $m); |
|
| 1411 | + |
|
| 1412 | + return array("intval($a1)", ((isset($m[2]) and $m[2]) ? $m[2] : 0)); |
|
| 1413 | + } else { |
|
| 1414 | + return array("intval($a1)", 0); |
|
| 1415 | + } |
|
| 1416 | + } else { |
|
| 1417 | + preg_match(',^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$,', $param[0]->texte, $m); |
|
| 1418 | + $a1 = $m[1]; |
|
| 1419 | + if (empty($m[3])) { |
|
| 1420 | + return array($a1, 0); |
|
| 1421 | + } elseif (!empty($m[4])) { |
|
| 1422 | + return array($a1, $m[4]); |
|
| 1423 | + } else { |
|
| 1424 | + return array($a1, calculer_liste(array($param[1]), $idb, $boucles, $boucles[$idb]->id_parent)); |
|
| 1425 | + } |
|
| 1426 | + } |
|
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | 1429 | |
@@ -1450,47 +1450,47 @@ discard block |
||
| 1450 | 1450 | * array : Erreur sur un des critères |
| 1451 | 1451 | **/ |
| 1452 | 1452 | function calculer_criteres($idb, &$boucles) { |
| 1453 | - $msg = ''; |
|
| 1454 | - $boucle = $boucles[$idb]; |
|
| 1455 | - $table = strtoupper($boucle->type_requete); |
|
| 1456 | - $serveur = strtolower($boucle->sql_serveur); |
|
| 1457 | - |
|
| 1458 | - $defaut = charger_fonction('DEFAUT', 'calculer_critere'); |
|
| 1459 | - // s'il y avait une erreur de syntaxe, propager cette info |
|
| 1460 | - if (!is_array($boucle->criteres)) { |
|
| 1461 | - return array(); |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - foreach ($boucle->criteres as $crit) { |
|
| 1465 | - $critere = $crit->op; |
|
| 1466 | - // critere personnalise ? |
|
| 1467 | - if ( |
|
| 1468 | - (!$serveur or |
|
| 1469 | - ((!function_exists($f = "critere_" . $serveur . "_" . $table . "_" . $critere)) |
|
| 1470 | - and (!function_exists($f = $f . "_dist")) |
|
| 1471 | - and (!function_exists($f = "critere_" . $serveur . "_" . $critere)) |
|
| 1472 | - and (!function_exists($f = $f . "_dist")) |
|
| 1473 | - ) |
|
| 1474 | - ) |
|
| 1475 | - and (!function_exists($f = "critere_" . $table . "_" . $critere)) |
|
| 1476 | - and (!function_exists($f = $f . "_dist")) |
|
| 1477 | - and (!function_exists($f = "critere_" . $critere)) |
|
| 1478 | - and (!function_exists($f = $f . "_dist")) |
|
| 1479 | - ) { |
|
| 1480 | - // fonction critere standard |
|
| 1481 | - $f = $defaut; |
|
| 1482 | - } |
|
| 1483 | - // compile le critere |
|
| 1484 | - $res = $f($idb, $boucles, $crit); |
|
| 1485 | - |
|
| 1486 | - // Gestion centralisee des erreurs pour pouvoir propager |
|
| 1487 | - if (is_array($res)) { |
|
| 1488 | - $msg = $res; |
|
| 1489 | - erreur_squelette($msg, $boucle); |
|
| 1490 | - } |
|
| 1491 | - } |
|
| 1492 | - |
|
| 1493 | - return $msg; |
|
| 1453 | + $msg = ''; |
|
| 1454 | + $boucle = $boucles[$idb]; |
|
| 1455 | + $table = strtoupper($boucle->type_requete); |
|
| 1456 | + $serveur = strtolower($boucle->sql_serveur); |
|
| 1457 | + |
|
| 1458 | + $defaut = charger_fonction('DEFAUT', 'calculer_critere'); |
|
| 1459 | + // s'il y avait une erreur de syntaxe, propager cette info |
|
| 1460 | + if (!is_array($boucle->criteres)) { |
|
| 1461 | + return array(); |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + foreach ($boucle->criteres as $crit) { |
|
| 1465 | + $critere = $crit->op; |
|
| 1466 | + // critere personnalise ? |
|
| 1467 | + if ( |
|
| 1468 | + (!$serveur or |
|
| 1469 | + ((!function_exists($f = "critere_" . $serveur . "_" . $table . "_" . $critere)) |
|
| 1470 | + and (!function_exists($f = $f . "_dist")) |
|
| 1471 | + and (!function_exists($f = "critere_" . $serveur . "_" . $critere)) |
|
| 1472 | + and (!function_exists($f = $f . "_dist")) |
|
| 1473 | + ) |
|
| 1474 | + ) |
|
| 1475 | + and (!function_exists($f = "critere_" . $table . "_" . $critere)) |
|
| 1476 | + and (!function_exists($f = $f . "_dist")) |
|
| 1477 | + and (!function_exists($f = "critere_" . $critere)) |
|
| 1478 | + and (!function_exists($f = $f . "_dist")) |
|
| 1479 | + ) { |
|
| 1480 | + // fonction critere standard |
|
| 1481 | + $f = $defaut; |
|
| 1482 | + } |
|
| 1483 | + // compile le critere |
|
| 1484 | + $res = $f($idb, $boucles, $crit); |
|
| 1485 | + |
|
| 1486 | + // Gestion centralisee des erreurs pour pouvoir propager |
|
| 1487 | + if (is_array($res)) { |
|
| 1488 | + $msg = $res; |
|
| 1489 | + erreur_squelette($msg, $boucle); |
|
| 1490 | + } |
|
| 1491 | + } |
|
| 1492 | + |
|
| 1493 | + return $msg; |
|
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | /** |
@@ -1507,11 +1507,11 @@ discard block |
||
| 1507 | 1507 | * @return string Code compilé rééchappé |
| 1508 | 1508 | */ |
| 1509 | 1509 | function kwote($lisp, $serveur = '', $type = '') { |
| 1510 | - if (preg_match(_CODE_QUOTE, $lisp, $r)) { |
|
| 1511 | - return $r[1] . "\"" . sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]), $serveur, $type) . "\""; |
|
| 1512 | - } else { |
|
| 1513 | - return "sql_quote($lisp, '$serveur', '" . str_replace("'", "\\'", $type) . "')"; |
|
| 1514 | - } |
|
| 1510 | + if (preg_match(_CODE_QUOTE, $lisp, $r)) { |
|
| 1511 | + return $r[1] . "\"" . sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]), $serveur, $type) . "\""; |
|
| 1512 | + } else { |
|
| 1513 | + return "sql_quote($lisp, '$serveur', '" . str_replace("'", "\\'", $type) . "')"; |
|
| 1514 | + } |
|
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | 1517 | |
@@ -1530,85 +1530,85 @@ discard block |
||
| 1530 | 1530 | * @return void |
| 1531 | 1531 | **/ |
| 1532 | 1532 | function critere_IN_dist($idb, &$boucles, $crit) { |
| 1533 | - $r = calculer_critere_infixe($idb, $boucles, $crit); |
|
| 1534 | - if (!$r) { |
|
| 1535 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . " ?"))); |
|
| 1536 | - } |
|
| 1537 | - list($arg, $op, $val, $col, $where_complement) = $r; |
|
| 1538 | - |
|
| 1539 | - $in = critere_IN_cas($idb, $boucles, $crit->not ? 'NOT' : ($crit->exclus ? 'exclus' : ''), $arg, $op, $val, $col); |
|
| 1540 | - |
|
| 1541 | - // inserer la condition; exemple: {id_mot ?IN (66, 62, 64)} |
|
| 1542 | - $where = $in; |
|
| 1543 | - if ($crit->cond) { |
|
| 1544 | - $pred = calculer_argument_precedent($idb, $col, $boucles); |
|
| 1545 | - $where = array("'?'", $pred, $where, "''"); |
|
| 1546 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1547 | - { |
|
| 1548 | - $where_complement = array("'?'", $pred, $where_complement, "''"); |
|
| 1549 | - } |
|
| 1550 | - } |
|
| 1551 | - if ($crit->exclus) { |
|
| 1552 | - if (!preg_match(",^L[0-9]+[.],", $arg)) { |
|
| 1553 | - $where = array("'NOT'", $where); |
|
| 1554 | - } else |
|
| 1555 | - // un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete |
|
| 1556 | - // c'est une sous requete identique a la requete principale sous la forme (SELF,$select,$where) avec $select et $where qui surchargent |
|
| 1557 | - { |
|
| 1558 | - $where = array( |
|
| 1559 | - "'NOT'", |
|
| 1560 | - array( |
|
| 1561 | - "'IN'", |
|
| 1562 | - "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", |
|
| 1563 | - array("'SELF'", "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", $where) |
|
| 1564 | - ) |
|
| 1565 | - ); |
|
| 1566 | - } |
|
| 1567 | - } |
|
| 1568 | - |
|
| 1569 | - $boucles[$idb]->where[] = $where; |
|
| 1570 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1571 | - { |
|
| 1572 | - $boucles[$idb]->where[] = $where_complement; |
|
| 1573 | - } |
|
| 1533 | + $r = calculer_critere_infixe($idb, $boucles, $crit); |
|
| 1534 | + if (!$r) { |
|
| 1535 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op . " ?"))); |
|
| 1536 | + } |
|
| 1537 | + list($arg, $op, $val, $col, $where_complement) = $r; |
|
| 1538 | + |
|
| 1539 | + $in = critere_IN_cas($idb, $boucles, $crit->not ? 'NOT' : ($crit->exclus ? 'exclus' : ''), $arg, $op, $val, $col); |
|
| 1540 | + |
|
| 1541 | + // inserer la condition; exemple: {id_mot ?IN (66, 62, 64)} |
|
| 1542 | + $where = $in; |
|
| 1543 | + if ($crit->cond) { |
|
| 1544 | + $pred = calculer_argument_precedent($idb, $col, $boucles); |
|
| 1545 | + $where = array("'?'", $pred, $where, "''"); |
|
| 1546 | + if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1547 | + { |
|
| 1548 | + $where_complement = array("'?'", $pred, $where_complement, "''"); |
|
| 1549 | + } |
|
| 1550 | + } |
|
| 1551 | + if ($crit->exclus) { |
|
| 1552 | + if (!preg_match(",^L[0-9]+[.],", $arg)) { |
|
| 1553 | + $where = array("'NOT'", $where); |
|
| 1554 | + } else |
|
| 1555 | + // un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete |
|
| 1556 | + // c'est une sous requete identique a la requete principale sous la forme (SELF,$select,$where) avec $select et $where qui surchargent |
|
| 1557 | + { |
|
| 1558 | + $where = array( |
|
| 1559 | + "'NOT'", |
|
| 1560 | + array( |
|
| 1561 | + "'IN'", |
|
| 1562 | + "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", |
|
| 1563 | + array("'SELF'", "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", $where) |
|
| 1564 | + ) |
|
| 1565 | + ); |
|
| 1566 | + } |
|
| 1567 | + } |
|
| 1568 | + |
|
| 1569 | + $boucles[$idb]->where[] = $where; |
|
| 1570 | + if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1571 | + { |
|
| 1572 | + $boucles[$idb]->where[] = $where_complement; |
|
| 1573 | + } |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | // https://code.spip.net/@critere_IN_cas |
| 1577 | 1577 | function critere_IN_cas($idb, &$boucles, $crit2, $arg, $op, $val, $col) { |
| 1578 | - static $num = array(); |
|
| 1579 | - $descr = $boucles[$idb]->descr; |
|
| 1580 | - $cpt = &$num[$descr['nom']][$descr['gram']][$idb]; |
|
| 1581 | - |
|
| 1582 | - $var = '$in' . $cpt++; |
|
| 1583 | - $x = "\n\t$var = array();"; |
|
| 1584 | - foreach ($val as $k => $v) { |
|
| 1585 | - if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)) { |
|
| 1586 | - // optimiser le traitement des constantes |
|
| 1587 | - if (is_numeric($r[2])) { |
|
| 1588 | - $x .= "\n\t$var" . "[]= $r[2];"; |
|
| 1589 | - } else { |
|
| 1590 | - $x .= "\n\t$var" . "[]= " . sql_quote($r[2]) . ";"; |
|
| 1591 | - } |
|
| 1592 | - } else { |
|
| 1593 | - // Pour permettre de passer des tableaux de valeurs |
|
| 1594 | - // on repere l'utilisation brute de #ENV**{X}, |
|
| 1595 | - // c'est-a-dire sa traduction en ($PILE[0][X]). |
|
| 1596 | - // et on deballe mais en rajoutant l'anti XSS |
|
| 1597 | - $x .= "\n\tif (!(is_array(\$a = ($v))))\n\t\t$var" . "[]= \$a;\n\telse $var = array_merge($var, \$a);"; |
|
| 1598 | - } |
|
| 1599 | - } |
|
| 1600 | - |
|
| 1601 | - $boucles[$idb]->in .= $x; |
|
| 1602 | - |
|
| 1603 | - // inserer le tri par defaut selon les ordres du IN ... |
|
| 1604 | - // avec une ecriture de type FIELD qui degrade les performances (du meme ordre qu'un regexp) |
|
| 1605 | - // et que l'on limite donc strictement aux cas necessaires : |
|
| 1606 | - // si ce n'est pas un !IN, et si il n'y a pas d'autre order dans la boucle |
|
| 1607 | - if (!$crit2) { |
|
| 1608 | - $boucles[$idb]->default_order[] = "((!\$zqv=sql_quote($var) OR \$zqv===\"''\") ? 0 : ('FIELD($arg,' . \$zqv . ')'))"; |
|
| 1609 | - } |
|
| 1610 | - |
|
| 1611 | - return "sql_in('$arg', $var" . ($crit2 == 'NOT' ? ",'NOT'" : "") . ")"; |
|
| 1578 | + static $num = array(); |
|
| 1579 | + $descr = $boucles[$idb]->descr; |
|
| 1580 | + $cpt = &$num[$descr['nom']][$descr['gram']][$idb]; |
|
| 1581 | + |
|
| 1582 | + $var = '$in' . $cpt++; |
|
| 1583 | + $x = "\n\t$var = array();"; |
|
| 1584 | + foreach ($val as $k => $v) { |
|
| 1585 | + if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)) { |
|
| 1586 | + // optimiser le traitement des constantes |
|
| 1587 | + if (is_numeric($r[2])) { |
|
| 1588 | + $x .= "\n\t$var" . "[]= $r[2];"; |
|
| 1589 | + } else { |
|
| 1590 | + $x .= "\n\t$var" . "[]= " . sql_quote($r[2]) . ";"; |
|
| 1591 | + } |
|
| 1592 | + } else { |
|
| 1593 | + // Pour permettre de passer des tableaux de valeurs |
|
| 1594 | + // on repere l'utilisation brute de #ENV**{X}, |
|
| 1595 | + // c'est-a-dire sa traduction en ($PILE[0][X]). |
|
| 1596 | + // et on deballe mais en rajoutant l'anti XSS |
|
| 1597 | + $x .= "\n\tif (!(is_array(\$a = ($v))))\n\t\t$var" . "[]= \$a;\n\telse $var = array_merge($var, \$a);"; |
|
| 1598 | + } |
|
| 1599 | + } |
|
| 1600 | + |
|
| 1601 | + $boucles[$idb]->in .= $x; |
|
| 1602 | + |
|
| 1603 | + // inserer le tri par defaut selon les ordres du IN ... |
|
| 1604 | + // avec une ecriture de type FIELD qui degrade les performances (du meme ordre qu'un regexp) |
|
| 1605 | + // et que l'on limite donc strictement aux cas necessaires : |
|
| 1606 | + // si ce n'est pas un !IN, et si il n'y a pas d'autre order dans la boucle |
|
| 1607 | + if (!$crit2) { |
|
| 1608 | + $boucles[$idb]->default_order[] = "((!\$zqv=sql_quote($var) OR \$zqv===\"''\") ? 0 : ('FIELD($arg,' . \$zqv . ')'))"; |
|
| 1609 | + } |
|
| 1610 | + |
|
| 1611 | + return "sql_in('$arg', $var" . ($crit2 == 'NOT' ? ",'NOT'" : "") . ")"; |
|
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | /** |
@@ -1624,22 +1624,22 @@ discard block |
||
| 1624 | 1624 | * @return void |
| 1625 | 1625 | */ |
| 1626 | 1626 | function critere_where_dist($idb, &$boucles, $crit) { |
| 1627 | - $boucle = &$boucles[$idb]; |
|
| 1628 | - if (isset($crit->param[0])) { |
|
| 1629 | - $_where = calculer_liste($crit->param[0], $idb, $boucles, $boucle->id_parent); |
|
| 1630 | - } else { |
|
| 1631 | - $_where = 'spip_sanitize_from_request(@$Pile[0]["where"],"where","vide")'; |
|
| 1632 | - } |
|
| 1633 | - |
|
| 1634 | - if ($crit->cond) { |
|
| 1635 | - $_where = "((\$zzw = $_where) ? \$zzw : '')"; |
|
| 1636 | - } |
|
| 1637 | - |
|
| 1638 | - if ($crit->not) { |
|
| 1639 | - $_where = "array('NOT',$_where)"; |
|
| 1640 | - } |
|
| 1641 | - |
|
| 1642 | - $boucle->where[] = $_where; |
|
| 1627 | + $boucle = &$boucles[$idb]; |
|
| 1628 | + if (isset($crit->param[0])) { |
|
| 1629 | + $_where = calculer_liste($crit->param[0], $idb, $boucles, $boucle->id_parent); |
|
| 1630 | + } else { |
|
| 1631 | + $_where = 'spip_sanitize_from_request(@$Pile[0]["where"],"where","vide")'; |
|
| 1632 | + } |
|
| 1633 | + |
|
| 1634 | + if ($crit->cond) { |
|
| 1635 | + $_where = "((\$zzw = $_where) ? \$zzw : '')"; |
|
| 1636 | + } |
|
| 1637 | + |
|
| 1638 | + if ($crit->not) { |
|
| 1639 | + $_where = "array('NOT',$_where)"; |
|
| 1640 | + } |
|
| 1641 | + |
|
| 1642 | + $boucle->where[] = $_where; |
|
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | 1645 | /** |
@@ -1667,31 +1667,31 @@ discard block |
||
| 1667 | 1667 | * @return void |
| 1668 | 1668 | */ |
| 1669 | 1669 | function critere_id__dist($idb, &$boucles, $crit) { |
| 1670 | - /** @var Boucle $boucle */ |
|
| 1671 | - $boucle = $boucles[$idb]; |
|
| 1672 | - |
|
| 1673 | - $champs = lister_champs_id_conditionnel( |
|
| 1674 | - $boucle->show['table'], |
|
| 1675 | - $boucle->show, |
|
| 1676 | - $boucle->sql_serveur |
|
| 1677 | - ); |
|
| 1678 | - |
|
| 1679 | - // ne pas tenir compte des critères identiques déjà présents. |
|
| 1680 | - if (!empty($boucle->modificateur['criteres'])) { |
|
| 1681 | - $champs = array_diff($champs, array_keys($boucle->modificateur['criteres'])); |
|
| 1682 | - } |
|
| 1683 | - // nous aider en mode debug. |
|
| 1684 | - $boucle->debug[] = "id_ : " . implode(', ', $champs); |
|
| 1685 | - $boucle->modificateur['id_'] = $champs; |
|
| 1686 | - |
|
| 1687 | - // créer un critère {id_xxx?} de chaque champ retenu |
|
| 1688 | - foreach ($champs as $champ) { |
|
| 1689 | - $critere_id_table = new Critere; |
|
| 1690 | - $critere_id_table->op = $champ; |
|
| 1691 | - $critere_id_table->cond = '?'; |
|
| 1692 | - $critere_id_table->ligne = $crit->ligne; |
|
| 1693 | - calculer_critere_DEFAUT_dist($idb, $boucles, $critere_id_table); |
|
| 1694 | - } |
|
| 1670 | + /** @var Boucle $boucle */ |
|
| 1671 | + $boucle = $boucles[$idb]; |
|
| 1672 | + |
|
| 1673 | + $champs = lister_champs_id_conditionnel( |
|
| 1674 | + $boucle->show['table'], |
|
| 1675 | + $boucle->show, |
|
| 1676 | + $boucle->sql_serveur |
|
| 1677 | + ); |
|
| 1678 | + |
|
| 1679 | + // ne pas tenir compte des critères identiques déjà présents. |
|
| 1680 | + if (!empty($boucle->modificateur['criteres'])) { |
|
| 1681 | + $champs = array_diff($champs, array_keys($boucle->modificateur['criteres'])); |
|
| 1682 | + } |
|
| 1683 | + // nous aider en mode debug. |
|
| 1684 | + $boucle->debug[] = "id_ : " . implode(', ', $champs); |
|
| 1685 | + $boucle->modificateur['id_'] = $champs; |
|
| 1686 | + |
|
| 1687 | + // créer un critère {id_xxx?} de chaque champ retenu |
|
| 1688 | + foreach ($champs as $champ) { |
|
| 1689 | + $critere_id_table = new Critere; |
|
| 1690 | + $critere_id_table->op = $champ; |
|
| 1691 | + $critere_id_table->cond = '?'; |
|
| 1692 | + $critere_id_table->ligne = $crit->ligne; |
|
| 1693 | + calculer_critere_DEFAUT_dist($idb, $boucles, $critere_id_table); |
|
| 1694 | + } |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | 1697 | /** |
@@ -1711,79 +1711,79 @@ discard block |
||
| 1711 | 1711 | * @return array Liste de nom de champs (tel que id_article, id_mot, id_parent ...) |
| 1712 | 1712 | */ |
| 1713 | 1713 | function lister_champs_id_conditionnel($table, $desc = null, $serveur = '') { |
| 1714 | - // calculer la description de la table |
|
| 1715 | - if (!is_array($desc)) { |
|
| 1716 | - $desc = description_table($table, $serveur); |
|
| 1717 | - } |
|
| 1718 | - if (!$desc) { |
|
| 1719 | - return []; |
|
| 1720 | - } |
|
| 1721 | - |
|
| 1722 | - // Les champs id_xx de la table demandée |
|
| 1723 | - $champs = array_filter( |
|
| 1724 | - array_keys($desc['field']), |
|
| 1725 | - function($champ){ |
|
| 1726 | - return |
|
| 1727 | - strpos($champ, 'id_') === 0 |
|
| 1728 | - or (in_array($champ, array('objet'))); |
|
| 1729 | - } |
|
| 1730 | - ); |
|
| 1731 | - |
|
| 1732 | - // Si le champ id_rubrique appartient à la liste et si id_secteur n'est pas inclus on le rajoute. |
|
| 1733 | - if ( |
|
| 1734 | - in_array('id_rubrique', $champs) |
|
| 1735 | - and !in_array('id_secteur', $champs) |
|
| 1736 | - ) { |
|
| 1737 | - $champs[] = 'id_secteur'; |
|
| 1738 | - } |
|
| 1739 | - |
|
| 1740 | - // On ne fera pas mieux pour les tables d’un autre serveur |
|
| 1741 | - if ($serveur) { |
|
| 1742 | - return $champs; |
|
| 1743 | - } |
|
| 1744 | - |
|
| 1745 | - $primary = false; |
|
| 1746 | - $associable = false; |
|
| 1747 | - include_spip('action/editer_liens'); |
|
| 1748 | - |
|
| 1749 | - if (isset($desc['type'])) { |
|
| 1750 | - $primary = id_table_objet($desc['type']); |
|
| 1751 | - $associable = objet_associable($desc['type']); |
|
| 1752 | - } |
|
| 1753 | - if (isset($desc['field']['id_objet']) and isset($desc['field']['objet'])) { |
|
| 1754 | - $associable = true; |
|
| 1755 | - } |
|
| 1756 | - |
|
| 1757 | - // liste de toutes les tables principales, sauf la notre |
|
| 1758 | - $tables = lister_tables_objets_sql(); |
|
| 1759 | - unset($tables[$table]); |
|
| 1760 | - |
|
| 1761 | - foreach ($tables as $_table => $_desc) { |
|
| 1762 | - if ( |
|
| 1763 | - $associable |
|
| 1764 | - or ($primary and in_array($primary, array_keys($_desc['field']))) |
|
| 1765 | - or objet_associable($_desc['type']) |
|
| 1766 | - ) { |
|
| 1767 | - $champs[] = id_table_objet($_table); |
|
| 1768 | - } |
|
| 1769 | - } |
|
| 1770 | - $champs = array_values(array_unique($champs)); |
|
| 1771 | - |
|
| 1772 | - // Exclusions de certains id |
|
| 1773 | - $exclusions = pipeline( |
|
| 1774 | - 'exclure_id_conditionnel', |
|
| 1775 | - array( |
|
| 1776 | - 'args' => array( |
|
| 1777 | - 'table' => $table, |
|
| 1778 | - 'id_table_objet' => $primary, |
|
| 1779 | - 'associable' => $associable, |
|
| 1780 | - ), |
|
| 1781 | - 'data' => array(), |
|
| 1782 | - ) |
|
| 1783 | - ); |
|
| 1784 | - $champs = array_diff($champs, $exclusions); |
|
| 1785 | - |
|
| 1786 | - return $champs; |
|
| 1714 | + // calculer la description de la table |
|
| 1715 | + if (!is_array($desc)) { |
|
| 1716 | + $desc = description_table($table, $serveur); |
|
| 1717 | + } |
|
| 1718 | + if (!$desc) { |
|
| 1719 | + return []; |
|
| 1720 | + } |
|
| 1721 | + |
|
| 1722 | + // Les champs id_xx de la table demandée |
|
| 1723 | + $champs = array_filter( |
|
| 1724 | + array_keys($desc['field']), |
|
| 1725 | + function($champ){ |
|
| 1726 | + return |
|
| 1727 | + strpos($champ, 'id_') === 0 |
|
| 1728 | + or (in_array($champ, array('objet'))); |
|
| 1729 | + } |
|
| 1730 | + ); |
|
| 1731 | + |
|
| 1732 | + // Si le champ id_rubrique appartient à la liste et si id_secteur n'est pas inclus on le rajoute. |
|
| 1733 | + if ( |
|
| 1734 | + in_array('id_rubrique', $champs) |
|
| 1735 | + and !in_array('id_secteur', $champs) |
|
| 1736 | + ) { |
|
| 1737 | + $champs[] = 'id_secteur'; |
|
| 1738 | + } |
|
| 1739 | + |
|
| 1740 | + // On ne fera pas mieux pour les tables d’un autre serveur |
|
| 1741 | + if ($serveur) { |
|
| 1742 | + return $champs; |
|
| 1743 | + } |
|
| 1744 | + |
|
| 1745 | + $primary = false; |
|
| 1746 | + $associable = false; |
|
| 1747 | + include_spip('action/editer_liens'); |
|
| 1748 | + |
|
| 1749 | + if (isset($desc['type'])) { |
|
| 1750 | + $primary = id_table_objet($desc['type']); |
|
| 1751 | + $associable = objet_associable($desc['type']); |
|
| 1752 | + } |
|
| 1753 | + if (isset($desc['field']['id_objet']) and isset($desc['field']['objet'])) { |
|
| 1754 | + $associable = true; |
|
| 1755 | + } |
|
| 1756 | + |
|
| 1757 | + // liste de toutes les tables principales, sauf la notre |
|
| 1758 | + $tables = lister_tables_objets_sql(); |
|
| 1759 | + unset($tables[$table]); |
|
| 1760 | + |
|
| 1761 | + foreach ($tables as $_table => $_desc) { |
|
| 1762 | + if ( |
|
| 1763 | + $associable |
|
| 1764 | + or ($primary and in_array($primary, array_keys($_desc['field']))) |
|
| 1765 | + or objet_associable($_desc['type']) |
|
| 1766 | + ) { |
|
| 1767 | + $champs[] = id_table_objet($_table); |
|
| 1768 | + } |
|
| 1769 | + } |
|
| 1770 | + $champs = array_values(array_unique($champs)); |
|
| 1771 | + |
|
| 1772 | + // Exclusions de certains id |
|
| 1773 | + $exclusions = pipeline( |
|
| 1774 | + 'exclure_id_conditionnel', |
|
| 1775 | + array( |
|
| 1776 | + 'args' => array( |
|
| 1777 | + 'table' => $table, |
|
| 1778 | + 'id_table_objet' => $primary, |
|
| 1779 | + 'associable' => $associable, |
|
| 1780 | + ), |
|
| 1781 | + 'data' => array(), |
|
| 1782 | + ) |
|
| 1783 | + ); |
|
| 1784 | + $champs = array_diff($champs, $exclusions); |
|
| 1785 | + |
|
| 1786 | + return $champs; |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | 1789 | /** |
@@ -1838,27 +1838,27 @@ discard block |
||
| 1838 | 1838 | * @return void |
| 1839 | 1839 | */ |
| 1840 | 1840 | function critere_tri_dist($idb, &$boucles, $crit) { |
| 1841 | - $boucle = &$boucles[$idb]; |
|
| 1842 | - |
|
| 1843 | - // definition du champ par defaut |
|
| 1844 | - $_champ_defaut = !isset($crit->param[0][0]) ? "''" |
|
| 1845 | - : calculer_liste(array($crit->param[0][0]), $idb, $boucles, $boucle->id_parent); |
|
| 1846 | - $_sens_defaut = !isset($crit->param[1][0]) ? "1" |
|
| 1847 | - : calculer_liste(array($crit->param[1][0]), $idb, $boucles, $boucle->id_parent); |
|
| 1848 | - $_variable = !isset($crit->param[2][0]) ? "'$idb'" |
|
| 1849 | - : calculer_liste(array($crit->param[2][0]), $idb, $boucles, $boucle->id_parent); |
|
| 1850 | - |
|
| 1851 | - $_tri = "((\$t=(isset(\$Pile[0]['tri'.$_variable]))?\$Pile[0]['tri'.$_variable]:((strncmp($_variable,'session',7)==0 AND session_get('tri'.$_variable))?session_get('tri'.$_variable):$_champ_defaut))?tri_protege_champ(\$t):'')"; |
|
| 1852 | - |
|
| 1853 | - $_sens_defaut = "(is_array(\$s=$_sens_defaut)?(isset(\$s[\$st=$_tri])?\$s[\$st]:reset(\$s)):\$s)"; |
|
| 1854 | - $_sens = "((intval(\$t=(isset(\$Pile[0]['sens'.$_variable]))?\$Pile[0]['sens'.$_variable]:((strncmp($_variable,'session',7)==0 AND session_get('sens'.$_variable))?session_get('sens'.$_variable):$_sens_defaut))==-1 OR \$t=='inverse')?-1:1)"; |
|
| 1855 | - |
|
| 1856 | - $boucle->modificateur['tri_champ'] = $_tri; |
|
| 1857 | - $boucle->modificateur['tri_sens'] = $_sens; |
|
| 1858 | - $boucle->modificateur['tri_nom'] = $_variable; |
|
| 1859 | - // faut il inserer un test sur l'existence de $tri parmi les champs de la table ? |
|
| 1860 | - // evite des erreurs sql, mais peut empecher des tri sur jointure ... |
|
| 1861 | - $boucle->hash .= " |
|
| 1841 | + $boucle = &$boucles[$idb]; |
|
| 1842 | + |
|
| 1843 | + // definition du champ par defaut |
|
| 1844 | + $_champ_defaut = !isset($crit->param[0][0]) ? "''" |
|
| 1845 | + : calculer_liste(array($crit->param[0][0]), $idb, $boucles, $boucle->id_parent); |
|
| 1846 | + $_sens_defaut = !isset($crit->param[1][0]) ? "1" |
|
| 1847 | + : calculer_liste(array($crit->param[1][0]), $idb, $boucles, $boucle->id_parent); |
|
| 1848 | + $_variable = !isset($crit->param[2][0]) ? "'$idb'" |
|
| 1849 | + : calculer_liste(array($crit->param[2][0]), $idb, $boucles, $boucle->id_parent); |
|
| 1850 | + |
|
| 1851 | + $_tri = "((\$t=(isset(\$Pile[0]['tri'.$_variable]))?\$Pile[0]['tri'.$_variable]:((strncmp($_variable,'session',7)==0 AND session_get('tri'.$_variable))?session_get('tri'.$_variable):$_champ_defaut))?tri_protege_champ(\$t):'')"; |
|
| 1852 | + |
|
| 1853 | + $_sens_defaut = "(is_array(\$s=$_sens_defaut)?(isset(\$s[\$st=$_tri])?\$s[\$st]:reset(\$s)):\$s)"; |
|
| 1854 | + $_sens = "((intval(\$t=(isset(\$Pile[0]['sens'.$_variable]))?\$Pile[0]['sens'.$_variable]:((strncmp($_variable,'session',7)==0 AND session_get('sens'.$_variable))?session_get('sens'.$_variable):$_sens_defaut))==-1 OR \$t=='inverse')?-1:1)"; |
|
| 1855 | + |
|
| 1856 | + $boucle->modificateur['tri_champ'] = $_tri; |
|
| 1857 | + $boucle->modificateur['tri_sens'] = $_sens; |
|
| 1858 | + $boucle->modificateur['tri_nom'] = $_variable; |
|
| 1859 | + // faut il inserer un test sur l'existence de $tri parmi les champs de la table ? |
|
| 1860 | + // evite des erreurs sql, mais peut empecher des tri sur jointure ... |
|
| 1861 | + $boucle->hash .= " |
|
| 1862 | 1862 | \$senstri = ''; |
| 1863 | 1863 | \$tri = $_tri; |
| 1864 | 1864 | if (\$tri){ |
@@ -1866,8 +1866,8 @@ discard block |
||
| 1866 | 1866 | \$senstri = (\$senstri<0)?' DESC':''; |
| 1867 | 1867 | }; |
| 1868 | 1868 | "; |
| 1869 | - $boucle->select[] = "\".tri_champ_select(\$tri).\""; |
|
| 1870 | - $boucle->order[] = "tri_champ_order(\$tri,\$command['from'],\$senstri)"; |
|
| 1869 | + $boucle->select[] = "\".tri_champ_select(\$tri).\""; |
|
| 1870 | + $boucle->order[] = "tri_champ_order(\$tri,\$command['from'],\$senstri)"; |
|
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | 1873 | # Criteres de comparaison |
@@ -1884,20 +1884,20 @@ discard block |
||
| 1884 | 1884 | * @return void |
| 1885 | 1885 | **/ |
| 1886 | 1886 | function calculer_critere_DEFAUT_dist($idb, &$boucles, $crit) { |
| 1887 | - // double cas particulier {0,1} et {1/2} repere a l'analyse lexicale |
|
| 1888 | - if (($crit->op == ",") or ($crit->op == '/')) { |
|
| 1889 | - return calculer_critere_parties($idb, $boucles, $crit); |
|
| 1890 | - } |
|
| 1891 | - |
|
| 1892 | - $r = calculer_critere_infixe($idb, $boucles, $crit); |
|
| 1893 | - if (!$r) { |
|
| 1894 | - # // on produit une erreur seulement si le critere n'a pas de '?' |
|
| 1895 | - # if (!$crit->cond) { |
|
| 1896 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op))); |
|
| 1897 | - # } |
|
| 1898 | - } else { |
|
| 1899 | - calculer_critere_DEFAUT_args($idb, $boucles, $crit, $r); |
|
| 1900 | - } |
|
| 1887 | + // double cas particulier {0,1} et {1/2} repere a l'analyse lexicale |
|
| 1888 | + if (($crit->op == ",") or ($crit->op == '/')) { |
|
| 1889 | + return calculer_critere_parties($idb, $boucles, $crit); |
|
| 1890 | + } |
|
| 1891 | + |
|
| 1892 | + $r = calculer_critere_infixe($idb, $boucles, $crit); |
|
| 1893 | + if (!$r) { |
|
| 1894 | + # // on produit une erreur seulement si le critere n'a pas de '?' |
|
| 1895 | + # if (!$crit->cond) { |
|
| 1896 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op))); |
|
| 1897 | + # } |
|
| 1898 | + } else { |
|
| 1899 | + calculer_critere_DEFAUT_args($idb, $boucles, $crit, $r); |
|
| 1900 | + } |
|
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | 1903 | |
@@ -1917,63 +1917,63 @@ discard block |
||
| 1917 | 1917 | * @return void |
| 1918 | 1918 | **/ |
| 1919 | 1919 | function calculer_critere_DEFAUT_args($idb, &$boucles, $crit, $args) { |
| 1920 | - list($arg, $op, $val, $col, $where_complement) = $args; |
|
| 1921 | - |
|
| 1922 | - $where = array("'$op'", "'$arg'", $val[0]); |
|
| 1923 | - |
|
| 1924 | - // inserer la negation (cf !...) |
|
| 1925 | - |
|
| 1926 | - if ($crit->not) { |
|
| 1927 | - $where = array("'NOT'", $where); |
|
| 1928 | - } |
|
| 1929 | - if ($crit->exclus) { |
|
| 1930 | - if (!preg_match(",^L[0-9]+[.],", $arg)) { |
|
| 1931 | - $where = array("'NOT'", $where); |
|
| 1932 | - } else |
|
| 1933 | - // un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete |
|
| 1934 | - // c'est une sous requete identique a la requete principale sous la forme (SELF,$select,$where) avec $select et $where qui surchargent |
|
| 1935 | - { |
|
| 1936 | - $where = array( |
|
| 1937 | - "'NOT'", |
|
| 1938 | - array( |
|
| 1939 | - "'IN'", |
|
| 1940 | - "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", |
|
| 1941 | - array("'SELF'", "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", $where) |
|
| 1942 | - ) |
|
| 1943 | - ); |
|
| 1944 | - } |
|
| 1945 | - } |
|
| 1946 | - |
|
| 1947 | - // inserer la condition (cf {lang?}) |
|
| 1948 | - // traiter a part la date, elle est mise d'office par SPIP, |
|
| 1949 | - if ($crit->cond) { |
|
| 1950 | - $pred = calculer_argument_precedent($idb, $col, $boucles); |
|
| 1951 | - if ($col == "date" or $col == "date_redac") { |
|
| 1952 | - if ($pred == "\$Pile[0]['" . $col . "']") { |
|
| 1953 | - $pred = "(\$Pile[0]['{$col}_default']?'':$pred)"; |
|
| 1954 | - } |
|
| 1955 | - } |
|
| 1956 | - |
|
| 1957 | - if ($op == '=' and !$crit->not) { |
|
| 1958 | - $where = array( |
|
| 1959 | - "'?'", |
|
| 1960 | - "(is_array($pred))", |
|
| 1961 | - critere_IN_cas($idb, $boucles, 'COND', $arg, $op, array($pred), $col), |
|
| 1962 | - $where |
|
| 1963 | - ); |
|
| 1964 | - } |
|
| 1965 | - $where = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where); |
|
| 1966 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1967 | - { |
|
| 1968 | - $where_complement = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where_complement); |
|
| 1969 | - } |
|
| 1970 | - } |
|
| 1971 | - |
|
| 1972 | - $boucles[$idb]->where[] = $where; |
|
| 1973 | - if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1974 | - { |
|
| 1975 | - $boucles[$idb]->where[] = $where_complement; |
|
| 1976 | - } |
|
| 1920 | + list($arg, $op, $val, $col, $where_complement) = $args; |
|
| 1921 | + |
|
| 1922 | + $where = array("'$op'", "'$arg'", $val[0]); |
|
| 1923 | + |
|
| 1924 | + // inserer la negation (cf !...) |
|
| 1925 | + |
|
| 1926 | + if ($crit->not) { |
|
| 1927 | + $where = array("'NOT'", $where); |
|
| 1928 | + } |
|
| 1929 | + if ($crit->exclus) { |
|
| 1930 | + if (!preg_match(",^L[0-9]+[.],", $arg)) { |
|
| 1931 | + $where = array("'NOT'", $where); |
|
| 1932 | + } else |
|
| 1933 | + // un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete |
|
| 1934 | + // c'est une sous requete identique a la requete principale sous la forme (SELF,$select,$where) avec $select et $where qui surchargent |
|
| 1935 | + { |
|
| 1936 | + $where = array( |
|
| 1937 | + "'NOT'", |
|
| 1938 | + array( |
|
| 1939 | + "'IN'", |
|
| 1940 | + "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", |
|
| 1941 | + array("'SELF'", "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", $where) |
|
| 1942 | + ) |
|
| 1943 | + ); |
|
| 1944 | + } |
|
| 1945 | + } |
|
| 1946 | + |
|
| 1947 | + // inserer la condition (cf {lang?}) |
|
| 1948 | + // traiter a part la date, elle est mise d'office par SPIP, |
|
| 1949 | + if ($crit->cond) { |
|
| 1950 | + $pred = calculer_argument_precedent($idb, $col, $boucles); |
|
| 1951 | + if ($col == "date" or $col == "date_redac") { |
|
| 1952 | + if ($pred == "\$Pile[0]['" . $col . "']") { |
|
| 1953 | + $pred = "(\$Pile[0]['{$col}_default']?'':$pred)"; |
|
| 1954 | + } |
|
| 1955 | + } |
|
| 1956 | + |
|
| 1957 | + if ($op == '=' and !$crit->not) { |
|
| 1958 | + $where = array( |
|
| 1959 | + "'?'", |
|
| 1960 | + "(is_array($pred))", |
|
| 1961 | + critere_IN_cas($idb, $boucles, 'COND', $arg, $op, array($pred), $col), |
|
| 1962 | + $where |
|
| 1963 | + ); |
|
| 1964 | + } |
|
| 1965 | + $where = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where); |
|
| 1966 | + if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1967 | + { |
|
| 1968 | + $where_complement = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where_complement); |
|
| 1969 | + } |
|
| 1970 | + } |
|
| 1971 | + |
|
| 1972 | + $boucles[$idb]->where[] = $where; |
|
| 1973 | + if ($where_complement) // condition annexe du type "AND (objet='article')" |
|
| 1974 | + { |
|
| 1975 | + $boucles[$idb]->where[] = $where_complement; |
|
| 1976 | + } |
|
| 1977 | 1977 | } |
| 1978 | 1978 | |
| 1979 | 1979 | |
@@ -2014,158 +2014,158 @@ discard block |
||
| 2014 | 2014 | **/ |
| 2015 | 2015 | function calculer_critere_infixe($idb, &$boucles, $crit) { |
| 2016 | 2016 | |
| 2017 | - $boucle = &$boucles[$idb]; |
|
| 2018 | - $type = $boucle->type_requete; |
|
| 2019 | - $table = $boucle->id_table; |
|
| 2020 | - $desc = $boucle->show; |
|
| 2021 | - $col_vraie = null; |
|
| 2022 | - |
|
| 2023 | - list($fct, $col, $op, $val, $args_sql) = |
|
| 2024 | - calculer_critere_infixe_ops($idb, $boucles, $crit); |
|
| 2025 | - |
|
| 2026 | - $col_alias = $col; |
|
| 2027 | - $where_complement = false; |
|
| 2028 | - |
|
| 2029 | - // Cas particulier : id_enfant => utiliser la colonne id_objet |
|
| 2030 | - if ($col == 'id_enfant') { |
|
| 2031 | - $col = $boucle->primary; |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - // Cas particulier : id_parent => verifier les exceptions de tables |
|
| 2035 | - if ((in_array($col, array('id_parent', 'id_secteur')) and isset($GLOBALS['exceptions_des_tables'][$table][$col])) |
|
| 2036 | - or (isset($GLOBALS['exceptions_des_tables'][$table][$col]) and is_string($GLOBALS['exceptions_des_tables'][$table][$col])) |
|
| 2037 | - ) { |
|
| 2038 | - $col = $GLOBALS['exceptions_des_tables'][$table][$col]; |
|
| 2039 | - } // et possibilite de gerer un critere secteur sur des tables de plugins (ie forums) |
|
| 2040 | - else { |
|
| 2041 | - if (($col == 'id_secteur') and ($critere_secteur = charger_fonction("critere_secteur_$type", "public", true))) { |
|
| 2042 | - $table = $critere_secteur($idb, $boucles, $val, $crit); |
|
| 2043 | - } |
|
| 2044 | - |
|
| 2045 | - // cas id_article=xx qui se mappe en id_objet=xx AND objet=article |
|
| 2046 | - // sauf si exception declaree : sauter cette etape |
|
| 2047 | - else { |
|
| 2048 | - if ( |
|
| 2049 | - !isset($GLOBALS['exceptions_des_jointures'][table_objet_sql($table)][$col]) |
|
| 2050 | - and !isset($GLOBALS['exceptions_des_jointures'][$col]) |
|
| 2051 | - and count(trouver_champs_decomposes($col, $desc)) > 1 |
|
| 2052 | - ) { |
|
| 2053 | - $e = decompose_champ_id_objet($col); |
|
| 2054 | - $col = array_shift($e); |
|
| 2055 | - $where_complement = primary_doublee($e, $table); |
|
| 2056 | - } // Cas particulier : expressions de date |
|
| 2057 | - else { |
|
| 2058 | - if ($c = calculer_critere_infixe_date($idb, $boucles, $col)) { |
|
| 2059 | - list($col, $col_vraie) = $c; |
|
| 2060 | - $table = ''; |
|
| 2061 | - } // table explicitée {mots.titre} |
|
| 2062 | - else { |
|
| 2063 | - if (preg_match('/^(.*)\.(.*)$/', $col, $r)) { |
|
| 2064 | - list(, $table, $col) = $r; |
|
| 2065 | - $col_alias = $col; |
|
| 2066 | - |
|
| 2067 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 2068 | - if ($desc = $trouver_table($table, $boucle->sql_serveur) |
|
| 2069 | - and isset($desc['field'][$col]) |
|
| 2070 | - and $cle = array_search($desc['table'], $boucle->from) |
|
| 2071 | - ) { |
|
| 2072 | - $table = $cle; |
|
| 2073 | - } else { |
|
| 2074 | - $table = trouver_jointure_champ($col, $boucle, array($table), ($crit->cond or $op != '=')); |
|
| 2075 | - } |
|
| 2076 | - #$table = calculer_critere_externe_init($boucle, array($table), $col, $desc, ($crit->cond OR $op!='='), true); |
|
| 2077 | - if (!$table) { |
|
| 2078 | - return ''; |
|
| 2079 | - } |
|
| 2080 | - } |
|
| 2081 | - // si le champ n'est pas trouvé dans la table, |
|
| 2082 | - // on cherche si une jointure peut l'obtenir |
|
| 2083 | - elseif (@!array_key_exists($col, $desc['field'])) { |
|
| 2084 | - // Champ joker * des iterateurs DATA qui accepte tout |
|
| 2085 | - if (@array_key_exists('*', $desc['field'])) { |
|
| 2086 | - $desc['field'][$col_vraie ? $col_vraie : $col] = ''; // on veut pas de cast INT par defaut car le type peut etre n'importe quoi dans les boucles DATA |
|
| 2087 | - } |
|
| 2088 | - else { |
|
| 2089 | - $r = calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table); |
|
| 2090 | - if (!$r) { |
|
| 2091 | - return ''; |
|
| 2092 | - } |
|
| 2093 | - list($col, $col_alias, $table, $where_complement, $desc) = $r; |
|
| 2094 | - } |
|
| 2095 | - } |
|
| 2096 | - } |
|
| 2097 | - } |
|
| 2098 | - } |
|
| 2099 | - } |
|
| 2100 | - |
|
| 2101 | - $col_vraie = ($col_vraie ? $col_vraie : $col); |
|
| 2102 | - // Dans tous les cas, |
|
| 2103 | - // virer les guillemets eventuels autour d'un int (qui sont refuses par certains SQL) |
|
| 2104 | - // et passer dans sql_quote avec le type si connu |
|
| 2105 | - // et int sinon si la valeur est numerique |
|
| 2106 | - // sinon introduire le vrai type du champ si connu dans le sql_quote (ou int NOT NULL sinon) |
|
| 2107 | - // Ne pas utiliser intval, PHP tronquant les Bigint de SQL |
|
| 2108 | - if ($op == '=' or in_array($op, $GLOBALS['table_criteres_infixes'])) { |
|
| 2109 | - $type_cast_quote = (isset($desc['field'][$col_vraie]) ? $desc['field'][$col_vraie] : 'int NOT NULL'); |
|
| 2110 | - // defaire le quote des int et les passer dans sql_quote avec le bon type de champ si on le connait, int sinon |
|
| 2111 | - // prendre en compte le debug ou la valeur arrive avec un commentaire PHP en debut |
|
| 2112 | - if (preg_match(",^\\A(\s*//.*?$\s*)?\"'(-?\d+)'\"\\z,ms", $val[0], $r)) { |
|
| 2113 | - $val[0] = $r[1] . '"' . sql_quote($r[2], $boucle->sql_serveur, $type_cast_quote) . '"'; |
|
| 2114 | - } |
|
| 2115 | - // sinon expliciter les |
|
| 2116 | - // sql_quote(truc) en sql_quote(truc,'',type) |
|
| 2117 | - // sql_quote(truc,serveur) en sql_quote(truc,serveur,type) |
|
| 2118 | - // sql_quote(truc,serveur,'') en sql_quote(truc,serveur,type) |
|
| 2119 | - // sans toucher aux |
|
| 2120 | - // sql_quote(truc,'','varchar(10) DEFAULT \'oui\' COLLATE NOCASE') |
|
| 2121 | - // sql_quote(truc,'','varchar') |
|
| 2122 | - elseif (preg_match('/\Asql_quote[(](.*?)(,[^)]*?)?(,[^)]*(?:\(\d+\)[^)]*)?)?[)]\s*\z/ms', $val[0], $r) |
|
| 2123 | - // si pas deja un type |
|
| 2124 | - and (!isset($r[3]) or !$r[3] or !trim($r[3],", '")) |
|
| 2125 | - ) { |
|
| 2126 | - $r = $r[1] |
|
| 2127 | - . ((isset($r[2]) and $r[2]) ? $r[2] : ",''") |
|
| 2128 | - . ",'" . addslashes($type_cast_quote) . "'"; |
|
| 2129 | - $val[0] = "sql_quote($r)"; |
|
| 2130 | - } |
|
| 2131 | - elseif(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2132 | - and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
|
| 2133 | - $val[0] = substr($val[0], 0, -strlen($r[0])) . "'" . addslashes($type_cast_quote) . "')"; |
|
| 2134 | - } |
|
| 2135 | - } |
|
| 2136 | - |
|
| 2137 | - if(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2138 | - and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
|
| 2139 | - $val[0] = substr($val[0], 0, -strlen($r[0])) . "'char')"; |
|
| 2140 | - } |
|
| 2141 | - |
|
| 2142 | - // Indicateur pour permettre aux fonctionx boucle_X de modifier |
|
| 2143 | - // leurs requetes par defaut, notamment le champ statut |
|
| 2144 | - // Ne pas confondre champs de la table principale et des jointures |
|
| 2145 | - if ($table === $boucle->id_table) { |
|
| 2146 | - $boucles[$idb]->modificateur['criteres'][$col_vraie] = true; |
|
| 2147 | - if ($col_alias != $col_vraie) { |
|
| 2148 | - $boucles[$idb]->modificateur['criteres'][$col_alias] = true; |
|
| 2149 | - } |
|
| 2150 | - } |
|
| 2151 | - |
|
| 2152 | - // inserer le nom de la table SQL devant le nom du champ |
|
| 2153 | - if ($table) { |
|
| 2154 | - if ($col[0] == "`") { |
|
| 2155 | - $arg = "$table." . substr($col, 1, -1); |
|
| 2156 | - } else { |
|
| 2157 | - $arg = "$table.$col"; |
|
| 2158 | - } |
|
| 2159 | - } else { |
|
| 2160 | - $arg = $col; |
|
| 2161 | - } |
|
| 2162 | - |
|
| 2163 | - // inserer la fonction SQL |
|
| 2164 | - if ($fct) { |
|
| 2165 | - $arg = "$fct($arg$args_sql)"; |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - return array($arg, $op, $val, $col_alias, $where_complement); |
|
| 2017 | + $boucle = &$boucles[$idb]; |
|
| 2018 | + $type = $boucle->type_requete; |
|
| 2019 | + $table = $boucle->id_table; |
|
| 2020 | + $desc = $boucle->show; |
|
| 2021 | + $col_vraie = null; |
|
| 2022 | + |
|
| 2023 | + list($fct, $col, $op, $val, $args_sql) = |
|
| 2024 | + calculer_critere_infixe_ops($idb, $boucles, $crit); |
|
| 2025 | + |
|
| 2026 | + $col_alias = $col; |
|
| 2027 | + $where_complement = false; |
|
| 2028 | + |
|
| 2029 | + // Cas particulier : id_enfant => utiliser la colonne id_objet |
|
| 2030 | + if ($col == 'id_enfant') { |
|
| 2031 | + $col = $boucle->primary; |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + // Cas particulier : id_parent => verifier les exceptions de tables |
|
| 2035 | + if ((in_array($col, array('id_parent', 'id_secteur')) and isset($GLOBALS['exceptions_des_tables'][$table][$col])) |
|
| 2036 | + or (isset($GLOBALS['exceptions_des_tables'][$table][$col]) and is_string($GLOBALS['exceptions_des_tables'][$table][$col])) |
|
| 2037 | + ) { |
|
| 2038 | + $col = $GLOBALS['exceptions_des_tables'][$table][$col]; |
|
| 2039 | + } // et possibilite de gerer un critere secteur sur des tables de plugins (ie forums) |
|
| 2040 | + else { |
|
| 2041 | + if (($col == 'id_secteur') and ($critere_secteur = charger_fonction("critere_secteur_$type", "public", true))) { |
|
| 2042 | + $table = $critere_secteur($idb, $boucles, $val, $crit); |
|
| 2043 | + } |
|
| 2044 | + |
|
| 2045 | + // cas id_article=xx qui se mappe en id_objet=xx AND objet=article |
|
| 2046 | + // sauf si exception declaree : sauter cette etape |
|
| 2047 | + else { |
|
| 2048 | + if ( |
|
| 2049 | + !isset($GLOBALS['exceptions_des_jointures'][table_objet_sql($table)][$col]) |
|
| 2050 | + and !isset($GLOBALS['exceptions_des_jointures'][$col]) |
|
| 2051 | + and count(trouver_champs_decomposes($col, $desc)) > 1 |
|
| 2052 | + ) { |
|
| 2053 | + $e = decompose_champ_id_objet($col); |
|
| 2054 | + $col = array_shift($e); |
|
| 2055 | + $where_complement = primary_doublee($e, $table); |
|
| 2056 | + } // Cas particulier : expressions de date |
|
| 2057 | + else { |
|
| 2058 | + if ($c = calculer_critere_infixe_date($idb, $boucles, $col)) { |
|
| 2059 | + list($col, $col_vraie) = $c; |
|
| 2060 | + $table = ''; |
|
| 2061 | + } // table explicitée {mots.titre} |
|
| 2062 | + else { |
|
| 2063 | + if (preg_match('/^(.*)\.(.*)$/', $col, $r)) { |
|
| 2064 | + list(, $table, $col) = $r; |
|
| 2065 | + $col_alias = $col; |
|
| 2066 | + |
|
| 2067 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 2068 | + if ($desc = $trouver_table($table, $boucle->sql_serveur) |
|
| 2069 | + and isset($desc['field'][$col]) |
|
| 2070 | + and $cle = array_search($desc['table'], $boucle->from) |
|
| 2071 | + ) { |
|
| 2072 | + $table = $cle; |
|
| 2073 | + } else { |
|
| 2074 | + $table = trouver_jointure_champ($col, $boucle, array($table), ($crit->cond or $op != '=')); |
|
| 2075 | + } |
|
| 2076 | + #$table = calculer_critere_externe_init($boucle, array($table), $col, $desc, ($crit->cond OR $op!='='), true); |
|
| 2077 | + if (!$table) { |
|
| 2078 | + return ''; |
|
| 2079 | + } |
|
| 2080 | + } |
|
| 2081 | + // si le champ n'est pas trouvé dans la table, |
|
| 2082 | + // on cherche si une jointure peut l'obtenir |
|
| 2083 | + elseif (@!array_key_exists($col, $desc['field'])) { |
|
| 2084 | + // Champ joker * des iterateurs DATA qui accepte tout |
|
| 2085 | + if (@array_key_exists('*', $desc['field'])) { |
|
| 2086 | + $desc['field'][$col_vraie ? $col_vraie : $col] = ''; // on veut pas de cast INT par defaut car le type peut etre n'importe quoi dans les boucles DATA |
|
| 2087 | + } |
|
| 2088 | + else { |
|
| 2089 | + $r = calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table); |
|
| 2090 | + if (!$r) { |
|
| 2091 | + return ''; |
|
| 2092 | + } |
|
| 2093 | + list($col, $col_alias, $table, $where_complement, $desc) = $r; |
|
| 2094 | + } |
|
| 2095 | + } |
|
| 2096 | + } |
|
| 2097 | + } |
|
| 2098 | + } |
|
| 2099 | + } |
|
| 2100 | + |
|
| 2101 | + $col_vraie = ($col_vraie ? $col_vraie : $col); |
|
| 2102 | + // Dans tous les cas, |
|
| 2103 | + // virer les guillemets eventuels autour d'un int (qui sont refuses par certains SQL) |
|
| 2104 | + // et passer dans sql_quote avec le type si connu |
|
| 2105 | + // et int sinon si la valeur est numerique |
|
| 2106 | + // sinon introduire le vrai type du champ si connu dans le sql_quote (ou int NOT NULL sinon) |
|
| 2107 | + // Ne pas utiliser intval, PHP tronquant les Bigint de SQL |
|
| 2108 | + if ($op == '=' or in_array($op, $GLOBALS['table_criteres_infixes'])) { |
|
| 2109 | + $type_cast_quote = (isset($desc['field'][$col_vraie]) ? $desc['field'][$col_vraie] : 'int NOT NULL'); |
|
| 2110 | + // defaire le quote des int et les passer dans sql_quote avec le bon type de champ si on le connait, int sinon |
|
| 2111 | + // prendre en compte le debug ou la valeur arrive avec un commentaire PHP en debut |
|
| 2112 | + if (preg_match(",^\\A(\s*//.*?$\s*)?\"'(-?\d+)'\"\\z,ms", $val[0], $r)) { |
|
| 2113 | + $val[0] = $r[1] . '"' . sql_quote($r[2], $boucle->sql_serveur, $type_cast_quote) . '"'; |
|
| 2114 | + } |
|
| 2115 | + // sinon expliciter les |
|
| 2116 | + // sql_quote(truc) en sql_quote(truc,'',type) |
|
| 2117 | + // sql_quote(truc,serveur) en sql_quote(truc,serveur,type) |
|
| 2118 | + // sql_quote(truc,serveur,'') en sql_quote(truc,serveur,type) |
|
| 2119 | + // sans toucher aux |
|
| 2120 | + // sql_quote(truc,'','varchar(10) DEFAULT \'oui\' COLLATE NOCASE') |
|
| 2121 | + // sql_quote(truc,'','varchar') |
|
| 2122 | + elseif (preg_match('/\Asql_quote[(](.*?)(,[^)]*?)?(,[^)]*(?:\(\d+\)[^)]*)?)?[)]\s*\z/ms', $val[0], $r) |
|
| 2123 | + // si pas deja un type |
|
| 2124 | + and (!isset($r[3]) or !$r[3] or !trim($r[3],", '")) |
|
| 2125 | + ) { |
|
| 2126 | + $r = $r[1] |
|
| 2127 | + . ((isset($r[2]) and $r[2]) ? $r[2] : ",''") |
|
| 2128 | + . ",'" . addslashes($type_cast_quote) . "'"; |
|
| 2129 | + $val[0] = "sql_quote($r)"; |
|
| 2130 | + } |
|
| 2131 | + elseif(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2132 | + and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
|
| 2133 | + $val[0] = substr($val[0], 0, -strlen($r[0])) . "'" . addslashes($type_cast_quote) . "')"; |
|
| 2134 | + } |
|
| 2135 | + } |
|
| 2136 | + |
|
| 2137 | + if(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2138 | + and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
|
| 2139 | + $val[0] = substr($val[0], 0, -strlen($r[0])) . "'char')"; |
|
| 2140 | + } |
|
| 2141 | + |
|
| 2142 | + // Indicateur pour permettre aux fonctionx boucle_X de modifier |
|
| 2143 | + // leurs requetes par defaut, notamment le champ statut |
|
| 2144 | + // Ne pas confondre champs de la table principale et des jointures |
|
| 2145 | + if ($table === $boucle->id_table) { |
|
| 2146 | + $boucles[$idb]->modificateur['criteres'][$col_vraie] = true; |
|
| 2147 | + if ($col_alias != $col_vraie) { |
|
| 2148 | + $boucles[$idb]->modificateur['criteres'][$col_alias] = true; |
|
| 2149 | + } |
|
| 2150 | + } |
|
| 2151 | + |
|
| 2152 | + // inserer le nom de la table SQL devant le nom du champ |
|
| 2153 | + if ($table) { |
|
| 2154 | + if ($col[0] == "`") { |
|
| 2155 | + $arg = "$table." . substr($col, 1, -1); |
|
| 2156 | + } else { |
|
| 2157 | + $arg = "$table.$col"; |
|
| 2158 | + } |
|
| 2159 | + } else { |
|
| 2160 | + $arg = $col; |
|
| 2161 | + } |
|
| 2162 | + |
|
| 2163 | + // inserer la fonction SQL |
|
| 2164 | + if ($fct) { |
|
| 2165 | + $arg = "$fct($arg$args_sql)"; |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + return array($arg, $op, $val, $col_alias, $where_complement); |
|
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | |
@@ -2194,77 +2194,77 @@ discard block |
||
| 2194 | 2194 | **/ |
| 2195 | 2195 | function calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table) { |
| 2196 | 2196 | |
| 2197 | - $where = ''; |
|
| 2198 | - |
|
| 2199 | - $calculer_critere_externe = 'calculer_critere_externe_init'; |
|
| 2200 | - // gestion par les plugins des jointures tordues |
|
| 2201 | - // pas automatiques mais necessaires |
|
| 2202 | - $table_sql = table_objet_sql($table); |
|
| 2203 | - if (isset($GLOBALS['exceptions_des_jointures'][$table_sql]) |
|
| 2204 | - and is_array($GLOBALS['exceptions_des_jointures'][$table_sql]) |
|
| 2205 | - and |
|
| 2206 | - ( |
|
| 2207 | - isset($GLOBALS['exceptions_des_jointures'][$table_sql][$col]) |
|
| 2208 | - or |
|
| 2209 | - isset($GLOBALS['exceptions_des_jointures'][$table_sql]['']) |
|
| 2210 | - ) |
|
| 2211 | - ) { |
|
| 2212 | - $t = $GLOBALS['exceptions_des_jointures'][$table_sql]; |
|
| 2213 | - $index = isset($t[$col]) |
|
| 2214 | - ? $t[$col] : (isset($t['']) ? $t[''] : array()); |
|
| 2215 | - |
|
| 2216 | - if (count($index) == 3) { |
|
| 2217 | - list($t, $col, $calculer_critere_externe) = $index; |
|
| 2218 | - } elseif (count($index) == 2) { |
|
| 2219 | - list($t, $col) = $t[$col]; |
|
| 2220 | - } elseif (count($index) == 1) { |
|
| 2221 | - list($calculer_critere_externe) = $index; |
|
| 2222 | - $t = $table; |
|
| 2223 | - } else { |
|
| 2224 | - $t = ''; |
|
| 2225 | - } // jointure non declaree. La trouver. |
|
| 2226 | - } elseif (isset($GLOBALS['exceptions_des_jointures'][$col])) { |
|
| 2227 | - list($t, $col) = $GLOBALS['exceptions_des_jointures'][$col]; |
|
| 2228 | - } else { |
|
| 2229 | - $t = ''; |
|
| 2230 | - } // jointure non declaree. La trouver. |
|
| 2231 | - |
|
| 2232 | - // ici on construit le from pour fournir $col en piochant dans les jointures |
|
| 2233 | - |
|
| 2234 | - // si des jointures explicites sont fournies, on cherche d'abord dans celles ci |
|
| 2235 | - // permet de forcer une table de lien quand il y a ambiguite |
|
| 2236 | - // <BOUCLE_(DOCUMENTS documents_liens){id_mot}> |
|
| 2237 | - // alors que <BOUCLE_(DOCUMENTS){id_mot}> produit la meme chose que <BOUCLE_(DOCUMENTS mots_liens){id_mot}> |
|
| 2238 | - $table = ""; |
|
| 2239 | - if ($boucle->jointures_explicites) { |
|
| 2240 | - $jointures_explicites = explode(' ', $boucle->jointures_explicites); |
|
| 2241 | - $table = $calculer_critere_externe($boucle, $jointures_explicites, $col, $desc, ($crit->cond or $op != '='), $t); |
|
| 2242 | - } |
|
| 2243 | - |
|
| 2244 | - // et sinon on cherche parmi toutes les jointures declarees |
|
| 2245 | - if (!$table) { |
|
| 2246 | - $table = $calculer_critere_externe($boucle, $boucle->jointures, $col, $desc, ($crit->cond or $op != '='), $t); |
|
| 2247 | - } |
|
| 2248 | - |
|
| 2249 | - if (!$table) { |
|
| 2250 | - return ''; |
|
| 2251 | - } |
|
| 2252 | - |
|
| 2253 | - // il ne reste plus qu'a trouver le champ dans les from |
|
| 2254 | - list($nom, $desc, $cle) = trouver_champ_exterieur($col, $boucle->from, $boucle); |
|
| 2255 | - |
|
| 2256 | - if (count($cle) > 1 or reset($cle) !== $col) { |
|
| 2257 | - $col_alias = $col; // id_article devient juste le nom d'origine |
|
| 2258 | - if (count($cle) > 1 and reset($cle) == 'id_objet') { |
|
| 2259 | - $e = decompose_champ_id_objet($col); |
|
| 2260 | - $col = array_shift($e); |
|
| 2261 | - $where = primary_doublee($e, $table); |
|
| 2262 | - } else { |
|
| 2263 | - $col = reset($cle); |
|
| 2264 | - } |
|
| 2265 | - } |
|
| 2266 | - |
|
| 2267 | - return array($col, $col_alias, $table, $where, $desc); |
|
| 2197 | + $where = ''; |
|
| 2198 | + |
|
| 2199 | + $calculer_critere_externe = 'calculer_critere_externe_init'; |
|
| 2200 | + // gestion par les plugins des jointures tordues |
|
| 2201 | + // pas automatiques mais necessaires |
|
| 2202 | + $table_sql = table_objet_sql($table); |
|
| 2203 | + if (isset($GLOBALS['exceptions_des_jointures'][$table_sql]) |
|
| 2204 | + and is_array($GLOBALS['exceptions_des_jointures'][$table_sql]) |
|
| 2205 | + and |
|
| 2206 | + ( |
|
| 2207 | + isset($GLOBALS['exceptions_des_jointures'][$table_sql][$col]) |
|
| 2208 | + or |
|
| 2209 | + isset($GLOBALS['exceptions_des_jointures'][$table_sql]['']) |
|
| 2210 | + ) |
|
| 2211 | + ) { |
|
| 2212 | + $t = $GLOBALS['exceptions_des_jointures'][$table_sql]; |
|
| 2213 | + $index = isset($t[$col]) |
|
| 2214 | + ? $t[$col] : (isset($t['']) ? $t[''] : array()); |
|
| 2215 | + |
|
| 2216 | + if (count($index) == 3) { |
|
| 2217 | + list($t, $col, $calculer_critere_externe) = $index; |
|
| 2218 | + } elseif (count($index) == 2) { |
|
| 2219 | + list($t, $col) = $t[$col]; |
|
| 2220 | + } elseif (count($index) == 1) { |
|
| 2221 | + list($calculer_critere_externe) = $index; |
|
| 2222 | + $t = $table; |
|
| 2223 | + } else { |
|
| 2224 | + $t = ''; |
|
| 2225 | + } // jointure non declaree. La trouver. |
|
| 2226 | + } elseif (isset($GLOBALS['exceptions_des_jointures'][$col])) { |
|
| 2227 | + list($t, $col) = $GLOBALS['exceptions_des_jointures'][$col]; |
|
| 2228 | + } else { |
|
| 2229 | + $t = ''; |
|
| 2230 | + } // jointure non declaree. La trouver. |
|
| 2231 | + |
|
| 2232 | + // ici on construit le from pour fournir $col en piochant dans les jointures |
|
| 2233 | + |
|
| 2234 | + // si des jointures explicites sont fournies, on cherche d'abord dans celles ci |
|
| 2235 | + // permet de forcer une table de lien quand il y a ambiguite |
|
| 2236 | + // <BOUCLE_(DOCUMENTS documents_liens){id_mot}> |
|
| 2237 | + // alors que <BOUCLE_(DOCUMENTS){id_mot}> produit la meme chose que <BOUCLE_(DOCUMENTS mots_liens){id_mot}> |
|
| 2238 | + $table = ""; |
|
| 2239 | + if ($boucle->jointures_explicites) { |
|
| 2240 | + $jointures_explicites = explode(' ', $boucle->jointures_explicites); |
|
| 2241 | + $table = $calculer_critere_externe($boucle, $jointures_explicites, $col, $desc, ($crit->cond or $op != '='), $t); |
|
| 2242 | + } |
|
| 2243 | + |
|
| 2244 | + // et sinon on cherche parmi toutes les jointures declarees |
|
| 2245 | + if (!$table) { |
|
| 2246 | + $table = $calculer_critere_externe($boucle, $boucle->jointures, $col, $desc, ($crit->cond or $op != '='), $t); |
|
| 2247 | + } |
|
| 2248 | + |
|
| 2249 | + if (!$table) { |
|
| 2250 | + return ''; |
|
| 2251 | + } |
|
| 2252 | + |
|
| 2253 | + // il ne reste plus qu'a trouver le champ dans les from |
|
| 2254 | + list($nom, $desc, $cle) = trouver_champ_exterieur($col, $boucle->from, $boucle); |
|
| 2255 | + |
|
| 2256 | + if (count($cle) > 1 or reset($cle) !== $col) { |
|
| 2257 | + $col_alias = $col; // id_article devient juste le nom d'origine |
|
| 2258 | + if (count($cle) > 1 and reset($cle) == 'id_objet') { |
|
| 2259 | + $e = decompose_champ_id_objet($col); |
|
| 2260 | + $col = array_shift($e); |
|
| 2261 | + $where = primary_doublee($e, $table); |
|
| 2262 | + } else { |
|
| 2263 | + $col = reset($cle); |
|
| 2264 | + } |
|
| 2265 | + } |
|
| 2266 | + |
|
| 2267 | + return array($col, $col_alias, $table, $where, $desc); |
|
| 2268 | 2268 | } |
| 2269 | 2269 | |
| 2270 | 2270 | |
@@ -2285,10 +2285,10 @@ discard block |
||
| 2285 | 2285 | * - valeur |
| 2286 | 2286 | **/ |
| 2287 | 2287 | function primary_doublee($decompose, $table) { |
| 2288 | - $e1 = reset($decompose); |
|
| 2289 | - $e2 = "sql_quote('" . end($decompose) . "')"; |
|
| 2288 | + $e1 = reset($decompose); |
|
| 2289 | + $e2 = "sql_quote('" . end($decompose) . "')"; |
|
| 2290 | 2290 | |
| 2291 | - return array("'='", "'$table." . $e1 . "'", $e2); |
|
| 2291 | + return array("'='", "'$table." . $e1 . "'", $e2); |
|
| 2292 | 2292 | } |
| 2293 | 2293 | |
| 2294 | 2294 | /** |
@@ -2319,56 +2319,56 @@ discard block |
||
| 2319 | 2319 | * Vide sinon. |
| 2320 | 2320 | */ |
| 2321 | 2321 | function calculer_critere_externe_init(&$boucle, $joints, $col, $desc, $cond, $checkarrivee = false) { |
| 2322 | - // si on demande un truc du genre spip_mots |
|
| 2323 | - // avec aussi spip_mots_liens dans les jointures dispo |
|
| 2324 | - // et qu'on est la |
|
| 2325 | - // il faut privilegier la jointure directe en 2 etapes spip_mots_liens, spip_mots |
|
| 2326 | - if ($checkarrivee |
|
| 2327 | - and is_string($checkarrivee) |
|
| 2328 | - and $a = table_objet($checkarrivee) |
|
| 2329 | - and in_array($a . '_liens', $joints) |
|
| 2330 | - ) { |
|
| 2331 | - if ($res = calculer_lien_externe_init($boucle, $joints, $col, $desc, $cond, $checkarrivee)) { |
|
| 2332 | - return $res; |
|
| 2333 | - } |
|
| 2334 | - } |
|
| 2335 | - foreach ($joints as $joint) { |
|
| 2336 | - if ($arrivee = trouver_champ_exterieur($col, array($joint), $boucle, $checkarrivee)) { |
|
| 2337 | - // alias de table dans le from |
|
| 2338 | - $t = array_search($arrivee[0], $boucle->from); |
|
| 2339 | - // recuperer la cle id_xx eventuellement decomposee en (id_objet,objet) |
|
| 2340 | - $cols = $arrivee[2]; |
|
| 2341 | - // mais on ignore la 3eme cle si presente qui correspond alors au point de depart |
|
| 2342 | - if (count($cols) > 2) { |
|
| 2343 | - array_pop($cols); |
|
| 2344 | - } |
|
| 2345 | - if ($t) { |
|
| 2346 | - // la table est déjà dans le FROM, on vérifie si le champ est utilisé. |
|
| 2347 | - $joindre = false; |
|
| 2348 | - foreach ($cols as $col) { |
|
| 2349 | - $c = '/\b' . $t . ".$col" . '\b/'; |
|
| 2350 | - if (trouver_champ($c, $boucle->where)) { |
|
| 2351 | - $joindre = true; |
|
| 2352 | - } else { |
|
| 2353 | - // mais ca peut etre dans le FIELD pour le Having |
|
| 2354 | - $c = "/FIELD.$t" . ".$col,/"; |
|
| 2355 | - if (trouver_champ($c, $boucle->select)) { |
|
| 2356 | - $joindre = true; |
|
| 2357 | - } |
|
| 2358 | - } |
|
| 2359 | - } |
|
| 2360 | - if (!$joindre) { |
|
| 2361 | - return $t; |
|
| 2362 | - } |
|
| 2363 | - } |
|
| 2364 | - array_pop($arrivee); |
|
| 2365 | - if ($res = calculer_jointure($boucle, array($boucle->id_table, $desc), $arrivee, $cols, $cond, 1)) { |
|
| 2366 | - return $res; |
|
| 2367 | - } |
|
| 2368 | - } |
|
| 2369 | - } |
|
| 2370 | - |
|
| 2371 | - return ''; |
|
| 2322 | + // si on demande un truc du genre spip_mots |
|
| 2323 | + // avec aussi spip_mots_liens dans les jointures dispo |
|
| 2324 | + // et qu'on est la |
|
| 2325 | + // il faut privilegier la jointure directe en 2 etapes spip_mots_liens, spip_mots |
|
| 2326 | + if ($checkarrivee |
|
| 2327 | + and is_string($checkarrivee) |
|
| 2328 | + and $a = table_objet($checkarrivee) |
|
| 2329 | + and in_array($a . '_liens', $joints) |
|
| 2330 | + ) { |
|
| 2331 | + if ($res = calculer_lien_externe_init($boucle, $joints, $col, $desc, $cond, $checkarrivee)) { |
|
| 2332 | + return $res; |
|
| 2333 | + } |
|
| 2334 | + } |
|
| 2335 | + foreach ($joints as $joint) { |
|
| 2336 | + if ($arrivee = trouver_champ_exterieur($col, array($joint), $boucle, $checkarrivee)) { |
|
| 2337 | + // alias de table dans le from |
|
| 2338 | + $t = array_search($arrivee[0], $boucle->from); |
|
| 2339 | + // recuperer la cle id_xx eventuellement decomposee en (id_objet,objet) |
|
| 2340 | + $cols = $arrivee[2]; |
|
| 2341 | + // mais on ignore la 3eme cle si presente qui correspond alors au point de depart |
|
| 2342 | + if (count($cols) > 2) { |
|
| 2343 | + array_pop($cols); |
|
| 2344 | + } |
|
| 2345 | + if ($t) { |
|
| 2346 | + // la table est déjà dans le FROM, on vérifie si le champ est utilisé. |
|
| 2347 | + $joindre = false; |
|
| 2348 | + foreach ($cols as $col) { |
|
| 2349 | + $c = '/\b' . $t . ".$col" . '\b/'; |
|
| 2350 | + if (trouver_champ($c, $boucle->where)) { |
|
| 2351 | + $joindre = true; |
|
| 2352 | + } else { |
|
| 2353 | + // mais ca peut etre dans le FIELD pour le Having |
|
| 2354 | + $c = "/FIELD.$t" . ".$col,/"; |
|
| 2355 | + if (trouver_champ($c, $boucle->select)) { |
|
| 2356 | + $joindre = true; |
|
| 2357 | + } |
|
| 2358 | + } |
|
| 2359 | + } |
|
| 2360 | + if (!$joindre) { |
|
| 2361 | + return $t; |
|
| 2362 | + } |
|
| 2363 | + } |
|
| 2364 | + array_pop($arrivee); |
|
| 2365 | + if ($res = calculer_jointure($boucle, array($boucle->id_table, $desc), $arrivee, $cols, $cond, 1)) { |
|
| 2366 | + return $res; |
|
| 2367 | + } |
|
| 2368 | + } |
|
| 2369 | + } |
|
| 2370 | + |
|
| 2371 | + return ''; |
|
| 2372 | 2372 | |
| 2373 | 2373 | } |
| 2374 | 2374 | |
@@ -2395,29 +2395,29 @@ discard block |
||
| 2395 | 2395 | * Alias de la table de jointure (Lx) |
| 2396 | 2396 | */ |
| 2397 | 2397 | function calculer_lien_externe_init(&$boucle, $joints, $col, $desc, $cond, $checkarrivee = false) { |
| 2398 | - $primary_arrivee = id_table_objet($checkarrivee); |
|
| 2399 | - |
|
| 2400 | - // [FIXME] $checkarrivee peut-il arriver avec false ???? |
|
| 2401 | - $intermediaire = trouver_champ_exterieur($primary_arrivee, $joints, $boucle, $checkarrivee . "_liens"); |
|
| 2402 | - $arrivee = trouver_champ_exterieur($col, $joints, $boucle, $checkarrivee); |
|
| 2403 | - |
|
| 2404 | - if (!$intermediaire or !$arrivee) { |
|
| 2405 | - return ''; |
|
| 2406 | - } |
|
| 2407 | - array_pop($intermediaire); // enlever la cle en 3eme argument |
|
| 2408 | - array_pop($arrivee); // enlever la cle en 3eme argument |
|
| 2409 | - |
|
| 2410 | - $res = fabrique_jointures($boucle, |
|
| 2411 | - array( |
|
| 2412 | - array( |
|
| 2413 | - $boucle->id_table, |
|
| 2414 | - $intermediaire, |
|
| 2415 | - array(id_table_objet($desc['table_objet']), 'id_objet', 'objet', $desc['type']) |
|
| 2416 | - ), |
|
| 2417 | - array(reset($intermediaire), $arrivee, $primary_arrivee) |
|
| 2418 | - ), $cond, $desc, $boucle->id_table, array($col)); |
|
| 2419 | - |
|
| 2420 | - return $res; |
|
| 2398 | + $primary_arrivee = id_table_objet($checkarrivee); |
|
| 2399 | + |
|
| 2400 | + // [FIXME] $checkarrivee peut-il arriver avec false ???? |
|
| 2401 | + $intermediaire = trouver_champ_exterieur($primary_arrivee, $joints, $boucle, $checkarrivee . "_liens"); |
|
| 2402 | + $arrivee = trouver_champ_exterieur($col, $joints, $boucle, $checkarrivee); |
|
| 2403 | + |
|
| 2404 | + if (!$intermediaire or !$arrivee) { |
|
| 2405 | + return ''; |
|
| 2406 | + } |
|
| 2407 | + array_pop($intermediaire); // enlever la cle en 3eme argument |
|
| 2408 | + array_pop($arrivee); // enlever la cle en 3eme argument |
|
| 2409 | + |
|
| 2410 | + $res = fabrique_jointures($boucle, |
|
| 2411 | + array( |
|
| 2412 | + array( |
|
| 2413 | + $boucle->id_table, |
|
| 2414 | + $intermediaire, |
|
| 2415 | + array(id_table_objet($desc['table_objet']), 'id_objet', 'objet', $desc['type']) |
|
| 2416 | + ), |
|
| 2417 | + array(reset($intermediaire), $arrivee, $primary_arrivee) |
|
| 2418 | + ), $cond, $desc, $boucle->id_table, array($col)); |
|
| 2419 | + |
|
| 2420 | + return $res; |
|
| 2421 | 2421 | } |
| 2422 | 2422 | |
| 2423 | 2423 | |
@@ -2434,17 +2434,17 @@ discard block |
||
| 2434 | 2434 | * false sinon. |
| 2435 | 2435 | **/ |
| 2436 | 2436 | function trouver_champ($champ, $where) { |
| 2437 | - if (!is_array($where)) { |
|
| 2438 | - return preg_match($champ, $where); |
|
| 2439 | - } else { |
|
| 2440 | - foreach ($where as $clause) { |
|
| 2441 | - if (trouver_champ($champ, $clause)) { |
|
| 2442 | - return true; |
|
| 2443 | - } |
|
| 2444 | - } |
|
| 2445 | - |
|
| 2446 | - return false; |
|
| 2447 | - } |
|
| 2437 | + if (!is_array($where)) { |
|
| 2438 | + return preg_match($champ, $where); |
|
| 2439 | + } else { |
|
| 2440 | + foreach ($where as $clause) { |
|
| 2441 | + if (trouver_champ($champ, $clause)) { |
|
| 2442 | + return true; |
|
| 2443 | + } |
|
| 2444 | + } |
|
| 2445 | + |
|
| 2446 | + return false; |
|
| 2447 | + } |
|
| 2448 | 2448 | } |
| 2449 | 2449 | |
| 2450 | 2450 | |
@@ -2470,128 +2470,128 @@ discard block |
||
| 2470 | 2470 | * - string $args_sql Suite des arguments du critère. ? |
| 2471 | 2471 | **/ |
| 2472 | 2472 | function calculer_critere_infixe_ops($idb, &$boucles, $crit) { |
| 2473 | - // cas d'une valeur comparee a elle-meme ou son referent |
|
| 2474 | - if (count($crit->param) == 0) { |
|
| 2475 | - $op = '='; |
|
| 2476 | - $col = $val = $crit->op; |
|
| 2477 | - if (preg_match('/^(.*)\.(.*)$/', $col, $r)) { |
|
| 2478 | - $val = $r[2]; |
|
| 2479 | - } |
|
| 2480 | - // Cas special {lang} : aller chercher $GLOBALS['spip_lang'] |
|
| 2481 | - if ($val == 'lang') { |
|
| 2482 | - $val = array(kwote('$GLOBALS[\'spip_lang\']')); |
|
| 2483 | - } else { |
|
| 2484 | - $defaut = null; |
|
| 2485 | - if ($val == 'id_parent') { |
|
| 2486 | - // Si id_parent, comparer l'id_parent avec l'id_objet |
|
| 2487 | - // de la boucle superieure.... faudrait verifier qu'il existe |
|
| 2488 | - // pour eviter l'erreur SQL |
|
| 2489 | - $val = $boucles[$idb]->primary; |
|
| 2490 | - // mais si pas de boucle superieure, prendre id_parent dans l'env |
|
| 2491 | - $defaut = "@\$Pile[0]['id_parent']"; |
|
| 2492 | - } elseif ($val == 'id_enfant') { |
|
| 2493 | - // Si id_enfant, comparer l'id_objet avec l'id_parent |
|
| 2494 | - // de la boucle superieure |
|
| 2495 | - $val = 'id_parent'; |
|
| 2496 | - } elseif ($crit->cond and ($col == "date" or $col == "date_redac")) { |
|
| 2497 | - // un critere conditionnel sur date est traite a part |
|
| 2498 | - // car la date est mise d'office par SPIP, |
|
| 2499 | - $defaut = "(\$Pile[0]['{$col}_default']?'':\$Pile[0]['" . $col . "'])"; |
|
| 2500 | - } |
|
| 2501 | - |
|
| 2502 | - $val = calculer_argument_precedent($idb, $val, $boucles, $defaut); |
|
| 2503 | - $val = array(kwote($val)); |
|
| 2504 | - } |
|
| 2505 | - } else { |
|
| 2506 | - // comparaison explicite |
|
| 2507 | - // le phraseur impose que le premier param soit du texte |
|
| 2508 | - $params = $crit->param; |
|
| 2509 | - $op = $crit->op; |
|
| 2510 | - if ($op == '==') { |
|
| 2511 | - $op = 'REGEXP'; |
|
| 2512 | - } |
|
| 2513 | - $col = array_shift($params); |
|
| 2514 | - $col = $col[0]->texte; |
|
| 2515 | - |
|
| 2516 | - $val = array(); |
|
| 2517 | - $parent = $boucles[$idb]->id_parent; |
|
| 2518 | - |
|
| 2519 | - // Dans le cas {x=='#DATE'} etc, defaire le travail du phraseur, |
|
| 2520 | - // celui ne sachant pas ce qu'est un critere infixe |
|
| 2521 | - // et a fortiori son 2e operande qu'entoure " ou ' |
|
| 2522 | - if (count($params) == 1 |
|
| 2523 | - and count($params[0]) == 3 |
|
| 2524 | - and $params[0][0]->type == 'texte' |
|
| 2525 | - and $params[0][2]->type == 'texte' |
|
| 2526 | - and ($p = $params[0][0]->texte) == $params[0][2]->texte |
|
| 2527 | - and (($p == "'") or ($p == '"')) |
|
| 2528 | - and $params[0][1]->type == 'champ' |
|
| 2529 | - ) { |
|
| 2530 | - $val[] = "$p\\$p#" . $params[0][1]->nom_champ . "\\$p$p"; |
|
| 2531 | - } else { |
|
| 2532 | - foreach ((($op != 'IN') ? $params : calculer_vieux_in($params)) as $p) { |
|
| 2533 | - $a = calculer_liste($p, $idb, $boucles, $parent); |
|
| 2534 | - if (strcasecmp($op, 'IN') == 0) { |
|
| 2535 | - $val[] = $a; |
|
| 2536 | - } else { |
|
| 2537 | - $val[] = kwote($a, $boucles[$idb]->sql_serveur, '@@defaultcast@@'); |
|
| 2538 | - } // toujours quoter en char ici |
|
| 2539 | - } |
|
| 2540 | - } |
|
| 2541 | - } |
|
| 2542 | - |
|
| 2543 | - $fct = $args_sql = ''; |
|
| 2544 | - // fonction SQL ? |
|
| 2545 | - // chercher FONCTION(champ) tel que CONCAT(titre,descriptif) |
|
| 2546 | - if (preg_match('/^(.*)' . SQL_ARGS . '$/', $col, $m)) { |
|
| 2547 | - $fct = $m[1]; |
|
| 2548 | - preg_match('/^\(([^,]*)(.*)\)$/', $m[2], $a); |
|
| 2549 | - $col = $a[1]; |
|
| 2550 | - if (preg_match('/^(\S*)(\s+AS\s+.*)$/i', $col, $m)) { |
|
| 2551 | - $col = $m[1]; |
|
| 2552 | - $args_sql = $m[2]; |
|
| 2553 | - } |
|
| 2554 | - $args_sql .= $a[2]; |
|
| 2555 | - } |
|
| 2556 | - |
|
| 2557 | - return array($fct, $col, $op, $val, $args_sql); |
|
| 2473 | + // cas d'une valeur comparee a elle-meme ou son referent |
|
| 2474 | + if (count($crit->param) == 0) { |
|
| 2475 | + $op = '='; |
|
| 2476 | + $col = $val = $crit->op; |
|
| 2477 | + if (preg_match('/^(.*)\.(.*)$/', $col, $r)) { |
|
| 2478 | + $val = $r[2]; |
|
| 2479 | + } |
|
| 2480 | + // Cas special {lang} : aller chercher $GLOBALS['spip_lang'] |
|
| 2481 | + if ($val == 'lang') { |
|
| 2482 | + $val = array(kwote('$GLOBALS[\'spip_lang\']')); |
|
| 2483 | + } else { |
|
| 2484 | + $defaut = null; |
|
| 2485 | + if ($val == 'id_parent') { |
|
| 2486 | + // Si id_parent, comparer l'id_parent avec l'id_objet |
|
| 2487 | + // de la boucle superieure.... faudrait verifier qu'il existe |
|
| 2488 | + // pour eviter l'erreur SQL |
|
| 2489 | + $val = $boucles[$idb]->primary; |
|
| 2490 | + // mais si pas de boucle superieure, prendre id_parent dans l'env |
|
| 2491 | + $defaut = "@\$Pile[0]['id_parent']"; |
|
| 2492 | + } elseif ($val == 'id_enfant') { |
|
| 2493 | + // Si id_enfant, comparer l'id_objet avec l'id_parent |
|
| 2494 | + // de la boucle superieure |
|
| 2495 | + $val = 'id_parent'; |
|
| 2496 | + } elseif ($crit->cond and ($col == "date" or $col == "date_redac")) { |
|
| 2497 | + // un critere conditionnel sur date est traite a part |
|
| 2498 | + // car la date est mise d'office par SPIP, |
|
| 2499 | + $defaut = "(\$Pile[0]['{$col}_default']?'':\$Pile[0]['" . $col . "'])"; |
|
| 2500 | + } |
|
| 2501 | + |
|
| 2502 | + $val = calculer_argument_precedent($idb, $val, $boucles, $defaut); |
|
| 2503 | + $val = array(kwote($val)); |
|
| 2504 | + } |
|
| 2505 | + } else { |
|
| 2506 | + // comparaison explicite |
|
| 2507 | + // le phraseur impose que le premier param soit du texte |
|
| 2508 | + $params = $crit->param; |
|
| 2509 | + $op = $crit->op; |
|
| 2510 | + if ($op == '==') { |
|
| 2511 | + $op = 'REGEXP'; |
|
| 2512 | + } |
|
| 2513 | + $col = array_shift($params); |
|
| 2514 | + $col = $col[0]->texte; |
|
| 2515 | + |
|
| 2516 | + $val = array(); |
|
| 2517 | + $parent = $boucles[$idb]->id_parent; |
|
| 2518 | + |
|
| 2519 | + // Dans le cas {x=='#DATE'} etc, defaire le travail du phraseur, |
|
| 2520 | + // celui ne sachant pas ce qu'est un critere infixe |
|
| 2521 | + // et a fortiori son 2e operande qu'entoure " ou ' |
|
| 2522 | + if (count($params) == 1 |
|
| 2523 | + and count($params[0]) == 3 |
|
| 2524 | + and $params[0][0]->type == 'texte' |
|
| 2525 | + and $params[0][2]->type == 'texte' |
|
| 2526 | + and ($p = $params[0][0]->texte) == $params[0][2]->texte |
|
| 2527 | + and (($p == "'") or ($p == '"')) |
|
| 2528 | + and $params[0][1]->type == 'champ' |
|
| 2529 | + ) { |
|
| 2530 | + $val[] = "$p\\$p#" . $params[0][1]->nom_champ . "\\$p$p"; |
|
| 2531 | + } else { |
|
| 2532 | + foreach ((($op != 'IN') ? $params : calculer_vieux_in($params)) as $p) { |
|
| 2533 | + $a = calculer_liste($p, $idb, $boucles, $parent); |
|
| 2534 | + if (strcasecmp($op, 'IN') == 0) { |
|
| 2535 | + $val[] = $a; |
|
| 2536 | + } else { |
|
| 2537 | + $val[] = kwote($a, $boucles[$idb]->sql_serveur, '@@defaultcast@@'); |
|
| 2538 | + } // toujours quoter en char ici |
|
| 2539 | + } |
|
| 2540 | + } |
|
| 2541 | + } |
|
| 2542 | + |
|
| 2543 | + $fct = $args_sql = ''; |
|
| 2544 | + // fonction SQL ? |
|
| 2545 | + // chercher FONCTION(champ) tel que CONCAT(titre,descriptif) |
|
| 2546 | + if (preg_match('/^(.*)' . SQL_ARGS . '$/', $col, $m)) { |
|
| 2547 | + $fct = $m[1]; |
|
| 2548 | + preg_match('/^\(([^,]*)(.*)\)$/', $m[2], $a); |
|
| 2549 | + $col = $a[1]; |
|
| 2550 | + if (preg_match('/^(\S*)(\s+AS\s+.*)$/i', $col, $m)) { |
|
| 2551 | + $col = $m[1]; |
|
| 2552 | + $args_sql = $m[2]; |
|
| 2553 | + } |
|
| 2554 | + $args_sql .= $a[2]; |
|
| 2555 | + } |
|
| 2556 | + |
|
| 2557 | + return array($fct, $col, $op, $val, $args_sql); |
|
| 2558 | 2558 | } |
| 2559 | 2559 | |
| 2560 | 2560 | // compatibilite ancienne version |
| 2561 | 2561 | |
| 2562 | 2562 | // https://code.spip.net/@calculer_vieux_in |
| 2563 | 2563 | function calculer_vieux_in($params) { |
| 2564 | - $deb = $params[0][0]; |
|
| 2565 | - $k = count($params) - 1; |
|
| 2566 | - $last = $params[$k]; |
|
| 2567 | - $j = count($last) - 1; |
|
| 2568 | - $last = $last[$j]; |
|
| 2569 | - $n = isset($last->texte) ? strlen($last->texte) : 0; |
|
| 2570 | - |
|
| 2571 | - if (!((isset($deb->texte[0]) and $deb->texte[0] == '(') |
|
| 2572 | - && (isset($last->texte[$n - 1]) and $last->texte[$n - 1] == ')')) |
|
| 2573 | - ) { |
|
| 2574 | - return $params; |
|
| 2575 | - } |
|
| 2576 | - $params[0][0]->texte = substr($deb->texte, 1); |
|
| 2577 | - // attention, on peut avoir k=0,j=0 ==> recalculer |
|
| 2578 | - $last = $params[$k][$j]; |
|
| 2579 | - $n = strlen($last->texte); |
|
| 2580 | - $params[$k][$j]->texte = substr($last->texte, 0, $n - 1); |
|
| 2581 | - $newp = array(); |
|
| 2582 | - foreach ($params as $v) { |
|
| 2583 | - if ($v[0]->type != 'texte') { |
|
| 2584 | - $newp[] = $v; |
|
| 2585 | - } else { |
|
| 2586 | - foreach (explode(',', $v[0]->texte) as $x) { |
|
| 2587 | - $t = new Texte; |
|
| 2588 | - $t->texte = $x; |
|
| 2589 | - $newp[] = array($t); |
|
| 2590 | - } |
|
| 2591 | - } |
|
| 2592 | - } |
|
| 2593 | - |
|
| 2594 | - return $newp; |
|
| 2564 | + $deb = $params[0][0]; |
|
| 2565 | + $k = count($params) - 1; |
|
| 2566 | + $last = $params[$k]; |
|
| 2567 | + $j = count($last) - 1; |
|
| 2568 | + $last = $last[$j]; |
|
| 2569 | + $n = isset($last->texte) ? strlen($last->texte) : 0; |
|
| 2570 | + |
|
| 2571 | + if (!((isset($deb->texte[0]) and $deb->texte[0] == '(') |
|
| 2572 | + && (isset($last->texte[$n - 1]) and $last->texte[$n - 1] == ')')) |
|
| 2573 | + ) { |
|
| 2574 | + return $params; |
|
| 2575 | + } |
|
| 2576 | + $params[0][0]->texte = substr($deb->texte, 1); |
|
| 2577 | + // attention, on peut avoir k=0,j=0 ==> recalculer |
|
| 2578 | + $last = $params[$k][$j]; |
|
| 2579 | + $n = strlen($last->texte); |
|
| 2580 | + $params[$k][$j]->texte = substr($last->texte, 0, $n - 1); |
|
| 2581 | + $newp = array(); |
|
| 2582 | + foreach ($params as $v) { |
|
| 2583 | + if ($v[0]->type != 'texte') { |
|
| 2584 | + $newp[] = $v; |
|
| 2585 | + } else { |
|
| 2586 | + foreach (explode(',', $v[0]->texte) as $x) { |
|
| 2587 | + $t = new Texte; |
|
| 2588 | + $t->texte = $x; |
|
| 2589 | + $newp[] = array($t); |
|
| 2590 | + } |
|
| 2591 | + } |
|
| 2592 | + } |
|
| 2593 | + |
|
| 2594 | + return $newp; |
|
| 2595 | 2595 | } |
| 2596 | 2596 | |
| 2597 | 2597 | /** |
@@ -2610,89 +2610,89 @@ discard block |
||
| 2610 | 2610 | * - nom de la colonne de date (si le calcul n'est pas relatif) |
| 2611 | 2611 | **/ |
| 2612 | 2612 | function calculer_critere_infixe_date($idb, &$boucles, $col) { |
| 2613 | - if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z_]+)?$,", $col, $regs)) { |
|
| 2614 | - return ''; |
|
| 2615 | - } |
|
| 2616 | - |
|
| 2617 | - $boucle = $boucles[$idb]; |
|
| 2618 | - $table = $boucle->show; |
|
| 2619 | - |
|
| 2620 | - // si c'est une colonne de la table, ne rien faire |
|
| 2621 | - if (isset($table['field'][$col])) { |
|
| 2622 | - return ''; |
|
| 2623 | - } |
|
| 2624 | - |
|
| 2625 | - if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) { |
|
| 2626 | - return ''; |
|
| 2627 | - } |
|
| 2628 | - $pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']]) ? $GLOBALS['table_date'][$table['id_table']] : $table['date']; |
|
| 2629 | - |
|
| 2630 | - $col = $regs[1]; |
|
| 2631 | - if (isset($regs[3]) and $suite = $regs[3]) { |
|
| 2632 | - # Recherche de l'existence du champ date_xxxx, |
|
| 2633 | - # si oui choisir ce champ, sinon choisir xxxx |
|
| 2634 | - |
|
| 2635 | - if (isset($table['field']["date$suite"])) { |
|
| 2636 | - $date_orig = 'date' . $suite; |
|
| 2637 | - } else { |
|
| 2638 | - $date_orig = substr($suite, 1); |
|
| 2639 | - } |
|
| 2640 | - $pred = $date_orig; |
|
| 2641 | - } else { |
|
| 2642 | - if (isset($regs[2]) and $rel = $regs[2]) { |
|
| 2643 | - $pred = 'date'; |
|
| 2644 | - } |
|
| 2645 | - } |
|
| 2646 | - |
|
| 2647 | - $date_compare = "\"' . normaliser_date(" . |
|
| 2648 | - calculer_argument_precedent($idb, $pred, $boucles) . |
|
| 2649 | - ") . '\""; |
|
| 2650 | - |
|
| 2651 | - $col_vraie = $date_orig; |
|
| 2652 | - $date_orig = $boucle->id_table . '.' . $date_orig; |
|
| 2653 | - |
|
| 2654 | - switch ($col) { |
|
| 2655 | - case 'date': |
|
| 2656 | - $col = $date_orig; |
|
| 2657 | - break; |
|
| 2658 | - case 'jour': |
|
| 2659 | - $col = "DAYOFMONTH($date_orig)"; |
|
| 2660 | - break; |
|
| 2661 | - case 'mois': |
|
| 2662 | - $col = "MONTH($date_orig)"; |
|
| 2663 | - break; |
|
| 2664 | - case 'annee': |
|
| 2665 | - $col = "YEAR($date_orig)"; |
|
| 2666 | - break; |
|
| 2667 | - case 'heure': |
|
| 2668 | - $col = "DATE_FORMAT($date_orig, \\'%H:%i\\')"; |
|
| 2669 | - break; |
|
| 2670 | - case 'age': |
|
| 2671 | - $col = calculer_param_date("\'' . date('Y-m-d H:i:00') . '\'", $date_orig); |
|
| 2672 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2673 | - break; |
|
| 2674 | - case 'age_relatif': |
|
| 2675 | - $col = calculer_param_date($date_compare, $date_orig); |
|
| 2676 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2677 | - break; |
|
| 2678 | - case 'jour_relatif': |
|
| 2679 | - $col = "(TO_DAYS(" . $date_compare . ")-TO_DAYS(" . $date_orig . "))"; |
|
| 2680 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2681 | - break; |
|
| 2682 | - case 'mois_relatif': |
|
| 2683 | - $col = "MONTH(" . $date_compare . ")-MONTH(" . |
|
| 2684 | - $date_orig . ")+12*(YEAR(" . $date_compare . |
|
| 2685 | - ")-YEAR(" . $date_orig . "))"; |
|
| 2686 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2687 | - break; |
|
| 2688 | - case 'annee_relatif': |
|
| 2689 | - $col = "YEAR(" . $date_compare . ")-YEAR(" . |
|
| 2690 | - $date_orig . ")"; |
|
| 2691 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2692 | - break; |
|
| 2693 | - } |
|
| 2694 | - |
|
| 2695 | - return array($col, $col_vraie); |
|
| 2613 | + if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z_]+)?$,", $col, $regs)) { |
|
| 2614 | + return ''; |
|
| 2615 | + } |
|
| 2616 | + |
|
| 2617 | + $boucle = $boucles[$idb]; |
|
| 2618 | + $table = $boucle->show; |
|
| 2619 | + |
|
| 2620 | + // si c'est une colonne de la table, ne rien faire |
|
| 2621 | + if (isset($table['field'][$col])) { |
|
| 2622 | + return ''; |
|
| 2623 | + } |
|
| 2624 | + |
|
| 2625 | + if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) { |
|
| 2626 | + return ''; |
|
| 2627 | + } |
|
| 2628 | + $pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']]) ? $GLOBALS['table_date'][$table['id_table']] : $table['date']; |
|
| 2629 | + |
|
| 2630 | + $col = $regs[1]; |
|
| 2631 | + if (isset($regs[3]) and $suite = $regs[3]) { |
|
| 2632 | + # Recherche de l'existence du champ date_xxxx, |
|
| 2633 | + # si oui choisir ce champ, sinon choisir xxxx |
|
| 2634 | + |
|
| 2635 | + if (isset($table['field']["date$suite"])) { |
|
| 2636 | + $date_orig = 'date' . $suite; |
|
| 2637 | + } else { |
|
| 2638 | + $date_orig = substr($suite, 1); |
|
| 2639 | + } |
|
| 2640 | + $pred = $date_orig; |
|
| 2641 | + } else { |
|
| 2642 | + if (isset($regs[2]) and $rel = $regs[2]) { |
|
| 2643 | + $pred = 'date'; |
|
| 2644 | + } |
|
| 2645 | + } |
|
| 2646 | + |
|
| 2647 | + $date_compare = "\"' . normaliser_date(" . |
|
| 2648 | + calculer_argument_precedent($idb, $pred, $boucles) . |
|
| 2649 | + ") . '\""; |
|
| 2650 | + |
|
| 2651 | + $col_vraie = $date_orig; |
|
| 2652 | + $date_orig = $boucle->id_table . '.' . $date_orig; |
|
| 2653 | + |
|
| 2654 | + switch ($col) { |
|
| 2655 | + case 'date': |
|
| 2656 | + $col = $date_orig; |
|
| 2657 | + break; |
|
| 2658 | + case 'jour': |
|
| 2659 | + $col = "DAYOFMONTH($date_orig)"; |
|
| 2660 | + break; |
|
| 2661 | + case 'mois': |
|
| 2662 | + $col = "MONTH($date_orig)"; |
|
| 2663 | + break; |
|
| 2664 | + case 'annee': |
|
| 2665 | + $col = "YEAR($date_orig)"; |
|
| 2666 | + break; |
|
| 2667 | + case 'heure': |
|
| 2668 | + $col = "DATE_FORMAT($date_orig, \\'%H:%i\\')"; |
|
| 2669 | + break; |
|
| 2670 | + case 'age': |
|
| 2671 | + $col = calculer_param_date("\'' . date('Y-m-d H:i:00') . '\'", $date_orig); |
|
| 2672 | + $col_vraie = "";// comparer a un int (par defaut) |
|
| 2673 | + break; |
|
| 2674 | + case 'age_relatif': |
|
| 2675 | + $col = calculer_param_date($date_compare, $date_orig); |
|
| 2676 | + $col_vraie = "";// comparer a un int (par defaut) |
|
| 2677 | + break; |
|
| 2678 | + case 'jour_relatif': |
|
| 2679 | + $col = "(TO_DAYS(" . $date_compare . ")-TO_DAYS(" . $date_orig . "))"; |
|
| 2680 | + $col_vraie = "";// comparer a un int (par defaut) |
|
| 2681 | + break; |
|
| 2682 | + case 'mois_relatif': |
|
| 2683 | + $col = "MONTH(" . $date_compare . ")-MONTH(" . |
|
| 2684 | + $date_orig . ")+12*(YEAR(" . $date_compare . |
|
| 2685 | + ")-YEAR(" . $date_orig . "))"; |
|
| 2686 | + $col_vraie = "";// comparer a un int (par defaut) |
|
| 2687 | + break; |
|
| 2688 | + case 'annee_relatif': |
|
| 2689 | + $col = "YEAR(" . $date_compare . ")-YEAR(" . |
|
| 2690 | + $date_orig . ")"; |
|
| 2691 | + $col_vraie = "";// comparer a un int (par defaut) |
|
| 2692 | + break; |
|
| 2693 | + } |
|
| 2694 | + |
|
| 2695 | + return array($col, $col_vraie); |
|
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | /** |
@@ -2711,16 +2711,16 @@ discard block |
||
| 2711 | 2711 | * de colonne SQL et une date. |
| 2712 | 2712 | **/ |
| 2713 | 2713 | function calculer_param_date($date_compare, $date_orig) { |
| 2714 | - if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)) { |
|
| 2715 | - $init = "'\" . (\$x = $r[1]) . \"'"; |
|
| 2716 | - $date_compare = '\'$x\''; |
|
| 2717 | - } else { |
|
| 2718 | - $init = $date_compare; |
|
| 2719 | - } |
|
| 2720 | - |
|
| 2721 | - return |
|
| 2722 | - // optimisation : mais prevoir le support SQLite avant |
|
| 2723 | - "TIMESTAMPDIFF(HOUR,$date_orig,$init)/24"; |
|
| 2714 | + if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)) { |
|
| 2715 | + $init = "'\" . (\$x = $r[1]) . \"'"; |
|
| 2716 | + $date_compare = '\'$x\''; |
|
| 2717 | + } else { |
|
| 2718 | + $init = $date_compare; |
|
| 2719 | + } |
|
| 2720 | + |
|
| 2721 | + return |
|
| 2722 | + // optimisation : mais prevoir le support SQLite avant |
|
| 2723 | + "TIMESTAMPDIFF(HOUR,$date_orig,$init)/24"; |
|
| 2724 | 2724 | } |
| 2725 | 2725 | |
| 2726 | 2726 | /** |
@@ -2738,18 +2738,18 @@ discard block |
||
| 2738 | 2738 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2739 | 2739 | */ |
| 2740 | 2740 | function critere_DATA_source_dist($idb, &$boucles, $crit) { |
| 2741 | - $boucle = &$boucles[$idb]; |
|
| 2741 | + $boucle = &$boucles[$idb]; |
|
| 2742 | 2742 | |
| 2743 | - $args = array(); |
|
| 2744 | - foreach ($crit->param as &$param) { |
|
| 2745 | - array_push($args, |
|
| 2746 | - calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent)); |
|
| 2747 | - } |
|
| 2743 | + $args = array(); |
|
| 2744 | + foreach ($crit->param as &$param) { |
|
| 2745 | + array_push($args, |
|
| 2746 | + calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent)); |
|
| 2747 | + } |
|
| 2748 | 2748 | |
| 2749 | - $boucle->hash .= ' |
|
| 2749 | + $boucle->hash .= ' |
|
| 2750 | 2750 | $command[\'sourcemode\'] = ' . array_shift($args) . ";\n"; |
| 2751 | 2751 | |
| 2752 | - $boucle->hash .= ' |
|
| 2752 | + $boucle->hash .= ' |
|
| 2753 | 2753 | $command[\'source\'] = array(' . join(', ', $args) . ");\n"; |
| 2754 | 2754 | } |
| 2755 | 2755 | |
@@ -2767,8 +2767,8 @@ discard block |
||
| 2767 | 2767 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2768 | 2768 | */ |
| 2769 | 2769 | function critere_DATA_datacache_dist($idb, &$boucles, $crit) { |
| 2770 | - $boucle = &$boucles[$idb]; |
|
| 2771 | - $boucle->hash .= ' |
|
| 2770 | + $boucle = &$boucles[$idb]; |
|
| 2771 | + $boucle->hash .= ' |
|
| 2772 | 2772 | $command[\'datacache\'] = ' . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent) . ';'; |
| 2773 | 2773 | } |
| 2774 | 2774 | |
@@ -2784,12 +2784,12 @@ discard block |
||
| 2784 | 2784 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2785 | 2785 | */ |
| 2786 | 2786 | function critere_php_args_dist($idb, &$boucles, $crit) { |
| 2787 | - $boucle = &$boucles[$idb]; |
|
| 2788 | - $boucle->hash .= '$command[\'args\']=array();'; |
|
| 2789 | - foreach ($crit->param as $param) { |
|
| 2790 | - $boucle->hash .= ' |
|
| 2787 | + $boucle = &$boucles[$idb]; |
|
| 2788 | + $boucle->hash .= '$command[\'args\']=array();'; |
|
| 2789 | + foreach ($crit->param as $param) { |
|
| 2790 | + $boucle->hash .= ' |
|
| 2791 | 2791 | $command[\'args\'][] = ' . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ';'; |
| 2792 | - } |
|
| 2792 | + } |
|
| 2793 | 2793 | } |
| 2794 | 2794 | |
| 2795 | 2795 | /** |
@@ -2806,12 +2806,12 @@ discard block |
||
| 2806 | 2806 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2807 | 2807 | */ |
| 2808 | 2808 | function critere_DATA_liste_dist($idb, &$boucles, $crit) { |
| 2809 | - $boucle = &$boucles[$idb]; |
|
| 2810 | - $boucle->hash .= "\n\t" . '$command[\'liste\'] = array();' . "\n"; |
|
| 2811 | - foreach ($crit->param as $param) { |
|
| 2812 | - $boucle->hash .= "\t" . '$command[\'liste\'][] = ' . calculer_liste($param, $idb, $boucles, |
|
| 2813 | - $boucles[$idb]->id_parent) . ";\n"; |
|
| 2814 | - } |
|
| 2809 | + $boucle = &$boucles[$idb]; |
|
| 2810 | + $boucle->hash .= "\n\t" . '$command[\'liste\'] = array();' . "\n"; |
|
| 2811 | + foreach ($crit->param as $param) { |
|
| 2812 | + $boucle->hash .= "\t" . '$command[\'liste\'][] = ' . calculer_liste($param, $idb, $boucles, |
|
| 2813 | + $boucles[$idb]->id_parent) . ";\n"; |
|
| 2814 | + } |
|
| 2815 | 2815 | } |
| 2816 | 2816 | |
| 2817 | 2817 | /** |
@@ -2836,12 +2836,12 @@ discard block |
||
| 2836 | 2836 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2837 | 2837 | */ |
| 2838 | 2838 | function critere_DATA_enum_dist($idb, &$boucles, $crit) { |
| 2839 | - $boucle = &$boucles[$idb]; |
|
| 2840 | - $boucle->hash .= "\n\t" . '$command[\'enum\'] = array();' . "\n"; |
|
| 2841 | - foreach ($crit->param as $param) { |
|
| 2842 | - $boucle->hash .= "\t" . '$command[\'enum\'][] = ' . calculer_liste($param, $idb, $boucles, |
|
| 2843 | - $boucles[$idb]->id_parent) . ";\n"; |
|
| 2844 | - } |
|
| 2839 | + $boucle = &$boucles[$idb]; |
|
| 2840 | + $boucle->hash .= "\n\t" . '$command[\'enum\'] = array();' . "\n"; |
|
| 2841 | + foreach ($crit->param as $param) { |
|
| 2842 | + $boucle->hash .= "\t" . '$command[\'enum\'][] = ' . calculer_liste($param, $idb, $boucles, |
|
| 2843 | + $boucles[$idb]->id_parent) . ";\n"; |
|
| 2844 | + } |
|
| 2845 | 2845 | } |
| 2846 | 2846 | |
| 2847 | 2847 | /** |
@@ -2856,11 +2856,11 @@ discard block |
||
| 2856 | 2856 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2857 | 2857 | */ |
| 2858 | 2858 | function critere_DATA_datapath_dist($idb, &$boucles, $crit) { |
| 2859 | - $boucle = &$boucles[$idb]; |
|
| 2860 | - foreach ($crit->param as $param) { |
|
| 2861 | - $boucle->hash .= ' |
|
| 2859 | + $boucle = &$boucles[$idb]; |
|
| 2860 | + foreach ($crit->param as $param) { |
|
| 2861 | + $boucle->hash .= ' |
|
| 2862 | 2862 | $command[\'datapath\'][] = ' . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ';'; |
| 2863 | - } |
|
| 2863 | + } |
|
| 2864 | 2864 | } |
| 2865 | 2865 | |
| 2866 | 2866 | |
@@ -2892,20 +2892,20 @@ discard block |
||
| 2892 | 2892 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2893 | 2893 | */ |
| 2894 | 2894 | function critere_si_dist($idb, &$boucles, $crit) { |
| 2895 | - $boucle = &$boucles[$idb]; |
|
| 2896 | - // il faut initialiser 1 fois le tableau a chaque appel de la boucle |
|
| 2897 | - // (par exemple lorsque notre boucle est appelee dans une autre boucle) |
|
| 2898 | - // mais ne pas l'initialiser n fois si il y a n criteres {si } dans la boucle ! |
|
| 2899 | - $boucle->hash .= "\n\tif (!isset(\$si_init)) { \$command['si'] = array(); \$si_init = true; }\n"; |
|
| 2900 | - if ($crit->param) { |
|
| 2901 | - foreach ($crit->param as $param) { |
|
| 2902 | - $boucle->hash .= "\t\$command['si'][] = " |
|
| 2903 | - . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ";\n"; |
|
| 2904 | - } |
|
| 2905 | - // interdire {si 0} aussi ! |
|
| 2906 | - } else { |
|
| 2907 | - $boucle->hash .= '$command[\'si\'][] = 0;'; |
|
| 2908 | - } |
|
| 2895 | + $boucle = &$boucles[$idb]; |
|
| 2896 | + // il faut initialiser 1 fois le tableau a chaque appel de la boucle |
|
| 2897 | + // (par exemple lorsque notre boucle est appelee dans une autre boucle) |
|
| 2898 | + // mais ne pas l'initialiser n fois si il y a n criteres {si } dans la boucle ! |
|
| 2899 | + $boucle->hash .= "\n\tif (!isset(\$si_init)) { \$command['si'] = array(); \$si_init = true; }\n"; |
|
| 2900 | + if ($crit->param) { |
|
| 2901 | + foreach ($crit->param as $param) { |
|
| 2902 | + $boucle->hash .= "\t\$command['si'][] = " |
|
| 2903 | + . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ";\n"; |
|
| 2904 | + } |
|
| 2905 | + // interdire {si 0} aussi ! |
|
| 2906 | + } else { |
|
| 2907 | + $boucle->hash .= '$command[\'si\'][] = 0;'; |
|
| 2908 | + } |
|
| 2909 | 2909 | } |
| 2910 | 2910 | |
| 2911 | 2911 | /** |
@@ -2922,8 +2922,8 @@ discard block |
||
| 2922 | 2922 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2923 | 2923 | */ |
| 2924 | 2924 | function critere_POUR_tableau_dist($idb, &$boucles, $crit) { |
| 2925 | - $boucle = &$boucles[$idb]; |
|
| 2926 | - $boucle->hash .= ' |
|
| 2925 | + $boucle = &$boucles[$idb]; |
|
| 2926 | + $boucle->hash .= ' |
|
| 2927 | 2927 | $command[\'source\'] = array(' . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent) . '); |
| 2928 | 2928 | $command[\'sourcemode\'] = \'table\';'; |
| 2929 | 2929 | } |
@@ -2944,29 +2944,29 @@ discard block |
||
| 2944 | 2944 | */ |
| 2945 | 2945 | function critere_noeud_dist($idb, &$boucles, $crit) { |
| 2946 | 2946 | |
| 2947 | - $not = $crit->not; |
|
| 2948 | - $boucle = &$boucles[$idb]; |
|
| 2949 | - $primary = $boucle->primary; |
|
| 2947 | + $not = $crit->not; |
|
| 2948 | + $boucle = &$boucles[$idb]; |
|
| 2949 | + $primary = $boucle->primary; |
|
| 2950 | 2950 | |
| 2951 | - if (!$primary or strpos($primary, ',')) { |
|
| 2952 | - erreur_squelette(_T('zbug_doublon_sur_table_sans_cle_primaire'), $boucle); |
|
| 2951 | + if (!$primary or strpos($primary, ',')) { |
|
| 2952 | + erreur_squelette(_T('zbug_doublon_sur_table_sans_cle_primaire'), $boucle); |
|
| 2953 | 2953 | |
| 2954 | - return; |
|
| 2955 | - } |
|
| 2956 | - $table = $boucle->type_requete; |
|
| 2957 | - $table_sql = table_objet_sql(objet_type($table)); |
|
| 2954 | + return; |
|
| 2955 | + } |
|
| 2956 | + $table = $boucle->type_requete; |
|
| 2957 | + $table_sql = table_objet_sql(objet_type($table)); |
|
| 2958 | 2958 | |
| 2959 | - $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
|
| 2960 | - $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 2961 | - 'id_parent'; |
|
| 2959 | + $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
|
| 2960 | + $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 2961 | + 'id_parent'; |
|
| 2962 | 2962 | |
| 2963 | - $in = "IN"; |
|
| 2964 | - $where = array("'IN'", "'$boucle->id_table." . "$primary'", "'('.sql_get_select('$id_parent', '$table_sql').')'"); |
|
| 2965 | - if ($not) { |
|
| 2966 | - $where = array("'NOT'", $where); |
|
| 2967 | - } |
|
| 2963 | + $in = "IN"; |
|
| 2964 | + $where = array("'IN'", "'$boucle->id_table." . "$primary'", "'('.sql_get_select('$id_parent', '$table_sql').')'"); |
|
| 2965 | + if ($not) { |
|
| 2966 | + $where = array("'NOT'", $where); |
|
| 2967 | + } |
|
| 2968 | 2968 | |
| 2969 | - $boucle->where[] = $where; |
|
| 2969 | + $boucle->where[] = $where; |
|
| 2970 | 2970 | } |
| 2971 | 2971 | |
| 2972 | 2972 | /** |
@@ -2982,8 +2982,8 @@ discard block |
||
| 2982 | 2982 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 2983 | 2983 | */ |
| 2984 | 2984 | function critere_feuille_dist($idb, &$boucles, $crit) { |
| 2985 | - $not = $crit->not; |
|
| 2986 | - $crit->not = $not ? false : true; |
|
| 2987 | - critere_noeud_dist($idb, $boucles, $crit); |
|
| 2988 | - $crit->not = $not; |
|
| 2985 | + $not = $crit->not; |
|
| 2986 | + $crit->not = $not ? false : true; |
|
| 2987 | + critere_noeud_dist($idb, $boucles, $crit); |
|
| 2988 | + $crit->not = $not; |
|
| 2989 | 2989 | } |
@@ -46,10 +46,9 @@ discard block |
||
| 46 | 46 | $not = $crit->not; |
| 47 | 47 | $boucle = &$boucles[$idb]; |
| 48 | 48 | $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
| 49 | - $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 50 | - 'id_parent'; |
|
| 49 | + $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : 'id_parent'; |
|
| 51 | 50 | |
| 52 | - $c = array("'='", "'$boucle->id_table." . "$id_parent'", 0); |
|
| 51 | + $c = array("'='", "'$boucle->id_table."."$id_parent'", 0); |
|
| 53 | 52 | $boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c); |
| 54 | 53 | } |
| 55 | 54 | |
@@ -72,10 +71,10 @@ discard block |
||
| 72 | 71 | $id = $boucle->primary; |
| 73 | 72 | |
| 74 | 73 | if ($not or !$id) { |
| 75 | - return (array('zbug_critere_inconnu', array('critere' => $not . $crit->op))); |
|
| 74 | + return (array('zbug_critere_inconnu', array('critere' => $not.$crit->op))); |
|
| 76 | 75 | } |
| 77 | 76 | $arg = kwote(calculer_argument_precedent($idb, $id, $boucles)); |
| 78 | - $boucle->where[] = array("'!='", "'$boucle->id_table." . "$id'", $arg); |
|
| 77 | + $boucle->where[] = array("'!='", "'$boucle->id_table."."$id'", $arg); |
|
| 79 | 78 | } |
| 80 | 79 | |
| 81 | 80 | |
@@ -106,12 +105,12 @@ discard block |
||
| 106 | 105 | $not = ($crit->not ? '' : 'NOT'); |
| 107 | 106 | |
| 108 | 107 | // le doublon s'applique sur un type de boucle (article) |
| 109 | - $nom = "'" . $boucle->type_requete . "'"; |
|
| 108 | + $nom = "'".$boucle->type_requete."'"; |
|
| 110 | 109 | |
| 111 | 110 | // compléter le nom avec un nom précisé {doublons nom} |
| 112 | 111 | // on obtient $nom = "'article' . 'nom'" |
| 113 | 112 | if (isset($crit->param[0])) { |
| 114 | - $nom .= "." . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 113 | + $nom .= ".".calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent); |
|
| 115 | 114 | } |
| 116 | 115 | |
| 117 | 116 | // code qui déclarera l'index du stockage de nos doublons (pour éviter une notice PHP) |
@@ -123,13 +122,13 @@ discard block |
||
| 123 | 122 | // $doublons et son index, ici $nom |
| 124 | 123 | |
| 125 | 124 | // debut du code "sql_in('articles.id_article', " |
| 126 | - $debut_in = "sql_in('" . $boucle->id_table . '.' . $primary . "', "; |
|
| 125 | + $debut_in = "sql_in('".$boucle->id_table.'.'.$primary."', "; |
|
| 127 | 126 | // lecture des données du doublon "$doublons[$doublon_index[] = " |
| 128 | 127 | // Attention : boucle->doublons désigne une variable qu'on affecte |
| 129 | - $debut_doub = '$doublons[' . (!$not ? '' : ($boucle->doublons . "[]= ")); |
|
| 128 | + $debut_doub = '$doublons['.(!$not ? '' : ($boucle->doublons."[]= ")); |
|
| 130 | 129 | |
| 131 | 130 | // le debut complet du code des doublons |
| 132 | - $debut_doub = $debut_in . $debut_doub; |
|
| 131 | + $debut_doub = $debut_in.$debut_doub; |
|
| 133 | 132 | |
| 134 | 133 | // nom du doublon "('article' . 'nom')]" |
| 135 | 134 | $fin_doub = "($nom)]"; |
@@ -139,22 +138,22 @@ discard block |
||
| 139 | 138 | foreach ($boucle->where as $k => $w) { |
| 140 | 139 | if (strpos($w[0], $debut_doub) === 0) { |
| 141 | 140 | // fusionner le sql_in (du where) |
| 142 | - $boucle->where[$k][0] = $debut_doub . $fin_doub . ' . ' . substr($w[0], strlen($debut_in)); |
|
| 141 | + $boucle->where[$k][0] = $debut_doub.$fin_doub.' . '.substr($w[0], strlen($debut_in)); |
|
| 143 | 142 | // fusionner l'initialisation (du hash) pour faire plus joli |
| 144 | 143 | $x = strpos($boucle->hash, $init_comment); |
| 145 | 144 | $len = strlen($init_comment); |
| 146 | 145 | $boucle->hash = |
| 147 | - substr($boucle->hash, 0, $x + $len) . $init_code . substr($boucle->hash, $x + $len); |
|
| 146 | + substr($boucle->hash, 0, $x + $len).$init_code.substr($boucle->hash, $x + $len); |
|
| 148 | 147 | |
| 149 | 148 | return; |
| 150 | 149 | } |
| 151 | 150 | } |
| 152 | 151 | |
| 153 | 152 | // mettre l'ensemble dans un tableau pour que ce ne soit pas vu comme une constante |
| 154 | - $boucle->where[] = array($debut_doub . $fin_doub . ", '" . $not . "')"); |
|
| 153 | + $boucle->where[] = array($debut_doub.$fin_doub.", '".$not."')"); |
|
| 155 | 154 | |
| 156 | 155 | // déclarer le doublon s'il n'existe pas encore |
| 157 | - $boucle->hash .= $init_comment . $init_code; |
|
| 156 | + $boucle->hash .= $init_comment.$init_code; |
|
| 158 | 157 | |
| 159 | 158 | |
| 160 | 159 | # la ligne suivante avait l'intention d'eviter une collecte deja faite |
@@ -215,10 +214,10 @@ discard block |
||
| 215 | 214 | $un = $un[0]->texte; |
| 216 | 215 | $deux = $deux[0]->texte; |
| 217 | 216 | if ($deux) { |
| 218 | - $boucles[$idb]->limit = 'intval($Pile[0]["debut' . |
|
| 219 | - $un . |
|
| 220 | - '"]) . ",' . |
|
| 221 | - $deux . |
|
| 217 | + $boucles[$idb]->limit = 'intval($Pile[0]["debut'. |
|
| 218 | + $un. |
|
| 219 | + '"]) . ",'. |
|
| 220 | + $deux. |
|
| 222 | 221 | '"'; |
| 223 | 222 | } else { |
| 224 | 223 | calculer_critere_DEFAUT_dist($idb, $boucles, $crit); |
@@ -281,26 +280,26 @@ discard block |
||
| 281 | 280 | $type = calculer_liste(array($crit->param[1][0]), $idb, $boucles, $boucle->id_parent); |
| 282 | 281 | } |
| 283 | 282 | |
| 284 | - $debut = ($type[0] !== "'") ? "'debut'.$type" : ("'debut" . substr($type, 1)); |
|
| 283 | + $debut = ($type[0] !== "'") ? "'debut'.$type" : ("'debut".substr($type, 1)); |
|
| 285 | 284 | $boucle->modificateur['debut_nom'] = $type; |
| 286 | 285 | $partie = |
| 287 | 286 | // tester si le numero de page demande est de la forme '@yyy' |
| 288 | - 'isset($Pile[0][' . $debut . ']) ? $Pile[0][' . $debut . '] : _request(' . $debut . ");\n" |
|
| 287 | + 'isset($Pile[0]['.$debut.']) ? $Pile[0]['.$debut.'] : _request('.$debut.");\n" |
|
| 289 | 288 | . "\tif(substr(\$debut_boucle,0,1)=='@'){\n" |
| 290 | - . "\t\t" . '$debut_boucle = $Pile[0][' . $debut . '] = quete_debut_pagination(\'' . $boucle->primary . '\',$Pile[0][\'@' . $boucle->primary . '\'] = substr($debut_boucle,1),' . $pas . ',$iter);' . "\n" |
|
| 291 | - . "\t\t" . '$iter->seek(0);' . "\n" |
|
| 289 | + . "\t\t".'$debut_boucle = $Pile[0]['.$debut.'] = quete_debut_pagination(\''.$boucle->primary.'\',$Pile[0][\'@'.$boucle->primary.'\'] = substr($debut_boucle,1),'.$pas.',$iter);'."\n" |
|
| 290 | + . "\t\t".'$iter->seek(0);'."\n" |
|
| 292 | 291 | . "\t}\n" |
| 293 | - . "\t" . '$debut_boucle = intval($debut_boucle)'; |
|
| 292 | + . "\t".'$debut_boucle = intval($debut_boucle)'; |
|
| 294 | 293 | |
| 295 | 294 | $boucle->hash .= ' |
| 296 | - $command[\'pagination\'] = array((isset($Pile[0][' . $debut . ']) ? $Pile[0][' . $debut . '] : null), ' . $pas . ');'; |
|
| 295 | + $command[\'pagination\'] = array((isset($Pile[0][' . $debut.']) ? $Pile[0]['.$debut.'] : null), '.$pas.');'; |
|
| 297 | 296 | |
| 298 | 297 | $boucle->total_parties = $pas; |
| 299 | 298 | calculer_parties($boucles, $idb, $partie, 'p+'); |
| 300 | 299 | // ajouter la cle primaire dans le select pour pouvoir gerer la pagination referencee par @id |
| 301 | 300 | // sauf si pas de primaire, ou si primaire composee |
| 302 | 301 | // dans ce cas, on ne sait pas gerer une pagination indirecte |
| 303 | - $t = $boucle->id_table . '.' . $boucle->primary; |
|
| 302 | + $t = $boucle->id_table.'.'.$boucle->primary; |
|
| 304 | 303 | if ($boucle->primary |
| 305 | 304 | and !preg_match('/[,\s]/', $boucle->primary) |
| 306 | 305 | and !in_array($t, $boucle->select) |
@@ -346,24 +345,24 @@ discard block |
||
| 346 | 345 | $boucle->hash .= ' |
| 347 | 346 | // RECHERCHE' |
| 348 | 347 | . ($crit->cond ? ' |
| 349 | - if (!strlen(' . $quoi . ')){ |
|
| 348 | + if (!strlen(' . $quoi.')){ |
|
| 350 | 349 | list($rech_select, $rech_where) = array("0 as points",""); |
| 351 | - } else' : '') . ' |
|
| 350 | + } else' : '').' |
|
| 352 | 351 | { |
| 353 | 352 | $prepare_recherche = charger_fonction(\'prepare_recherche\', \'inc\'); |
| 354 | - list($rech_select, $rech_where) = $prepare_recherche(' . $quoi . ', "' . $boucle->id_table . '", "' . $crit->cond . '","' . $boucle->sql_serveur . '",' . $_modificateur . ',"' . $boucle->primary . '"); |
|
| 353 | + list($rech_select, $rech_where) = $prepare_recherche(' . $quoi.', "'.$boucle->id_table.'", "'.$crit->cond.'","'.$boucle->sql_serveur.'",'.$_modificateur.',"'.$boucle->primary.'"); |
|
| 355 | 354 | } |
| 356 | 355 | '; |
| 357 | 356 | |
| 358 | 357 | |
| 359 | - $t = $boucle->id_table . '.' . $boucle->primary; |
|
| 358 | + $t = $boucle->id_table.'.'.$boucle->primary; |
|
| 360 | 359 | if (!in_array($t, $boucles[$idb]->select)) { |
| 361 | 360 | $boucle->select[] = $t; |
| 362 | 361 | } # pour postgres, neuneu ici |
| 363 | 362 | // jointure uniquement sur le serveur principal |
| 364 | 363 | // (on ne peut joindre une table d'un serveur distant avec la table des resultats du serveur principal) |
| 365 | 364 | if (!$boucle->sql_serveur) { |
| 366 | - $boucle->join['resultats'] = array("'" . $boucle->id_table . "'", "'id'", "'" . $boucle->primary . "'"); |
|
| 365 | + $boucle->join['resultats'] = array("'".$boucle->id_table."'", "'id'", "'".$boucle->primary."'"); |
|
| 367 | 366 | $boucle->from['resultats'] = 'spip_resultats'; |
| 368 | 367 | } |
| 369 | 368 | $boucle->select[] = '$rech_select'; |
@@ -430,7 +429,7 @@ discard block |
||
| 430 | 429 | $c = |
| 431 | 430 | array( |
| 432 | 431 | "'OR'", |
| 433 | - array("'='", "'$table." . "id_trad'", "'$table.$prim'"), |
|
| 432 | + array("'='", "'$table."."id_trad'", "'$table.$prim'"), |
|
| 434 | 433 | array("'='", "'$table.id_trad'", "'0'") |
| 435 | 434 | ); |
| 436 | 435 | $boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c); |
@@ -453,16 +452,15 @@ discard block |
||
| 453 | 452 | $boucle = &$boucles[$idb]; |
| 454 | 453 | $arg = kwote(calculer_argument_precedent($idb, 'id_parent', $boucles)); |
| 455 | 454 | $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
| 456 | - $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 457 | - 'id_parent'; |
|
| 458 | - $mparent = $boucle->id_table . '.' . $id_parent; |
|
| 455 | + $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : 'id_parent'; |
|
| 456 | + $mparent = $boucle->id_table.'.'.$id_parent; |
|
| 459 | 457 | |
| 460 | 458 | if ($boucle->type_requete == 'rubriques' or isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'])) { |
| 461 | 459 | $boucle->where[] = array("'='", "'$mparent'", $arg); |
| 462 | 460 | |
| 463 | 461 | } // le cas FORUMS est gere dans le plugin forum, dans la fonction critere_FORUMS_meme_parent_dist() |
| 464 | 462 | else { |
| 465 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . ' ' . $boucle->type_requete))); |
|
| 463 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op.' '.$boucle->type_requete))); |
|
| 466 | 464 | } |
| 467 | 465 | } |
| 468 | 466 | |
@@ -515,16 +513,15 @@ discard block |
||
| 515 | 513 | if (count(trouver_champs_decomposes($champ, $desc)) > 1) { |
| 516 | 514 | $decompose = decompose_champ_id_objet($champ); |
| 517 | 515 | $champ = array_shift($decompose); |
| 518 | - $boucle->where[] = array("'='", _q($cle . "." . reset($decompose)), '"' . sql_quote(end($decompose)) . '"'); |
|
| 516 | + $boucle->where[] = array("'='", _q($cle.".".reset($decompose)), '"'.sql_quote(end($decompose)).'"'); |
|
| 519 | 517 | } |
| 520 | 518 | } else { |
| 521 | 519 | $cle = $boucle->id_table; |
| 522 | 520 | } |
| 523 | 521 | |
| 524 | - $c = "sql_in('$cle" . ".$champ', calcul_branche_in($arg)" |
|
| 525 | - . ($not ? ", 'NOT'" : '') . ")"; |
|
| 526 | - $boucle->where[] = !$crit->cond ? $c : |
|
| 527 | - ("($arg ? $c : " . ($not ? "'0=1'" : "'1=1'") . ')'); |
|
| 522 | + $c = "sql_in('$cle".".$champ', calcul_branche_in($arg)" |
|
| 523 | + . ($not ? ", 'NOT'" : '').")"; |
|
| 524 | + $boucle->where[] = !$crit->cond ? $c : ("($arg ? $c : ".($not ? "'0=1'" : "'1=1'").')'); |
|
| 528 | 525 | } |
| 529 | 526 | |
| 530 | 527 | /** |
@@ -544,9 +541,9 @@ discard block |
||
| 544 | 541 | $not = ($crit->not ? 'NOT' : ''); |
| 545 | 542 | $serveur = $boucle->sql_serveur; |
| 546 | 543 | |
| 547 | - $c = "sql_in('" . |
|
| 548 | - $boucle->id_table . '.' . $boucle->primary |
|
| 549 | - . "', lister_objets_avec_logos('" . $boucle->primary . "'), '$not', '$serveur')"; |
|
| 544 | + $c = "sql_in('". |
|
| 545 | + $boucle->id_table.'.'.$boucle->primary |
|
| 546 | + . "', lister_objets_avec_logos('".$boucle->primary."'), '$not', '$serveur')"; |
|
| 550 | 547 | |
| 551 | 548 | $boucle->where[] = $c; |
| 552 | 549 | } |
@@ -578,7 +575,7 @@ discard block |
||
| 578 | 575 | $t = table_objet_sql($r[1]); |
| 579 | 576 | $t = array_search($t, $boucles[$idb]->from); |
| 580 | 577 | if ($t) { |
| 581 | - $t .= '.' . $r[2]; |
|
| 578 | + $t .= '.'.$r[2]; |
|
| 582 | 579 | } |
| 583 | 580 | } |
| 584 | 581 | } else { |
@@ -593,7 +590,7 @@ discard block |
||
| 593 | 590 | $boucles[$idb]->select[] = $t; |
| 594 | 591 | } |
| 595 | 592 | } else { |
| 596 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . ' ?'))); |
|
| 593 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op.' ?'))); |
|
| 597 | 594 | } |
| 598 | 595 | } |
| 599 | 596 | |
@@ -613,7 +610,7 @@ discard block |
||
| 613 | 610 | * @param Critere $crit Paramètres du critère dans cette boucle |
| 614 | 611 | * @return void |
| 615 | 612 | **/ |
| 616 | -function critere_fusion_supprimer_dist($idb, &$boucles, $crit){ |
|
| 613 | +function critere_fusion_supprimer_dist($idb, &$boucles, $crit) { |
|
| 617 | 614 | $boucles[$idb]->group = array(); |
| 618 | 615 | } |
| 619 | 616 | |
@@ -663,26 +660,26 @@ discard block |
||
| 663 | 660 | (false !== $i = strpos($boucle->order[$n - 1], 'ASC')) |
| 664 | 661 | OR (false !== $i = strpos($boucle->order[$n - 1], 'DESC')) |
| 665 | 662 | ) { |
| 666 | - $boucle->order[$n - 1] = substr_replace($boucle->order[$n - 1], "' . " . $boucle->modificateur['collate'] . " . ' ", $i, 0); |
|
| 663 | + $boucle->order[$n - 1] = substr_replace($boucle->order[$n - 1], "' . ".$boucle->modificateur['collate']." . ' ", $i, 0); |
|
| 667 | 664 | } else { |
| 668 | - $boucle->order[$n - 1] .= " . " . $boucle->modificateur['collate']; |
|
| 665 | + $boucle->order[$n - 1] .= " . ".$boucle->modificateur['collate']; |
|
| 669 | 666 | } |
| 670 | 667 | } |
| 671 | 668 | } else { |
| 672 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . " " . count($boucles[$idb]->order)))); |
|
| 669 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op." ".count($boucles[$idb]->order)))); |
|
| 673 | 670 | } |
| 674 | 671 | } |
| 675 | 672 | |
| 676 | 673 | // https://code.spip.net/@calculer_critere_arg_dynamique |
| 677 | 674 | function calculer_critere_arg_dynamique($idb, &$boucles, $crit, $suffix = '') { |
| 678 | 675 | $boucle = $boucles[$idb]; |
| 679 | - $alt = "('" . $boucle->id_table . '.\' . $x' . $suffix . ')'; |
|
| 680 | - $var = '$champs_' . $idb; |
|
| 676 | + $alt = "('".$boucle->id_table.'.\' . $x'.$suffix.')'; |
|
| 677 | + $var = '$champs_'.$idb; |
|
| 681 | 678 | $desc = (strpos($boucle->in, "static $var =") !== false); |
| 682 | 679 | if (!$desc) { |
| 683 | 680 | $desc = $boucle->show['field']; |
| 684 | 681 | $desc = implode(',', array_map('_q', array_keys($desc))); |
| 685 | - $boucles[$idb]->in .= "\n\tstatic $var = array(" . $desc . ");"; |
|
| 682 | + $boucles[$idb]->in .= "\n\tstatic $var = array(".$desc.");"; |
|
| 686 | 683 | } |
| 687 | 684 | if ($desc) { |
| 688 | 685 | $alt = "(in_array(\$x, $var) ? $alt :(\$x$suffix))"; |
@@ -757,7 +754,7 @@ discard block |
||
| 757 | 754 | $sens = " . ' DESC'"; |
| 758 | 755 | } |
| 759 | 756 | if (isset($boucle->modificateur['collate'])) { |
| 760 | - $collecte = ' . ' . $boucle->modificateur['collate']; |
|
| 757 | + $collecte = ' . '.$boucle->modificateur['collate']; |
|
| 761 | 758 | } |
| 762 | 759 | |
| 763 | 760 | // Pour chaque paramètre du critère |
@@ -779,14 +776,14 @@ discard block |
||
| 779 | 776 | if (preg_match(",^(\w+)[\s]+(.*)$,", $par, $m)) { |
| 780 | 777 | $expression = trim($m[1]); |
| 781 | 778 | $champ = trim($m[2]); |
| 782 | - if (function_exists($f = 'calculer_critere_par_expression_' . $expression)) { |
|
| 779 | + if (function_exists($f = 'calculer_critere_par_expression_'.$expression)) { |
|
| 783 | 780 | $order = $f($idb, $boucles, $crit, $tri, $champ); |
| 784 | 781 | } else { |
| 785 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 782 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." $par")); |
|
| 786 | 783 | } |
| 787 | 784 | |
| 788 | 785 | // tris de la forme {par champ} ou {par FONCTION(champ)} |
| 789 | - } elseif (preg_match(",^" . CHAMP_SQL_PLUS_FONC . '$,is', $par, $match)) { |
|
| 786 | + } elseif (preg_match(",^".CHAMP_SQL_PLUS_FONC.'$,is', $par, $match)) { |
|
| 790 | 787 | // {par FONCTION(champ)} |
| 791 | 788 | if (count($match) > 2) { |
| 792 | 789 | $par = substr($match[2], 1, -1); |
@@ -796,7 +793,7 @@ discard block |
||
| 796 | 793 | if ($par == 'hasard') { |
| 797 | 794 | $order = calculer_critere_par_hasard($idb, $boucles, $crit); |
| 798 | 795 | } elseif ($par == 'date' and !empty($boucle->show['date'])) { |
| 799 | - $order = "'" . $boucle->id_table . "." . $boucle->show['date'] . "'"; |
|
| 796 | + $order = "'".$boucle->id_table.".".$boucle->show['date']."'"; |
|
| 800 | 797 | } else { |
| 801 | 798 | // cas général {par champ}, {par table.champ}, ... |
| 802 | 799 | $order = calculer_critere_par_champ($idb, $boucles, $crit, $par); |
@@ -805,7 +802,7 @@ discard block |
||
| 805 | 802 | |
| 806 | 803 | // on ne sait pas traiter… |
| 807 | 804 | else { |
| 808 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 805 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." $par")); |
|
| 809 | 806 | } |
| 810 | 807 | |
| 811 | 808 | // En cas d'erreur de squelette retournée par une fonction |
@@ -825,14 +822,14 @@ discard block |
||
| 825 | 822 | |
| 826 | 823 | if ($fct) { |
| 827 | 824 | if (preg_match("/^\s*'(.*)'\s*$/", $order, $r)) { |
| 828 | - $order = "'$fct(" . $r[1] . ")'"; |
|
| 825 | + $order = "'$fct(".$r[1].")'"; |
|
| 829 | 826 | } else { |
| 830 | 827 | $order = "'$fct(' . $order . ')'"; |
| 831 | 828 | } |
| 832 | 829 | } |
| 833 | - $t = $order . $collecte . $sens; |
|
| 830 | + $t = $order.$collecte.$sens; |
|
| 834 | 831 | if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) { |
| 835 | - $t = $r[1] . $r[2]; |
|
| 832 | + $t = $r[1].$r[2]; |
|
| 836 | 833 | } |
| 837 | 834 | |
| 838 | 835 | $boucle->order[] = $t; |
@@ -882,16 +879,16 @@ discard block |
||
| 882 | 879 | function calculer_critere_par_expression_num($idb, &$boucles, $crit, $tri, $champ) { |
| 883 | 880 | $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
| 884 | 881 | if (is_array($_champ)) { |
| 885 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " num $champ")); |
|
| 882 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." num $champ")); |
|
| 886 | 883 | } |
| 887 | 884 | $boucle = &$boucles[$idb]; |
| 888 | - $texte = '0+' . $_champ; |
|
| 885 | + $texte = '0+'.$_champ; |
|
| 889 | 886 | $suite = calculer_liste($tri, $idb, $boucles, $boucle->id_parent); |
| 890 | 887 | if ($suite !== "''") { |
| 891 | - $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; |
|
| 888 | + $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')"." . \""; |
|
| 892 | 889 | } |
| 893 | - $asnum = 'num' . ($boucle->order ? count($boucle->order) : ""); |
|
| 894 | - $boucle->select[] = $texte . " AS $asnum"; |
|
| 890 | + $asnum = 'num'.($boucle->order ? count($boucle->order) : ""); |
|
| 891 | + $boucle->select[] = $texte." AS $asnum"; |
|
| 895 | 892 | |
| 896 | 893 | $orderassinum = calculer_critere_par_expression_sinum($idb, $boucles, $crit, $tri, $champ); |
| 897 | 894 | $orderassinum = trim($orderassinum, "'"); |
@@ -920,13 +917,13 @@ discard block |
||
| 920 | 917 | function calculer_critere_par_expression_sinum($idb, &$boucles, $crit, $tri, $champ) { |
| 921 | 918 | $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
| 922 | 919 | if (is_array($_champ)) { |
| 923 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " sinum $champ")); |
|
| 920 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." sinum $champ")); |
|
| 924 | 921 | } |
| 925 | 922 | $boucle = &$boucles[$idb]; |
| 926 | - $texte = '0+' . $_champ; |
|
| 923 | + $texte = '0+'.$_champ; |
|
| 927 | 924 | $suite = calculer_liste($tri, $idb, $boucles, $boucle->id_parent); |
| 928 | 925 | if ($suite !== "''") { |
| 929 | - $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; |
|
| 926 | + $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')"." . \""; |
|
| 930 | 927 | } |
| 931 | 928 | |
| 932 | 929 | $as = false; |
@@ -942,8 +939,8 @@ discard block |
||
| 942 | 939 | } |
| 943 | 940 | |
| 944 | 941 | if (!$as) { |
| 945 | - $as = 'sinum' . ($boucle->order ? count($boucle->order) : ""); |
|
| 946 | - $boucle->select[] = $select . $as; |
|
| 942 | + $as = 'sinum'.($boucle->order ? count($boucle->order) : ""); |
|
| 943 | + $boucle->select[] = $select.$as; |
|
| 947 | 944 | } |
| 948 | 945 | $order = "'$as'"; |
| 949 | 946 | return $order; |
@@ -968,10 +965,10 @@ discard block |
||
| 968 | 965 | function calculer_critere_par_expression_multi($idb, &$boucles, $crit, $tri, $champ) { |
| 969 | 966 | $_champ = calculer_critere_par_champ($idb, $boucles, $crit, $champ, true); |
| 970 | 967 | if (is_array($_champ)) { |
| 971 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " multi $champ")); |
|
| 968 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." multi $champ")); |
|
| 972 | 969 | } |
| 973 | 970 | $boucle = &$boucles[$idb]; |
| 974 | - $boucle->select[] = "\".sql_multi('" . $_champ . "', \$GLOBALS['spip_lang']).\""; |
|
| 971 | + $boucle->select[] = "\".sql_multi('".$_champ."', \$GLOBALS['spip_lang']).\""; |
|
| 975 | 972 | $order = "'multi'"; |
| 976 | 973 | return $order; |
| 977 | 974 | } |
@@ -991,13 +988,13 @@ discard block |
||
| 991 | 988 | * @param bool $raw Retourne le champ pour le compilateur ("'alias.champ'") ou brut ('alias.champ') |
| 992 | 989 | * @return array|string |
| 993 | 990 | */ |
| 994 | -function calculer_critere_par_champ($idb, &$boucles, $crit, $par, $raw = false) { |
|
| 991 | +function calculer_critere_par_champ($idb, &$boucles, $crit, $par, $raw = false) { |
|
| 995 | 992 | $boucle = &$boucles[$idb]; |
| 996 | 993 | $desc = $boucle->show; |
| 997 | 994 | |
| 998 | 995 | // le champ existe dans la table, pas de souci (le plus commun) |
| 999 | 996 | if (isset($desc['field'][$par])) { |
| 1000 | - $par = $boucle->id_table . "." . $par; |
|
| 997 | + $par = $boucle->id_table.".".$par; |
|
| 1001 | 998 | } |
| 1002 | 999 | // le champ est peut être une jointure |
| 1003 | 1000 | else { |
@@ -1018,24 +1015,24 @@ discard block |
||
| 1018 | 1015 | // Sinon on cherche le champ dans les tables possibles de jointures |
| 1019 | 1016 | // Si la table est déjà dans le from, on la réutilise. |
| 1020 | 1017 | if ($infos = chercher_champ_dans_tables($champ, $boucle->from, $boucle->sql_serveur, $table)) { |
| 1021 | - $par = $infos['alias'] . "." . $champ; |
|
| 1018 | + $par = $infos['alias'].".".$champ; |
|
| 1022 | 1019 | } elseif ( |
| 1023 | 1020 | $boucle->jointures_explicites |
| 1024 | 1021 | and $alias = trouver_jointure_champ($champ, $boucle, explode(' ', $boucle->jointures_explicites), false, $table) |
| 1025 | 1022 | ) { |
| 1026 | - $par = $alias . "." . $champ; |
|
| 1023 | + $par = $alias.".".$champ; |
|
| 1027 | 1024 | } elseif ($alias = trouver_jointure_champ($champ, $boucle, $boucle->jointures, false, $table)) { |
| 1028 | - $par = $alias . "." . $champ; |
|
| 1025 | + $par = $alias.".".$champ; |
|
| 1029 | 1026 | // en spécifiant directement l'alias {par L2.titre} (situation hasardeuse tout de même) |
| 1030 | 1027 | } elseif ( |
| 1031 | 1028 | $table_alias |
| 1032 | 1029 | and isset($boucle->from[$table_alias]) |
| 1033 | 1030 | and $infos = chercher_champ_dans_tables($champ, $boucle->from, $boucle->sql_serveur, $boucle->from[$table_alias]) |
| 1034 | 1031 | ) { |
| 1035 | - $par = $infos['alias'] . "." . $champ; |
|
| 1032 | + $par = $infos['alias'].".".$champ; |
|
| 1036 | 1033 | } elseif ($table) { |
| 1037 | 1034 | // On avait table + champ, mais on ne les a pas trouvés |
| 1038 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " $par")); |
|
| 1035 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." $par")); |
|
| 1039 | 1036 | } else { |
| 1040 | 1037 | // Sinon tant pis, ca doit etre un champ synthetise (cf points) |
| 1041 | 1038 | } |
@@ -1059,7 +1056,7 @@ discard block |
||
| 1059 | 1056 | if (!$t) { |
| 1060 | 1057 | $t = trouver_jointure_champ($champ, $boucle); |
| 1061 | 1058 | } |
| 1062 | - return !$t ? '' : ("'" . $t . '.' . $champ . "'"); |
|
| 1059 | + return !$t ? '' : ("'".$t.'.'.$champ."'"); |
|
| 1063 | 1060 | } |
| 1064 | 1061 | |
| 1065 | 1062 | /** |
@@ -1104,9 +1101,9 @@ discard block |
||
| 1104 | 1101 | $boucle->default_order[] = ' DESC'; |
| 1105 | 1102 | } |
| 1106 | 1103 | } else { |
| 1107 | - $t = $boucle->order[$n - 1] . " . $order"; |
|
| 1104 | + $t = $boucle->order[$n - 1]." . $order"; |
|
| 1108 | 1105 | if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) { |
| 1109 | - $t = $r[1] . $r[2]; |
|
| 1106 | + $t = $r[1].$r[2]; |
|
| 1110 | 1107 | } |
| 1111 | 1108 | $boucle->order[$n - 1] = $t; |
| 1112 | 1109 | } |
@@ -1120,11 +1117,11 @@ discard block |
||
| 1120 | 1117 | * @param $crit |
| 1121 | 1118 | * @return array|string |
| 1122 | 1119 | */ |
| 1123 | -function critere_par_ordre_liste_dist($idb, &$boucles, $crit){ |
|
| 1120 | +function critere_par_ordre_liste_dist($idb, &$boucles, $crit) { |
|
| 1124 | 1121 | $boucle = &$boucles[$idb]; |
| 1125 | 1122 | |
| 1126 | 1123 | $sens = $collecte = ''; |
| 1127 | - if ($crit->not){ |
|
| 1124 | + if ($crit->not) { |
|
| 1128 | 1125 | $sens = " . ' DESC'"; |
| 1129 | 1126 | } |
| 1130 | 1127 | |
@@ -1134,14 +1131,14 @@ discard block |
||
| 1134 | 1131 | $res = critere_parinverse($idb, $boucles, $crit2); |
| 1135 | 1132 | |
| 1136 | 1133 | // erreur ? |
| 1137 | - if (is_array($res)){ |
|
| 1134 | + if (is_array($res)) { |
|
| 1138 | 1135 | return $res; |
| 1139 | 1136 | } |
| 1140 | 1137 | |
| 1141 | 1138 | $_order = array_pop($boucle->order); |
| 1142 | 1139 | |
| 1143 | 1140 | $_liste = calculer_liste($crit->param[1], array(), $boucles, $boucles[$idb]->id_parent); |
| 1144 | - $boucle->order[] = "'FIELD(' . $_order . ',' . ((\$zl=formate_liste_critere_par_ordre_liste($_liste,'" . $boucle->sql_serveur . "')) ? \$zl : '0').')'$sens"; |
|
| 1141 | + $boucle->order[] = "'FIELD(' . $_order . ',' . ((\$zl=formate_liste_critere_par_ordre_liste($_liste,'".$boucle->sql_serveur."')) ? \$zl : '0').')'$sens"; |
|
| 1145 | 1142 | } |
| 1146 | 1143 | |
| 1147 | 1144 | |
@@ -1150,7 +1147,7 @@ discard block |
||
| 1150 | 1147 | $params = $crit->param; |
| 1151 | 1148 | |
| 1152 | 1149 | if (count($params) < 1) { |
| 1153 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " ?")); |
|
| 1150 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." ?")); |
|
| 1154 | 1151 | } |
| 1155 | 1152 | |
| 1156 | 1153 | $boucle = &$boucles[$idb]; |
@@ -1171,7 +1168,7 @@ discard block |
||
| 1171 | 1168 | if ((count($date) == 1) and ($date[0]->type == 'texte')) { |
| 1172 | 1169 | $date = $date[0]->texte; |
| 1173 | 1170 | if (!isset($fields[$date])) { |
| 1174 | - return array('zbug_critere_inconnu', array('critere' => $crit->op . " " . $date)); |
|
| 1171 | + return array('zbug_critere_inconnu', array('critere' => $crit->op." ".$date)); |
|
| 1175 | 1172 | } |
| 1176 | 1173 | } else { |
| 1177 | 1174 | $a = calculer_liste($date, $idb, $boucles, $parent); |
@@ -1183,38 +1180,38 @@ discard block |
||
| 1183 | 1180 | $date = "'.(($cond)\n?\$a:\"$defaut\").'"; |
| 1184 | 1181 | } |
| 1185 | 1182 | $annee = $params ? array_shift($params) : ""; |
| 1186 | - $annee = "\n" . 'sprintf("%04d", ($x = ' . |
|
| 1187 | - calculer_liste($annee, $idb, $boucles, $parent) . |
|
| 1183 | + $annee = "\n".'sprintf("%04d", ($x = '. |
|
| 1184 | + calculer_liste($annee, $idb, $boucles, $parent). |
|
| 1188 | 1185 | ') ? $x : date("Y"))'; |
| 1189 | 1186 | |
| 1190 | 1187 | $mois = $params ? array_shift($params) : ""; |
| 1191 | - $mois = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1192 | - calculer_liste($mois, $idb, $boucles, $parent) . |
|
| 1188 | + $mois = "\n".'sprintf("%02d", ($x = '. |
|
| 1189 | + calculer_liste($mois, $idb, $boucles, $parent). |
|
| 1193 | 1190 | ') ? $x : date("m"))'; |
| 1194 | 1191 | |
| 1195 | 1192 | $jour = $params ? array_shift($params) : ""; |
| 1196 | - $jour = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1197 | - calculer_liste($jour, $idb, $boucles, $parent) . |
|
| 1193 | + $jour = "\n".'sprintf("%02d", ($x = '. |
|
| 1194 | + calculer_liste($jour, $idb, $boucles, $parent). |
|
| 1198 | 1195 | ') ? $x : date("d"))'; |
| 1199 | 1196 | |
| 1200 | 1197 | $annee2 = $params ? array_shift($params) : ""; |
| 1201 | - $annee2 = "\n" . 'sprintf("%04d", ($x = ' . |
|
| 1202 | - calculer_liste($annee2, $idb, $boucles, $parent) . |
|
| 1198 | + $annee2 = "\n".'sprintf("%04d", ($x = '. |
|
| 1199 | + calculer_liste($annee2, $idb, $boucles, $parent). |
|
| 1203 | 1200 | ') ? $x : date("Y"))'; |
| 1204 | 1201 | |
| 1205 | 1202 | $mois2 = $params ? array_shift($params) : ""; |
| 1206 | - $mois2 = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1207 | - calculer_liste($mois2, $idb, $boucles, $parent) . |
|
| 1203 | + $mois2 = "\n".'sprintf("%02d", ($x = '. |
|
| 1204 | + calculer_liste($mois2, $idb, $boucles, $parent). |
|
| 1208 | 1205 | ') ? $x : date("m"))'; |
| 1209 | 1206 | |
| 1210 | 1207 | $jour2 = $params ? array_shift($params) : ""; |
| 1211 | - $jour2 = "\n" . 'sprintf("%02d", ($x = ' . |
|
| 1212 | - calculer_liste($jour2, $idb, $boucles, $parent) . |
|
| 1208 | + $jour2 = "\n".'sprintf("%02d", ($x = '. |
|
| 1209 | + calculer_liste($jour2, $idb, $boucles, $parent). |
|
| 1213 | 1210 | ') ? $x : date("d"))'; |
| 1214 | 1211 | |
| 1215 | - $date = $boucle->id_table . ".$date"; |
|
| 1212 | + $date = $boucle->id_table.".$date"; |
|
| 1216 | 1213 | |
| 1217 | - $quote_end = ",'" . $boucle->sql_serveur . "','text'"; |
|
| 1214 | + $quote_end = ",'".$boucle->sql_serveur."','text'"; |
|
| 1218 | 1215 | if ($type == 'jour') { |
| 1219 | 1216 | $boucle->where[] = array( |
| 1220 | 1217 | "'='", |
@@ -1286,14 +1283,13 @@ discard block |
||
| 1286 | 1283 | list($a21, $a22) = calculer_critere_parties_aux($idb, $boucles, $a2); |
| 1287 | 1284 | |
| 1288 | 1285 | if (($op == ',') && (is_numeric($a11) && (is_numeric($a21)))) { |
| 1289 | - $boucle->limit = $a11 . ',' . $a21; |
|
| 1286 | + $boucle->limit = $a11.','.$a21; |
|
| 1290 | 1287 | } else { |
| 1291 | 1288 | // 3 dans {1/3}, {2,3} ou {1,n-3} |
| 1292 | 1289 | $boucle->total_parties = ($a21 != 'n') ? $a21 : $a22; |
| 1293 | 1290 | // 2 dans {2/3}, {2,5}, {n-2,1} |
| 1294 | 1291 | $partie = ($a11 != 'n') ? $a11 : $a12; |
| 1295 | - $mode = (($op == '/') ? '/' : |
|
| 1296 | - (($a11 == 'n') ? '-' : '+') . (($a21 == 'n') ? '-' : '+')); |
|
| 1292 | + $mode = (($op == '/') ? '/' : (($a11 == 'n') ? '-' : '+').(($a21 == 'n') ? '-' : '+')); |
|
| 1297 | 1293 | // cas simple {0,#ENV{truc}} compilons le en LIMIT : |
| 1298 | 1294 | if ($a11 !== 'n' and $a21 !== 'n' and $mode == "++" and $op == ',') { |
| 1299 | 1295 | $boucle->limit = |
@@ -1339,8 +1335,7 @@ discard block |
||
| 1339 | 1335 | // {1/3} |
| 1340 | 1336 | if ($op1 == '/') { |
| 1341 | 1337 | $pmoins1 = is_numeric($debut) ? ($debut - 1) : "($debut-1)"; |
| 1342 | - $totpos = is_numeric($total_parties) ? ($total_parties) : |
|
| 1343 | - "($total_parties ? $total_parties : 1)"; |
|
| 1338 | + $totpos = is_numeric($total_parties) ? ($total_parties) : "($total_parties ? $total_parties : 1)"; |
|
| 1344 | 1339 | $fin = "ceil(($nombre_boucle * $debut )/$totpos) - 1"; |
| 1345 | 1340 | $debut = !$pmoins1 ? 0 : "ceil(($nombre_boucle * $pmoins1)/$totpos);"; |
| 1346 | 1341 | } else { |
@@ -1351,15 +1346,13 @@ discard block |
||
| 1351 | 1346 | |
| 1352 | 1347 | // cas {x,n-1} |
| 1353 | 1348 | if ($op2 == '-') { |
| 1354 | - $fin = '$debut_boucle + ' . $nombre_boucle . ' - ' |
|
| 1355 | - . (is_numeric($total_parties) ? ($total_parties + 1) : |
|
| 1356 | - ($total_parties . ' - 1')); |
|
| 1349 | + $fin = '$debut_boucle + '.$nombre_boucle.' - ' |
|
| 1350 | + . (is_numeric($total_parties) ? ($total_parties + 1) : ($total_parties.' - 1')); |
|
| 1357 | 1351 | } else { |
| 1358 | 1352 | // {x,1} ou {pagination} |
| 1359 | 1353 | $fin = '$debut_boucle' |
| 1360 | 1354 | . (is_numeric($total_parties) ? |
| 1361 | - (($total_parties == 1) ? "" : (' + ' . ($total_parties - 1))) : |
|
| 1362 | - ('+' . $total_parties . ' - 1')); |
|
| 1355 | + (($total_parties == 1) ? "" : (' + '.($total_parties - 1))) : ('+'.$total_parties.' - 1')); |
|
| 1363 | 1356 | } |
| 1364 | 1357 | |
| 1365 | 1358 | // {pagination}, gerer le debut_xx=-1 pour tout voir |
@@ -1377,11 +1370,11 @@ discard block |
||
| 1377 | 1370 | // Utiliser min pour rabattre $fin_boucle sur total_boucle. |
| 1378 | 1371 | |
| 1379 | 1372 | $boucles[$id_boucle]->mode_partie = "\n\t" |
| 1380 | - . '$debut_boucle = ' . $debut . ";\n " |
|
| 1373 | + . '$debut_boucle = '.$debut.";\n " |
|
| 1381 | 1374 | . "\$debut_boucle = intval(\$debut_boucle);\n " |
| 1382 | - . '$fin_boucle = min(' . $fin . ", \$Numrows['$id_boucle']['total'] - 1);\n " |
|
| 1383 | - . '$Numrows[\'' . $id_boucle . "']['grand_total'] = \$Numrows['$id_boucle']['total'];\n " |
|
| 1384 | - . '$Numrows[\'' . $id_boucle . '\']["total"] = max(0,$fin_boucle - $debut_boucle + 1);' |
|
| 1375 | + . '$fin_boucle = min('.$fin.", \$Numrows['$id_boucle']['total'] - 1);\n " |
|
| 1376 | + . '$Numrows[\''.$id_boucle."']['grand_total'] = \$Numrows['$id_boucle']['total'];\n " |
|
| 1377 | + . '$Numrows[\''.$id_boucle.'\']["total"] = max(0,$fin_boucle - $debut_boucle + 1);' |
|
| 1385 | 1378 | . "\n\tif (\$debut_boucle>0" |
| 1386 | 1379 | . " AND \$debut_boucle < \$Numrows['$id_boucle']['grand_total']" |
| 1387 | 1380 | . " AND \$iter->seek(\$debut_boucle,'continue'))" |
@@ -1466,16 +1459,16 @@ discard block |
||
| 1466 | 1459 | // critere personnalise ? |
| 1467 | 1460 | if ( |
| 1468 | 1461 | (!$serveur or |
| 1469 | - ((!function_exists($f = "critere_" . $serveur . "_" . $table . "_" . $critere)) |
|
| 1470 | - and (!function_exists($f = $f . "_dist")) |
|
| 1471 | - and (!function_exists($f = "critere_" . $serveur . "_" . $critere)) |
|
| 1472 | - and (!function_exists($f = $f . "_dist")) |
|
| 1462 | + ((!function_exists($f = "critere_".$serveur."_".$table."_".$critere)) |
|
| 1463 | + and (!function_exists($f = $f."_dist")) |
|
| 1464 | + and (!function_exists($f = "critere_".$serveur."_".$critere)) |
|
| 1465 | + and (!function_exists($f = $f."_dist")) |
|
| 1473 | 1466 | ) |
| 1474 | 1467 | ) |
| 1475 | - and (!function_exists($f = "critere_" . $table . "_" . $critere)) |
|
| 1476 | - and (!function_exists($f = $f . "_dist")) |
|
| 1477 | - and (!function_exists($f = "critere_" . $critere)) |
|
| 1478 | - and (!function_exists($f = $f . "_dist")) |
|
| 1468 | + and (!function_exists($f = "critere_".$table."_".$critere)) |
|
| 1469 | + and (!function_exists($f = $f."_dist")) |
|
| 1470 | + and (!function_exists($f = "critere_".$critere)) |
|
| 1471 | + and (!function_exists($f = $f."_dist")) |
|
| 1479 | 1472 | ) { |
| 1480 | 1473 | // fonction critere standard |
| 1481 | 1474 | $f = $defaut; |
@@ -1508,9 +1501,9 @@ discard block |
||
| 1508 | 1501 | */ |
| 1509 | 1502 | function kwote($lisp, $serveur = '', $type = '') { |
| 1510 | 1503 | if (preg_match(_CODE_QUOTE, $lisp, $r)) { |
| 1511 | - return $r[1] . "\"" . sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]), $serveur, $type) . "\""; |
|
| 1504 | + return $r[1]."\"".sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]), $serveur, $type)."\""; |
|
| 1512 | 1505 | } else { |
| 1513 | - return "sql_quote($lisp, '$serveur', '" . str_replace("'", "\\'", $type) . "')"; |
|
| 1506 | + return "sql_quote($lisp, '$serveur', '".str_replace("'", "\\'", $type)."')"; |
|
| 1514 | 1507 | } |
| 1515 | 1508 | } |
| 1516 | 1509 | |
@@ -1532,7 +1525,7 @@ discard block |
||
| 1532 | 1525 | function critere_IN_dist($idb, &$boucles, $crit) { |
| 1533 | 1526 | $r = calculer_critere_infixe($idb, $boucles, $crit); |
| 1534 | 1527 | if (!$r) { |
| 1535 | - return (array('zbug_critere_inconnu', array('critere' => $crit->op . " ?"))); |
|
| 1528 | + return (array('zbug_critere_inconnu', array('critere' => $crit->op." ?"))); |
|
| 1536 | 1529 | } |
| 1537 | 1530 | list($arg, $op, $val, $col, $where_complement) = $r; |
| 1538 | 1531 | |
@@ -1559,8 +1552,8 @@ discard block |
||
| 1559 | 1552 | "'NOT'", |
| 1560 | 1553 | array( |
| 1561 | 1554 | "'IN'", |
| 1562 | - "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", |
|
| 1563 | - array("'SELF'", "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", $where) |
|
| 1555 | + "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", |
|
| 1556 | + array("'SELF'", "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", $where) |
|
| 1564 | 1557 | ) |
| 1565 | 1558 | ); |
| 1566 | 1559 | } |
@@ -1579,22 +1572,22 @@ discard block |
||
| 1579 | 1572 | $descr = $boucles[$idb]->descr; |
| 1580 | 1573 | $cpt = &$num[$descr['nom']][$descr['gram']][$idb]; |
| 1581 | 1574 | |
| 1582 | - $var = '$in' . $cpt++; |
|
| 1575 | + $var = '$in'.$cpt++; |
|
| 1583 | 1576 | $x = "\n\t$var = array();"; |
| 1584 | 1577 | foreach ($val as $k => $v) { |
| 1585 | 1578 | if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)) { |
| 1586 | 1579 | // optimiser le traitement des constantes |
| 1587 | 1580 | if (is_numeric($r[2])) { |
| 1588 | - $x .= "\n\t$var" . "[]= $r[2];"; |
|
| 1581 | + $x .= "\n\t$var"."[]= $r[2];"; |
|
| 1589 | 1582 | } else { |
| 1590 | - $x .= "\n\t$var" . "[]= " . sql_quote($r[2]) . ";"; |
|
| 1583 | + $x .= "\n\t$var"."[]= ".sql_quote($r[2]).";"; |
|
| 1591 | 1584 | } |
| 1592 | 1585 | } else { |
| 1593 | 1586 | // Pour permettre de passer des tableaux de valeurs |
| 1594 | 1587 | // on repere l'utilisation brute de #ENV**{X}, |
| 1595 | 1588 | // c'est-a-dire sa traduction en ($PILE[0][X]). |
| 1596 | 1589 | // et on deballe mais en rajoutant l'anti XSS |
| 1597 | - $x .= "\n\tif (!(is_array(\$a = ($v))))\n\t\t$var" . "[]= \$a;\n\telse $var = array_merge($var, \$a);"; |
|
| 1590 | + $x .= "\n\tif (!(is_array(\$a = ($v))))\n\t\t$var"."[]= \$a;\n\telse $var = array_merge($var, \$a);"; |
|
| 1598 | 1591 | } |
| 1599 | 1592 | } |
| 1600 | 1593 | |
@@ -1608,7 +1601,7 @@ discard block |
||
| 1608 | 1601 | $boucles[$idb]->default_order[] = "((!\$zqv=sql_quote($var) OR \$zqv===\"''\") ? 0 : ('FIELD($arg,' . \$zqv . ')'))"; |
| 1609 | 1602 | } |
| 1610 | 1603 | |
| 1611 | - return "sql_in('$arg', $var" . ($crit2 == 'NOT' ? ",'NOT'" : "") . ")"; |
|
| 1604 | + return "sql_in('$arg', $var".($crit2 == 'NOT' ? ",'NOT'" : "").")"; |
|
| 1612 | 1605 | } |
| 1613 | 1606 | |
| 1614 | 1607 | /** |
@@ -1681,7 +1674,7 @@ discard block |
||
| 1681 | 1674 | $champs = array_diff($champs, array_keys($boucle->modificateur['criteres'])); |
| 1682 | 1675 | } |
| 1683 | 1676 | // nous aider en mode debug. |
| 1684 | - $boucle->debug[] = "id_ : " . implode(', ', $champs); |
|
| 1677 | + $boucle->debug[] = "id_ : ".implode(', ', $champs); |
|
| 1685 | 1678 | $boucle->modificateur['id_'] = $champs; |
| 1686 | 1679 | |
| 1687 | 1680 | // créer un critère {id_xxx?} de chaque champ retenu |
@@ -1722,7 +1715,7 @@ discard block |
||
| 1722 | 1715 | // Les champs id_xx de la table demandée |
| 1723 | 1716 | $champs = array_filter( |
| 1724 | 1717 | array_keys($desc['field']), |
| 1725 | - function($champ){ |
|
| 1718 | + function($champ) { |
|
| 1726 | 1719 | return |
| 1727 | 1720 | strpos($champ, 'id_') === 0 |
| 1728 | 1721 | or (in_array($champ, array('objet'))); |
@@ -1937,8 +1930,8 @@ discard block |
||
| 1937 | 1930 | "'NOT'", |
| 1938 | 1931 | array( |
| 1939 | 1932 | "'IN'", |
| 1940 | - "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", |
|
| 1941 | - array("'SELF'", "'" . $boucles[$idb]->id_table . "." . $boucles[$idb]->primary . "'", $where) |
|
| 1933 | + "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", |
|
| 1934 | + array("'SELF'", "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", $where) |
|
| 1942 | 1935 | ) |
| 1943 | 1936 | ); |
| 1944 | 1937 | } |
@@ -1949,7 +1942,7 @@ discard block |
||
| 1949 | 1942 | if ($crit->cond) { |
| 1950 | 1943 | $pred = calculer_argument_precedent($idb, $col, $boucles); |
| 1951 | 1944 | if ($col == "date" or $col == "date_redac") { |
| 1952 | - if ($pred == "\$Pile[0]['" . $col . "']") { |
|
| 1945 | + if ($pred == "\$Pile[0]['".$col."']") { |
|
| 1953 | 1946 | $pred = "(\$Pile[0]['{$col}_default']?'':$pred)"; |
| 1954 | 1947 | } |
| 1955 | 1948 | } |
@@ -2110,7 +2103,7 @@ discard block |
||
| 2110 | 2103 | // defaire le quote des int et les passer dans sql_quote avec le bon type de champ si on le connait, int sinon |
| 2111 | 2104 | // prendre en compte le debug ou la valeur arrive avec un commentaire PHP en debut |
| 2112 | 2105 | if (preg_match(",^\\A(\s*//.*?$\s*)?\"'(-?\d+)'\"\\z,ms", $val[0], $r)) { |
| 2113 | - $val[0] = $r[1] . '"' . sql_quote($r[2], $boucle->sql_serveur, $type_cast_quote) . '"'; |
|
| 2106 | + $val[0] = $r[1].'"'.sql_quote($r[2], $boucle->sql_serveur, $type_cast_quote).'"'; |
|
| 2114 | 2107 | } |
| 2115 | 2108 | // sinon expliciter les |
| 2116 | 2109 | // sql_quote(truc) en sql_quote(truc,'',type) |
@@ -2121,22 +2114,22 @@ discard block |
||
| 2121 | 2114 | // sql_quote(truc,'','varchar') |
| 2122 | 2115 | elseif (preg_match('/\Asql_quote[(](.*?)(,[^)]*?)?(,[^)]*(?:\(\d+\)[^)]*)?)?[)]\s*\z/ms', $val[0], $r) |
| 2123 | 2116 | // si pas deja un type |
| 2124 | - and (!isset($r[3]) or !$r[3] or !trim($r[3],", '")) |
|
| 2117 | + and (!isset($r[3]) or !$r[3] or !trim($r[3], ", '")) |
|
| 2125 | 2118 | ) { |
| 2126 | 2119 | $r = $r[1] |
| 2127 | 2120 | . ((isset($r[2]) and $r[2]) ? $r[2] : ",''") |
| 2128 | - . ",'" . addslashes($type_cast_quote) . "'"; |
|
| 2121 | + . ",'".addslashes($type_cast_quote)."'"; |
|
| 2129 | 2122 | $val[0] = "sql_quote($r)"; |
| 2130 | 2123 | } |
| 2131 | - elseif(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2124 | + elseif (strpos($val[0], '@@defaultcast@@') !== false |
|
| 2132 | 2125 | and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
| 2133 | - $val[0] = substr($val[0], 0, -strlen($r[0])) . "'" . addslashes($type_cast_quote) . "')"; |
|
| 2126 | + $val[0] = substr($val[0], 0, -strlen($r[0]))."'".addslashes($type_cast_quote)."')"; |
|
| 2134 | 2127 | } |
| 2135 | 2128 | } |
| 2136 | 2129 | |
| 2137 | - if(strpos($val[0], '@@defaultcast@@') !== false |
|
| 2130 | + if (strpos($val[0], '@@defaultcast@@') !== false |
|
| 2138 | 2131 | and preg_match("/'@@defaultcast@@'\s*\)\s*\z/ms", $val[0], $r)) { |
| 2139 | - $val[0] = substr($val[0], 0, -strlen($r[0])) . "'char')"; |
|
| 2132 | + $val[0] = substr($val[0], 0, -strlen($r[0]))."'char')"; |
|
| 2140 | 2133 | } |
| 2141 | 2134 | |
| 2142 | 2135 | // Indicateur pour permettre aux fonctionx boucle_X de modifier |
@@ -2152,7 +2145,7 @@ discard block |
||
| 2152 | 2145 | // inserer le nom de la table SQL devant le nom du champ |
| 2153 | 2146 | if ($table) { |
| 2154 | 2147 | if ($col[0] == "`") { |
| 2155 | - $arg = "$table." . substr($col, 1, -1); |
|
| 2148 | + $arg = "$table.".substr($col, 1, -1); |
|
| 2156 | 2149 | } else { |
| 2157 | 2150 | $arg = "$table.$col"; |
| 2158 | 2151 | } |
@@ -2286,9 +2279,9 @@ discard block |
||
| 2286 | 2279 | **/ |
| 2287 | 2280 | function primary_doublee($decompose, $table) { |
| 2288 | 2281 | $e1 = reset($decompose); |
| 2289 | - $e2 = "sql_quote('" . end($decompose) . "')"; |
|
| 2282 | + $e2 = "sql_quote('".end($decompose)."')"; |
|
| 2290 | 2283 | |
| 2291 | - return array("'='", "'$table." . $e1 . "'", $e2); |
|
| 2284 | + return array("'='", "'$table.".$e1."'", $e2); |
|
| 2292 | 2285 | } |
| 2293 | 2286 | |
| 2294 | 2287 | /** |
@@ -2326,7 +2319,7 @@ discard block |
||
| 2326 | 2319 | if ($checkarrivee |
| 2327 | 2320 | and is_string($checkarrivee) |
| 2328 | 2321 | and $a = table_objet($checkarrivee) |
| 2329 | - and in_array($a . '_liens', $joints) |
|
| 2322 | + and in_array($a.'_liens', $joints) |
|
| 2330 | 2323 | ) { |
| 2331 | 2324 | if ($res = calculer_lien_externe_init($boucle, $joints, $col, $desc, $cond, $checkarrivee)) { |
| 2332 | 2325 | return $res; |
@@ -2346,12 +2339,12 @@ discard block |
||
| 2346 | 2339 | // la table est déjà dans le FROM, on vérifie si le champ est utilisé. |
| 2347 | 2340 | $joindre = false; |
| 2348 | 2341 | foreach ($cols as $col) { |
| 2349 | - $c = '/\b' . $t . ".$col" . '\b/'; |
|
| 2342 | + $c = '/\b'.$t.".$col".'\b/'; |
|
| 2350 | 2343 | if (trouver_champ($c, $boucle->where)) { |
| 2351 | 2344 | $joindre = true; |
| 2352 | 2345 | } else { |
| 2353 | 2346 | // mais ca peut etre dans le FIELD pour le Having |
| 2354 | - $c = "/FIELD.$t" . ".$col,/"; |
|
| 2347 | + $c = "/FIELD.$t".".$col,/"; |
|
| 2355 | 2348 | if (trouver_champ($c, $boucle->select)) { |
| 2356 | 2349 | $joindre = true; |
| 2357 | 2350 | } |
@@ -2398,7 +2391,7 @@ discard block |
||
| 2398 | 2391 | $primary_arrivee = id_table_objet($checkarrivee); |
| 2399 | 2392 | |
| 2400 | 2393 | // [FIXME] $checkarrivee peut-il arriver avec false ???? |
| 2401 | - $intermediaire = trouver_champ_exterieur($primary_arrivee, $joints, $boucle, $checkarrivee . "_liens"); |
|
| 2394 | + $intermediaire = trouver_champ_exterieur($primary_arrivee, $joints, $boucle, $checkarrivee."_liens"); |
|
| 2402 | 2395 | $arrivee = trouver_champ_exterieur($col, $joints, $boucle, $checkarrivee); |
| 2403 | 2396 | |
| 2404 | 2397 | if (!$intermediaire or !$arrivee) { |
@@ -2496,7 +2489,7 @@ discard block |
||
| 2496 | 2489 | } elseif ($crit->cond and ($col == "date" or $col == "date_redac")) { |
| 2497 | 2490 | // un critere conditionnel sur date est traite a part |
| 2498 | 2491 | // car la date est mise d'office par SPIP, |
| 2499 | - $defaut = "(\$Pile[0]['{$col}_default']?'':\$Pile[0]['" . $col . "'])"; |
|
| 2492 | + $defaut = "(\$Pile[0]['{$col}_default']?'':\$Pile[0]['".$col."'])"; |
|
| 2500 | 2493 | } |
| 2501 | 2494 | |
| 2502 | 2495 | $val = calculer_argument_precedent($idb, $val, $boucles, $defaut); |
@@ -2527,7 +2520,7 @@ discard block |
||
| 2527 | 2520 | and (($p == "'") or ($p == '"')) |
| 2528 | 2521 | and $params[0][1]->type == 'champ' |
| 2529 | 2522 | ) { |
| 2530 | - $val[] = "$p\\$p#" . $params[0][1]->nom_champ . "\\$p$p"; |
|
| 2523 | + $val[] = "$p\\$p#".$params[0][1]->nom_champ."\\$p$p"; |
|
| 2531 | 2524 | } else { |
| 2532 | 2525 | foreach ((($op != 'IN') ? $params : calculer_vieux_in($params)) as $p) { |
| 2533 | 2526 | $a = calculer_liste($p, $idb, $boucles, $parent); |
@@ -2543,7 +2536,7 @@ discard block |
||
| 2543 | 2536 | $fct = $args_sql = ''; |
| 2544 | 2537 | // fonction SQL ? |
| 2545 | 2538 | // chercher FONCTION(champ) tel que CONCAT(titre,descriptif) |
| 2546 | - if (preg_match('/^(.*)' . SQL_ARGS . '$/', $col, $m)) { |
|
| 2539 | + if (preg_match('/^(.*)'.SQL_ARGS.'$/', $col, $m)) { |
|
| 2547 | 2540 | $fct = $m[1]; |
| 2548 | 2541 | preg_match('/^\(([^,]*)(.*)\)$/', $m[2], $a); |
| 2549 | 2542 | $col = $a[1]; |
@@ -2633,7 +2626,7 @@ discard block |
||
| 2633 | 2626 | # si oui choisir ce champ, sinon choisir xxxx |
| 2634 | 2627 | |
| 2635 | 2628 | if (isset($table['field']["date$suite"])) { |
| 2636 | - $date_orig = 'date' . $suite; |
|
| 2629 | + $date_orig = 'date'.$suite; |
|
| 2637 | 2630 | } else { |
| 2638 | 2631 | $date_orig = substr($suite, 1); |
| 2639 | 2632 | } |
@@ -2644,12 +2637,12 @@ discard block |
||
| 2644 | 2637 | } |
| 2645 | 2638 | } |
| 2646 | 2639 | |
| 2647 | - $date_compare = "\"' . normaliser_date(" . |
|
| 2648 | - calculer_argument_precedent($idb, $pred, $boucles) . |
|
| 2640 | + $date_compare = "\"' . normaliser_date(". |
|
| 2641 | + calculer_argument_precedent($idb, $pred, $boucles). |
|
| 2649 | 2642 | ") . '\""; |
| 2650 | 2643 | |
| 2651 | 2644 | $col_vraie = $date_orig; |
| 2652 | - $date_orig = $boucle->id_table . '.' . $date_orig; |
|
| 2645 | + $date_orig = $boucle->id_table.'.'.$date_orig; |
|
| 2653 | 2646 | |
| 2654 | 2647 | switch ($col) { |
| 2655 | 2648 | case 'date': |
@@ -2669,26 +2662,26 @@ discard block |
||
| 2669 | 2662 | break; |
| 2670 | 2663 | case 'age': |
| 2671 | 2664 | $col = calculer_param_date("\'' . date('Y-m-d H:i:00') . '\'", $date_orig); |
| 2672 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2665 | + $col_vraie = ""; // comparer a un int (par defaut) |
|
| 2673 | 2666 | break; |
| 2674 | 2667 | case 'age_relatif': |
| 2675 | 2668 | $col = calculer_param_date($date_compare, $date_orig); |
| 2676 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2669 | + $col_vraie = ""; // comparer a un int (par defaut) |
|
| 2677 | 2670 | break; |
| 2678 | 2671 | case 'jour_relatif': |
| 2679 | - $col = "(TO_DAYS(" . $date_compare . ")-TO_DAYS(" . $date_orig . "))"; |
|
| 2680 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2672 | + $col = "(TO_DAYS(".$date_compare.")-TO_DAYS(".$date_orig."))"; |
|
| 2673 | + $col_vraie = ""; // comparer a un int (par defaut) |
|
| 2681 | 2674 | break; |
| 2682 | 2675 | case 'mois_relatif': |
| 2683 | - $col = "MONTH(" . $date_compare . ")-MONTH(" . |
|
| 2684 | - $date_orig . ")+12*(YEAR(" . $date_compare . |
|
| 2685 | - ")-YEAR(" . $date_orig . "))"; |
|
| 2686 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2676 | + $col = "MONTH(".$date_compare.")-MONTH(". |
|
| 2677 | + $date_orig.")+12*(YEAR(".$date_compare. |
|
| 2678 | + ")-YEAR(".$date_orig."))"; |
|
| 2679 | + $col_vraie = ""; // comparer a un int (par defaut) |
|
| 2687 | 2680 | break; |
| 2688 | 2681 | case 'annee_relatif': |
| 2689 | - $col = "YEAR(" . $date_compare . ")-YEAR(" . |
|
| 2690 | - $date_orig . ")"; |
|
| 2691 | - $col_vraie = "";// comparer a un int (par defaut) |
|
| 2682 | + $col = "YEAR(".$date_compare.")-YEAR(". |
|
| 2683 | + $date_orig.")"; |
|
| 2684 | + $col_vraie = ""; // comparer a un int (par defaut) |
|
| 2692 | 2685 | break; |
| 2693 | 2686 | } |
| 2694 | 2687 | |
@@ -2747,10 +2740,10 @@ discard block |
||
| 2747 | 2740 | } |
| 2748 | 2741 | |
| 2749 | 2742 | $boucle->hash .= ' |
| 2750 | - $command[\'sourcemode\'] = ' . array_shift($args) . ";\n"; |
|
| 2743 | + $command[\'sourcemode\'] = ' . array_shift($args).";\n"; |
|
| 2751 | 2744 | |
| 2752 | 2745 | $boucle->hash .= ' |
| 2753 | - $command[\'source\'] = array(' . join(', ', $args) . ");\n"; |
|
| 2746 | + $command[\'source\'] = array(' . join(', ', $args).");\n"; |
|
| 2754 | 2747 | } |
| 2755 | 2748 | |
| 2756 | 2749 | /** |
@@ -2769,7 +2762,7 @@ discard block |
||
| 2769 | 2762 | function critere_DATA_datacache_dist($idb, &$boucles, $crit) { |
| 2770 | 2763 | $boucle = &$boucles[$idb]; |
| 2771 | 2764 | $boucle->hash .= ' |
| 2772 | - $command[\'datacache\'] = ' . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent) . ';'; |
|
| 2765 | + $command[\'datacache\'] = ' . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent).';'; |
|
| 2773 | 2766 | } |
| 2774 | 2767 | |
| 2775 | 2768 | |
@@ -2788,7 +2781,7 @@ discard block |
||
| 2788 | 2781 | $boucle->hash .= '$command[\'args\']=array();'; |
| 2789 | 2782 | foreach ($crit->param as $param) { |
| 2790 | 2783 | $boucle->hash .= ' |
| 2791 | - $command[\'args\'][] = ' . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ';'; |
|
| 2784 | + $command[\'args\'][] = ' . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent).';'; |
|
| 2792 | 2785 | } |
| 2793 | 2786 | } |
| 2794 | 2787 | |
@@ -2807,10 +2800,10 @@ discard block |
||
| 2807 | 2800 | */ |
| 2808 | 2801 | function critere_DATA_liste_dist($idb, &$boucles, $crit) { |
| 2809 | 2802 | $boucle = &$boucles[$idb]; |
| 2810 | - $boucle->hash .= "\n\t" . '$command[\'liste\'] = array();' . "\n"; |
|
| 2803 | + $boucle->hash .= "\n\t".'$command[\'liste\'] = array();'."\n"; |
|
| 2811 | 2804 | foreach ($crit->param as $param) { |
| 2812 | - $boucle->hash .= "\t" . '$command[\'liste\'][] = ' . calculer_liste($param, $idb, $boucles, |
|
| 2813 | - $boucles[$idb]->id_parent) . ";\n"; |
|
| 2805 | + $boucle->hash .= "\t".'$command[\'liste\'][] = '.calculer_liste($param, $idb, $boucles, |
|
| 2806 | + $boucles[$idb]->id_parent).";\n"; |
|
| 2814 | 2807 | } |
| 2815 | 2808 | } |
| 2816 | 2809 | |
@@ -2837,10 +2830,10 @@ discard block |
||
| 2837 | 2830 | */ |
| 2838 | 2831 | function critere_DATA_enum_dist($idb, &$boucles, $crit) { |
| 2839 | 2832 | $boucle = &$boucles[$idb]; |
| 2840 | - $boucle->hash .= "\n\t" . '$command[\'enum\'] = array();' . "\n"; |
|
| 2833 | + $boucle->hash .= "\n\t".'$command[\'enum\'] = array();'."\n"; |
|
| 2841 | 2834 | foreach ($crit->param as $param) { |
| 2842 | - $boucle->hash .= "\t" . '$command[\'enum\'][] = ' . calculer_liste($param, $idb, $boucles, |
|
| 2843 | - $boucles[$idb]->id_parent) . ";\n"; |
|
| 2835 | + $boucle->hash .= "\t".'$command[\'enum\'][] = '.calculer_liste($param, $idb, $boucles, |
|
| 2836 | + $boucles[$idb]->id_parent).";\n"; |
|
| 2844 | 2837 | } |
| 2845 | 2838 | } |
| 2846 | 2839 | |
@@ -2859,7 +2852,7 @@ discard block |
||
| 2859 | 2852 | $boucle = &$boucles[$idb]; |
| 2860 | 2853 | foreach ($crit->param as $param) { |
| 2861 | 2854 | $boucle->hash .= ' |
| 2862 | - $command[\'datapath\'][] = ' . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ';'; |
|
| 2855 | + $command[\'datapath\'][] = ' . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent).';'; |
|
| 2863 | 2856 | } |
| 2864 | 2857 | } |
| 2865 | 2858 | |
@@ -2900,7 +2893,7 @@ discard block |
||
| 2900 | 2893 | if ($crit->param) { |
| 2901 | 2894 | foreach ($crit->param as $param) { |
| 2902 | 2895 | $boucle->hash .= "\t\$command['si'][] = " |
| 2903 | - . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent) . ";\n"; |
|
| 2896 | + . calculer_liste($param, $idb, $boucles, $boucles[$idb]->id_parent).";\n"; |
|
| 2904 | 2897 | } |
| 2905 | 2898 | // interdire {si 0} aussi ! |
| 2906 | 2899 | } else { |
@@ -2924,7 +2917,7 @@ discard block |
||
| 2924 | 2917 | function critere_POUR_tableau_dist($idb, &$boucles, $crit) { |
| 2925 | 2918 | $boucle = &$boucles[$idb]; |
| 2926 | 2919 | $boucle->hash .= ' |
| 2927 | - $command[\'source\'] = array(' . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent) . '); |
|
| 2920 | + $command[\'source\'] = array(' . calculer_liste($crit->param[0], $idb, $boucles, $boucles[$idb]->id_parent).'); |
|
| 2928 | 2921 | $command[\'sourcemode\'] = \'table\';'; |
| 2929 | 2922 | } |
| 2930 | 2923 | |
@@ -2957,11 +2950,10 @@ discard block |
||
| 2957 | 2950 | $table_sql = table_objet_sql(objet_type($table)); |
| 2958 | 2951 | |
| 2959 | 2952 | $id_parent = isset($GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent']) ? |
| 2960 | - $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : |
|
| 2961 | - 'id_parent'; |
|
| 2953 | + $GLOBALS['exceptions_des_tables'][$boucle->id_table]['id_parent'] : 'id_parent'; |
|
| 2962 | 2954 | |
| 2963 | 2955 | $in = "IN"; |
| 2964 | - $where = array("'IN'", "'$boucle->id_table." . "$primary'", "'('.sql_get_select('$id_parent', '$table_sql').')'"); |
|
| 2956 | + $where = array("'IN'", "'$boucle->id_table."."$primary'", "'('.sql_get_select('$id_parent', '$table_sql').')'"); |
|
| 2965 | 2957 | if ($not) { |
| 2966 | 2958 | $where = array("'NOT'", $where); |
| 2967 | 2959 | } |
@@ -471,9 +471,11 @@ discard block |
||
| 471 | 471 | $contexte[$var] = $val; |
| 472 | 472 | } else { |
| 473 | 473 | $args = explode('=', $val); |
| 474 | - if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 474 | + if (count($args) >= 2) { |
|
| 475 | + // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 475 | 476 | { |
| 476 | 477 | $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
| 478 | + } |
|
| 477 | 479 | } else // notation abregee |
| 478 | 480 | { |
| 479 | 481 | $contexte[trim($val)] = trim($val); |
@@ -676,8 +678,8 @@ discard block |
||
| 676 | 678 | function page_base_href(&$texte) { |
| 677 | 679 | static $set_html_base = null; |
| 678 | 680 | if (is_null($set_html_base)) { |
| 679 | - if (!defined('_SET_HTML_BASE')) |
|
| 680 | - // si la profondeur est superieure a 1 |
|
| 681 | + if (!defined('_SET_HTML_BASE')) { |
|
| 682 | + // si la profondeur est superieure a 1 |
|
| 681 | 683 | // est que ce n'est pas une url page ni une url action |
| 682 | 684 | // activer par defaut |
| 683 | 685 | { |
@@ -685,6 +687,7 @@ discard block |
||
| 685 | 687 | $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
| 686 | 688 | and _request(_SPIP_PAGE) !== 'login' |
| 687 | 689 | and !_request('action')) ? true : false); |
| 690 | + } |
|
| 688 | 691 | } else { |
| 689 | 692 | $set_html_base = _SET_HTML_BASE; |
| 690 | 693 | } |
@@ -742,8 +745,10 @@ discard block |
||
| 742 | 745 | // et demarrent par X-Spip-... |
| 743 | 746 | // https://code.spip.net/@envoyer_entetes |
| 744 | 747 | function envoyer_entetes($entetes) { |
| 745 | - foreach ($entetes as $k => $v) # if (strncmp($k, 'X-Spip-', 7)) |
|
| 748 | + foreach ($entetes as $k => $v) { |
|
| 749 | + # if (strncmp($k, 'X-Spip-', 7)) |
|
| 746 | 750 | { |
| 747 | 751 | @header(strlen($v) ? "$k: $v" : $k); |
| 748 | 752 | } |
| 753 | + } |
|
| 749 | 754 | } |
@@ -20,155 +20,155 @@ discard block |
||
| 20 | 20 | **/ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // En cas de modification, il faut aussi actualiser la regexp de nettoyer_uri_var() dans inc/utils.php |
| 27 | 27 | if (!defined('_CONTEXTE_IGNORE_VARIABLES')) { |
| 28 | - define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$|^fbclid$|^utm_)/"); |
|
| 28 | + define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$|^fbclid$|^utm_)/"); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // https://code.spip.net/@assembler |
| 32 | 32 | function assembler($fond, $connect = '') { |
| 33 | 33 | |
| 34 | - // flag_preserver est modifie ici, et utilise en globale |
|
| 35 | - // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 36 | - // contexte est utilise en globale dans le formulaire d'admin |
|
| 37 | - |
|
| 38 | - $GLOBALS['contexte'] = calculer_contexte(); |
|
| 39 | - $page = array('contexte_implicite' => calculer_contexte_implicite()); |
|
| 40 | - $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', |
|
| 41 | - preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 42 | - // Cette fonction est utilisee deux fois |
|
| 43 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 44 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 45 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 46 | - if ($cacher) { |
|
| 47 | - $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified); |
|
| 48 | - } else { |
|
| 49 | - $GLOBALS['use_cache'] = -1; |
|
| 50 | - } |
|
| 51 | - // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 52 | - if ($res) { |
|
| 53 | - return array('texte' => $res); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - if (!$chemin_cache || !$lastmodified) { |
|
| 57 | - $lastmodified = time(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 61 | - $calculer_page = true; |
|
| 62 | - |
|
| 63 | - // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 64 | - // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 65 | - // pages sont dynamiques) |
|
| 66 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 67 | - and (!defined('_VAR_MODE') or !_VAR_MODE) |
|
| 68 | - and $chemin_cache |
|
| 69 | - and isset($page['entetes']) |
|
| 70 | - and isset($page['entetes']['Cache-Control']) |
|
| 71 | - and strstr($page['entetes']['Cache-Control'], 'max-age=') |
|
| 72 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 73 | - ) { |
|
| 74 | - $since = preg_replace('/;.*/', '', |
|
| 75 | - $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
| 76 | - $since = str_replace('GMT', '', $since); |
|
| 77 | - if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { |
|
| 78 | - $page['status'] = 304; |
|
| 79 | - $headers_only = true; |
|
| 80 | - $calculer_page = false; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 85 | - // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 86 | - if (!$calculer_page) { |
|
| 87 | - $page['texte'] = ""; |
|
| 88 | - } else { |
|
| 89 | - // si la page est prise dans le cache |
|
| 90 | - if (!$GLOBALS['use_cache']) { |
|
| 91 | - // Informer les boutons d'admin du contexte |
|
| 92 | - // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 93 | - $GLOBALS['contexte'] = $page['contexte']; |
|
| 94 | - |
|
| 95 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 96 | - // d'inversion url => objet |
|
| 97 | - // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 98 | - #unset($_SERVER['REDIRECT_url_propre']); |
|
| 99 | - #unset($_ENV['url_propre']); |
|
| 100 | - } else { |
|
| 101 | - // Compat ascendante : |
|
| 102 | - // 1. $contexte est global |
|
| 103 | - // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 104 | - // et calculer la page |
|
| 105 | - if (!test_espace_prive()) { |
|
| 106 | - include_spip('inc/urls'); |
|
| 107 | - list($fond, $GLOBALS['contexte'], $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $GLOBALS['contexte'], |
|
| 108 | - true); |
|
| 109 | - } |
|
| 110 | - // squelette par defaut |
|
| 111 | - if (!strlen($fond)) { |
|
| 112 | - $fond = 'sommaire'; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // produire la page : peut mettre a jour $lastmodified |
|
| 116 | - $produire_page = charger_fonction('produire_page', 'public'); |
|
| 117 | - $page = $produire_page($fond, $GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, null, $page, |
|
| 118 | - $lastmodified, $connect); |
|
| 119 | - if ($page === '') { |
|
| 120 | - $erreur = _T('info_erreur_squelette2', |
|
| 121 | - array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES)); |
|
| 122 | - erreur_squelette($erreur); |
|
| 123 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 124 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if ($page and $chemin_cache) { |
|
| 129 | - $page['cache'] = $chemin_cache; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - auto_content_type($page); |
|
| 133 | - |
|
| 134 | - $GLOBALS['flag_preserver'] |= headers_sent(); |
|
| 135 | - |
|
| 136 | - // Definir les entetes si ce n'est fait |
|
| 137 | - if (!$GLOBALS['flag_preserver']) { |
|
| 138 | - if ($GLOBALS['flag_ob']) { |
|
| 139 | - // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 140 | - if (trim($page['texte']) === '' |
|
| 141 | - and _VAR_MODE != 'debug' |
|
| 142 | - and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 143 | - ) { |
|
| 144 | - $GLOBALS['contexte']['fond_erreur'] = $fond; |
|
| 145 | - $page = message_page_indisponible($page, $GLOBALS['contexte']); |
|
| 146 | - } |
|
| 147 | - // pas de cache client en mode 'observation' |
|
| 148 | - if (defined('_VAR_MODE') and _VAR_MODE) { |
|
| 149 | - $page['entetes']["Cache-Control"] = "no-cache,must-revalidate"; |
|
| 150 | - $page['entetes']["Pragma"] = "no-cache"; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - // Entete Last-Modified: |
|
| 157 | - // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 158 | - // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 159 | - if ($lastmodified |
|
| 160 | - and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 161 | - and !isset($page['entetes']["Last-Modified"]) |
|
| 162 | - ) { |
|
| 163 | - $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // fermer la connexion apres les headers si requete HEAD |
|
| 167 | - if ($headers_only) { |
|
| 168 | - $page['entetes']["Connection"] = "close"; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - return $page; |
|
| 34 | + // flag_preserver est modifie ici, et utilise en globale |
|
| 35 | + // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 36 | + // contexte est utilise en globale dans le formulaire d'admin |
|
| 37 | + |
|
| 38 | + $GLOBALS['contexte'] = calculer_contexte(); |
|
| 39 | + $page = array('contexte_implicite' => calculer_contexte_implicite()); |
|
| 40 | + $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', |
|
| 41 | + preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 42 | + // Cette fonction est utilisee deux fois |
|
| 43 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 44 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 45 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 46 | + if ($cacher) { |
|
| 47 | + $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified); |
|
| 48 | + } else { |
|
| 49 | + $GLOBALS['use_cache'] = -1; |
|
| 50 | + } |
|
| 51 | + // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 52 | + if ($res) { |
|
| 53 | + return array('texte' => $res); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + if (!$chemin_cache || !$lastmodified) { |
|
| 57 | + $lastmodified = time(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 61 | + $calculer_page = true; |
|
| 62 | + |
|
| 63 | + // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 64 | + // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 65 | + // pages sont dynamiques) |
|
| 66 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 67 | + and (!defined('_VAR_MODE') or !_VAR_MODE) |
|
| 68 | + and $chemin_cache |
|
| 69 | + and isset($page['entetes']) |
|
| 70 | + and isset($page['entetes']['Cache-Control']) |
|
| 71 | + and strstr($page['entetes']['Cache-Control'], 'max-age=') |
|
| 72 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 73 | + ) { |
|
| 74 | + $since = preg_replace('/;.*/', '', |
|
| 75 | + $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
| 76 | + $since = str_replace('GMT', '', $since); |
|
| 77 | + if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { |
|
| 78 | + $page['status'] = 304; |
|
| 79 | + $headers_only = true; |
|
| 80 | + $calculer_page = false; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 85 | + // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 86 | + if (!$calculer_page) { |
|
| 87 | + $page['texte'] = ""; |
|
| 88 | + } else { |
|
| 89 | + // si la page est prise dans le cache |
|
| 90 | + if (!$GLOBALS['use_cache']) { |
|
| 91 | + // Informer les boutons d'admin du contexte |
|
| 92 | + // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 93 | + $GLOBALS['contexte'] = $page['contexte']; |
|
| 94 | + |
|
| 95 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 96 | + // d'inversion url => objet |
|
| 97 | + // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 98 | + #unset($_SERVER['REDIRECT_url_propre']); |
|
| 99 | + #unset($_ENV['url_propre']); |
|
| 100 | + } else { |
|
| 101 | + // Compat ascendante : |
|
| 102 | + // 1. $contexte est global |
|
| 103 | + // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 104 | + // et calculer la page |
|
| 105 | + if (!test_espace_prive()) { |
|
| 106 | + include_spip('inc/urls'); |
|
| 107 | + list($fond, $GLOBALS['contexte'], $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $GLOBALS['contexte'], |
|
| 108 | + true); |
|
| 109 | + } |
|
| 110 | + // squelette par defaut |
|
| 111 | + if (!strlen($fond)) { |
|
| 112 | + $fond = 'sommaire'; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // produire la page : peut mettre a jour $lastmodified |
|
| 116 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 117 | + $page = $produire_page($fond, $GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, null, $page, |
|
| 118 | + $lastmodified, $connect); |
|
| 119 | + if ($page === '') { |
|
| 120 | + $erreur = _T('info_erreur_squelette2', |
|
| 121 | + array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES)); |
|
| 122 | + erreur_squelette($erreur); |
|
| 123 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 124 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if ($page and $chemin_cache) { |
|
| 129 | + $page['cache'] = $chemin_cache; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + auto_content_type($page); |
|
| 133 | + |
|
| 134 | + $GLOBALS['flag_preserver'] |= headers_sent(); |
|
| 135 | + |
|
| 136 | + // Definir les entetes si ce n'est fait |
|
| 137 | + if (!$GLOBALS['flag_preserver']) { |
|
| 138 | + if ($GLOBALS['flag_ob']) { |
|
| 139 | + // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 140 | + if (trim($page['texte']) === '' |
|
| 141 | + and _VAR_MODE != 'debug' |
|
| 142 | + and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 143 | + ) { |
|
| 144 | + $GLOBALS['contexte']['fond_erreur'] = $fond; |
|
| 145 | + $page = message_page_indisponible($page, $GLOBALS['contexte']); |
|
| 146 | + } |
|
| 147 | + // pas de cache client en mode 'observation' |
|
| 148 | + if (defined('_VAR_MODE') and _VAR_MODE) { |
|
| 149 | + $page['entetes']["Cache-Control"] = "no-cache,must-revalidate"; |
|
| 150 | + $page['entetes']["Pragma"] = "no-cache"; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + // Entete Last-Modified: |
|
| 157 | + // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 158 | + // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 159 | + if ($lastmodified |
|
| 160 | + and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 161 | + and !isset($page['entetes']["Last-Modified"]) |
|
| 162 | + ) { |
|
| 163 | + $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + // fermer la connexion apres les headers si requete HEAD |
|
| 167 | + if ($headers_only) { |
|
| 168 | + $page['entetes']["Connection"] = "close"; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + return $page; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -187,19 +187,19 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function calculer_contexte() { |
| 189 | 189 | |
| 190 | - $contexte = array(); |
|
| 191 | - foreach ($_GET as $var => $val) { |
|
| 192 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 193 | - $contexte[$var] = $val; |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - foreach ($_POST as $var => $val) { |
|
| 197 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 198 | - $contexte[$var] = $val; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return $contexte; |
|
| 190 | + $contexte = array(); |
|
| 191 | + foreach ($_GET as $var => $val) { |
|
| 192 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 193 | + $contexte[$var] = $val; |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + foreach ($_POST as $var => $val) { |
|
| 197 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 198 | + $contexte[$var] = $val; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return $contexte; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -210,25 +210,25 @@ discard block |
||
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | 212 | function calculer_contexte_implicite() { |
| 213 | - static $notes = null; |
|
| 214 | - if (is_null($notes)) { |
|
| 215 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 216 | - } |
|
| 217 | - $contexte_implicite = array( |
|
| 218 | - 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 219 | - 'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null), |
|
| 220 | - 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
|
| 221 | - 'espace' => test_espace_prive(), |
|
| 222 | - 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 223 | - 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 224 | - 'notes' => $notes ? $notes('', 'contexter_cache') : '', |
|
| 225 | - 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 226 | - ); |
|
| 227 | - if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 228 | - $contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - return $contexte_implicite; |
|
| 213 | + static $notes = null; |
|
| 214 | + if (is_null($notes)) { |
|
| 215 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 216 | + } |
|
| 217 | + $contexte_implicite = array( |
|
| 218 | + 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 219 | + 'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null), |
|
| 220 | + 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
|
| 221 | + 'espace' => test_espace_prive(), |
|
| 222 | + 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 223 | + 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 224 | + 'notes' => $notes ? $notes('', 'contexter_cache') : '', |
|
| 225 | + 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 226 | + ); |
|
| 227 | + if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 228 | + $contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + return $contexte_implicite; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // |
@@ -238,50 +238,50 @@ discard block |
||
| 238 | 238 | // https://code.spip.net/@auto_content_type |
| 239 | 239 | function auto_content_type($page) { |
| 240 | 240 | |
| 241 | - if (!isset($GLOBALS['flag_preserver'])) { |
|
| 242 | - $GLOBALS['flag_preserver'] = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", |
|
| 243 | - $page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 244 | - } |
|
| 241 | + if (!isset($GLOBALS['flag_preserver'])) { |
|
| 242 | + $GLOBALS['flag_preserver'] = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", |
|
| 243 | + $page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 244 | + } |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // https://code.spip.net/@inclure_page |
| 248 | 248 | function inclure_page($fond, $contexte, $connect = '') { |
| 249 | - static $cacher, $produire_page; |
|
| 250 | - |
|
| 251 | - // enlever le fond de contexte inclus car sinon il prend la main |
|
| 252 | - // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 253 | - // (cette precaution n'est probablement plus utile) |
|
| 254 | - unset($contexte['fond']); |
|
| 255 | - $page = array('contexte_implicite' => calculer_contexte_implicite()); |
|
| 256 | - $page['contexte_implicite']['cache'] = $fond; |
|
| 257 | - if (is_null($cacher)) { |
|
| 258 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 259 | - } |
|
| 260 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 261 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 262 | - if ($cacher) { |
|
| 263 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 264 | - } else { |
|
| 265 | - $use_cache = -1; |
|
| 266 | - } |
|
| 267 | - // $res = message d'erreur : on sort de la |
|
| 268 | - if ($res) { |
|
| 269 | - return array('texte' => $res); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 273 | - // produire la page : peut mettre a jour $lastinclude |
|
| 274 | - // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 275 | - if ($use_cache) { |
|
| 276 | - if (is_null($produire_page)) { |
|
| 277 | - $produire_page = charger_fonction('produire_page', 'public'); |
|
| 278 | - } |
|
| 279 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 280 | - } |
|
| 281 | - // dans tous les cas, mettre a jour $GLOBALS['lastmodified'] |
|
| 282 | - $GLOBALS['lastmodified'] = max((isset($GLOBALS['lastmodified']) ? $GLOBALS['lastmodified'] : 0), $lastinclude); |
|
| 283 | - |
|
| 284 | - return $page; |
|
| 249 | + static $cacher, $produire_page; |
|
| 250 | + |
|
| 251 | + // enlever le fond de contexte inclus car sinon il prend la main |
|
| 252 | + // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 253 | + // (cette precaution n'est probablement plus utile) |
|
| 254 | + unset($contexte['fond']); |
|
| 255 | + $page = array('contexte_implicite' => calculer_contexte_implicite()); |
|
| 256 | + $page['contexte_implicite']['cache'] = $fond; |
|
| 257 | + if (is_null($cacher)) { |
|
| 258 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 259 | + } |
|
| 260 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 261 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 262 | + if ($cacher) { |
|
| 263 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 264 | + } else { |
|
| 265 | + $use_cache = -1; |
|
| 266 | + } |
|
| 267 | + // $res = message d'erreur : on sort de la |
|
| 268 | + if ($res) { |
|
| 269 | + return array('texte' => $res); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 273 | + // produire la page : peut mettre a jour $lastinclude |
|
| 274 | + // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 275 | + if ($use_cache) { |
|
| 276 | + if (is_null($produire_page)) { |
|
| 277 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 278 | + } |
|
| 279 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 280 | + } |
|
| 281 | + // dans tous les cas, mettre a jour $GLOBALS['lastmodified'] |
|
| 282 | + $GLOBALS['lastmodified'] = max((isset($GLOBALS['lastmodified']) ? $GLOBALS['lastmodified'] : 0), $lastinclude); |
|
| 283 | + |
|
| 284 | + return $page; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -299,40 +299,40 @@ discard block |
||
| 299 | 299 | * @return array |
| 300 | 300 | */ |
| 301 | 301 | function public_produire_page_dist( |
| 302 | - $fond, |
|
| 303 | - $contexte, |
|
| 304 | - $use_cache, |
|
| 305 | - $chemin_cache, |
|
| 306 | - $contexte_cache, |
|
| 307 | - &$page, |
|
| 308 | - &$lastinclude, |
|
| 309 | - $connect = '' |
|
| 302 | + $fond, |
|
| 303 | + $contexte, |
|
| 304 | + $use_cache, |
|
| 305 | + $chemin_cache, |
|
| 306 | + $contexte_cache, |
|
| 307 | + &$page, |
|
| 308 | + &$lastinclude, |
|
| 309 | + $connect = '' |
|
| 310 | 310 | ) { |
| 311 | - static $parametrer, $cacher; |
|
| 312 | - if (!$parametrer) { |
|
| 313 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 314 | - } |
|
| 315 | - $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 316 | - // et on l'enregistre sur le disque |
|
| 317 | - if ($chemin_cache |
|
| 318 | - and $use_cache > -1 |
|
| 319 | - and is_array($page) |
|
| 320 | - and count($page) |
|
| 321 | - and isset($page['entetes']['X-Spip-Cache']) |
|
| 322 | - and $page['entetes']['X-Spip-Cache'] > 0 |
|
| 323 | - ) { |
|
| 324 | - if (is_null($cacher)) { |
|
| 325 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 326 | - } |
|
| 327 | - $lastinclude = time(); |
|
| 328 | - if ($cacher) { |
|
| 329 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 330 | - } else { |
|
| 331 | - $use_cache = -1; |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - return $page; |
|
| 311 | + static $parametrer, $cacher; |
|
| 312 | + if (!$parametrer) { |
|
| 313 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 314 | + } |
|
| 315 | + $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 316 | + // et on l'enregistre sur le disque |
|
| 317 | + if ($chemin_cache |
|
| 318 | + and $use_cache > -1 |
|
| 319 | + and is_array($page) |
|
| 320 | + and count($page) |
|
| 321 | + and isset($page['entetes']['X-Spip-Cache']) |
|
| 322 | + and $page['entetes']['X-Spip-Cache'] > 0 |
|
| 323 | + ) { |
|
| 324 | + if (is_null($cacher)) { |
|
| 325 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 326 | + } |
|
| 327 | + $lastinclude = time(); |
|
| 328 | + if ($cacher) { |
|
| 329 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 330 | + } else { |
|
| 331 | + $use_cache = -1; |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + return $page; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Fonction inseree par le compilateur dans le code compile. |
@@ -346,14 +346,14 @@ discard block |
||
| 346 | 346 | // 4: langue |
| 347 | 347 | |
| 348 | 348 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) { |
| 349 | - arguments_balise_dyn_depuis_modele(null, 'reset'); |
|
| 350 | - |
|
| 351 | - if (!is_array($contexte_exec)) { |
|
| 352 | - echo $contexte_exec; |
|
| 353 | - } // message d'erreur etc |
|
| 354 | - else { |
|
| 355 | - inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 356 | - } |
|
| 349 | + arguments_balise_dyn_depuis_modele(null, 'reset'); |
|
| 350 | + |
|
| 351 | + if (!is_array($contexte_exec)) { |
|
| 352 | + echo $contexte_exec; |
|
| 353 | + } // message d'erreur etc |
|
| 354 | + else { |
|
| 355 | + inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -368,97 +368,97 @@ discard block |
||
| 368 | 368 | * @return string |
| 369 | 369 | */ |
| 370 | 370 | function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array()) { |
| 371 | - if (is_array($texte)) { |
|
| 372 | - |
|
| 373 | - list($fond, $delainc, $contexte_inclus) = $texte; |
|
| 374 | - |
|
| 375 | - // delais a l'ancienne, c'est pratiquement mort |
|
| 376 | - $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : null; |
|
| 377 | - $GLOBALS['delais'] = $delainc; |
|
| 378 | - |
|
| 379 | - $page = recuperer_fond($fond, $contexte_inclus, |
|
| 380 | - array('trim' => false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 381 | - |
|
| 382 | - $texte = $page['texte']; |
|
| 383 | - |
|
| 384 | - $GLOBALS['delais'] = $d; |
|
| 385 | - // Faire remonter les entetes |
|
| 386 | - if (is_array($page['entetes'])) { |
|
| 387 | - // mais pas toutes |
|
| 388 | - unset($page['entetes']['X-Spip-Cache']); |
|
| 389 | - unset($page['entetes']['Content-Type']); |
|
| 390 | - if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) { |
|
| 391 | - if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 392 | - $GLOBALS['page']['entetes'] = array(); |
|
| 393 | - } |
|
| 394 | - $GLOBALS['page']['entetes'] = |
|
| 395 | - array_merge($GLOBALS['page']['entetes'], $page['entetes']); |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 399 | - if (isset($page['contexte']['_pipelines']) |
|
| 400 | - and is_array($page['contexte']['_pipelines']) |
|
| 401 | - and count($page['contexte']['_pipelines']) |
|
| 402 | - ) { |
|
| 403 | - foreach ($page['contexte']['_pipelines'] as $pipe => $args) { |
|
| 404 | - $args['contexte'] = $page['contexte']; |
|
| 405 | - unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 406 | - $texte = pipeline( |
|
| 407 | - $pipe, |
|
| 408 | - array( |
|
| 409 | - 'data' => $texte, |
|
| 410 | - 'args' => $args |
|
| 411 | - ), |
|
| 412 | - false |
|
| 413 | - ); |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 419 | - // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 420 | - $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 421 | - $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 422 | - } |
|
| 423 | - if ($echo) { |
|
| 424 | - echo $texte; |
|
| 425 | - } else { |
|
| 426 | - return $texte; |
|
| 427 | - } |
|
| 371 | + if (is_array($texte)) { |
|
| 372 | + |
|
| 373 | + list($fond, $delainc, $contexte_inclus) = $texte; |
|
| 374 | + |
|
| 375 | + // delais a l'ancienne, c'est pratiquement mort |
|
| 376 | + $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : null; |
|
| 377 | + $GLOBALS['delais'] = $delainc; |
|
| 378 | + |
|
| 379 | + $page = recuperer_fond($fond, $contexte_inclus, |
|
| 380 | + array('trim' => false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 381 | + |
|
| 382 | + $texte = $page['texte']; |
|
| 383 | + |
|
| 384 | + $GLOBALS['delais'] = $d; |
|
| 385 | + // Faire remonter les entetes |
|
| 386 | + if (is_array($page['entetes'])) { |
|
| 387 | + // mais pas toutes |
|
| 388 | + unset($page['entetes']['X-Spip-Cache']); |
|
| 389 | + unset($page['entetes']['Content-Type']); |
|
| 390 | + if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) { |
|
| 391 | + if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 392 | + $GLOBALS['page']['entetes'] = array(); |
|
| 393 | + } |
|
| 394 | + $GLOBALS['page']['entetes'] = |
|
| 395 | + array_merge($GLOBALS['page']['entetes'], $page['entetes']); |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 399 | + if (isset($page['contexte']['_pipelines']) |
|
| 400 | + and is_array($page['contexte']['_pipelines']) |
|
| 401 | + and count($page['contexte']['_pipelines']) |
|
| 402 | + ) { |
|
| 403 | + foreach ($page['contexte']['_pipelines'] as $pipe => $args) { |
|
| 404 | + $args['contexte'] = $page['contexte']; |
|
| 405 | + unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 406 | + $texte = pipeline( |
|
| 407 | + $pipe, |
|
| 408 | + array( |
|
| 409 | + 'data' => $texte, |
|
| 410 | + 'args' => $args |
|
| 411 | + ), |
|
| 412 | + false |
|
| 413 | + ); |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 419 | + // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 420 | + $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 421 | + $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 422 | + } |
|
| 423 | + if ($echo) { |
|
| 424 | + echo $texte; |
|
| 425 | + } else { |
|
| 426 | + return $texte; |
|
| 427 | + } |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // https://code.spip.net/@message_page_indisponible |
| 431 | 431 | function message_page_indisponible($page, $contexte) { |
| 432 | - static $deja = false; |
|
| 433 | - if ($deja) { |
|
| 434 | - return "erreur"; |
|
| 435 | - } |
|
| 436 | - $codes = array( |
|
| 437 | - '404' => '404 Not Found', |
|
| 438 | - '503' => '503 Service Unavailable', |
|
| 439 | - ); |
|
| 440 | - |
|
| 441 | - $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 442 | - $contexte['code'] = $codes[$contexte['status']]; |
|
| 443 | - $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 444 | - if (!isset($contexte['lang'])) { |
|
| 445 | - include_spip('inc/lang'); |
|
| 446 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - $deja = true; |
|
| 450 | - // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 451 | - // ex restriction d'acces => 401 |
|
| 452 | - $contexte = pipeline('page_indisponible', $contexte); |
|
| 453 | - |
|
| 454 | - // produire la page d'erreur |
|
| 455 | - $page = inclure_page($contexte['fond'], $contexte); |
|
| 456 | - if (!$page) { |
|
| 457 | - $page = inclure_page('404', $contexte); |
|
| 458 | - } |
|
| 459 | - $page['status'] = $contexte['status']; |
|
| 460 | - |
|
| 461 | - return $page; |
|
| 432 | + static $deja = false; |
|
| 433 | + if ($deja) { |
|
| 434 | + return "erreur"; |
|
| 435 | + } |
|
| 436 | + $codes = array( |
|
| 437 | + '404' => '404 Not Found', |
|
| 438 | + '503' => '503 Service Unavailable', |
|
| 439 | + ); |
|
| 440 | + |
|
| 441 | + $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 442 | + $contexte['code'] = $codes[$contexte['status']]; |
|
| 443 | + $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 444 | + if (!isset($contexte['lang'])) { |
|
| 445 | + include_spip('inc/lang'); |
|
| 446 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + $deja = true; |
|
| 450 | + // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 451 | + // ex restriction d'acces => 401 |
|
| 452 | + $contexte = pipeline('page_indisponible', $contexte); |
|
| 453 | + |
|
| 454 | + // produire la page d'erreur |
|
| 455 | + $page = inclure_page($contexte['fond'], $contexte); |
|
| 456 | + if (!$page) { |
|
| 457 | + $page = inclure_page('404', $contexte); |
|
| 458 | + } |
|
| 459 | + $page['status'] = $contexte['status']; |
|
| 460 | + |
|
| 461 | + return $page; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -470,46 +470,46 @@ discard block |
||
| 470 | 470 | * @return mixed |
| 471 | 471 | */ |
| 472 | 472 | function arguments_balise_dyn_depuis_modele($arg, $operation = 'set') { |
| 473 | - static $balise_dyn_appellee_par_modele = null; |
|
| 474 | - switch ($operation) { |
|
| 475 | - case 'read': |
|
| 476 | - return $balise_dyn_appellee_par_modele; |
|
| 477 | - case 'reset': |
|
| 478 | - $balise_dyn_appellee_par_modele = null; |
|
| 479 | - return null; |
|
| 480 | - case 'set': |
|
| 481 | - default: |
|
| 482 | - $balise_dyn_appellee_par_modele = $arg; |
|
| 483 | - return $arg; |
|
| 484 | - } |
|
| 473 | + static $balise_dyn_appellee_par_modele = null; |
|
| 474 | + switch ($operation) { |
|
| 475 | + case 'read': |
|
| 476 | + return $balise_dyn_appellee_par_modele; |
|
| 477 | + case 'reset': |
|
| 478 | + $balise_dyn_appellee_par_modele = null; |
|
| 479 | + return null; |
|
| 480 | + case 'set': |
|
| 481 | + default: |
|
| 482 | + $balise_dyn_appellee_par_modele = $arg; |
|
| 483 | + return $arg; |
|
| 484 | + } |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | // temporairement ici : a mettre dans le futur inc/modeles |
| 488 | 488 | // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array() |
| 489 | 489 | // https://code.spip.net/@creer_contexte_de_modele |
| 490 | 490 | function creer_contexte_de_modele($args) { |
| 491 | - $contexte = array(); |
|
| 492 | - foreach ($args as $var => $val) { |
|
| 493 | - if (is_int($var)) { // argument pas formate |
|
| 494 | - if (in_array($val, array('left', 'right', 'center'))) { |
|
| 495 | - $var = 'align'; |
|
| 496 | - $contexte[$var] = $val; |
|
| 497 | - } else { |
|
| 498 | - $args = explode('=', $val); |
|
| 499 | - if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 500 | - { |
|
| 501 | - $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
|
| 502 | - } else // notation abregee |
|
| 503 | - { |
|
| 504 | - $contexte[trim($val)] = trim($val); |
|
| 505 | - } |
|
| 506 | - } |
|
| 507 | - } else { |
|
| 508 | - $contexte[$var] = $val; |
|
| 509 | - } |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - return $contexte; |
|
| 491 | + $contexte = array(); |
|
| 492 | + foreach ($args as $var => $val) { |
|
| 493 | + if (is_int($var)) { // argument pas formate |
|
| 494 | + if (in_array($val, array('left', 'right', 'center'))) { |
|
| 495 | + $var = 'align'; |
|
| 496 | + $contexte[$var] = $val; |
|
| 497 | + } else { |
|
| 498 | + $args = explode('=', $val); |
|
| 499 | + if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 500 | + { |
|
| 501 | + $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
|
| 502 | + } else // notation abregee |
|
| 503 | + { |
|
| 504 | + $contexte[trim($val)] = trim($val); |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | + } else { |
|
| 508 | + $contexte[$var] = $val; |
|
| 509 | + } |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + return $contexte; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
@@ -524,40 +524,40 @@ discard block |
||
| 524 | 524 | * @return string |
| 525 | 525 | */ |
| 526 | 526 | function styliser_modele($modele, $id, $contexte=null) { |
| 527 | - static $styliseurs = null; |
|
| 528 | - if (is_null($styliseurs)) { |
|
| 529 | - $tables_objet = lister_tables_objets_sql(); |
|
| 530 | - foreach ($tables_objet as $table => $desc) { |
|
| 531 | - if (isset($desc['modeles']) and $desc['modeles'] |
|
| 532 | - and isset($desc['modeles_styliser']) and $desc['modeles_styliser'] |
|
| 533 | - and function_exists($desc['modeles_styliser'])) { |
|
| 534 | - $primary = id_table_objet($table); |
|
| 535 | - foreach ($desc['modeles'] as $m) { |
|
| 536 | - $styliseurs[$m] = ['primary' => $primary, 'callback' => $desc['modeles_styliser']]; |
|
| 537 | - } |
|
| 538 | - } |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - if (isset($styliseurs[$modele])) { |
|
| 543 | - $styliseur = $styliseurs[$modele]['callback']; |
|
| 544 | - if (is_null($id) and $contexte) { |
|
| 545 | - if (isset($contexte['id'])) { |
|
| 546 | - $id = $contexte['id']; |
|
| 547 | - } elseif (isset($contexte[$primary])) { |
|
| 548 | - $id = $contexte[$primary]; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - if (is_null($id)) { |
|
| 552 | - $msg = "modeles/$modele : " . _T('zbug_parametres_inclus_incorrects', array('param' => "id/$primary")); |
|
| 553 | - erreur_squelette($msg); |
|
| 554 | - // on passe id=0 au routeur pour tomber sur le modele par defaut et eviter une seconde erreur sur un modele inexistant |
|
| 555 | - $id = 0; |
|
| 556 | - } |
|
| 557 | - $modele = $styliseur($modele, $id); |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - return $modele; |
|
| 527 | + static $styliseurs = null; |
|
| 528 | + if (is_null($styliseurs)) { |
|
| 529 | + $tables_objet = lister_tables_objets_sql(); |
|
| 530 | + foreach ($tables_objet as $table => $desc) { |
|
| 531 | + if (isset($desc['modeles']) and $desc['modeles'] |
|
| 532 | + and isset($desc['modeles_styliser']) and $desc['modeles_styliser'] |
|
| 533 | + and function_exists($desc['modeles_styliser'])) { |
|
| 534 | + $primary = id_table_objet($table); |
|
| 535 | + foreach ($desc['modeles'] as $m) { |
|
| 536 | + $styliseurs[$m] = ['primary' => $primary, 'callback' => $desc['modeles_styliser']]; |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | + } |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + if (isset($styliseurs[$modele])) { |
|
| 543 | + $styliseur = $styliseurs[$modele]['callback']; |
|
| 544 | + if (is_null($id) and $contexte) { |
|
| 545 | + if (isset($contexte['id'])) { |
|
| 546 | + $id = $contexte['id']; |
|
| 547 | + } elseif (isset($contexte[$primary])) { |
|
| 548 | + $id = $contexte[$primary]; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + if (is_null($id)) { |
|
| 552 | + $msg = "modeles/$modele : " . _T('zbug_parametres_inclus_incorrects', array('param' => "id/$primary")); |
|
| 553 | + erreur_squelette($msg); |
|
| 554 | + // on passe id=0 au routeur pour tomber sur le modele par defaut et eviter une seconde erreur sur un modele inexistant |
|
| 555 | + $id = 0; |
|
| 556 | + } |
|
| 557 | + $modele = $styliseur($modele, $id); |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + return $modele; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
@@ -576,95 +576,95 @@ discard block |
||
| 576 | 576 | */ |
| 577 | 577 | function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) { |
| 578 | 578 | |
| 579 | - static $compteur; |
|
| 580 | - if (++$compteur > 10) { |
|
| 581 | - return ''; |
|
| 582 | - } # ne pas boucler indefiniment |
|
| 583 | - |
|
| 584 | - $type = strtolower($type); |
|
| 585 | - $type = styliser_modele($type, $id); |
|
| 586 | - |
|
| 587 | - $fond = $class = ''; |
|
| 588 | - |
|
| 589 | - $params = array_filter(explode('|', $params)); |
|
| 590 | - if ($params) { |
|
| 591 | - $soustype = current($params); |
|
| 592 | - $soustype = strtolower(trim($soustype)); |
|
| 593 | - if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) { |
|
| 594 | - $soustype = next($params); |
|
| 595 | - $soustype = strtolower($soustype); |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 599 | - if (!trouve_modele($fond = ($type . '_' . $soustype))) { |
|
| 600 | - $fond = ''; |
|
| 601 | - $class = $soustype; |
|
| 602 | - } |
|
| 603 | - // enlever le sous type des params |
|
| 604 | - $params = array_diff($params, array($soustype)); |
|
| 605 | - } |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 609 | - if (!$fond and !trouve_modele($fond = $type)) { |
|
| 610 | - spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); |
|
| 611 | - |
|
| 612 | - return false; |
|
| 613 | - } |
|
| 614 | - $fond = 'modeles/' . $fond; |
|
| 615 | - // Creer le contexte |
|
| 616 | - $contexte = $env; |
|
| 617 | - $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 618 | - |
|
| 619 | - // Le numero du modele est mis dans l'environnement |
|
| 620 | - // d'une part sous l'identifiant "id" |
|
| 621 | - // et d'autre part sous l'identifiant de la cle primaire |
|
| 622 | - // par la fonction id_table_objet, |
|
| 623 | - // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 624 | - $_id = id_table_objet($type); |
|
| 625 | - $contexte['id'] = $contexte[$_id] = $id; |
|
| 626 | - |
|
| 627 | - if (isset($class)) { |
|
| 628 | - $contexte['class'] = $class; |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - // Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url] |
|
| 632 | - if ($lien) { |
|
| 633 | - # un eventuel guillemet (") sera reechappe par #ENV |
|
| 634 | - $contexte['lien'] = str_replace(""", '"', $lien['href']); |
|
| 635 | - $contexte['lien_class'] = $lien['class']; |
|
| 636 | - $contexte['lien_mime'] = $lien['mime']; |
|
| 637 | - $contexte['lien_title'] = $lien['title']; |
|
| 638 | - $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - // Traiter les parametres |
|
| 642 | - // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 643 | - $arg_list = creer_contexte_de_modele($params); |
|
| 644 | - $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 645 | - $contexte = array_merge($contexte, $arg_list); |
|
| 646 | - |
|
| 647 | - // Appliquer le modele avec le contexte |
|
| 648 | - $retour = recuperer_fond($fond, $contexte, array(), $connect); |
|
| 649 | - |
|
| 650 | - // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 651 | - // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 652 | - // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 653 | - if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', |
|
| 654 | - 'spip_lien_ok')) { |
|
| 655 | - $retour = inserer_attribut($retour, 'class', |
|
| 656 | - trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
|
| 657 | - } else { |
|
| 658 | - if ($lien) { |
|
| 659 | - $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>"; |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - $compteur--; |
|
| 664 | - |
|
| 665 | - return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax') |
|
| 666 | - ? encoder_contexte_ajax($contexte, '', $retour) |
|
| 667 | - : $retour; |
|
| 579 | + static $compteur; |
|
| 580 | + if (++$compteur > 10) { |
|
| 581 | + return ''; |
|
| 582 | + } # ne pas boucler indefiniment |
|
| 583 | + |
|
| 584 | + $type = strtolower($type); |
|
| 585 | + $type = styliser_modele($type, $id); |
|
| 586 | + |
|
| 587 | + $fond = $class = ''; |
|
| 588 | + |
|
| 589 | + $params = array_filter(explode('|', $params)); |
|
| 590 | + if ($params) { |
|
| 591 | + $soustype = current($params); |
|
| 592 | + $soustype = strtolower(trim($soustype)); |
|
| 593 | + if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) { |
|
| 594 | + $soustype = next($params); |
|
| 595 | + $soustype = strtolower($soustype); |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 599 | + if (!trouve_modele($fond = ($type . '_' . $soustype))) { |
|
| 600 | + $fond = ''; |
|
| 601 | + $class = $soustype; |
|
| 602 | + } |
|
| 603 | + // enlever le sous type des params |
|
| 604 | + $params = array_diff($params, array($soustype)); |
|
| 605 | + } |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 609 | + if (!$fond and !trouve_modele($fond = $type)) { |
|
| 610 | + spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); |
|
| 611 | + |
|
| 612 | + return false; |
|
| 613 | + } |
|
| 614 | + $fond = 'modeles/' . $fond; |
|
| 615 | + // Creer le contexte |
|
| 616 | + $contexte = $env; |
|
| 617 | + $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 618 | + |
|
| 619 | + // Le numero du modele est mis dans l'environnement |
|
| 620 | + // d'une part sous l'identifiant "id" |
|
| 621 | + // et d'autre part sous l'identifiant de la cle primaire |
|
| 622 | + // par la fonction id_table_objet, |
|
| 623 | + // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 624 | + $_id = id_table_objet($type); |
|
| 625 | + $contexte['id'] = $contexte[$_id] = $id; |
|
| 626 | + |
|
| 627 | + if (isset($class)) { |
|
| 628 | + $contexte['class'] = $class; |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + // Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url] |
|
| 632 | + if ($lien) { |
|
| 633 | + # un eventuel guillemet (") sera reechappe par #ENV |
|
| 634 | + $contexte['lien'] = str_replace(""", '"', $lien['href']); |
|
| 635 | + $contexte['lien_class'] = $lien['class']; |
|
| 636 | + $contexte['lien_mime'] = $lien['mime']; |
|
| 637 | + $contexte['lien_title'] = $lien['title']; |
|
| 638 | + $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + // Traiter les parametres |
|
| 642 | + // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 643 | + $arg_list = creer_contexte_de_modele($params); |
|
| 644 | + $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 645 | + $contexte = array_merge($contexte, $arg_list); |
|
| 646 | + |
|
| 647 | + // Appliquer le modele avec le contexte |
|
| 648 | + $retour = recuperer_fond($fond, $contexte, array(), $connect); |
|
| 649 | + |
|
| 650 | + // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 651 | + // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 652 | + // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 653 | + if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', |
|
| 654 | + 'spip_lien_ok')) { |
|
| 655 | + $retour = inserer_attribut($retour, 'class', |
|
| 656 | + trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
|
| 657 | + } else { |
|
| 658 | + if ($lien) { |
|
| 659 | + $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>"; |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + $compteur--; |
|
| 664 | + |
|
| 665 | + return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax') |
|
| 666 | + ? encoder_contexte_ajax($contexte, '', $retour) |
|
| 667 | + : $retour; |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | // Un inclure_page qui marche aussi pour l'espace prive |
@@ -674,98 +674,98 @@ discard block |
||
| 674 | 674 | // https://code.spip.net/@evaluer_fond |
| 675 | 675 | function evaluer_fond($fond, $contexte = array(), $connect = null) { |
| 676 | 676 | |
| 677 | - $page = inclure_page($fond, $contexte, $connect); |
|
| 678 | - |
|
| 679 | - if (!$page) { |
|
| 680 | - return $page; |
|
| 681 | - } |
|
| 682 | - // eval $page et affecte $res |
|
| 683 | - include _ROOT_RESTREINT . "public/evaluer_page.php"; |
|
| 684 | - |
|
| 685 | - // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 686 | - // a destination de public/parametrer |
|
| 687 | - // pour remonter vers les inclusions appelantes |
|
| 688 | - // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 689 | - // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 690 | - if (isset($page['invalideurs']) |
|
| 691 | - and isset($page['invalideurs']['session']) |
|
| 692 | - ) { |
|
| 693 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - return $page; |
|
| 677 | + $page = inclure_page($fond, $contexte, $connect); |
|
| 678 | + |
|
| 679 | + if (!$page) { |
|
| 680 | + return $page; |
|
| 681 | + } |
|
| 682 | + // eval $page et affecte $res |
|
| 683 | + include _ROOT_RESTREINT . "public/evaluer_page.php"; |
|
| 684 | + |
|
| 685 | + // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 686 | + // a destination de public/parametrer |
|
| 687 | + // pour remonter vers les inclusions appelantes |
|
| 688 | + // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 689 | + // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 690 | + if (isset($page['invalideurs']) |
|
| 691 | + and isset($page['invalideurs']['session']) |
|
| 692 | + ) { |
|
| 693 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + return $page; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
| 700 | 700 | // https://code.spip.net/@page_base_href |
| 701 | 701 | function page_base_href(&$texte) { |
| 702 | - static $set_html_base = null; |
|
| 703 | - if (is_null($set_html_base)) { |
|
| 704 | - if (!defined('_SET_HTML_BASE')) |
|
| 705 | - // si la profondeur est superieure a 1 |
|
| 706 | - // est que ce n'est pas une url page ni une url action |
|
| 707 | - // activer par defaut |
|
| 708 | - { |
|
| 709 | - $set_html_base = (( |
|
| 710 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 711 | - and _request(_SPIP_PAGE) !== 'login' |
|
| 712 | - and !_request('action')) ? true : false); |
|
| 713 | - } else { |
|
| 714 | - $set_html_base = _SET_HTML_BASE; |
|
| 715 | - } |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - if ($set_html_base |
|
| 719 | - and isset($GLOBALS['html']) and $GLOBALS['html'] |
|
| 720 | - and $GLOBALS['profondeur_url'] > 0 |
|
| 721 | - and ($poshead = strpos($texte, '</head>')) !== false |
|
| 722 | - ) { |
|
| 723 | - $head = substr($texte, 0, $poshead); |
|
| 724 | - $insert = false; |
|
| 725 | - $href_base = false; |
|
| 726 | - if (strpos($head, '<base') === false) { |
|
| 727 | - $insert = true; |
|
| 728 | - } else { |
|
| 729 | - // si aucun <base ...> n'a de href il faut en inserer un |
|
| 730 | - // sinon juste re-ecrire les ancres si besoin |
|
| 731 | - $insert = true; |
|
| 732 | - include_spip('inc/filtres'); |
|
| 733 | - $bases = extraire_balises($head, 'base'); |
|
| 734 | - foreach ($bases as $base) { |
|
| 735 | - if ($href_base = extraire_attribut($base, 'href')) { |
|
| 736 | - $insert = false; |
|
| 737 | - break; |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - if ($insert){ |
|
| 743 | - include_spip('inc/filtres_mini'); |
|
| 744 | - // ajouter un base qui reglera tous les liens relatifs |
|
| 745 | - $href_base = url_absolue('./'); |
|
| 746 | - $base = "\n<base href=\"$href_base\" />"; |
|
| 747 | - if (($pos = strpos($head, '<head>'))!==false){ |
|
| 748 | - $head = substr_replace($head, $base, $pos+6, 0); |
|
| 749 | - } elseif (preg_match(",<head[^>]*>,i", $head, $r)) { |
|
| 750 | - $head = str_replace($r[0], $r[0] . $base, $head); |
|
| 751 | - } |
|
| 752 | - $texte = $head . substr($texte, $poshead); |
|
| 753 | - } |
|
| 754 | - if ($href_base) { |
|
| 755 | - // gerer les ancres |
|
| 756 | - $base = $_SERVER['REQUEST_URI']; |
|
| 757 | - // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
|
| 758 | - if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
|
| 759 | - $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
|
| 760 | - } |
|
| 761 | - if (strpos($texte, "href='#") !== false) { |
|
| 762 | - $texte = str_replace("href='#", "href='$base#", $texte); |
|
| 763 | - } |
|
| 764 | - if (strpos($texte, "href=\"#") !== false) { |
|
| 765 | - $texte = str_replace("href=\"#", "href=\"$base#", $texte); |
|
| 766 | - } |
|
| 767 | - } |
|
| 768 | - } |
|
| 702 | + static $set_html_base = null; |
|
| 703 | + if (is_null($set_html_base)) { |
|
| 704 | + if (!defined('_SET_HTML_BASE')) |
|
| 705 | + // si la profondeur est superieure a 1 |
|
| 706 | + // est que ce n'est pas une url page ni une url action |
|
| 707 | + // activer par defaut |
|
| 708 | + { |
|
| 709 | + $set_html_base = (( |
|
| 710 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 711 | + and _request(_SPIP_PAGE) !== 'login' |
|
| 712 | + and !_request('action')) ? true : false); |
|
| 713 | + } else { |
|
| 714 | + $set_html_base = _SET_HTML_BASE; |
|
| 715 | + } |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + if ($set_html_base |
|
| 719 | + and isset($GLOBALS['html']) and $GLOBALS['html'] |
|
| 720 | + and $GLOBALS['profondeur_url'] > 0 |
|
| 721 | + and ($poshead = strpos($texte, '</head>')) !== false |
|
| 722 | + ) { |
|
| 723 | + $head = substr($texte, 0, $poshead); |
|
| 724 | + $insert = false; |
|
| 725 | + $href_base = false; |
|
| 726 | + if (strpos($head, '<base') === false) { |
|
| 727 | + $insert = true; |
|
| 728 | + } else { |
|
| 729 | + // si aucun <base ...> n'a de href il faut en inserer un |
|
| 730 | + // sinon juste re-ecrire les ancres si besoin |
|
| 731 | + $insert = true; |
|
| 732 | + include_spip('inc/filtres'); |
|
| 733 | + $bases = extraire_balises($head, 'base'); |
|
| 734 | + foreach ($bases as $base) { |
|
| 735 | + if ($href_base = extraire_attribut($base, 'href')) { |
|
| 736 | + $insert = false; |
|
| 737 | + break; |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + if ($insert){ |
|
| 743 | + include_spip('inc/filtres_mini'); |
|
| 744 | + // ajouter un base qui reglera tous les liens relatifs |
|
| 745 | + $href_base = url_absolue('./'); |
|
| 746 | + $base = "\n<base href=\"$href_base\" />"; |
|
| 747 | + if (($pos = strpos($head, '<head>'))!==false){ |
|
| 748 | + $head = substr_replace($head, $base, $pos+6, 0); |
|
| 749 | + } elseif (preg_match(",<head[^>]*>,i", $head, $r)) { |
|
| 750 | + $head = str_replace($r[0], $r[0] . $base, $head); |
|
| 751 | + } |
|
| 752 | + $texte = $head . substr($texte, $poshead); |
|
| 753 | + } |
|
| 754 | + if ($href_base) { |
|
| 755 | + // gerer les ancres |
|
| 756 | + $base = $_SERVER['REQUEST_URI']; |
|
| 757 | + // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
|
| 758 | + if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
|
| 759 | + $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
|
| 760 | + } |
|
| 761 | + if (strpos($texte, "href='#") !== false) { |
|
| 762 | + $texte = str_replace("href='#", "href='$base#", $texte); |
|
| 763 | + } |
|
| 764 | + if (strpos($texte, "href=\"#") !== false) { |
|
| 765 | + $texte = str_replace("href=\"#", "href=\"$base#", $texte); |
|
| 766 | + } |
|
| 767 | + } |
|
| 768 | + } |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -773,8 +773,8 @@ discard block |
||
| 773 | 773 | // et demarrent par X-Spip-... |
| 774 | 774 | // https://code.spip.net/@envoyer_entetes |
| 775 | 775 | function envoyer_entetes($entetes) { |
| 776 | - foreach ($entetes as $k => $v) # if (strncmp($k, 'X-Spip-', 7)) |
|
| 777 | - { |
|
| 778 | - @header(strlen($v) ? "$k: $v" : $k); |
|
| 779 | - } |
|
| 776 | + foreach ($entetes as $k => $v) # if (strncmp($k, 'X-Spip-', 7)) |
|
| 777 | + { |
|
| 778 | + @header(strlen($v) ? "$k: $v" : $k); |
|
| 779 | + } |
|
| 780 | 780 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $GLOBALS['contexte'] = calculer_contexte(); |
| 39 | 39 | $page = array('contexte_implicite' => calculer_contexte_implicite()); |
| 40 | - $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', |
|
| 40 | + $page['contexte_implicite']['cache'] = $fond.preg_replace(',\.[a-zA-Z0-9]*$,', '', |
|
| 41 | 41 | preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
| 42 | 42 | // Cette fonction est utilisee deux fois |
| 43 | 43 | $cacher = charger_fonction('cacher', 'public', true); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $lastmodified, $connect); |
| 119 | 119 | if ($page === '') { |
| 120 | 120 | $erreur = _T('info_erreur_squelette2', |
| 121 | - array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES)); |
|
| 121 | + array('fichier' => spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES)); |
|
| 122 | 122 | erreur_squelette($erreur); |
| 123 | 123 | // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
| 124 | 124 | $page = array('texte' => '', 'erreur' => $erreur); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 161 | 161 | and !isset($page['entetes']["Last-Modified"]) |
| 162 | 162 | ) { |
| 163 | - $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"; |
|
| 163 | + $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // fermer la connexion apres les headers si requete HEAD |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | 'spip_version_code' => $GLOBALS['spip_version_code'], |
| 226 | 226 | ); |
| 227 | 227 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 228 | - $contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 228 | + $contexte_implicite['host'] .= "|".$_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | return $contexte_implicite; |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | * et il ne doit etre utilise que pour trouver le id_xx si pas de $id fourni (cas appel depuis styliser) |
| 524 | 524 | * @return string |
| 525 | 525 | */ |
| 526 | -function styliser_modele($modele, $id, $contexte=null) { |
|
| 526 | +function styliser_modele($modele, $id, $contexte = null) { |
|
| 527 | 527 | static $styliseurs = null; |
| 528 | 528 | if (is_null($styliseurs)) { |
| 529 | 529 | $tables_objet = lister_tables_objets_sql(); |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | 551 | if (is_null($id)) { |
| 552 | - $msg = "modeles/$modele : " . _T('zbug_parametres_inclus_incorrects', array('param' => "id/$primary")); |
|
| 552 | + $msg = "modeles/$modele : "._T('zbug_parametres_inclus_incorrects', array('param' => "id/$primary")); |
|
| 553 | 553 | erreur_squelette($msg); |
| 554 | 554 | // on passe id=0 au routeur pour tomber sur le modele par defaut et eviter une seconde erreur sur un modele inexistant |
| 555 | 555 | $id = 0; |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
| 599 | - if (!trouve_modele($fond = ($type . '_' . $soustype))) { |
|
| 599 | + if (!trouve_modele($fond = ($type.'_'.$soustype))) { |
|
| 600 | 600 | $fond = ''; |
| 601 | 601 | $class = $soustype; |
| 602 | 602 | } |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | |
| 612 | 612 | return false; |
| 613 | 613 | } |
| 614 | - $fond = 'modeles/' . $fond; |
|
| 614 | + $fond = 'modeles/'.$fond; |
|
| 615 | 615 | // Creer le contexte |
| 616 | 616 | $contexte = $env; |
| 617 | 617 | $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
@@ -650,13 +650,13 @@ discard block |
||
| 650 | 650 | // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
| 651 | 651 | // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
| 652 | 652 | // sinon, s'il y a un lien, on l'ajoute classiquement |
| 653 | - if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', |
|
| 653 | + if (strstr(' '.($classes = extraire_attribut($retour, 'class')).' ', |
|
| 654 | 654 | 'spip_lien_ok')) { |
| 655 | 655 | $retour = inserer_attribut($retour, 'class', |
| 656 | 656 | trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
| 657 | 657 | } else { |
| 658 | 658 | if ($lien) { |
| 659 | - $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>"; |
|
| 659 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | return $page; |
| 681 | 681 | } |
| 682 | 682 | // eval $page et affecte $res |
| 683 | - include _ROOT_RESTREINT . "public/evaluer_page.php"; |
|
| 683 | + include _ROOT_RESTREINT."public/evaluer_page.php"; |
|
| 684 | 684 | |
| 685 | 685 | // Lever un drapeau (global) si le fond utilise #SESSION |
| 686 | 686 | // a destination de public/parametrer |
@@ -739,24 +739,24 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if ($insert){ |
|
| 742 | + if ($insert) { |
|
| 743 | 743 | include_spip('inc/filtres_mini'); |
| 744 | 744 | // ajouter un base qui reglera tous les liens relatifs |
| 745 | 745 | $href_base = url_absolue('./'); |
| 746 | 746 | $base = "\n<base href=\"$href_base\" />"; |
| 747 | - if (($pos = strpos($head, '<head>'))!==false){ |
|
| 748 | - $head = substr_replace($head, $base, $pos+6, 0); |
|
| 747 | + if (($pos = strpos($head, '<head>')) !== false) { |
|
| 748 | + $head = substr_replace($head, $base, $pos + 6, 0); |
|
| 749 | 749 | } elseif (preg_match(",<head[^>]*>,i", $head, $r)) { |
| 750 | - $head = str_replace($r[0], $r[0] . $base, $head); |
|
| 750 | + $head = str_replace($r[0], $r[0].$base, $head); |
|
| 751 | 751 | } |
| 752 | - $texte = $head . substr($texte, $poshead); |
|
| 752 | + $texte = $head.substr($texte, $poshead); |
|
| 753 | 753 | } |
| 754 | 754 | if ($href_base) { |
| 755 | 755 | // gerer les ancres |
| 756 | 756 | $base = $_SERVER['REQUEST_URI']; |
| 757 | 757 | // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
| 758 | - if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
|
| 759 | - $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
|
| 758 | + if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) { |
|
| 759 | + $base = str_replace(array("'", '"', '<'), array("%27", '%22', '%3C'), $base); |
|
| 760 | 760 | } |
| 761 | 761 | if (strpos($texte, "href='#") !== false) { |
| 762 | 762 | $texte = str_replace("href='#", "href='$base#", $texte); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('base/abstract_sql'); |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | |
| 25 | 25 | function inc_lien_dist( |
| 26 | - $lien, |
|
| 27 | - $texte = '', |
|
| 28 | - $class = '', |
|
| 29 | - $title = '', |
|
| 30 | - $hlang = '', |
|
| 31 | - $rel = '', |
|
| 32 | - $connect = '', |
|
| 33 | - $env = array() |
|
| 26 | + $lien, |
|
| 27 | + $texte = '', |
|
| 28 | + $class = '', |
|
| 29 | + $title = '', |
|
| 30 | + $hlang = '', |
|
| 31 | + $rel = '', |
|
| 32 | + $connect = '', |
|
| 33 | + $env = array() |
|
| 34 | 34 | ) { |
| 35 | - return $lien; |
|
| 35 | + return $lien; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
@@ -44,30 +44,30 @@ discard block |
||
| 44 | 44 | // https://code.spip.net/@expanser_liens |
| 45 | 45 | function expanser_liens($t, $connect = '', $env = array()) { |
| 46 | 46 | |
| 47 | - $t = pipeline('pre_liens', $t); |
|
| 47 | + $t = pipeline('pre_liens', $t); |
|
| 48 | 48 | |
| 49 | - // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | - // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | - $t = traiter_modeles($t, false, false, $connect); |
|
| 49 | + // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | + // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | + $t = traiter_modeles($t, false, false, $connect); |
|
| 52 | 52 | |
| 53 | - return $t; |
|
| 53 | + return $t; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Meme analyse mais pour eliminer les liens |
| 57 | 57 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 58 | 58 | // https://code.spip.net/@nettoyer_raccourcis_typo |
| 59 | 59 | function nettoyer_raccourcis_typo($texte, $connect = '') { |
| 60 | - return $texte; |
|
| 60 | + return $texte; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Repere dans la partie texte d'un raccourci [texte->...] |
| 64 | 64 | // la langue et la bulle eventuelles |
| 65 | 65 | // https://code.spip.net/@traiter_raccourci_lien_atts |
| 66 | 66 | function traiter_raccourci_lien_atts($texte) { |
| 67 | - $bulle = ''; |
|
| 68 | - $hlang = ''; |
|
| 67 | + $bulle = ''; |
|
| 68 | + $hlang = ''; |
|
| 69 | 69 | |
| 70 | - return array(trim($texte), $bulle, $hlang); |
|
| 70 | + return array(trim($texte), $bulle, $hlang); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function virtuel_redirige($virtuel, $url = false) { |
| 86 | - return $virtuel; |
|
| 86 | + return $virtuel; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Cherche un lien du type [->raccourci 123] |
@@ -97,114 +97,114 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // https://code.spip.net/@calculer_url |
| 99 | 99 | function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 100 | - $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 100 | + $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 101 | 101 | |
| 102 | - return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 102 | + return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
| 106 | 106 | |
| 107 | 107 | // https://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 109 | - if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | - return ($pour != 'tout') ? '' : array('', '', '', ''); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $lien = entites_html(trim($ref)); |
|
| 114 | - |
|
| 115 | - // Liens explicites |
|
| 116 | - if (!$texte) { |
|
| 117 | - $texte = str_replace('"', '', $lien); |
|
| 118 | - // evite l'affichage de trops longues urls. |
|
| 119 | - $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | - $texte = $lien_court($texte); |
|
| 121 | - if ($echappe_typo) { |
|
| 122 | - $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // petites corrections d'URL |
|
| 127 | - if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | - $lien = "http://" . $lien; |
|
| 129 | - } else { |
|
| 130 | - if (strpos($lien, "@") && email_valide($lien)) { |
|
| 131 | - if (!$texte) { |
|
| 132 | - $texte = $lien; |
|
| 133 | - } |
|
| 134 | - $lien = "mailto:" . $lien; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($pour == 'url') { |
|
| 139 | - return $lien; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if ($pour == 'titre') { |
|
| 143 | - return $texte; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return array('url' => $lien, 'titre' => $texte); |
|
| 109 | + if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | + return ($pour != 'tout') ? '' : array('', '', '', ''); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $lien = entites_html(trim($ref)); |
|
| 114 | + |
|
| 115 | + // Liens explicites |
|
| 116 | + if (!$texte) { |
|
| 117 | + $texte = str_replace('"', '', $lien); |
|
| 118 | + // evite l'affichage de trops longues urls. |
|
| 119 | + $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | + $texte = $lien_court($texte); |
|
| 121 | + if ($echappe_typo) { |
|
| 122 | + $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // petites corrections d'URL |
|
| 127 | + if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | + $lien = "http://" . $lien; |
|
| 129 | + } else { |
|
| 130 | + if (strpos($lien, "@") && email_valide($lien)) { |
|
| 131 | + if (!$texte) { |
|
| 132 | + $texte = $lien; |
|
| 133 | + } |
|
| 134 | + $lien = "mailto:" . $lien; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($pour == 'url') { |
|
| 139 | + return $lien; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if ($pour == 'titre') { |
|
| 143 | + return $texte; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return array('url' => $lien, 'titre' => $texte); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | - $url = $f($texte, $id); |
|
| 152 | - } else { |
|
| 153 | - $url = glossaire_std($texte); |
|
| 154 | - } |
|
| 150 | + if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | + $url = $f($texte, $id); |
|
| 152 | + } else { |
|
| 153 | + $url = glossaire_std($texte); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $url; |
|
| 156 | + return $url; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // https://code.spip.net/@traiter_lien_implicite |
| 160 | 160 | function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') { |
| 161 | - if (!($match = typer_raccourci($ref))) { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | - // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | - // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | - if ($f = charger_fonction("implicite_$type", "liens", true)) { |
|
| 168 | - $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | - } |
|
| 170 | - if (!$url) { |
|
| 171 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | - } |
|
| 173 | - if (!$url) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - if (is_array($url)) { |
|
| 177 | - @list($type, $id) = $url; |
|
| 178 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | - } |
|
| 180 | - if ($pour === 'url') { |
|
| 181 | - return $url; |
|
| 182 | - } |
|
| 183 | - $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | - if ($r) { |
|
| 185 | - $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | - } |
|
| 187 | - if ($texte = trim($texte)) { |
|
| 188 | - $r['titre'] = $texte; |
|
| 189 | - } |
|
| 190 | - if (!@$r['titre']) { |
|
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 192 | - } |
|
| 193 | - if ($pour == 'titre') { |
|
| 194 | - return $r['titre']; |
|
| 195 | - } |
|
| 196 | - $r['url'] = $url; |
|
| 197 | - |
|
| 198 | - // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | - if ($type == 'document' |
|
| 200 | - and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
|
| 201 | - "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 202 | - '', '', '', '', $connect) |
|
| 203 | - ) { |
|
| 204 | - $r['mime'] = $mime; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - return $r; |
|
| 161 | + if (!($match = typer_raccourci($ref))) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | + @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | + // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | + // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | + if ($f = charger_fonction("implicite_$type", "liens", true)) { |
|
| 168 | + $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | + } |
|
| 170 | + if (!$url) { |
|
| 171 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | + } |
|
| 173 | + if (!$url) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + if (is_array($url)) { |
|
| 177 | + @list($type, $id) = $url; |
|
| 178 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | + } |
|
| 180 | + if ($pour === 'url') { |
|
| 181 | + return $url; |
|
| 182 | + } |
|
| 183 | + $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | + if ($r) { |
|
| 185 | + $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | + } |
|
| 187 | + if ($texte = trim($texte)) { |
|
| 188 | + $r['titre'] = $texte; |
|
| 189 | + } |
|
| 190 | + if (!@$r['titre']) { |
|
| 191 | + $r['titre'] = _T($type) . " $id"; |
|
| 192 | + } |
|
| 193 | + if ($pour == 'titre') { |
|
| 194 | + return $r['titre']; |
|
| 195 | + } |
|
| 196 | + $r['url'] = $url; |
|
| 197 | + |
|
| 198 | + // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | + if ($type == 'document' |
|
| 200 | + and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
|
| 201 | + "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 202 | + '', '', '', '', $connect) |
|
| 203 | + ) { |
|
| 204 | + $r['mime'] = $mime; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + return $r; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes |
@@ -213,41 +213,41 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // https://code.spip.net/@typer_raccourci |
| 215 | 215 | function typer_raccourci($lien) { |
| 216 | - if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 217 | - return array(); |
|
| 218 | - } |
|
| 219 | - $f = $match[1]; |
|
| 220 | - // valeur par defaut et alias historiques |
|
| 221 | - if (!$f) { |
|
| 222 | - $f = 'article'; |
|
| 223 | - } else { |
|
| 224 | - if ($f == 'art') { |
|
| 225 | - $f = 'article'; |
|
| 226 | - } else { |
|
| 227 | - if ($f == 'br') { |
|
| 228 | - $f = 'breve'; |
|
| 229 | - } else { |
|
| 230 | - if ($f == 'rub') { |
|
| 231 | - $f = 'rubrique'; |
|
| 232 | - } else { |
|
| 233 | - if ($f == 'aut') { |
|
| 234 | - $f = 'auteur'; |
|
| 235 | - } else { |
|
| 236 | - if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 237 | - $f = 'document'; |
|
| 238 | - } else { |
|
| 239 | - if (preg_match('/^br..?ve$/S', $f)) { |
|
| 240 | - $f = 'breve'; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } # accents :( |
|
| 248 | - $match[0] = $f; |
|
| 249 | - |
|
| 250 | - return $match; |
|
| 216 | + if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 217 | + return array(); |
|
| 218 | + } |
|
| 219 | + $f = $match[1]; |
|
| 220 | + // valeur par defaut et alias historiques |
|
| 221 | + if (!$f) { |
|
| 222 | + $f = 'article'; |
|
| 223 | + } else { |
|
| 224 | + if ($f == 'art') { |
|
| 225 | + $f = 'article'; |
|
| 226 | + } else { |
|
| 227 | + if ($f == 'br') { |
|
| 228 | + $f = 'breve'; |
|
| 229 | + } else { |
|
| 230 | + if ($f == 'rub') { |
|
| 231 | + $f = 'rubrique'; |
|
| 232 | + } else { |
|
| 233 | + if ($f == 'aut') { |
|
| 234 | + $f = 'auteur'; |
|
| 235 | + } else { |
|
| 236 | + if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 237 | + $f = 'document'; |
|
| 238 | + } else { |
|
| 239 | + if (preg_match('/^br..?ve$/S', $f)) { |
|
| 240 | + $f = 'breve'; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } # accents :( |
|
| 248 | + $match[0] = $f; |
|
| 249 | + |
|
| 250 | + return $match; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -262,25 +262,25 @@ discard block |
||
| 262 | 262 | * } |
| 263 | 263 | **/ |
| 264 | 264 | function traiter_raccourci_titre($id, $type, $connect = null) { |
| 265 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 266 | - $desc = $trouver_table(table_objet($type)); |
|
| 267 | - if (!($desc and $s = $desc['titre'])) { |
|
| 268 | - return array(); |
|
| 269 | - } |
|
| 270 | - $_id = $desc['key']['PRIMARY KEY']; |
|
| 271 | - $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 272 | - if (!$r) { |
|
| 273 | - return array(); |
|
| 274 | - } |
|
| 275 | - $r['titre'] = supprimer_numero($r['titre']); |
|
| 276 | - if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 277 | - $r['titre'] = $r['surnom']; |
|
| 278 | - } |
|
| 279 | - if (!isset($r['lang'])) { |
|
| 280 | - $r['lang'] = ''; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - return $r; |
|
| 265 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 266 | + $desc = $trouver_table(table_objet($type)); |
|
| 267 | + if (!($desc and $s = $desc['titre'])) { |
|
| 268 | + return array(); |
|
| 269 | + } |
|
| 270 | + $_id = $desc['key']['PRIMARY KEY']; |
|
| 271 | + $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 272 | + if (!$r) { |
|
| 273 | + return array(); |
|
| 274 | + } |
|
| 275 | + $r['titre'] = supprimer_numero($r['titre']); |
|
| 276 | + if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 277 | + $r['titre'] = $r['surnom']; |
|
| 278 | + } |
|
| 279 | + if (!isset($r['lang'])) { |
|
| 280 | + $r['lang'] = ''; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + return $r; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // traite les modeles (dans la fonction typo), en remplacant |
@@ -292,115 +292,115 @@ discard block |
||
| 292 | 292 | // https://code.spip.net/@traiter_modeles |
| 293 | 293 | |
| 294 | 294 | define('_RACCOURCI_MODELE', |
| 295 | - '(<([a-z_-]{3,})' # <modele |
|
| 296 | - . '\s*([0-9]*)\s*' # id |
|
| 297 | - . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 298 | - . '\s*/?' . '>)' # fin du modele > |
|
| 299 | - . '\s*(<\/a>)?' # eventuel </a> |
|
| 295 | + '(<([a-z_-]{3,})' # <modele |
|
| 296 | + . '\s*([0-9]*)\s*' # id |
|
| 297 | + . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 298 | + . '\s*/?' . '>)' # fin du modele > |
|
| 299 | + . '\s*(<\/a>)?' # eventuel </a> |
|
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | 302 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 303 | 303 | |
| 304 | 304 | // https://code.spip.net/@traiter_modeles |
| 305 | 305 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
| 306 | - // preserver la compatibilite : true = recherche des documents |
|
| 307 | - if ($doublons === true) { |
|
| 308 | - $doublons = array('documents' => array('doc', 'emb', 'img')); |
|
| 309 | - } |
|
| 310 | - // detecter les modeles (rapide) |
|
| 311 | - if (strpos($texte, "<") !== false and |
|
| 312 | - preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 313 | - ) { |
|
| 314 | - include_spip('public/assembler'); |
|
| 315 | - $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true); |
|
| 316 | - foreach ($matches as $match) { |
|
| 317 | - // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 318 | - |
|
| 319 | - $a = strpos($texte, $match[0]); |
|
| 320 | - preg_match(_RACCOURCI_MODELE_DEBUT, |
|
| 321 | - substr($texte, $a), $regs); |
|
| 322 | - $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 323 | - list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 324 | - if ($fin and |
|
| 325 | - preg_match('/<a\s[^<>]*>\s*$/i', |
|
| 326 | - substr($texte, 0, $a), $r) |
|
| 327 | - ) { |
|
| 328 | - $lien = array( |
|
| 329 | - 'href' => extraire_attribut($r[0], 'href'), |
|
| 330 | - 'class' => extraire_attribut($r[0], 'class'), |
|
| 331 | - 'mime' => extraire_attribut($r[0], 'type'), |
|
| 332 | - 'title' => extraire_attribut($r[0], 'title'), |
|
| 333 | - 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 334 | - ); |
|
| 335 | - $n = strlen($r[0]); |
|
| 336 | - $a -= $n; |
|
| 337 | - $cherche = $n + strlen($regs[0]); |
|
| 338 | - } else { |
|
| 339 | - $lien = false; |
|
| 340 | - $cherche = strlen($mod); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - // calculer le modele |
|
| 344 | - # hack indexation |
|
| 345 | - if ($doublons) { |
|
| 346 | - $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 347 | - } # version normale |
|
| 348 | - else { |
|
| 349 | - // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 350 | - // dans les parametres, plutot que les liens echappes |
|
| 351 | - if (!is_null($liens)) { |
|
| 352 | - $params = str_replace($liens[0], $liens[1], $params); |
|
| 353 | - } |
|
| 354 | - $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 355 | - // en cas d'echec, |
|
| 356 | - // si l'objet demande a une url, |
|
| 357 | - // creer un petit encadre vers elle |
|
| 358 | - if ($modele === false) { |
|
| 359 | - if (!$lien) { |
|
| 360 | - $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 361 | - } |
|
| 362 | - if ($lien) { |
|
| 363 | - $modele = '<a href="' |
|
| 364 | - . $lien['url'] |
|
| 365 | - . '" class="spip_modele' |
|
| 366 | - . '">' |
|
| 367 | - . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 368 | - . "</a>"; |
|
| 369 | - } else { |
|
| 370 | - $modele = ""; |
|
| 371 | - if (test_espace_prive()) { |
|
| 372 | - $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 373 | - if (!is_null($liens)) { |
|
| 374 | - $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - // le remplacer dans le texte |
|
| 380 | - if ($modele !== false) { |
|
| 381 | - $modele = protege_js_modeles($modele); |
|
| 382 | - if ($wrap_embed_html) { |
|
| 383 | - $modele = $wrap_embed_html($mod, $modele); |
|
| 384 | - } |
|
| 385 | - $rempl = code_echappement($modele, $echap); |
|
| 386 | - $texte = substr($texte, 0, $a) |
|
| 387 | - . $rempl |
|
| 388 | - . substr($texte, $a + $cherche); |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // hack pour tout l'espace prive |
|
| 393 | - if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 394 | - foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) { |
|
| 395 | - if (in_array($type, $modeles)) { |
|
| 396 | - $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - return $texte; |
|
| 306 | + // preserver la compatibilite : true = recherche des documents |
|
| 307 | + if ($doublons === true) { |
|
| 308 | + $doublons = array('documents' => array('doc', 'emb', 'img')); |
|
| 309 | + } |
|
| 310 | + // detecter les modeles (rapide) |
|
| 311 | + if (strpos($texte, "<") !== false and |
|
| 312 | + preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 313 | + ) { |
|
| 314 | + include_spip('public/assembler'); |
|
| 315 | + $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true); |
|
| 316 | + foreach ($matches as $match) { |
|
| 317 | + // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 318 | + |
|
| 319 | + $a = strpos($texte, $match[0]); |
|
| 320 | + preg_match(_RACCOURCI_MODELE_DEBUT, |
|
| 321 | + substr($texte, $a), $regs); |
|
| 322 | + $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 323 | + list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 324 | + if ($fin and |
|
| 325 | + preg_match('/<a\s[^<>]*>\s*$/i', |
|
| 326 | + substr($texte, 0, $a), $r) |
|
| 327 | + ) { |
|
| 328 | + $lien = array( |
|
| 329 | + 'href' => extraire_attribut($r[0], 'href'), |
|
| 330 | + 'class' => extraire_attribut($r[0], 'class'), |
|
| 331 | + 'mime' => extraire_attribut($r[0], 'type'), |
|
| 332 | + 'title' => extraire_attribut($r[0], 'title'), |
|
| 333 | + 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 334 | + ); |
|
| 335 | + $n = strlen($r[0]); |
|
| 336 | + $a -= $n; |
|
| 337 | + $cherche = $n + strlen($regs[0]); |
|
| 338 | + } else { |
|
| 339 | + $lien = false; |
|
| 340 | + $cherche = strlen($mod); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + // calculer le modele |
|
| 344 | + # hack indexation |
|
| 345 | + if ($doublons) { |
|
| 346 | + $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 347 | + } # version normale |
|
| 348 | + else { |
|
| 349 | + // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 350 | + // dans les parametres, plutot que les liens echappes |
|
| 351 | + if (!is_null($liens)) { |
|
| 352 | + $params = str_replace($liens[0], $liens[1], $params); |
|
| 353 | + } |
|
| 354 | + $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 355 | + // en cas d'echec, |
|
| 356 | + // si l'objet demande a une url, |
|
| 357 | + // creer un petit encadre vers elle |
|
| 358 | + if ($modele === false) { |
|
| 359 | + if (!$lien) { |
|
| 360 | + $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 361 | + } |
|
| 362 | + if ($lien) { |
|
| 363 | + $modele = '<a href="' |
|
| 364 | + . $lien['url'] |
|
| 365 | + . '" class="spip_modele' |
|
| 366 | + . '">' |
|
| 367 | + . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 368 | + . "</a>"; |
|
| 369 | + } else { |
|
| 370 | + $modele = ""; |
|
| 371 | + if (test_espace_prive()) { |
|
| 372 | + $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 373 | + if (!is_null($liens)) { |
|
| 374 | + $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + // le remplacer dans le texte |
|
| 380 | + if ($modele !== false) { |
|
| 381 | + $modele = protege_js_modeles($modele); |
|
| 382 | + if ($wrap_embed_html) { |
|
| 383 | + $modele = $wrap_embed_html($mod, $modele); |
|
| 384 | + } |
|
| 385 | + $rempl = code_echappement($modele, $echap); |
|
| 386 | + $texte = substr($texte, 0, $a) |
|
| 387 | + . $rempl |
|
| 388 | + . substr($texte, $a + $cherche); |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // hack pour tout l'espace prive |
|
| 393 | + if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 394 | + foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) { |
|
| 395 | + if (in_array($type, $modeles)) { |
|
| 396 | + $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + return $texte; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | // |
| 409 | 409 | // https://code.spip.net/@traiter_raccourci_ancre |
| 410 | 410 | function traiter_raccourci_ancre($letexte) { |
| 411 | - return $letexte; |
|
| 411 | + return $letexte; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // https://code.spip.net/@traiter_raccourci_glossaire |
| 415 | 415 | function traiter_raccourci_glossaire($texte) { |
| 416 | - return $texte; |
|
| 416 | + return $texte; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // https://code.spip.net/@glossaire_std |
| 420 | 420 | function glossaire_std($terme) { |
| 421 | - return $terme; |
|
| 421 | + return $terme; |
|
| 422 | 422 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
|
| 105 | +define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS'); |
|
| 106 | 106 | |
| 107 | 107 | // https://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $lien_court = charger_fonction('lien_court', 'inc'); |
| 120 | 120 | $texte = $lien_court($texte); |
| 121 | 121 | if ($echappe_typo) { |
| 122 | - $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 122 | + $texte = "<html>".quote_amp($texte)."</html>"; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // petites corrections d'URL |
| 127 | 127 | if (preg_match('/^www\.[^@]+$/S', $lien)) { |
| 128 | - $lien = "http://" . $lien; |
|
| 128 | + $lien = "http://".$lien; |
|
| 129 | 129 | } else { |
| 130 | 130 | if (strpos($lien, "@") && email_valide($lien)) { |
| 131 | 131 | if (!$texte) { |
| 132 | 132 | $texte = $lien; |
| 133 | 133 | } |
| 134 | - $lien = "mailto:" . $lien; |
|
| 134 | + $lien = "mailto:".$lien; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 150 | + if (function_exists($f = 'glossaire_'.$ancre)) { |
|
| 151 | 151 | $url = $f($texte, $id); |
| 152 | 152 | } else { |
| 153 | 153 | $url = glossaire_std($texte); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | if (!($match = typer_raccourci($ref))) { |
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 164 | + @list($type,, $id,, $args,, $ancre) = $match; |
|
| 165 | 165 | // attention dans le cas des sites le lien doit pointer non pas sur |
| 166 | 166 | // la page locale du site, mais directement sur le site lui-meme |
| 167 | 167 | if ($f = charger_fonction("implicite_$type", "liens", true)) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $r['titre'] = $texte; |
| 189 | 189 | } |
| 190 | 190 | if (!@$r['titre']) { |
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 191 | + $r['titre'] = _T($type)." $id"; |
|
| 192 | 192 | } |
| 193 | 193 | if ($pour == 'titre') { |
| 194 | 194 | return $r['titre']; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
| 199 | 199 | if ($type == 'document' |
| 200 | 200 | and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
| 201 | - "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 201 | + "extension IN (".sql_get_select("extension", "spip_documents", "id_document=".sql_quote($id)).")", |
|
| 202 | 202 | '', '', '', '', $connect) |
| 203 | 203 | ) { |
| 204 | 204 | $r['mime'] = $mime; |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | '(<([a-z_-]{3,})' # <modele |
| 296 | 296 | . '\s*([0-9]*)\s*' # id |
| 297 | 297 | . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
| 298 | - . '\s*/?' . '>)' # fin du modele > |
|
| 298 | + . '\s*/?'.'>)' # fin du modele > |
|
| 299 | 299 | . '\s*(<\/a>)?' # eventuel </a> |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | -define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
|
| 302 | +define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS'); |
|
| 303 | 303 | |
| 304 | 304 | // https://code.spip.net/@traiter_modeles |
| 305 | 305 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if (test_espace_prive()) { |
| 372 | 372 | $modele = entites_html(substr($texte, $a, $cherche)); |
| 373 | 373 | if (!is_null($liens)) { |
| 374 | - $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 374 | + $modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>"; |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Affichage |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return string Code HTML |
| 46 | 46 | */ |
| 47 | 47 | function debut_gauche() { |
| 48 | - return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 48 | + return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | * @return string Code HTML |
| 62 | 62 | */ |
| 63 | 63 | function creer_colonne_droite() { |
| 64 | - static $deja_colonne_droite; |
|
| 65 | - if ($deja_colonne_droite) { |
|
| 66 | - return ''; |
|
| 67 | - } |
|
| 68 | - $deja_colonne_droite = true; |
|
| 64 | + static $deja_colonne_droite; |
|
| 65 | + if ($deja_colonne_droite) { |
|
| 66 | + return ''; |
|
| 67 | + } |
|
| 68 | + $deja_colonne_droite = true; |
|
| 69 | 69 | |
| 70 | - return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 70 | + return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | * @return string Code HTML |
| 77 | 77 | */ |
| 78 | 78 | function debut_droite() { |
| 79 | - return liste_objets_bloques(_request('exec')) |
|
| 80 | - . creer_colonne_droite() |
|
| 81 | - . "</div>" |
|
| 82 | - . "\n<div id='contenu'>"; |
|
| 79 | + return liste_objets_bloques(_request('exec')) |
|
| 80 | + . creer_colonne_droite() |
|
| 81 | + . "</div>" |
|
| 82 | + . "\n<div id='contenu'>"; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -101,30 +101,30 @@ discard block |
||
| 101 | 101 | * Code HTML |
| 102 | 102 | **/ |
| 103 | 103 | function liste_objets_bloques($exec, $contexte = array(), $auteur = null) { |
| 104 | - $res = ''; |
|
| 105 | - if ($GLOBALS['meta']["articles_modif"] != "non") { |
|
| 106 | - include_spip('inc/drapeau_edition'); |
|
| 107 | - if (is_null($auteur)) { |
|
| 108 | - $auteur = $GLOBALS['visiteur_session']; |
|
| 109 | - } |
|
| 110 | - if ($en_cours = trouver_objet_exec($exec) |
|
| 111 | - and $en_cours['edition'] |
|
| 112 | - and $type = $en_cours['type'] |
|
| 113 | - and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']]) |
|
| 114 | - or $id = _request($en_cours['id_table_objet'])) |
|
| 115 | - ) { |
|
| 116 | - // marquer le fait que l'objet est ouvert en edition par toto |
|
| 117 | - // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 118 | - signale_edition($id, $auteur, $type); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 122 | - if (count($objets_ouverts)) { |
|
| 123 | - $res .= recuperer_fond('prive/objets/liste/objets-en-edition', array(), array('ajax' => true)); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - return $res; |
|
| 104 | + $res = ''; |
|
| 105 | + if ($GLOBALS['meta']["articles_modif"] != "non") { |
|
| 106 | + include_spip('inc/drapeau_edition'); |
|
| 107 | + if (is_null($auteur)) { |
|
| 108 | + $auteur = $GLOBALS['visiteur_session']; |
|
| 109 | + } |
|
| 110 | + if ($en_cours = trouver_objet_exec($exec) |
|
| 111 | + and $en_cours['edition'] |
|
| 112 | + and $type = $en_cours['type'] |
|
| 113 | + and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']]) |
|
| 114 | + or $id = _request($en_cours['id_table_objet'])) |
|
| 115 | + ) { |
|
| 116 | + // marquer le fait que l'objet est ouvert en edition par toto |
|
| 117 | + // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 118 | + signale_edition($id, $auteur, $type); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 122 | + if (count($objets_ouverts)) { |
|
| 123 | + $res .= recuperer_fond('prive/objets/liste/objets-en-edition', array(), array('ajax' => true)); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + return $res; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
@@ -138,20 +138,20 @@ discard block |
||
| 138 | 138 | * @return string Code HTML |
| 139 | 139 | **/ |
| 140 | 140 | function fin_page() { |
| 141 | - include_spip('inc/pipelines'); |
|
| 142 | - // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 143 | - $debug = ((_request('exec') !== 'valider_xml') |
|
| 144 | - and ((_request('var_mode') == 'debug') |
|
| 145 | - or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps']) |
|
| 146 | - and isset($_COOKIE['spip_admin']))); |
|
| 147 | - $t = '</div><div id="pied"><div class="largeur">' |
|
| 148 | - . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 149 | - . "</div>" |
|
| 150 | - . "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 151 | - . ($debug ? erreur_squelette() : '') |
|
| 152 | - . "</body></html>\n"; |
|
| 153 | - |
|
| 154 | - return f_queue($t); |
|
| 141 | + include_spip('inc/pipelines'); |
|
| 142 | + // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 143 | + $debug = ((_request('exec') !== 'valider_xml') |
|
| 144 | + and ((_request('var_mode') == 'debug') |
|
| 145 | + or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps']) |
|
| 146 | + and isset($_COOKIE['spip_admin']))); |
|
| 147 | + $t = '</div><div id="pied"><div class="largeur">' |
|
| 148 | + . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 149 | + . "</div>" |
|
| 150 | + . "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 151 | + . ($debug ? erreur_squelette() : '') |
|
| 152 | + . "</body></html>\n"; |
|
| 153 | + |
|
| 154 | + return f_queue($t); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -166,20 +166,20 @@ discard block |
||
| 166 | 166 | * @return string Code HTML |
| 167 | 167 | **/ |
| 168 | 168 | function html_tests_js() { |
| 169 | - if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) { |
|
| 170 | - // pour le pied de page (deja defini si on est validation XML) |
|
| 171 | - define('_TESTER_NOSCRIPT', |
|
| 172 | - "<noscript>\n<div style='display:none;'><img src='" |
|
| 173 | - . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 174 | - . "' width='1' height='1' alt='' /></div></noscript>\n"); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $rejouer = ''; |
|
| 178 | - if (defined('_SESSION_REJOUER')) { |
|
| 179 | - $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 169 | + if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) { |
|
| 170 | + // pour le pied de page (deja defini si on est validation XML) |
|
| 171 | + define('_TESTER_NOSCRIPT', |
|
| 172 | + "<noscript>\n<div style='display:none;'><img src='" |
|
| 173 | + . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 174 | + . "' width='1' height='1' alt='' /></div></noscript>\n"); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $rejouer = ''; |
|
| 178 | + if (defined('_SESSION_REJOUER')) { |
|
| 179 | + $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -189,25 +189,25 @@ discard block |
||
| 189 | 189 | **/ |
| 190 | 190 | function info_maj_spip() { |
| 191 | 191 | |
| 192 | - $maj = isset($GLOBALS['meta']['info_maj_spip']) ? $GLOBALS['meta']['info_maj_spip'] : null; |
|
| 193 | - if (!$maj) { |
|
| 194 | - return ""; |
|
| 195 | - } |
|
| 192 | + $maj = isset($GLOBALS['meta']['info_maj_spip']) ? $GLOBALS['meta']['info_maj_spip'] : null; |
|
| 193 | + if (!$maj) { |
|
| 194 | + return ""; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $maj = explode('|', $maj); |
|
| 198 | - // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 199 | - if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 200 | - return ""; |
|
| 201 | - } |
|
| 197 | + $maj = explode('|', $maj); |
|
| 198 | + // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 199 | + if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 200 | + return ""; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - if (!autoriser('webmestre')) { |
|
| 204 | - return ""; |
|
| 205 | - } |
|
| 203 | + if (!autoriser('webmestre')) { |
|
| 204 | + return ""; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - array_shift($maj); |
|
| 208 | - $maj = implode('|', $maj); |
|
| 207 | + array_shift($maj); |
|
| 208 | + $maj = implode('|', $maj); |
|
| 209 | 209 | |
| 210 | - return "$maj<br />"; |
|
| 210 | + return "$maj<br />"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -218,43 +218,43 @@ discard block |
||
| 218 | 218 | **/ |
| 219 | 219 | function info_copyright() { |
| 220 | 220 | |
| 221 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 222 | - |
|
| 223 | - // |
|
| 224 | - // Mention, le cas echeant, de la revision SVN courante |
|
| 225 | - // |
|
| 226 | - if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 227 | - if ($vcs['vcs'] === 'GIT') { |
|
| 228 | - $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 229 | - } elseif ($vcs['vcs'] === 'SVN') { |
|
| 230 | - $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 231 | - } else { |
|
| 232 | - $url = ''; |
|
| 233 | - } |
|
| 234 | - // affichage "GIT [master: abcdef]" |
|
| 235 | - $commit = isset($vcs['commit_short']) ? $vcs['commit_short'] : $vcs['commit']; |
|
| 236 | - if ($url) { |
|
| 237 | - $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 238 | - } |
|
| 239 | - if ($vcs['branch']) { |
|
| 240 | - $commit = $vcs['branch'] . ': ' . $commit; |
|
| 241 | - } |
|
| 242 | - $version .= " {$vcs['vcs']} [$commit]"; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - // et la version de l'ecran de securite |
|
| 246 | - $secu = defined('_ECRAN_SECURITE') |
|
| 247 | - ? "<br />" . _T('ecran_securite', array('version' => _ECRAN_SECURITE)) |
|
| 248 | - : ''; |
|
| 249 | - |
|
| 250 | - return _T('info_copyright', |
|
| 251 | - array( |
|
| 252 | - 'spip' => "<b>SPIP $version</b> ", |
|
| 253 | - 'lien_gpl' => |
|
| 254 | - "<a href='" . generer_url_ecrire("aide", |
|
| 255 | - "aide=licence&var_lang=" . $GLOBALS['spip_lang']) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . "</a>" |
|
| 256 | - )) |
|
| 257 | - . $secu; |
|
| 221 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 222 | + |
|
| 223 | + // |
|
| 224 | + // Mention, le cas echeant, de la revision SVN courante |
|
| 225 | + // |
|
| 226 | + if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 227 | + if ($vcs['vcs'] === 'GIT') { |
|
| 228 | + $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 229 | + } elseif ($vcs['vcs'] === 'SVN') { |
|
| 230 | + $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 231 | + } else { |
|
| 232 | + $url = ''; |
|
| 233 | + } |
|
| 234 | + // affichage "GIT [master: abcdef]" |
|
| 235 | + $commit = isset($vcs['commit_short']) ? $vcs['commit_short'] : $vcs['commit']; |
|
| 236 | + if ($url) { |
|
| 237 | + $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 238 | + } |
|
| 239 | + if ($vcs['branch']) { |
|
| 240 | + $commit = $vcs['branch'] . ': ' . $commit; |
|
| 241 | + } |
|
| 242 | + $version .= " {$vcs['vcs']} [$commit]"; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + // et la version de l'ecran de securite |
|
| 246 | + $secu = defined('_ECRAN_SECURITE') |
|
| 247 | + ? "<br />" . _T('ecran_securite', array('version' => _ECRAN_SECURITE)) |
|
| 248 | + : ''; |
|
| 249 | + |
|
| 250 | + return _T('info_copyright', |
|
| 251 | + array( |
|
| 252 | + 'spip' => "<b>SPIP $version</b> ", |
|
| 253 | + 'lien_gpl' => |
|
| 254 | + "<a href='" . generer_url_ecrire("aide", |
|
| 255 | + "aide=licence&var_lang=" . $GLOBALS['spip_lang']) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . "</a>" |
|
| 256 | + )) |
|
| 257 | + . $secu; |
|
| 258 | 258 | |
| 259 | 259 | } |
| 260 | 260 | |
@@ -270,17 +270,17 @@ discard block |
||
| 270 | 270 | * @return string Code HTML |
| 271 | 271 | **/ |
| 272 | 272 | function formulaire_recherche($page, $complement = "") { |
| 273 | - $recherche = _request('recherche'); |
|
| 274 | - $recherche_aff = entites_html($recherche); |
|
| 275 | - if (!strlen($recherche)) { |
|
| 276 | - $recherche_aff = _T('info_rechercher'); |
|
| 277 | - $onfocus = " onfocus=\"this.value='';\""; |
|
| 278 | - } else { |
|
| 279 | - $onfocus = ''; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 283 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 284 | - |
|
| 285 | - return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . "</div>"; |
|
| 273 | + $recherche = _request('recherche'); |
|
| 274 | + $recherche_aff = entites_html($recherche); |
|
| 275 | + if (!strlen($recherche)) { |
|
| 276 | + $recherche_aff = _T('info_rechercher'); |
|
| 277 | + $onfocus = " onfocus=\"this.value='';\""; |
|
| 278 | + } else { |
|
| 279 | + $onfocus = ''; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 283 | + $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 284 | + |
|
| 285 | + return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . "</div>"; |
|
| 286 | 286 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 182 | + return $rejouer.(defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | // |
| 226 | 226 | if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
| 227 | 227 | if ($vcs['vcs'] === 'GIT') { |
| 228 | - $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 228 | + $url = 'https://git.spip.net/spip/spip/commit/'.$vcs['commit']; |
|
| 229 | 229 | } elseif ($vcs['vcs'] === 'SVN') { |
| 230 | - $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 230 | + $url = 'https://core.spip.net/projects/spip/repository/revisions/'.$vcs['commit']; |
|
| 231 | 231 | } else { |
| 232 | 232 | $url = ''; |
| 233 | 233 | } |
@@ -237,22 +237,22 @@ discard block |
||
| 237 | 237 | $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
| 238 | 238 | } |
| 239 | 239 | if ($vcs['branch']) { |
| 240 | - $commit = $vcs['branch'] . ': ' . $commit; |
|
| 240 | + $commit = $vcs['branch'].': '.$commit; |
|
| 241 | 241 | } |
| 242 | 242 | $version .= " {$vcs['vcs']} [$commit]"; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // et la version de l'ecran de securite |
| 246 | 246 | $secu = defined('_ECRAN_SECURITE') |
| 247 | - ? "<br />" . _T('ecran_securite', array('version' => _ECRAN_SECURITE)) |
|
| 247 | + ? "<br />"._T('ecran_securite', array('version' => _ECRAN_SECURITE)) |
|
| 248 | 248 | : ''; |
| 249 | 249 | |
| 250 | 250 | return _T('info_copyright', |
| 251 | 251 | array( |
| 252 | 252 | 'spip' => "<b>SPIP $version</b> ", |
| 253 | 253 | 'lien_gpl' => |
| 254 | - "<a href='" . generer_url_ecrire("aide", |
|
| 255 | - "aide=licence&var_lang=" . $GLOBALS['spip_lang']) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . "</a>" |
|
| 254 | + "<a href='".generer_url_ecrire("aide", |
|
| 255 | + "aide=licence&var_lang=".$GLOBALS['spip_lang'])."' class=\"aide popin\">"._T('info_copyright_gpl')."</a>" |
|
| 256 | 256 | )) |
| 257 | 257 | . $secu; |
| 258 | 258 | |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | $onfocus = ''; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 283 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 282 | + $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"'.$onfocus.' />'; |
|
| 283 | + $form .= "<input type='image' src='".chemin_image('rechercher-20.png')."' name='submit' class='submit' alt='"._T('info_rechercher')."' />"; |
|
| 284 | 284 | |
| 285 | - return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . "</div>"; |
|
| 285 | + return "<div class='spip_recherche'>".generer_form_ecrire($page, $form.$complement, " method='get'")."</div>"; |
|
| 286 | 286 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -26,41 +26,41 @@ discard block |
||
| 26 | 26 | * @return string Code HTML du cadre dépliable |
| 27 | 27 | **/ |
| 28 | 28 | function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') { |
| 29 | - $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 30 | - |
|
| 31 | - return |
|
| 32 | - debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 33 | - . debut_block_depliable($deplie, $ids) |
|
| 34 | - . "<div class='cadre_padding'>\n" |
|
| 35 | - . $contenu |
|
| 36 | - . "</div>\n" |
|
| 37 | - . fin_block() |
|
| 38 | - . fin_cadre(); |
|
| 29 | + $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 30 | + |
|
| 31 | + return |
|
| 32 | + debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 33 | + . debut_block_depliable($deplie, $ids) |
|
| 34 | + . "<div class='cadre_padding'>\n" |
|
| 35 | + . $contenu |
|
| 36 | + . "</div>\n" |
|
| 37 | + . fin_block() |
|
| 38 | + . fin_cadre(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // https://code.spip.net/@block_parfois_visible |
| 42 | 42 | function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) { |
| 43 | - return "\n" |
|
| 44 | - . bouton_block_depliable($invite, $visible, $nom) |
|
| 45 | - . debut_block_depliable($visible, $nom) |
|
| 46 | - . $masque |
|
| 47 | - . fin_block(); |
|
| 43 | + return "\n" |
|
| 44 | + . bouton_block_depliable($invite, $visible, $nom) |
|
| 45 | + . debut_block_depliable($visible, $nom) |
|
| 46 | + . $masque |
|
| 47 | + . fin_block(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // https://code.spip.net/@debut_block_depliable |
| 51 | 51 | function debut_block_depliable($deplie, $id = "") { |
| 52 | - $class = ' blocdeplie'; |
|
| 53 | - // si on n'accepte pas js, ne pas fermer |
|
| 54 | - if (!$deplie) { |
|
| 55 | - $class = " blocreplie"; |
|
| 56 | - } |
|
| 52 | + $class = ' blocdeplie'; |
|
| 53 | + // si on n'accepte pas js, ne pas fermer |
|
| 54 | + if (!$deplie) { |
|
| 55 | + $class = " blocreplie"; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>"; |
|
| 58 | + return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // https://code.spip.net/@fin_block |
| 62 | 62 | function fin_block() { |
| 63 | - return "<div class='nettoyeur'></div>\n</div>"; |
|
| 63 | + return "<div class='nettoyeur'></div>\n</div>"; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // $texte : texte du bouton |
@@ -68,32 +68,32 @@ discard block |
||
| 68 | 68 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 69 | 69 | // https://code.spip.net/@bouton_block_depliable |
| 70 | 70 | function bouton_block_depliable($texte, $deplie, $ids = "") { |
| 71 | - $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 72 | - |
|
| 73 | - $class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie"); |
|
| 74 | - if (strlen($ids)) { |
|
| 75 | - $cible = explode(',', $ids); |
|
| 76 | - $cible = '#' . implode(",#", $cible); |
|
| 77 | - } else { |
|
| 78 | - $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - $b = (strpos($texte, "<h") === false ? 'h3' : 'div'); |
|
| 82 | - |
|
| 83 | - return "<$b " |
|
| 84 | - . ($bouton_id ? "id='$bouton_id' " : "") |
|
| 85 | - . "class='titrem$class'" |
|
| 86 | - . (($deplie === -1) |
|
| 87 | - ? "" |
|
| 88 | - : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 89 | - ) |
|
| 90 | - . ">" |
|
| 91 | - // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 92 | - . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 93 | - . "$texte</$b>" |
|
| 94 | - . http_script(($deplie === 'incertain') |
|
| 95 | - ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 96 | - : ''); |
|
| 71 | + $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 72 | + |
|
| 73 | + $class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie"); |
|
| 74 | + if (strlen($ids)) { |
|
| 75 | + $cible = explode(',', $ids); |
|
| 76 | + $cible = '#' . implode(",#", $cible); |
|
| 77 | + } else { |
|
| 78 | + $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + $b = (strpos($texte, "<h") === false ? 'h3' : 'div'); |
|
| 82 | + |
|
| 83 | + return "<$b " |
|
| 84 | + . ($bouton_id ? "id='$bouton_id' " : "") |
|
| 85 | + . "class='titrem$class'" |
|
| 86 | + . (($deplie === -1) |
|
| 87 | + ? "" |
|
| 88 | + : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 89 | + ) |
|
| 90 | + . ">" |
|
| 91 | + // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 92 | + . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 93 | + . "$texte</$b>" |
|
| 94 | + . http_script(($deplie === 'incertain') |
|
| 95 | + ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 96 | + : ''); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // |
@@ -102,62 +102,62 @@ discard block |
||
| 102 | 102 | // https://code.spip.net/@verif_butineur |
| 103 | 103 | function verif_butineur() { |
| 104 | 104 | |
| 105 | - preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 106 | - $GLOBALS['browser_name'] = $match[1]; |
|
| 107 | - $GLOBALS['browser_version'] = $match[2]; |
|
| 108 | - $GLOBALS['browser_description'] = $match[3]; |
|
| 109 | - $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 110 | - $GLOBALS['browser_barre'] = ''; |
|
| 111 | - |
|
| 112 | - if (!preg_match(",opera,i", $GLOBALS['browser_description']) && preg_match(",opera,i", $GLOBALS['browser_name'])) { |
|
| 113 | - $GLOBALS['browser_name'] = "Opera"; |
|
| 114 | - $GLOBALS['browser_version'] = $match[2]; |
|
| 115 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 116 | - } else { |
|
| 117 | - if (preg_match(",opera,i", $GLOBALS['browser_description'])) { |
|
| 118 | - preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match); |
|
| 119 | - $GLOBALS['browser_name'] = "Opera"; |
|
| 120 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 121 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 122 | - } else { |
|
| 123 | - if (preg_match(",msie,i", $GLOBALS['browser_description'])) { |
|
| 124 | - preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match); |
|
| 125 | - $GLOBALS['browser_name'] = "MSIE"; |
|
| 126 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 127 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); |
|
| 128 | - } else { |
|
| 129 | - if (preg_match(",KHTML,i", $GLOBALS['browser_description']) && |
|
| 130 | - preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match) |
|
| 131 | - ) { |
|
| 132 | - $GLOBALS['browser_name'] = "Safari"; |
|
| 133 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 134 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); |
|
| 135 | - } else { |
|
| 136 | - if (preg_match(",mozilla,i", $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) { |
|
| 137 | - // Numero de version pour Mozilla "authentique" |
|
| 138 | - if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) { |
|
| 139 | - $GLOBALS['browser_rev'] = doubleval($match[1]); |
|
| 140 | - } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 141 | - else { |
|
| 142 | - if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'], |
|
| 143 | - "KHTML") |
|
| 144 | - ) { |
|
| 145 | - $GLOBALS['browser_rev'] = 1.4; |
|
| 146 | - } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 147 | - else { |
|
| 148 | - $GLOBALS['browser_rev'] = 1.0; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - if (!$GLOBALS['browser_name']) { |
|
| 159 | - $GLOBALS['browser_name'] = "Mozilla"; |
|
| 160 | - } |
|
| 105 | + preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 106 | + $GLOBALS['browser_name'] = $match[1]; |
|
| 107 | + $GLOBALS['browser_version'] = $match[2]; |
|
| 108 | + $GLOBALS['browser_description'] = $match[3]; |
|
| 109 | + $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 110 | + $GLOBALS['browser_barre'] = ''; |
|
| 111 | + |
|
| 112 | + if (!preg_match(",opera,i", $GLOBALS['browser_description']) && preg_match(",opera,i", $GLOBALS['browser_name'])) { |
|
| 113 | + $GLOBALS['browser_name'] = "Opera"; |
|
| 114 | + $GLOBALS['browser_version'] = $match[2]; |
|
| 115 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 116 | + } else { |
|
| 117 | + if (preg_match(",opera,i", $GLOBALS['browser_description'])) { |
|
| 118 | + preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match); |
|
| 119 | + $GLOBALS['browser_name'] = "Opera"; |
|
| 120 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 121 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 122 | + } else { |
|
| 123 | + if (preg_match(",msie,i", $GLOBALS['browser_description'])) { |
|
| 124 | + preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match); |
|
| 125 | + $GLOBALS['browser_name'] = "MSIE"; |
|
| 126 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 127 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); |
|
| 128 | + } else { |
|
| 129 | + if (preg_match(",KHTML,i", $GLOBALS['browser_description']) && |
|
| 130 | + preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match) |
|
| 131 | + ) { |
|
| 132 | + $GLOBALS['browser_name'] = "Safari"; |
|
| 133 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 134 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); |
|
| 135 | + } else { |
|
| 136 | + if (preg_match(",mozilla,i", $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) { |
|
| 137 | + // Numero de version pour Mozilla "authentique" |
|
| 138 | + if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) { |
|
| 139 | + $GLOBALS['browser_rev'] = doubleval($match[1]); |
|
| 140 | + } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 141 | + else { |
|
| 142 | + if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'], |
|
| 143 | + "KHTML") |
|
| 144 | + ) { |
|
| 145 | + $GLOBALS['browser_rev'] = 1.4; |
|
| 146 | + } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 147 | + else { |
|
| 148 | + $GLOBALS['browser_rev'] = 1.0; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + if (!$GLOBALS['browser_name']) { |
|
| 159 | + $GLOBALS['browser_name'] = "Mozilla"; |
|
| 160 | + } |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | verif_butineur(); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $class = " blocreplie"; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>"; |
|
| 58 | + return "<div ".($id ? "id='$id' " : "")."class='bloc_depliable$class'>"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // https://code.spip.net/@fin_block |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 69 | 69 | // https://code.spip.net/@bouton_block_depliable |
| 70 | 70 | function bouton_block_depliable($texte, $deplie, $ids = "") { |
| 71 | - $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 71 | + $bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8); |
|
| 72 | 72 | |
| 73 | 73 | $class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie"); |
| 74 | 74 | if (strlen($ids)) { |
| 75 | 75 | $cible = explode(',', $ids); |
| 76 | - $cible = '#' . implode(",#", $cible); |
|
| 76 | + $cible = '#'.implode(",#", $cible); |
|
| 77 | 77 | } else { |
| 78 | 78 | $cible = "#$bouton_id + div.bloc_depliable"; |
| 79 | 79 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | **/ |
| 45 | 45 | function install_fichier_connexion($nom, $texte) { |
| 46 | - $texte = "<" . "?php\n" |
|
| 47 | - . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | - . $texte |
|
| 49 | - . "?" . ">"; |
|
| 46 | + $texte = "<" . "?php\n" |
|
| 47 | + . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | + . $texte |
|
| 49 | + . "?" . ">"; |
|
| 50 | 50 | |
| 51 | - ecrire_fichier($nom, $texte); |
|
| 51 | + ecrire_fichier($nom, $texte); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -77,20 +77,20 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | **/ |
| 79 | 79 | function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') { |
| 80 | - $adr = addcslashes($adr, "'\\"); |
|
| 81 | - $port = addcslashes($port, "'\\"); |
|
| 82 | - $login = addcslashes($login, "'\\"); |
|
| 83 | - $pass = addcslashes($pass, "'\\"); |
|
| 84 | - $base = addcslashes($base, "'\\"); |
|
| 85 | - $type = addcslashes($type, "'\\"); |
|
| 86 | - $pref = addcslashes($pref, "'\\"); |
|
| 87 | - $ldap = addcslashes($ldap, "'\\"); |
|
| 88 | - $charset = addcslashes($charset, "'\\"); |
|
| 89 | - |
|
| 90 | - return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 91 | - . "spip_connect_db(" |
|
| 92 | - . "'$adr','$port','$login','$pass','$base'" |
|
| 93 | - . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 80 | + $adr = addcslashes($adr, "'\\"); |
|
| 81 | + $port = addcslashes($port, "'\\"); |
|
| 82 | + $login = addcslashes($login, "'\\"); |
|
| 83 | + $pass = addcslashes($pass, "'\\"); |
|
| 84 | + $base = addcslashes($base, "'\\"); |
|
| 85 | + $type = addcslashes($type, "'\\"); |
|
| 86 | + $pref = addcslashes($pref, "'\\"); |
|
| 87 | + $ldap = addcslashes($ldap, "'\\"); |
|
| 88 | + $charset = addcslashes($charset, "'\\"); |
|
| 89 | + |
|
| 90 | + return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 91 | + . "spip_connect_db(" |
|
| 92 | + . "'$adr','$port','$login','$pass','$base'" |
|
| 93 | + . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -106,26 +106,26 @@ discard block |
||
| 106 | 106 | * Tableau des informations sur la connexion |
| 107 | 107 | **/ |
| 108 | 108 | function analyse_fichier_connection($file) { |
| 109 | - $s = @join('', file($file)); |
|
| 110 | - if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 111 | - array_shift($regs); |
|
| 112 | - |
|
| 113 | - return $regs; |
|
| 114 | - } else { |
|
| 115 | - $ar = '\s*\'([^\']*)\''; |
|
| 116 | - $r = '\s*,' . $ar; |
|
| 117 | - $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 118 | - if (preg_match($r, $s, $regs)) { |
|
| 119 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";"); |
|
| 120 | - array_shift($regs); |
|
| 121 | - array_shift($regs); |
|
| 122 | - |
|
| 123 | - return $regs; |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - spip_log("$file n'est pas un fichier de connexion"); |
|
| 127 | - |
|
| 128 | - return array(); |
|
| 109 | + $s = @join('', file($file)); |
|
| 110 | + if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 111 | + array_shift($regs); |
|
| 112 | + |
|
| 113 | + return $regs; |
|
| 114 | + } else { |
|
| 115 | + $ar = '\s*\'([^\']*)\''; |
|
| 116 | + $r = '\s*,' . $ar; |
|
| 117 | + $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 118 | + if (preg_match($r, $s, $regs)) { |
|
| 119 | + $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";"); |
|
| 120 | + array_shift($regs); |
|
| 121 | + array_shift($regs); |
|
| 122 | + |
|
| 123 | + return $regs; |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + spip_log("$file n'est pas un fichier de connexion"); |
|
| 127 | + |
|
| 128 | + return array(); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -142,21 +142,21 @@ discard block |
||
| 142 | 142 | * Liste des noms de connecteurs |
| 143 | 143 | **/ |
| 144 | 144 | function bases_referencees($exclu = '') { |
| 145 | - $tables = array(); |
|
| 146 | - foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 147 | - if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 148 | - $tables[] = basename($f, '.php'); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $tables; |
|
| 145 | + $tables = array(); |
|
| 146 | + foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 147 | + if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 148 | + $tables[] = basename($f, '.php'); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $tables; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | function install_mode_appel($server_db, $tout = true) { |
| 157 | - return ($server_db != 'mysql') ? '' |
|
| 158 | - : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 159 | - . test_sql_mode_mysql($server_db)); |
|
| 157 | + return ($server_db != 'mysql') ? '' |
|
| 158 | + : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 159 | + . test_sql_mode_mysql($server_db)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // |
@@ -164,52 +164,52 @@ discard block |
||
| 164 | 164 | // (sert a l'etape 1 de l'installation) |
| 165 | 165 | // https://code.spip.net/@tester_compatibilite_hebergement |
| 166 | 166 | function tester_compatibilite_hebergement() { |
| 167 | - $err = array(); |
|
| 168 | - |
|
| 169 | - $p = phpversion(); |
|
| 170 | - if (version_compare($p, _PHP_MIN, '<')) { |
|
| 171 | - $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN)); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 175 | - if ($err) { |
|
| 176 | - die("<div class='error'>" |
|
| 177 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 178 | - . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - // Il faut une base de donnees tout de meme ... |
|
| 182 | - $serveurs = install_select_serveur(); |
|
| 183 | - if (!$serveurs) { |
|
| 184 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 185 | - . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 186 | - . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 187 | - . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // et il faut preg |
|
| 191 | - if (!function_exists('preg_match_all')) { |
|
| 192 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 193 | - . " <a href='http://se.php.net/pcre'>PCRE</a>"; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - // et surtout pas ce mbstring.overload |
|
| 197 | - if ($a = @ini_get('mbstring.func_overload')) { |
|
| 198 | - $err[] = _T('install_extension_mbstring') |
|
| 199 | - . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - if ($err) { |
|
| 203 | - echo "<div class='error'>" |
|
| 204 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 205 | - foreach ($err as $e) { |
|
| 206 | - echo "<li><strong>$e</strong></li>\n"; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 210 | - # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 211 | - echo "</ul></div>\n"; |
|
| 212 | - } |
|
| 167 | + $err = array(); |
|
| 168 | + |
|
| 169 | + $p = phpversion(); |
|
| 170 | + if (version_compare($p, _PHP_MIN, '<')) { |
|
| 171 | + $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN)); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 175 | + if ($err) { |
|
| 176 | + die("<div class='error'>" |
|
| 177 | + . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 178 | + . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + // Il faut une base de donnees tout de meme ... |
|
| 182 | + $serveurs = install_select_serveur(); |
|
| 183 | + if (!$serveurs) { |
|
| 184 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 185 | + . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 186 | + . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 187 | + . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // et il faut preg |
|
| 191 | + if (!function_exists('preg_match_all')) { |
|
| 192 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 193 | + . " <a href='http://se.php.net/pcre'>PCRE</a>"; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + // et surtout pas ce mbstring.overload |
|
| 197 | + if ($a = @ini_get('mbstring.func_overload')) { |
|
| 198 | + $err[] = _T('install_extension_mbstring') |
|
| 199 | + . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + if ($err) { |
|
| 203 | + echo "<div class='error'>" |
|
| 204 | + . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 205 | + foreach ($err as $e) { |
|
| 206 | + echo "<li><strong>$e</strong></li>\n"; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 210 | + # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 211 | + echo "</ul></div>\n"; |
|
| 212 | + } |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -219,24 +219,24 @@ discard block |
||
| 219 | 219 | * @note superflu ?? |
| 220 | 220 | */ |
| 221 | 221 | function login_hebergeur() { |
| 222 | - $base_hebergeur = 'localhost'; # par defaut |
|
| 222 | + $base_hebergeur = 'localhost'; # par defaut |
|
| 223 | 223 | |
| 224 | - // Free |
|
| 225 | - if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 226 | - $base_hebergeur = 'sql.free.fr'; |
|
| 227 | - $login_hebergeur = $regs[1]; |
|
| 228 | - } else { |
|
| 229 | - $login_hebergeur = ''; |
|
| 230 | - } |
|
| 224 | + // Free |
|
| 225 | + if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 226 | + $base_hebergeur = 'sql.free.fr'; |
|
| 227 | + $login_hebergeur = $regs[1]; |
|
| 228 | + } else { |
|
| 229 | + $login_hebergeur = ''; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return array($base_hebergeur, $login_hebergeur); |
|
| 232 | + return array($base_hebergeur, $login_hebergeur); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | // https://code.spip.net/@info_etape |
| 237 | 237 | function info_etape($titre, $complement = '') { |
| 238 | - return "<h2>" . $titre . "</h2>\n" . |
|
| 239 | - ($complement ? "" . $complement . "\n" : ''); |
|
| 238 | + return "<h2>" . $titre . "</h2>\n" . |
|
| 239 | + ($complement ? "" . $complement . "\n" : ''); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -246,155 +246,155 @@ discard block |
||
| 246 | 246 | * @return string Code HTML du bouton |
| 247 | 247 | **/ |
| 248 | 248 | function bouton_suivant($code = '') { |
| 249 | - if ($code == '') { |
|
| 250 | - $code = _T('bouton_suivant'); |
|
| 251 | - } |
|
| 252 | - static $suivant = 0; |
|
| 253 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 254 | - $suivant += 1; |
|
| 255 | - |
|
| 256 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 257 | - $code . |
|
| 258 | - " >>\" /></p>\n"; |
|
| 249 | + if ($code == '') { |
|
| 250 | + $code = _T('bouton_suivant'); |
|
| 251 | + } |
|
| 252 | + static $suivant = 0; |
|
| 253 | + $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 254 | + $suivant += 1; |
|
| 255 | + |
|
| 256 | + return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 257 | + $code . |
|
| 258 | + " >>\" /></p>\n"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // https://code.spip.net/@info_progression_etape |
| 262 | 262 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 263 | - //$en_cours = _request('etape')?_request('etape'):""; |
|
| 264 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 265 | - $debut = 1; |
|
| 266 | - $etat = "ok"; |
|
| 267 | - $last = count($liste); |
|
| 263 | + //$en_cours = _request('etape')?_request('etape'):""; |
|
| 264 | + $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 265 | + $debut = 1; |
|
| 266 | + $etat = "ok"; |
|
| 267 | + $last = count($liste); |
|
| 268 | 268 | // $texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo')); |
| 269 | 269 | |
| 270 | - $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee')); |
|
| 271 | - $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 272 | - $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles')); |
|
| 273 | - $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape')); |
|
| 270 | + $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee')); |
|
| 271 | + $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 272 | + $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles')); |
|
| 273 | + $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape')); |
|
| 274 | 274 | |
| 275 | - $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap')); |
|
| 276 | - $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap')); |
|
| 277 | - $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1')); |
|
| 278 | - $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap')); |
|
| 279 | - $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok')); |
|
| 275 | + $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap')); |
|
| 276 | + $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap')); |
|
| 277 | + $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1')); |
|
| 278 | + $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap')); |
|
| 279 | + $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok')); |
|
| 280 | 280 | |
| 281 | 281 | // $aff_etapes = "<span id='etapes'>"; |
| 282 | 282 | |
| 283 | - $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 284 | - |
|
| 285 | - foreach ($liste as $etape => $fichier) { |
|
| 286 | - if ($debut < $last) { |
|
| 287 | - if ($debut == $en_cours && $erreur) { |
|
| 288 | - $class = "on erreur"; |
|
| 289 | - } else { |
|
| 290 | - if ($debut == $en_cours) { |
|
| 291 | - $class = "on"; |
|
| 292 | - } else { |
|
| 293 | - if ($debut > $en_cours) { |
|
| 294 | - $class = "prochains"; |
|
| 295 | - } else { |
|
| 296 | - $class = "valides"; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 302 | - $aff_etapes .= ($debut == $en_cours) ? "<strong>" : ''; |
|
| 303 | - $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 304 | - $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 305 | - $aff_etapes .= ($debut == $en_cours) ? "</strong>" : ''; |
|
| 306 | - $aff_etapes .= "</div></li>"; |
|
| 307 | - } |
|
| 308 | - $debut++; |
|
| 309 | - } |
|
| 310 | - $aff_etapes .= "</ul>"; |
|
| 311 | - $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 312 | - |
|
| 313 | - return $aff_etapes; |
|
| 283 | + $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 284 | + |
|
| 285 | + foreach ($liste as $etape => $fichier) { |
|
| 286 | + if ($debut < $last) { |
|
| 287 | + if ($debut == $en_cours && $erreur) { |
|
| 288 | + $class = "on erreur"; |
|
| 289 | + } else { |
|
| 290 | + if ($debut == $en_cours) { |
|
| 291 | + $class = "on"; |
|
| 292 | + } else { |
|
| 293 | + if ($debut > $en_cours) { |
|
| 294 | + $class = "prochains"; |
|
| 295 | + } else { |
|
| 296 | + $class = "valides"; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 302 | + $aff_etapes .= ($debut == $en_cours) ? "<strong>" : ''; |
|
| 303 | + $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 304 | + $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 305 | + $aff_etapes .= ($debut == $en_cours) ? "</strong>" : ''; |
|
| 306 | + $aff_etapes .= "</div></li>"; |
|
| 307 | + } |
|
| 308 | + $debut++; |
|
| 309 | + } |
|
| 310 | + $aff_etapes .= "</ul>"; |
|
| 311 | + $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 312 | + |
|
| 313 | + return $aff_etapes; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
| 317 | 317 | // https://code.spip.net/@fieldset |
| 318 | 318 | function fieldset($legend, $champs = array(), $apres = '', $avant = '') { |
| 319 | - return "<fieldset>\n" . |
|
| 320 | - $avant . |
|
| 321 | - ($legend ? "<legend>" . $legend . "</legend>\n" : '') . |
|
| 322 | - fieldset_champs($champs) . |
|
| 323 | - $apres . |
|
| 324 | - "</fieldset>\n"; |
|
| 319 | + return "<fieldset>\n" . |
|
| 320 | + $avant . |
|
| 321 | + ($legend ? "<legend>" . $legend . "</legend>\n" : '') . |
|
| 322 | + fieldset_champs($champs) . |
|
| 323 | + $apres . |
|
| 324 | + "</fieldset>\n"; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | function fieldset_champs($champs = array()) { |
| 328 | - $fieldset = ''; |
|
| 329 | - foreach ($champs as $nom => $contenu) { |
|
| 330 | - $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 331 | - $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 332 | - if (isset($contenu['alternatives'])) { |
|
| 333 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 334 | - foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 335 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 336 | - "' id='$nom-$valeur' value='$valeur'" |
|
| 337 | - . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 338 | - . "/>\n"; |
|
| 339 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 340 | - } |
|
| 341 | - $fieldset .= "<br />\n"; |
|
| 342 | - } else { |
|
| 343 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 344 | - $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 345 | - . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 346 | - . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "") |
|
| 347 | - . " />\n"; |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - return $fieldset; |
|
| 328 | + $fieldset = ''; |
|
| 329 | + foreach ($champs as $nom => $contenu) { |
|
| 330 | + $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 331 | + $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 332 | + if (isset($contenu['alternatives'])) { |
|
| 333 | + $fieldset .= $contenu['label'] . "\n"; |
|
| 334 | + foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 335 | + $fieldset .= "<input type='radio' name='" . $nom . |
|
| 336 | + "' id='$nom-$valeur' value='$valeur'" |
|
| 337 | + . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 338 | + . "/>\n"; |
|
| 339 | + $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 340 | + } |
|
| 341 | + $fieldset .= "<br />\n"; |
|
| 342 | + } else { |
|
| 343 | + $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 344 | + $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 345 | + . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 346 | + . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "") |
|
| 347 | + . " />\n"; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + return $fieldset; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | function install_select_serveur() { |
| 355 | - $options = array(); |
|
| 356 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 357 | - $d = opendir($dir); |
|
| 358 | - if (!$d) { |
|
| 359 | - return array(); |
|
| 360 | - } |
|
| 361 | - while (($f = readdir($d)) !== false) { |
|
| 362 | - if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 363 | - and is_readable($f = $dir . $f) |
|
| 364 | - ) { |
|
| 365 | - require_once($f); |
|
| 366 | - $s = $s[1]; |
|
| 367 | - $v = 'spip_versions_' . $s; |
|
| 368 | - if (function_exists($v) and $v()) { |
|
| 369 | - $titre = _T("install_select_type_$s"); |
|
| 370 | - // proposer mysql par defaut si dispo |
|
| 371 | - $checked = ($s == 'mysql' ? " checked='checked'" : ""); |
|
| 372 | - $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 373 | - . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>"; |
|
| 374 | - } else { |
|
| 375 | - spip_log("$s: portage indisponible"); |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - sort($options); |
|
| 380 | - |
|
| 381 | - return $options; |
|
| 355 | + $options = array(); |
|
| 356 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 357 | + $d = opendir($dir); |
|
| 358 | + if (!$d) { |
|
| 359 | + return array(); |
|
| 360 | + } |
|
| 361 | + while (($f = readdir($d)) !== false) { |
|
| 362 | + if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 363 | + and is_readable($f = $dir . $f) |
|
| 364 | + ) { |
|
| 365 | + require_once($f); |
|
| 366 | + $s = $s[1]; |
|
| 367 | + $v = 'spip_versions_' . $s; |
|
| 368 | + if (function_exists($v) and $v()) { |
|
| 369 | + $titre = _T("install_select_type_$s"); |
|
| 370 | + // proposer mysql par defaut si dispo |
|
| 371 | + $checked = ($s == 'mysql' ? " checked='checked'" : ""); |
|
| 372 | + $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 373 | + . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>"; |
|
| 374 | + } else { |
|
| 375 | + spip_log("$s: portage indisponible"); |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + sort($options); |
|
| 380 | + |
|
| 381 | + return $options; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // https://code.spip.net/@install_connexion_form |
| 385 | 385 | function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) { |
| 386 | - $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 387 | - |
|
| 388 | - return generer_form_ecrire('install', ( |
|
| 389 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 390 | - . $hidden |
|
| 391 | - . (_request('echec') ? |
|
| 392 | - ("<p><b>" . _T('avis_connexion_echec_1') . |
|
| 393 | - "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>") |
|
| 394 | - : "") |
|
| 395 | - |
|
| 396 | - . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 397 | - . http_script(' |
|
| 386 | + $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 387 | + |
|
| 388 | + return generer_form_ecrire('install', ( |
|
| 389 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 390 | + . $hidden |
|
| 391 | + . (_request('echec') ? |
|
| 392 | + ("<p><b>" . _T('avis_connexion_echec_1') . |
|
| 393 | + "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>") |
|
| 394 | + : "") |
|
| 395 | + |
|
| 396 | + . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 397 | + . http_script(' |
|
| 398 | 398 | jQuery(function($) { |
| 399 | 399 | $details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur"); |
| 400 | 400 | $("input[type=hidden][name=server_db]").each(function(){ |
@@ -427,67 +427,67 @@ discard block |
||
| 427 | 427 | }); |
| 428 | 428 | });') |
| 429 | 429 | |
| 430 | - . ($server_db |
|
| 431 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 432 | - . (($predef[0]) |
|
| 433 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 434 | - : '') |
|
| 435 | - : ('<fieldset><legend>' |
|
| 436 | - . _T('install_select_type_db') |
|
| 437 | - . "</legend>" |
|
| 438 | - . '<p class="explication">' |
|
| 439 | - . _T('install_types_db_connus') |
|
| 440 | - // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 441 | - // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 442 | - . '</p>' |
|
| 443 | - . "\n<div class='p'>\n<ul>\n" |
|
| 444 | - . join("\n", install_select_serveur()) |
|
| 445 | - . "\n</ul>\n</div></fieldset>") |
|
| 446 | - ) |
|
| 447 | - . '<div id="install_adresse_base_hebergeur">' |
|
| 448 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 449 | - . ($predef[1] |
|
| 450 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 451 | - : fieldset(_T('entree_base_donnee_1'), |
|
| 452 | - array( |
|
| 453 | - 'adresse_db' => array( |
|
| 454 | - 'label' => $db[1], |
|
| 455 | - 'valeur' => $db[0] |
|
| 456 | - ), |
|
| 457 | - ) |
|
| 458 | - ) |
|
| 459 | - ) |
|
| 460 | - . '</div>' |
|
| 461 | - |
|
| 462 | - . '<div id="install_login_base_hebergeur">' |
|
| 463 | - . ($predef[2] |
|
| 464 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 465 | - : fieldset(_T('entree_login_connexion_1'), |
|
| 466 | - array( |
|
| 467 | - 'login_db' => array( |
|
| 468 | - 'label' => $login[1], |
|
| 469 | - 'valeur' => $login[0] |
|
| 470 | - ), |
|
| 471 | - ) |
|
| 472 | - ) |
|
| 473 | - ) |
|
| 474 | - . '</div>' |
|
| 475 | - |
|
| 476 | - . '<div id="install_pass_base_hebergeur">' |
|
| 477 | - . ($predef[3] |
|
| 478 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 479 | - : fieldset(_T('entree_mot_passe_1'), |
|
| 480 | - array( |
|
| 481 | - 'pass_db' => array( |
|
| 482 | - 'label' => $pass[1], |
|
| 483 | - 'valeur' => $pass[0] |
|
| 484 | - ), |
|
| 485 | - ) |
|
| 486 | - ) |
|
| 487 | - ) |
|
| 488 | - . '</div>' |
|
| 489 | - |
|
| 490 | - . bouton_suivant())); |
|
| 430 | + . ($server_db |
|
| 431 | + ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 432 | + . (($predef[0]) |
|
| 433 | + ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 434 | + : '') |
|
| 435 | + : ('<fieldset><legend>' |
|
| 436 | + . _T('install_select_type_db') |
|
| 437 | + . "</legend>" |
|
| 438 | + . '<p class="explication">' |
|
| 439 | + . _T('install_types_db_connus') |
|
| 440 | + // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 441 | + // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 442 | + . '</p>' |
|
| 443 | + . "\n<div class='p'>\n<ul>\n" |
|
| 444 | + . join("\n", install_select_serveur()) |
|
| 445 | + . "\n</ul>\n</div></fieldset>") |
|
| 446 | + ) |
|
| 447 | + . '<div id="install_adresse_base_hebergeur">' |
|
| 448 | + . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 449 | + . ($predef[1] |
|
| 450 | + ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 451 | + : fieldset(_T('entree_base_donnee_1'), |
|
| 452 | + array( |
|
| 453 | + 'adresse_db' => array( |
|
| 454 | + 'label' => $db[1], |
|
| 455 | + 'valeur' => $db[0] |
|
| 456 | + ), |
|
| 457 | + ) |
|
| 458 | + ) |
|
| 459 | + ) |
|
| 460 | + . '</div>' |
|
| 461 | + |
|
| 462 | + . '<div id="install_login_base_hebergeur">' |
|
| 463 | + . ($predef[2] |
|
| 464 | + ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 465 | + : fieldset(_T('entree_login_connexion_1'), |
|
| 466 | + array( |
|
| 467 | + 'login_db' => array( |
|
| 468 | + 'label' => $login[1], |
|
| 469 | + 'valeur' => $login[0] |
|
| 470 | + ), |
|
| 471 | + ) |
|
| 472 | + ) |
|
| 473 | + ) |
|
| 474 | + . '</div>' |
|
| 475 | + |
|
| 476 | + . '<div id="install_pass_base_hebergeur">' |
|
| 477 | + . ($predef[3] |
|
| 478 | + ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 479 | + : fieldset(_T('entree_mot_passe_1'), |
|
| 480 | + array( |
|
| 481 | + 'pass_db' => array( |
|
| 482 | + 'label' => $pass[1], |
|
| 483 | + 'valeur' => $pass[0] |
|
| 484 | + ), |
|
| 485 | + ) |
|
| 486 | + ) |
|
| 487 | + ) |
|
| 488 | + . '</div>' |
|
| 489 | + |
|
| 490 | + . bouton_suivant())); |
|
| 491 | 491 | |
| 492 | 492 | } |
| 493 | 493 | |
@@ -496,75 +496,75 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | // https://code.spip.net/@predef_ou_cache |
| 498 | 498 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 499 | - return ((defined('_INSTALL_HOST_DB')) |
|
| 500 | - ? '' |
|
| 501 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . "\" />" |
|
| 502 | - ) |
|
| 503 | - . ((defined('_INSTALL_USER_DB')) |
|
| 504 | - ? '' |
|
| 505 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />" |
|
| 506 | - ) |
|
| 507 | - . ((defined('_INSTALL_PASS_DB')) |
|
| 508 | - ? '' |
|
| 509 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />" |
|
| 510 | - ) |
|
| 511 | - |
|
| 512 | - . ((defined('_INSTALL_SERVER_DB')) |
|
| 513 | - ? '' |
|
| 514 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />" |
|
| 515 | - ); |
|
| 499 | + return ((defined('_INSTALL_HOST_DB')) |
|
| 500 | + ? '' |
|
| 501 | + : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . "\" />" |
|
| 502 | + ) |
|
| 503 | + . ((defined('_INSTALL_USER_DB')) |
|
| 504 | + ? '' |
|
| 505 | + : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />" |
|
| 506 | + ) |
|
| 507 | + . ((defined('_INSTALL_PASS_DB')) |
|
| 508 | + ? '' |
|
| 509 | + : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />" |
|
| 510 | + ) |
|
| 511 | + |
|
| 512 | + . ((defined('_INSTALL_SERVER_DB')) |
|
| 513 | + ? '' |
|
| 514 | + : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />" |
|
| 515 | + ); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // presentation des bases existantes |
| 519 | 519 | |
| 520 | 520 | // https://code.spip.net/@install_etape_liste_bases |
| 521 | 521 | function install_etape_liste_bases($server_db, $login_db, $disabled = array()) { |
| 522 | - $bases = $checked = array(); |
|
| 523 | - $noms = sql_listdbs($server_db); |
|
| 524 | - if (!$noms) { |
|
| 525 | - return ''; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - foreach ($noms as $nom) { |
|
| 529 | - $id = spip_htmlspecialchars($nom); |
|
| 530 | - $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 531 | - $base = " name=\"choix_db\" value=\"" |
|
| 532 | - . $nom |
|
| 533 | - . '"' |
|
| 534 | - . $dis |
|
| 535 | - . " type='radio' id='$id'"; |
|
| 536 | - $label = "<label for='$id'>" |
|
| 537 | - . ($dis ? "<i>$nom</i>" : $nom) |
|
| 538 | - . "</label>"; |
|
| 539 | - |
|
| 540 | - if (!$checked and !$dis and |
|
| 541 | - (($nom == $login_db) or |
|
| 542 | - ($GLOBALS['table_prefix'] == $nom)) |
|
| 543 | - ) { |
|
| 544 | - $checked = "<input$base checked='checked' />\n$label"; |
|
| 545 | - } else { |
|
| 546 | - $bases[] = "<input$base />\n$label"; |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - if (!$bases && !$checked) { |
|
| 551 | - return false; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - if ($checked) { |
|
| 555 | - array_unshift($bases, $checked); |
|
| 556 | - $checked = true; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - return array($checked, $bases); |
|
| 522 | + $bases = $checked = array(); |
|
| 523 | + $noms = sql_listdbs($server_db); |
|
| 524 | + if (!$noms) { |
|
| 525 | + return ''; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + foreach ($noms as $nom) { |
|
| 529 | + $id = spip_htmlspecialchars($nom); |
|
| 530 | + $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 531 | + $base = " name=\"choix_db\" value=\"" |
|
| 532 | + . $nom |
|
| 533 | + . '"' |
|
| 534 | + . $dis |
|
| 535 | + . " type='radio' id='$id'"; |
|
| 536 | + $label = "<label for='$id'>" |
|
| 537 | + . ($dis ? "<i>$nom</i>" : $nom) |
|
| 538 | + . "</label>"; |
|
| 539 | + |
|
| 540 | + if (!$checked and !$dis and |
|
| 541 | + (($nom == $login_db) or |
|
| 542 | + ($GLOBALS['table_prefix'] == $nom)) |
|
| 543 | + ) { |
|
| 544 | + $checked = "<input$base checked='checked' />\n$label"; |
|
| 545 | + } else { |
|
| 546 | + $bases[] = "<input$base />\n$label"; |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + if (!$bases && !$checked) { |
|
| 551 | + return false; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + if ($checked) { |
|
| 555 | + array_unshift($bases, $checked); |
|
| 556 | + $checked = true; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + return array($checked, $bases); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | function install_propager($hidden) { |
| 563 | - $res = ''; |
|
| 564 | - foreach ($hidden as $k) { |
|
| 565 | - $v = spip_htmlentities(_request($k)); |
|
| 566 | - $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 567 | - } |
|
| 563 | + $res = ''; |
|
| 564 | + foreach ($hidden as $k) { |
|
| 565 | + $v = spip_htmlentities(_request($k)); |
|
| 566 | + $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - return $res; |
|
| 569 | + return $res; |
|
| 570 | 570 | } |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | **/ |
| 45 | 45 | function install_fichier_connexion($nom, $texte) { |
| 46 | - $texte = "<" . "?php\n" |
|
| 46 | + $texte = "<"."?php\n" |
|
| 47 | 47 | . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
| 48 | 48 | . $texte |
| 49 | - . "?" . ">"; |
|
| 49 | + . "?".">"; |
|
| 50 | 50 | |
| 51 | 51 | ecrire_fichier($nom, $texte); |
| 52 | 52 | } |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | return $regs; |
| 114 | 114 | } else { |
| 115 | 115 | $ar = '\s*\'([^\']*)\''; |
| 116 | - $r = '\s*,' . $ar; |
|
| 116 | + $r = '\s*,'.$ar; |
|
| 117 | 117 | $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
| 118 | 118 | if (preg_match($r, $s, $regs)) { |
| 119 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";"); |
|
| 119 | + $regs[2] = $regs[1].(!$regs[2] ? '' : ":".$regs[2].";"); |
|
| 120 | 120 | array_shift($regs); |
| 121 | 121 | array_shift($regs); |
| 122 | 122 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | // Si on n'a pas la bonne version de PHP, c'est la fin |
| 175 | 175 | if ($err) { |
| 176 | 176 | die("<div class='error'>" |
| 177 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 177 | + . "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>" |
|
| 178 | 178 | . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | if ($err) { |
| 203 | 203 | echo "<div class='error'>" |
| 204 | - . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 204 | + . "<h3>"._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"; |
|
| 205 | 205 | foreach ($err as $e) { |
| 206 | 206 | echo "<li><strong>$e</strong></li>\n"; |
| 207 | 207 | } |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | // https://code.spip.net/@info_etape |
| 237 | 237 | function info_etape($titre, $complement = '') { |
| 238 | - return "<h2>" . $titre . "</h2>\n" . |
|
| 239 | - ($complement ? "" . $complement . "\n" : ''); |
|
| 238 | + return "<h2>".$titre."</h2>\n". |
|
| 239 | + ($complement ? "".$complement."\n" : ''); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -250,18 +250,18 @@ discard block |
||
| 250 | 250 | $code = _T('bouton_suivant'); |
| 251 | 251 | } |
| 252 | 252 | static $suivant = 0; |
| 253 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 253 | + $id = 'suivant'.(($suivant > 0) ? strval($suivant) : ''); |
|
| 254 | 254 | $suivant += 1; |
| 255 | 255 | |
| 256 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 257 | - $code . |
|
| 256 | + return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"". |
|
| 257 | + $code. |
|
| 258 | 258 | " >>\" /></p>\n"; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // https://code.spip.net/@info_progression_etape |
| 262 | 262 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 263 | 263 | //$en_cours = _request('etape')?_request('etape'):""; |
| 264 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 264 | + $liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$'); |
|
| 265 | 265 | $debut = 1; |
| 266 | 266 | $etat = "ok"; |
| 267 | 267 | $last = count($liste); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $aff_etapes .= "<li class='$class'><div class='fond'>"; |
| 302 | 302 | $aff_etapes .= ($debut == $en_cours) ? "<strong>" : ''; |
| 303 | - $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 303 | + $aff_etapes .= "<em>"._T('etape')." </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 304 | 304 | $aff_etapes .= $intitule_etat["$phase"][$debut]; |
| 305 | 305 | $aff_etapes .= ($debut == $en_cours) ? "</strong>" : ''; |
| 306 | 306 | $aff_etapes .= "</div></li>"; |
@@ -316,11 +316,11 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // https://code.spip.net/@fieldset |
| 318 | 318 | function fieldset($legend, $champs = array(), $apres = '', $avant = '') { |
| 319 | - return "<fieldset>\n" . |
|
| 320 | - $avant . |
|
| 321 | - ($legend ? "<legend>" . $legend . "</legend>\n" : '') . |
|
| 322 | - fieldset_champs($champs) . |
|
| 323 | - $apres . |
|
| 319 | + return "<fieldset>\n". |
|
| 320 | + $avant. |
|
| 321 | + ($legend ? "<legend>".$legend."</legend>\n" : ''). |
|
| 322 | + fieldset_champs($champs). |
|
| 323 | + $apres. |
|
| 324 | 324 | "</fieldset>\n"; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -330,18 +330,18 @@ discard block |
||
| 330 | 330 | $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
| 331 | 331 | $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
| 332 | 332 | if (isset($contenu['alternatives'])) { |
| 333 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 333 | + $fieldset .= $contenu['label']."\n"; |
|
| 334 | 334 | foreach ($contenu['alternatives'] as $valeur => $label) { |
| 335 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 335 | + $fieldset .= "<input type='radio' name='".$nom. |
|
| 336 | 336 | "' id='$nom-$valeur' value='$valeur'" |
| 337 | 337 | . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
| 338 | 338 | . "/>\n"; |
| 339 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 339 | + $fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n"; |
|
| 340 | 340 | } |
| 341 | 341 | $fieldset .= "<br />\n"; |
| 342 | 342 | } else { |
| 343 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 344 | - $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 343 | + $fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n"; |
|
| 344 | + $fieldset .= "<input ".$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'" |
|
| 345 | 345 | . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
| 346 | 346 | . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "") |
| 347 | 347 | . " />\n"; |
@@ -353,24 +353,24 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | function install_select_serveur() { |
| 355 | 355 | $options = array(); |
| 356 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 356 | + $dir = _DIR_RESTREINT.'req/'; |
|
| 357 | 357 | $d = opendir($dir); |
| 358 | 358 | if (!$d) { |
| 359 | 359 | return array(); |
| 360 | 360 | } |
| 361 | 361 | while (($f = readdir($d)) !== false) { |
| 362 | 362 | if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
| 363 | - and is_readable($f = $dir . $f) |
|
| 363 | + and is_readable($f = $dir.$f) |
|
| 364 | 364 | ) { |
| 365 | 365 | require_once($f); |
| 366 | 366 | $s = $s[1]; |
| 367 | - $v = 'spip_versions_' . $s; |
|
| 367 | + $v = 'spip_versions_'.$s; |
|
| 368 | 368 | if (function_exists($v) and $v()) { |
| 369 | 369 | $titre = _T("install_select_type_$s"); |
| 370 | 370 | // proposer mysql par defaut si dispo |
| 371 | 371 | $checked = ($s == 'mysql' ? " checked='checked'" : ""); |
| 372 | 372 | $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
| 373 | - . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>"; |
|
| 373 | + . "<label for='$s'>".($titre ? $titre : $s)."</label></li>"; |
|
| 374 | 374 | } else { |
| 375 | 375 | spip_log("$s: portage indisponible"); |
| 376 | 376 | } |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | "\n<input type='hidden' name='etape' value='$etape' />" |
| 390 | 390 | . $hidden |
| 391 | 391 | . (_request('echec') ? |
| 392 | - ("<p><b>" . _T('avis_connexion_echec_1') . |
|
| 393 | - "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>") |
|
| 392 | + ("<p><b>"._T('avis_connexion_echec_1'). |
|
| 393 | + "</b></p><p>"._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3')."</p>") |
|
| 394 | 394 | : "") |
| 395 | 395 | |
| 396 | 396 | . ($jquery ? http_script('', 'jquery.js') : '') |
@@ -428,9 +428,9 @@ discard block |
||
| 428 | 428 | });') |
| 429 | 429 | |
| 430 | 430 | . ($server_db |
| 431 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 431 | + ? '<input type="hidden" name="server_db" value="'.$server_db.'" />' |
|
| 432 | 432 | . (($predef[0]) |
| 433 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 433 | + ? ('<h3>'._T('install_serveur_hebergeur').'</h3>') |
|
| 434 | 434 | : '') |
| 435 | 435 | : ('<fieldset><legend>' |
| 436 | 436 | . _T('install_select_type_db') |
@@ -445,9 +445,9 @@ discard block |
||
| 445 | 445 | . "\n</ul>\n</div></fieldset>") |
| 446 | 446 | ) |
| 447 | 447 | . '<div id="install_adresse_base_hebergeur">' |
| 448 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 448 | + . '<p>'._T('texte_connexion_mysql').'</p>' |
|
| 449 | 449 | . ($predef[1] |
| 450 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 450 | + ? '<h3>'._T('install_adresse_base_hebergeur').'</h3>' |
|
| 451 | 451 | : fieldset(_T('entree_base_donnee_1'), |
| 452 | 452 | array( |
| 453 | 453 | 'adresse_db' => array( |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | . '<div id="install_login_base_hebergeur">' |
| 463 | 463 | . ($predef[2] |
| 464 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 464 | + ? '<h3>'._T('install_login_base_hebergeur').'</h3>' |
|
| 465 | 465 | : fieldset(_T('entree_login_connexion_1'), |
| 466 | 466 | array( |
| 467 | 467 | 'login_db' => array( |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | . '<div id="install_pass_base_hebergeur">' |
| 477 | 477 | . ($predef[3] |
| 478 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 478 | + ? '<h3>'._T('install_pass_base_hebergeur').'</h3>' |
|
| 479 | 479 | : fieldset(_T('entree_mot_passe_1'), |
| 480 | 480 | array( |
| 481 | 481 | 'pass_db' => array( |
@@ -498,20 +498,20 @@ discard block |
||
| 498 | 498 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 499 | 499 | return ((defined('_INSTALL_HOST_DB')) |
| 500 | 500 | ? '' |
| 501 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . "\" />" |
|
| 501 | + : "\n<input type='hidden' name='adresse_db' value=\"".spip_htmlspecialchars($adresse_db)."\" />" |
|
| 502 | 502 | ) |
| 503 | 503 | . ((defined('_INSTALL_USER_DB')) |
| 504 | 504 | ? '' |
| 505 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />" |
|
| 505 | + : "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db)."\" />" |
|
| 506 | 506 | ) |
| 507 | 507 | . ((defined('_INSTALL_PASS_DB')) |
| 508 | 508 | ? '' |
| 509 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />" |
|
| 509 | + : "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db)."\" />" |
|
| 510 | 510 | ) |
| 511 | 511 | |
| 512 | 512 | . ((defined('_INSTALL_SERVER_DB')) |
| 513 | 513 | ? '' |
| 514 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />" |
|
| 514 | + : "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db)."\" />" |
|
| 515 | 515 | ); |
| 516 | 516 | } |
| 517 | 517 | |