@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | **/ |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 25 | - return; |
|
| 25 | + return; |
|
| 26 | 26 | } |
| 27 | 27 | include_spip('inc/filtres'); |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @return string Rien. |
| 40 | 40 | **/ |
| 41 | 41 | function filtre_image_dist($t) { |
| 42 | - return ''; |
|
| 42 | + return ''; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return string Rien. |
| 53 | 53 | **/ |
| 54 | 54 | function filtre_audio_dist($t) { |
| 55 | - return ''; |
|
| 55 | + return ''; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @return string Rien. |
| 66 | 66 | **/ |
| 67 | 67 | function filtre_video_dist($t) { |
| 68 | - return ''; |
|
| 68 | + return ''; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return string Rien. |
| 79 | 79 | **/ |
| 80 | 80 | function filtre_application_dist($t) { |
| 81 | - return ''; |
|
| 81 | + return ''; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return string Rien. |
| 92 | 92 | **/ |
| 93 | 93 | function filtre_message_dist($t) { |
| 94 | - return ''; |
|
| 94 | + return ''; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return string Rien. |
| 105 | 105 | **/ |
| 106 | 106 | function filtre_multipart_dist($t) { |
| 107 | - return ''; |
|
| 107 | + return ''; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | * @return string Contenu échappé. |
| 118 | 118 | **/ |
| 119 | 119 | function filtre_text_dist($t) { |
| 120 | - static $t1 = array('&', '<', '>'); |
|
| 121 | - static $t2 = array('&', '<', '>'); |
|
| 120 | + static $t1 = array('&', '<', '>'); |
|
| 121 | + static $t2 = array('&', '<', '>'); |
|
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 123 | + return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -135,22 +135,22 @@ discard block |
||
| 135 | 135 | * Tableau (formaté en SPIP) |
| 136 | 136 | **/ |
| 137 | 137 | function filtre_text_csv_dist($t) { |
| 138 | - include_spip('inc/csv'); |
|
| 139 | - list($entete, $lignes, $caption) = analyse_csv($t); |
|
| 140 | - foreach ($lignes as &$l) { |
|
| 141 | - $l = join('|', $l); |
|
| 142 | - } |
|
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 149 | - str_replace("\n", "|\n|", $corps); |
|
| 150 | - $corps = str_replace('"#', '"', $corps); |
|
| 151 | - include_spip('inc/texte'); |
|
| 152 | - |
|
| 153 | - return propre($corps); |
|
| 138 | + include_spip('inc/csv'); |
|
| 139 | + list($entete, $lignes, $caption) = analyse_csv($t); |
|
| 140 | + foreach ($lignes as &$l) { |
|
| 141 | + $l = join('|', $l); |
|
| 142 | + } |
|
| 143 | + $corps = join("\n", $lignes) . "\n"; |
|
| 144 | + $corps = $caption . |
|
| 145 | + "\n|{{" . |
|
| 146 | + join('}}|{{', $entete) . |
|
| 147 | + '}}|' . |
|
| 148 | + "\n|" . |
|
| 149 | + str_replace("\n", "|\n|", $corps); |
|
| 150 | + $corps = str_replace('"#', '"', $corps); |
|
| 151 | + include_spip('inc/texte'); |
|
| 152 | + |
|
| 153 | + return propre($corps); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -164,31 +164,31 @@ discard block |
||
| 164 | 164 | * @return string Code html sécurisé ou texte échappé |
| 165 | 165 | **/ |
| 166 | 166 | function filtre_text_html_dist($t) { |
| 167 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 168 | - return appliquer_filtre($t, 'text/plain'); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - list(, $h, $t) = $r; |
|
| 172 | - |
|
| 173 | - $style = ''; |
|
| 174 | - // recuperer les styles internes |
|
| 175 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 176 | - $style = join("\n", $r[1]); |
|
| 177 | - } |
|
| 178 | - // ... et externes |
|
| 179 | - |
|
| 180 | - include_spip('inc/distant'); |
|
| 181 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 182 | - foreach ($r[0] as $l) { |
|
| 183 | - preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 184 | - $style .= "\n/* $l */\n" |
|
| 185 | - . str_replace('<', '', recuperer_page($m[1])); |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 189 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 190 | - |
|
| 191 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 167 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 168 | + return appliquer_filtre($t, 'text/plain'); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + list(, $h, $t) = $r; |
|
| 172 | + |
|
| 173 | + $style = ''; |
|
| 174 | + // recuperer les styles internes |
|
| 175 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 176 | + $style = join("\n", $r[1]); |
|
| 177 | + } |
|
| 178 | + // ... et externes |
|
| 179 | + |
|
| 180 | + include_spip('inc/distant'); |
|
| 181 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 182 | + foreach ($r[0] as $l) { |
|
| 183 | + preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 184 | + $style .= "\n/* $l */\n" |
|
| 185 | + . str_replace('<', '', recuperer_page($m[1])); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 189 | + $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 190 | + |
|
| 191 | + return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return string Code HTML des balises `<param>` |
| 202 | 202 | **/ |
| 203 | 203 | function filtre_audio_x_pn_realaudio($id) { |
| 204 | - return " |
|
| 204 | + return " |
|
| 205 | 205 | <param name='controls' value='PositionSlider' /> |
| 206 | 206 | <param name='controls' value='ImageWindow' /> |
| 207 | 207 | <param name='controls' value='PlayButton' /> |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | static $t1 = array('&', '<', '>'); |
| 121 | 121 | static $t2 = array('&', '<', '>'); |
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 123 | + return '<pre>'.str_replace($t1, $t2, $t).'</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | foreach ($lignes as &$l) { |
| 141 | 141 | $l = join('|', $l); |
| 142 | 142 | } |
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 143 | + $corps = join("\n", $lignes)."\n"; |
|
| 144 | + $corps = $caption. |
|
| 145 | + "\n|{{". |
|
| 146 | + join('}}|{{', $entete). |
|
| 147 | + '}}|'. |
|
| 148 | + "\n|". |
|
| 149 | 149 | str_replace("\n", "|\n|", $corps); |
| 150 | 150 | $corps = str_replace('"#', '"', $corps); |
| 151 | 151 | include_spip('inc/texte'); |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
| 189 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 189 | + $t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t)); |
|
| 190 | 190 | |
| 191 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 191 | + return (!$style ? '' : "\n<style>".$style.'</style>').$t; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function extraire_date($texte) { |
| 39 | 39 | // format = 2001-08 |
| 40 | 40 | if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
| 41 | - return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 41 | + return $regs[1]."-".sprintf("%02d", $regs[2])."-01"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
| 70 | 70 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 71 | - $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 71 | + $date = $regs[1]."-00-00".$regs[3]; |
|
| 72 | 72 | } else { |
| 73 | 73 | if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
| 74 | 74 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 75 | - $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 75 | + $date = preg_replace("@/@", "-", $regs[1])."-00".$regs[3]; |
|
| 76 | 76 | } else { |
| 77 | 77 | $date = date("Y-m-d H:i:s", strtotime($date)); |
| 78 | 78 | } |
@@ -367,17 +367,17 @@ discard block |
||
| 367 | 367 | if ($decal > 3600 * 24 * 30) { |
| 368 | 368 | $mois = floor($decal / (3600 * 24 * 30)); |
| 369 | 369 | if ($mois < 2) { |
| 370 | - $delai = "$mois " . _T("date_un_mois"); |
|
| 370 | + $delai = "$mois "._T("date_un_mois"); |
|
| 371 | 371 | } else { |
| 372 | - $delai = "$mois " . _T("date_mois"); |
|
| 372 | + $delai = "$mois "._T("date_mois"); |
|
| 373 | 373 | } |
| 374 | 374 | } else { |
| 375 | 375 | if ($decal > 3600 * 24 * 7) { |
| 376 | 376 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 377 | 377 | if ($semaines < 2) { |
| 378 | - $delai = "$semaines " . _T("date_une_semaine"); |
|
| 378 | + $delai = "$semaines "._T("date_une_semaine"); |
|
| 379 | 379 | } else { |
| 380 | - $delai = "$semaines " . _T("date_semaines"); |
|
| 380 | + $delai = "$semaines "._T("date_semaines"); |
|
| 381 | 381 | } |
| 382 | 382 | } else { |
| 383 | 383 | if ($decal > 3600 * 24) { |
@@ -385,30 +385,30 @@ discard block |
||
| 385 | 385 | if ($jours < 2) { |
| 386 | 386 | return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
| 387 | 387 | } else { |
| 388 | - $delai = "$jours " . _T("date_jours"); |
|
| 388 | + $delai = "$jours "._T("date_jours"); |
|
| 389 | 389 | } |
| 390 | 390 | } else { |
| 391 | 391 | if ($decal >= 3600) { |
| 392 | 392 | $heures = floor($decal / 3600); |
| 393 | 393 | if ($heures < 2) { |
| 394 | - $delai = "$heures " . _T("date_une_heure"); |
|
| 394 | + $delai = "$heures "._T("date_une_heure"); |
|
| 395 | 395 | } else { |
| 396 | - $delai = "$heures " . _T("date_heures"); |
|
| 396 | + $delai = "$heures "._T("date_heures"); |
|
| 397 | 397 | } |
| 398 | 398 | } else { |
| 399 | 399 | if ($decal >= 60) { |
| 400 | 400 | $minutes = floor($decal / 60); |
| 401 | 401 | if ($minutes < 2) { |
| 402 | - $delai = "$minutes " . _T("date_une_minute"); |
|
| 402 | + $delai = "$minutes "._T("date_une_minute"); |
|
| 403 | 403 | } else { |
| 404 | - $delai = "$minutes " . _T("date_minutes"); |
|
| 404 | + $delai = "$minutes "._T("date_minutes"); |
|
| 405 | 405 | } |
| 406 | 406 | } else { |
| 407 | 407 | $secondes = ceil($decal); |
| 408 | 408 | if ($secondes < 2) { |
| 409 | - $delai = "$secondes " . _T("date_une_seconde"); |
|
| 409 | + $delai = "$secondes "._T("date_une_seconde"); |
|
| 410 | 410 | } else { |
| 411 | - $delai = "$secondes " . _T("date_secondes"); |
|
| 411 | + $delai = "$secondes "._T("date_secondes"); |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | } |
@@ -503,16 +503,16 @@ discard block |
||
| 503 | 503 | $njour = 0; |
| 504 | 504 | } else { |
| 505 | 505 | $njour = intval($jour); |
| 506 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 506 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 507 | 507 | $jour = $jourth; |
| 508 | 508 | } |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | $mois = intval($mois); |
| 512 | 512 | if ($mois > 0 and $mois < 13) { |
| 513 | - $nommois = _T('date_mois_' . $mois); |
|
| 513 | + $nommois = _T('date_mois_'.$mois); |
|
| 514 | 514 | if ($jour) { |
| 515 | - $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 515 | + $jourmois = _T('date_de_mois_'.$mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 516 | 516 | } else { |
| 517 | 517 | $jourmois = $nommois; |
| 518 | 518 | } |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | if ($annee < 0) { |
| 525 | - $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 525 | + $annee = -$annee." "._T('date_avant_jc'); |
|
| 526 | 526 | $avjc = true; |
| 527 | 527 | } else { |
| 528 | 528 | $avjc = false; |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | if ($vue == 'saison') { |
| 551 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 551 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 552 | 552 | } else { |
| 553 | 553 | return $saison ? trim(_T('date_fmt_saison_annee', |
| 554 | - array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 554 | + array('saison' => _T('date_saison_'.$saison), 'annee' => $annee))) : ''; |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | case 'court': |
@@ -600,9 +600,9 @@ discard block |
||
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | case 'nom_mois': |
| 603 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 603 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 604 | 604 | if ($param and $mois) { |
| 605 | - return _T('date_mois_' . $mois . $param); |
|
| 605 | + return _T('date_mois_'.$mois.$param); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | return $nommois; |
@@ -622,9 +622,9 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 624 | 624 | $nom = 1 + date('w', $nom); |
| 625 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 625 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 626 | 626 | |
| 627 | - return _T('date_jour_' . $nom . $param); |
|
| 627 | + return _T('date_jour_'.$nom.$param); |
|
| 628 | 628 | |
| 629 | 629 | case 'mois_annee': |
| 630 | 630 | if ($avjc) { |
@@ -1019,8 +1019,8 @@ discard block |
||
| 1019 | 1019 | |
| 1020 | 1020 | $dtstart = $dtend = $dtabbr = ""; |
| 1021 | 1021 | if (strpos($forme, 'hcal') !== false) { |
| 1022 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1023 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1022 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1023 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1024 | 1024 | $dtabbr = "</abbr>"; |
| 1025 | 1025 | } |
| 1026 | 1026 | |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | } |
| 1061 | 1061 | } else { |
| 1062 | 1062 | if ($dtabbr && $dtstart) { |
| 1063 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1063 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1064 | 1064 | } else { |
| 1065 | 1065 | $s = spip_ucfirst($s); |
| 1066 | 1066 | } |
@@ -1083,8 +1083,8 @@ discard block |
||
| 1083 | 1083 | $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
| 1084 | 1084 | $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
| 1085 | 1085 | } |
| 1086 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1087 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1086 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1087 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1088 | 1088 | |
| 1089 | 1089 | $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
| 1090 | 1090 | } else { |
@@ -1101,8 +1101,8 @@ discard block |
||
| 1101 | 1101 | $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1105 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1104 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1105 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1106 | 1106 | $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
| 1107 | 1107 | |
| 1108 | 1108 | } |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | $d = date("Y-m-d"); |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1210 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | /** |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | $d = date("Y-m-d"); |
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1230 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * Date au format SQL tel que `2008-04-01` |
| 37 | 37 | **/ |
| 38 | 38 | function extraire_date($texte) { |
| 39 | - // format = 2001-08 |
|
| 40 | - if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
|
| 41 | - return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 42 | - } |
|
| 39 | + // format = 2001-08 |
|
| 40 | + if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
|
| 41 | + return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -61,29 +61,29 @@ discard block |
||
| 61 | 61 | * - une chaîne vide si la date est considérée nulle |
| 62 | 62 | **/ |
| 63 | 63 | function normaliser_date($date, $forcer_jour = false) { |
| 64 | - $date = vider_date($date); |
|
| 65 | - if ($date) { |
|
| 66 | - if (preg_match("/^[0-9]{8,10}$/", $date)) { |
|
| 67 | - $date = date("Y-m-d H:i:s", $date); |
|
| 68 | - } |
|
| 69 | - if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 70 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | - $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 72 | - } else { |
|
| 73 | - if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 74 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | - $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 76 | - } else { |
|
| 77 | - $date = date("Y-m-d H:i:s", strtotime($date)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($forcer_jour) { |
|
| 82 | - $date = str_replace('-00', '-01', $date); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return $date; |
|
| 64 | + $date = vider_date($date); |
|
| 65 | + if ($date) { |
|
| 66 | + if (preg_match("/^[0-9]{8,10}$/", $date)) { |
|
| 67 | + $date = date("Y-m-d H:i:s", $date); |
|
| 68 | + } |
|
| 69 | + if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 70 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | + $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 72 | + } else { |
|
| 73 | + if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 74 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | + $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 76 | + } else { |
|
| 77 | + $date = date("Y-m-d H:i:s", strtotime($date)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($forcer_jour) { |
|
| 82 | + $date = str_replace('-00', '-01', $date); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return $date; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | * - Une chaine vide |
| 96 | 96 | **/ |
| 97 | 97 | function vider_date($letexte) { |
| 98 | - if (strncmp("0000-00-00", $letexte, 10) == 0) { |
|
| 99 | - return ''; |
|
| 100 | - } |
|
| 101 | - if (strncmp("0001-01-01", $letexte, 10) == 0) { |
|
| 102 | - return ''; |
|
| 103 | - } |
|
| 104 | - if (strncmp("1970-01-01", $letexte, 10) == 0) { |
|
| 105 | - return ''; |
|
| 106 | - } // eviter le bug GMT-1 |
|
| 107 | - return $letexte; |
|
| 98 | + if (strncmp("0000-00-00", $letexte, 10) == 0) { |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + if (strncmp("0001-01-01", $letexte, 10) == 0) { |
|
| 102 | + return ''; |
|
| 103 | + } |
|
| 104 | + if (strncmp("1970-01-01", $letexte, 10) == 0) { |
|
| 105 | + return ''; |
|
| 106 | + } // eviter le bug GMT-1 |
|
| 107 | + return $letexte; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -120,14 +120,14 @@ discard block |
||
| 120 | 120 | **/ |
| 121 | 121 | function recup_heure($date) { |
| 122 | 122 | |
| 123 | - static $d = array(0, 0, 0); |
|
| 124 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 125 | - return $d; |
|
| 126 | - } |
|
| 123 | + static $d = array(0, 0, 0); |
|
| 124 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 125 | + return $d; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - array_shift($r); |
|
| 128 | + array_shift($r); |
|
| 129 | 129 | |
| 130 | - return $r; |
|
| 130 | + return $r; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | * @return int heures, sinon 0 |
| 142 | 142 | **/ |
| 143 | 143 | function heures($numdate) { |
| 144 | - $date_array = recup_heure($numdate); |
|
| 145 | - if ($date_array) { |
|
| 146 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 147 | - } |
|
| 144 | + $date_array = recup_heure($numdate); |
|
| 145 | + if ($date_array) { |
|
| 146 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return $heures; |
|
| 149 | + return $heures; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | * @return int minutes, sinon 0 |
| 161 | 161 | **/ |
| 162 | 162 | function minutes($numdate) { |
| 163 | - $date_array = recup_heure($numdate); |
|
| 164 | - if ($date_array) { |
|
| 165 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 166 | - } |
|
| 163 | + $date_array = recup_heure($numdate); |
|
| 164 | + if ($date_array) { |
|
| 165 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - return $minutes; |
|
| 168 | + return $minutes; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | * @return int secondes, sinon 0 |
| 180 | 180 | **/ |
| 181 | 181 | function secondes($numdate) { |
| 182 | - $date_array = recup_heure($numdate); |
|
| 183 | - if ($date_array) { |
|
| 184 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 185 | - } |
|
| 182 | + $date_array = recup_heure($numdate); |
|
| 183 | + if ($date_array) { |
|
| 184 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - return $secondes; |
|
| 187 | + return $secondes; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @return string L'heure formatée dans la langue en cours. |
| 201 | 201 | **/ |
| 202 | 202 | function heures_minutes($numdate) { |
| 203 | - return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 203 | + return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -225,57 +225,57 @@ discard block |
||
| 225 | 225 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 226 | 226 | **/ |
| 227 | 227 | function recup_date($numdate, $forcer_jour = true) { |
| 228 | - if (!$numdate) { |
|
| 229 | - return ''; |
|
| 230 | - } |
|
| 231 | - $heures = $minutes = $secondes = 0; |
|
| 232 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 233 | - $jour = $regs[1]; |
|
| 234 | - $mois = $regs[2]; |
|
| 235 | - $annee = $regs[3]; |
|
| 236 | - if ($annee < 90) { |
|
| 237 | - $annee = 2000 + $annee; |
|
| 238 | - } elseif ($annee < 100) { |
|
| 239 | - $annee = 1900 + $annee; |
|
| 240 | - } |
|
| 241 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 242 | - |
|
| 243 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 244 | - $annee = $regs[1]; |
|
| 245 | - $mois = $regs[2]; |
|
| 246 | - $jour = $regs[3]; |
|
| 247 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 248 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 249 | - $annee = $regs[1]; |
|
| 250 | - $mois = $regs[2]; |
|
| 251 | - $jour = ''; |
|
| 252 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 253 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 254 | - $annee = $regs[1]; |
|
| 255 | - $mois = $regs[2]; |
|
| 256 | - $jour = $regs[3]; |
|
| 257 | - $heures = $regs[4]; |
|
| 258 | - $minutes = $regs[5]; |
|
| 259 | - $secondes = $regs[6]; |
|
| 260 | - } else { |
|
| 261 | - $annee = $mois = $jour = ''; |
|
| 262 | - } |
|
| 263 | - if ($annee > 4000) { |
|
| 264 | - $annee -= 9000; |
|
| 265 | - } |
|
| 266 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 267 | - $jour = substr($jour, 1); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - if ($forcer_jour and $jour == '0') { |
|
| 271 | - $jour = '1'; |
|
| 272 | - } |
|
| 273 | - if ($forcer_jour and $mois == '0') { |
|
| 274 | - $mois = '1'; |
|
| 275 | - } |
|
| 276 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 277 | - return array($annee, $mois, $jour, $heures, $minutes, $secondes); |
|
| 278 | - } |
|
| 228 | + if (!$numdate) { |
|
| 229 | + return ''; |
|
| 230 | + } |
|
| 231 | + $heures = $minutes = $secondes = 0; |
|
| 232 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 233 | + $jour = $regs[1]; |
|
| 234 | + $mois = $regs[2]; |
|
| 235 | + $annee = $regs[3]; |
|
| 236 | + if ($annee < 90) { |
|
| 237 | + $annee = 2000 + $annee; |
|
| 238 | + } elseif ($annee < 100) { |
|
| 239 | + $annee = 1900 + $annee; |
|
| 240 | + } |
|
| 241 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 242 | + |
|
| 243 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 244 | + $annee = $regs[1]; |
|
| 245 | + $mois = $regs[2]; |
|
| 246 | + $jour = $regs[3]; |
|
| 247 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 248 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 249 | + $annee = $regs[1]; |
|
| 250 | + $mois = $regs[2]; |
|
| 251 | + $jour = ''; |
|
| 252 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 253 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 254 | + $annee = $regs[1]; |
|
| 255 | + $mois = $regs[2]; |
|
| 256 | + $jour = $regs[3]; |
|
| 257 | + $heures = $regs[4]; |
|
| 258 | + $minutes = $regs[5]; |
|
| 259 | + $secondes = $regs[6]; |
|
| 260 | + } else { |
|
| 261 | + $annee = $mois = $jour = ''; |
|
| 262 | + } |
|
| 263 | + if ($annee > 4000) { |
|
| 264 | + $annee -= 9000; |
|
| 265 | + } |
|
| 266 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 267 | + $jour = substr($jour, 1); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + if ($forcer_jour and $jour == '0') { |
|
| 271 | + $jour = '1'; |
|
| 272 | + } |
|
| 273 | + if ($forcer_jour and $mois == '0') { |
|
| 274 | + $mois = '1'; |
|
| 275 | + } |
|
| 276 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 277 | + return array($annee, $mois, $jour, $heures, $minutes, $secondes); |
|
| 278 | + } |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | * La date relative ou complète |
| 303 | 303 | **/ |
| 304 | 304 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) { |
| 305 | - return sinon( |
|
| 306 | - date_relative($date, $decalage_maxi), |
|
| 307 | - affdate_heure($date) |
|
| 308 | - ); |
|
| 305 | + return sinon( |
|
| 306 | + date_relative($date, $decalage_maxi), |
|
| 307 | + affdate_heure($date) |
|
| 308 | + ); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -338,85 +338,85 @@ discard block |
||
| 338 | 338 | **/ |
| 339 | 339 | function date_relative($date, $decalage_maxi = 0, $ref_date = null) { |
| 340 | 340 | |
| 341 | - if (is_null($ref_date)) { |
|
| 342 | - $ref_time = time(); |
|
| 343 | - } else { |
|
| 344 | - $ref_time = strtotime($ref_date); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - if (!$date) { |
|
| 348 | - return; |
|
| 349 | - } |
|
| 350 | - $decal = date("U", $ref_time) - date("U", strtotime($date)); |
|
| 351 | - |
|
| 352 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 353 | - return ''; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if ($decal < 0) { |
|
| 357 | - $il_y_a = "date_dans"; |
|
| 358 | - $decal = -1 * $decal; |
|
| 359 | - } else { |
|
| 360 | - $il_y_a = "date_il_y_a"; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 364 | - return affdate_court($date); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if ($decal > 3600 * 24 * 30) { |
|
| 368 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 369 | - if ($mois < 2) { |
|
| 370 | - $delai = "$mois " . _T("date_un_mois"); |
|
| 371 | - } else { |
|
| 372 | - $delai = "$mois " . _T("date_mois"); |
|
| 373 | - } |
|
| 374 | - } else { |
|
| 375 | - if ($decal > 3600 * 24 * 7) { |
|
| 376 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 377 | - if ($semaines < 2) { |
|
| 378 | - $delai = "$semaines " . _T("date_une_semaine"); |
|
| 379 | - } else { |
|
| 380 | - $delai = "$semaines " . _T("date_semaines"); |
|
| 381 | - } |
|
| 382 | - } else { |
|
| 383 | - if ($decal > 3600 * 24) { |
|
| 384 | - $jours = floor($decal / (3600 * 24)); |
|
| 385 | - if ($jours < 2) { |
|
| 386 | - return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
|
| 387 | - } else { |
|
| 388 | - $delai = "$jours " . _T("date_jours"); |
|
| 389 | - } |
|
| 390 | - } else { |
|
| 391 | - if ($decal >= 3600) { |
|
| 392 | - $heures = floor($decal / 3600); |
|
| 393 | - if ($heures < 2) { |
|
| 394 | - $delai = "$heures " . _T("date_une_heure"); |
|
| 395 | - } else { |
|
| 396 | - $delai = "$heures " . _T("date_heures"); |
|
| 397 | - } |
|
| 398 | - } else { |
|
| 399 | - if ($decal >= 60) { |
|
| 400 | - $minutes = floor($decal / 60); |
|
| 401 | - if ($minutes < 2) { |
|
| 402 | - $delai = "$minutes " . _T("date_une_minute"); |
|
| 403 | - } else { |
|
| 404 | - $delai = "$minutes " . _T("date_minutes"); |
|
| 405 | - } |
|
| 406 | - } else { |
|
| 407 | - $secondes = ceil($decal); |
|
| 408 | - if ($secondes < 2) { |
|
| 409 | - $delai = "$secondes " . _T("date_une_seconde"); |
|
| 410 | - } else { |
|
| 411 | - $delai = "$secondes " . _T("date_secondes"); |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - return _T($il_y_a, array("delai" => $delai)); |
|
| 341 | + if (is_null($ref_date)) { |
|
| 342 | + $ref_time = time(); |
|
| 343 | + } else { |
|
| 344 | + $ref_time = strtotime($ref_date); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + if (!$date) { |
|
| 348 | + return; |
|
| 349 | + } |
|
| 350 | + $decal = date("U", $ref_time) - date("U", strtotime($date)); |
|
| 351 | + |
|
| 352 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 353 | + return ''; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if ($decal < 0) { |
|
| 357 | + $il_y_a = "date_dans"; |
|
| 358 | + $decal = -1 * $decal; |
|
| 359 | + } else { |
|
| 360 | + $il_y_a = "date_il_y_a"; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 364 | + return affdate_court($date); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if ($decal > 3600 * 24 * 30) { |
|
| 368 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 369 | + if ($mois < 2) { |
|
| 370 | + $delai = "$mois " . _T("date_un_mois"); |
|
| 371 | + } else { |
|
| 372 | + $delai = "$mois " . _T("date_mois"); |
|
| 373 | + } |
|
| 374 | + } else { |
|
| 375 | + if ($decal > 3600 * 24 * 7) { |
|
| 376 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 377 | + if ($semaines < 2) { |
|
| 378 | + $delai = "$semaines " . _T("date_une_semaine"); |
|
| 379 | + } else { |
|
| 380 | + $delai = "$semaines " . _T("date_semaines"); |
|
| 381 | + } |
|
| 382 | + } else { |
|
| 383 | + if ($decal > 3600 * 24) { |
|
| 384 | + $jours = floor($decal / (3600 * 24)); |
|
| 385 | + if ($jours < 2) { |
|
| 386 | + return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
|
| 387 | + } else { |
|
| 388 | + $delai = "$jours " . _T("date_jours"); |
|
| 389 | + } |
|
| 390 | + } else { |
|
| 391 | + if ($decal >= 3600) { |
|
| 392 | + $heures = floor($decal / 3600); |
|
| 393 | + if ($heures < 2) { |
|
| 394 | + $delai = "$heures " . _T("date_une_heure"); |
|
| 395 | + } else { |
|
| 396 | + $delai = "$heures " . _T("date_heures"); |
|
| 397 | + } |
|
| 398 | + } else { |
|
| 399 | + if ($decal >= 60) { |
|
| 400 | + $minutes = floor($decal / 60); |
|
| 401 | + if ($minutes < 2) { |
|
| 402 | + $delai = "$minutes " . _T("date_une_minute"); |
|
| 403 | + } else { |
|
| 404 | + $delai = "$minutes " . _T("date_minutes"); |
|
| 405 | + } |
|
| 406 | + } else { |
|
| 407 | + $secondes = ceil($decal); |
|
| 408 | + if ($secondes < 2) { |
|
| 409 | + $delai = "$secondes " . _T("date_une_seconde"); |
|
| 410 | + } else { |
|
| 411 | + $delai = "$secondes " . _T("date_secondes"); |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + return _T($il_y_a, array("delai" => $delai)); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | |
@@ -442,32 +442,32 @@ discard block |
||
| 442 | 442 | **/ |
| 443 | 443 | function date_relativecourt($date, $decalage_maxi = 0) { |
| 444 | 444 | |
| 445 | - if (!$date) { |
|
| 446 | - return; |
|
| 447 | - } |
|
| 448 | - $decal = date("U", strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 449 | - |
|
| 450 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 451 | - return ''; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - if ($decal < -24 * 3600) { |
|
| 455 | - $retour = date_relative($date, $decalage_maxi); |
|
| 456 | - } elseif ($decal < 0) { |
|
| 457 | - $retour = _T("date_demain"); |
|
| 458 | - } else { |
|
| 459 | - if ($decal < (3600 * 24)) { |
|
| 460 | - $retour = _T("date_aujourdhui"); |
|
| 461 | - } else { |
|
| 462 | - if ($decal < (3600 * 24 * 2)) { |
|
| 463 | - $retour = _T("date_hier"); |
|
| 464 | - } else { |
|
| 465 | - $retour = date_relative($date, $decalage_maxi); |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - return $retour; |
|
| 445 | + if (!$date) { |
|
| 446 | + return; |
|
| 447 | + } |
|
| 448 | + $decal = date("U", strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 449 | + |
|
| 450 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 451 | + return ''; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + if ($decal < -24 * 3600) { |
|
| 455 | + $retour = date_relative($date, $decalage_maxi); |
|
| 456 | + } elseif ($decal < 0) { |
|
| 457 | + $retour = _T("date_demain"); |
|
| 458 | + } else { |
|
| 459 | + if ($decal < (3600 * 24)) { |
|
| 460 | + $retour = _T("date_aujourdhui"); |
|
| 461 | + } else { |
|
| 462 | + if ($decal < (3600 * 24 * 2)) { |
|
| 463 | + $retour = _T("date_hier"); |
|
| 464 | + } else { |
|
| 465 | + $retour = date_relative($date, $decalage_maxi); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + return $retour; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
@@ -486,165 +486,165 @@ discard block |
||
| 486 | 486 | * @return mixed|string |
| 487 | 487 | */ |
| 488 | 488 | function affdate_base($numdate, $vue, $options = array()) { |
| 489 | - if (is_string($options)) { |
|
| 490 | - $options = array('param' => $options); |
|
| 491 | - } |
|
| 492 | - $date_array = recup_date($numdate, false); |
|
| 493 | - if (!$date_array) { |
|
| 494 | - return; |
|
| 495 | - } |
|
| 496 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 497 | - |
|
| 498 | - // 1er, 21st, etc. |
|
| 499 | - $journum = $jour; |
|
| 500 | - |
|
| 501 | - if ($jour == 0) { |
|
| 502 | - $jour = ''; |
|
| 503 | - $njour = 0; |
|
| 504 | - } else { |
|
| 505 | - $njour = intval($jour); |
|
| 506 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 507 | - $jour = $jourth; |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - $mois = intval($mois); |
|
| 512 | - if ($mois > 0 and $mois < 13) { |
|
| 513 | - $nommois = _T('date_mois_' . $mois); |
|
| 514 | - if ($jour) { |
|
| 515 | - $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 516 | - } else { |
|
| 517 | - $jourmois = $nommois; |
|
| 518 | - } |
|
| 519 | - } else { |
|
| 520 | - $nommois = ''; |
|
| 521 | - $jourmois = ''; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - if ($annee < 0) { |
|
| 525 | - $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 526 | - $avjc = true; |
|
| 527 | - } else { |
|
| 528 | - $avjc = false; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - switch ($vue) { |
|
| 532 | - case 'saison': |
|
| 533 | - case 'saison_annee': |
|
| 534 | - $saison = ''; |
|
| 535 | - if ($mois > 0) { |
|
| 536 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 537 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 538 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 539 | - } |
|
| 540 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 541 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 542 | - } |
|
| 543 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 544 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 545 | - } |
|
| 546 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 547 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 548 | - } |
|
| 549 | - } |
|
| 550 | - if ($vue == 'saison') { |
|
| 551 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 552 | - } else { |
|
| 553 | - return $saison ? trim(_T('date_fmt_saison_annee', |
|
| 554 | - array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - case 'court': |
|
| 558 | - if ($avjc) { |
|
| 559 | - return $annee; |
|
| 560 | - } |
|
| 561 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 562 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 563 | - return $annee; |
|
| 564 | - } |
|
| 565 | - if ($annee != $a) { |
|
| 566 | - return _T('date_fmt_mois_annee', |
|
| 567 | - array('mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee)); |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - return _T('date_fmt_jour_mois', |
|
| 571 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 572 | - |
|
| 573 | - case 'jourcourt': |
|
| 574 | - if ($avjc) { |
|
| 575 | - return $annee; |
|
| 576 | - } |
|
| 577 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 578 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 579 | - return $annee; |
|
| 580 | - } |
|
| 581 | - if ($annee != $a) { |
|
| 582 | - return _T('date_fmt_jour_mois_annee', |
|
| 583 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - return _T('date_fmt_jour_mois', |
|
| 587 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 588 | - |
|
| 589 | - case 'entier': |
|
| 590 | - if ($avjc) { |
|
| 591 | - return $annee; |
|
| 592 | - } |
|
| 593 | - if ($jour) { |
|
| 594 | - return _T('date_fmt_jour_mois_annee', |
|
| 595 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 596 | - } elseif ($mois) { |
|
| 597 | - return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 598 | - } else { |
|
| 599 | - return $annee; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - case 'nom_mois': |
|
| 603 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 604 | - if ($param and $mois) { |
|
| 605 | - return _T('date_mois_' . $mois . $param); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - return $nommois; |
|
| 609 | - |
|
| 610 | - case 'mois': |
|
| 611 | - return sprintf("%02s", $mois); |
|
| 612 | - |
|
| 613 | - case 'jour': |
|
| 614 | - return $jour; |
|
| 615 | - |
|
| 616 | - case 'journum': |
|
| 617 | - return $journum; |
|
| 618 | - |
|
| 619 | - case 'nom_jour': |
|
| 620 | - if (!$mois or !$njour) { |
|
| 621 | - return ''; |
|
| 622 | - } |
|
| 623 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 624 | - $nom = 1 + date('w', $nom); |
|
| 625 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 626 | - |
|
| 627 | - return _T('date_jour_' . $nom . $param); |
|
| 628 | - |
|
| 629 | - case 'mois_annee': |
|
| 630 | - if ($avjc) { |
|
| 631 | - return $annee; |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 635 | - |
|
| 636 | - case 'annee': |
|
| 637 | - return $annee; |
|
| 638 | - |
|
| 639 | - // Cas d'une vue non definie : retomber sur le format |
|
| 640 | - // de date propose par http://www.php.net/date |
|
| 641 | - default: |
|
| 642 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 643 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 644 | - $time = strtotime($numdate); |
|
| 645 | - } |
|
| 646 | - return date($vue, $time); |
|
| 647 | - } |
|
| 489 | + if (is_string($options)) { |
|
| 490 | + $options = array('param' => $options); |
|
| 491 | + } |
|
| 492 | + $date_array = recup_date($numdate, false); |
|
| 493 | + if (!$date_array) { |
|
| 494 | + return; |
|
| 495 | + } |
|
| 496 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 497 | + |
|
| 498 | + // 1er, 21st, etc. |
|
| 499 | + $journum = $jour; |
|
| 500 | + |
|
| 501 | + if ($jour == 0) { |
|
| 502 | + $jour = ''; |
|
| 503 | + $njour = 0; |
|
| 504 | + } else { |
|
| 505 | + $njour = intval($jour); |
|
| 506 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 507 | + $jour = $jourth; |
|
| 508 | + } |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + $mois = intval($mois); |
|
| 512 | + if ($mois > 0 and $mois < 13) { |
|
| 513 | + $nommois = _T('date_mois_' . $mois); |
|
| 514 | + if ($jour) { |
|
| 515 | + $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 516 | + } else { |
|
| 517 | + $jourmois = $nommois; |
|
| 518 | + } |
|
| 519 | + } else { |
|
| 520 | + $nommois = ''; |
|
| 521 | + $jourmois = ''; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + if ($annee < 0) { |
|
| 525 | + $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 526 | + $avjc = true; |
|
| 527 | + } else { |
|
| 528 | + $avjc = false; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + switch ($vue) { |
|
| 532 | + case 'saison': |
|
| 533 | + case 'saison_annee': |
|
| 534 | + $saison = ''; |
|
| 535 | + if ($mois > 0) { |
|
| 536 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 537 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 538 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 539 | + } |
|
| 540 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 541 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 542 | + } |
|
| 543 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 544 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 545 | + } |
|
| 546 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 547 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | + if ($vue == 'saison') { |
|
| 551 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 552 | + } else { |
|
| 553 | + return $saison ? trim(_T('date_fmt_saison_annee', |
|
| 554 | + array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + case 'court': |
|
| 558 | + if ($avjc) { |
|
| 559 | + return $annee; |
|
| 560 | + } |
|
| 561 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 562 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 563 | + return $annee; |
|
| 564 | + } |
|
| 565 | + if ($annee != $a) { |
|
| 566 | + return _T('date_fmt_mois_annee', |
|
| 567 | + array('mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee)); |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + return _T('date_fmt_jour_mois', |
|
| 571 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 572 | + |
|
| 573 | + case 'jourcourt': |
|
| 574 | + if ($avjc) { |
|
| 575 | + return $annee; |
|
| 576 | + } |
|
| 577 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 578 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 579 | + return $annee; |
|
| 580 | + } |
|
| 581 | + if ($annee != $a) { |
|
| 582 | + return _T('date_fmt_jour_mois_annee', |
|
| 583 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + return _T('date_fmt_jour_mois', |
|
| 587 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 588 | + |
|
| 589 | + case 'entier': |
|
| 590 | + if ($avjc) { |
|
| 591 | + return $annee; |
|
| 592 | + } |
|
| 593 | + if ($jour) { |
|
| 594 | + return _T('date_fmt_jour_mois_annee', |
|
| 595 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 596 | + } elseif ($mois) { |
|
| 597 | + return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 598 | + } else { |
|
| 599 | + return $annee; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + case 'nom_mois': |
|
| 603 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 604 | + if ($param and $mois) { |
|
| 605 | + return _T('date_mois_' . $mois . $param); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + return $nommois; |
|
| 609 | + |
|
| 610 | + case 'mois': |
|
| 611 | + return sprintf("%02s", $mois); |
|
| 612 | + |
|
| 613 | + case 'jour': |
|
| 614 | + return $jour; |
|
| 615 | + |
|
| 616 | + case 'journum': |
|
| 617 | + return $journum; |
|
| 618 | + |
|
| 619 | + case 'nom_jour': |
|
| 620 | + if (!$mois or !$njour) { |
|
| 621 | + return ''; |
|
| 622 | + } |
|
| 623 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 624 | + $nom = 1 + date('w', $nom); |
|
| 625 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 626 | + |
|
| 627 | + return _T('date_jour_' . $nom . $param); |
|
| 628 | + |
|
| 629 | + case 'mois_annee': |
|
| 630 | + if ($avjc) { |
|
| 631 | + return $annee; |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 635 | + |
|
| 636 | + case 'annee': |
|
| 637 | + return $annee; |
|
| 638 | + |
|
| 639 | + // Cas d'une vue non definie : retomber sur le format |
|
| 640 | + // de date propose par http://www.php.net/date |
|
| 641 | + default: |
|
| 642 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 643 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 644 | + $time = strtotime($numdate); |
|
| 645 | + } |
|
| 646 | + return date($vue, $time); |
|
| 647 | + } |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | |
@@ -671,11 +671,11 @@ discard block |
||
| 671 | 671 | * Nom du jour |
| 672 | 672 | **/ |
| 673 | 673 | function nom_jour($numdate, $forme = '') { |
| 674 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 675 | - $forme = ''; |
|
| 676 | - } |
|
| 674 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 675 | + $forme = ''; |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 678 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | * Numéro du jour |
| 698 | 698 | **/ |
| 699 | 699 | function jour($numdate) { |
| 700 | - return affdate_base($numdate, 'jour'); |
|
| 700 | + return affdate_base($numdate, 'jour'); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | * Numéro du jour |
| 716 | 716 | **/ |
| 717 | 717 | function journum($numdate) { |
| 718 | - return affdate_base($numdate, 'journum'); |
|
| 718 | + return affdate_base($numdate, 'journum'); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | * Numéro du mois (sur 2 chiffres) |
| 734 | 734 | **/ |
| 735 | 735 | function mois($numdate) { |
| 736 | - return affdate_base($numdate, 'mois'); |
|
| 736 | + return affdate_base($numdate, 'mois'); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | /** |
@@ -757,11 +757,11 @@ discard block |
||
| 757 | 757 | * Nom du mois |
| 758 | 758 | **/ |
| 759 | 759 | function nom_mois($numdate, $forme = '') { |
| 760 | - if (!($forme == 'abbr')) { |
|
| 761 | - $forme = ''; |
|
| 762 | - } |
|
| 760 | + if (!($forme == 'abbr')) { |
|
| 761 | + $forme = ''; |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 764 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | * Année (sur 4 chiffres) |
| 780 | 780 | **/ |
| 781 | 781 | function annee($numdate) { |
| 782 | - return affdate_base($numdate, 'annee'); |
|
| 782 | + return affdate_base($numdate, 'annee'); |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | |
@@ -809,11 +809,11 @@ discard block |
||
| 809 | 809 | * La date formatée |
| 810 | 810 | **/ |
| 811 | 811 | function saison($numdate, $hemisphere = 'nord') { |
| 812 | - if ($hemisphere != 'sud') { |
|
| 813 | - $hemisphere = 'nord'; |
|
| 814 | - } |
|
| 812 | + if ($hemisphere != 'sud') { |
|
| 813 | + $hemisphere = 'nord'; |
|
| 814 | + } |
|
| 815 | 815 | |
| 816 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 816 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | |
@@ -842,11 +842,11 @@ discard block |
||
| 842 | 842 | * La date formatée |
| 843 | 843 | **/ |
| 844 | 844 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 845 | - if ($hemisphere != 'sud') { |
|
| 846 | - $hemisphere = 'nord'; |
|
| 847 | - } |
|
| 845 | + if ($hemisphere != 'sud') { |
|
| 846 | + $hemisphere = 'nord'; |
|
| 847 | + } |
|
| 848 | 848 | |
| 849 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 849 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * La date formatée |
| 875 | 875 | **/ |
| 876 | 876 | function affdate($numdate, $format = 'entier') { |
| 877 | - return affdate_base($numdate, $format); |
|
| 877 | + return affdate_base($numdate, $format); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | * La date formatée |
| 902 | 902 | **/ |
| 903 | 903 | function affdate_court($numdate, $annee_courante = null) { |
| 904 | - return affdate_base($numdate, 'court', array('annee_courante' => $annee_courante)); |
|
| 904 | + return affdate_base($numdate, 'court', array('annee_courante' => $annee_courante)); |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | * La date formatée |
| 929 | 929 | **/ |
| 930 | 930 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 931 | - return affdate_base($numdate, 'jourcourt', array('annee_courante' => $annee_courante)); |
|
| 931 | + return affdate_base($numdate, 'jourcourt', array('annee_courante' => $annee_courante)); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | * La date formatée |
| 947 | 947 | **/ |
| 948 | 948 | function affdate_mois_annee($numdate) { |
| 949 | - return affdate_base($numdate, 'mois_annee'); |
|
| 949 | + return affdate_base($numdate, 'mois_annee'); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | /** |
@@ -964,16 +964,16 @@ discard block |
||
| 964 | 964 | * La date formatée |
| 965 | 965 | **/ |
| 966 | 966 | function affdate_heure($numdate) { |
| 967 | - $date_array = recup_date($numdate); |
|
| 968 | - if (!$date_array) { |
|
| 969 | - return; |
|
| 970 | - } |
|
| 971 | - list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 972 | - |
|
| 973 | - return _T('date_fmt_jour_heure', array( |
|
| 974 | - 'jour' => affdate($numdate), |
|
| 975 | - 'heure' => _T('date_fmt_heures_minutes', array('h' => $heures, 'm' => $minutes)) |
|
| 976 | - )); |
|
| 967 | + $date_array = recup_date($numdate); |
|
| 968 | + if (!$date_array) { |
|
| 969 | + return; |
|
| 970 | + } |
|
| 971 | + list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 972 | + |
|
| 973 | + return _T('date_fmt_jour_heure', array( |
|
| 974 | + 'jour' => affdate($numdate), |
|
| 975 | + 'heure' => _T('date_fmt_heures_minutes', array('h' => $heures, 'm' => $minutes)) |
|
| 976 | + )); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -1005,114 +1005,114 @@ discard block |
||
| 1005 | 1005 | * Texte de la date |
| 1006 | 1006 | */ |
| 1007 | 1007 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1008 | - $abbr = $jour = ''; |
|
| 1009 | - $affdate = "affdate_jourcourt"; |
|
| 1010 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1011 | - $abbr = 'abbr'; |
|
| 1012 | - } |
|
| 1013 | - if (strpos($forme, 'annee') !== false) { |
|
| 1014 | - $affdate = 'affdate'; |
|
| 1015 | - } |
|
| 1016 | - if (strpos($forme, 'jour') !== false) { |
|
| 1017 | - $jour = 'jour'; |
|
| 1018 | - } |
|
| 1019 | - |
|
| 1020 | - $dtstart = $dtend = $dtabbr = ""; |
|
| 1021 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1022 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1023 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1024 | - $dtabbr = "</abbr>"; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - $date_debut = strtotime($date_debut); |
|
| 1028 | - $date_fin = strtotime($date_fin); |
|
| 1029 | - $d = date("Y-m-d", $date_debut); |
|
| 1030 | - $f = date("Y-m-d", $date_fin); |
|
| 1031 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1032 | - $hd = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_debut), 'm' => date("i", $date_debut))); |
|
| 1033 | - $hf = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_fin), 'm' => date("i", $date_fin))); |
|
| 1034 | - |
|
| 1035 | - if ($d == $f) { // meme jour |
|
| 1036 | - $nomjour = nom_jour($d, $abbr); |
|
| 1037 | - $s = $affdate($d); |
|
| 1038 | - $s = _T('date_fmt_jour', array('nomjour' => $nomjour, 'jour' => $s)); |
|
| 1039 | - if ($h) { |
|
| 1040 | - if ($hd == $hf) { |
|
| 1041 | - // Lundi 20 fevrier a 18h25 |
|
| 1042 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', array('jour' => $s, 'heure' => $hd))); |
|
| 1043 | - $s = "$dtstart$s$dtabbr"; |
|
| 1044 | - } else { |
|
| 1045 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1046 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1047 | - $s = _T('date_fmt_jour_heure_debut_fin_abbr', array( |
|
| 1048 | - 'jour' => spip_ucfirst($s), |
|
| 1049 | - 'heure_debut' => $hd, |
|
| 1050 | - 'heure_fin' => $hf, |
|
| 1051 | - 'dtstart' => $dtstart, |
|
| 1052 | - 'dtend' => $dtend, |
|
| 1053 | - 'dtabbr' => $dtabbr |
|
| 1054 | - ), |
|
| 1055 | - array( |
|
| 1056 | - 'sanitize' => false |
|
| 1057 | - ) |
|
| 1058 | - ); |
|
| 1059 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1060 | - else { |
|
| 1061 | - $s = spip_ucfirst(_T('date_fmt_jour_heure_debut_fin', |
|
| 1062 | - array('jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf))); |
|
| 1063 | - } |
|
| 1064 | - } |
|
| 1065 | - } else { |
|
| 1066 | - if ($dtabbr && $dtstart) { |
|
| 1067 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1068 | - } else { |
|
| 1069 | - $s = spip_ucfirst($s); |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - } else { |
|
| 1073 | - if ((date("Y-m", $date_debut)) == date("Y-m", $date_fin)) { // meme annee et mois, jours differents |
|
| 1074 | - if (!$h) { |
|
| 1075 | - $date_debut = jour($d); |
|
| 1076 | - } else { |
|
| 1077 | - $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1078 | - } |
|
| 1079 | - $date_fin = $affdate($f); |
|
| 1080 | - if ($jour) { |
|
| 1081 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1082 | - $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1083 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1084 | - $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1085 | - } |
|
| 1086 | - if ($h) { |
|
| 1087 | - $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1088 | - $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1089 | - } |
|
| 1090 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1091 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1092 | - |
|
| 1093 | - $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1094 | - } else { |
|
| 1095 | - $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1096 | - $date_fin = $affdate($f); |
|
| 1097 | - if ($jour) { |
|
| 1098 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1099 | - $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1100 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1101 | - $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1102 | - } |
|
| 1103 | - if ($h) { |
|
| 1104 | - $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1105 | - $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1109 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1110 | - $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1111 | - |
|
| 1112 | - } |
|
| 1113 | - } |
|
| 1114 | - |
|
| 1115 | - return $s; |
|
| 1008 | + $abbr = $jour = ''; |
|
| 1009 | + $affdate = "affdate_jourcourt"; |
|
| 1010 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1011 | + $abbr = 'abbr'; |
|
| 1012 | + } |
|
| 1013 | + if (strpos($forme, 'annee') !== false) { |
|
| 1014 | + $affdate = 'affdate'; |
|
| 1015 | + } |
|
| 1016 | + if (strpos($forme, 'jour') !== false) { |
|
| 1017 | + $jour = 'jour'; |
|
| 1018 | + } |
|
| 1019 | + |
|
| 1020 | + $dtstart = $dtend = $dtabbr = ""; |
|
| 1021 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1022 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1023 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1024 | + $dtabbr = "</abbr>"; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + $date_debut = strtotime($date_debut); |
|
| 1028 | + $date_fin = strtotime($date_fin); |
|
| 1029 | + $d = date("Y-m-d", $date_debut); |
|
| 1030 | + $f = date("Y-m-d", $date_fin); |
|
| 1031 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1032 | + $hd = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_debut), 'm' => date("i", $date_debut))); |
|
| 1033 | + $hf = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_fin), 'm' => date("i", $date_fin))); |
|
| 1034 | + |
|
| 1035 | + if ($d == $f) { // meme jour |
|
| 1036 | + $nomjour = nom_jour($d, $abbr); |
|
| 1037 | + $s = $affdate($d); |
|
| 1038 | + $s = _T('date_fmt_jour', array('nomjour' => $nomjour, 'jour' => $s)); |
|
| 1039 | + if ($h) { |
|
| 1040 | + if ($hd == $hf) { |
|
| 1041 | + // Lundi 20 fevrier a 18h25 |
|
| 1042 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', array('jour' => $s, 'heure' => $hd))); |
|
| 1043 | + $s = "$dtstart$s$dtabbr"; |
|
| 1044 | + } else { |
|
| 1045 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1046 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1047 | + $s = _T('date_fmt_jour_heure_debut_fin_abbr', array( |
|
| 1048 | + 'jour' => spip_ucfirst($s), |
|
| 1049 | + 'heure_debut' => $hd, |
|
| 1050 | + 'heure_fin' => $hf, |
|
| 1051 | + 'dtstart' => $dtstart, |
|
| 1052 | + 'dtend' => $dtend, |
|
| 1053 | + 'dtabbr' => $dtabbr |
|
| 1054 | + ), |
|
| 1055 | + array( |
|
| 1056 | + 'sanitize' => false |
|
| 1057 | + ) |
|
| 1058 | + ); |
|
| 1059 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1060 | + else { |
|
| 1061 | + $s = spip_ucfirst(_T('date_fmt_jour_heure_debut_fin', |
|
| 1062 | + array('jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf))); |
|
| 1063 | + } |
|
| 1064 | + } |
|
| 1065 | + } else { |
|
| 1066 | + if ($dtabbr && $dtstart) { |
|
| 1067 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1068 | + } else { |
|
| 1069 | + $s = spip_ucfirst($s); |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + } else { |
|
| 1073 | + if ((date("Y-m", $date_debut)) == date("Y-m", $date_fin)) { // meme annee et mois, jours differents |
|
| 1074 | + if (!$h) { |
|
| 1075 | + $date_debut = jour($d); |
|
| 1076 | + } else { |
|
| 1077 | + $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1078 | + } |
|
| 1079 | + $date_fin = $affdate($f); |
|
| 1080 | + if ($jour) { |
|
| 1081 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1082 | + $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1083 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1084 | + $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1085 | + } |
|
| 1086 | + if ($h) { |
|
| 1087 | + $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1088 | + $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1089 | + } |
|
| 1090 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1091 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1092 | + |
|
| 1093 | + $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1094 | + } else { |
|
| 1095 | + $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1096 | + $date_fin = $affdate($f); |
|
| 1097 | + if ($jour) { |
|
| 1098 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1099 | + $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1100 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1101 | + $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1102 | + } |
|
| 1103 | + if ($h) { |
|
| 1104 | + $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1105 | + $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1109 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1110 | + $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1111 | + |
|
| 1112 | + } |
|
| 1113 | + } |
|
| 1114 | + |
|
| 1115 | + return $s; |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | /** |
@@ -1133,10 +1133,10 @@ discard block |
||
| 1133 | 1133 | * Date au format ical |
| 1134 | 1134 | **/ |
| 1135 | 1135 | function date_ical($date, $addminutes = 0) { |
| 1136 | - list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1137 | - list($annee, $mois, $jour) = recup_date($date); |
|
| 1136 | + list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1137 | + list($annee, $mois, $jour) = recup_date($date); |
|
| 1138 | 1138 | |
| 1139 | - return gmdate("Ymd\THis\Z", mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1139 | + return gmdate("Ymd\THis\Z", mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | |
@@ -1160,11 +1160,11 @@ discard block |
||
| 1160 | 1160 | * La date formatée |
| 1161 | 1161 | **/ |
| 1162 | 1162 | function date_iso($date_heure) { |
| 1163 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1164 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1165 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1163 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1164 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1165 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1166 | 1166 | |
| 1167 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1167 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | /** |
@@ -1187,11 +1187,11 @@ discard block |
||
| 1187 | 1187 | * La date formatée |
| 1188 | 1188 | **/ |
| 1189 | 1189 | function date_822($date_heure) { |
| 1190 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1191 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1192 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1190 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1191 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1192 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1193 | 1193 | |
| 1194 | - return date('r', $time); |
|
| 1194 | + return date('r', $time); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1207,11 +1207,11 @@ discard block |
||
| 1207 | 1207 | * Date au format `Ymd` |
| 1208 | 1208 | **/ |
| 1209 | 1209 | function date_anneemoisjour($d) { |
| 1210 | - if (!$d) { |
|
| 1211 | - $d = date("Y-m-d"); |
|
| 1212 | - } |
|
| 1210 | + if (!$d) { |
|
| 1211 | + $d = date("Y-m-d"); |
|
| 1212 | + } |
|
| 1213 | 1213 | |
| 1214 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1214 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | /** |
@@ -1227,11 +1227,11 @@ discard block |
||
| 1227 | 1227 | * Date au format `Ym` |
| 1228 | 1228 | **/ |
| 1229 | 1229 | function date_anneemois($d) { |
| 1230 | - if (!$d) { |
|
| 1231 | - $d = date("Y-m-d"); |
|
| 1232 | - } |
|
| 1230 | + if (!$d) { |
|
| 1231 | + $d = date("Y-m-d"); |
|
| 1232 | + } |
|
| 1233 | 1233 | |
| 1234 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1234 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | /** |
@@ -1247,13 +1247,13 @@ discard block |
||
| 1247 | 1247 | * Date au lundi de la même semaine au format `Ymd` |
| 1248 | 1248 | **/ |
| 1249 | 1249 | function date_debut_semaine($annee, $mois, $jour) { |
| 1250 | - $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1251 | - if ($w_day == 0) { |
|
| 1252 | - $w_day = 7; |
|
| 1253 | - } // Gaffe: le dimanche est zero |
|
| 1254 | - $debut = $jour - $w_day + 1; |
|
| 1250 | + $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1251 | + if ($w_day == 0) { |
|
| 1252 | + $w_day = 7; |
|
| 1253 | + } // Gaffe: le dimanche est zero |
|
| 1254 | + $debut = $jour - $w_day + 1; |
|
| 1255 | 1255 | |
| 1256 | - return date("Ymd", mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1256 | + return date("Ymd", mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | /** |
@@ -1269,12 +1269,12 @@ discard block |
||
| 1269 | 1269 | * Date au dimanche de la même semaine au format `Ymd` |
| 1270 | 1270 | **/ |
| 1271 | 1271 | function date_fin_semaine($annee, $mois, $jour) { |
| 1272 | - $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1273 | - if ($w_day == 0) { |
|
| 1274 | - $w_day = 7; |
|
| 1275 | - } // Gaffe: le dimanche est zero |
|
| 1276 | - $debut = $jour - $w_day + 1; |
|
| 1272 | + $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1273 | + if ($w_day == 0) { |
|
| 1274 | + $w_day = 7; |
|
| 1275 | + } // Gaffe: le dimanche est zero |
|
| 1276 | + $debut = $jour - $w_day + 1; |
|
| 1277 | 1277 | |
| 1278 | - return date("Ymd", mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1278 | + return date("Ymd", mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | if (strncmp($url, 'configurer_', 11) == 0) { |
| 341 | 341 | $deja[$url] = $b; |
| 342 | 342 | } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
| 343 | - $deja["configurer_" . $match[1]] = $b; |
|
| 343 | + $deja["configurer_".$match[1]] = $b; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
@@ -354,10 +354,10 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | // trouver toutes les pages configurer_xxx de l'espace prive |
| 356 | 356 | // et construire un tableau des entrees qui ne sont pas dans $deja |
| 357 | - $pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$'); |
|
| 357 | + $pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]"._EXTENSION_SQUELETTES.'$'); |
|
| 358 | 358 | |
| 359 | 359 | foreach ($pages as $page) { |
| 360 | - $configurer = basename($page, "." . _EXTENSION_SQUELETTES); |
|
| 360 | + $configurer = basename($page, "."._EXTENSION_SQUELETTES); |
|
| 361 | 361 | if (!isset($exclure[$configurer])) { |
| 362 | 362 | $liste[$configurer] = array( |
| 363 | 363 | 'parent' => 'bando_configuration', |
@@ -377,9 +377,9 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | // trouver tous les formulaires/configurer_ |
| 379 | 379 | // et construire un tableau des entrees |
| 380 | - $pages = find_all_in_path("formulaires/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$'); |
|
| 380 | + $pages = find_all_in_path("formulaires/", "configurer_.*[.]"._EXTENSION_SQUELETTES.'$'); |
|
| 381 | 381 | foreach ($pages as $page) { |
| 382 | - $configurer = basename($page, "." . _EXTENSION_SQUELETTES); |
|
| 382 | + $configurer = basename($page, "."._EXTENSION_SQUELETTES); |
|
| 383 | 383 | if (!isset($forms[$configurer]) |
| 384 | 384 | and !isset($liste[$configurer]) |
| 385 | 385 | and !isset($exclure[$configurer]) |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $liste[$configurer] = array( |
| 388 | 388 | 'parent' => 'bando_configuration', |
| 389 | 389 | 'url' => 'configurer', |
| 390 | - 'args' => 'cfg=' . substr($configurer, 11), |
|
| 390 | + 'args' => 'cfg='.substr($configurer, 11), |
|
| 391 | 391 | 'titre' => _T("configurer:{$configurer}_titre"), |
| 392 | 392 | 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
| 393 | 393 | ); |
@@ -419,8 +419,8 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
| 421 | 421 | // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
| 422 | - $config = basename(substr($file, 0, -strlen("." . _EXTENSION_SQUELETTES))); |
|
| 423 | - spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 422 | + $config = basename(substr($file, 0, -strlen("."._EXTENSION_SQUELETTES))); |
|
| 423 | + spip_log('Calcul de '."prive/squelettes/contenu/$config"); |
|
| 424 | 424 | $fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config)); |
| 425 | 425 | |
| 426 | 426 | // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function inc_config_dist() { |
| 31 | - actualise_metas(liste_metas()); |
|
| 31 | + actualise_metas(liste_metas()); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -45,34 +45,34 @@ discard block |
||
| 45 | 45 | * Liste (table, casier, sous_casier) |
| 46 | 46 | */ |
| 47 | 47 | function expliquer_config($cfg) { |
| 48 | - // par defaut, sur la table des meta |
|
| 49 | - $table = 'meta'; |
|
| 50 | - $casier = null; |
|
| 51 | - $sous_casier = array(); |
|
| 52 | - $cfg = explode('/', $cfg); |
|
| 53 | - |
|
| 54 | - // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | - if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | - array_shift($cfg); |
|
| 57 | - $table = array_shift($cfg); |
|
| 58 | - if (!isset($GLOBALS[$table])) { |
|
| 59 | - lire_metas($table); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | - if (count($cfg)) { |
|
| 65 | - // pas sur un appel vide '' |
|
| 66 | - if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | - $casier = $c; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if (count($cfg)) { |
|
| 72 | - $sous_casier = $cfg; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return array($table, $casier, $sous_casier); |
|
| 48 | + // par defaut, sur la table des meta |
|
| 49 | + $table = 'meta'; |
|
| 50 | + $casier = null; |
|
| 51 | + $sous_casier = array(); |
|
| 52 | + $cfg = explode('/', $cfg); |
|
| 53 | + |
|
| 54 | + // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | + if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | + array_shift($cfg); |
|
| 57 | + $table = array_shift($cfg); |
|
| 58 | + if (!isset($GLOBALS[$table])) { |
|
| 59 | + lire_metas($table); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | + if (count($cfg)) { |
|
| 65 | + // pas sur un appel vide '' |
|
| 66 | + if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | + $casier = $c; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if (count($cfg)) { |
|
| 72 | + $sous_casier = $cfg; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return array($table, $casier, $sous_casier); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -100,65 +100,65 @@ discard block |
||
| 100 | 100 | * Contenu de la configuration obtenue |
| 101 | 101 | */ |
| 102 | 102 | function lire_config($cfg = '', $def = null, $unserialize = true) { |
| 103 | - // lire le stockage sous la forme /table/valeur |
|
| 104 | - // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | - // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | - |
|
| 107 | - // traiter en priorite le cas simple et frequent |
|
| 108 | - // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | - if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | - $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | - ((!$unserialize |
|
| 112 | - // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | - or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | - // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | - or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | - or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | - : $def; |
|
| 118 | - |
|
| 119 | - return $r; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // Brancher sur methodes externes si besoin |
|
| 123 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | - $methode = substr($cfg, 0, $p); |
|
| 125 | - $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | - |
|
| 127 | - return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 131 | - |
|
| 132 | - if (!isset($GLOBALS[$table])) { |
|
| 133 | - return $def; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $r = $GLOBALS[$table]; |
|
| 137 | - |
|
| 138 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | - if (!$casier) { |
|
| 140 | - return $unserialize ? $r : serialize($r); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // casier principal : |
|
| 144 | - // le deserializer si demande |
|
| 145 | - // ou si on a besoin |
|
| 146 | - // d'un sous casier |
|
| 147 | - $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 148 | - if (($unserialize or count($sous_casier)) and $r and is_string($r)) { |
|
| 149 | - $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // aller chercher le sous_casier |
|
| 153 | - while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | - $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (is_null($r)) { |
|
| 158 | - return $def; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $r; |
|
| 103 | + // lire le stockage sous la forme /table/valeur |
|
| 104 | + // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | + // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | + |
|
| 107 | + // traiter en priorite le cas simple et frequent |
|
| 108 | + // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | + if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | + $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | + ((!$unserialize |
|
| 112 | + // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | + or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | + // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | + or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | + or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | + : $def; |
|
| 118 | + |
|
| 119 | + return $r; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // Brancher sur methodes externes si besoin |
|
| 123 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | + $methode = substr($cfg, 0, $p); |
|
| 125 | + $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | + |
|
| 127 | + return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 131 | + |
|
| 132 | + if (!isset($GLOBALS[$table])) { |
|
| 133 | + return $def; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $r = $GLOBALS[$table]; |
|
| 137 | + |
|
| 138 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | + if (!$casier) { |
|
| 140 | + return $unserialize ? $r : serialize($r); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // casier principal : |
|
| 144 | + // le deserializer si demande |
|
| 145 | + // ou si on a besoin |
|
| 146 | + // d'un sous casier |
|
| 147 | + $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 148 | + if (($unserialize or count($sous_casier)) and $r and is_string($r)) { |
|
| 149 | + $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // aller chercher le sous_casier |
|
| 153 | + while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | + $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (is_null($r)) { |
|
| 158 | + return $def; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $r; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @return mixed |
| 173 | 173 | */ |
| 174 | 174 | function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) { |
| 175 | - return lire_config($cfg, $def, $unserialize); |
|
| 175 | + return lire_config($cfg, $def, $unserialize); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -184,103 +184,103 @@ discard block |
||
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | 186 | function ecrire_config($cfg, $store) { |
| 187 | - // Brancher sur methodes externes si besoin |
|
| 188 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | - $methode = substr($cfg, 0, $p); |
|
| 190 | - $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | - |
|
| 192 | - return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 196 | - // il faut au moins un casier pour ecrire |
|
| 197 | - if (!$casier) { |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // trouvons ou creons le pointeur sur le casier |
|
| 202 | - $st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null; |
|
| 203 | - if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | - $st = unserialize($st); |
|
| 205 | - if ($st === false) { |
|
| 206 | - // ne rien creer si c'est une demande d'effacement |
|
| 207 | - if (is_null($store)) { |
|
| 208 | - return false; |
|
| 209 | - } |
|
| 210 | - $st = array(); |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - // si on a affaire a un sous caiser |
|
| 215 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 216 | - if ($c = $sous_casier) { |
|
| 217 | - $sc = &$st; |
|
| 218 | - $pointeurs = array(); |
|
| 219 | - while (count($c) and $cc = array_shift($c)) { |
|
| 220 | - // creer l'entree si elle n'existe pas |
|
| 221 | - if (!isset($sc[$cc])) { |
|
| 222 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 223 | - // ne rien creer mais sortir |
|
| 224 | - if (is_null($store)) { |
|
| 225 | - return false; |
|
| 226 | - } |
|
| 227 | - $sc[$cc] = array(); |
|
| 228 | - } |
|
| 229 | - $pointeurs[$cc] = &$sc; |
|
| 230 | - $sc = &$sc[$cc]; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // si c'est une demande d'effacement |
|
| 234 | - if (is_null($store)) { |
|
| 235 | - $c = $sous_casier; |
|
| 236 | - $sous = array_pop($c); |
|
| 237 | - // effacer, et remonter pour effacer les parents vides |
|
| 238 | - do { |
|
| 239 | - unset($pointeurs[$sous][$sous]); |
|
| 240 | - } while ($sous = array_pop($c) and !count($pointeurs[$sous][$sous])); |
|
| 241 | - |
|
| 242 | - // si on a vide tous les sous casiers, |
|
| 243 | - // et que le casier est vide |
|
| 244 | - // vider aussi la meta |
|
| 245 | - if (!$sous and !count($st)) { |
|
| 246 | - $st = null; |
|
| 247 | - } |
|
| 248 | - } // dans tous les autres cas, on ecrase |
|
| 249 | - else { |
|
| 250 | - $sc = $store; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - // Maintenant que $st est modifiee |
|
| 254 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 255 | - $store = $st; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if (is_null($store)) { |
|
| 259 | - if (is_null($st) and !$sous_casier) { |
|
| 260 | - return false; |
|
| 261 | - } // la config n'existait deja pas ! |
|
| 262 | - effacer_meta($casier, $table); |
|
| 263 | - if (!count($GLOBALS[$table]) |
|
| 264 | - or count($GLOBALS[$table]) == 1 and isset($GLOBALS[$table]['charset']) |
|
| 265 | - ) { |
|
| 266 | - effacer_meta('charset', $table); // enlevons cette meta |
|
| 267 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 268 | - } |
|
| 269 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 270 | - else { |
|
| 271 | - if (!isset($GLOBALS[$table])) { |
|
| 272 | - installer_table_meta($table); |
|
| 273 | - } |
|
| 274 | - // si ce n'est pas une chaine |
|
| 275 | - // il faut serializer |
|
| 276 | - if (!is_string($store)) { |
|
| 277 | - $store = serialize($store); |
|
| 278 | - } |
|
| 279 | - ecrire_meta($casier, $store, null, $table); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // verifier que lire_config($cfg)==$store ? |
|
| 283 | - return true; |
|
| 187 | + // Brancher sur methodes externes si besoin |
|
| 188 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | + $methode = substr($cfg, 0, $p); |
|
| 190 | + $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | + |
|
| 192 | + return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 196 | + // il faut au moins un casier pour ecrire |
|
| 197 | + if (!$casier) { |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // trouvons ou creons le pointeur sur le casier |
|
| 202 | + $st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null; |
|
| 203 | + if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | + $st = unserialize($st); |
|
| 205 | + if ($st === false) { |
|
| 206 | + // ne rien creer si c'est une demande d'effacement |
|
| 207 | + if (is_null($store)) { |
|
| 208 | + return false; |
|
| 209 | + } |
|
| 210 | + $st = array(); |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + // si on a affaire a un sous caiser |
|
| 215 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 216 | + if ($c = $sous_casier) { |
|
| 217 | + $sc = &$st; |
|
| 218 | + $pointeurs = array(); |
|
| 219 | + while (count($c) and $cc = array_shift($c)) { |
|
| 220 | + // creer l'entree si elle n'existe pas |
|
| 221 | + if (!isset($sc[$cc])) { |
|
| 222 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 223 | + // ne rien creer mais sortir |
|
| 224 | + if (is_null($store)) { |
|
| 225 | + return false; |
|
| 226 | + } |
|
| 227 | + $sc[$cc] = array(); |
|
| 228 | + } |
|
| 229 | + $pointeurs[$cc] = &$sc; |
|
| 230 | + $sc = &$sc[$cc]; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // si c'est une demande d'effacement |
|
| 234 | + if (is_null($store)) { |
|
| 235 | + $c = $sous_casier; |
|
| 236 | + $sous = array_pop($c); |
|
| 237 | + // effacer, et remonter pour effacer les parents vides |
|
| 238 | + do { |
|
| 239 | + unset($pointeurs[$sous][$sous]); |
|
| 240 | + } while ($sous = array_pop($c) and !count($pointeurs[$sous][$sous])); |
|
| 241 | + |
|
| 242 | + // si on a vide tous les sous casiers, |
|
| 243 | + // et que le casier est vide |
|
| 244 | + // vider aussi la meta |
|
| 245 | + if (!$sous and !count($st)) { |
|
| 246 | + $st = null; |
|
| 247 | + } |
|
| 248 | + } // dans tous les autres cas, on ecrase |
|
| 249 | + else { |
|
| 250 | + $sc = $store; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + // Maintenant que $st est modifiee |
|
| 254 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 255 | + $store = $st; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if (is_null($store)) { |
|
| 259 | + if (is_null($st) and !$sous_casier) { |
|
| 260 | + return false; |
|
| 261 | + } // la config n'existait deja pas ! |
|
| 262 | + effacer_meta($casier, $table); |
|
| 263 | + if (!count($GLOBALS[$table]) |
|
| 264 | + or count($GLOBALS[$table]) == 1 and isset($GLOBALS[$table]['charset']) |
|
| 265 | + ) { |
|
| 266 | + effacer_meta('charset', $table); // enlevons cette meta |
|
| 267 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 268 | + } |
|
| 269 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 270 | + else { |
|
| 271 | + if (!isset($GLOBALS[$table])) { |
|
| 272 | + installer_table_meta($table); |
|
| 273 | + } |
|
| 274 | + // si ce n'est pas une chaine |
|
| 275 | + // il faut serializer |
|
| 276 | + if (!is_string($store)) { |
|
| 277 | + $store = serialize($store); |
|
| 278 | + } |
|
| 279 | + ecrire_meta($casier, $store, null, $table); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // verifier que lire_config($cfg)==$store ? |
|
| 283 | + return true; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | * @return bool |
| 295 | 295 | */ |
| 296 | 296 | function ecrire_config_metapack_dist($cfg, $store) { |
| 297 | - // cas particulier en metapack:: |
|
| 298 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 299 | - // intacte en sortie ... |
|
| 300 | - if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 301 | - $store = serialize($store); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - return ecrire_config($cfg, $store); |
|
| 297 | + // cas particulier en metapack:: |
|
| 298 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 299 | + // intacte en sortie ... |
|
| 300 | + if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 301 | + $store = serialize($store); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + return ecrire_config($cfg, $store); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | * @return bool |
| 312 | 312 | */ |
| 313 | 313 | function effacer_config($cfg) { |
| 314 | - ecrire_config($cfg, null); |
|
| 314 | + ecrire_config($cfg, null); |
|
| 315 | 315 | |
| 316 | - return true; |
|
| 316 | + return true; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -330,71 +330,71 @@ discard block |
||
| 330 | 330 | * @return array |
| 331 | 331 | */ |
| 332 | 332 | function lister_configurer($exclure = array()) { |
| 333 | - return array(); |
|
| 334 | - |
|
| 335 | - // lister les pages de config deja dans les menus |
|
| 336 | - $deja = array(); |
|
| 337 | - foreach ($exclure as $id => $b) { |
|
| 338 | - $url = ($b['url'] ? $b['url'] : $id); |
|
| 339 | - if (!$b['url'] or !isset($exclure[$url])) { |
|
| 340 | - if (strncmp($url, 'configurer_', 11) == 0) { |
|
| 341 | - $deja[$url] = $b; |
|
| 342 | - } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
|
| 343 | - $deja["configurer_" . $match[1]] = $b; |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - } |
|
| 348 | - $exclure = $exclure + $deja; |
|
| 349 | - |
|
| 350 | - $icone_defaut = "images/configuration-16.png"; |
|
| 351 | - $liste = array(); |
|
| 352 | - $skels = array(); |
|
| 353 | - $forms = array(); |
|
| 354 | - |
|
| 355 | - // trouver toutes les pages configurer_xxx de l'espace prive |
|
| 356 | - // et construire un tableau des entrees qui ne sont pas dans $deja |
|
| 357 | - $pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$'); |
|
| 358 | - |
|
| 359 | - foreach ($pages as $page) { |
|
| 360 | - $configurer = basename($page, "." . _EXTENSION_SQUELETTES); |
|
| 361 | - if (!isset($exclure[$configurer])) { |
|
| 362 | - $liste[$configurer] = array( |
|
| 363 | - 'parent' => 'bando_configuration', |
|
| 364 | - 'url' => $configurer, |
|
| 365 | - 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 366 | - 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 367 | - ); |
|
| 368 | - } |
|
| 369 | - $skels[$configurer] = $page; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus |
|
| 373 | - foreach ($skels as $file) { |
|
| 374 | - $forms = array_merge($forms, lister_formulaires_configurer($file)); |
|
| 375 | - } |
|
| 376 | - $forms = array_flip($forms); |
|
| 377 | - |
|
| 378 | - // trouver tous les formulaires/configurer_ |
|
| 379 | - // et construire un tableau des entrees |
|
| 380 | - $pages = find_all_in_path("formulaires/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$'); |
|
| 381 | - foreach ($pages as $page) { |
|
| 382 | - $configurer = basename($page, "." . _EXTENSION_SQUELETTES); |
|
| 383 | - if (!isset($forms[$configurer]) |
|
| 384 | - and !isset($liste[$configurer]) |
|
| 385 | - and !isset($exclure[$configurer]) |
|
| 386 | - ) { |
|
| 387 | - $liste[$configurer] = array( |
|
| 388 | - 'parent' => 'bando_configuration', |
|
| 389 | - 'url' => 'configurer', |
|
| 390 | - 'args' => 'cfg=' . substr($configurer, 11), |
|
| 391 | - 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 392 | - 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 393 | - ); |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - return $liste; |
|
| 333 | + return array(); |
|
| 334 | + |
|
| 335 | + // lister les pages de config deja dans les menus |
|
| 336 | + $deja = array(); |
|
| 337 | + foreach ($exclure as $id => $b) { |
|
| 338 | + $url = ($b['url'] ? $b['url'] : $id); |
|
| 339 | + if (!$b['url'] or !isset($exclure[$url])) { |
|
| 340 | + if (strncmp($url, 'configurer_', 11) == 0) { |
|
| 341 | + $deja[$url] = $b; |
|
| 342 | + } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
|
| 343 | + $deja["configurer_" . $match[1]] = $b; |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + } |
|
| 348 | + $exclure = $exclure + $deja; |
|
| 349 | + |
|
| 350 | + $icone_defaut = "images/configuration-16.png"; |
|
| 351 | + $liste = array(); |
|
| 352 | + $skels = array(); |
|
| 353 | + $forms = array(); |
|
| 354 | + |
|
| 355 | + // trouver toutes les pages configurer_xxx de l'espace prive |
|
| 356 | + // et construire un tableau des entrees qui ne sont pas dans $deja |
|
| 357 | + $pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$'); |
|
| 358 | + |
|
| 359 | + foreach ($pages as $page) { |
|
| 360 | + $configurer = basename($page, "." . _EXTENSION_SQUELETTES); |
|
| 361 | + if (!isset($exclure[$configurer])) { |
|
| 362 | + $liste[$configurer] = array( |
|
| 363 | + 'parent' => 'bando_configuration', |
|
| 364 | + 'url' => $configurer, |
|
| 365 | + 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 366 | + 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 367 | + ); |
|
| 368 | + } |
|
| 369 | + $skels[$configurer] = $page; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus |
|
| 373 | + foreach ($skels as $file) { |
|
| 374 | + $forms = array_merge($forms, lister_formulaires_configurer($file)); |
|
| 375 | + } |
|
| 376 | + $forms = array_flip($forms); |
|
| 377 | + |
|
| 378 | + // trouver tous les formulaires/configurer_ |
|
| 379 | + // et construire un tableau des entrees |
|
| 380 | + $pages = find_all_in_path("formulaires/", "configurer_.*[.]" . _EXTENSION_SQUELETTES . '$'); |
|
| 381 | + foreach ($pages as $page) { |
|
| 382 | + $configurer = basename($page, "." . _EXTENSION_SQUELETTES); |
|
| 383 | + if (!isset($forms[$configurer]) |
|
| 384 | + and !isset($liste[$configurer]) |
|
| 385 | + and !isset($exclure[$configurer]) |
|
| 386 | + ) { |
|
| 387 | + $liste[$configurer] = array( |
|
| 388 | + 'parent' => 'bando_configuration', |
|
| 389 | + 'url' => 'configurer', |
|
| 390 | + 'args' => 'cfg=' . substr($configurer, 11), |
|
| 391 | + 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 392 | + 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 393 | + ); |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + return $liste; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
@@ -408,35 +408,35 @@ discard block |
||
| 408 | 408 | * Liste des formulaires trouvés |
| 409 | 409 | **/ |
| 410 | 410 | function lister_formulaires_configurer($file) { |
| 411 | - $forms = array(); |
|
| 412 | - |
|
| 413 | - lire_fichier($file, $skel); |
|
| 414 | - if (preg_match_all(",#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),", $skel, $matches, PREG_SET_ORDER)) { |
|
| 415 | - $matches = array_map('end', $matches); |
|
| 416 | - $matches = array_map('strtolower', $matches); |
|
| 417 | - $forms = array_merge($forms, $matches); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
|
| 421 | - // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
|
| 422 | - $config = basename(substr($file, 0, -strlen("." . _EXTENSION_SQUELETTES))); |
|
| 423 | - spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 424 | - $fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config)); |
|
| 425 | - |
|
| 426 | - // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
|
| 427 | - // et donc que l'on puisse les referencer aussi ! |
|
| 428 | - $fond = pipeline('affiche_milieu', array('args' => array("exec" => $config), 'data' => $fond)); |
|
| 429 | - |
|
| 430 | - // recuperer les noms des formulaires presents. |
|
| 431 | - if (is_array($inputs = extraire_balises($fond, "input"))) { |
|
| 432 | - foreach ($inputs as $i) { |
|
| 433 | - if (extraire_attribut($i, 'name') == 'formulaire_action') { |
|
| 434 | - $forms[] = ($c = extraire_attribut($i, 'value')); |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - return $forms; |
|
| 411 | + $forms = array(); |
|
| 412 | + |
|
| 413 | + lire_fichier($file, $skel); |
|
| 414 | + if (preg_match_all(",#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),", $skel, $matches, PREG_SET_ORDER)) { |
|
| 415 | + $matches = array_map('end', $matches); |
|
| 416 | + $matches = array_map('strtolower', $matches); |
|
| 417 | + $forms = array_merge($forms, $matches); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
|
| 421 | + // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
|
| 422 | + $config = basename(substr($file, 0, -strlen("." . _EXTENSION_SQUELETTES))); |
|
| 423 | + spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 424 | + $fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config)); |
|
| 425 | + |
|
| 426 | + // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
|
| 427 | + // et donc que l'on puisse les referencer aussi ! |
|
| 428 | + $fond = pipeline('affiche_milieu', array('args' => array("exec" => $config), 'data' => $fond)); |
|
| 429 | + |
|
| 430 | + // recuperer les noms des formulaires presents. |
|
| 431 | + if (is_array($inputs = extraire_balises($fond, "input"))) { |
|
| 432 | + foreach ($inputs as $i) { |
|
| 433 | + if (extraire_attribut($i, 'name') == 'formulaire_action') { |
|
| 434 | + $forms[] = ($c = extraire_attribut($i, 'value')); |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + return $forms; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | |
@@ -454,58 +454,58 @@ discard block |
||
| 454 | 454 | * Couples nom de la `meta` => valeur par défaut |
| 455 | 455 | */ |
| 456 | 456 | function liste_metas() { |
| 457 | - return pipeline('configurer_liste_metas', array( |
|
| 458 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 459 | - 'slogan_site' => '', |
|
| 460 | - 'adresse_site' => preg_replace(",/$,", "", url_de_base()), |
|
| 461 | - 'descriptif_site' => '', |
|
| 462 | - 'activer_logos' => 'oui', |
|
| 463 | - 'activer_logos_survol' => 'non', |
|
| 464 | - 'articles_surtitre' => 'non', |
|
| 465 | - 'articles_soustitre' => 'non', |
|
| 466 | - 'articles_descriptif' => 'non', |
|
| 467 | - 'articles_chapeau' => 'non', |
|
| 468 | - 'articles_texte' => 'oui', |
|
| 469 | - 'articles_ps' => 'non', |
|
| 470 | - 'articles_redac' => 'non', |
|
| 471 | - 'post_dates' => 'non', |
|
| 472 | - 'articles_urlref' => 'non', |
|
| 473 | - 'articles_redirection' => 'non', |
|
| 474 | - 'creer_preview' => 'non', |
|
| 475 | - 'taille_preview' => 150, |
|
| 476 | - 'articles_modif' => 'non', |
|
| 477 | - |
|
| 478 | - 'rubriques_descriptif' => 'non', |
|
| 479 | - 'rubriques_texte' => 'oui', |
|
| 480 | - |
|
| 481 | - 'accepter_inscriptions' => 'non', |
|
| 482 | - 'accepter_visiteurs' => 'non', |
|
| 483 | - 'prevenir_auteurs' => 'non', |
|
| 484 | - 'suivi_edito' => 'non', |
|
| 485 | - 'adresse_suivi' => '', |
|
| 486 | - 'adresse_suivi_inscription' => '', |
|
| 487 | - 'adresse_neuf' => '', |
|
| 488 | - 'jours_neuf' => '', |
|
| 489 | - 'quoi_de_neuf' => 'non', |
|
| 490 | - 'preview' => ',0minirezo,1comite,', |
|
| 491 | - |
|
| 492 | - 'syndication_integrale' => 'oui', |
|
| 493 | - 'charset' => _DEFAULT_CHARSET, |
|
| 494 | - 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 495 | - |
|
| 496 | - 'multi_rubriques' => 'non', |
|
| 497 | - 'multi_secteurs' => 'non', |
|
| 498 | - 'gerer_trad' => 'non', |
|
| 499 | - 'langues_multilingue' => '', |
|
| 500 | - |
|
| 501 | - 'version_html_max' => 'html4', |
|
| 502 | - |
|
| 503 | - 'type_urls' => 'page', |
|
| 504 | - |
|
| 505 | - 'email_envoi' => '', |
|
| 506 | - 'email_webmaster' => '', |
|
| 507 | - 'auto_compress_http' => 'non', |
|
| 508 | - )); |
|
| 457 | + return pipeline('configurer_liste_metas', array( |
|
| 458 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 459 | + 'slogan_site' => '', |
|
| 460 | + 'adresse_site' => preg_replace(",/$,", "", url_de_base()), |
|
| 461 | + 'descriptif_site' => '', |
|
| 462 | + 'activer_logos' => 'oui', |
|
| 463 | + 'activer_logos_survol' => 'non', |
|
| 464 | + 'articles_surtitre' => 'non', |
|
| 465 | + 'articles_soustitre' => 'non', |
|
| 466 | + 'articles_descriptif' => 'non', |
|
| 467 | + 'articles_chapeau' => 'non', |
|
| 468 | + 'articles_texte' => 'oui', |
|
| 469 | + 'articles_ps' => 'non', |
|
| 470 | + 'articles_redac' => 'non', |
|
| 471 | + 'post_dates' => 'non', |
|
| 472 | + 'articles_urlref' => 'non', |
|
| 473 | + 'articles_redirection' => 'non', |
|
| 474 | + 'creer_preview' => 'non', |
|
| 475 | + 'taille_preview' => 150, |
|
| 476 | + 'articles_modif' => 'non', |
|
| 477 | + |
|
| 478 | + 'rubriques_descriptif' => 'non', |
|
| 479 | + 'rubriques_texte' => 'oui', |
|
| 480 | + |
|
| 481 | + 'accepter_inscriptions' => 'non', |
|
| 482 | + 'accepter_visiteurs' => 'non', |
|
| 483 | + 'prevenir_auteurs' => 'non', |
|
| 484 | + 'suivi_edito' => 'non', |
|
| 485 | + 'adresse_suivi' => '', |
|
| 486 | + 'adresse_suivi_inscription' => '', |
|
| 487 | + 'adresse_neuf' => '', |
|
| 488 | + 'jours_neuf' => '', |
|
| 489 | + 'quoi_de_neuf' => 'non', |
|
| 490 | + 'preview' => ',0minirezo,1comite,', |
|
| 491 | + |
|
| 492 | + 'syndication_integrale' => 'oui', |
|
| 493 | + 'charset' => _DEFAULT_CHARSET, |
|
| 494 | + 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 495 | + |
|
| 496 | + 'multi_rubriques' => 'non', |
|
| 497 | + 'multi_secteurs' => 'non', |
|
| 498 | + 'gerer_trad' => 'non', |
|
| 499 | + 'langues_multilingue' => '', |
|
| 500 | + |
|
| 501 | + 'version_html_max' => 'html4', |
|
| 502 | + |
|
| 503 | + 'type_urls' => 'page', |
|
| 504 | + |
|
| 505 | + 'email_envoi' => '', |
|
| 506 | + 'email_webmaster' => '', |
|
| 507 | + 'auto_compress_http' => 'non', |
|
| 508 | + )); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | /** |
@@ -516,43 +516,43 @@ discard block |
||
| 516 | 516 | * @return void |
| 517 | 517 | */ |
| 518 | 518 | function actualise_metas($liste_meta) { |
| 519 | - $meta_serveur = |
|
| 520 | - array( |
|
| 521 | - 'version_installee', |
|
| 522 | - 'adresse_site', |
|
| 523 | - 'alea_ephemere_ancien', |
|
| 524 | - 'alea_ephemere', |
|
| 525 | - 'alea_ephemere_date', |
|
| 526 | - 'langue_site', |
|
| 527 | - 'langues_proposees', |
|
| 528 | - 'date_calcul_rubriques', |
|
| 529 | - 'derniere_modif', |
|
| 530 | - 'optimiser_table', |
|
| 531 | - 'drapeau_edition', |
|
| 532 | - 'creer_preview', |
|
| 533 | - 'taille_preview', |
|
| 534 | - 'creer_htpasswd', |
|
| 535 | - 'creer_htaccess', |
|
| 536 | - 'gd_formats_read', |
|
| 537 | - 'gd_formats', |
|
| 538 | - 'netpbm_formats', |
|
| 539 | - 'formats_graphiques', |
|
| 540 | - 'image_process', |
|
| 541 | - 'plugin_header', |
|
| 542 | - 'plugin' |
|
| 543 | - ); |
|
| 544 | - // verifier le impt=non |
|
| 545 | - sql_updateq('spip_meta', array('impt' => 'non'), sql_in('nom', $meta_serveur)); |
|
| 546 | - |
|
| 547 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 548 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 549 | - ecrire_meta($nom, $valeur); |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - include_spip('inc/rubriques'); |
|
| 554 | - $langues = calculer_langues_utilisees(); |
|
| 555 | - ecrire_meta('langues_utilisees', $langues); |
|
| 519 | + $meta_serveur = |
|
| 520 | + array( |
|
| 521 | + 'version_installee', |
|
| 522 | + 'adresse_site', |
|
| 523 | + 'alea_ephemere_ancien', |
|
| 524 | + 'alea_ephemere', |
|
| 525 | + 'alea_ephemere_date', |
|
| 526 | + 'langue_site', |
|
| 527 | + 'langues_proposees', |
|
| 528 | + 'date_calcul_rubriques', |
|
| 529 | + 'derniere_modif', |
|
| 530 | + 'optimiser_table', |
|
| 531 | + 'drapeau_edition', |
|
| 532 | + 'creer_preview', |
|
| 533 | + 'taille_preview', |
|
| 534 | + 'creer_htpasswd', |
|
| 535 | + 'creer_htaccess', |
|
| 536 | + 'gd_formats_read', |
|
| 537 | + 'gd_formats', |
|
| 538 | + 'netpbm_formats', |
|
| 539 | + 'formats_graphiques', |
|
| 540 | + 'image_process', |
|
| 541 | + 'plugin_header', |
|
| 542 | + 'plugin' |
|
| 543 | + ); |
|
| 544 | + // verifier le impt=non |
|
| 545 | + sql_updateq('spip_meta', array('impt' => 'non'), sql_in('nom', $meta_serveur)); |
|
| 546 | + |
|
| 547 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 548 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 549 | + ecrire_meta($nom, $valeur); |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + include_spip('inc/rubriques'); |
|
| 554 | + $langues = calculer_langues_utilisees(); |
|
| 555 | + ecrire_meta('langues_utilisees', $langues); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | |
@@ -574,18 +574,18 @@ discard block |
||
| 574 | 574 | */ |
| 575 | 575 | function appliquer_modifs_config($purger_skel = false) { |
| 576 | 576 | |
| 577 | - foreach (liste_metas() as $i => $v) { |
|
| 578 | - if (($x = _request($i)) !== null) { |
|
| 579 | - ecrire_meta($i, $x); |
|
| 580 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 581 | - ecrire_meta($i, $v); |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - if ($purger_skel) { |
|
| 586 | - include_spip('inc/invalideur'); |
|
| 587 | - purger_repertoire(_DIR_SKELS); |
|
| 588 | - } |
|
| 577 | + foreach (liste_metas() as $i => $v) { |
|
| 578 | + if (($x = _request($i)) !== null) { |
|
| 579 | + ecrire_meta($i, $x); |
|
| 580 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 581 | + ecrire_meta($i, $v); |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + if ($purger_skel) { |
|
| 586 | + include_spip('inc/invalideur'); |
|
| 587 | + purger_repertoire(_DIR_SKELS); |
|
| 588 | + } |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -596,19 +596,19 @@ discard block |
||
| 596 | 596 | * @return string |
| 597 | 597 | */ |
| 598 | 598 | function appliquer_adresse_site($adresse_site) { |
| 599 | - if ($adresse_site !== null) { |
|
| 600 | - if (!strlen($adresse_site)) { |
|
| 601 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 602 | - $adresse_site = url_de_base(); |
|
| 603 | - } |
|
| 604 | - $adresse_site = preg_replace(",/?\s*$,", "", $adresse_site); |
|
| 599 | + if ($adresse_site !== null) { |
|
| 600 | + if (!strlen($adresse_site)) { |
|
| 601 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 602 | + $adresse_site = url_de_base(); |
|
| 603 | + } |
|
| 604 | + $adresse_site = preg_replace(",/?\s*$,", "", $adresse_site); |
|
| 605 | 605 | |
| 606 | - if (!tester_url_absolue($adresse_site)) { |
|
| 607 | - $adresse_site = "http://$adresse_site"; |
|
| 608 | - } |
|
| 606 | + if (!tester_url_absolue($adresse_site)) { |
|
| 607 | + $adresse_site = "http://$adresse_site"; |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 611 | - } |
|
| 610 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - return $adresse_site; |
|
| 613 | + return $adresse_site; |
|
| 614 | 614 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('inc/autoriser'); |
@@ -31,78 +31,78 @@ discard block |
||
| 31 | 31 | * Un tableau des sous rubriques |
| 32 | 32 | */ |
| 33 | 33 | function enfant_rub($collection, $debut = 0, $limite = 500) { |
| 34 | - $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
|
| 35 | - $logo = ''; |
|
| 36 | - |
|
| 37 | - if ($voir_logo) { |
|
| 38 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 39 | - include_spip('inc/filtres_images_mini'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - $res = array(); |
|
| 43 | - |
|
| 44 | - $result = sql_select( |
|
| 45 | - 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 46 | - 'spip_rubriques', |
|
| 47 | - 'id_parent='.intval($collection), |
|
| 48 | - '', |
|
| 49 | - '0+titre,titre', |
|
| 50 | - "$debut,$limite" |
|
| 51 | - ); |
|
| 52 | - while ($row = sql_fetch($result)) { |
|
| 53 | - $id_rubrique = $row['id_rubrique']; |
|
| 54 | - $id_parent = $row['id_parent']; |
|
| 55 | - // pour etre sur de passer par tous les traitements |
|
| 56 | - $titre = generer_info_entite($id_rubrique, 'rubrique', 'titre'); |
|
| 57 | - if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 58 | - $rang = "$rang. "; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 62 | - $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 63 | - |
|
| 64 | - changer_typo($row['lang']); |
|
| 65 | - $lang_dir = lang_dir($row['lang']); |
|
| 66 | - $descriptif = propre($row['descriptif']); |
|
| 67 | - |
|
| 68 | - if ($voir_logo) { |
|
| 69 | - if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
|
| 70 | - list($fid, $dir, $nom, $format) = $logo; |
|
| 71 | - $logo = image_reduire("<img src='$fid' alt='' />", 48, 36); |
|
| 72 | - if ($logo) { |
|
| 73 | - $logo = inserer_attribut($logo, 'class', 'logo'); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 79 | - http_img_pack( |
|
| 80 | - 'auteur-0minirezo-16.png', |
|
| 81 | - '', |
|
| 82 | - " width='16' height='16'", |
|
| 83 | - _T('image_administrer_rubrique') |
|
| 84 | - )) . |
|
| 85 | - " <a dir='$lang_dir'" . |
|
| 86 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 87 | - " href='" . |
|
| 88 | - generer_url_entite($id_rubrique, 'rubrique') . |
|
| 89 | - "'>" . |
|
| 90 | - $rang . $titre . |
|
| 91 | - '</a>'; |
|
| 92 | - |
|
| 93 | - $titre = (is_string($logo) ? $logo : '') . |
|
| 94 | - bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique"); |
|
| 95 | - |
|
| 96 | - $res[] = |
|
| 97 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 98 | - (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") . |
|
| 99 | - $les_sous_enfants . |
|
| 100 | - fin_cadre_sous_rub(true); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 105 | - return $res; |
|
| 34 | + $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
|
| 35 | + $logo = ''; |
|
| 36 | + |
|
| 37 | + if ($voir_logo) { |
|
| 38 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 39 | + include_spip('inc/filtres_images_mini'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + $res = array(); |
|
| 43 | + |
|
| 44 | + $result = sql_select( |
|
| 45 | + 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 46 | + 'spip_rubriques', |
|
| 47 | + 'id_parent='.intval($collection), |
|
| 48 | + '', |
|
| 49 | + '0+titre,titre', |
|
| 50 | + "$debut,$limite" |
|
| 51 | + ); |
|
| 52 | + while ($row = sql_fetch($result)) { |
|
| 53 | + $id_rubrique = $row['id_rubrique']; |
|
| 54 | + $id_parent = $row['id_parent']; |
|
| 55 | + // pour etre sur de passer par tous les traitements |
|
| 56 | + $titre = generer_info_entite($id_rubrique, 'rubrique', 'titre'); |
|
| 57 | + if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 58 | + $rang = "$rang. "; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 62 | + $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 63 | + |
|
| 64 | + changer_typo($row['lang']); |
|
| 65 | + $lang_dir = lang_dir($row['lang']); |
|
| 66 | + $descriptif = propre($row['descriptif']); |
|
| 67 | + |
|
| 68 | + if ($voir_logo) { |
|
| 69 | + if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
|
| 70 | + list($fid, $dir, $nom, $format) = $logo; |
|
| 71 | + $logo = image_reduire("<img src='$fid' alt='' />", 48, 36); |
|
| 72 | + if ($logo) { |
|
| 73 | + $logo = inserer_attribut($logo, 'class', 'logo'); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 79 | + http_img_pack( |
|
| 80 | + 'auteur-0minirezo-16.png', |
|
| 81 | + '', |
|
| 82 | + " width='16' height='16'", |
|
| 83 | + _T('image_administrer_rubrique') |
|
| 84 | + )) . |
|
| 85 | + " <a dir='$lang_dir'" . |
|
| 86 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 87 | + " href='" . |
|
| 88 | + generer_url_entite($id_rubrique, 'rubrique') . |
|
| 89 | + "'>" . |
|
| 90 | + $rang . $titre . |
|
| 91 | + '</a>'; |
|
| 92 | + |
|
| 93 | + $titre = (is_string($logo) ? $logo : '') . |
|
| 94 | + bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique"); |
|
| 95 | + |
|
| 96 | + $res[] = |
|
| 97 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 98 | + (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") . |
|
| 99 | + $les_sous_enfants . |
|
| 100 | + fin_cadre_sous_rub(true); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 105 | + return $res; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -115,65 +115,65 @@ discard block |
||
| 115 | 115 | * Le contenu du bloc dépliable |
| 116 | 116 | */ |
| 117 | 117 | function sous_enfant_rub($collection2) { |
| 118 | - $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2)); |
|
| 119 | - |
|
| 120 | - $retour = ''; |
|
| 121 | - $pagination = ''; |
|
| 122 | - $debut = 0; |
|
| 123 | - $limite = 500; |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * On ne va afficher que 500 résultats max |
|
| 127 | - * Si > 500 on affiche une pagination |
|
| 128 | - */ |
|
| 129 | - if ($nb > $limite) { |
|
| 130 | - $debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut; |
|
| 131 | - $pagination = chercher_filtre('pagination'); |
|
| 132 | - $pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true, |
|
| 133 | - 'prive') . '</p>'; |
|
| 134 | - $limite = $debut + $limite; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $result = sql_select( |
|
| 138 | - 'id_rubrique, id_parent, titre, lang', |
|
| 139 | - 'spip_rubriques', |
|
| 140 | - 'id_parent='.intval($collection2), |
|
| 141 | - '', |
|
| 142 | - '0+titre,titre', |
|
| 143 | - "$debut,$limite" |
|
| 144 | - ); |
|
| 145 | - |
|
| 146 | - while ($row = sql_fetch($result)) { |
|
| 147 | - $id_rubrique2 = $row['id_rubrique']; |
|
| 148 | - $titre2 = generer_info_entite( |
|
| 149 | - $id_rubrique2, |
|
| 150 | - 'rubrique', |
|
| 151 | - 'titre' |
|
| 152 | - ); // pour etre sur de passer par tous les traitements |
|
| 153 | - if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 154 | - $rang2 = "$rang2. "; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - changer_typo($row['lang']); |
|
| 158 | - $lang_dir = lang_dir($row['lang']); |
|
| 159 | - if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 160 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite( |
|
| 161 | - $id_rubrique2, |
|
| 162 | - 'rubrique' |
|
| 163 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $retour = $pagination . $retour . $pagination; |
|
| 168 | - |
|
| 169 | - if (!$retour) { |
|
| 170 | - return ''; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
|
| 174 | - . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 175 | - . $retour |
|
| 176 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 118 | + $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2)); |
|
| 119 | + |
|
| 120 | + $retour = ''; |
|
| 121 | + $pagination = ''; |
|
| 122 | + $debut = 0; |
|
| 123 | + $limite = 500; |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * On ne va afficher que 500 résultats max |
|
| 127 | + * Si > 500 on affiche une pagination |
|
| 128 | + */ |
|
| 129 | + if ($nb > $limite) { |
|
| 130 | + $debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut; |
|
| 131 | + $pagination = chercher_filtre('pagination'); |
|
| 132 | + $pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true, |
|
| 133 | + 'prive') . '</p>'; |
|
| 134 | + $limite = $debut + $limite; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $result = sql_select( |
|
| 138 | + 'id_rubrique, id_parent, titre, lang', |
|
| 139 | + 'spip_rubriques', |
|
| 140 | + 'id_parent='.intval($collection2), |
|
| 141 | + '', |
|
| 142 | + '0+titre,titre', |
|
| 143 | + "$debut,$limite" |
|
| 144 | + ); |
|
| 145 | + |
|
| 146 | + while ($row = sql_fetch($result)) { |
|
| 147 | + $id_rubrique2 = $row['id_rubrique']; |
|
| 148 | + $titre2 = generer_info_entite( |
|
| 149 | + $id_rubrique2, |
|
| 150 | + 'rubrique', |
|
| 151 | + 'titre' |
|
| 152 | + ); // pour etre sur de passer par tous les traitements |
|
| 153 | + if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 154 | + $rang2 = "$rang2. "; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + changer_typo($row['lang']); |
|
| 158 | + $lang_dir = lang_dir($row['lang']); |
|
| 159 | + if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 160 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite( |
|
| 161 | + $id_rubrique2, |
|
| 162 | + 'rubrique' |
|
| 163 | + ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $retour = $pagination . $retour . $pagination; |
|
| 168 | + |
|
| 169 | + if (!$retour) { |
|
| 170 | + return ''; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
|
| 174 | + . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 175 | + . $retour |
|
| 176 | + . "</ul>\n" . fin_block() . "\n\n"; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -188,44 +188,44 @@ discard block |
||
| 188 | 188 | * Le contenu textuel affiché, la liste des sous rubriques |
| 189 | 189 | */ |
| 190 | 190 | function afficher_enfant_rub($id_rubrique = 0) { |
| 191 | - $pagination = ''; |
|
| 192 | - $debut = 0; |
|
| 193 | - $limite = 500; |
|
| 194 | - |
|
| 195 | - $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
|
| 196 | - |
|
| 197 | - if ($nb > $limite) { |
|
| 198 | - $debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut; |
|
| 199 | - $pagination = chercher_filtre('pagination'); |
|
| 200 | - $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 201 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 202 | - '</p>'; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 206 | - |
|
| 207 | - if (!$n = count($les_enfants)) { |
|
| 208 | - return ''; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if ($n == 1) { |
|
| 212 | - $les_enfants = reset($les_enfants); |
|
| 213 | - $les_enfants2 = ''; |
|
| 214 | - } else { |
|
| 215 | - $n = ceil($n / 2); |
|
| 216 | - $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 217 | - $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - $res = |
|
| 221 | - $pagination |
|
| 222 | - . "<div class='gauche'>" |
|
| 223 | - . $les_enfants |
|
| 224 | - . '</div>' |
|
| 225 | - . "<div class='droite'>" |
|
| 226 | - . $les_enfants2 |
|
| 227 | - . '</div>' |
|
| 228 | - . $pagination; |
|
| 229 | - |
|
| 230 | - return $res; |
|
| 191 | + $pagination = ''; |
|
| 192 | + $debut = 0; |
|
| 193 | + $limite = 500; |
|
| 194 | + |
|
| 195 | + $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
|
| 196 | + |
|
| 197 | + if ($nb > $limite) { |
|
| 198 | + $debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut; |
|
| 199 | + $pagination = chercher_filtre('pagination'); |
|
| 200 | + $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 201 | + $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 202 | + '</p>'; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 206 | + |
|
| 207 | + if (!$n = count($les_enfants)) { |
|
| 208 | + return ''; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if ($n == 1) { |
|
| 212 | + $les_enfants = reset($les_enfants); |
|
| 213 | + $les_enfants2 = ''; |
|
| 214 | + } else { |
|
| 215 | + $n = ceil($n / 2); |
|
| 216 | + $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 217 | + $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + $res = |
|
| 221 | + $pagination |
|
| 222 | + . "<div class='gauche'>" |
|
| 223 | + . $les_enfants |
|
| 224 | + . '</div>' |
|
| 225 | + . "<div class='droite'>" |
|
| 226 | + . $les_enfants2 |
|
| 227 | + . '</div>' |
|
| 228 | + . $pagination; |
|
| 229 | + |
|
| 230 | + return $res; |
|
| 231 | 231 | } |
@@ -75,28 +75,27 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 79 | - http_img_pack( |
|
| 78 | + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : http_img_pack( |
|
| 80 | 79 | 'auteur-0minirezo-16.png', |
| 81 | 80 | '', |
| 82 | 81 | " width='16' height='16'", |
| 83 | 82 | _T('image_administrer_rubrique') |
| 84 | - )) . |
|
| 85 | - " <a dir='$lang_dir'" . |
|
| 86 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 87 | - " href='" . |
|
| 88 | - generer_url_entite($id_rubrique, 'rubrique') . |
|
| 89 | - "'>" . |
|
| 90 | - $rang . $titre . |
|
| 83 | + )). |
|
| 84 | + " <a dir='$lang_dir'". |
|
| 85 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : ''). |
|
| 86 | + " href='". |
|
| 87 | + generer_url_entite($id_rubrique, 'rubrique'). |
|
| 88 | + "'>". |
|
| 89 | + $rang.$titre. |
|
| 91 | 90 | '</a>'; |
| 92 | 91 | |
| 93 | - $titre = (is_string($logo) ? $logo : '') . |
|
| 92 | + $titre = (is_string($logo) ? $logo : ''). |
|
| 94 | 93 | bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique"); |
| 95 | 94 | |
| 96 | 95 | $res[] = |
| 97 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 98 | - (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") . |
|
| 99 | - $les_sous_enfants . |
|
| 96 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre). |
|
| 97 | + (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>"). |
|
| 98 | + $les_sous_enfants. |
|
| 100 | 99 | fin_cadre_sous_rub(true); |
| 101 | 100 | } |
| 102 | 101 | } |
@@ -127,10 +126,10 @@ discard block |
||
| 127 | 126 | * Si > 500 on affiche une pagination |
| 128 | 127 | */ |
| 129 | 128 | if ($nb > $limite) { |
| 130 | - $debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut; |
|
| 129 | + $debut = _request('debut_rubrique'.$collection2) ? _request('debut_rubrique'.$collection2) : $debut; |
|
| 131 | 130 | $pagination = chercher_filtre('pagination'); |
| 132 | - $pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true, |
|
| 133 | - 'prive') . '</p>'; |
|
| 131 | + $pagination = '<p class="pagination">'.$pagination($nb, '_rubrique'.$collection2, $debut, $limite, true, |
|
| 132 | + 'prive').'</p>'; |
|
| 134 | 133 | $limite = $debut + $limite; |
| 135 | 134 | } |
| 136 | 135 | |
@@ -157,14 +156,14 @@ discard block |
||
| 157 | 156 | changer_typo($row['lang']); |
| 158 | 157 | $lang_dir = lang_dir($row['lang']); |
| 159 | 158 | if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
| 160 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite( |
|
| 159 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_url_entite( |
|
| 161 | 160 | $id_rubrique2, |
| 162 | 161 | 'rubrique' |
| 163 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 162 | + )."'>".$rang2.$titre2."</a></li>\n"; |
|
| 164 | 163 | } |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | - $retour = $pagination . $retour . $pagination; |
|
| 166 | + $retour = $pagination.$retour.$pagination; |
|
| 168 | 167 | |
| 169 | 168 | if (!$retour) { |
| 170 | 169 | return ''; |
@@ -173,7 +172,7 @@ discard block |
||
| 173 | 172 | return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
| 174 | 173 | . "\n<ul class='liste-items sous-sous-rub'>\n" |
| 175 | 174 | . $retour |
| 176 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 175 | + . "</ul>\n".fin_block()."\n\n"; |
|
| 177 | 176 | } |
| 178 | 177 | |
| 179 | 178 | /** |
@@ -195,10 +194,10 @@ discard block |
||
| 195 | 194 | $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
| 196 | 195 | |
| 197 | 196 | if ($nb > $limite) { |
| 198 | - $debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut; |
|
| 197 | + $debut = _request('debut_rubrique'.$id_rubrique) ? _request('debut_rubrique'.$id_rubrique) : $debut; |
|
| 199 | 198 | $pagination = chercher_filtre('pagination'); |
| 200 | - $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 201 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 199 | + $pagination = '<br class="nettoyeur"><p class="pagination">'. |
|
| 200 | + $pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive'). |
|
| 202 | 201 | '</p>'; |
| 203 | 202 | } |
| 204 | 203 | |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/boutons'); |
| 18 | 18 | include_spip('base/objets'); |
| 19 | 19 | |
| 20 | 20 | function inc_icone_renommer_dist($fond, $fonction) { |
| 21 | - $size = 24; |
|
| 22 | - if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i", $fond, $match) |
|
| 23 | - and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1])) |
|
| 24 | - ) { |
|
| 25 | - if (isset($match[1]) and $match[1]) { |
|
| 26 | - $size = $match[1]; |
|
| 27 | - } |
|
| 28 | - $type = substr($fond, 0, -strlen($match[0])); |
|
| 29 | - if (!isset($match[2]) or !$match[2]) { |
|
| 30 | - $fond .= ".png"; |
|
| 31 | - } |
|
| 32 | - } else { |
|
| 33 | - $type = $fond; |
|
| 34 | - $fond .= ".png"; |
|
| 35 | - } |
|
| 21 | + $size = 24; |
|
| 22 | + if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i", $fond, $match) |
|
| 23 | + and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1])) |
|
| 24 | + ) { |
|
| 25 | + if (isset($match[1]) and $match[1]) { |
|
| 26 | + $size = $match[1]; |
|
| 27 | + } |
|
| 28 | + $type = substr($fond, 0, -strlen($match[0])); |
|
| 29 | + if (!isset($match[2]) or !$match[2]) { |
|
| 30 | + $fond .= ".png"; |
|
| 31 | + } |
|
| 32 | + } else { |
|
| 33 | + $type = $fond; |
|
| 34 | + $fond .= ".png"; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $rtl = false; |
|
| 38 | - if (preg_match(',[-_]rtl$,i', $type, $match)) { |
|
| 39 | - $rtl = true; |
|
| 40 | - $type = substr($type, 0, -strlen($match[0])); |
|
| 41 | - } |
|
| 37 | + $rtl = false; |
|
| 38 | + if (preg_match(',[-_]rtl$,i', $type, $match)) { |
|
| 39 | + $rtl = true; |
|
| 40 | + $type = substr($type, 0, -strlen($match[0])); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
|
| 44 | - // et ne finit pas par un s, sauf si c'est une exception declaree |
|
| 45 | - $type = objet_type($type, false); |
|
| 43 | + // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
|
| 44 | + // et ne finit pas par un s, sauf si c'est une exception declaree |
|
| 45 | + $type = objet_type($type, false); |
|
| 46 | 46 | |
| 47 | - $dir = "images/"; |
|
| 48 | - $f = "$type-$size.png"; |
|
| 49 | - if ($icone = find_in_theme($dir . $f)) { |
|
| 50 | - $dir = dirname($icone); |
|
| 51 | - $fond = $icone; |
|
| 47 | + $dir = "images/"; |
|
| 48 | + $f = "$type-$size.png"; |
|
| 49 | + if ($icone = find_in_theme($dir . $f)) { |
|
| 50 | + $dir = dirname($icone); |
|
| 51 | + $fond = $icone; |
|
| 52 | 52 | |
| 53 | - if ($rtl |
|
| 54 | - and $fr = "$type-rtl-$size.png" |
|
| 55 | - and file_exists($dir . '/' . $fr) |
|
| 56 | - ) { |
|
| 57 | - $type = "$type-rtl"; |
|
| 58 | - } |
|
| 53 | + if ($rtl |
|
| 54 | + and $fr = "$type-rtl-$size.png" |
|
| 55 | + and file_exists($dir . '/' . $fr) |
|
| 56 | + ) { |
|
| 57 | + $type = "$type-rtl"; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $action = $fonction; |
|
| 61 | - if ($action == "supprimer.gif") { |
|
| 62 | - $action = "del"; |
|
| 63 | - } elseif ($action == "creer.gif") { |
|
| 64 | - $action = "new"; |
|
| 65 | - } elseif ($action == "edit.gif") { |
|
| 66 | - $action = "edit"; |
|
| 67 | - } |
|
| 68 | - if (!in_array($action, array('del', 'new', 'edit'))) { |
|
| 69 | - $action = ""; |
|
| 70 | - } |
|
| 71 | - if ($action) { |
|
| 72 | - if ($fa = "$type-$action-$size.png" |
|
| 73 | - and file_exists($dir . '/' . $fa) |
|
| 74 | - ) { |
|
| 75 | - $fond = $dir . '/' . $fa; |
|
| 76 | - $fonction = ""; |
|
| 77 | - } else { |
|
| 78 | - $fonction = "$action-$size.png"; |
|
| 79 | - } |
|
| 80 | - } |
|
| 60 | + $action = $fonction; |
|
| 61 | + if ($action == "supprimer.gif") { |
|
| 62 | + $action = "del"; |
|
| 63 | + } elseif ($action == "creer.gif") { |
|
| 64 | + $action = "new"; |
|
| 65 | + } elseif ($action == "edit.gif") { |
|
| 66 | + $action = "edit"; |
|
| 67 | + } |
|
| 68 | + if (!in_array($action, array('del', 'new', 'edit'))) { |
|
| 69 | + $action = ""; |
|
| 70 | + } |
|
| 71 | + if ($action) { |
|
| 72 | + if ($fa = "$type-$action-$size.png" |
|
| 73 | + and file_exists($dir . '/' . $fa) |
|
| 74 | + ) { |
|
| 75 | + $fond = $dir . '/' . $fa; |
|
| 76 | + $fonction = ""; |
|
| 77 | + } else { |
|
| 78 | + $fonction = "$action-$size.png"; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // c'est bon ! |
|
| 83 | - return array($fond, $fonction); |
|
| 84 | - } |
|
| 82 | + // c'est bon ! |
|
| 83 | + return array($fond, $fonction); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return array($fond, $fonction); |
|
| 86 | + return array($fond, $fonction); |
|
| 87 | 87 | } |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $dir = "images/"; |
| 48 | 48 | $f = "$type-$size.png"; |
| 49 | - if ($icone = find_in_theme($dir . $f)) { |
|
| 49 | + if ($icone = find_in_theme($dir.$f)) { |
|
| 50 | 50 | $dir = dirname($icone); |
| 51 | 51 | $fond = $icone; |
| 52 | 52 | |
| 53 | 53 | if ($rtl |
| 54 | 54 | and $fr = "$type-rtl-$size.png" |
| 55 | - and file_exists($dir . '/' . $fr) |
|
| 55 | + and file_exists($dir.'/'.$fr) |
|
| 56 | 56 | ) { |
| 57 | 57 | $type = "$type-rtl"; |
| 58 | 58 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | if ($action) { |
| 72 | 72 | if ($fa = "$type-$action-$size.png" |
| 73 | - and file_exists($dir . '/' . $fa) |
|
| 73 | + and file_exists($dir.'/'.$fa) |
|
| 74 | 74 | ) { |
| 75 | - $fond = $dir . '/' . $fa; |
|
| 75 | + $fond = $dir.'/'.$fa; |
|
| 76 | 76 | $fonction = ""; |
| 77 | 77 | } else { |
| 78 | 78 | $fonction = "$action-$size.png"; |
@@ -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,12 +22,12 @@ discard block |
||
| 22 | 22 | * http://zoumzamzouilam/truc/chose/machin..." |
| 23 | 23 | */ |
| 24 | 24 | function inc_lien_court($url) { |
| 25 | - $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40; |
|
| 26 | - $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35; |
|
| 25 | + $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40; |
|
| 26 | + $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35; |
|
| 27 | 27 | |
| 28 | - if (strlen($url) > $long_url) { |
|
| 29 | - $url = substr($url, 0, $coupe_url) . '...'; |
|
| 30 | - } |
|
| 28 | + if (strlen($url) > $long_url) { |
|
| 29 | + $url = substr($url, 0, $coupe_url) . '...'; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return $url; |
|
| 32 | + return $url; |
|
| 33 | 33 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35; |
| 27 | 27 | |
| 28 | 28 | if (strlen($url) > $long_url) { |
| 29 | - $url = substr($url, 0, $coupe_url) . '...'; |
|
| 29 | + $url = substr($url, 0, $coupe_url).'...'; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return $url; |
@@ -11,103 +11,103 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) { |
| 18 | - static $test_repertoire = array(); |
|
| 19 | - static $compteur = array(); |
|
| 20 | - static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | - |
|
| 22 | - if (is_null($logname) or !is_string($logname)) { |
|
| 23 | - $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | - } |
|
| 25 | - if (!isset($compteur[$logname])) { |
|
| 26 | - $compteur[$logname] = 0; |
|
| 27 | - } |
|
| 28 | - if ($logname != 'maj' |
|
| 29 | - and defined('_MAX_LOG') |
|
| 30 | - and ( |
|
| 31 | - $compteur[$logname]++ > _MAX_LOG |
|
| 32 | - or !$GLOBALS['nombre_de_logs'] |
|
| 33 | - or !$GLOBALS['taille_des_logs'] |
|
| 34 | - ) |
|
| 35 | - ) { |
|
| 36 | - return; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - $logfile = ($logdir === null ? _DIR_LOG : $logdir) |
|
| 40 | - . ($logname) |
|
| 41 | - . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 42 | - |
|
| 43 | - if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 44 | - $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 45 | - $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 46 | - $d, |
|
| 47 | - '', |
|
| 48 | - false, |
|
| 49 | - true |
|
| 50 | - ) : false)); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 54 | - if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
|
| 55 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $rotate = 0; |
|
| 59 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 60 | - |
|
| 61 | - // accepter spip_log( Array ) |
|
| 62 | - if (!is_string($message)) { |
|
| 63 | - $message = var_export($message, true); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 67 | - $debug = debug_backtrace(); |
|
| 68 | - $l = $debug[1]['line']; |
|
| 69 | - $fi = $debug[1]['file']; |
|
| 70 | - if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 71 | - $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 72 | - } |
|
| 73 | - $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 74 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 78 | - //distinguer les logs prives et publics dans les grep |
|
| 79 | - . $debugverb |
|
| 80 | - . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 81 | - . preg_replace("/\n*$/", "\n", $message); |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - if (@is_readable($logfile) |
|
| 85 | - and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 86 | - ) { |
|
| 87 | - $rotate = $GLOBALS['nombre_de_logs']; |
|
| 88 | - $m .= "[-- rotate --]\n"; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $f = @fopen($logfile, 'ab'); |
|
| 92 | - if ($f) { |
|
| 93 | - fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 94 | - fclose($f); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($rotate-- > 0 |
|
| 98 | - and function_exists('spip_unlink') |
|
| 99 | - ) { |
|
| 100 | - spip_unlink($logfile . '.' . $rotate); |
|
| 101 | - while ($rotate--) { |
|
| 102 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // Dupliquer les erreurs specifiques dans le log general |
|
| 107 | - if ($logname !== _FILE_LOG |
|
| 108 | - and defined('_FILE_LOG') |
|
| 109 | - ) { |
|
| 110 | - inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 111 | - } |
|
| 112 | - $debugverb = ''; |
|
| 18 | + static $test_repertoire = array(); |
|
| 19 | + static $compteur = array(); |
|
| 20 | + static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | + |
|
| 22 | + if (is_null($logname) or !is_string($logname)) { |
|
| 23 | + $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | + } |
|
| 25 | + if (!isset($compteur[$logname])) { |
|
| 26 | + $compteur[$logname] = 0; |
|
| 27 | + } |
|
| 28 | + if ($logname != 'maj' |
|
| 29 | + and defined('_MAX_LOG') |
|
| 30 | + and ( |
|
| 31 | + $compteur[$logname]++ > _MAX_LOG |
|
| 32 | + or !$GLOBALS['nombre_de_logs'] |
|
| 33 | + or !$GLOBALS['taille_des_logs'] |
|
| 34 | + ) |
|
| 35 | + ) { |
|
| 36 | + return; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + $logfile = ($logdir === null ? _DIR_LOG : $logdir) |
|
| 40 | + . ($logname) |
|
| 41 | + . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 42 | + |
|
| 43 | + if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 44 | + $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 45 | + $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 46 | + $d, |
|
| 47 | + '', |
|
| 48 | + false, |
|
| 49 | + true |
|
| 50 | + ) : false)); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 54 | + if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
|
| 55 | + $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $rotate = 0; |
|
| 59 | + $pid = '(pid ' . @getmypid() . ')'; |
|
| 60 | + |
|
| 61 | + // accepter spip_log( Array ) |
|
| 62 | + if (!is_string($message)) { |
|
| 63 | + $message = var_export($message, true); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 67 | + $debug = debug_backtrace(); |
|
| 68 | + $l = $debug[1]['line']; |
|
| 69 | + $fi = $debug[1]['file']; |
|
| 70 | + if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 71 | + $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 72 | + } |
|
| 73 | + $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 74 | + $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 78 | + //distinguer les logs prives et publics dans les grep |
|
| 79 | + . $debugverb |
|
| 80 | + . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 81 | + . preg_replace("/\n*$/", "\n", $message); |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + if (@is_readable($logfile) |
|
| 85 | + and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 86 | + ) { |
|
| 87 | + $rotate = $GLOBALS['nombre_de_logs']; |
|
| 88 | + $m .= "[-- rotate --]\n"; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $f = @fopen($logfile, 'ab'); |
|
| 92 | + if ($f) { |
|
| 93 | + fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 94 | + fclose($f); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($rotate-- > 0 |
|
| 98 | + and function_exists('spip_unlink') |
|
| 99 | + ) { |
|
| 100 | + spip_unlink($logfile . '.' . $rotate); |
|
| 101 | + while ($rotate--) { |
|
| 102 | + @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // Dupliquer les erreurs specifiques dans le log general |
|
| 107 | + if ($logname !== _FILE_LOG |
|
| 108 | + and defined('_FILE_LOG') |
|
| 109 | + ) { |
|
| 110 | + inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 111 | + } |
|
| 112 | + $debugverb = ''; |
|
| 113 | 113 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
| 54 | 54 | if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
| 55 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 55 | + $logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $rotate = 0; |
| 59 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 59 | + $pid = '(pid '.@getmypid().')'; |
|
| 60 | 60 | |
| 61 | 61 | // accepter spip_log( Array ) |
| 62 | 62 | if (!is_string($message)) { |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | $fi = substr($fi, strlen(_ROOT_RACINE)); |
| 72 | 72 | } |
| 73 | 73 | $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
| 74 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 74 | + $debugverb = "$fi:L$l:$fu".'():'; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 77 | + $m = date('Y-m-d H:i:s').' '.(isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '').' '.$pid.' ' |
|
| 78 | 78 | //distinguer les logs prives et publics dans les grep |
| 79 | 79 | . $debugverb |
| 80 | 80 | . (test_espace_prive() ? ':Pri:' : ':Pub:') |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | if ($rotate-- > 0 |
| 98 | 98 | and function_exists('spip_unlink') |
| 99 | 99 | ) { |
| 100 | - spip_unlink($logfile . '.' . $rotate); |
|
| 100 | + spip_unlink($logfile.'.'.$rotate); |
|
| 101 | 101 | while ($rotate--) { |
| 102 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 102 | + @rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1)); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -12,241 +12,241 @@ |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | // methodes sql |
| 20 | 20 | function inc_recherche_to_array_dist($recherche, $options = array()) { |
| 21 | 21 | |
| 22 | - // options par defaut |
|
| 23 | - $options = array_merge( |
|
| 24 | - array( |
|
| 25 | - 'score' => true, |
|
| 26 | - 'champs' => false, |
|
| 27 | - 'toutvoir' => false, |
|
| 28 | - 'matches' => false, |
|
| 29 | - 'jointures' => false |
|
| 30 | - ), |
|
| 31 | - $options |
|
| 32 | - ); |
|
| 33 | - |
|
| 34 | - include_spip('inc/rechercher'); |
|
| 35 | - include_spip('inc/autoriser'); |
|
| 36 | - |
|
| 37 | - $requete = array( |
|
| 38 | - "SELECT" => array(), |
|
| 39 | - "FROM" => array(), |
|
| 40 | - "WHERE" => array(), |
|
| 41 | - "GROUPBY" => array(), |
|
| 42 | - "ORDERBY" => array(), |
|
| 43 | - "LIMIT" => "", |
|
| 44 | - "HAVING" => array() |
|
| 45 | - ); |
|
| 46 | - |
|
| 47 | - $table = sinon($options['table'], 'article'); |
|
| 48 | - if ($options['champs']) { |
|
| 49 | - $champs = $options['champs']; |
|
| 50 | - } else { |
|
| 51 | - $l = liste_des_champs(); |
|
| 52 | - $champs = $l['article']; |
|
| 53 | - } |
|
| 54 | - $serveur = $options['serveur']; |
|
| 55 | - |
|
| 56 | - list($methode, $q, $preg) = expression_recherche($recherche, $options); |
|
| 57 | - |
|
| 58 | - $jointures = $options['jointures'] |
|
| 59 | - ? liste_des_jointures() |
|
| 60 | - : array(); |
|
| 61 | - |
|
| 62 | - $_id_table = id_table_objet($table); |
|
| 63 | - |
|
| 64 | - // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 65 | - // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 66 | - if (strpos($_id_table, ",") !== false) { |
|
| 67 | - $_id_table = explode(',', $_id_table); |
|
| 68 | - $_id_table = reset($_id_table); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $requete['SELECT'][] = "t." . $_id_table; |
|
| 72 | - $a = array(); |
|
| 73 | - // Recherche fulltext |
|
| 74 | - foreach ($champs as $champ => $poids) { |
|
| 75 | - if (is_array($champ)) { |
|
| 76 | - spip_log("requetes imbriquees interdites"); |
|
| 77 | - } else { |
|
| 78 | - if (strpos($champ, ".") === false) { |
|
| 79 | - $champ = "t.$champ"; |
|
| 80 | - } |
|
| 81 | - $requete['SELECT'][] = $champ; |
|
| 82 | - $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - if ($a) { |
|
| 86 | - $requete['WHERE'][] = join(" OR ", $a); |
|
| 87 | - } |
|
| 88 | - $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 89 | - |
|
| 90 | - $results = array(); |
|
| 91 | - |
|
| 92 | - $s = sql_select( |
|
| 93 | - $requete['SELECT'], $requete['FROM'], $requete['WHERE'], |
|
| 94 | - implode(" ", $requete['GROUPBY']), |
|
| 95 | - $requete['ORDERBY'], $requete['LIMIT'], |
|
| 96 | - $requete['HAVING'], $serveur |
|
| 97 | - ); |
|
| 98 | - |
|
| 99 | - while ($t = sql_fetch($s, $serveur) |
|
| 100 | - and (!isset($t['score']) or $t['score'] > 0)) { |
|
| 101 | - $id = intval($t[$_id_table]); |
|
| 102 | - |
|
| 103 | - if ($options['toutvoir'] |
|
| 104 | - or autoriser('voir', $table, $id) |
|
| 105 | - ) { |
|
| 106 | - // indiquer les champs concernes |
|
| 107 | - $champs_vus = array(); |
|
| 108 | - $score = 0; |
|
| 109 | - $matches = array(); |
|
| 110 | - |
|
| 111 | - $vu = false; |
|
| 112 | - foreach ($champs as $champ => $poids) { |
|
| 113 | - $champ = explode('.', $champ); |
|
| 114 | - $champ = end($champ); |
|
| 115 | - // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 116 | - $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 117 | - if ($n = |
|
| 118 | - ($options['score'] || $options['matches']) |
|
| 119 | - ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER) |
|
| 120 | - : preg_match($preg, $value) |
|
| 121 | - ) { |
|
| 122 | - $vu = true; |
|
| 123 | - |
|
| 124 | - if ($options['champs']) { |
|
| 125 | - $champs_vus[$champ] = $t[$champ]; |
|
| 126 | - } |
|
| 127 | - if ($options['score']) { |
|
| 128 | - $score += $n * $poids; |
|
| 129 | - } |
|
| 130 | - if ($options['matches']) { |
|
| 131 | - $matches[$champ] = $regs; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if (!$options['champs'] |
|
| 135 | - and !$options['score'] |
|
| 136 | - and !$options['matches'] |
|
| 137 | - ) { |
|
| 138 | - break; |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - if ($vu) { |
|
| 144 | - if (!isset($results)) { |
|
| 145 | - $results = array(); |
|
| 146 | - } |
|
| 147 | - $results[$id] = array(); |
|
| 148 | - if ($champs_vus) { |
|
| 149 | - $results[$id]['champs'] = $champs_vus; |
|
| 150 | - } |
|
| 151 | - if ($score) { |
|
| 152 | - $results[$id]['score'] = $score; |
|
| 153 | - } |
|
| 154 | - if ($matches) { |
|
| 155 | - $results[$id]['matches'] = $matches; |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - // Gerer les donnees associees |
|
| 163 | - // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 164 | - // on ne sait passer que par table de laison en 1 coup |
|
| 165 | - if (isset($jointures[$table]) |
|
| 166 | - and $joints = recherche_en_base( |
|
| 167 | - $recherche, |
|
| 168 | - $jointures[$table], |
|
| 169 | - array_merge($options, array('jointures' => false)) |
|
| 170 | - ) |
|
| 171 | - ) { |
|
| 172 | - include_spip('action/editer_liens'); |
|
| 173 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 174 | - $cle_depart = id_table_objet($table); |
|
| 175 | - $table_depart = table_objet($table, $serveur); |
|
| 176 | - $desc_depart = $trouver_table($table_depart, $serveur); |
|
| 177 | - $depart_associable = objet_associable($table); |
|
| 178 | - foreach ($joints as $table_liee => $ids_trouves) { |
|
| 179 | - // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 180 | - if ( |
|
| 181 | - !( |
|
| 182 | - $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", "inc", true) |
|
| 183 | - or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", "inc", true) |
|
| 184 | - or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", "inc", true) |
|
| 185 | - ) |
|
| 186 | - ) { |
|
| 187 | - $cle_arrivee = id_table_objet($table_liee); |
|
| 188 | - $table_arrivee = table_objet($table_liee, $serveur); |
|
| 189 | - $desc_arrivee = $trouver_table($table_arrivee, $serveur); |
|
| 190 | - // cas simple : $cle_depart dans la table_liee |
|
| 191 | - if (isset($desc_arrivee['field'][$cle_depart])) { |
|
| 192 | - $s = sql_select("$cle_depart, $cle_arrivee", $desc_arrivee['table_sql'], |
|
| 193 | - sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur); |
|
| 194 | - } // cas simple : $cle_arrivee dans la table |
|
| 195 | - elseif (isset($desc_depart['field'][$cle_arrivee])) { |
|
| 196 | - $s = sql_select("$cle_depart, $cle_arrivee", $desc_depart['table_sql'], |
|
| 197 | - sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur); |
|
| 198 | - } |
|
| 199 | - // sinon cherchons une table de liaison |
|
| 200 | - // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 201 | - elseif ($l = objet_associable($table_liee)) { |
|
| 202 | - list($primary, $table_liens) = $l; |
|
| 203 | - $s = sql_select("id_objet as $cle_depart, $primary as $cle_arrivee", $table_liens, |
|
| 204 | - array("objet='$table'", sql_in($primary, array_keys($ids_trouves))), '', '', '', '', $serveur); |
|
| 205 | - } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 206 | - elseif ($l = $depart_associable) { |
|
| 207 | - list($primary, $table_liens) = $l; |
|
| 208 | - $s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens, |
|
| 209 | - array("objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))), '', '', '', '', $serveur); |
|
| 210 | - } // cas table de liaison generique spip_xxx_yyy |
|
| 211 | - elseif ($t = $trouver_table($table_arrivee . "_" . $table_depart, $serveur) |
|
| 212 | - or $t = $trouver_table($table_depart . "_" . $table_arrivee, $serveur) |
|
| 213 | - ) { |
|
| 214 | - $s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 215 | - '', '', '', '', $serveur); |
|
| 216 | - } |
|
| 217 | - } else { |
|
| 218 | - list($cle_depart, $cle_arrivee, $s) = $rechercher_joints($table, $table_liee, array_keys($ids_trouves), |
|
| 219 | - $serveur); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) { |
|
| 223 | - $id = $t[$cle_depart]; |
|
| 224 | - $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 225 | - if (!isset($results)) { |
|
| 226 | - $results = array(); |
|
| 227 | - } |
|
| 228 | - if (!isset($results[$id])) { |
|
| 229 | - $results[$id] = array(); |
|
| 230 | - } |
|
| 231 | - if (isset($joint['score']) and $joint['score']) { |
|
| 232 | - if (!isset($results[$id]['score'])) { |
|
| 233 | - $results[$id]['score'] = 0; |
|
| 234 | - } |
|
| 235 | - $results[$id]['score'] += $joint['score']; |
|
| 236 | - } |
|
| 237 | - if (isset($joint['champs']) and $joint['champs']) { |
|
| 238 | - foreach ($joint['champs'] as $c => $val) { |
|
| 239 | - $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 240 | - } |
|
| 241 | - } |
|
| 242 | - if (isset($joint['matches']) and $joint['matches']) { |
|
| 243 | - foreach ($joint['matches'] as $c => $val) { |
|
| 244 | - $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - return $results; |
|
| 22 | + // options par defaut |
|
| 23 | + $options = array_merge( |
|
| 24 | + array( |
|
| 25 | + 'score' => true, |
|
| 26 | + 'champs' => false, |
|
| 27 | + 'toutvoir' => false, |
|
| 28 | + 'matches' => false, |
|
| 29 | + 'jointures' => false |
|
| 30 | + ), |
|
| 31 | + $options |
|
| 32 | + ); |
|
| 33 | + |
|
| 34 | + include_spip('inc/rechercher'); |
|
| 35 | + include_spip('inc/autoriser'); |
|
| 36 | + |
|
| 37 | + $requete = array( |
|
| 38 | + "SELECT" => array(), |
|
| 39 | + "FROM" => array(), |
|
| 40 | + "WHERE" => array(), |
|
| 41 | + "GROUPBY" => array(), |
|
| 42 | + "ORDERBY" => array(), |
|
| 43 | + "LIMIT" => "", |
|
| 44 | + "HAVING" => array() |
|
| 45 | + ); |
|
| 46 | + |
|
| 47 | + $table = sinon($options['table'], 'article'); |
|
| 48 | + if ($options['champs']) { |
|
| 49 | + $champs = $options['champs']; |
|
| 50 | + } else { |
|
| 51 | + $l = liste_des_champs(); |
|
| 52 | + $champs = $l['article']; |
|
| 53 | + } |
|
| 54 | + $serveur = $options['serveur']; |
|
| 55 | + |
|
| 56 | + list($methode, $q, $preg) = expression_recherche($recherche, $options); |
|
| 57 | + |
|
| 58 | + $jointures = $options['jointures'] |
|
| 59 | + ? liste_des_jointures() |
|
| 60 | + : array(); |
|
| 61 | + |
|
| 62 | + $_id_table = id_table_objet($table); |
|
| 63 | + |
|
| 64 | + // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 65 | + // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 66 | + if (strpos($_id_table, ",") !== false) { |
|
| 67 | + $_id_table = explode(',', $_id_table); |
|
| 68 | + $_id_table = reset($_id_table); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $requete['SELECT'][] = "t." . $_id_table; |
|
| 72 | + $a = array(); |
|
| 73 | + // Recherche fulltext |
|
| 74 | + foreach ($champs as $champ => $poids) { |
|
| 75 | + if (is_array($champ)) { |
|
| 76 | + spip_log("requetes imbriquees interdites"); |
|
| 77 | + } else { |
|
| 78 | + if (strpos($champ, ".") === false) { |
|
| 79 | + $champ = "t.$champ"; |
|
| 80 | + } |
|
| 81 | + $requete['SELECT'][] = $champ; |
|
| 82 | + $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + if ($a) { |
|
| 86 | + $requete['WHERE'][] = join(" OR ", $a); |
|
| 87 | + } |
|
| 88 | + $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 89 | + |
|
| 90 | + $results = array(); |
|
| 91 | + |
|
| 92 | + $s = sql_select( |
|
| 93 | + $requete['SELECT'], $requete['FROM'], $requete['WHERE'], |
|
| 94 | + implode(" ", $requete['GROUPBY']), |
|
| 95 | + $requete['ORDERBY'], $requete['LIMIT'], |
|
| 96 | + $requete['HAVING'], $serveur |
|
| 97 | + ); |
|
| 98 | + |
|
| 99 | + while ($t = sql_fetch($s, $serveur) |
|
| 100 | + and (!isset($t['score']) or $t['score'] > 0)) { |
|
| 101 | + $id = intval($t[$_id_table]); |
|
| 102 | + |
|
| 103 | + if ($options['toutvoir'] |
|
| 104 | + or autoriser('voir', $table, $id) |
|
| 105 | + ) { |
|
| 106 | + // indiquer les champs concernes |
|
| 107 | + $champs_vus = array(); |
|
| 108 | + $score = 0; |
|
| 109 | + $matches = array(); |
|
| 110 | + |
|
| 111 | + $vu = false; |
|
| 112 | + foreach ($champs as $champ => $poids) { |
|
| 113 | + $champ = explode('.', $champ); |
|
| 114 | + $champ = end($champ); |
|
| 115 | + // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 116 | + $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 117 | + if ($n = |
|
| 118 | + ($options['score'] || $options['matches']) |
|
| 119 | + ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER) |
|
| 120 | + : preg_match($preg, $value) |
|
| 121 | + ) { |
|
| 122 | + $vu = true; |
|
| 123 | + |
|
| 124 | + if ($options['champs']) { |
|
| 125 | + $champs_vus[$champ] = $t[$champ]; |
|
| 126 | + } |
|
| 127 | + if ($options['score']) { |
|
| 128 | + $score += $n * $poids; |
|
| 129 | + } |
|
| 130 | + if ($options['matches']) { |
|
| 131 | + $matches[$champ] = $regs; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if (!$options['champs'] |
|
| 135 | + and !$options['score'] |
|
| 136 | + and !$options['matches'] |
|
| 137 | + ) { |
|
| 138 | + break; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + if ($vu) { |
|
| 144 | + if (!isset($results)) { |
|
| 145 | + $results = array(); |
|
| 146 | + } |
|
| 147 | + $results[$id] = array(); |
|
| 148 | + if ($champs_vus) { |
|
| 149 | + $results[$id]['champs'] = $champs_vus; |
|
| 150 | + } |
|
| 151 | + if ($score) { |
|
| 152 | + $results[$id]['score'] = $score; |
|
| 153 | + } |
|
| 154 | + if ($matches) { |
|
| 155 | + $results[$id]['matches'] = $matches; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + // Gerer les donnees associees |
|
| 163 | + // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 164 | + // on ne sait passer que par table de laison en 1 coup |
|
| 165 | + if (isset($jointures[$table]) |
|
| 166 | + and $joints = recherche_en_base( |
|
| 167 | + $recherche, |
|
| 168 | + $jointures[$table], |
|
| 169 | + array_merge($options, array('jointures' => false)) |
|
| 170 | + ) |
|
| 171 | + ) { |
|
| 172 | + include_spip('action/editer_liens'); |
|
| 173 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 174 | + $cle_depart = id_table_objet($table); |
|
| 175 | + $table_depart = table_objet($table, $serveur); |
|
| 176 | + $desc_depart = $trouver_table($table_depart, $serveur); |
|
| 177 | + $depart_associable = objet_associable($table); |
|
| 178 | + foreach ($joints as $table_liee => $ids_trouves) { |
|
| 179 | + // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 180 | + if ( |
|
| 181 | + !( |
|
| 182 | + $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}", "inc", true) |
|
| 183 | + or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}", "inc", true) |
|
| 184 | + or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie", "inc", true) |
|
| 185 | + ) |
|
| 186 | + ) { |
|
| 187 | + $cle_arrivee = id_table_objet($table_liee); |
|
| 188 | + $table_arrivee = table_objet($table_liee, $serveur); |
|
| 189 | + $desc_arrivee = $trouver_table($table_arrivee, $serveur); |
|
| 190 | + // cas simple : $cle_depart dans la table_liee |
|
| 191 | + if (isset($desc_arrivee['field'][$cle_depart])) { |
|
| 192 | + $s = sql_select("$cle_depart, $cle_arrivee", $desc_arrivee['table_sql'], |
|
| 193 | + sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur); |
|
| 194 | + } // cas simple : $cle_arrivee dans la table |
|
| 195 | + elseif (isset($desc_depart['field'][$cle_arrivee])) { |
|
| 196 | + $s = sql_select("$cle_depart, $cle_arrivee", $desc_depart['table_sql'], |
|
| 197 | + sql_in($cle_arrivee, array_keys($ids_trouves)), '', '', '', '', $serveur); |
|
| 198 | + } |
|
| 199 | + // sinon cherchons une table de liaison |
|
| 200 | + // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 201 | + elseif ($l = objet_associable($table_liee)) { |
|
| 202 | + list($primary, $table_liens) = $l; |
|
| 203 | + $s = sql_select("id_objet as $cle_depart, $primary as $cle_arrivee", $table_liens, |
|
| 204 | + array("objet='$table'", sql_in($primary, array_keys($ids_trouves))), '', '', '', '', $serveur); |
|
| 205 | + } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 206 | + elseif ($l = $depart_associable) { |
|
| 207 | + list($primary, $table_liens) = $l; |
|
| 208 | + $s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens, |
|
| 209 | + array("objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))), '', '', '', '', $serveur); |
|
| 210 | + } // cas table de liaison generique spip_xxx_yyy |
|
| 211 | + elseif ($t = $trouver_table($table_arrivee . "_" . $table_depart, $serveur) |
|
| 212 | + or $t = $trouver_table($table_depart . "_" . $table_arrivee, $serveur) |
|
| 213 | + ) { |
|
| 214 | + $s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 215 | + '', '', '', '', $serveur); |
|
| 216 | + } |
|
| 217 | + } else { |
|
| 218 | + list($cle_depart, $cle_arrivee, $s) = $rechercher_joints($table, $table_liee, array_keys($ids_trouves), |
|
| 219 | + $serveur); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) { |
|
| 223 | + $id = $t[$cle_depart]; |
|
| 224 | + $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 225 | + if (!isset($results)) { |
|
| 226 | + $results = array(); |
|
| 227 | + } |
|
| 228 | + if (!isset($results[$id])) { |
|
| 229 | + $results[$id] = array(); |
|
| 230 | + } |
|
| 231 | + if (isset($joint['score']) and $joint['score']) { |
|
| 232 | + if (!isset($results[$id]['score'])) { |
|
| 233 | + $results[$id]['score'] = 0; |
|
| 234 | + } |
|
| 235 | + $results[$id]['score'] += $joint['score']; |
|
| 236 | + } |
|
| 237 | + if (isset($joint['champs']) and $joint['champs']) { |
|
| 238 | + foreach ($joint['champs'] as $c => $val) { |
|
| 239 | + $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + if (isset($joint['matches']) and $joint['matches']) { |
|
| 243 | + foreach ($joint['matches'] as $c => $val) { |
|
| 244 | + $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + return $results; |
|
| 252 | 252 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $_id_table = reset($_id_table); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $requete['SELECT'][] = "t." . $_id_table; |
|
| 71 | + $requete['SELECT'][] = "t.".$_id_table; |
|
| 72 | 72 | $a = array(); |
| 73 | 73 | // Recherche fulltext |
| 74 | 74 | foreach ($champs as $champ => $poids) { |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | $champ = "t.$champ"; |
| 80 | 80 | } |
| 81 | 81 | $requete['SELECT'][] = $champ; |
| 82 | - $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 82 | + $a[] = $champ.' '.$methode.' '.$q; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | if ($a) { |
| 86 | 86 | $requete['WHERE'][] = join(" OR ", $a); |
| 87 | 87 | } |
| 88 | - $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 88 | + $requete['FROM'][] = table_objet_sql($table).' AS t'; |
|
| 89 | 89 | |
| 90 | 90 | $results = array(); |
| 91 | 91 | |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | $s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens, |
| 209 | 209 | array("objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))), '', '', '', '', $serveur); |
| 210 | 210 | } // cas table de liaison generique spip_xxx_yyy |
| 211 | - elseif ($t = $trouver_table($table_arrivee . "_" . $table_depart, $serveur) |
|
| 212 | - or $t = $trouver_table($table_depart . "_" . $table_arrivee, $serveur) |
|
| 211 | + elseif ($t = $trouver_table($table_arrivee."_".$table_depart, $serveur) |
|
| 212 | + or $t = $trouver_table($table_depart."_".$table_arrivee, $serveur) |
|
| 213 | 213 | ) { |
| 214 | 214 | $s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)), |
| 215 | 215 | '', '', '', '', $serveur); |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | if (isset($joint['champs']) and $joint['champs']) { |
| 238 | 238 | foreach ($joint['champs'] as $c => $val) { |
| 239 | - $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 239 | + $results[$id]['champs'][$table_liee.'.'.$c] = $val; |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | if (isset($joint['matches']) and $joint['matches']) { |
| 243 | 243 | foreach ($joint['matches'] as $c => $val) { |
| 244 | - $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 244 | + $results[$id]['matches'][$table_liee.'.'.$c] = $val; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/acces'); |
@@ -101,93 +101,93 @@ discard block |
||
| 101 | 101 | * @return int|bool Timestamp du verrou, false si erreur |
| 102 | 102 | */ |
| 103 | 103 | function spip_nfslock($fichier, $max_age = 0) { |
| 104 | - $tries = 0; |
|
| 104 | + $tries = 0; |
|
| 105 | 105 | |
| 106 | - if (!$max_age) { |
|
| 107 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | - } |
|
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 106 | + if (!$max_age) { |
|
| 107 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | + } |
|
| 109 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - /* |
|
| 112 | + /* |
|
| 113 | 113 | * 1. create a tmp file with a psuedo random file name. we also make |
| 114 | 114 | * tpath which is a buffer to store the full pathname of the tmp file. |
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | - $id = creer_uniqid(); |
|
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | - $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | - if (!$tmpfd) { /* open failed */ |
|
| 121 | - @fclose($tmpfd); |
|
| 122 | - spip_unlink($tpath); |
|
| 117 | + $id = creer_uniqid(); |
|
| 118 | + $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | + $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | + if (!$tmpfd) { /* open failed */ |
|
| 121 | + @fclose($tmpfd); |
|
| 122 | + spip_unlink($tpath); |
|
| 123 | 123 | |
| 124 | - return false; //NFSL_SYSF |
|
| 125 | - } |
|
| 124 | + return false; //NFSL_SYSF |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /* |
|
| 127 | + /* |
|
| 128 | 128 | * 2. make fullpath, a buffer for the full pathname of the lock file. |
| 129 | 129 | * then start looping trying to lock it |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - while ($tries < 10) { |
|
| 133 | - /* |
|
| 132 | + while ($tries < 10) { |
|
| 133 | + /* |
|
| 134 | 134 | * 3. link tmp file to lock file. if it goes, we win and we clean |
| 135 | 135 | * up and return the st_ctime of the lock file. |
| 136 | 136 | */ |
| 137 | 137 | |
| 138 | - if (link($tpath, $lock_file) == 1) { |
|
| 139 | - spip_unlink($tpath); /* got it! */ |
|
| 140 | - @fclose($tmpfd); |
|
| 141 | - if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | - spip_unlink($lock_file); |
|
| 138 | + if (link($tpath, $lock_file) == 1) { |
|
| 139 | + spip_unlink($tpath); /* got it! */ |
|
| 140 | + @fclose($tmpfd); |
|
| 141 | + if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | + spip_unlink($lock_file); |
|
| 143 | 143 | |
| 144 | - return false; // (NFSL_SYSF); |
|
| 145 | - } |
|
| 144 | + return false; // (NFSL_SYSF); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return ($our_tmp['ctime']); |
|
| 148 | - } |
|
| 147 | + return ($our_tmp['ctime']); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /* |
|
| 150 | + /* |
|
| 151 | 151 | * 4. the lock failed. check for a stale lock file, being mindful |
| 152 | 152 | * of NFS and the fact the time is set from the NFS server. we |
| 153 | 153 | * do a write on the tmp file to update its time to the server's |
| 154 | 154 | * idea of "now." |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | - $old_stat = lstat($lock_file); |
|
| 158 | - if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | - break; |
|
| 160 | - } /* something bogus is going on */ |
|
| 157 | + $old_stat = lstat($lock_file); |
|
| 158 | + if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | + break; |
|
| 160 | + } /* something bogus is going on */ |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | - if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | - spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | - $tries++; |
|
| 166 | - /* It is CRITICAL that we sleep after breaking |
|
| 163 | + if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | + spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | + $tries++; |
|
| 166 | + /* It is CRITICAL that we sleep after breaking |
|
| 167 | 167 | * the lock. Otherwise, we could race with |
| 168 | 168 | * another process and unlink it's newly- |
| 169 | 169 | * created file. |
| 170 | 170 | */ |
| 171 | - sleep(1 + rand(0, 4)); |
|
| 172 | - continue; |
|
| 173 | - } |
|
| 171 | + sleep(1 + rand(0, 4)); |
|
| 172 | + continue; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /* |
|
| 175 | + /* |
|
| 176 | 176 | * 5. try again |
| 177 | 177 | */ |
| 178 | 178 | |
| 179 | - $tries++; |
|
| 180 | - sleep(1 + rand(0, 4)); |
|
| 181 | - } |
|
| 179 | + $tries++; |
|
| 180 | + sleep(1 + rand(0, 4)); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /* |
|
| 183 | + /* |
|
| 184 | 184 | * 6. give up, failure. |
| 185 | 185 | */ |
| 186 | 186 | |
| 187 | - spip_unlink($tpath); |
|
| 188 | - @fclose($tmpfd); |
|
| 187 | + spip_unlink($tpath); |
|
| 188 | + @fclose($tmpfd); |
|
| 189 | 189 | |
| 190 | - return false; //(NFSL_LOCKED); |
|
| 190 | + return false; //(NFSL_LOCKED); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -231,73 +231,73 @@ discard block |
||
| 231 | 231 | * return bool true si déverrouillé, false sinon |
| 232 | 232 | */ |
| 233 | 233 | function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) { |
| 234 | - $id = creer_uniqid(); |
|
| 235 | - if (!$max_age) { |
|
| 236 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | - } |
|
| 234 | + $id = creer_uniqid(); |
|
| 235 | + if (!$max_age) { |
|
| 236 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - /* |
|
| 239 | + /* |
|
| 240 | 240 | * 1. Build a temp file and stat that to get an idea of what the server |
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | - $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | - if ((!$tmpfd) |
|
| 247 | - or (@fputs($tmpfd, 'zz', 2) != 2) |
|
| 248 | - or !($our_tmp = fstat($tmpfd)) |
|
| 249 | - ) { |
|
| 250 | - /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 251 | - @fclose($tmpfd); |
|
| 252 | - spip_unlink($tpath); |
|
| 244 | + $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | + $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | + if ((!$tmpfd) |
|
| 247 | + or (@fputs($tmpfd, 'zz', 2) != 2) |
|
| 248 | + or !($our_tmp = fstat($tmpfd)) |
|
| 249 | + ) { |
|
| 250 | + /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 251 | + @fclose($tmpfd); |
|
| 252 | + spip_unlink($tpath); |
|
| 253 | 253 | |
| 254 | - return false; //(NFSL_SYSF); |
|
| 255 | - } |
|
| 254 | + return false; //(NFSL_SYSF); |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 258 | - spip_unlink($tpath); |
|
| 257 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 258 | + spip_unlink($tpath); |
|
| 259 | 259 | |
| 260 | - /* |
|
| 260 | + /* |
|
| 261 | 261 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 262 | 262 | */ |
| 263 | 263 | |
| 264 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 264 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 265 | 265 | |
| 266 | - /* |
|
| 266 | + /* |
|
| 267 | 267 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
| 268 | 268 | * lock has expired, sleep the usual random interval before returning. |
| 269 | 269 | * If we didn't sleep, there could be a race if the caller immediately |
| 270 | 270 | * tries to relock the file. |
| 271 | 271 | */ |
| 272 | 272 | |
| 273 | - if (($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 274 | - && ($old_stat['ctime'] == $birth) |
|
| 275 | - ) { /* hasn't been modified since birth */ |
|
| 276 | - if (!$test) { |
|
| 277 | - spip_unlink($lock_file); |
|
| 278 | - } /* so the lock is ours to remove */ |
|
| 279 | - if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 280 | - if (!$test) { |
|
| 281 | - return false; |
|
| 282 | - } //(NFSL_LOST); |
|
| 283 | - sleep(1 + (random(0, 4))); /* so sleep a bit */ |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - return true;//(NFSL_OK); /* success */ |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /* |
|
| 273 | + if (($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 274 | + && ($old_stat['ctime'] == $birth) |
|
| 275 | + ) { /* hasn't been modified since birth */ |
|
| 276 | + if (!$test) { |
|
| 277 | + spip_unlink($lock_file); |
|
| 278 | + } /* so the lock is ours to remove */ |
|
| 279 | + if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 280 | + if (!$test) { |
|
| 281 | + return false; |
|
| 282 | + } //(NFSL_LOST); |
|
| 283 | + sleep(1 + (random(0, 4))); /* so sleep a bit */ |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + return true;//(NFSL_OK); /* success */ |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /* |
|
| 290 | 290 | * 4. Either ctime has been modified, or the entire lock file is missing. |
| 291 | 291 | * If the lock should still be ours, based on the ctime of the temp |
| 292 | 292 | * file, return with NFSL_STOLEN. If not, then our lock is expired and |
| 293 | 293 | * someone else has grabbed the file, so return NFSL_LOST. |
| 294 | 294 | */ |
| 295 | 295 | |
| 296 | - if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 297 | - return false; |
|
| 298 | - } //(NFSL_STOLEN); |
|
| 296 | + if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 297 | + return false; |
|
| 298 | + } //(NFSL_STOLEN); |
|
| 299 | 299 | |
| 300 | - return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 300 | + return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
@@ -321,5 +321,5 @@ discard block |
||
| 321 | 321 | * return bool true si déverrouillé, false sinon |
| 322 | 322 | */ |
| 323 | 323 | function spip_nfslock_test($fichier, $birth, $max_age = 0) { |
| 324 | - return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 324 | + return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 325 | 325 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (!$max_age) { |
| 107 | 107 | $max_age = _DEFAULT_LOCKTIME; |
| 108 | 108 | } |
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 109 | + $lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | /* |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | 117 | $id = creer_uniqid(); |
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 118 | + $tpath = _DIR_TMP."slock.$id"; |
|
| 119 | 119 | $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
| 120 | 120 | if (!$tmpfd) { /* open failed */ |
| 121 | 121 | @fclose($tmpfd); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 244 | + $tpath = _DIR_TMP."stime.$id"; |
|
| 245 | 245 | $tmpfd = @fopen($tpath, 'w'); |
| 246 | 246 | if ((!$tmpfd) |
| 247 | 247 | or (@fputs($tmpfd, 'zz', 2) != 2) |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | return false; //(NFSL_SYSF); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 257 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 258 | 258 | spip_unlink($tpath); |
| 259 | 259 | |
| 260 | 260 | /* |
| 261 | 261 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 262 | 262 | */ |
| 263 | 263 | |
| 264 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 264 | + $lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8); |
|
| 265 | 265 | |
| 266 | 266 | /* |
| 267 | 267 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | if (!$test) { |
| 281 | 281 | return false; |
| 282 | 282 | } //(NFSL_LOST); |
| 283 | - sleep(1 + (random(0, 4))); /* so sleep a bit */ |
|
| 283 | + sleep(1 + (random(0, 4))); /* so sleep a bit */ |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - return true;//(NFSL_OK); /* success */ |
|
| 286 | + return true; //(NFSL_OK); /* success */ |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /* |