@@ -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 | include_spip('inc/filtres'); |
| 23 | 23 | include_spip('inc/lang'); |
@@ -39,21 +39,21 @@ discard block |
||
| 39 | 39 | **/ |
| 40 | 40 | function definir_puce() { |
| 41 | 41 | |
| 42 | - // Attention au sens, qui n'est pas defini de la meme facon dans |
|
| 43 | - // l'espace prive (spip_lang est la langue de l'interface, lang_dir |
|
| 44 | - // celle du texte) et public (spip_lang est la langue du texte) |
|
| 45 | - $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
|
| 42 | + // Attention au sens, qui n'est pas defini de la meme facon dans |
|
| 43 | + // l'espace prive (spip_lang est la langue de l'interface, lang_dir |
|
| 44 | + // celle du texte) et public (spip_lang est la langue du texte) |
|
| 45 | + $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
|
| 46 | 46 | |
| 47 | - $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 48 | - if ($dir == 'rtl') { |
|
| 49 | - $p .= '_rtl'; |
|
| 50 | - } |
|
| 47 | + $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 48 | + if ($dir == 'rtl') { |
|
| 49 | + $p .= '_rtl'; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - if (!isset($GLOBALS[$p])) { |
|
| 53 | - $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 54 | - } |
|
| 52 | + if (!isset($GLOBALS[$p])) { |
|
| 53 | + $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return $GLOBALS[$p]; |
|
| 56 | + return $GLOBALS[$p]; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | // dont on souhaite qu'ils provoquent un saut de paragraphe |
| 62 | 62 | |
| 63 | 63 | if (!defined('_BALISES_BLOCS')) { |
| 64 | - define( |
|
| 65 | - '_BALISES_BLOCS', |
|
| 66 | - 'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style' |
|
| 67 | - ); |
|
| 64 | + define( |
|
| 65 | + '_BALISES_BLOCS', |
|
| 66 | + 'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style' |
|
| 67 | + ); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (!defined('_BALISES_BLOCS_REGEXP')) { |
| 71 | - define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS'); |
|
| 71 | + define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // |
@@ -79,106 +79,106 @@ discard block |
||
| 79 | 79 | // une $source differente ; le script detecte automagiquement si ce qu'on |
| 80 | 80 | // echappe est un div ou un span |
| 81 | 81 | function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) { |
| 82 | - if (!strlen($rempl)) { |
|
| 83 | - return ''; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // Tester si on echappe en span ou en div |
|
| 87 | - if (is_null($mode) or !in_array($mode, ['div', 'span'])) { |
|
| 88 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span'; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // Decouper en morceaux, base64 a des probleme selon la taille de la pile |
|
| 92 | - $taille = 30000; |
|
| 93 | - $return = ''; |
|
| 94 | - for ($i = 0; $i < strlen($rempl); $i += $taille) { |
|
| 95 | - // Convertir en base64 et cacher dans un attribut |
|
| 96 | - // utiliser les " pour eviter le re-encodage de ' et ’ |
|
| 97 | - $base64 = base64_encode(substr($rempl, $i, $taille)); |
|
| 98 | - $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>"; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $return; |
|
| 82 | + if (!strlen($rempl)) { |
|
| 83 | + return ''; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // Tester si on echappe en span ou en div |
|
| 87 | + if (is_null($mode) or !in_array($mode, ['div', 'span'])) { |
|
| 88 | + $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span'; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // Decouper en morceaux, base64 a des probleme selon la taille de la pile |
|
| 92 | + $taille = 30000; |
|
| 93 | + $return = ''; |
|
| 94 | + for ($i = 0; $i < strlen($rempl); $i += $taille) { |
|
| 95 | + // Convertir en base64 et cacher dans un attribut |
|
| 96 | + // utiliser les " pour eviter le re-encodage de ' et ’ |
|
| 97 | + $base64 = base64_encode(substr($rempl, $i, $taille)); |
|
| 98 | + $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>"; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $return; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | // Echapper les <html>...</ html> |
| 106 | 106 | function traiter_echap_html_dist($regs) { |
| 107 | - return $regs[3]; |
|
| 107 | + return $regs[3]; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // Echapper les <pre>...</ pre> |
| 111 | 111 | function traiter_echap_pre_dist($regs) { |
| 112 | - // echapper les <code> dans <pre> |
|
| 113 | - $pre = $regs[3]; |
|
| 114 | - |
|
| 115 | - // echapper les < dans <code> |
|
| 116 | - // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code> |
|
| 117 | - if ( |
|
| 118 | - strpos($pre, '<') !== false |
|
| 119 | - and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER) |
|
| 120 | - ) { |
|
| 121 | - foreach ($matches as $m) { |
|
| 122 | - if ($m[1] === 'code') { |
|
| 123 | - $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>'; |
|
| 124 | - $pre = str_replace($m[0], $code, $pre); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - return "<pre>$pre</pre>"; |
|
| 112 | + // echapper les <code> dans <pre> |
|
| 113 | + $pre = $regs[3]; |
|
| 114 | + |
|
| 115 | + // echapper les < dans <code> |
|
| 116 | + // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code> |
|
| 117 | + if ( |
|
| 118 | + strpos($pre, '<') !== false |
|
| 119 | + and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER) |
|
| 120 | + ) { |
|
| 121 | + foreach ($matches as $m) { |
|
| 122 | + if ($m[1] === 'code') { |
|
| 123 | + $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>'; |
|
| 124 | + $pre = str_replace($m[0], $code, $pre); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + return "<pre>$pre</pre>"; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Echapper les <code>...</ code> |
| 132 | 132 | function traiter_echap_code_dist($regs) { |
| 133 | - [, , $att, $corps] = $regs; |
|
| 134 | - $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
|
| 135 | - |
|
| 136 | - // ne pas mettre le <div...> s'il n'y a qu'une ligne |
|
| 137 | - if (is_int(strpos($echap, "\n"))) { |
|
| 138 | - // supprimer les sauts de ligne debut/fin |
|
| 139 | - // (mais pas les espaces => ascii art). |
|
| 140 | - $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap); |
|
| 141 | - $echap = nl2br($echap); |
|
| 142 | - $echap = "<div style='text-align: left;' " |
|
| 143 | - . "class='spip_code' dir='ltr'><code$att>" |
|
| 144 | - . $echap . '</code></div>'; |
|
| 145 | - } else { |
|
| 146 | - $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>'; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $echap = str_replace("\t", ' ', $echap); |
|
| 150 | - $echap = str_replace(' ', ' ', $echap); |
|
| 151 | - |
|
| 152 | - return $echap; |
|
| 133 | + [, , $att, $corps] = $regs; |
|
| 134 | + $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
|
| 135 | + |
|
| 136 | + // ne pas mettre le <div...> s'il n'y a qu'une ligne |
|
| 137 | + if (is_int(strpos($echap, "\n"))) { |
|
| 138 | + // supprimer les sauts de ligne debut/fin |
|
| 139 | + // (mais pas les espaces => ascii art). |
|
| 140 | + $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap); |
|
| 141 | + $echap = nl2br($echap); |
|
| 142 | + $echap = "<div style='text-align: left;' " |
|
| 143 | + . "class='spip_code' dir='ltr'><code$att>" |
|
| 144 | + . $echap . '</code></div>'; |
|
| 145 | + } else { |
|
| 146 | + $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>'; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $echap = str_replace("\t", ' ', $echap); |
|
| 150 | + $echap = str_replace(' ', ' ', $echap); |
|
| 151 | + |
|
| 152 | + return $echap; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Echapper les <cadre>...</ cadre> aka <frame>...</ frame> |
| 156 | 156 | function traiter_echap_cadre_dist($regs) { |
| 157 | - $echap = trim(entites_html($regs[3])); |
|
| 158 | - // compter les lignes un peu plus finement qu'avec les \n |
|
| 159 | - $lignes = explode("\n", trim($echap)); |
|
| 160 | - $n = 0; |
|
| 161 | - foreach ($lignes as $l) { |
|
| 162 | - $n += floor(strlen($l) / 60) + 1; |
|
| 163 | - } |
|
| 164 | - $n = max($n, 2); |
|
| 165 | - $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>"; |
|
| 166 | - |
|
| 167 | - return $echap; |
|
| 157 | + $echap = trim(entites_html($regs[3])); |
|
| 158 | + // compter les lignes un peu plus finement qu'avec les \n |
|
| 159 | + $lignes = explode("\n", trim($echap)); |
|
| 160 | + $n = 0; |
|
| 161 | + foreach ($lignes as $l) { |
|
| 162 | + $n += floor(strlen($l) / 60) + 1; |
|
| 163 | + } |
|
| 164 | + $n = max($n, 2); |
|
| 165 | + $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>"; |
|
| 166 | + |
|
| 167 | + return $echap; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | function traiter_echap_frame_dist($regs) { |
| 171 | - return traiter_echap_cadre_dist($regs); |
|
| 171 | + return traiter_echap_cadre_dist($regs); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | function traiter_echap_script_dist($regs) { |
| 175 | - // rendre joli (et inactif) si c'est un script language=php |
|
| 176 | - if (preg_match(',<script\b[^>]+php,ims', $regs[0])) { |
|
| 177 | - return highlight_string($regs[0], true); |
|
| 178 | - } |
|
| 175 | + // rendre joli (et inactif) si c'est un script language=php |
|
| 176 | + if (preg_match(',<script\b[^>]+php,ims', $regs[0])) { |
|
| 177 | + return highlight_string($regs[0], true); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // Cas normal : le script passe tel quel |
|
| 181 | - return $regs[0]; |
|
| 180 | + // Cas normal : le script passe tel quel |
|
| 181 | + return $regs[0]; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\b[^>]*)?>(.*)</\1>,UimsS'); |
@@ -196,67 +196,67 @@ discard block |
||
| 196 | 196 | * @return string|string[] |
| 197 | 197 | */ |
| 198 | 198 | function echappe_html( |
| 199 | - $letexte, |
|
| 200 | - $source = '', |
|
| 201 | - $no_transform = false, |
|
| 202 | - $preg = '', |
|
| 203 | - $callback_prefix = '' |
|
| 199 | + $letexte, |
|
| 200 | + $source = '', |
|
| 201 | + $no_transform = false, |
|
| 202 | + $preg = '', |
|
| 203 | + $callback_prefix = '' |
|
| 204 | 204 | ) { |
| 205 | - if (!is_string($letexte) or !strlen($letexte)) { |
|
| 206 | - return $letexte; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - if ( |
|
| 210 | - ($preg or strpos($letexte, '<') !== false) |
|
| 211 | - and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER) |
|
| 212 | - ) { |
|
| 213 | - foreach ($matches as $regs) { |
|
| 214 | - // echappements tels quels ? |
|
| 215 | - if ($no_transform) { |
|
| 216 | - $echap = $regs[0]; |
|
| 217 | - } // sinon les traiter selon le cas |
|
| 218 | - else { |
|
| 219 | - if ( |
|
| 220 | - function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 221 | - or function_exists($f = $f . '_dist') |
|
| 222 | - ) { |
|
| 223 | - $echap = $f($regs); |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $p = strpos($letexte, (string) $regs[0]); |
|
| 228 | - $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0])); |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - if ($no_transform) { |
|
| 233 | - return $letexte; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - // Echapper le php pour faire joli (ici, c'est pas pour la securite) |
|
| 237 | - // seulement si on a echappe les <script> |
|
| 238 | - // (derogatoire car on ne peut pas faire passer < ? ... ? > |
|
| 239 | - // dans une callback autonommee |
|
| 240 | - if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) { |
|
| 241 | - if ( |
|
| 242 | - strpos($letexte, '<' . '?') !== false and preg_match_all( |
|
| 243 | - ',<[?].*($|[?]>),UisS', |
|
| 244 | - $letexte, |
|
| 245 | - $matches, |
|
| 246 | - PREG_SET_ORDER |
|
| 247 | - ) |
|
| 248 | - ) { |
|
| 249 | - foreach ($matches as $regs) { |
|
| 250 | - $letexte = str_replace( |
|
| 251 | - $regs[0], |
|
| 252 | - code_echappement(highlight_string($regs[0], true), $source), |
|
| 253 | - $letexte |
|
| 254 | - ); |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - return $letexte; |
|
| 205 | + if (!is_string($letexte) or !strlen($letexte)) { |
|
| 206 | + return $letexte; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + if ( |
|
| 210 | + ($preg or strpos($letexte, '<') !== false) |
|
| 211 | + and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER) |
|
| 212 | + ) { |
|
| 213 | + foreach ($matches as $regs) { |
|
| 214 | + // echappements tels quels ? |
|
| 215 | + if ($no_transform) { |
|
| 216 | + $echap = $regs[0]; |
|
| 217 | + } // sinon les traiter selon le cas |
|
| 218 | + else { |
|
| 219 | + if ( |
|
| 220 | + function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 221 | + or function_exists($f = $f . '_dist') |
|
| 222 | + ) { |
|
| 223 | + $echap = $f($regs); |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $p = strpos($letexte, (string) $regs[0]); |
|
| 228 | + $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0])); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + if ($no_transform) { |
|
| 233 | + return $letexte; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + // Echapper le php pour faire joli (ici, c'est pas pour la securite) |
|
| 237 | + // seulement si on a echappe les <script> |
|
| 238 | + // (derogatoire car on ne peut pas faire passer < ? ... ? > |
|
| 239 | + // dans une callback autonommee |
|
| 240 | + if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) { |
|
| 241 | + if ( |
|
| 242 | + strpos($letexte, '<' . '?') !== false and preg_match_all( |
|
| 243 | + ',<[?].*($|[?]>),UisS', |
|
| 244 | + $letexte, |
|
| 245 | + $matches, |
|
| 246 | + PREG_SET_ORDER |
|
| 247 | + ) |
|
| 248 | + ) { |
|
| 249 | + foreach ($matches as $regs) { |
|
| 250 | + $letexte = str_replace( |
|
| 251 | + $regs[0], |
|
| 252 | + code_echappement(highlight_string($regs[0], true), $source), |
|
| 253 | + $letexte |
|
| 254 | + ); |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + return $letexte; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // |
@@ -264,57 +264,57 @@ discard block |
||
| 264 | 264 | // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes |
| 265 | 265 | // par propre() : exemple dans multi et dans typo() |
| 266 | 266 | function echappe_retour($letexte, $source = '', $filtre = '') { |
| 267 | - if (strpos($letexte, (string) "base64$source")) { |
|
| 268 | - # spip_log(spip_htmlspecialchars($letexte)); ## pour les curieux |
|
| 269 | - $max_prof = 5; |
|
| 270 | - while ( |
|
| 271 | - strpos($letexte, '<') !== false |
|
| 272 | - and |
|
| 273 | - preg_match_all( |
|
| 274 | - ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS', |
|
| 275 | - $letexte, |
|
| 276 | - $regs, |
|
| 277 | - PREG_SET_ORDER |
|
| 278 | - ) |
|
| 279 | - and $max_prof-- |
|
| 280 | - ) { |
|
| 281 | - foreach ($regs as $reg) { |
|
| 282 | - $rempl = base64_decode(extraire_attribut($reg[0], 'title')); |
|
| 283 | - // recherche d'attributs supplementaires |
|
| 284 | - $at = []; |
|
| 285 | - foreach (['lang', 'dir'] as $attr) { |
|
| 286 | - if ($a = extraire_attribut($reg[0], $attr)) { |
|
| 287 | - $at[$attr] = $a; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - if ($at) { |
|
| 291 | - $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>'; |
|
| 292 | - foreach ($at as $attr => $a) { |
|
| 293 | - $rempl = inserer_attribut($rempl, $attr, $a); |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - if ($filtre) { |
|
| 297 | - $rempl = $filtre($rempl); |
|
| 298 | - } |
|
| 299 | - $letexte = str_replace($reg[0], $rempl, $letexte); |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - return $letexte; |
|
| 267 | + if (strpos($letexte, (string) "base64$source")) { |
|
| 268 | + # spip_log(spip_htmlspecialchars($letexte)); ## pour les curieux |
|
| 269 | + $max_prof = 5; |
|
| 270 | + while ( |
|
| 271 | + strpos($letexte, '<') !== false |
|
| 272 | + and |
|
| 273 | + preg_match_all( |
|
| 274 | + ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS', |
|
| 275 | + $letexte, |
|
| 276 | + $regs, |
|
| 277 | + PREG_SET_ORDER |
|
| 278 | + ) |
|
| 279 | + and $max_prof-- |
|
| 280 | + ) { |
|
| 281 | + foreach ($regs as $reg) { |
|
| 282 | + $rempl = base64_decode(extraire_attribut($reg[0], 'title')); |
|
| 283 | + // recherche d'attributs supplementaires |
|
| 284 | + $at = []; |
|
| 285 | + foreach (['lang', 'dir'] as $attr) { |
|
| 286 | + if ($a = extraire_attribut($reg[0], $attr)) { |
|
| 287 | + $at[$attr] = $a; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + if ($at) { |
|
| 291 | + $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>'; |
|
| 292 | + foreach ($at as $attr => $a) { |
|
| 293 | + $rempl = inserer_attribut($rempl, $attr, $a); |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + if ($filtre) { |
|
| 297 | + $rempl = $filtre($rempl); |
|
| 298 | + } |
|
| 299 | + $letexte = str_replace($reg[0], $rempl, $letexte); |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + return $letexte; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Reinserer le javascript de confiance (venant des modeles) |
| 308 | 308 | |
| 309 | 309 | function echappe_retour_modeles($letexte, $interdire_scripts = false) { |
| 310 | - $letexte = echappe_retour($letexte); |
|
| 310 | + $letexte = echappe_retour($letexte); |
|
| 311 | 311 | |
| 312 | - // Dans les appels directs hors squelette, securiser aussi ici |
|
| 313 | - if ($interdire_scripts) { |
|
| 314 | - $letexte = interdire_scripts($letexte); |
|
| 315 | - } |
|
| 312 | + // Dans les appels directs hors squelette, securiser aussi ici |
|
| 313 | + if ($interdire_scripts) { |
|
| 314 | + $letexte = interdire_scripts($letexte); |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - return trim($letexte); |
|
| 317 | + return trim($letexte); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
@@ -342,131 +342,131 @@ discard block |
||
| 342 | 342 | * Texte coupé |
| 343 | 343 | **/ |
| 344 | 344 | function couper($texte, $taille = 50, $suite = null) { |
| 345 | - if (!($length = strlen($texte)) or $taille <= 0) { |
|
| 346 | - return ''; |
|
| 347 | - } |
|
| 348 | - $offset = 400 + 2 * $taille; |
|
| 349 | - while ( |
|
| 350 | - $offset < $length |
|
| 351 | - and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille |
|
| 352 | - ) { |
|
| 353 | - $offset = 2 * $offset; |
|
| 354 | - } |
|
| 355 | - if ( |
|
| 356 | - $offset < $length |
|
| 357 | - && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null |
|
| 358 | - ) { |
|
| 359 | - $p_tag_fermant = strpos($texte, '>', $offset); |
|
| 360 | - if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) { |
|
| 361 | - $offset = $p_tag_fermant + 1; |
|
| 362 | - } // prolonger la coupe jusqu'au tag fermant suivant eventuel |
|
| 363 | - } |
|
| 364 | - $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */ |
|
| 365 | - |
|
| 366 | - if (!function_exists('nettoyer_raccourcis_typo')) { |
|
| 367 | - include_spip('inc/lien'); |
|
| 368 | - } |
|
| 369 | - $texte = nettoyer_raccourcis_typo($texte); |
|
| 370 | - |
|
| 371 | - // balises de sauts de ligne et paragraphe |
|
| 372 | - $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte); |
|
| 373 | - $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 374 | - |
|
| 375 | - // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
|
| 376 | - $texte = str_replace("\n\n", "\r", $texte); |
|
| 377 | - |
|
| 378 | - // supprimer les tags |
|
| 379 | - $texte = supprimer_tags($texte); |
|
| 380 | - $texte = trim(str_replace("\n", ' ', $texte)); |
|
| 381 | - $texte .= "\n"; // marquer la fin |
|
| 382 | - |
|
| 383 | - // corriger la longueur de coupe |
|
| 384 | - // en fonction de la presence de caracteres utf |
|
| 385 | - if ($GLOBALS['meta']['charset'] == 'utf-8') { |
|
| 386 | - $long = charset2unicode($texte); |
|
| 387 | - $long = spip_substr($long, 0, max($taille, 1)); |
|
| 388 | - $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches); |
|
| 389 | - $taille += $nbcharutf; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - // couper au mot precedent |
|
| 394 | - $long = spip_substr($texte, 0, max($taille - 4, 1)); |
|
| 395 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 396 | - $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long); |
|
| 397 | - if (is_null($suite)) { |
|
| 398 | - $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : ' (...)'); |
|
| 399 | - } |
|
| 400 | - $points = $suite; |
|
| 401 | - |
|
| 402 | - // trop court ? ne pas faire de (...) |
|
| 403 | - if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
|
| 404 | - $points = ''; |
|
| 405 | - $long = spip_substr($texte, 0, $taille); |
|
| 406 | - $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long); |
|
| 407 | - // encore trop court ? couper au caractere |
|
| 408 | - if (spip_strlen($texte) < 0.75 * $taille) { |
|
| 409 | - $texte = $long; |
|
| 410 | - } |
|
| 411 | - } else { |
|
| 412 | - $texte = $court; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - if (strpos($texte, "\n")) { // la fin est encore la : c'est qu'on n'a pas de texte de suite |
|
| 416 | - $points = ''; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - // remettre les paragraphes |
|
| 420 | - $texte = preg_replace("/\r+/", "\n\n", $texte); |
|
| 421 | - |
|
| 422 | - // supprimer l'eventuelle entite finale mal coupee |
|
| 423 | - $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
|
| 424 | - |
|
| 425 | - return quote_amp(trim($texte)) . $points; |
|
| 345 | + if (!($length = strlen($texte)) or $taille <= 0) { |
|
| 346 | + return ''; |
|
| 347 | + } |
|
| 348 | + $offset = 400 + 2 * $taille; |
|
| 349 | + while ( |
|
| 350 | + $offset < $length |
|
| 351 | + and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille |
|
| 352 | + ) { |
|
| 353 | + $offset = 2 * $offset; |
|
| 354 | + } |
|
| 355 | + if ( |
|
| 356 | + $offset < $length |
|
| 357 | + && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null |
|
| 358 | + ) { |
|
| 359 | + $p_tag_fermant = strpos($texte, '>', $offset); |
|
| 360 | + if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) { |
|
| 361 | + $offset = $p_tag_fermant + 1; |
|
| 362 | + } // prolonger la coupe jusqu'au tag fermant suivant eventuel |
|
| 363 | + } |
|
| 364 | + $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */ |
|
| 365 | + |
|
| 366 | + if (!function_exists('nettoyer_raccourcis_typo')) { |
|
| 367 | + include_spip('inc/lien'); |
|
| 368 | + } |
|
| 369 | + $texte = nettoyer_raccourcis_typo($texte); |
|
| 370 | + |
|
| 371 | + // balises de sauts de ligne et paragraphe |
|
| 372 | + $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte); |
|
| 373 | + $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 374 | + |
|
| 375 | + // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
|
| 376 | + $texte = str_replace("\n\n", "\r", $texte); |
|
| 377 | + |
|
| 378 | + // supprimer les tags |
|
| 379 | + $texte = supprimer_tags($texte); |
|
| 380 | + $texte = trim(str_replace("\n", ' ', $texte)); |
|
| 381 | + $texte .= "\n"; // marquer la fin |
|
| 382 | + |
|
| 383 | + // corriger la longueur de coupe |
|
| 384 | + // en fonction de la presence de caracteres utf |
|
| 385 | + if ($GLOBALS['meta']['charset'] == 'utf-8') { |
|
| 386 | + $long = charset2unicode($texte); |
|
| 387 | + $long = spip_substr($long, 0, max($taille, 1)); |
|
| 388 | + $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches); |
|
| 389 | + $taille += $nbcharutf; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + // couper au mot precedent |
|
| 394 | + $long = spip_substr($texte, 0, max($taille - 4, 1)); |
|
| 395 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 396 | + $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long); |
|
| 397 | + if (is_null($suite)) { |
|
| 398 | + $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : ' (...)'); |
|
| 399 | + } |
|
| 400 | + $points = $suite; |
|
| 401 | + |
|
| 402 | + // trop court ? ne pas faire de (...) |
|
| 403 | + if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
|
| 404 | + $points = ''; |
|
| 405 | + $long = spip_substr($texte, 0, $taille); |
|
| 406 | + $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long); |
|
| 407 | + // encore trop court ? couper au caractere |
|
| 408 | + if (spip_strlen($texte) < 0.75 * $taille) { |
|
| 409 | + $texte = $long; |
|
| 410 | + } |
|
| 411 | + } else { |
|
| 412 | + $texte = $court; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + if (strpos($texte, "\n")) { // la fin est encore la : c'est qu'on n'a pas de texte de suite |
|
| 416 | + $points = ''; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + // remettre les paragraphes |
|
| 420 | + $texte = preg_replace("/\r+/", "\n\n", $texte); |
|
| 421 | + |
|
| 422 | + // supprimer l'eventuelle entite finale mal coupee |
|
| 423 | + $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
|
| 424 | + |
|
| 425 | + return quote_amp(trim($texte)) . $points; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
| 429 | 429 | function protege_js_modeles($t) { |
| 430 | - if (isset($GLOBALS['visiteur_session'])) { |
|
| 431 | - if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 432 | - if (!defined('_PROTEGE_JS_MODELES')) { |
|
| 433 | - include_spip('inc/acces'); |
|
| 434 | - define('_PROTEGE_JS_MODELES', creer_uniqid()); |
|
| 435 | - } |
|
| 436 | - foreach ($r as $regs) { |
|
| 437 | - $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t); |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 441 | - if (!defined('_PROTEGE_PHP_MODELES')) { |
|
| 442 | - include_spip('inc/acces'); |
|
| 443 | - define('_PROTEGE_PHP_MODELES', creer_uniqid()); |
|
| 444 | - } |
|
| 445 | - foreach ($r as $regs) { |
|
| 446 | - $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t); |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return $t; |
|
| 430 | + if (isset($GLOBALS['visiteur_session'])) { |
|
| 431 | + if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 432 | + if (!defined('_PROTEGE_JS_MODELES')) { |
|
| 433 | + include_spip('inc/acces'); |
|
| 434 | + define('_PROTEGE_JS_MODELES', creer_uniqid()); |
|
| 435 | + } |
|
| 436 | + foreach ($r as $regs) { |
|
| 437 | + $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t); |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 441 | + if (!defined('_PROTEGE_PHP_MODELES')) { |
|
| 442 | + include_spip('inc/acces'); |
|
| 443 | + define('_PROTEGE_PHP_MODELES', creer_uniqid()); |
|
| 444 | + } |
|
| 445 | + foreach ($r as $regs) { |
|
| 446 | + $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t); |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return $t; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
| 455 | 455 | function echapper_faux_tags($letexte) { |
| 456 | - if (strpos($letexte, '<') === false) { |
|
| 457 | - return $letexte; |
|
| 458 | - } |
|
| 459 | - $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 460 | - |
|
| 461 | - $letexte = ''; |
|
| 462 | - while (is_countable($textMatches) ? count($textMatches) : 0) { |
|
| 463 | - // un texte a echapper |
|
| 464 | - $letexte .= str_replace('<', '<', array_shift($textMatches)); |
|
| 465 | - // un tag html qui a servit a faite le split |
|
| 466 | - $letexte .= array_shift($textMatches); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - return $letexte; |
|
| 456 | + if (strpos($letexte, '<') === false) { |
|
| 457 | + return $letexte; |
|
| 458 | + } |
|
| 459 | + $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 460 | + |
|
| 461 | + $letexte = ''; |
|
| 462 | + while (is_countable($textMatches) ? count($textMatches) : 0) { |
|
| 463 | + // un texte a echapper |
|
| 464 | + $letexte .= str_replace('<', '<', array_shift($textMatches)); |
|
| 465 | + // un tag html qui a servit a faite le split |
|
| 466 | + $letexte .= array_shift($textMatches); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + return $letexte; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -479,47 +479,47 @@ discard block |
||
| 479 | 479 | * @return string |
| 480 | 480 | */ |
| 481 | 481 | function echapper_html_suspect($texte, $strict = true) { |
| 482 | - static $echapper_html_suspect; |
|
| 483 | - if (!$texte or !is_string($texte)) { |
|
| 484 | - return $texte; |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - if (!isset($echapper_html_suspect)) { |
|
| 488 | - $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true); |
|
| 489 | - } |
|
| 490 | - // si fonction personalisee, on delegue |
|
| 491 | - if ($echapper_html_suspect) { |
|
| 492 | - return $echapper_html_suspect($texte, $strict); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - if ( |
|
| 496 | - strpos($texte, '<') === false |
|
| 497 | - or strpos($texte, '=') === false |
|
| 498 | - ) { |
|
| 499 | - return $texte; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx= |
|
| 503 | - // car sinon on declenche sur les modeles ou ressources |
|
| 504 | - if ( |
|
| 505 | - !$strict and |
|
| 506 | - (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte)) |
|
| 507 | - ) { |
|
| 508 | - return $texte; |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - // on teste sur strlen car safehtml supprime le contenu dangereux |
|
| 512 | - // mais il peut aussi changer des ' en " sur les attributs html, |
|
| 513 | - // donc un test d'egalite est trop strict |
|
| 514 | - if (strlen(safehtml($texte)) !== strlen($texte)) { |
|
| 515 | - $texte = str_replace('<', '<', $texte); |
|
| 516 | - if (!function_exists('attribut_html')) { |
|
| 517 | - include_spip('inc/filtres'); |
|
| 518 | - } |
|
| 519 | - $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - return $texte; |
|
| 482 | + static $echapper_html_suspect; |
|
| 483 | + if (!$texte or !is_string($texte)) { |
|
| 484 | + return $texte; |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + if (!isset($echapper_html_suspect)) { |
|
| 488 | + $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true); |
|
| 489 | + } |
|
| 490 | + // si fonction personalisee, on delegue |
|
| 491 | + if ($echapper_html_suspect) { |
|
| 492 | + return $echapper_html_suspect($texte, $strict); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + if ( |
|
| 496 | + strpos($texte, '<') === false |
|
| 497 | + or strpos($texte, '=') === false |
|
| 498 | + ) { |
|
| 499 | + return $texte; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx= |
|
| 503 | + // car sinon on declenche sur les modeles ou ressources |
|
| 504 | + if ( |
|
| 505 | + !$strict and |
|
| 506 | + (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte)) |
|
| 507 | + ) { |
|
| 508 | + return $texte; |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + // on teste sur strlen car safehtml supprime le contenu dangereux |
|
| 512 | + // mais il peut aussi changer des ' en " sur les attributs html, |
|
| 513 | + // donc un test d'egalite est trop strict |
|
| 514 | + if (strlen(safehtml($texte)) !== strlen($texte)) { |
|
| 515 | + $texte = str_replace('<', '<', $texte); |
|
| 516 | + if (!function_exists('attribut_html')) { |
|
| 517 | + include_spip('inc/filtres'); |
|
| 518 | + } |
|
| 519 | + $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + return $texte; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | |
@@ -540,30 +540,30 @@ discard block |
||
| 540 | 540 | * Texte sécurisé |
| 541 | 541 | **/ |
| 542 | 542 | function safehtml($t) { |
| 543 | - static $safehtml; |
|
| 544 | - |
|
| 545 | - if (!$t or !is_string($t)) { |
|
| 546 | - return $t; |
|
| 547 | - } |
|
| 548 | - # attention safehtml nettoie deux ou trois caracteres de plus. A voir |
|
| 549 | - if (strpos($t, '<') === false) { |
|
| 550 | - return str_replace("\x00", '', $t); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - if (!function_exists('interdire_scripts')) { |
|
| 554 | - include_spip('inc/texte'); |
|
| 555 | - } |
|
| 556 | - $t = interdire_scripts($t); // jolifier le php |
|
| 557 | - $t = echappe_js($t); |
|
| 558 | - |
|
| 559 | - if (!isset($safehtml)) { |
|
| 560 | - $safehtml = charger_fonction('safehtml', 'inc', true); |
|
| 561 | - } |
|
| 562 | - if ($safehtml) { |
|
| 563 | - $t = $safehtml($t); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - return interdire_scripts($t); // interdire le php (2 precautions) |
|
| 543 | + static $safehtml; |
|
| 544 | + |
|
| 545 | + if (!$t or !is_string($t)) { |
|
| 546 | + return $t; |
|
| 547 | + } |
|
| 548 | + # attention safehtml nettoie deux ou trois caracteres de plus. A voir |
|
| 549 | + if (strpos($t, '<') === false) { |
|
| 550 | + return str_replace("\x00", '', $t); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + if (!function_exists('interdire_scripts')) { |
|
| 554 | + include_spip('inc/texte'); |
|
| 555 | + } |
|
| 556 | + $t = interdire_scripts($t); // jolifier le php |
|
| 557 | + $t = echappe_js($t); |
|
| 558 | + |
|
| 559 | + if (!isset($safehtml)) { |
|
| 560 | + $safehtml = charger_fonction('safehtml', 'inc', true); |
|
| 561 | + } |
|
| 562 | + if ($safehtml) { |
|
| 563 | + $t = $safehtml($t); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + return interdire_scripts($t); // interdire le php (2 precautions) |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
@@ -585,13 +585,13 @@ discard block |
||
| 585 | 585 | * Texte sans les modèles d'image |
| 586 | 586 | **/ |
| 587 | 587 | function supprime_img($letexte, $message = null) { |
| 588 | - if ($message === null) { |
|
| 589 | - $message = '(' . _T('img_indisponible') . ')'; |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - return preg_replace( |
|
| 593 | - ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 594 | - $message, |
|
| 595 | - $letexte |
|
| 596 | - ); |
|
| 588 | + if ($message === null) { |
|
| 589 | + $message = '(' . _T('img_indisponible') . ')'; |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + return preg_replace( |
|
| 593 | + ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 594 | + $message, |
|
| 595 | + $letexte |
|
| 596 | + ); |
|
| 597 | 597 | } |
@@ -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 | |
@@ -52,68 +52,68 @@ discard block |
||
| 52 | 52 | * cookie sécurisé ou non ? |
| 53 | 53 | **/ |
| 54 | 54 | function spip_setcookie($name = '', $value = '', $options = []) { |
| 55 | - static $to_secure_list = ['spip_session']; |
|
| 56 | - if (defined('_COOKIE_SECURE_LIST') and is_array(_COOKIE_SECURE_LIST)) { |
|
| 57 | - $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - if (!is_array($options)) { |
|
| 61 | - // anciens paramètres : |
|
| 62 | - # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '') |
|
| 63 | - $opt = func_get_args(); |
|
| 64 | - $opt = array_slice($opt, 2); |
|
| 65 | - $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !); |
|
| 66 | - if (isset($opt[0])) { |
|
| 67 | - $options['expires'] = $opt[0]; |
|
| 68 | - } |
|
| 69 | - if (isset($opt[1])) { |
|
| 70 | - $options['path'] = $opt[1]; |
|
| 71 | - } |
|
| 72 | - if (isset($opt[2])) { |
|
| 73 | - $options['domain'] = $opt[2]; |
|
| 74 | - } |
|
| 75 | - if (isset($opt[3])) { |
|
| 76 | - $options['secure'] = $opt[3]; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // expires |
|
| 81 | - if (!isset($options['expires'])) { |
|
| 82 | - $options['expires'] = 0; |
|
| 83 | - } |
|
| 84 | - if (!isset($options['path']) or $options['path'] === 'AUTO') { |
|
| 85 | - if (defined('_COOKIE_PATH')) { |
|
| 86 | - $options['path'] = _COOKIE_PATH; |
|
| 87 | - } else { |
|
| 88 | - $options['path'] = preg_replace(',^\w+://[^/]*,', '', url_de_base()); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - if (empty($options['domain']) and defined('_COOKIE_DOMAIN') and _COOKIE_DOMAIN) { |
|
| 92 | - $options['domain'] = _COOKIE_DOMAIN; |
|
| 93 | - } |
|
| 94 | - if (in_array($name, $to_secure_list)) { |
|
| 95 | - if (empty($options['secure']) and defined('_COOKIE_SECURE') and _COOKIE_SECURE) { |
|
| 96 | - $options['secure'] = true; |
|
| 97 | - } |
|
| 98 | - if (empty($options['httponly'])) { |
|
| 99 | - $options['httponly'] = true; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - if (empty($options['samesite'])) { |
|
| 103 | - $options['samesite'] = 'Lax'; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // in fine renommer le prefixe si besoin |
|
| 107 | - if (strpos($name, 'spip_') === 0) { |
|
| 108 | - $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies"); |
|
| 112 | - $a = @setcookie($name, $value, $options); |
|
| 113 | - |
|
| 114 | - spip_cookie_envoye(true); |
|
| 115 | - |
|
| 116 | - return $a; |
|
| 55 | + static $to_secure_list = ['spip_session']; |
|
| 56 | + if (defined('_COOKIE_SECURE_LIST') and is_array(_COOKIE_SECURE_LIST)) { |
|
| 57 | + $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + if (!is_array($options)) { |
|
| 61 | + // anciens paramètres : |
|
| 62 | + # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '') |
|
| 63 | + $opt = func_get_args(); |
|
| 64 | + $opt = array_slice($opt, 2); |
|
| 65 | + $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !); |
|
| 66 | + if (isset($opt[0])) { |
|
| 67 | + $options['expires'] = $opt[0]; |
|
| 68 | + } |
|
| 69 | + if (isset($opt[1])) { |
|
| 70 | + $options['path'] = $opt[1]; |
|
| 71 | + } |
|
| 72 | + if (isset($opt[2])) { |
|
| 73 | + $options['domain'] = $opt[2]; |
|
| 74 | + } |
|
| 75 | + if (isset($opt[3])) { |
|
| 76 | + $options['secure'] = $opt[3]; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // expires |
|
| 81 | + if (!isset($options['expires'])) { |
|
| 82 | + $options['expires'] = 0; |
|
| 83 | + } |
|
| 84 | + if (!isset($options['path']) or $options['path'] === 'AUTO') { |
|
| 85 | + if (defined('_COOKIE_PATH')) { |
|
| 86 | + $options['path'] = _COOKIE_PATH; |
|
| 87 | + } else { |
|
| 88 | + $options['path'] = preg_replace(',^\w+://[^/]*,', '', url_de_base()); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + if (empty($options['domain']) and defined('_COOKIE_DOMAIN') and _COOKIE_DOMAIN) { |
|
| 92 | + $options['domain'] = _COOKIE_DOMAIN; |
|
| 93 | + } |
|
| 94 | + if (in_array($name, $to_secure_list)) { |
|
| 95 | + if (empty($options['secure']) and defined('_COOKIE_SECURE') and _COOKIE_SECURE) { |
|
| 96 | + $options['secure'] = true; |
|
| 97 | + } |
|
| 98 | + if (empty($options['httponly'])) { |
|
| 99 | + $options['httponly'] = true; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + if (empty($options['samesite'])) { |
|
| 103 | + $options['samesite'] = 'Lax'; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // in fine renommer le prefixe si besoin |
|
| 107 | + if (strpos($name, 'spip_') === 0) { |
|
| 108 | + $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies"); |
|
| 112 | + $a = @setcookie($name, $value, $options); |
|
| 113 | + |
|
| 114 | + spip_cookie_envoye(true); |
|
| 115 | + |
|
| 116 | + return $a; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * @return bool |
| 130 | 130 | **/ |
| 131 | 131 | function spip_cookie_envoye($set = '') { |
| 132 | - static $envoye = false; |
|
| 133 | - if ($set) { |
|
| 134 | - $envoye = true; |
|
| 135 | - } |
|
| 132 | + static $envoye = false; |
|
| 133 | + if ($set) { |
|
| 134 | + $envoye = true; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - return $envoye; |
|
| 137 | + return $envoye; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -153,21 +153,21 @@ discard block |
||
| 153 | 153 | * Préfixe des cookies de SPIP |
| 154 | 154 | **/ |
| 155 | 155 | function recuperer_cookies_spip($cookie_prefix) { |
| 156 | - $prefix_long = strlen($cookie_prefix); |
|
| 157 | - |
|
| 158 | - foreach ($_COOKIE as $name => $value) { |
|
| 159 | - if (substr($name, 0, 5) == 'spip_' && substr($name, 0, $prefix_long) != $cookie_prefix) { |
|
| 160 | - unset($_COOKIE[$name]); |
|
| 161 | - unset($GLOBALS[$name]); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - foreach ($_COOKIE as $name => $value) { |
|
| 165 | - if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
|
| 166 | - $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 167 | - $_COOKIE[$spipname] = $value; |
|
| 168 | - $GLOBALS[$spipname] = $value; |
|
| 169 | - } |
|
| 170 | - } |
|
| 156 | + $prefix_long = strlen($cookie_prefix); |
|
| 157 | + |
|
| 158 | + foreach ($_COOKIE as $name => $value) { |
|
| 159 | + if (substr($name, 0, 5) == 'spip_' && substr($name, 0, $prefix_long) != $cookie_prefix) { |
|
| 160 | + unset($_COOKIE[$name]); |
|
| 161 | + unset($GLOBALS[$name]); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + foreach ($_COOKIE as $name => $value) { |
|
| 165 | + if (substr($name, 0, $prefix_long) == $cookie_prefix) { |
|
| 166 | + $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name); |
|
| 167 | + $_COOKIE[$spipname] = $value; |
|
| 168 | + $GLOBALS[$spipname] = $value; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | |
@@ -186,18 +186,18 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | **/ |
| 188 | 188 | function exec_test_ajax_dist() { |
| 189 | - switch (_request('js')) { |
|
| 190 | - // on est appele par <noscript> |
|
| 191 | - case -1: |
|
| 192 | - spip_setcookie('spip_accepte_ajax', -1); |
|
| 193 | - include_spip('inc/headers'); |
|
| 194 | - redirige_par_entete(chemin_image('erreur-xx.svg')); |
|
| 195 | - break; |
|
| 196 | - |
|
| 197 | - // ou par ajax |
|
| 198 | - case 1: |
|
| 199 | - default: |
|
| 200 | - spip_setcookie('spip_accepte_ajax', 1); |
|
| 201 | - break; |
|
| 202 | - } |
|
| 189 | + switch (_request('js')) { |
|
| 190 | + // on est appele par <noscript> |
|
| 191 | + case -1: |
|
| 192 | + spip_setcookie('spip_accepte_ajax', -1); |
|
| 193 | + include_spip('inc/headers'); |
|
| 194 | + redirige_par_entete(chemin_image('erreur-xx.svg')); |
|
| 195 | + break; |
|
| 196 | + |
|
| 197 | + // ou par ajax |
|
| 198 | + case 1: |
|
| 199 | + default: |
|
| 200 | + spip_setcookie('spip_accepte_ajax', 1); |
|
| 201 | + break; |
|
| 202 | + } |
|
| 203 | 203 | } |
@@ -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 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,91 +82,91 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | - |
|
| 119 | - if ($contient_breves > 0) { |
|
| 120 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | - $scb = _T( |
|
| 122 | - 'avis_deplacement_rubrique', |
|
| 123 | - [ |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - ] |
|
| 127 | - ); |
|
| 128 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | - . $scb . |
|
| 131 | - "</label></div></div>\n"; |
|
| 132 | - } else { |
|
| 133 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $form .= $confirm; |
|
| 137 | - if ($actionable) { |
|
| 138 | - if (strpos($form, '<select') !== false) { |
|
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | - . '</div>'; |
|
| 142 | - } |
|
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | - $form = generer_action_auteur( |
|
| 146 | - "editer_$objet", |
|
| 147 | - $id_objet, |
|
| 148 | - self(), |
|
| 149 | - $form, |
|
| 150 | - " method='post' class='submit_plongeur'" |
|
| 151 | - ); |
|
| 152 | - } else { |
|
| 153 | - $form = generer_action_auteur( |
|
| 154 | - 'editer_objet', |
|
| 155 | - "$objet/$id_objet", |
|
| 156 | - self(), |
|
| 157 | - $form, |
|
| 158 | - " method='post' class='submit_plongeur'" |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ($retour_sans_cadre) { |
|
| 164 | - return $form; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - include_spip('inc/presentation'); |
|
| 168 | - |
|
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | + |
|
| 119 | + if ($contient_breves > 0) { |
|
| 120 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | + $scb = _T( |
|
| 122 | + 'avis_deplacement_rubrique', |
|
| 123 | + [ |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + ] |
|
| 127 | + ); |
|
| 128 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | + . $scb . |
|
| 131 | + "</label></div></div>\n"; |
|
| 132 | + } else { |
|
| 133 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $form .= $confirm; |
|
| 137 | + if ($actionable) { |
|
| 138 | + if (strpos($form, '<select') !== false) { |
|
| 139 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + . '</div>'; |
|
| 142 | + } |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | + $form = generer_action_auteur( |
|
| 146 | + "editer_$objet", |
|
| 147 | + $id_objet, |
|
| 148 | + self(), |
|
| 149 | + $form, |
|
| 150 | + " method='post' class='submit_plongeur'" |
|
| 151 | + ); |
|
| 152 | + } else { |
|
| 153 | + $form = generer_action_auteur( |
|
| 154 | + 'editer_objet', |
|
| 155 | + "$objet/$id_objet", |
|
| 156 | + self(), |
|
| 157 | + $form, |
|
| 158 | + " method='post' class='submit_plongeur'" |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ($retour_sans_cadre) { |
|
| 164 | + return $form; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + include_spip('inc/presentation'); |
|
| 168 | + |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | 182 | function avoir_visiteurs($past = false, $accepter = true) { |
| 183 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | - return true; |
|
| 185 | - } |
|
| 186 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (!$past) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return sql_countsel( |
|
| 197 | - 'spip_auteurs', |
|
| 198 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 183 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | + return true; |
|
| 185 | + } |
|
| 186 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (!$past) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return sql_countsel( |
|
| 197 | + 'spip_auteurs', |
|
| 198 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 199 | 199 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 200 | - ); |
|
| 200 | + ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function statuts_articles_visibles($statut_auteur) { |
| 216 | - static $auth = []; |
|
| 217 | - if (!isset($auth[$statut_auteur])) { |
|
| 218 | - $auth[$statut_auteur] = []; |
|
| 219 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | - foreach ($statuts as $s) { |
|
| 221 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | - $auth[$statut_auteur][] = $s; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $auth[$statut_auteur]; |
|
| 216 | + static $auth = []; |
|
| 217 | + if (!isset($auth[$statut_auteur])) { |
|
| 218 | + $auth[$statut_auteur] = []; |
|
| 219 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | + foreach ($statuts as $s) { |
|
| 221 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | + $auth[$statut_auteur][] = $s; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $auth[$statut_auteur]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -238,38 +238,38 @@ discard block |
||
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | 240 | function traduire_statut_auteur($statut, $attente = '') { |
| 241 | - $plus = ''; |
|
| 242 | - if ($statut == 'nouveau') { |
|
| 243 | - if ($attente) { |
|
| 244 | - $statut = $attente; |
|
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | - } else { |
|
| 247 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $recom = [ |
|
| 252 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | - ]; |
|
| 257 | - if (isset($recom[$statut])) { |
|
| 258 | - return $recom[$statut] . $plus; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // retrouver directement par le statut sinon |
|
| 262 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | - if (isset($recom[$t])) { |
|
| 264 | - return $recom[$t] . $plus; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return _T($t) . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | - // c'est toujours plus informatif que rien du tout |
|
| 272 | - return $statut; |
|
| 241 | + $plus = ''; |
|
| 242 | + if ($statut == 'nouveau') { |
|
| 243 | + if ($attente) { |
|
| 244 | + $statut = $attente; |
|
| 245 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | + } else { |
|
| 247 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $recom = [ |
|
| 252 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | + ]; |
|
| 257 | + if (isset($recom[$statut])) { |
|
| 258 | + return $recom[$statut] . $plus; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // retrouver directement par le statut sinon |
|
| 262 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | + if (isset($recom[$t])) { |
|
| 264 | + return $recom[$t] . $plus; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return _T($t) . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | + // c'est toujours plus informatif que rien du tout |
|
| 272 | + return $statut; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,29 +280,29 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet): string { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - include_spip('inc/config'); |
|
| 289 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | - return $qui[$objet][$id_objet] = ''; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - include_spip('inc/drapeau_edition'); |
|
| 294 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | - if (!$modif) { |
|
| 296 | - return $qui[$objet][$id_objet] = ''; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - include_spip('base/objets'); |
|
| 300 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | - if (isset($infos['texte_signale_edition'])) { |
|
| 302 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 283 | + static $qui = []; |
|
| 284 | + if (isset($qui[$objet][$id_objet])) { |
|
| 285 | + return $qui[$objet][$id_objet]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + include_spip('inc/config'); |
|
| 289 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | + return $qui[$objet][$id_objet] = ''; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + include_spip('inc/drapeau_edition'); |
|
| 294 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | + if (!$modif) { |
|
| 296 | + return $qui[$objet][$id_objet] = ''; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + include_spip('base/objets'); |
|
| 300 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | + if (isset($infos['texte_signale_edition'])) { |
|
| 302 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -320,53 +320,53 @@ discard block |
||
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | 322 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 323 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - switch ($quoi) { |
|
| 328 | - case 'redacteurs': |
|
| 329 | - $statut = AUTEURS_MIN_REDAC; |
|
| 330 | - $statut = explode(',', $statut); |
|
| 331 | - if ($en_base) { |
|
| 332 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | - $retire = array_diff($statut, $check); |
|
| 334 | - $statut = array_diff($statut, $retire); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return array_unique($statut); |
|
| 338 | - |
|
| 339 | - case 'visiteurs': |
|
| 340 | - $statut = []; |
|
| 341 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | - $exclus = explode(',', $exclus); |
|
| 343 | - if (!$en_base) { |
|
| 344 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | - } |
|
| 347 | - $s_complement = array_column( |
|
| 348 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | - 'statut' |
|
| 350 | - ); |
|
| 351 | - |
|
| 352 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | - |
|
| 354 | - default: |
|
| 355 | - case 'tous': |
|
| 356 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | - $s_complement = array_column( |
|
| 358 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | - 'statut' |
|
| 360 | - ); |
|
| 361 | - $statut = array_merge($statut, $s_complement); |
|
| 362 | - if ($en_base) { |
|
| 363 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | - $retire = array_diff($statut, $check); |
|
| 365 | - $statut = array_diff($statut, $retire); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - return array_unique($statut); |
|
| 369 | - } |
|
| 323 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + switch ($quoi) { |
|
| 328 | + case 'redacteurs': |
|
| 329 | + $statut = AUTEURS_MIN_REDAC; |
|
| 330 | + $statut = explode(',', $statut); |
|
| 331 | + if ($en_base) { |
|
| 332 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | + $retire = array_diff($statut, $check); |
|
| 334 | + $statut = array_diff($statut, $retire); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return array_unique($statut); |
|
| 338 | + |
|
| 339 | + case 'visiteurs': |
|
| 340 | + $statut = []; |
|
| 341 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | + $exclus = explode(',', $exclus); |
|
| 343 | + if (!$en_base) { |
|
| 344 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | + } |
|
| 347 | + $s_complement = array_column( |
|
| 348 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | + 'statut' |
|
| 350 | + ); |
|
| 351 | + |
|
| 352 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | + |
|
| 354 | + default: |
|
| 355 | + case 'tous': |
|
| 356 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | + $s_complement = array_column( |
|
| 358 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | + 'statut' |
|
| 360 | + ); |
|
| 361 | + $statut = array_merge($statut, $s_complement); |
|
| 362 | + if ($en_base) { |
|
| 363 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | + $retire = array_diff($statut, $check); |
|
| 365 | + $statut = array_diff($statut, $retire); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + return array_unique($statut); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,28 +382,28 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 384 | 384 | |
| 385 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | - ? '' |
|
| 388 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | - |
|
| 390 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | - if ($objet == 'rubrique') { |
|
| 392 | - $id_rubrique = 0; |
|
| 393 | - } else { |
|
| 394 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $id_rubrique; |
|
| 385 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | + ? '' |
|
| 388 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | + |
|
| 390 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | + if ($objet == 'rubrique') { |
|
| 392 | + $id_rubrique = 0; |
|
| 393 | + } else { |
|
| 394 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $id_rubrique; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | 416 | function lien_article_virtuel($virtuel) { |
| 417 | - include_spip('inc/lien'); |
|
| 418 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | - return ''; |
|
| 420 | - } |
|
| 417 | + include_spip('inc/lien'); |
|
| 418 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | + return ''; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - return propre('[->' . $virtuel . ']'); |
|
| 422 | + return propre('[->' . $virtuel . ']'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -442,11 +442,11 @@ discard block |
||
| 442 | 442 | * @filtre |
| 443 | 443 | */ |
| 444 | 444 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 445 | - include_spip('inc/acces'); |
|
| 446 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 445 | + include_spip('inc/acces'); |
|
| 446 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 447 | 447 | |
| 448 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 448 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | |
@@ -458,76 +458,76 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function alertes_auteur($id_auteur): string { |
| 460 | 460 | |
| 461 | - $alertes = []; |
|
| 462 | - |
|
| 463 | - if ( |
|
| 464 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | - ) { |
|
| 467 | - include_spip('genie/maintenance'); |
|
| 468 | - if ($msg = message_crash_tables()) { |
|
| 469 | - $alertes[] = $msg; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - if ( |
|
| 474 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | - ) { |
|
| 479 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | - if ( |
|
| 485 | - $a |
|
| 486 | - and is_array($a = unserialize($a)) |
|
| 487 | - and count($a) |
|
| 488 | - ) { |
|
| 489 | - $update = false; |
|
| 490 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | - $update = true; |
|
| 494 | - } |
|
| 495 | - if (isset($a[''])) { |
|
| 496 | - $alertes = array_merge($alertes, $a['']); |
|
| 497 | - unset($a['']); |
|
| 498 | - $update = true; |
|
| 499 | - } |
|
| 500 | - if ($update) { |
|
| 501 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - if ( |
|
| 506 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | - ) { |
|
| 509 | - include_spip('inc/plugin'); |
|
| 510 | - $alertes[] = plugin_donne_erreurs(); |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - $alertes = pipeline( |
|
| 514 | - 'alertes_auteur', |
|
| 515 | - [ |
|
| 516 | - 'args' => [ |
|
| 517 | - 'id_auteur' => $id_auteur, |
|
| 518 | - 'exec' => _request('exec'), |
|
| 519 | - ], |
|
| 520 | - 'data' => $alertes |
|
| 521 | - ] |
|
| 522 | - ); |
|
| 523 | - |
|
| 524 | - if ($alertes = array_filter($alertes)) { |
|
| 525 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | - join(' | ', $alertes) |
|
| 527 | - . '</div></div>'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return ''; |
|
| 461 | + $alertes = []; |
|
| 462 | + |
|
| 463 | + if ( |
|
| 464 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | + ) { |
|
| 467 | + include_spip('genie/maintenance'); |
|
| 468 | + if ($msg = message_crash_tables()) { |
|
| 469 | + $alertes[] = $msg; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + if ( |
|
| 474 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | + ) { |
|
| 479 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | + if ( |
|
| 485 | + $a |
|
| 486 | + and is_array($a = unserialize($a)) |
|
| 487 | + and count($a) |
|
| 488 | + ) { |
|
| 489 | + $update = false; |
|
| 490 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | + $update = true; |
|
| 494 | + } |
|
| 495 | + if (isset($a[''])) { |
|
| 496 | + $alertes = array_merge($alertes, $a['']); |
|
| 497 | + unset($a['']); |
|
| 498 | + $update = true; |
|
| 499 | + } |
|
| 500 | + if ($update) { |
|
| 501 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + if ( |
|
| 506 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | + ) { |
|
| 509 | + include_spip('inc/plugin'); |
|
| 510 | + $alertes[] = plugin_donne_erreurs(); |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + $alertes = pipeline( |
|
| 514 | + 'alertes_auteur', |
|
| 515 | + [ |
|
| 516 | + 'args' => [ |
|
| 517 | + 'id_auteur' => $id_auteur, |
|
| 518 | + 'exec' => _request('exec'), |
|
| 519 | + ], |
|
| 520 | + 'data' => $alertes |
|
| 521 | + ] |
|
| 522 | + ); |
|
| 523 | + |
|
| 524 | + if ($alertes = array_filter($alertes)) { |
|
| 525 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | + join(' | ', $alertes) |
|
| 527 | + . '</div></div>'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return ''; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | 539 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 540 | - include_spip('inc/presenter_enfants'); |
|
| 540 | + include_spip('inc/presenter_enfants'); |
|
| 541 | 541 | |
| 542 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -557,15 +557,15 @@ discard block |
||
| 557 | 557 | * @return string |
| 558 | 558 | */ |
| 559 | 559 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 560 | - $titre = attribut_html($titre); |
|
| 561 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | - |
|
| 564 | - if (!$titre_lien) { |
|
| 565 | - return $icone; |
|
| 566 | - } else { |
|
| 567 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | - } |
|
| 560 | + $titre = attribut_html($titre); |
|
| 561 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | + |
|
| 564 | + if (!$titre_lien) { |
|
| 565 | + return $icone; |
|
| 566 | + } else { |
|
| 567 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + } |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -584,22 +584,22 @@ discard block |
||
| 584 | 584 | * @return array |
| 585 | 585 | */ |
| 586 | 586 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 587 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | - return []; |
|
| 590 | - } |
|
| 591 | - $r = reset($res); |
|
| 592 | - if (isset($r['rang_lien'])) { |
|
| 593 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | - asort($l); |
|
| 595 | - $l = array_keys($l); |
|
| 596 | - } else { |
|
| 597 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | - // Sinon c'est dans "id_objet" |
|
| 599 | - $l = array_column( |
|
| 600 | - $res, |
|
| 601 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | - ); |
|
| 603 | - } |
|
| 604 | - return $l; |
|
| 587 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | + return []; |
|
| 590 | + } |
|
| 591 | + $r = reset($res); |
|
| 592 | + if (isset($r['rang_lien'])) { |
|
| 593 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | + asort($l); |
|
| 595 | + $l = array_keys($l); |
|
| 596 | + } else { |
|
| 597 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | + // Sinon c'est dans "id_objet" |
|
| 599 | + $l = array_column( |
|
| 600 | + $res, |
|
| 601 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | + ); |
|
| 603 | + } |
|
| 604 | + return $l; |
|
| 605 | 605 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Affichage |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @return string Code HTML |
| 26 | 26 | */ |
| 27 | 27 | function debut_grand_cadre() { |
| 28 | - return "\n<div class = 'table_page'>\n"; |
|
| 28 | + return "\n<div class = 'table_page'>\n"; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return string Code HTML |
| 35 | 35 | */ |
| 36 | 36 | function fin_grand_cadre() { |
| 37 | - return "\n</div>"; |
|
| 37 | + return "\n</div>"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Debut de la colonne de gauche |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @return string Code HTML |
| 50 | 50 | */ |
| 51 | 51 | function debut_gauche() { |
| 52 | - return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 52 | + return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return string Code HTML |
| 59 | 59 | */ |
| 60 | 60 | function fin_gauche() { |
| 61 | - return "</div></div><br class = 'nettoyeur' />"; |
|
| 61 | + return "</div></div><br class = 'nettoyeur' />"; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @return string Code HTML |
| 68 | 68 | */ |
| 69 | 69 | function creer_colonne_droite() { |
| 70 | - static $deja_colonne_droite; |
|
| 71 | - if ($deja_colonne_droite) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 74 | - $deja_colonne_droite = true; |
|
| 70 | + static $deja_colonne_droite; |
|
| 71 | + if ($deja_colonne_droite) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | + $deja_colonne_droite = true; |
|
| 75 | 75 | |
| 76 | - return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 76 | + return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | * @return string Code HTML |
| 83 | 83 | */ |
| 84 | 84 | function debut_droite() { |
| 85 | - return liste_objets_bloques(_request('exec')) |
|
| 86 | - . creer_colonne_droite() |
|
| 87 | - . '</div>' |
|
| 88 | - . "\n<div id='contenu'>"; |
|
| 85 | + return liste_objets_bloques(_request('exec')) |
|
| 86 | + . creer_colonne_droite() |
|
| 87 | + . '</div>' |
|
| 88 | + . "\n<div id='contenu'>"; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -107,32 +107,32 @@ discard block |
||
| 107 | 107 | * Code HTML |
| 108 | 108 | **/ |
| 109 | 109 | function liste_objets_bloques($exec, $contexte = [], $auteur = null): string { |
| 110 | - $res = ''; |
|
| 111 | - include_spip('inc/config'); |
|
| 112 | - if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 113 | - include_spip('inc/drapeau_edition'); |
|
| 114 | - if (is_null($auteur)) { |
|
| 115 | - $auteur = $GLOBALS['visiteur_session']; |
|
| 116 | - } |
|
| 117 | - if ( |
|
| 118 | - $en_cours = trouver_objet_exec($exec) |
|
| 119 | - and $en_cours['edition'] |
|
| 120 | - and $type = $en_cours['type'] |
|
| 121 | - and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']]) |
|
| 122 | - or $id = _request($en_cours['id_table_objet'])) |
|
| 123 | - ) { |
|
| 124 | - // marquer le fait que l'objet est ouvert en edition par toto |
|
| 125 | - // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 126 | - signale_edition($id, $auteur, $type); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 130 | - if (count($objets_ouverts)) { |
|
| 131 | - $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - return $res; |
|
| 110 | + $res = ''; |
|
| 111 | + include_spip('inc/config'); |
|
| 112 | + if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 113 | + include_spip('inc/drapeau_edition'); |
|
| 114 | + if (is_null($auteur)) { |
|
| 115 | + $auteur = $GLOBALS['visiteur_session']; |
|
| 116 | + } |
|
| 117 | + if ( |
|
| 118 | + $en_cours = trouver_objet_exec($exec) |
|
| 119 | + and $en_cours['edition'] |
|
| 120 | + and $type = $en_cours['type'] |
|
| 121 | + and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']]) |
|
| 122 | + or $id = _request($en_cours['id_table_objet'])) |
|
| 123 | + ) { |
|
| 124 | + // marquer le fait que l'objet est ouvert en edition par toto |
|
| 125 | + // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 126 | + signale_edition($id, $auteur, $type); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 130 | + if (count($objets_ouverts)) { |
|
| 131 | + $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + return $res; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -146,20 +146,20 @@ discard block |
||
| 146 | 146 | * @return string Code HTML |
| 147 | 147 | **/ |
| 148 | 148 | function fin_page() { |
| 149 | - include_spip('inc/pipelines'); |
|
| 150 | - // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 151 | - $debug = ((_request('exec') !== 'valider_xml') |
|
| 152 | - and ((_request('var_mode') == 'debug') |
|
| 153 | - or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps']) |
|
| 154 | - and isset($_COOKIE['spip_admin']))); |
|
| 155 | - $t = '</div><div id="pied"><div class="largeur">' |
|
| 156 | - . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 157 | - . '</div>' |
|
| 158 | - . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 159 | - . ($debug ? erreur_squelette() : '') |
|
| 160 | - . "</body></html>\n"; |
|
| 161 | - |
|
| 162 | - return f_queue($t); |
|
| 149 | + include_spip('inc/pipelines'); |
|
| 150 | + // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 151 | + $debug = ((_request('exec') !== 'valider_xml') |
|
| 152 | + and ((_request('var_mode') == 'debug') |
|
| 153 | + or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps']) |
|
| 154 | + and isset($_COOKIE['spip_admin']))); |
|
| 155 | + $t = '</div><div id="pied"><div class="largeur">' |
|
| 156 | + . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 157 | + . '</div>' |
|
| 158 | + . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 159 | + . ($debug ? erreur_squelette() : '') |
|
| 160 | + . "</body></html>\n"; |
|
| 161 | + |
|
| 162 | + return f_queue($t); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -174,22 +174,22 @@ discard block |
||
| 174 | 174 | * @return string Code HTML |
| 175 | 175 | **/ |
| 176 | 176 | function html_tests_js() { |
| 177 | - if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) { |
|
| 178 | - // pour le pied de page (deja defini si on est validation XML) |
|
| 179 | - define( |
|
| 180 | - '_TESTER_NOSCRIPT', |
|
| 181 | - "<noscript>\n<div style='display:none;'><img src='" |
|
| 182 | - . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 183 | - . "' width='1' height='1' alt='' /></div></noscript>\n" |
|
| 184 | - ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $rejouer = ''; |
|
| 188 | - if (defined('_SESSION_REJOUER')) { |
|
| 189 | - $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 177 | + if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) { |
|
| 178 | + // pour le pied de page (deja defini si on est validation XML) |
|
| 179 | + define( |
|
| 180 | + '_TESTER_NOSCRIPT', |
|
| 181 | + "<noscript>\n<div style='display:none;'><img src='" |
|
| 182 | + . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 183 | + . "' width='1' height='1' alt='' /></div></noscript>\n" |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $rejouer = ''; |
|
| 188 | + if (defined('_SESSION_REJOUER')) { |
|
| 189 | + $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -199,25 +199,25 @@ discard block |
||
| 199 | 199 | **/ |
| 200 | 200 | function info_maj_spip() { |
| 201 | 201 | |
| 202 | - $maj = $GLOBALS['meta']['info_maj_spip'] ?? null; |
|
| 203 | - if (!$maj) { |
|
| 204 | - return ''; |
|
| 205 | - } |
|
| 202 | + $maj = $GLOBALS['meta']['info_maj_spip'] ?? null; |
|
| 203 | + if (!$maj) { |
|
| 204 | + return ''; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $maj = explode('|', $maj); |
|
| 208 | - // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 209 | - if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 210 | - return ''; |
|
| 211 | - } |
|
| 207 | + $maj = explode('|', $maj); |
|
| 208 | + // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 209 | + if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 210 | + return ''; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - if (!autoriser('webmestre')) { |
|
| 214 | - return ''; |
|
| 215 | - } |
|
| 213 | + if (!autoriser('webmestre')) { |
|
| 214 | + return ''; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - array_shift($maj); |
|
| 218 | - $maj = implode('|', $maj); |
|
| 217 | + array_shift($maj); |
|
| 218 | + $maj = implode('|', $maj); |
|
| 219 | 219 | |
| 220 | - return "$maj<br />"; |
|
| 220 | + return "$maj<br />"; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -228,47 +228,47 @@ discard block |
||
| 228 | 228 | **/ |
| 229 | 229 | function info_copyright() { |
| 230 | 230 | |
| 231 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 232 | - |
|
| 233 | - // |
|
| 234 | - // Mention, le cas echeant, de la revision SVN courante |
|
| 235 | - // |
|
| 236 | - if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 237 | - if ($vcs['vcs'] === 'GIT') { |
|
| 238 | - $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 239 | - } elseif ($vcs['vcs'] === 'SVN') { |
|
| 240 | - $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 241 | - } else { |
|
| 242 | - $url = ''; |
|
| 243 | - } |
|
| 244 | - // affichage "GIT [master: abcdef]" |
|
| 245 | - $commit = $vcs['commit_short'] ?? $vcs['commit']; |
|
| 246 | - if ($url) { |
|
| 247 | - $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 248 | - } |
|
| 249 | - if ($vcs['branch']) { |
|
| 250 | - $commit = $vcs['branch'] . ': ' . $commit; |
|
| 251 | - } |
|
| 252 | - $version .= " {$vcs['vcs']} [$commit]"; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // et la version de l'ecran de securite |
|
| 256 | - $secu = defined('_ECRAN_SECURITE') |
|
| 257 | - ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 258 | - : ''; |
|
| 259 | - |
|
| 260 | - return _T( |
|
| 261 | - 'info_copyright', |
|
| 262 | - [ |
|
| 263 | - 'spip' => "<b>SPIP $version</b> ", |
|
| 264 | - 'lien_gpl' => |
|
| 265 | - "<a href='" . generer_url_ecrire( |
|
| 266 | - 'aide', |
|
| 267 | - 'aide=licence&var_lang=' . $GLOBALS['spip_lang'] |
|
| 268 | - ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>' |
|
| 269 | - ] |
|
| 270 | - ) |
|
| 271 | - . $secu; |
|
| 231 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 232 | + |
|
| 233 | + // |
|
| 234 | + // Mention, le cas echeant, de la revision SVN courante |
|
| 235 | + // |
|
| 236 | + if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 237 | + if ($vcs['vcs'] === 'GIT') { |
|
| 238 | + $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 239 | + } elseif ($vcs['vcs'] === 'SVN') { |
|
| 240 | + $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 241 | + } else { |
|
| 242 | + $url = ''; |
|
| 243 | + } |
|
| 244 | + // affichage "GIT [master: abcdef]" |
|
| 245 | + $commit = $vcs['commit_short'] ?? $vcs['commit']; |
|
| 246 | + if ($url) { |
|
| 247 | + $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 248 | + } |
|
| 249 | + if ($vcs['branch']) { |
|
| 250 | + $commit = $vcs['branch'] . ': ' . $commit; |
|
| 251 | + } |
|
| 252 | + $version .= " {$vcs['vcs']} [$commit]"; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // et la version de l'ecran de securite |
|
| 256 | + $secu = defined('_ECRAN_SECURITE') |
|
| 257 | + ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 258 | + : ''; |
|
| 259 | + |
|
| 260 | + return _T( |
|
| 261 | + 'info_copyright', |
|
| 262 | + [ |
|
| 263 | + 'spip' => "<b>SPIP $version</b> ", |
|
| 264 | + 'lien_gpl' => |
|
| 265 | + "<a href='" . generer_url_ecrire( |
|
| 266 | + 'aide', |
|
| 267 | + 'aide=licence&var_lang=' . $GLOBALS['spip_lang'] |
|
| 268 | + ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>' |
|
| 269 | + ] |
|
| 270 | + ) |
|
| 271 | + . $secu; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | * @return string Code HTML |
| 284 | 284 | **/ |
| 285 | 285 | function formulaire_recherche($page, $complement = '') { |
| 286 | - $recherche = _request('recherche'); |
|
| 287 | - $recherche_aff = entites_html($recherche); |
|
| 288 | - if (!strlen($recherche)) { |
|
| 289 | - $recherche_aff = _T('info_rechercher'); |
|
| 290 | - $onfocus = " onfocus=\"this.value='';\""; |
|
| 291 | - } else { |
|
| 292 | - $onfocus = ''; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 296 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 297 | - |
|
| 298 | - return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 286 | + $recherche = _request('recherche'); |
|
| 287 | + $recherche_aff = entites_html($recherche); |
|
| 288 | + if (!strlen($recherche)) { |
|
| 289 | + $recherche_aff = _T('info_rechercher'); |
|
| 290 | + $onfocus = " onfocus=\"this.value='';\""; |
|
| 291 | + } else { |
|
| 292 | + $onfocus = ''; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 296 | + $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 297 | + |
|
| 298 | + return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 299 | 299 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Fichier |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,28 +36,28 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function spip_livrer_fichier($fichier, $content_type = 'application/octet-stream', $options = []) { |
| 38 | 38 | |
| 39 | - $defaut = [ |
|
| 40 | - 'attachment' => false, |
|
| 41 | - 'expires' => 3600, |
|
| 42 | - 'range' => null |
|
| 43 | - ]; |
|
| 44 | - $options = array_merge($defaut, $options); |
|
| 45 | - if (is_numeric($options['expires']) and $options['expires'] > 0) { |
|
| 46 | - $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - if (is_null($options) and isset($_SERVER['HTTP_RANGE'])) { |
|
| 50 | - $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - spip_livrer_fichier_entetes($fichier, $content_type, $options['attachment'] && !$options['range'], $options['expires']); |
|
| 54 | - |
|
| 55 | - if (!is_null($options['range'])) { |
|
| 56 | - spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 57 | - } |
|
| 58 | - else { |
|
| 59 | - spip_livrer_fichier_entier($fichier); |
|
| 60 | - } |
|
| 39 | + $defaut = [ |
|
| 40 | + 'attachment' => false, |
|
| 41 | + 'expires' => 3600, |
|
| 42 | + 'range' => null |
|
| 43 | + ]; |
|
| 44 | + $options = array_merge($defaut, $options); |
|
| 45 | + if (is_numeric($options['expires']) and $options['expires'] > 0) { |
|
| 46 | + $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + if (is_null($options) and isset($_SERVER['HTTP_RANGE'])) { |
|
| 50 | + $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + spip_livrer_fichier_entetes($fichier, $content_type, $options['attachment'] && !$options['range'], $options['expires']); |
|
| 54 | + |
|
| 55 | + if (!is_null($options['range'])) { |
|
| 56 | + spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 57 | + } |
|
| 58 | + else { |
|
| 59 | + spip_livrer_fichier_entier($fichier); |
|
| 60 | + } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -70,28 +70,28 @@ discard block |
||
| 70 | 70 | * @param int|string $expires |
| 71 | 71 | */ |
| 72 | 72 | function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) { |
| 73 | - // toujours envoyer un content type, meme vide ! |
|
| 74 | - header('Accept-Ranges: bytes'); |
|
| 75 | - header('Content-Type: ' . $content_type); |
|
| 76 | - |
|
| 77 | - if ($attachment) { |
|
| 78 | - $f = basename($fichier); |
|
| 79 | - // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 80 | - header('Content-Type: application/octet-stream'); |
|
| 81 | - |
|
| 82 | - header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 83 | - header('Content-Transfer-Encoding: binary'); |
|
| 84 | - |
|
| 85 | - // fix for IE caching or PHP bug issue |
|
| 86 | - header('Expires: 0'); // set expiration time |
|
| 87 | - header('Pragma: public'); |
|
| 88 | - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 89 | - } |
|
| 90 | - else { |
|
| 91 | - $f = basename($fichier); |
|
| 92 | - header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 93 | - header('Expires: ' . $expires); // set expiration time |
|
| 94 | - } |
|
| 73 | + // toujours envoyer un content type, meme vide ! |
|
| 74 | + header('Accept-Ranges: bytes'); |
|
| 75 | + header('Content-Type: ' . $content_type); |
|
| 76 | + |
|
| 77 | + if ($attachment) { |
|
| 78 | + $f = basename($fichier); |
|
| 79 | + // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 80 | + header('Content-Type: application/octet-stream'); |
|
| 81 | + |
|
| 82 | + header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 83 | + header('Content-Transfer-Encoding: binary'); |
|
| 84 | + |
|
| 85 | + // fix for IE caching or PHP bug issue |
|
| 86 | + header('Expires: 0'); // set expiration time |
|
| 87 | + header('Pragma: public'); |
|
| 88 | + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 89 | + } |
|
| 90 | + else { |
|
| 91 | + $f = basename($fichier); |
|
| 92 | + header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 93 | + header('Expires: ' . $expires); // set expiration time |
|
| 94 | + } |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | * @param string $fichier |
| 100 | 100 | */ |
| 101 | 101 | function spip_livrer_fichier_entier($fichier) { |
| 102 | - if (!file_exists($fichier)) { |
|
| 103 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 104 | - } |
|
| 102 | + if (!file_exists($fichier)) { |
|
| 103 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - if (!is_readable($fichier)) { |
|
| 107 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 108 | - } |
|
| 106 | + if (!is_readable($fichier)) { |
|
| 107 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - if ($size = filesize($fichier)) { |
|
| 111 | - header(sprintf('Content-Length: %d', $size)); |
|
| 112 | - } |
|
| 110 | + if ($size = filesize($fichier)) { |
|
| 111 | + header(sprintf('Content-Length: %d', $size)); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - readfile($fichier); |
|
| 115 | - exit(); |
|
| 114 | + readfile($fichier); |
|
| 115 | + exit(); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -125,98 +125,98 @@ discard block |
||
| 125 | 125 | * @throws Exception |
| 126 | 126 | */ |
| 127 | 127 | function spip_livrer_fichier_partie($fichier, $range = null) { |
| 128 | - if (!file_exists($fichier)) { |
|
| 129 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 130 | - } |
|
| 128 | + if (!file_exists($fichier)) { |
|
| 129 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - if (!is_readable($fichier)) { |
|
| 133 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 134 | - } |
|
| 132 | + if (!is_readable($fichier)) { |
|
| 133 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | |
| 137 | - // Par defaut on envoie tout |
|
| 138 | - $byteOffset = 0; |
|
| 139 | - $byteLength = $fileSize = filesize($fichier); |
|
| 137 | + // Par defaut on envoie tout |
|
| 138 | + $byteOffset = 0; |
|
| 139 | + $byteLength = $fileSize = filesize($fichier); |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | - // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 143 | - if ($range and preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 144 | - ### Offset signifies where we should begin to read the file |
|
| 145 | - $byteOffset = (int)$match[1]; |
|
| 142 | + // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 143 | + if ($range and preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 144 | + ### Offset signifies where we should begin to read the file |
|
| 145 | + $byteOffset = (int)$match[1]; |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | - ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 149 | - if (isset($match[2])) { |
|
| 150 | - $finishBytes = (int)$match[2]; |
|
| 151 | - $byteLength = $finishBytes + 1; |
|
| 152 | - } else { |
|
| 153 | - $finishBytes = $fileSize - 1; |
|
| 154 | - } |
|
| 148 | + ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 149 | + if (isset($match[2])) { |
|
| 150 | + $finishBytes = (int)$match[2]; |
|
| 151 | + $byteLength = $finishBytes + 1; |
|
| 152 | + } else { |
|
| 153 | + $finishBytes = $fileSize - 1; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 157 | - } |
|
| 158 | - else { |
|
| 159 | - // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 160 | - spip_livrer_fichier_entier($fichier); |
|
| 161 | - // redondant, mais facilite la comprehension du code |
|
| 162 | - exit(); |
|
| 163 | - } |
|
| 156 | + $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 157 | + } |
|
| 158 | + else { |
|
| 159 | + // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 160 | + spip_livrer_fichier_entier($fichier); |
|
| 161 | + // redondant, mais facilite la comprehension du code |
|
| 162 | + exit(); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - // Remove headers that might unnecessarily clutter up the output |
|
| 166 | - header_remove('Cache-Control'); |
|
| 167 | - header_remove('Pragma'); |
|
| 165 | + // Remove headers that might unnecessarily clutter up the output |
|
| 166 | + header_remove('Cache-Control'); |
|
| 167 | + header_remove('Pragma'); |
|
| 168 | 168 | |
| 169 | - // partial content |
|
| 170 | - header('HTTP/1.1 206 Partial content'); |
|
| 171 | - header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 169 | + // partial content |
|
| 170 | + header('HTTP/1.1 206 Partial content'); |
|
| 171 | + header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | - $byteRange = $byteLength - $byteOffset; |
|
| 174 | + $byteRange = $byteLength - $byteOffset; |
|
| 175 | 175 | |
| 176 | - header(sprintf('Content-Length: %d', $byteRange)); |
|
| 176 | + header(sprintf('Content-Length: %d', $byteRange)); |
|
| 177 | 177 | |
| 178 | - // Variable containing the buffer |
|
| 179 | - $buffer = ''; |
|
| 180 | - // Just a reasonable buffer size |
|
| 181 | - $bufferSize = 512 * 16; |
|
| 182 | - // Contains how much is left to read of the byteRange |
|
| 183 | - $bytePool = $byteRange; |
|
| 178 | + // Variable containing the buffer |
|
| 179 | + $buffer = ''; |
|
| 180 | + // Just a reasonable buffer size |
|
| 181 | + $bufferSize = 512 * 16; |
|
| 182 | + // Contains how much is left to read of the byteRange |
|
| 183 | + $bytePool = $byteRange; |
|
| 184 | 184 | |
| 185 | - if (!$handle = fopen($fichier, 'r')) { |
|
| 186 | - throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 187 | - } |
|
| 185 | + if (!$handle = fopen($fichier, 'r')) { |
|
| 186 | + throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 190 | - throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 191 | - } |
|
| 189 | + if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 190 | + throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | |
| 194 | - while ($bytePool > 0) { |
|
| 195 | - // How many bytes we request on this iteration |
|
| 196 | - $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 194 | + while ($bytePool > 0) { |
|
| 195 | + // How many bytes we request on this iteration |
|
| 196 | + $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 197 | 197 | |
| 198 | - // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 199 | - $buffer = fread($handle, $chunkSizeRequested); |
|
| 198 | + // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 199 | + $buffer = fread($handle, $chunkSizeRequested); |
|
| 200 | 200 | |
| 201 | - // Store how many bytes were actually read |
|
| 202 | - $chunkSizeActual = strlen($buffer); |
|
| 201 | + // Store how many bytes were actually read |
|
| 202 | + $chunkSizeActual = strlen($buffer); |
|
| 203 | 203 | |
| 204 | - // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 205 | - if ($chunkSizeActual == 0) { |
|
| 206 | - // For production servers this should go in your php error log, since it will break the output |
|
| 207 | - trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 208 | - break; |
|
| 209 | - } |
|
| 204 | + // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 205 | + if ($chunkSizeActual == 0) { |
|
| 206 | + // For production servers this should go in your php error log, since it will break the output |
|
| 207 | + trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 208 | + break; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 212 | - $bytePool -= $chunkSizeActual; |
|
| 211 | + // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 212 | + $bytePool -= $chunkSizeActual; |
|
| 213 | 213 | |
| 214 | - // Write the buffer to output |
|
| 215 | - print $buffer; |
|
| 214 | + // Write the buffer to output |
|
| 215 | + print $buffer; |
|
| 216 | 216 | |
| 217 | - // Try to output the data to the client immediately |
|
| 218 | - flush(); |
|
| 219 | - } |
|
| 217 | + // Try to output the data to the client immediately |
|
| 218 | + flush(); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - exit(); |
|
| 221 | + exit(); |
|
| 222 | 222 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Rubriques\Edition |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/rubriques'); |
@@ -38,34 +38,34 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function action_editer_rubrique_dist($arg = null) { |
| 40 | 40 | |
| 41 | - if (is_null($arg)) { |
|
| 42 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 43 | - $arg = $securiser_action(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (!$id_rubrique = intval($arg)) { |
|
| 47 | - if ($arg != 'oui') { |
|
| 48 | - include_spip('inc/headers'); |
|
| 49 | - redirige_url_ecrire(); |
|
| 50 | - } |
|
| 51 | - $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - $err = rubrique_modifier($id_rubrique); |
|
| 55 | - |
|
| 56 | - if (_request('redirect')) { |
|
| 57 | - $redirect = parametre_url( |
|
| 58 | - urldecode(_request('redirect')), |
|
| 59 | - 'id_rubrique', |
|
| 60 | - $id_rubrique, |
|
| 61 | - '&' |
|
| 62 | - ); |
|
| 63 | - |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - redirige_par_entete($redirect); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - return [$id_rubrique, $err]; |
|
| 41 | + if (is_null($arg)) { |
|
| 42 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 43 | + $arg = $securiser_action(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (!$id_rubrique = intval($arg)) { |
|
| 47 | + if ($arg != 'oui') { |
|
| 48 | + include_spip('inc/headers'); |
|
| 49 | + redirige_url_ecrire(); |
|
| 50 | + } |
|
| 51 | + $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + $err = rubrique_modifier($id_rubrique); |
|
| 55 | + |
|
| 56 | + if (_request('redirect')) { |
|
| 57 | + $redirect = parametre_url( |
|
| 58 | + urldecode(_request('redirect')), |
|
| 59 | + 'id_rubrique', |
|
| 60 | + $id_rubrique, |
|
| 61 | + '&' |
|
| 62 | + ); |
|
| 63 | + |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + redirige_par_entete($redirect); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + return [$id_rubrique, $err]; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
@@ -80,42 +80,42 @@ discard block |
||
| 80 | 80 | * Identifiant de la rubrique crée |
| 81 | 81 | */ |
| 82 | 82 | function rubrique_inserer($id_parent, $set = null) { |
| 83 | - $champs = [ |
|
| 84 | - 'titre' => _T('item_nouvelle_rubrique'), |
|
| 85 | - 'id_parent' => intval($id_parent), |
|
| 86 | - 'statut' => 'prepa' |
|
| 87 | - ]; |
|
| 88 | - |
|
| 89 | - if ($set) { |
|
| 90 | - $champs = array_merge($champs, $set); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Envoyer aux plugins |
|
| 94 | - $champs = pipeline( |
|
| 95 | - 'pre_insertion', |
|
| 96 | - [ |
|
| 97 | - 'args' => [ |
|
| 98 | - 'table' => 'spip_rubriques', |
|
| 99 | - ], |
|
| 100 | - 'data' => $champs |
|
| 101 | - ] |
|
| 102 | - ); |
|
| 103 | - |
|
| 104 | - $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 105 | - pipeline( |
|
| 106 | - 'post_insertion', |
|
| 107 | - [ |
|
| 108 | - 'args' => [ |
|
| 109 | - 'table' => 'spip_rubriques', |
|
| 110 | - 'id_objet' => $id_rubrique |
|
| 111 | - ], |
|
| 112 | - 'data' => $champs |
|
| 113 | - ] |
|
| 114 | - ); |
|
| 115 | - propager_les_secteurs(); |
|
| 116 | - calculer_langues_rubriques(); |
|
| 117 | - |
|
| 118 | - return $id_rubrique; |
|
| 83 | + $champs = [ |
|
| 84 | + 'titre' => _T('item_nouvelle_rubrique'), |
|
| 85 | + 'id_parent' => intval($id_parent), |
|
| 86 | + 'statut' => 'prepa' |
|
| 87 | + ]; |
|
| 88 | + |
|
| 89 | + if ($set) { |
|
| 90 | + $champs = array_merge($champs, $set); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Envoyer aux plugins |
|
| 94 | + $champs = pipeline( |
|
| 95 | + 'pre_insertion', |
|
| 96 | + [ |
|
| 97 | + 'args' => [ |
|
| 98 | + 'table' => 'spip_rubriques', |
|
| 99 | + ], |
|
| 100 | + 'data' => $champs |
|
| 101 | + ] |
|
| 102 | + ); |
|
| 103 | + |
|
| 104 | + $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 105 | + pipeline( |
|
| 106 | + 'post_insertion', |
|
| 107 | + [ |
|
| 108 | + 'args' => [ |
|
| 109 | + 'table' => 'spip_rubriques', |
|
| 110 | + 'id_objet' => $id_rubrique |
|
| 111 | + ], |
|
| 112 | + 'data' => $champs |
|
| 113 | + ] |
|
| 114 | + ); |
|
| 115 | + propager_les_secteurs(); |
|
| 116 | + calculer_langues_rubriques(); |
|
| 117 | + |
|
| 118 | + return $id_rubrique; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -131,46 +131,46 @@ discard block |
||
| 131 | 131 | * - chaîne : Texte d'un message d'erreur |
| 132 | 132 | */ |
| 133 | 133 | function rubrique_modifier($id_rubrique, $set = null) { |
| 134 | - include_spip('inc/autoriser'); |
|
| 135 | - include_spip('inc/filtres'); |
|
| 136 | - |
|
| 137 | - include_spip('inc/modifier'); |
|
| 138 | - $c = collecter_requests( |
|
| 139 | - // include list |
|
| 140 | - objet_info('rubrique', 'champs_editables'), |
|
| 141 | - // exclude list |
|
| 142 | - ['id_parent', 'confirme_deplace'], |
|
| 143 | - // donnees eventuellement fournies |
|
| 144 | - $set |
|
| 145 | - ); |
|
| 146 | - |
|
| 147 | - if ( |
|
| 148 | - $err = objet_modifier_champs( |
|
| 149 | - 'rubrique', |
|
| 150 | - $id_rubrique, |
|
| 151 | - [ |
|
| 152 | - 'data' => $set, |
|
| 153 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 154 | - ], |
|
| 155 | - $c |
|
| 156 | - ) |
|
| 157 | - ) { |
|
| 158 | - return $err; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 162 | - // Deplacer la rubrique |
|
| 163 | - if (isset($c['id_parent'])) { |
|
| 164 | - $err = rubrique_instituer($id_rubrique, $c); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // invalider les caches marques de cette rubrique |
|
| 168 | - include_spip('inc/invalideur'); |
|
| 169 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 170 | - // et celui de menu_rubriques |
|
| 171 | - effacer_meta('date_calcul_rubriques'); |
|
| 172 | - |
|
| 173 | - return $err; |
|
| 134 | + include_spip('inc/autoriser'); |
|
| 135 | + include_spip('inc/filtres'); |
|
| 136 | + |
|
| 137 | + include_spip('inc/modifier'); |
|
| 138 | + $c = collecter_requests( |
|
| 139 | + // include list |
|
| 140 | + objet_info('rubrique', 'champs_editables'), |
|
| 141 | + // exclude list |
|
| 142 | + ['id_parent', 'confirme_deplace'], |
|
| 143 | + // donnees eventuellement fournies |
|
| 144 | + $set |
|
| 145 | + ); |
|
| 146 | + |
|
| 147 | + if ( |
|
| 148 | + $err = objet_modifier_champs( |
|
| 149 | + 'rubrique', |
|
| 150 | + $id_rubrique, |
|
| 151 | + [ |
|
| 152 | + 'data' => $set, |
|
| 153 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 154 | + ], |
|
| 155 | + $c |
|
| 156 | + ) |
|
| 157 | + ) { |
|
| 158 | + return $err; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 162 | + // Deplacer la rubrique |
|
| 163 | + if (isset($c['id_parent'])) { |
|
| 164 | + $err = rubrique_instituer($id_rubrique, $c); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // invalider les caches marques de cette rubrique |
|
| 168 | + include_spip('inc/invalideur'); |
|
| 169 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 170 | + // et celui de menu_rubriques |
|
| 171 | + effacer_meta('date_calcul_rubriques'); |
|
| 172 | + |
|
| 173 | + return $err; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -193,25 +193,25 @@ discard block |
||
| 193 | 193 | * false si la confirmation du déplacement n'est pas présente |
| 194 | 194 | */ |
| 195 | 195 | function editer_rubrique_breves($id_rubrique, $id_parent, $c = []) { |
| 196 | - if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 197 | - return true; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') { |
|
| 201 | - return false; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if ( |
|
| 205 | - $id_secteur = sql_getfetsel( |
|
| 206 | - 'id_secteur', |
|
| 207 | - 'spip_rubriques', |
|
| 208 | - "id_rubrique=$id_parent" |
|
| 209 | - ) |
|
| 210 | - ) { |
|
| 211 | - sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - return true; |
|
| 196 | + if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 197 | + return true; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') { |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if ( |
|
| 205 | + $id_secteur = sql_getfetsel( |
|
| 206 | + 'id_secteur', |
|
| 207 | + 'spip_rubriques', |
|
| 208 | + "id_rubrique=$id_parent" |
|
| 209 | + ) |
|
| 210 | + ) { |
|
| 211 | + sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + return true; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -233,50 +233,50 @@ discard block |
||
| 233 | 233 | * Chaîne : Texte du message d'erreur |
| 234 | 234 | */ |
| 235 | 235 | function rubrique_instituer($id_rubrique, $c) { |
| 236 | - // traitement de la rubrique parente |
|
| 237 | - // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 238 | - // qu'on n'administre pas. |
|
| 239 | - |
|
| 240 | - if (null !== ($id_parent = $c['id_parent'])) { |
|
| 241 | - $id_parent = intval($id_parent); |
|
| 242 | - $filles = calcul_branche_in($id_rubrique); |
|
| 243 | - if (strpos(",$id_parent,", (string) ",$filles,") !== false) { |
|
| 244 | - spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 245 | - } else { |
|
| 246 | - $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 247 | - $old_parent = $s['id_parent']; |
|
| 248 | - |
|
| 249 | - if ( |
|
| 250 | - !($id_parent != $old_parent |
|
| 251 | - and autoriser('publierdans', 'rubrique', $id_parent) |
|
| 252 | - and autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 253 | - and autoriser('publierdans', 'rubrique', $old_parent) |
|
| 254 | - ) |
|
| 255 | - ) { |
|
| 256 | - if ($s['statut'] != 'prepa') { |
|
| 257 | - spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 258 | - } |
|
| 259 | - } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 260 | - $statut_ancien = $s['statut']; |
|
| 261 | - sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - propager_les_secteurs(); |
|
| 265 | - |
|
| 266 | - // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 267 | - if ($statut_ancien == 'publie') { |
|
| 268 | - calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 269 | - } |
|
| 270 | - // Creation ou deplacement d'une rubrique non publiee |
|
| 271 | - // invalider le cache de leur menu |
|
| 272 | - elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 273 | - effacer_meta('date_calcul_rubriques'); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - calculer_langues_rubriques(); |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - return ''; // pas d'erreur |
|
| 236 | + // traitement de la rubrique parente |
|
| 237 | + // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 238 | + // qu'on n'administre pas. |
|
| 239 | + |
|
| 240 | + if (null !== ($id_parent = $c['id_parent'])) { |
|
| 241 | + $id_parent = intval($id_parent); |
|
| 242 | + $filles = calcul_branche_in($id_rubrique); |
|
| 243 | + if (strpos(",$id_parent,", (string) ",$filles,") !== false) { |
|
| 244 | + spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 245 | + } else { |
|
| 246 | + $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 247 | + $old_parent = $s['id_parent']; |
|
| 248 | + |
|
| 249 | + if ( |
|
| 250 | + !($id_parent != $old_parent |
|
| 251 | + and autoriser('publierdans', 'rubrique', $id_parent) |
|
| 252 | + and autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 253 | + and autoriser('publierdans', 'rubrique', $old_parent) |
|
| 254 | + ) |
|
| 255 | + ) { |
|
| 256 | + if ($s['statut'] != 'prepa') { |
|
| 257 | + spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 258 | + } |
|
| 259 | + } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 260 | + $statut_ancien = $s['statut']; |
|
| 261 | + sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + propager_les_secteurs(); |
|
| 265 | + |
|
| 266 | + // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 267 | + if ($statut_ancien == 'publie') { |
|
| 268 | + calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 269 | + } |
|
| 270 | + // Creation ou deplacement d'une rubrique non publiee |
|
| 271 | + // invalider le cache de leur menu |
|
| 272 | + elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 273 | + effacer_meta('date_calcul_rubriques'); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + calculer_langues_rubriques(); |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + return ''; // pas d'erreur |
|
| 282 | 282 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | **/ |
| 45 | 45 | function install_fichier_connexion($nom, $texte) { |
| 46 | - $texte = '<' . "?php\n" |
|
| 47 | - . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | - . $texte; |
|
| 46 | + $texte = '<' . "?php\n" |
|
| 47 | + . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 48 | + . $texte; |
|
| 49 | 49 | |
| 50 | - ecrire_fichier($nom, $texte); |
|
| 50 | + ecrire_fichier($nom, $texte); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -76,20 +76,20 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | **/ |
| 78 | 78 | function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') { |
| 79 | - $adr = addcslashes($adr, "'\\"); |
|
| 80 | - $port = addcslashes($port, "'\\"); |
|
| 81 | - $login = addcslashes($login, "'\\"); |
|
| 82 | - $pass = addcslashes($pass, "'\\"); |
|
| 83 | - $base = addcslashes($base, "'\\"); |
|
| 84 | - $type = addcslashes($type, "'\\"); |
|
| 85 | - $pref = addcslashes($pref, "'\\"); |
|
| 86 | - $ldap = addcslashes($ldap, "'\\"); |
|
| 87 | - $charset = addcslashes($charset, "'\\"); |
|
| 88 | - |
|
| 89 | - return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 90 | - . 'spip_connect_db(' |
|
| 91 | - . "'$adr','$port','$login','$pass','$base'" |
|
| 92 | - . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 79 | + $adr = addcslashes($adr, "'\\"); |
|
| 80 | + $port = addcslashes($port, "'\\"); |
|
| 81 | + $login = addcslashes($login, "'\\"); |
|
| 82 | + $pass = addcslashes($pass, "'\\"); |
|
| 83 | + $base = addcslashes($base, "'\\"); |
|
| 84 | + $type = addcslashes($type, "'\\"); |
|
| 85 | + $pref = addcslashes($pref, "'\\"); |
|
| 86 | + $ldap = addcslashes($ldap, "'\\"); |
|
| 87 | + $charset = addcslashes($charset, "'\\"); |
|
| 88 | + |
|
| 89 | + return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 90 | + . 'spip_connect_db(' |
|
| 91 | + . "'$adr','$port','$login','$pass','$base'" |
|
| 92 | + . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -105,29 +105,29 @@ discard block |
||
| 105 | 105 | * Tableau des informations sur la connexion |
| 106 | 106 | **/ |
| 107 | 107 | function analyse_fichier_connection(string $file): array { |
| 108 | - if (!file_exists($file)) { |
|
| 109 | - return []; |
|
| 110 | - } |
|
| 111 | - $s = file_get_contents($file); |
|
| 112 | - if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 113 | - array_shift($regs); |
|
| 114 | - |
|
| 115 | - return $regs; |
|
| 116 | - } else { |
|
| 117 | - $ar = '\s*\'([^\']*)\''; |
|
| 118 | - $r = '\s*,' . $ar; |
|
| 119 | - $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 120 | - if (preg_match($r, $s, $regs)) { |
|
| 121 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';'); |
|
| 122 | - array_shift($regs); |
|
| 123 | - array_shift($regs); |
|
| 124 | - |
|
| 125 | - return $regs; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - spip_log("$file n'est pas un fichier de connexion"); |
|
| 129 | - |
|
| 130 | - return []; |
|
| 108 | + if (!file_exists($file)) { |
|
| 109 | + return []; |
|
| 110 | + } |
|
| 111 | + $s = file_get_contents($file); |
|
| 112 | + if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 113 | + array_shift($regs); |
|
| 114 | + |
|
| 115 | + return $regs; |
|
| 116 | + } else { |
|
| 117 | + $ar = '\s*\'([^\']*)\''; |
|
| 118 | + $r = '\s*,' . $ar; |
|
| 119 | + $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 120 | + if (preg_match($r, $s, $regs)) { |
|
| 121 | + $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';'); |
|
| 122 | + array_shift($regs); |
|
| 123 | + array_shift($regs); |
|
| 124 | + |
|
| 125 | + return $regs; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + spip_log("$file n'est pas un fichier de connexion"); |
|
| 129 | + |
|
| 130 | + return []; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -144,75 +144,75 @@ discard block |
||
| 144 | 144 | * Liste des noms de connecteurs |
| 145 | 145 | **/ |
| 146 | 146 | function bases_referencees($exclu = '') { |
| 147 | - $tables = []; |
|
| 148 | - foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 149 | - if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 150 | - $tables[] = basename($f, '.php'); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $tables; |
|
| 147 | + $tables = []; |
|
| 148 | + foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 149 | + if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 150 | + $tables[] = basename($f, '.php'); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $tables; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | function install_mode_appel($server_db, $tout = true) { |
| 159 | - return ($server_db != 'mysql') ? '' |
|
| 160 | - : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 161 | - . test_sql_mode_mysql($server_db)); |
|
| 159 | + return ($server_db != 'mysql') ? '' |
|
| 160 | + : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 161 | + . test_sql_mode_mysql($server_db)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // |
| 165 | 165 | // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-) |
| 166 | 166 | // (sert a l'etape 1 de l'installation) |
| 167 | 167 | function tester_compatibilite_hebergement() { |
| 168 | - $err = []; |
|
| 169 | - |
|
| 170 | - $p = phpversion(); |
|
| 171 | - if (version_compare($p, _PHP_MIN, '<')) { |
|
| 172 | - $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]); |
|
| 173 | - } |
|
| 174 | - if (version_compare($p, _PHP_MAX, '>')) { |
|
| 175 | - $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions()); |
|
| 179 | - if (!empty($diff)) { |
|
| 180 | - $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 184 | - if ($err) { |
|
| 185 | - die("<div class='error'>" |
|
| 186 | - . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 187 | - . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // Il faut une base de donnees tout de meme ... |
|
| 191 | - $serveurs = install_select_serveur(); |
|
| 192 | - if (!$serveurs) { |
|
| 193 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 194 | - . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 195 | - . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 196 | - . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0) |
|
| 200 | - if ($a = @ini_get('mbstring.func_overload')) { |
|
| 201 | - $err[] = _T('install_extension_mbstring') |
|
| 202 | - . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - if ($err) { |
|
| 206 | - echo "<div class='error'>" |
|
| 207 | - . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 208 | - foreach ($err as $e) { |
|
| 209 | - echo "<li><strong>$e</strong></li>\n"; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 213 | - # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 214 | - echo "</ul></div>\n"; |
|
| 215 | - } |
|
| 168 | + $err = []; |
|
| 169 | + |
|
| 170 | + $p = phpversion(); |
|
| 171 | + if (version_compare($p, _PHP_MIN, '<')) { |
|
| 172 | + $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]); |
|
| 173 | + } |
|
| 174 | + if (version_compare($p, _PHP_MAX, '>')) { |
|
| 175 | + $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions()); |
|
| 179 | + if (!empty($diff)) { |
|
| 180 | + $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 184 | + if ($err) { |
|
| 185 | + die("<div class='error'>" |
|
| 186 | + . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 187 | + . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // Il faut une base de donnees tout de meme ... |
|
| 191 | + $serveurs = install_select_serveur(); |
|
| 192 | + if (!$serveurs) { |
|
| 193 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 194 | + . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 195 | + . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 196 | + . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0) |
|
| 200 | + if ($a = @ini_get('mbstring.func_overload')) { |
|
| 201 | + $err[] = _T('install_extension_mbstring') |
|
| 202 | + . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + if ($err) { |
|
| 206 | + echo "<div class='error'>" |
|
| 207 | + . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 208 | + foreach ($err as $e) { |
|
| 209 | + echo "<li><strong>$e</strong></li>\n"; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 213 | + # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 214 | + echo "</ul></div>\n"; |
|
| 215 | + } |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
@@ -222,23 +222,23 @@ discard block |
||
| 222 | 222 | * @note superflu ?? |
| 223 | 223 | */ |
| 224 | 224 | function login_hebergeur() { |
| 225 | - $base_hebergeur = 'localhost'; # par defaut |
|
| 225 | + $base_hebergeur = 'localhost'; # par defaut |
|
| 226 | 226 | |
| 227 | - // Free |
|
| 228 | - if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 229 | - $base_hebergeur = 'sql.free.fr'; |
|
| 230 | - $login_hebergeur = $regs[1]; |
|
| 231 | - } else { |
|
| 232 | - $login_hebergeur = ''; |
|
| 233 | - } |
|
| 227 | + // Free |
|
| 228 | + if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 229 | + $base_hebergeur = 'sql.free.fr'; |
|
| 230 | + $login_hebergeur = $regs[1]; |
|
| 231 | + } else { |
|
| 232 | + $login_hebergeur = ''; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - return [$base_hebergeur, $login_hebergeur]; |
|
| 235 | + return [$base_hebergeur, $login_hebergeur]; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | function info_etape($titre, $complement = '') { |
| 240 | - return '<h2>' . $titre . "</h2>\n" . |
|
| 241 | - ($complement ? '' . $complement . "\n" : ''); |
|
| 240 | + return '<h2>' . $titre . "</h2>\n" . |
|
| 241 | + ($complement ? '' . $complement . "\n" : ''); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -248,154 +248,154 @@ discard block |
||
| 248 | 248 | * @return string Code HTML du bouton |
| 249 | 249 | **/ |
| 250 | 250 | function bouton_suivant($code = '') { |
| 251 | - if ($code == '') { |
|
| 252 | - $code = _T('bouton_suivant'); |
|
| 253 | - } |
|
| 254 | - static $suivant = 0; |
|
| 255 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 256 | - $suivant += 1; |
|
| 257 | - |
|
| 258 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 259 | - $code . |
|
| 260 | - " >>\" /></p>\n"; |
|
| 251 | + if ($code == '') { |
|
| 252 | + $code = _T('bouton_suivant'); |
|
| 253 | + } |
|
| 254 | + static $suivant = 0; |
|
| 255 | + $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 256 | + $suivant += 1; |
|
| 257 | + |
|
| 258 | + return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 259 | + $code . |
|
| 260 | + " >>\" /></p>\n"; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 264 | - $intitule_etat = []; |
|
| 265 | - //$en_cours = _request('etape')?_request('etape'):""; |
|
| 266 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 267 | - $debut = 1; |
|
| 268 | - $etat = 'ok'; |
|
| 269 | - $last = count($liste); |
|
| 264 | + $intitule_etat = []; |
|
| 265 | + //$en_cours = _request('etape')?_request('etape'):""; |
|
| 266 | + $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 267 | + $debut = 1; |
|
| 268 | + $etat = 'ok'; |
|
| 269 | + $last = count($liste); |
|
| 270 | 270 | // $texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo')); |
| 271 | 271 | |
| 272 | - $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee')); |
|
| 273 | - $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 274 | - $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles')); |
|
| 275 | - $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape')); |
|
| 272 | + $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee')); |
|
| 273 | + $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 274 | + $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles')); |
|
| 275 | + $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape')); |
|
| 276 | 276 | |
| 277 | - $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap')); |
|
| 278 | - $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap')); |
|
| 279 | - $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1')); |
|
| 280 | - $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap')); |
|
| 281 | - $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok')); |
|
| 277 | + $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap')); |
|
| 278 | + $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap')); |
|
| 279 | + $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1')); |
|
| 280 | + $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap')); |
|
| 281 | + $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok')); |
|
| 282 | 282 | |
| 283 | 283 | // $aff_etapes = "<span id='etapes'>"; |
| 284 | 284 | |
| 285 | - $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 286 | - |
|
| 287 | - foreach ($liste as $etape => $fichier) { |
|
| 288 | - if ($debut < $last) { |
|
| 289 | - if ($debut == $en_cours && $erreur) { |
|
| 290 | - $class = 'on erreur'; |
|
| 291 | - } else { |
|
| 292 | - if ($debut == $en_cours) { |
|
| 293 | - $class = 'on'; |
|
| 294 | - } else { |
|
| 295 | - if ($debut > $en_cours) { |
|
| 296 | - $class = 'prochains'; |
|
| 297 | - } else { |
|
| 298 | - $class = 'valides'; |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 304 | - $aff_etapes .= ($debut == $en_cours) ? '<strong>' : ''; |
|
| 305 | - $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 306 | - $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 307 | - $aff_etapes .= ($debut == $en_cours) ? '</strong>' : ''; |
|
| 308 | - $aff_etapes .= '</div></li>'; |
|
| 309 | - } |
|
| 310 | - $debut++; |
|
| 311 | - } |
|
| 312 | - $aff_etapes .= '</ul>'; |
|
| 313 | - $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 314 | - |
|
| 315 | - return $aff_etapes; |
|
| 285 | + $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 286 | + |
|
| 287 | + foreach ($liste as $etape => $fichier) { |
|
| 288 | + if ($debut < $last) { |
|
| 289 | + if ($debut == $en_cours && $erreur) { |
|
| 290 | + $class = 'on erreur'; |
|
| 291 | + } else { |
|
| 292 | + if ($debut == $en_cours) { |
|
| 293 | + $class = 'on'; |
|
| 294 | + } else { |
|
| 295 | + if ($debut > $en_cours) { |
|
| 296 | + $class = 'prochains'; |
|
| 297 | + } else { |
|
| 298 | + $class = 'valides'; |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 304 | + $aff_etapes .= ($debut == $en_cours) ? '<strong>' : ''; |
|
| 305 | + $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 306 | + $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 307 | + $aff_etapes .= ($debut == $en_cours) ? '</strong>' : ''; |
|
| 308 | + $aff_etapes .= '</div></li>'; |
|
| 309 | + } |
|
| 310 | + $debut++; |
|
| 311 | + } |
|
| 312 | + $aff_etapes .= '</ul>'; |
|
| 313 | + $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 314 | + |
|
| 315 | + return $aff_etapes; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | function fieldset($legend, $champs = [], $apres = '', $avant = '') { |
| 320 | - return "<fieldset>\n" . |
|
| 321 | - $avant . |
|
| 322 | - ($legend ? '<legend>' . $legend . "</legend>\n" : '') . |
|
| 323 | - fieldset_champs($champs) . |
|
| 324 | - $apres . |
|
| 325 | - "</fieldset>\n"; |
|
| 320 | + return "<fieldset>\n" . |
|
| 321 | + $avant . |
|
| 322 | + ($legend ? '<legend>' . $legend . "</legend>\n" : '') . |
|
| 323 | + fieldset_champs($champs) . |
|
| 324 | + $apres . |
|
| 325 | + "</fieldset>\n"; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | function fieldset_champs($champs = []) { |
| 329 | - $fieldset = ''; |
|
| 330 | - foreach ($champs as $nom => $contenu) { |
|
| 331 | - $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 332 | - $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 333 | - if (isset($contenu['alternatives'])) { |
|
| 334 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 335 | - foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 336 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 337 | - "' id='$nom-$valeur' value='$valeur'" |
|
| 338 | - . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 339 | - . "/>\n"; |
|
| 340 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 341 | - } |
|
| 342 | - $fieldset .= "<br />\n"; |
|
| 343 | - } else { |
|
| 344 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 345 | - $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 346 | - . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 347 | - . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '') |
|
| 348 | - . " />\n"; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - return $fieldset; |
|
| 329 | + $fieldset = ''; |
|
| 330 | + foreach ($champs as $nom => $contenu) { |
|
| 331 | + $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 332 | + $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 333 | + if (isset($contenu['alternatives'])) { |
|
| 334 | + $fieldset .= $contenu['label'] . "\n"; |
|
| 335 | + foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 336 | + $fieldset .= "<input type='radio' name='" . $nom . |
|
| 337 | + "' id='$nom-$valeur' value='$valeur'" |
|
| 338 | + . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 339 | + . "/>\n"; |
|
| 340 | + $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 341 | + } |
|
| 342 | + $fieldset .= "<br />\n"; |
|
| 343 | + } else { |
|
| 344 | + $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 345 | + $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 346 | + . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 347 | + . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '') |
|
| 348 | + . " />\n"; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + return $fieldset; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | function install_select_serveur() { |
| 356 | - $options = []; |
|
| 357 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 358 | - $d = opendir($dir); |
|
| 359 | - if (!$d) { |
|
| 360 | - return []; |
|
| 361 | - } |
|
| 362 | - while (($f = readdir($d)) !== false) { |
|
| 363 | - if ( |
|
| 364 | - (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 365 | - and is_readable($f = $dir . $f) |
|
| 366 | - ) { |
|
| 367 | - require_once($f); |
|
| 368 | - $s = $s[1]; |
|
| 369 | - $v = 'spip_versions_' . $s; |
|
| 370 | - if (function_exists($v) and $v()) { |
|
| 371 | - $titre = _T("install_select_type_$s"); |
|
| 372 | - // proposer mysql par defaut si dispo |
|
| 373 | - $checked = ($s == 'mysql' ? " checked='checked'" : ''); |
|
| 374 | - $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 375 | - . "<label for='$s'>" . ($titre ?: $s) . '</label></li>'; |
|
| 376 | - } else { |
|
| 377 | - spip_log("$s: portage indisponible"); |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - sort($options); |
|
| 382 | - |
|
| 383 | - return $options; |
|
| 356 | + $options = []; |
|
| 357 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 358 | + $d = opendir($dir); |
|
| 359 | + if (!$d) { |
|
| 360 | + return []; |
|
| 361 | + } |
|
| 362 | + while (($f = readdir($d)) !== false) { |
|
| 363 | + if ( |
|
| 364 | + (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 365 | + and is_readable($f = $dir . $f) |
|
| 366 | + ) { |
|
| 367 | + require_once($f); |
|
| 368 | + $s = $s[1]; |
|
| 369 | + $v = 'spip_versions_' . $s; |
|
| 370 | + if (function_exists($v) and $v()) { |
|
| 371 | + $titre = _T("install_select_type_$s"); |
|
| 372 | + // proposer mysql par defaut si dispo |
|
| 373 | + $checked = ($s == 'mysql' ? " checked='checked'" : ''); |
|
| 374 | + $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 375 | + . "<label for='$s'>" . ($titre ?: $s) . '</label></li>'; |
|
| 376 | + } else { |
|
| 377 | + spip_log("$s: portage indisponible"); |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + sort($options); |
|
| 382 | + |
|
| 383 | + return $options; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) { |
| 387 | - $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 388 | - |
|
| 389 | - return generer_form_ecrire('install', ( |
|
| 390 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 391 | - . $hidden |
|
| 392 | - . (_request('echec') ? |
|
| 393 | - ('<p><b>' . _T('avis_connexion_echec_1') . |
|
| 394 | - '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>') |
|
| 395 | - : '') |
|
| 396 | - |
|
| 397 | - . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 398 | - . http_script(' |
|
| 387 | + $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 388 | + |
|
| 389 | + return generer_form_ecrire('install', ( |
|
| 390 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 391 | + . $hidden |
|
| 392 | + . (_request('echec') ? |
|
| 393 | + ('<p><b>' . _T('avis_connexion_echec_1') . |
|
| 394 | + '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>') |
|
| 395 | + : '') |
|
| 396 | + |
|
| 397 | + . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 398 | + . http_script(' |
|
| 399 | 399 | jQuery(function($) { |
| 400 | 400 | $details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur"); |
| 401 | 401 | $("input[type=hidden][name=server_db]").each(function(){ |
@@ -428,145 +428,145 @@ discard block |
||
| 428 | 428 | }); |
| 429 | 429 | });') |
| 430 | 430 | |
| 431 | - . ($server_db |
|
| 432 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 433 | - . (($predef[0]) |
|
| 434 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 435 | - : '') |
|
| 436 | - : ('<fieldset><legend>' |
|
| 437 | - . _T('install_select_type_db') |
|
| 438 | - . '</legend>' |
|
| 439 | - . '<p class="explication">' |
|
| 440 | - . _T('install_types_db_connus') |
|
| 441 | - // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 442 | - // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 443 | - . '</p>' |
|
| 444 | - . "\n<div class='p'>\n<ul>\n" |
|
| 445 | - . join("\n", install_select_serveur()) |
|
| 446 | - . "\n</ul>\n</div></fieldset>") |
|
| 447 | - ) |
|
| 448 | - . '<div id="install_adresse_base_hebergeur">' |
|
| 449 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 450 | - . ($predef[1] |
|
| 451 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 452 | - : fieldset( |
|
| 453 | - _T('entree_base_donnee_1'), |
|
| 454 | - [ |
|
| 455 | - 'adresse_db' => [ |
|
| 456 | - 'label' => $db[1], |
|
| 457 | - 'valeur' => $db[0] |
|
| 458 | - ], |
|
| 459 | - ] |
|
| 460 | - ) |
|
| 461 | - ) |
|
| 462 | - . '</div>' |
|
| 463 | - |
|
| 464 | - . '<div id="install_login_base_hebergeur">' |
|
| 465 | - . ($predef[2] |
|
| 466 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 467 | - : fieldset( |
|
| 468 | - _T('entree_login_connexion_1'), |
|
| 469 | - [ |
|
| 470 | - 'login_db' => [ |
|
| 471 | - 'label' => $login[1], |
|
| 472 | - 'valeur' => $login[0] |
|
| 473 | - ], |
|
| 474 | - ] |
|
| 475 | - ) |
|
| 476 | - ) |
|
| 477 | - . '</div>' |
|
| 478 | - |
|
| 479 | - . '<div id="install_pass_base_hebergeur">' |
|
| 480 | - . ($predef[3] |
|
| 481 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 482 | - : fieldset( |
|
| 483 | - _T('entree_mot_passe_1'), |
|
| 484 | - [ |
|
| 485 | - 'pass_db' => [ |
|
| 486 | - 'label' => $pass[1], |
|
| 487 | - 'valeur' => $pass[0] |
|
| 488 | - ], |
|
| 489 | - ] |
|
| 490 | - ) |
|
| 491 | - ) |
|
| 492 | - . '</div>' |
|
| 493 | - |
|
| 494 | - . bouton_suivant())); |
|
| 431 | + . ($server_db |
|
| 432 | + ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 433 | + . (($predef[0]) |
|
| 434 | + ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 435 | + : '') |
|
| 436 | + : ('<fieldset><legend>' |
|
| 437 | + . _T('install_select_type_db') |
|
| 438 | + . '</legend>' |
|
| 439 | + . '<p class="explication">' |
|
| 440 | + . _T('install_types_db_connus') |
|
| 441 | + // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 442 | + // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 443 | + . '</p>' |
|
| 444 | + . "\n<div class='p'>\n<ul>\n" |
|
| 445 | + . join("\n", install_select_serveur()) |
|
| 446 | + . "\n</ul>\n</div></fieldset>") |
|
| 447 | + ) |
|
| 448 | + . '<div id="install_adresse_base_hebergeur">' |
|
| 449 | + . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 450 | + . ($predef[1] |
|
| 451 | + ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 452 | + : fieldset( |
|
| 453 | + _T('entree_base_donnee_1'), |
|
| 454 | + [ |
|
| 455 | + 'adresse_db' => [ |
|
| 456 | + 'label' => $db[1], |
|
| 457 | + 'valeur' => $db[0] |
|
| 458 | + ], |
|
| 459 | + ] |
|
| 460 | + ) |
|
| 461 | + ) |
|
| 462 | + . '</div>' |
|
| 463 | + |
|
| 464 | + . '<div id="install_login_base_hebergeur">' |
|
| 465 | + . ($predef[2] |
|
| 466 | + ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 467 | + : fieldset( |
|
| 468 | + _T('entree_login_connexion_1'), |
|
| 469 | + [ |
|
| 470 | + 'login_db' => [ |
|
| 471 | + 'label' => $login[1], |
|
| 472 | + 'valeur' => $login[0] |
|
| 473 | + ], |
|
| 474 | + ] |
|
| 475 | + ) |
|
| 476 | + ) |
|
| 477 | + . '</div>' |
|
| 478 | + |
|
| 479 | + . '<div id="install_pass_base_hebergeur">' |
|
| 480 | + . ($predef[3] |
|
| 481 | + ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 482 | + : fieldset( |
|
| 483 | + _T('entree_mot_passe_1'), |
|
| 484 | + [ |
|
| 485 | + 'pass_db' => [ |
|
| 486 | + 'label' => $pass[1], |
|
| 487 | + 'valeur' => $pass[0] |
|
| 488 | + ], |
|
| 489 | + ] |
|
| 490 | + ) |
|
| 491 | + ) |
|
| 492 | + . '</div>' |
|
| 493 | + |
|
| 494 | + . bouton_suivant())); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // 4 valeurs qu'on reconduit d'un script a l'autre |
| 498 | 498 | // sauf s'ils sont predefinis. |
| 499 | 499 | |
| 500 | 500 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 501 | - return ((defined('_INSTALL_HOST_DB')) |
|
| 502 | - ? '' |
|
| 503 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . '" />' |
|
| 504 | - ) |
|
| 505 | - . ((defined('_INSTALL_USER_DB')) |
|
| 506 | - ? '' |
|
| 507 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />' |
|
| 508 | - ) |
|
| 509 | - . ((defined('_INSTALL_PASS_DB')) |
|
| 510 | - ? '' |
|
| 511 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />' |
|
| 512 | - ) |
|
| 513 | - |
|
| 514 | - . ((defined('_INSTALL_SERVER_DB')) |
|
| 515 | - ? '' |
|
| 516 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />' |
|
| 517 | - ); |
|
| 501 | + return ((defined('_INSTALL_HOST_DB')) |
|
| 502 | + ? '' |
|
| 503 | + : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . '" />' |
|
| 504 | + ) |
|
| 505 | + . ((defined('_INSTALL_USER_DB')) |
|
| 506 | + ? '' |
|
| 507 | + : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />' |
|
| 508 | + ) |
|
| 509 | + . ((defined('_INSTALL_PASS_DB')) |
|
| 510 | + ? '' |
|
| 511 | + : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />' |
|
| 512 | + ) |
|
| 513 | + |
|
| 514 | + . ((defined('_INSTALL_SERVER_DB')) |
|
| 515 | + ? '' |
|
| 516 | + : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />' |
|
| 517 | + ); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | // presentation des bases existantes |
| 521 | 521 | |
| 522 | 522 | function install_etape_liste_bases($server_db, $login_db, $disabled = []) { |
| 523 | - $bases = $checked = []; |
|
| 524 | - $noms = sql_listdbs($server_db); |
|
| 525 | - if (!$noms) { |
|
| 526 | - return ''; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - foreach ($noms as $nom) { |
|
| 530 | - $id = spip_htmlspecialchars($nom); |
|
| 531 | - $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 532 | - $base = ' name="choix_db" value="' |
|
| 533 | - . $nom |
|
| 534 | - . '"' |
|
| 535 | - . $dis |
|
| 536 | - . " type='radio' id='$id'"; |
|
| 537 | - $label = "<label for='$id'>" |
|
| 538 | - . ($dis ? "<i>$nom</i>" : $nom) |
|
| 539 | - . '</label>'; |
|
| 540 | - |
|
| 541 | - if ( |
|
| 542 | - !$checked and !$dis and |
|
| 543 | - (($nom == $login_db) or |
|
| 544 | - ($GLOBALS['table_prefix'] == $nom)) |
|
| 545 | - ) { |
|
| 546 | - $checked = "<input$base checked='checked' />\n$label"; |
|
| 547 | - } else { |
|
| 548 | - $bases[] = "<input$base />\n$label"; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - if (!$bases && !$checked) { |
|
| 553 | - return false; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - if ($checked) { |
|
| 557 | - array_unshift($bases, $checked); |
|
| 558 | - $checked = true; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - return [$checked, $bases]; |
|
| 523 | + $bases = $checked = []; |
|
| 524 | + $noms = sql_listdbs($server_db); |
|
| 525 | + if (!$noms) { |
|
| 526 | + return ''; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + foreach ($noms as $nom) { |
|
| 530 | + $id = spip_htmlspecialchars($nom); |
|
| 531 | + $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 532 | + $base = ' name="choix_db" value="' |
|
| 533 | + . $nom |
|
| 534 | + . '"' |
|
| 535 | + . $dis |
|
| 536 | + . " type='radio' id='$id'"; |
|
| 537 | + $label = "<label for='$id'>" |
|
| 538 | + . ($dis ? "<i>$nom</i>" : $nom) |
|
| 539 | + . '</label>'; |
|
| 540 | + |
|
| 541 | + if ( |
|
| 542 | + !$checked and !$dis and |
|
| 543 | + (($nom == $login_db) or |
|
| 544 | + ($GLOBALS['table_prefix'] == $nom)) |
|
| 545 | + ) { |
|
| 546 | + $checked = "<input$base checked='checked' />\n$label"; |
|
| 547 | + } else { |
|
| 548 | + $bases[] = "<input$base />\n$label"; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + if (!$bases && !$checked) { |
|
| 553 | + return false; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + if ($checked) { |
|
| 557 | + array_unshift($bases, $checked); |
|
| 558 | + $checked = true; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + return [$checked, $bases]; |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | function install_propager($hidden) { |
| 565 | - $res = ''; |
|
| 566 | - foreach ($hidden as $k) { |
|
| 567 | - $v = spip_htmlentities(_request($k)); |
|
| 568 | - $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 569 | - } |
|
| 565 | + $res = ''; |
|
| 566 | + foreach ($hidden as $k) { |
|
| 567 | + $v = spip_htmlentities(_request($k)); |
|
| 568 | + $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - return $res; |
|
| 571 | + return $res; |
|
| 572 | 572 | } |
@@ -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 | |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | * Date au format SQL tel que `2008-04-01` sinon '' |
| 38 | 38 | **/ |
| 39 | 39 | function extraire_date($texte): string { |
| 40 | - // format = 2001-08 |
|
| 41 | - if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 42 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 43 | - } |
|
| 44 | - return ''; |
|
| 40 | + // format = 2001-08 |
|
| 41 | + if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 42 | + return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 43 | + } |
|
| 44 | + return ''; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -63,29 +63,29 @@ discard block |
||
| 63 | 63 | * - une chaîne vide si la date est considérée nulle |
| 64 | 64 | **/ |
| 65 | 65 | function normaliser_date($date, $forcer_jour = false): string { |
| 66 | - $date = vider_date($date); |
|
| 67 | - if ($date) { |
|
| 68 | - if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 69 | - $date = date('Y-m-d H:i:s', $date); |
|
| 70 | - } |
|
| 71 | - if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 72 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 73 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 74 | - } else { |
|
| 75 | - if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 76 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 77 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 78 | - } else { |
|
| 79 | - $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - if ($forcer_jour) { |
|
| 84 | - $date = str_replace('-00', '-01', $date); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return $date; |
|
| 66 | + $date = vider_date($date); |
|
| 67 | + if ($date) { |
|
| 68 | + if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 69 | + $date = date('Y-m-d H:i:s', $date); |
|
| 70 | + } |
|
| 71 | + if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 72 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 73 | + $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 74 | + } else { |
|
| 75 | + if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 76 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 77 | + $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 78 | + } else { |
|
| 79 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + if ($forcer_jour) { |
|
| 84 | + $date = str_replace('-00', '-01', $date); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return $date; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -98,23 +98,23 @@ discard block |
||
| 98 | 98 | * - Une chaine vide |
| 99 | 99 | **/ |
| 100 | 100 | function vider_date($letexte, $verif_format_date = false): string { |
| 101 | - $letexte ??= ''; |
|
| 102 | - if ( |
|
| 103 | - !$verif_format_date |
|
| 104 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 105 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 106 | - ) { |
|
| 107 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 108 | - return ''; |
|
| 109 | - } |
|
| 110 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 111 | - return ''; |
|
| 112 | - } |
|
| 113 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 114 | - return ''; |
|
| 115 | - } // eviter le bug GMT-1 |
|
| 116 | - } |
|
| 117 | - return $letexte; |
|
| 101 | + $letexte ??= ''; |
|
| 102 | + if ( |
|
| 103 | + !$verif_format_date |
|
| 104 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 105 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 106 | + ) { |
|
| 107 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 110 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 111 | + return ''; |
|
| 112 | + } |
|
| 113 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 114 | + return ''; |
|
| 115 | + } // eviter le bug GMT-1 |
|
| 116 | + } |
|
| 117 | + return $letexte; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | **/ |
| 131 | 131 | function recup_heure($date): array { |
| 132 | 132 | |
| 133 | - static $d = [0, 0, 0]; |
|
| 134 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 135 | - return $d; |
|
| 136 | - } |
|
| 133 | + static $d = [0, 0, 0]; |
|
| 134 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 135 | + return $d; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - array_shift($r); |
|
| 138 | + array_shift($r); |
|
| 139 | 139 | |
| 140 | - return $r; |
|
| 140 | + return $r; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | * @return string heures, sinon 0 |
| 152 | 152 | **/ |
| 153 | 153 | function heures($numdate): string { |
| 154 | - $heures = null; |
|
| 155 | - $date_array = recup_heure($numdate); |
|
| 156 | - if ($date_array) { |
|
| 157 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 158 | - } |
|
| 154 | + $heures = null; |
|
| 155 | + $date_array = recup_heure($numdate); |
|
| 156 | + if ($date_array) { |
|
| 157 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - return $heures; |
|
| 160 | + return $heures; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | * @return string minutes, sinon 0 |
| 172 | 172 | **/ |
| 173 | 173 | function minutes($numdate): string { |
| 174 | - $minutes = null; |
|
| 175 | - $date_array = recup_heure($numdate); |
|
| 176 | - if ($date_array) { |
|
| 177 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 178 | - } |
|
| 174 | + $minutes = null; |
|
| 175 | + $date_array = recup_heure($numdate); |
|
| 176 | + if ($date_array) { |
|
| 177 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - return $minutes; |
|
| 180 | + return $minutes; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | * @return string secondes, sinon 0 |
| 192 | 192 | **/ |
| 193 | 193 | function secondes($numdate): string { |
| 194 | - $secondes = null; |
|
| 195 | - $date_array = recup_heure($numdate); |
|
| 196 | - if ($date_array) { |
|
| 197 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 198 | - } |
|
| 194 | + $secondes = null; |
|
| 195 | + $date_array = recup_heure($numdate); |
|
| 196 | + if ($date_array) { |
|
| 197 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - return $secondes; |
|
| 200 | + return $secondes; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | * @return string L'heure formatée dans la langue en cours. |
| 217 | 217 | **/ |
| 218 | 218 | function heures_minutes($numdate, $forme = ''): string { |
| 219 | - if ($forme !== 'abbr') { |
|
| 220 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 221 | - } else { |
|
| 222 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 223 | - } |
|
| 219 | + if ($forme !== 'abbr') { |
|
| 220 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 221 | + } else { |
|
| 222 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 223 | + } |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -245,57 +245,57 @@ discard block |
||
| 245 | 245 | * @return array [année, mois, jour, heures, minutes, secondes] ou [] |
| 246 | 246 | **/ |
| 247 | 247 | function recup_date($numdate, $forcer_jour = true): array { |
| 248 | - if (!$numdate) { |
|
| 249 | - return []; |
|
| 250 | - } |
|
| 251 | - $heures = $minutes = $secondes = 0; |
|
| 252 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 253 | - $jour = $regs[1]; |
|
| 254 | - $mois = $regs[2]; |
|
| 255 | - $annee = $regs[3]; |
|
| 256 | - if ($annee < 90) { |
|
| 257 | - $annee = 2000 + $annee; |
|
| 258 | - } elseif ($annee < 100) { |
|
| 259 | - $annee = 1900 + $annee; |
|
| 260 | - } |
|
| 261 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 262 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 263 | - $annee = $regs[1]; |
|
| 264 | - $mois = $regs[2]; |
|
| 265 | - $jour = $regs[3]; |
|
| 266 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 267 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 268 | - $annee = $regs[1]; |
|
| 269 | - $mois = $regs[2]; |
|
| 270 | - $jour = ''; |
|
| 271 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 272 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 273 | - $annee = $regs[1]; |
|
| 274 | - $mois = $regs[2]; |
|
| 275 | - $jour = $regs[3]; |
|
| 276 | - $heures = $regs[4]; |
|
| 277 | - $minutes = $regs[5]; |
|
| 278 | - $secondes = $regs[6]; |
|
| 279 | - } else { |
|
| 280 | - $annee = $mois = $jour = ''; |
|
| 281 | - } |
|
| 282 | - if ($annee > 4000) { |
|
| 283 | - $annee -= 9000; |
|
| 284 | - } |
|
| 285 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 286 | - $jour = substr($jour, 1); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if ($forcer_jour and $jour == '0') { |
|
| 290 | - $jour = '1'; |
|
| 291 | - } |
|
| 292 | - if ($forcer_jour and $mois == '0') { |
|
| 293 | - $mois = '1'; |
|
| 294 | - } |
|
| 295 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 296 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 297 | - } |
|
| 298 | - return []; |
|
| 248 | + if (!$numdate) { |
|
| 249 | + return []; |
|
| 250 | + } |
|
| 251 | + $heures = $minutes = $secondes = 0; |
|
| 252 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 253 | + $jour = $regs[1]; |
|
| 254 | + $mois = $regs[2]; |
|
| 255 | + $annee = $regs[3]; |
|
| 256 | + if ($annee < 90) { |
|
| 257 | + $annee = 2000 + $annee; |
|
| 258 | + } elseif ($annee < 100) { |
|
| 259 | + $annee = 1900 + $annee; |
|
| 260 | + } |
|
| 261 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 262 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 263 | + $annee = $regs[1]; |
|
| 264 | + $mois = $regs[2]; |
|
| 265 | + $jour = $regs[3]; |
|
| 266 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 267 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 268 | + $annee = $regs[1]; |
|
| 269 | + $mois = $regs[2]; |
|
| 270 | + $jour = ''; |
|
| 271 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 272 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 273 | + $annee = $regs[1]; |
|
| 274 | + $mois = $regs[2]; |
|
| 275 | + $jour = $regs[3]; |
|
| 276 | + $heures = $regs[4]; |
|
| 277 | + $minutes = $regs[5]; |
|
| 278 | + $secondes = $regs[6]; |
|
| 279 | + } else { |
|
| 280 | + $annee = $mois = $jour = ''; |
|
| 281 | + } |
|
| 282 | + if ($annee > 4000) { |
|
| 283 | + $annee -= 9000; |
|
| 284 | + } |
|
| 285 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 286 | + $jour = substr($jour, 1); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if ($forcer_jour and $jour == '0') { |
|
| 290 | + $jour = '1'; |
|
| 291 | + } |
|
| 292 | + if ($forcer_jour and $mois == '0') { |
|
| 293 | + $mois = '1'; |
|
| 294 | + } |
|
| 295 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 296 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 297 | + } |
|
| 298 | + return []; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | * La date relative ou complète |
| 323 | 323 | **/ |
| 324 | 324 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */): string { |
| 325 | - return sinon( |
|
| 326 | - date_relative($date, $decalage_maxi), |
|
| 327 | - affdate_heure($date) |
|
| 328 | - ); |
|
| 325 | + return sinon( |
|
| 326 | + date_relative($date, $decalage_maxi), |
|
| 327 | + affdate_heure($date) |
|
| 328 | + ); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -358,86 +358,86 @@ discard block |
||
| 358 | 358 | **/ |
| 359 | 359 | function date_relative($date, $decalage_maxi = 0, $ref_date = null): string { |
| 360 | 360 | |
| 361 | - if (!$date) { |
|
| 362 | - return ''; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - if (is_null($ref_date)) { |
|
| 366 | - $ref_time = time(); |
|
| 367 | - } else { |
|
| 368 | - $ref_time = strtotime($ref_date); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 372 | - |
|
| 373 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 374 | - return ''; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if ($decal < 0) { |
|
| 378 | - $il_y_a = 'date_dans'; |
|
| 379 | - $decal = -1 * $decal; |
|
| 380 | - } else { |
|
| 381 | - $il_y_a = 'date_il_y_a'; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 385 | - return affdate_court($date); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if ($decal > 3600 * 24 * 30) { |
|
| 389 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 390 | - if ($mois < 2) { |
|
| 391 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 392 | - } else { |
|
| 393 | - $delai = "$mois " . _T('date_mois'); |
|
| 394 | - } |
|
| 395 | - } else { |
|
| 396 | - if ($decal > 3600 * 24 * 7) { |
|
| 397 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 398 | - if ($semaines < 2) { |
|
| 399 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 400 | - } else { |
|
| 401 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 402 | - } |
|
| 403 | - } else { |
|
| 404 | - if ($decal > 3600 * 24) { |
|
| 405 | - $jours = floor($decal / (3600 * 24)); |
|
| 406 | - if ($jours < 2) { |
|
| 407 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 408 | - } else { |
|
| 409 | - $delai = "$jours " . _T('date_jours'); |
|
| 410 | - } |
|
| 411 | - } else { |
|
| 412 | - if ($decal >= 3600) { |
|
| 413 | - $heures = floor($decal / 3600); |
|
| 414 | - if ($heures < 2) { |
|
| 415 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 416 | - } else { |
|
| 417 | - $delai = "$heures " . _T('date_heures'); |
|
| 418 | - } |
|
| 419 | - } else { |
|
| 420 | - if ($decal >= 60) { |
|
| 421 | - $minutes = floor($decal / 60); |
|
| 422 | - if ($minutes < 2) { |
|
| 423 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 424 | - } else { |
|
| 425 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 426 | - } |
|
| 427 | - } else { |
|
| 428 | - $secondes = ceil($decal); |
|
| 429 | - if ($secondes < 2) { |
|
| 430 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 431 | - } else { |
|
| 432 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 361 | + if (!$date) { |
|
| 362 | + return ''; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + if (is_null($ref_date)) { |
|
| 366 | + $ref_time = time(); |
|
| 367 | + } else { |
|
| 368 | + $ref_time = strtotime($ref_date); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 372 | + |
|
| 373 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 374 | + return ''; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if ($decal < 0) { |
|
| 378 | + $il_y_a = 'date_dans'; |
|
| 379 | + $decal = -1 * $decal; |
|
| 380 | + } else { |
|
| 381 | + $il_y_a = 'date_il_y_a'; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 385 | + return affdate_court($date); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if ($decal > 3600 * 24 * 30) { |
|
| 389 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 390 | + if ($mois < 2) { |
|
| 391 | + $delai = "$mois " . _T('date_un_mois'); |
|
| 392 | + } else { |
|
| 393 | + $delai = "$mois " . _T('date_mois'); |
|
| 394 | + } |
|
| 395 | + } else { |
|
| 396 | + if ($decal > 3600 * 24 * 7) { |
|
| 397 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 398 | + if ($semaines < 2) { |
|
| 399 | + $delai = "$semaines " . _T('date_une_semaine'); |
|
| 400 | + } else { |
|
| 401 | + $delai = "$semaines " . _T('date_semaines'); |
|
| 402 | + } |
|
| 403 | + } else { |
|
| 404 | + if ($decal > 3600 * 24) { |
|
| 405 | + $jours = floor($decal / (3600 * 24)); |
|
| 406 | + if ($jours < 2) { |
|
| 407 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 408 | + } else { |
|
| 409 | + $delai = "$jours " . _T('date_jours'); |
|
| 410 | + } |
|
| 411 | + } else { |
|
| 412 | + if ($decal >= 3600) { |
|
| 413 | + $heures = floor($decal / 3600); |
|
| 414 | + if ($heures < 2) { |
|
| 415 | + $delai = "$heures " . _T('date_une_heure'); |
|
| 416 | + } else { |
|
| 417 | + $delai = "$heures " . _T('date_heures'); |
|
| 418 | + } |
|
| 419 | + } else { |
|
| 420 | + if ($decal >= 60) { |
|
| 421 | + $minutes = floor($decal / 60); |
|
| 422 | + if ($minutes < 2) { |
|
| 423 | + $delai = "$minutes " . _T('date_une_minute'); |
|
| 424 | + } else { |
|
| 425 | + $delai = "$minutes " . _T('date_minutes'); |
|
| 426 | + } |
|
| 427 | + } else { |
|
| 428 | + $secondes = ceil($decal); |
|
| 429 | + if ($secondes < 2) { |
|
| 430 | + $delai = "$secondes " . _T('date_une_seconde'); |
|
| 431 | + } else { |
|
| 432 | + $delai = "$secondes " . _T('date_secondes'); |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | |
@@ -463,32 +463,32 @@ discard block |
||
| 463 | 463 | **/ |
| 464 | 464 | function date_relativecourt($date, $decalage_maxi = 0): string { |
| 465 | 465 | |
| 466 | - if (!$date) { |
|
| 467 | - return ''; |
|
| 468 | - } |
|
| 469 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 470 | - |
|
| 471 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 472 | - return ''; |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - if ($decal < -24 * 3600) { |
|
| 476 | - $retour = date_relative($date, $decalage_maxi); |
|
| 477 | - } elseif ($decal < 0) { |
|
| 478 | - $retour = _T('date_demain'); |
|
| 479 | - } else { |
|
| 480 | - if ($decal < (3600 * 24)) { |
|
| 481 | - $retour = _T('date_aujourdhui'); |
|
| 482 | - } else { |
|
| 483 | - if ($decal < (3600 * 24 * 2)) { |
|
| 484 | - $retour = _T('date_hier'); |
|
| 485 | - } else { |
|
| 486 | - $retour = date_relative($date, $decalage_maxi); |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - return $retour; |
|
| 466 | + if (!$date) { |
|
| 467 | + return ''; |
|
| 468 | + } |
|
| 469 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 470 | + |
|
| 471 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 472 | + return ''; |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + if ($decal < -24 * 3600) { |
|
| 476 | + $retour = date_relative($date, $decalage_maxi); |
|
| 477 | + } elseif ($decal < 0) { |
|
| 478 | + $retour = _T('date_demain'); |
|
| 479 | + } else { |
|
| 480 | + if ($decal < (3600 * 24)) { |
|
| 481 | + $retour = _T('date_aujourdhui'); |
|
| 482 | + } else { |
|
| 483 | + if ($decal < (3600 * 24 * 2)) { |
|
| 484 | + $retour = _T('date_hier'); |
|
| 485 | + } else { |
|
| 486 | + $retour = date_relative($date, $decalage_maxi); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + return $retour; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -505,174 +505,174 @@ discard block |
||
| 505 | 505 | * @return string |
| 506 | 506 | */ |
| 507 | 507 | function affdate_base($numdate, $vue, $options = []): string { |
| 508 | - if (is_string($options)) { |
|
| 509 | - $options = ['param' => $options]; |
|
| 510 | - } |
|
| 511 | - $date_array = recup_date($numdate, false); |
|
| 512 | - if (!$date_array) { |
|
| 513 | - return ''; |
|
| 514 | - } |
|
| 515 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 516 | - |
|
| 517 | - // 1er, 21st, etc. |
|
| 518 | - $journum = $jour; |
|
| 519 | - |
|
| 520 | - if ($jour == 0) { |
|
| 521 | - $jour = ''; |
|
| 522 | - $njour = 0; |
|
| 523 | - } else { |
|
| 524 | - $njour = intval($jour); |
|
| 525 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 526 | - $jour = $jourth; |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - $mois = intval($mois); |
|
| 531 | - if ($mois > 0 and $mois < 13) { |
|
| 532 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 533 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 534 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 535 | - if ($jour) { |
|
| 536 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 537 | - } else { |
|
| 538 | - $jourmois = $nommois; |
|
| 539 | - } |
|
| 540 | - } else { |
|
| 541 | - $nommois = ''; |
|
| 542 | - $jourmois = ''; |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - if ($annee < 0) { |
|
| 546 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 547 | - $avjc = true; |
|
| 548 | - } else { |
|
| 549 | - $avjc = false; |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - switch ($vue) { |
|
| 553 | - case 'saison': |
|
| 554 | - case 'saison_annee': |
|
| 555 | - $saison = ''; |
|
| 556 | - if ($mois > 0) { |
|
| 557 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 558 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 559 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 560 | - } |
|
| 561 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 562 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 563 | - } |
|
| 564 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 565 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 566 | - } |
|
| 567 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 568 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - if ($vue == 'saison') { |
|
| 572 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 573 | - } else { |
|
| 574 | - return $saison ? trim(_T( |
|
| 575 | - 'date_fmt_saison_annee', |
|
| 576 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 577 | - )) : ''; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - case 'court': |
|
| 581 | - if ($avjc) { |
|
| 582 | - return $annee; |
|
| 583 | - } |
|
| 584 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 585 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 586 | - return $annee; |
|
| 587 | - } |
|
| 588 | - if ($annee != $a) { |
|
| 589 | - return _T( |
|
| 590 | - 'date_fmt_mois_annee', |
|
| 591 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 592 | - ); |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - return _T( |
|
| 596 | - 'date_fmt_jour_mois', |
|
| 597 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 598 | - ); |
|
| 599 | - |
|
| 600 | - case 'jourcourt': |
|
| 601 | - if ($avjc) { |
|
| 602 | - return $annee; |
|
| 603 | - } |
|
| 604 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 605 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 606 | - return $annee; |
|
| 607 | - } |
|
| 608 | - if ($annee != $a) { |
|
| 609 | - return _T( |
|
| 610 | - 'date_fmt_jour_mois_annee', |
|
| 611 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 612 | - ); |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - return _T( |
|
| 616 | - 'date_fmt_jour_mois', |
|
| 617 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 618 | - ); |
|
| 619 | - |
|
| 620 | - case 'entier': |
|
| 621 | - if ($avjc) { |
|
| 622 | - return $annee; |
|
| 623 | - } |
|
| 624 | - if ($jour) { |
|
| 625 | - return _T( |
|
| 626 | - 'date_fmt_jour_mois_annee', |
|
| 627 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 628 | - ); |
|
| 629 | - } elseif ($mois) { |
|
| 630 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 631 | - } else { |
|
| 632 | - return $annee; |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - case 'nom_mois': |
|
| 636 | - return $nommois; |
|
| 637 | - |
|
| 638 | - case 'mois': |
|
| 639 | - return sprintf('%02s', $mois); |
|
| 640 | - |
|
| 641 | - case 'jour': |
|
| 642 | - return $jour; |
|
| 643 | - |
|
| 644 | - case 'journum': |
|
| 645 | - return $journum; |
|
| 646 | - |
|
| 647 | - case 'nom_jour': |
|
| 648 | - if (!$mois or !$njour) { |
|
| 649 | - return ''; |
|
| 650 | - } |
|
| 651 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 652 | - $nom = 1 + (int) date('w', $nom); |
|
| 653 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 654 | - |
|
| 655 | - return _T('date_jour_' . $nom . $param); |
|
| 656 | - |
|
| 657 | - case 'mois_annee': |
|
| 658 | - if ($avjc) { |
|
| 659 | - return $annee; |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 663 | - |
|
| 664 | - case 'annee': |
|
| 665 | - return $annee; |
|
| 666 | - |
|
| 667 | - // Cas d'une vue non definie : retomber sur le format |
|
| 668 | - // de date propose par http://www.php.net/date |
|
| 669 | - default: |
|
| 670 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 671 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 672 | - $time = strtotime($numdate); |
|
| 673 | - } |
|
| 674 | - return date($vue, $time); |
|
| 675 | - } |
|
| 508 | + if (is_string($options)) { |
|
| 509 | + $options = ['param' => $options]; |
|
| 510 | + } |
|
| 511 | + $date_array = recup_date($numdate, false); |
|
| 512 | + if (!$date_array) { |
|
| 513 | + return ''; |
|
| 514 | + } |
|
| 515 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 516 | + |
|
| 517 | + // 1er, 21st, etc. |
|
| 518 | + $journum = $jour; |
|
| 519 | + |
|
| 520 | + if ($jour == 0) { |
|
| 521 | + $jour = ''; |
|
| 522 | + $njour = 0; |
|
| 523 | + } else { |
|
| 524 | + $njour = intval($jour); |
|
| 525 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 526 | + $jour = $jourth; |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + $mois = intval($mois); |
|
| 531 | + if ($mois > 0 and $mois < 13) { |
|
| 532 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 533 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 534 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 535 | + if ($jour) { |
|
| 536 | + $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 537 | + } else { |
|
| 538 | + $jourmois = $nommois; |
|
| 539 | + } |
|
| 540 | + } else { |
|
| 541 | + $nommois = ''; |
|
| 542 | + $jourmois = ''; |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + if ($annee < 0) { |
|
| 546 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 547 | + $avjc = true; |
|
| 548 | + } else { |
|
| 549 | + $avjc = false; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + switch ($vue) { |
|
| 553 | + case 'saison': |
|
| 554 | + case 'saison_annee': |
|
| 555 | + $saison = ''; |
|
| 556 | + if ($mois > 0) { |
|
| 557 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 558 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 559 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 560 | + } |
|
| 561 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 562 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 563 | + } |
|
| 564 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 565 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 566 | + } |
|
| 567 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 568 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + if ($vue == 'saison') { |
|
| 572 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 573 | + } else { |
|
| 574 | + return $saison ? trim(_T( |
|
| 575 | + 'date_fmt_saison_annee', |
|
| 576 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 577 | + )) : ''; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + case 'court': |
|
| 581 | + if ($avjc) { |
|
| 582 | + return $annee; |
|
| 583 | + } |
|
| 584 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 585 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 586 | + return $annee; |
|
| 587 | + } |
|
| 588 | + if ($annee != $a) { |
|
| 589 | + return _T( |
|
| 590 | + 'date_fmt_mois_annee', |
|
| 591 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 592 | + ); |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + return _T( |
|
| 596 | + 'date_fmt_jour_mois', |
|
| 597 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 598 | + ); |
|
| 599 | + |
|
| 600 | + case 'jourcourt': |
|
| 601 | + if ($avjc) { |
|
| 602 | + return $annee; |
|
| 603 | + } |
|
| 604 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 605 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 606 | + return $annee; |
|
| 607 | + } |
|
| 608 | + if ($annee != $a) { |
|
| 609 | + return _T( |
|
| 610 | + 'date_fmt_jour_mois_annee', |
|
| 611 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 612 | + ); |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + return _T( |
|
| 616 | + 'date_fmt_jour_mois', |
|
| 617 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 618 | + ); |
|
| 619 | + |
|
| 620 | + case 'entier': |
|
| 621 | + if ($avjc) { |
|
| 622 | + return $annee; |
|
| 623 | + } |
|
| 624 | + if ($jour) { |
|
| 625 | + return _T( |
|
| 626 | + 'date_fmt_jour_mois_annee', |
|
| 627 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 628 | + ); |
|
| 629 | + } elseif ($mois) { |
|
| 630 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 631 | + } else { |
|
| 632 | + return $annee; |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + case 'nom_mois': |
|
| 636 | + return $nommois; |
|
| 637 | + |
|
| 638 | + case 'mois': |
|
| 639 | + return sprintf('%02s', $mois); |
|
| 640 | + |
|
| 641 | + case 'jour': |
|
| 642 | + return $jour; |
|
| 643 | + |
|
| 644 | + case 'journum': |
|
| 645 | + return $journum; |
|
| 646 | + |
|
| 647 | + case 'nom_jour': |
|
| 648 | + if (!$mois or !$njour) { |
|
| 649 | + return ''; |
|
| 650 | + } |
|
| 651 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 652 | + $nom = 1 + (int) date('w', $nom); |
|
| 653 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 654 | + |
|
| 655 | + return _T('date_jour_' . $nom . $param); |
|
| 656 | + |
|
| 657 | + case 'mois_annee': |
|
| 658 | + if ($avjc) { |
|
| 659 | + return $annee; |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 663 | + |
|
| 664 | + case 'annee': |
|
| 665 | + return $annee; |
|
| 666 | + |
|
| 667 | + // Cas d'une vue non definie : retomber sur le format |
|
| 668 | + // de date propose par http://www.php.net/date |
|
| 669 | + default: |
|
| 670 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 671 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 672 | + $time = strtotime($numdate); |
|
| 673 | + } |
|
| 674 | + return date($vue, $time); |
|
| 675 | + } |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | |
@@ -699,11 +699,11 @@ discard block |
||
| 699 | 699 | * Nom du jour |
| 700 | 700 | **/ |
| 701 | 701 | function nom_jour($numdate, $forme = ''): string { |
| 702 | - if (!($forme === 'abbr' or $forme === 'initiale')) { |
|
| 703 | - $forme = ''; |
|
| 704 | - } |
|
| 702 | + if (!($forme === 'abbr' or $forme === 'initiale')) { |
|
| 703 | + $forme = ''; |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 706 | + return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | * Numéro du jour |
| 726 | 726 | **/ |
| 727 | 727 | function jour($numdate): string { |
| 728 | - return affdate_base($numdate, 'jour'); |
|
| 728 | + return affdate_base($numdate, 'jour'); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | * Numéro du jour |
| 744 | 744 | **/ |
| 745 | 745 | function journum($numdate): string { |
| 746 | - return affdate_base($numdate, 'journum'); |
|
| 746 | + return affdate_base($numdate, 'journum'); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | * Numéro du mois (sur 2 chiffres) |
| 762 | 762 | **/ |
| 763 | 763 | function mois($numdate): string { |
| 764 | - return affdate_base($numdate, 'mois'); |
|
| 764 | + return affdate_base($numdate, 'mois'); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -785,11 +785,11 @@ discard block |
||
| 785 | 785 | * Nom du mois |
| 786 | 786 | **/ |
| 787 | 787 | function nom_mois($numdate, $forme = ''): string { |
| 788 | - if (!($forme === 'abbr')) { |
|
| 789 | - $forme = ''; |
|
| 790 | - } |
|
| 788 | + if (!($forme === 'abbr')) { |
|
| 789 | + $forme = ''; |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | - return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 792 | + return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | * Année (sur 4 chiffres) |
| 808 | 808 | **/ |
| 809 | 809 | function annee($numdate): string { |
| 810 | - return affdate_base($numdate, 'annee'); |
|
| 810 | + return affdate_base($numdate, 'annee'); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | |
@@ -837,11 +837,11 @@ discard block |
||
| 837 | 837 | * La date formatée |
| 838 | 838 | **/ |
| 839 | 839 | function saison($numdate, $hemisphere = 'nord'): string { |
| 840 | - if ($hemisphere !== 'sud') { |
|
| 841 | - $hemisphere = 'nord'; |
|
| 842 | - } |
|
| 840 | + if ($hemisphere !== 'sud') { |
|
| 841 | + $hemisphere = 'nord'; |
|
| 842 | + } |
|
| 843 | 843 | |
| 844 | - return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 844 | + return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | |
@@ -870,11 +870,11 @@ discard block |
||
| 870 | 870 | * La date formatée |
| 871 | 871 | **/ |
| 872 | 872 | function saison_annee($numdate, $hemisphere = 'nord'): string { |
| 873 | - if ($hemisphere !== 'sud') { |
|
| 874 | - $hemisphere = 'nord'; |
|
| 875 | - } |
|
| 873 | + if ($hemisphere !== 'sud') { |
|
| 874 | + $hemisphere = 'nord'; |
|
| 875 | + } |
|
| 876 | 876 | |
| 877 | - return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 877 | + return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | /** |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | * La date formatée |
| 903 | 903 | **/ |
| 904 | 904 | function affdate($numdate, $format = 'entier'): string { |
| 905 | - return affdate_base($numdate, $format); |
|
| 905 | + return affdate_base($numdate, $format); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | * La date formatée |
| 930 | 930 | **/ |
| 931 | 931 | function affdate_court($numdate, $annee_courante = null): string { |
| 932 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 932 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | * La date formatée |
| 957 | 957 | **/ |
| 958 | 958 | function affdate_jourcourt($numdate, $annee_courante = null): string { |
| 959 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 959 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | /** |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * La date formatée |
| 975 | 975 | **/ |
| 976 | 976 | function affdate_mois_annee($numdate): string { |
| 977 | - return affdate_base($numdate, 'mois_annee'); |
|
| 977 | + return affdate_base($numdate, 'mois_annee'); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -992,16 +992,16 @@ discard block |
||
| 992 | 992 | * La date formatée, sinon '' |
| 993 | 993 | **/ |
| 994 | 994 | function affdate_heure($numdate): string { |
| 995 | - $date_array = recup_date($numdate); |
|
| 996 | - if (!$date_array) { |
|
| 997 | - return ''; |
|
| 998 | - } |
|
| 999 | - [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 1000 | - |
|
| 1001 | - return _T('date_fmt_jour_heure', [ |
|
| 1002 | - 'jour' => affdate($numdate), |
|
| 1003 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1004 | - ]); |
|
| 995 | + $date_array = recup_date($numdate); |
|
| 996 | + if (!$date_array) { |
|
| 997 | + return ''; |
|
| 998 | + } |
|
| 999 | + [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 1000 | + |
|
| 1001 | + return _T('date_fmt_jour_heure', [ |
|
| 1002 | + 'jour' => affdate($numdate), |
|
| 1003 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1004 | + ]); |
|
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | 1007 | /** |
@@ -1033,117 +1033,117 @@ discard block |
||
| 1033 | 1033 | * Texte de la date |
| 1034 | 1034 | */ |
| 1035 | 1035 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = ''): string { |
| 1036 | - $abbr = $jour = ''; |
|
| 1037 | - $affdate = 'affdate_jourcourt'; |
|
| 1038 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1039 | - $abbr = 'abbr'; |
|
| 1040 | - } |
|
| 1041 | - if (strpos($forme, 'annee') !== false) { |
|
| 1042 | - $affdate = 'affdate'; |
|
| 1043 | - } |
|
| 1044 | - if (strpos($forme, 'jour') !== false) { |
|
| 1045 | - $jour = 'jour'; |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1049 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1050 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1051 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1052 | - $dtabbr = '</abbr>'; |
|
| 1053 | - } |
|
| 1054 | - |
|
| 1055 | - $date_debut = strtotime($date_debut); |
|
| 1056 | - $date_fin = strtotime($date_fin); |
|
| 1057 | - $d = date('Y-m-d', $date_debut); |
|
| 1058 | - $f = date('Y-m-d', $date_fin); |
|
| 1059 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1060 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1061 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1062 | - |
|
| 1063 | - if ($d == $f) { // meme jour |
|
| 1064 | - $nomjour = nom_jour($d, $abbr); |
|
| 1065 | - $s = $affdate($d); |
|
| 1066 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1067 | - if ($h) { |
|
| 1068 | - if ($hd == $hf) { |
|
| 1069 | - // Lundi 20 fevrier a 18h25 |
|
| 1070 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1071 | - $s = "$dtstart$s$dtabbr"; |
|
| 1072 | - } else { |
|
| 1073 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1074 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1075 | - $s = _T( |
|
| 1076 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1077 | - [ |
|
| 1078 | - 'jour' => spip_ucfirst($s), |
|
| 1079 | - 'heure_debut' => $hd, |
|
| 1080 | - 'heure_fin' => $hf, |
|
| 1081 | - 'dtstart' => $dtstart, |
|
| 1082 | - 'dtend' => $dtend, |
|
| 1083 | - 'dtabbr' => $dtabbr |
|
| 1084 | - ], |
|
| 1085 | - [ |
|
| 1086 | - 'sanitize' => false |
|
| 1087 | - ] |
|
| 1088 | - ); |
|
| 1089 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1090 | - else { |
|
| 1091 | - $s = spip_ucfirst(_T( |
|
| 1092 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1093 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1094 | - )); |
|
| 1095 | - } |
|
| 1096 | - } |
|
| 1097 | - } else { |
|
| 1098 | - if ($dtabbr && $dtstart) { |
|
| 1099 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1100 | - } else { |
|
| 1101 | - $s = spip_ucfirst($s); |
|
| 1102 | - } |
|
| 1103 | - } |
|
| 1104 | - } else { |
|
| 1105 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1106 | - if (!$h) { |
|
| 1107 | - $date_debut = jour($d); |
|
| 1108 | - } else { |
|
| 1109 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1110 | - } |
|
| 1111 | - $date_fin = $affdate($f); |
|
| 1112 | - if ($jour) { |
|
| 1113 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1114 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1115 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1116 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1117 | - } |
|
| 1118 | - if ($h) { |
|
| 1119 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1120 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1121 | - } |
|
| 1122 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1123 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1124 | - |
|
| 1125 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1126 | - } else { |
|
| 1127 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1128 | - $date_fin = $affdate($f); |
|
| 1129 | - if ($jour) { |
|
| 1130 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1131 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1132 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1133 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1134 | - } |
|
| 1135 | - if ($h) { |
|
| 1136 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1137 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1141 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1142 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1143 | - } |
|
| 1144 | - } |
|
| 1145 | - |
|
| 1146 | - return $s; |
|
| 1036 | + $abbr = $jour = ''; |
|
| 1037 | + $affdate = 'affdate_jourcourt'; |
|
| 1038 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1039 | + $abbr = 'abbr'; |
|
| 1040 | + } |
|
| 1041 | + if (strpos($forme, 'annee') !== false) { |
|
| 1042 | + $affdate = 'affdate'; |
|
| 1043 | + } |
|
| 1044 | + if (strpos($forme, 'jour') !== false) { |
|
| 1045 | + $jour = 'jour'; |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1049 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1050 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1051 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1052 | + $dtabbr = '</abbr>'; |
|
| 1053 | + } |
|
| 1054 | + |
|
| 1055 | + $date_debut = strtotime($date_debut); |
|
| 1056 | + $date_fin = strtotime($date_fin); |
|
| 1057 | + $d = date('Y-m-d', $date_debut); |
|
| 1058 | + $f = date('Y-m-d', $date_fin); |
|
| 1059 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1060 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1061 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1062 | + |
|
| 1063 | + if ($d == $f) { // meme jour |
|
| 1064 | + $nomjour = nom_jour($d, $abbr); |
|
| 1065 | + $s = $affdate($d); |
|
| 1066 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1067 | + if ($h) { |
|
| 1068 | + if ($hd == $hf) { |
|
| 1069 | + // Lundi 20 fevrier a 18h25 |
|
| 1070 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1071 | + $s = "$dtstart$s$dtabbr"; |
|
| 1072 | + } else { |
|
| 1073 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1074 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1075 | + $s = _T( |
|
| 1076 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1077 | + [ |
|
| 1078 | + 'jour' => spip_ucfirst($s), |
|
| 1079 | + 'heure_debut' => $hd, |
|
| 1080 | + 'heure_fin' => $hf, |
|
| 1081 | + 'dtstart' => $dtstart, |
|
| 1082 | + 'dtend' => $dtend, |
|
| 1083 | + 'dtabbr' => $dtabbr |
|
| 1084 | + ], |
|
| 1085 | + [ |
|
| 1086 | + 'sanitize' => false |
|
| 1087 | + ] |
|
| 1088 | + ); |
|
| 1089 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1090 | + else { |
|
| 1091 | + $s = spip_ucfirst(_T( |
|
| 1092 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1093 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1094 | + )); |
|
| 1095 | + } |
|
| 1096 | + } |
|
| 1097 | + } else { |
|
| 1098 | + if ($dtabbr && $dtstart) { |
|
| 1099 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1100 | + } else { |
|
| 1101 | + $s = spip_ucfirst($s); |
|
| 1102 | + } |
|
| 1103 | + } |
|
| 1104 | + } else { |
|
| 1105 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1106 | + if (!$h) { |
|
| 1107 | + $date_debut = jour($d); |
|
| 1108 | + } else { |
|
| 1109 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1110 | + } |
|
| 1111 | + $date_fin = $affdate($f); |
|
| 1112 | + if ($jour) { |
|
| 1113 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1114 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1115 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1116 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1117 | + } |
|
| 1118 | + if ($h) { |
|
| 1119 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1120 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1121 | + } |
|
| 1122 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1123 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1124 | + |
|
| 1125 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1126 | + } else { |
|
| 1127 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1128 | + $date_fin = $affdate($f); |
|
| 1129 | + if ($jour) { |
|
| 1130 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1131 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1132 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1133 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1134 | + } |
|
| 1135 | + if ($h) { |
|
| 1136 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1137 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1141 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1142 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1143 | + } |
|
| 1144 | + } |
|
| 1145 | + |
|
| 1146 | + return $s; |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /** |
@@ -1164,10 +1164,10 @@ discard block |
||
| 1164 | 1164 | * Date au format ical |
| 1165 | 1165 | **/ |
| 1166 | 1166 | function date_ical($date, $addminutes = 0): string { |
| 1167 | - [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1168 | - [$annee, $mois, $jour] = recup_date($date); |
|
| 1167 | + [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1168 | + [$annee, $mois, $jour] = recup_date($date); |
|
| 1169 | 1169 | |
| 1170 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1170 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | |
@@ -1191,11 +1191,11 @@ discard block |
||
| 1191 | 1191 | * La date formatée |
| 1192 | 1192 | **/ |
| 1193 | 1193 | function date_iso($date_heure): string { |
| 1194 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1195 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1196 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1194 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1195 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1196 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1197 | 1197 | |
| 1198 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1198 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | /** |
@@ -1218,11 +1218,11 @@ discard block |
||
| 1218 | 1218 | * La date formatée |
| 1219 | 1219 | **/ |
| 1220 | 1220 | function date_822($date_heure): string { |
| 1221 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1222 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1223 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1221 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1222 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1223 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1224 | 1224 | |
| 1225 | - return date('r', $time); |
|
| 1225 | + return date('r', $time); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | /** |
@@ -1238,11 +1238,11 @@ discard block |
||
| 1238 | 1238 | * Date au format `Ymd` |
| 1239 | 1239 | **/ |
| 1240 | 1240 | function date_anneemoisjour($d): string { |
| 1241 | - if (!$d) { |
|
| 1242 | - $d = date('Y-m-d'); |
|
| 1243 | - } |
|
| 1241 | + if (!$d) { |
|
| 1242 | + $d = date('Y-m-d'); |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1245 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |
@@ -1258,11 +1258,11 @@ discard block |
||
| 1258 | 1258 | * Date au format `Ym` |
| 1259 | 1259 | **/ |
| 1260 | 1260 | function date_anneemois($d): string { |
| 1261 | - if (!$d) { |
|
| 1262 | - $d = date('Y-m-d'); |
|
| 1263 | - } |
|
| 1261 | + if (!$d) { |
|
| 1262 | + $d = date('Y-m-d'); |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1265 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | /** |
@@ -1278,13 +1278,13 @@ discard block |
||
| 1278 | 1278 | * Date au lundi de la même semaine au format `Ymd` |
| 1279 | 1279 | **/ |
| 1280 | 1280 | function date_debut_semaine($annee, $mois, $jour): string { |
| 1281 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1282 | - if ($w_day == 0) { |
|
| 1283 | - $w_day = 7; |
|
| 1284 | - } // Gaffe: le dimanche est zero |
|
| 1285 | - $debut = $jour - $w_day + 1; |
|
| 1281 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1282 | + if ($w_day == 0) { |
|
| 1283 | + $w_day = 7; |
|
| 1284 | + } // Gaffe: le dimanche est zero |
|
| 1285 | + $debut = $jour - $w_day + 1; |
|
| 1286 | 1286 | |
| 1287 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1287 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | 1290 | /** |
@@ -1300,11 +1300,11 @@ discard block |
||
| 1300 | 1300 | * Date au dimanche de la même semaine au format `Ymd` |
| 1301 | 1301 | **/ |
| 1302 | 1302 | function date_fin_semaine($annee, $mois, $jour): string { |
| 1303 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1304 | - if ($w_day == 0) { |
|
| 1305 | - $w_day = 7; |
|
| 1306 | - } // Gaffe: le dimanche est zero |
|
| 1307 | - $debut = $jour - $w_day + 1; |
|
| 1303 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1304 | + if ($w_day == 0) { |
|
| 1305 | + $w_day = 7; |
|
| 1306 | + } // Gaffe: le dimanche est zero |
|
| 1307 | + $debut = $jour - $w_day + 1; |
|
| 1308 | 1308 | |
| 1309 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1309 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1310 | 1310 | } |
@@ -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 | include_spip('inc/actions'); |
@@ -46,33 +46,33 @@ discard block |
||
| 46 | 46 | * Environnement du formulaire |
| 47 | 47 | **/ |
| 48 | 48 | function formulaires_editer_article_charger_dist( |
| 49 | - $id_article = 'new', |
|
| 50 | - $id_rubrique = 0, |
|
| 51 | - $retour = '', |
|
| 52 | - $lier_trad = 0, |
|
| 53 | - $config_fonc = 'articles_edit_config', |
|
| 54 | - $row = [], |
|
| 55 | - $hidden = '' |
|
| 49 | + $id_article = 'new', |
|
| 50 | + $id_rubrique = 0, |
|
| 51 | + $retour = '', |
|
| 52 | + $lier_trad = 0, |
|
| 53 | + $config_fonc = 'articles_edit_config', |
|
| 54 | + $row = [], |
|
| 55 | + $hidden = '' |
|
| 56 | 56 | ) { |
| 57 | - $valeurs = formulaires_editer_objet_charger( |
|
| 58 | - 'article', |
|
| 59 | - $id_article, |
|
| 60 | - $id_rubrique, |
|
| 61 | - $lier_trad, |
|
| 62 | - $retour, |
|
| 63 | - $config_fonc, |
|
| 64 | - $row, |
|
| 65 | - $hidden |
|
| 66 | - ); |
|
| 57 | + $valeurs = formulaires_editer_objet_charger( |
|
| 58 | + 'article', |
|
| 59 | + $id_article, |
|
| 60 | + $id_rubrique, |
|
| 61 | + $lier_trad, |
|
| 62 | + $retour, |
|
| 63 | + $config_fonc, |
|
| 64 | + $row, |
|
| 65 | + $hidden |
|
| 66 | + ); |
|
| 67 | 67 | |
| 68 | - if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) { |
|
| 69 | - $valeurs['editable'] = ''; |
|
| 70 | - } |
|
| 68 | + if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) { |
|
| 69 | + $valeurs['editable'] = ''; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - // il faut enlever l'id_rubrique car la saisie se fait sur id_parent |
|
| 73 | - // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale |
|
| 74 | - // et sera perdue si elle est supposee saisie |
|
| 75 | - return $valeurs; |
|
| 72 | + // il faut enlever l'id_rubrique car la saisie se fait sur id_parent |
|
| 73 | + // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale |
|
| 74 | + // et sera perdue si elle est supposee saisie |
|
| 75 | + return $valeurs; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -97,15 +97,15 @@ discard block |
||
| 97 | 97 | * Hash du formulaire |
| 98 | 98 | */ |
| 99 | 99 | function formulaires_editer_article_identifier_dist( |
| 100 | - $id_article = 'new', |
|
| 101 | - $id_rubrique = 0, |
|
| 102 | - $retour = '', |
|
| 103 | - $lier_trad = 0, |
|
| 104 | - $config_fonc = 'articles_edit_config', |
|
| 105 | - $row = [], |
|
| 106 | - $hidden = '' |
|
| 100 | + $id_article = 'new', |
|
| 101 | + $id_rubrique = 0, |
|
| 102 | + $retour = '', |
|
| 103 | + $lier_trad = 0, |
|
| 104 | + $config_fonc = 'articles_edit_config', |
|
| 105 | + $row = [], |
|
| 106 | + $hidden = '' |
|
| 107 | 107 | ) { |
| 108 | - return serialize([intval($id_article), $lier_trad]); |
|
| 108 | + return serialize([intval($id_article), $lier_trad]); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | function articles_edit_config(array $row): array { |
| 120 | 120 | |
| 121 | - $config = []; |
|
| 122 | - $config['lignes'] = 8; |
|
| 123 | - $config['langue'] = $GLOBALS['spip_lang']; |
|
| 124 | - $config['restreint'] = ($row['statut'] === 'publie'); |
|
| 121 | + $config = []; |
|
| 122 | + $config['lignes'] = 8; |
|
| 123 | + $config['langue'] = $GLOBALS['spip_lang']; |
|
| 124 | + $config['restreint'] = ($row['statut'] === 'publie'); |
|
| 125 | 125 | |
| 126 | - return $config; |
|
| 126 | + return $config; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -149,43 +149,43 @@ discard block |
||
| 149 | 149 | * Erreurs du formulaire |
| 150 | 150 | **/ |
| 151 | 151 | function formulaires_editer_article_verifier_dist( |
| 152 | - $id_article = 'new', |
|
| 153 | - $id_rubrique = 0, |
|
| 154 | - $retour = '', |
|
| 155 | - $lier_trad = 0, |
|
| 156 | - $config_fonc = 'articles_edit_config', |
|
| 157 | - $row = [], |
|
| 158 | - $hidden = '' |
|
| 152 | + $id_article = 'new', |
|
| 153 | + $id_rubrique = 0, |
|
| 154 | + $retour = '', |
|
| 155 | + $lier_trad = 0, |
|
| 156 | + $config_fonc = 'articles_edit_config', |
|
| 157 | + $row = [], |
|
| 158 | + $hidden = '' |
|
| 159 | 159 | ) { |
| 160 | - // auto-renseigner le titre si il n'existe pas |
|
| 161 | - titre_automatique('titre', ['descriptif', 'chapo', 'texte']); |
|
| 162 | - if (!_request('id_parent') and !intval($id_article)) { |
|
| 163 | - $valeurs = formulaires_editer_objet_charger( |
|
| 164 | - 'article', |
|
| 165 | - $id_article, |
|
| 166 | - $id_rubrique, |
|
| 167 | - $lier_trad, |
|
| 168 | - $retour, |
|
| 169 | - $config_fonc, |
|
| 170 | - $row, |
|
| 171 | - $hidden |
|
| 172 | - ); |
|
| 173 | - set_request('id_parent', $valeurs['id_parent']); |
|
| 174 | - } |
|
| 175 | - // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide |
|
| 176 | - $erreurs = formulaires_editer_objet_verifier('article', $id_article, ['id_parent']); |
|
| 177 | - // si on utilise le formulaire dans le public |
|
| 178 | - if (!function_exists('autoriser')) { |
|
| 179 | - include_spip('inc/autoriser'); |
|
| 180 | - } |
|
| 181 | - if ( |
|
| 182 | - !isset($erreurs['id_parent']) |
|
| 183 | - and !autoriser('creerarticledans', 'rubrique', _request('id_parent')) |
|
| 184 | - ) { |
|
| 185 | - $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise'); |
|
| 186 | - } |
|
| 160 | + // auto-renseigner le titre si il n'existe pas |
|
| 161 | + titre_automatique('titre', ['descriptif', 'chapo', 'texte']); |
|
| 162 | + if (!_request('id_parent') and !intval($id_article)) { |
|
| 163 | + $valeurs = formulaires_editer_objet_charger( |
|
| 164 | + 'article', |
|
| 165 | + $id_article, |
|
| 166 | + $id_rubrique, |
|
| 167 | + $lier_trad, |
|
| 168 | + $retour, |
|
| 169 | + $config_fonc, |
|
| 170 | + $row, |
|
| 171 | + $hidden |
|
| 172 | + ); |
|
| 173 | + set_request('id_parent', $valeurs['id_parent']); |
|
| 174 | + } |
|
| 175 | + // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide |
|
| 176 | + $erreurs = formulaires_editer_objet_verifier('article', $id_article, ['id_parent']); |
|
| 177 | + // si on utilise le formulaire dans le public |
|
| 178 | + if (!function_exists('autoriser')) { |
|
| 179 | + include_spip('inc/autoriser'); |
|
| 180 | + } |
|
| 181 | + if ( |
|
| 182 | + !isset($erreurs['id_parent']) |
|
| 183 | + and !autoriser('creerarticledans', 'rubrique', _request('id_parent')) |
|
| 184 | + ) { |
|
| 185 | + $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise'); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - return $erreurs; |
|
| 188 | + return $erreurs; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -211,29 +211,29 @@ discard block |
||
| 211 | 211 | * Retours des traitements |
| 212 | 212 | **/ |
| 213 | 213 | function formulaires_editer_article_traiter_dist( |
| 214 | - $id_article = 'new', |
|
| 215 | - $id_rubrique = 0, |
|
| 216 | - $retour = '', |
|
| 217 | - $lier_trad = 0, |
|
| 218 | - $config_fonc = 'articles_edit_config', |
|
| 219 | - $row = [], |
|
| 220 | - $hidden = '' |
|
| 214 | + $id_article = 'new', |
|
| 215 | + $id_rubrique = 0, |
|
| 216 | + $retour = '', |
|
| 217 | + $lier_trad = 0, |
|
| 218 | + $config_fonc = 'articles_edit_config', |
|
| 219 | + $row = [], |
|
| 220 | + $hidden = '' |
|
| 221 | 221 | ) { |
| 222 | - // ici on ignore changer_lang qui est poste en cas de trad, |
|
| 223 | - // car l'heuristique du choix de la langue est pris en charge par article_inserer |
|
| 224 | - // en fonction de la config du site et de la rubrique choisie |
|
| 225 | - if (!$lier_trad) { |
|
| 226 | - set_request('changer_lang'); |
|
| 227 | - } |
|
| 222 | + // ici on ignore changer_lang qui est poste en cas de trad, |
|
| 223 | + // car l'heuristique du choix de la langue est pris en charge par article_inserer |
|
| 224 | + // en fonction de la config du site et de la rubrique choisie |
|
| 225 | + if (!$lier_trad) { |
|
| 226 | + set_request('changer_lang'); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return formulaires_editer_objet_traiter( |
|
| 230 | - 'article', |
|
| 231 | - $id_article, |
|
| 232 | - $id_rubrique, |
|
| 233 | - $lier_trad, |
|
| 234 | - $retour, |
|
| 235 | - $config_fonc, |
|
| 236 | - $row, |
|
| 237 | - $hidden |
|
| 238 | - ); |
|
| 229 | + return formulaires_editer_objet_traiter( |
|
| 230 | + 'article', |
|
| 231 | + $id_article, |
|
| 232 | + $id_rubrique, |
|
| 233 | + $lier_trad, |
|
| 234 | + $retour, |
|
| 235 | + $config_fonc, |
|
| 236 | + $row, |
|
| 237 | + $hidden |
|
| 238 | + ); |
|
| 239 | 239 | } |