@@ -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,22 +98,22 @@ discard block |
||
| 98 | 98 | * - Une chaine vide |
| 99 | 99 | **/ |
| 100 | 100 | function vider_date($letexte, $verif_format_date = false): string { |
| 101 | - if ( |
|
| 102 | - !$verif_format_date |
|
| 103 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 105 | - ) { |
|
| 106 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 110 | - return ''; |
|
| 111 | - } |
|
| 112 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 113 | - return ''; |
|
| 114 | - } // eviter le bug GMT-1 |
|
| 115 | - } |
|
| 116 | - return $letexte; |
|
| 101 | + if ( |
|
| 102 | + !$verif_format_date |
|
| 103 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 104 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 105 | + ) { |
|
| 106 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 110 | + return ''; |
|
| 111 | + } |
|
| 112 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 113 | + return ''; |
|
| 114 | + } // eviter le bug GMT-1 |
|
| 115 | + } |
|
| 116 | + return $letexte; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | **/ |
| 130 | 130 | function recup_heure($date): array { |
| 131 | 131 | |
| 132 | - static $d = [0, 0, 0]; |
|
| 133 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 134 | - return $d; |
|
| 135 | - } |
|
| 132 | + static $d = [0, 0, 0]; |
|
| 133 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 134 | + return $d; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - array_shift($r); |
|
| 137 | + array_shift($r); |
|
| 138 | 138 | |
| 139 | - return $r; |
|
| 139 | + return $r; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * @return string heures, sinon 0 |
| 151 | 151 | **/ |
| 152 | 152 | function heures($numdate): string { |
| 153 | - $heures = null; |
|
| 154 | - $date_array = recup_heure($numdate); |
|
| 155 | - if ($date_array) { |
|
| 156 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 157 | - } |
|
| 153 | + $heures = null; |
|
| 154 | + $date_array = recup_heure($numdate); |
|
| 155 | + if ($date_array) { |
|
| 156 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - return $heures; |
|
| 159 | + return $heures; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | * @return string minutes, sinon 0 |
| 171 | 171 | **/ |
| 172 | 172 | function minutes($numdate): string { |
| 173 | - $minutes = null; |
|
| 174 | - $date_array = recup_heure($numdate); |
|
| 175 | - if ($date_array) { |
|
| 176 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 177 | - } |
|
| 173 | + $minutes = null; |
|
| 174 | + $date_array = recup_heure($numdate); |
|
| 175 | + if ($date_array) { |
|
| 176 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - return $minutes; |
|
| 179 | + return $minutes; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | * @return string secondes, sinon 0 |
| 191 | 191 | **/ |
| 192 | 192 | function secondes($numdate): string { |
| 193 | - $secondes = null; |
|
| 194 | - $date_array = recup_heure($numdate); |
|
| 195 | - if ($date_array) { |
|
| 196 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 197 | - } |
|
| 193 | + $secondes = null; |
|
| 194 | + $date_array = recup_heure($numdate); |
|
| 195 | + if ($date_array) { |
|
| 196 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - return $secondes; |
|
| 199 | + return $secondes; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | * @return string L'heure formatée dans la langue en cours. |
| 216 | 216 | **/ |
| 217 | 217 | function heures_minutes($numdate, $forme = ''): string { |
| 218 | - if ($forme !== 'abbr') { |
|
| 219 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 220 | - } else { |
|
| 221 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 222 | - } |
|
| 218 | + if ($forme !== 'abbr') { |
|
| 219 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 220 | + } else { |
|
| 221 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 222 | + } |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -244,57 +244,57 @@ discard block |
||
| 244 | 244 | * @return array [année, mois, jour, heures, minutes, secondes] ou [] |
| 245 | 245 | **/ |
| 246 | 246 | function recup_date($numdate, $forcer_jour = true): array { |
| 247 | - if (!$numdate) { |
|
| 248 | - return []; |
|
| 249 | - } |
|
| 250 | - $heures = $minutes = $secondes = 0; |
|
| 251 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 252 | - $jour = $regs[1]; |
|
| 253 | - $mois = $regs[2]; |
|
| 254 | - $annee = $regs[3]; |
|
| 255 | - if ($annee < 90) { |
|
| 256 | - $annee = 2000 + $annee; |
|
| 257 | - } elseif ($annee < 100) { |
|
| 258 | - $annee = 1900 + $annee; |
|
| 259 | - } |
|
| 260 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 261 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 262 | - $annee = $regs[1]; |
|
| 263 | - $mois = $regs[2]; |
|
| 264 | - $jour = $regs[3]; |
|
| 265 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 266 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 267 | - $annee = $regs[1]; |
|
| 268 | - $mois = $regs[2]; |
|
| 269 | - $jour = ''; |
|
| 270 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 271 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 272 | - $annee = $regs[1]; |
|
| 273 | - $mois = $regs[2]; |
|
| 274 | - $jour = $regs[3]; |
|
| 275 | - $heures = $regs[4]; |
|
| 276 | - $minutes = $regs[5]; |
|
| 277 | - $secondes = $regs[6]; |
|
| 278 | - } else { |
|
| 279 | - $annee = $mois = $jour = ''; |
|
| 280 | - } |
|
| 281 | - if ($annee > 4000) { |
|
| 282 | - $annee -= 9000; |
|
| 283 | - } |
|
| 284 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 285 | - $jour = substr($jour, 1); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if ($forcer_jour and $jour == '0') { |
|
| 289 | - $jour = '1'; |
|
| 290 | - } |
|
| 291 | - if ($forcer_jour and $mois == '0') { |
|
| 292 | - $mois = '1'; |
|
| 293 | - } |
|
| 294 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 295 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 296 | - } |
|
| 297 | - return []; |
|
| 247 | + if (!$numdate) { |
|
| 248 | + return []; |
|
| 249 | + } |
|
| 250 | + $heures = $minutes = $secondes = 0; |
|
| 251 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 252 | + $jour = $regs[1]; |
|
| 253 | + $mois = $regs[2]; |
|
| 254 | + $annee = $regs[3]; |
|
| 255 | + if ($annee < 90) { |
|
| 256 | + $annee = 2000 + $annee; |
|
| 257 | + } elseif ($annee < 100) { |
|
| 258 | + $annee = 1900 + $annee; |
|
| 259 | + } |
|
| 260 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 261 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 262 | + $annee = $regs[1]; |
|
| 263 | + $mois = $regs[2]; |
|
| 264 | + $jour = $regs[3]; |
|
| 265 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 266 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 267 | + $annee = $regs[1]; |
|
| 268 | + $mois = $regs[2]; |
|
| 269 | + $jour = ''; |
|
| 270 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 271 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 272 | + $annee = $regs[1]; |
|
| 273 | + $mois = $regs[2]; |
|
| 274 | + $jour = $regs[3]; |
|
| 275 | + $heures = $regs[4]; |
|
| 276 | + $minutes = $regs[5]; |
|
| 277 | + $secondes = $regs[6]; |
|
| 278 | + } else { |
|
| 279 | + $annee = $mois = $jour = ''; |
|
| 280 | + } |
|
| 281 | + if ($annee > 4000) { |
|
| 282 | + $annee -= 9000; |
|
| 283 | + } |
|
| 284 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 285 | + $jour = substr($jour, 1); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + if ($forcer_jour and $jour == '0') { |
|
| 289 | + $jour = '1'; |
|
| 290 | + } |
|
| 291 | + if ($forcer_jour and $mois == '0') { |
|
| 292 | + $mois = '1'; |
|
| 293 | + } |
|
| 294 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 295 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 296 | + } |
|
| 297 | + return []; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | * La date relative ou complète |
| 322 | 322 | **/ |
| 323 | 323 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */): string { |
| 324 | - return sinon( |
|
| 325 | - date_relative($date, $decalage_maxi), |
|
| 326 | - affdate_heure($date) |
|
| 327 | - ); |
|
| 324 | + return sinon( |
|
| 325 | + date_relative($date, $decalage_maxi), |
|
| 326 | + affdate_heure($date) |
|
| 327 | + ); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -357,86 +357,86 @@ discard block |
||
| 357 | 357 | **/ |
| 358 | 358 | function date_relative($date, $decalage_maxi = 0, $ref_date = null): string { |
| 359 | 359 | |
| 360 | - if (!$date) { |
|
| 361 | - return ''; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - if (is_null($ref_date)) { |
|
| 365 | - $ref_time = time(); |
|
| 366 | - } else { |
|
| 367 | - $ref_time = strtotime($ref_date); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 371 | - |
|
| 372 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 373 | - return ''; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - if ($decal < 0) { |
|
| 377 | - $il_y_a = 'date_dans'; |
|
| 378 | - $decal = -1 * $decal; |
|
| 379 | - } else { |
|
| 380 | - $il_y_a = 'date_il_y_a'; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 384 | - return affdate_court($date); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - if ($decal > 3600 * 24 * 30) { |
|
| 388 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 389 | - if ($mois < 2) { |
|
| 390 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 391 | - } else { |
|
| 392 | - $delai = "$mois " . _T('date_mois'); |
|
| 393 | - } |
|
| 394 | - } else { |
|
| 395 | - if ($decal > 3600 * 24 * 7) { |
|
| 396 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 397 | - if ($semaines < 2) { |
|
| 398 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 399 | - } else { |
|
| 400 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 401 | - } |
|
| 402 | - } else { |
|
| 403 | - if ($decal > 3600 * 24) { |
|
| 404 | - $jours = floor($decal / (3600 * 24)); |
|
| 405 | - if ($jours < 2) { |
|
| 406 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 407 | - } else { |
|
| 408 | - $delai = "$jours " . _T('date_jours'); |
|
| 409 | - } |
|
| 410 | - } else { |
|
| 411 | - if ($decal >= 3600) { |
|
| 412 | - $heures = floor($decal / 3600); |
|
| 413 | - if ($heures < 2) { |
|
| 414 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 415 | - } else { |
|
| 416 | - $delai = "$heures " . _T('date_heures'); |
|
| 417 | - } |
|
| 418 | - } else { |
|
| 419 | - if ($decal >= 60) { |
|
| 420 | - $minutes = floor($decal / 60); |
|
| 421 | - if ($minutes < 2) { |
|
| 422 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 423 | - } else { |
|
| 424 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 425 | - } |
|
| 426 | - } else { |
|
| 427 | - $secondes = ceil($decal); |
|
| 428 | - if ($secondes < 2) { |
|
| 429 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 430 | - } else { |
|
| 431 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 360 | + if (!$date) { |
|
| 361 | + return ''; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + if (is_null($ref_date)) { |
|
| 365 | + $ref_time = time(); |
|
| 366 | + } else { |
|
| 367 | + $ref_time = strtotime($ref_date); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 371 | + |
|
| 372 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 373 | + return ''; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + if ($decal < 0) { |
|
| 377 | + $il_y_a = 'date_dans'; |
|
| 378 | + $decal = -1 * $decal; |
|
| 379 | + } else { |
|
| 380 | + $il_y_a = 'date_il_y_a'; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 384 | + return affdate_court($date); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + if ($decal > 3600 * 24 * 30) { |
|
| 388 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 389 | + if ($mois < 2) { |
|
| 390 | + $delai = "$mois " . _T('date_un_mois'); |
|
| 391 | + } else { |
|
| 392 | + $delai = "$mois " . _T('date_mois'); |
|
| 393 | + } |
|
| 394 | + } else { |
|
| 395 | + if ($decal > 3600 * 24 * 7) { |
|
| 396 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 397 | + if ($semaines < 2) { |
|
| 398 | + $delai = "$semaines " . _T('date_une_semaine'); |
|
| 399 | + } else { |
|
| 400 | + $delai = "$semaines " . _T('date_semaines'); |
|
| 401 | + } |
|
| 402 | + } else { |
|
| 403 | + if ($decal > 3600 * 24) { |
|
| 404 | + $jours = floor($decal / (3600 * 24)); |
|
| 405 | + if ($jours < 2) { |
|
| 406 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 407 | + } else { |
|
| 408 | + $delai = "$jours " . _T('date_jours'); |
|
| 409 | + } |
|
| 410 | + } else { |
|
| 411 | + if ($decal >= 3600) { |
|
| 412 | + $heures = floor($decal / 3600); |
|
| 413 | + if ($heures < 2) { |
|
| 414 | + $delai = "$heures " . _T('date_une_heure'); |
|
| 415 | + } else { |
|
| 416 | + $delai = "$heures " . _T('date_heures'); |
|
| 417 | + } |
|
| 418 | + } else { |
|
| 419 | + if ($decal >= 60) { |
|
| 420 | + $minutes = floor($decal / 60); |
|
| 421 | + if ($minutes < 2) { |
|
| 422 | + $delai = "$minutes " . _T('date_une_minute'); |
|
| 423 | + } else { |
|
| 424 | + $delai = "$minutes " . _T('date_minutes'); |
|
| 425 | + } |
|
| 426 | + } else { |
|
| 427 | + $secondes = ceil($decal); |
|
| 428 | + if ($secondes < 2) { |
|
| 429 | + $delai = "$secondes " . _T('date_une_seconde'); |
|
| 430 | + } else { |
|
| 431 | + $delai = "$secondes " . _T('date_secondes'); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | |
@@ -462,32 +462,32 @@ discard block |
||
| 462 | 462 | **/ |
| 463 | 463 | function date_relativecourt($date, $decalage_maxi = 0): string { |
| 464 | 464 | |
| 465 | - if (!$date) { |
|
| 466 | - return ''; |
|
| 467 | - } |
|
| 468 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 469 | - |
|
| 470 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 471 | - return ''; |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - if ($decal < -24 * 3600) { |
|
| 475 | - $retour = date_relative($date, $decalage_maxi); |
|
| 476 | - } elseif ($decal < 0) { |
|
| 477 | - $retour = _T('date_demain'); |
|
| 478 | - } else { |
|
| 479 | - if ($decal < (3600 * 24)) { |
|
| 480 | - $retour = _T('date_aujourdhui'); |
|
| 481 | - } else { |
|
| 482 | - if ($decal < (3600 * 24 * 2)) { |
|
| 483 | - $retour = _T('date_hier'); |
|
| 484 | - } else { |
|
| 485 | - $retour = date_relative($date, $decalage_maxi); |
|
| 486 | - } |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - return $retour; |
|
| 465 | + if (!$date) { |
|
| 466 | + return ''; |
|
| 467 | + } |
|
| 468 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 469 | + |
|
| 470 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 471 | + return ''; |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + if ($decal < -24 * 3600) { |
|
| 475 | + $retour = date_relative($date, $decalage_maxi); |
|
| 476 | + } elseif ($decal < 0) { |
|
| 477 | + $retour = _T('date_demain'); |
|
| 478 | + } else { |
|
| 479 | + if ($decal < (3600 * 24)) { |
|
| 480 | + $retour = _T('date_aujourdhui'); |
|
| 481 | + } else { |
|
| 482 | + if ($decal < (3600 * 24 * 2)) { |
|
| 483 | + $retour = _T('date_hier'); |
|
| 484 | + } else { |
|
| 485 | + $retour = date_relative($date, $decalage_maxi); |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + return $retour; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -504,174 +504,174 @@ discard block |
||
| 504 | 504 | * @return string |
| 505 | 505 | */ |
| 506 | 506 | function affdate_base($numdate, $vue, $options = []): string { |
| 507 | - if (is_string($options)) { |
|
| 508 | - $options = ['param' => $options]; |
|
| 509 | - } |
|
| 510 | - $date_array = recup_date($numdate, false); |
|
| 511 | - if (!$date_array) { |
|
| 512 | - return ''; |
|
| 513 | - } |
|
| 514 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 515 | - |
|
| 516 | - // 1er, 21st, etc. |
|
| 517 | - $journum = $jour; |
|
| 518 | - |
|
| 519 | - if ($jour == 0) { |
|
| 520 | - $jour = ''; |
|
| 521 | - $njour = 0; |
|
| 522 | - } else { |
|
| 523 | - $njour = intval($jour); |
|
| 524 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 525 | - $jour = $jourth; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - $mois = intval($mois); |
|
| 530 | - if ($mois > 0 and $mois < 13) { |
|
| 531 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 532 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 533 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 534 | - if ($jour) { |
|
| 535 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 536 | - } else { |
|
| 537 | - $jourmois = $nommois; |
|
| 538 | - } |
|
| 539 | - } else { |
|
| 540 | - $nommois = ''; |
|
| 541 | - $jourmois = ''; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - if ($annee < 0) { |
|
| 545 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 546 | - $avjc = true; |
|
| 547 | - } else { |
|
| 548 | - $avjc = false; |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - switch ($vue) { |
|
| 552 | - case 'saison': |
|
| 553 | - case 'saison_annee': |
|
| 554 | - $saison = ''; |
|
| 555 | - if ($mois > 0) { |
|
| 556 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 557 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 558 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 559 | - } |
|
| 560 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 561 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 562 | - } |
|
| 563 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 564 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 565 | - } |
|
| 566 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 567 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - if ($vue == 'saison') { |
|
| 571 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 572 | - } else { |
|
| 573 | - return $saison ? trim(_T( |
|
| 574 | - 'date_fmt_saison_annee', |
|
| 575 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 576 | - )) : ''; |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - case 'court': |
|
| 580 | - if ($avjc) { |
|
| 581 | - return $annee; |
|
| 582 | - } |
|
| 583 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 584 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 585 | - return $annee; |
|
| 586 | - } |
|
| 587 | - if ($annee != $a) { |
|
| 588 | - return _T( |
|
| 589 | - 'date_fmt_mois_annee', |
|
| 590 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 591 | - ); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return _T( |
|
| 595 | - 'date_fmt_jour_mois', |
|
| 596 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 597 | - ); |
|
| 598 | - |
|
| 599 | - case 'jourcourt': |
|
| 600 | - if ($avjc) { |
|
| 601 | - return $annee; |
|
| 602 | - } |
|
| 603 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 604 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 605 | - return $annee; |
|
| 606 | - } |
|
| 607 | - if ($annee != $a) { |
|
| 608 | - return _T( |
|
| 609 | - 'date_fmt_jour_mois_annee', |
|
| 610 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 611 | - ); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - return _T( |
|
| 615 | - 'date_fmt_jour_mois', |
|
| 616 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 617 | - ); |
|
| 618 | - |
|
| 619 | - case 'entier': |
|
| 620 | - if ($avjc) { |
|
| 621 | - return $annee; |
|
| 622 | - } |
|
| 623 | - if ($jour) { |
|
| 624 | - return _T( |
|
| 625 | - 'date_fmt_jour_mois_annee', |
|
| 626 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 627 | - ); |
|
| 628 | - } elseif ($mois) { |
|
| 629 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 630 | - } else { |
|
| 631 | - return $annee; |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - case 'nom_mois': |
|
| 635 | - return $nommois; |
|
| 636 | - |
|
| 637 | - case 'mois': |
|
| 638 | - return sprintf('%02s', $mois); |
|
| 639 | - |
|
| 640 | - case 'jour': |
|
| 641 | - return $jour; |
|
| 642 | - |
|
| 643 | - case 'journum': |
|
| 644 | - return $journum; |
|
| 645 | - |
|
| 646 | - case 'nom_jour': |
|
| 647 | - if (!$mois or !$njour) { |
|
| 648 | - return ''; |
|
| 649 | - } |
|
| 650 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 651 | - $nom = 1 + date('w', $nom); |
|
| 652 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 653 | - |
|
| 654 | - return _T('date_jour_' . $nom . $param); |
|
| 655 | - |
|
| 656 | - case 'mois_annee': |
|
| 657 | - if ($avjc) { |
|
| 658 | - return $annee; |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 662 | - |
|
| 663 | - case 'annee': |
|
| 664 | - return $annee; |
|
| 665 | - |
|
| 666 | - // Cas d'une vue non definie : retomber sur le format |
|
| 667 | - // de date propose par http://www.php.net/date |
|
| 668 | - default: |
|
| 669 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 670 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 671 | - $time = strtotime($numdate); |
|
| 672 | - } |
|
| 673 | - return date($vue, $time); |
|
| 674 | - } |
|
| 507 | + if (is_string($options)) { |
|
| 508 | + $options = ['param' => $options]; |
|
| 509 | + } |
|
| 510 | + $date_array = recup_date($numdate, false); |
|
| 511 | + if (!$date_array) { |
|
| 512 | + return ''; |
|
| 513 | + } |
|
| 514 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 515 | + |
|
| 516 | + // 1er, 21st, etc. |
|
| 517 | + $journum = $jour; |
|
| 518 | + |
|
| 519 | + if ($jour == 0) { |
|
| 520 | + $jour = ''; |
|
| 521 | + $njour = 0; |
|
| 522 | + } else { |
|
| 523 | + $njour = intval($jour); |
|
| 524 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 525 | + $jour = $jourth; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + $mois = intval($mois); |
|
| 530 | + if ($mois > 0 and $mois < 13) { |
|
| 531 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 532 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 533 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 534 | + if ($jour) { |
|
| 535 | + $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 536 | + } else { |
|
| 537 | + $jourmois = $nommois; |
|
| 538 | + } |
|
| 539 | + } else { |
|
| 540 | + $nommois = ''; |
|
| 541 | + $jourmois = ''; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + if ($annee < 0) { |
|
| 545 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 546 | + $avjc = true; |
|
| 547 | + } else { |
|
| 548 | + $avjc = false; |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + switch ($vue) { |
|
| 552 | + case 'saison': |
|
| 553 | + case 'saison_annee': |
|
| 554 | + $saison = ''; |
|
| 555 | + if ($mois > 0) { |
|
| 556 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 557 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 558 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 559 | + } |
|
| 560 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 561 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 562 | + } |
|
| 563 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 564 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 565 | + } |
|
| 566 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 567 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + if ($vue == 'saison') { |
|
| 571 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 572 | + } else { |
|
| 573 | + return $saison ? trim(_T( |
|
| 574 | + 'date_fmt_saison_annee', |
|
| 575 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 576 | + )) : ''; |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + case 'court': |
|
| 580 | + if ($avjc) { |
|
| 581 | + return $annee; |
|
| 582 | + } |
|
| 583 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 584 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 585 | + return $annee; |
|
| 586 | + } |
|
| 587 | + if ($annee != $a) { |
|
| 588 | + return _T( |
|
| 589 | + 'date_fmt_mois_annee', |
|
| 590 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 591 | + ); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return _T( |
|
| 595 | + 'date_fmt_jour_mois', |
|
| 596 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 597 | + ); |
|
| 598 | + |
|
| 599 | + case 'jourcourt': |
|
| 600 | + if ($avjc) { |
|
| 601 | + return $annee; |
|
| 602 | + } |
|
| 603 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 604 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 605 | + return $annee; |
|
| 606 | + } |
|
| 607 | + if ($annee != $a) { |
|
| 608 | + return _T( |
|
| 609 | + 'date_fmt_jour_mois_annee', |
|
| 610 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 611 | + ); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + return _T( |
|
| 615 | + 'date_fmt_jour_mois', |
|
| 616 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 617 | + ); |
|
| 618 | + |
|
| 619 | + case 'entier': |
|
| 620 | + if ($avjc) { |
|
| 621 | + return $annee; |
|
| 622 | + } |
|
| 623 | + if ($jour) { |
|
| 624 | + return _T( |
|
| 625 | + 'date_fmt_jour_mois_annee', |
|
| 626 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 627 | + ); |
|
| 628 | + } elseif ($mois) { |
|
| 629 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 630 | + } else { |
|
| 631 | + return $annee; |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + case 'nom_mois': |
|
| 635 | + return $nommois; |
|
| 636 | + |
|
| 637 | + case 'mois': |
|
| 638 | + return sprintf('%02s', $mois); |
|
| 639 | + |
|
| 640 | + case 'jour': |
|
| 641 | + return $jour; |
|
| 642 | + |
|
| 643 | + case 'journum': |
|
| 644 | + return $journum; |
|
| 645 | + |
|
| 646 | + case 'nom_jour': |
|
| 647 | + if (!$mois or !$njour) { |
|
| 648 | + return ''; |
|
| 649 | + } |
|
| 650 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 651 | + $nom = 1 + date('w', $nom); |
|
| 652 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 653 | + |
|
| 654 | + return _T('date_jour_' . $nom . $param); |
|
| 655 | + |
|
| 656 | + case 'mois_annee': |
|
| 657 | + if ($avjc) { |
|
| 658 | + return $annee; |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 662 | + |
|
| 663 | + case 'annee': |
|
| 664 | + return $annee; |
|
| 665 | + |
|
| 666 | + // Cas d'une vue non definie : retomber sur le format |
|
| 667 | + // de date propose par http://www.php.net/date |
|
| 668 | + default: |
|
| 669 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 670 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 671 | + $time = strtotime($numdate); |
|
| 672 | + } |
|
| 673 | + return date($vue, $time); |
|
| 674 | + } |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
@@ -698,11 +698,11 @@ discard block |
||
| 698 | 698 | * Nom du jour |
| 699 | 699 | **/ |
| 700 | 700 | function nom_jour($numdate, $forme = ''): string { |
| 701 | - if (!($forme === 'abbr' or $forme === 'initiale')) { |
|
| 702 | - $forme = ''; |
|
| 703 | - } |
|
| 701 | + if (!($forme === 'abbr' or $forme === 'initiale')) { |
|
| 702 | + $forme = ''; |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | - return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 705 | + return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | * Numéro du jour |
| 725 | 725 | **/ |
| 726 | 726 | function jour($numdate): string { |
| 727 | - return affdate_base($numdate, 'jour'); |
|
| 727 | + return affdate_base($numdate, 'jour'); |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | /** |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | * Numéro du jour |
| 743 | 743 | **/ |
| 744 | 744 | function journum($numdate): string { |
| 745 | - return affdate_base($numdate, 'journum'); |
|
| 745 | + return affdate_base($numdate, 'journum'); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /** |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | * Numéro du mois (sur 2 chiffres) |
| 761 | 761 | **/ |
| 762 | 762 | function mois($numdate): string { |
| 763 | - return affdate_base($numdate, 'mois'); |
|
| 763 | + return affdate_base($numdate, 'mois'); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | /** |
@@ -784,11 +784,11 @@ discard block |
||
| 784 | 784 | * Nom du mois |
| 785 | 785 | **/ |
| 786 | 786 | function nom_mois($numdate, $forme = ''): string { |
| 787 | - if (!($forme === 'abbr')) { |
|
| 788 | - $forme = ''; |
|
| 789 | - } |
|
| 787 | + if (!($forme === 'abbr')) { |
|
| 788 | + $forme = ''; |
|
| 789 | + } |
|
| 790 | 790 | |
| 791 | - return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 791 | + return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | /** |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | * Année (sur 4 chiffres) |
| 807 | 807 | **/ |
| 808 | 808 | function annee($numdate): string { |
| 809 | - return affdate_base($numdate, 'annee'); |
|
| 809 | + return affdate_base($numdate, 'annee'); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | |
@@ -836,11 +836,11 @@ discard block |
||
| 836 | 836 | * La date formatée |
| 837 | 837 | **/ |
| 838 | 838 | function saison($numdate, $hemisphere = 'nord'): string { |
| 839 | - if ($hemisphere !== 'sud') { |
|
| 840 | - $hemisphere = 'nord'; |
|
| 841 | - } |
|
| 839 | + if ($hemisphere !== 'sud') { |
|
| 840 | + $hemisphere = 'nord'; |
|
| 841 | + } |
|
| 842 | 842 | |
| 843 | - return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 843 | + return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | |
@@ -869,11 +869,11 @@ discard block |
||
| 869 | 869 | * La date formatée |
| 870 | 870 | **/ |
| 871 | 871 | function saison_annee($numdate, $hemisphere = 'nord'): string { |
| 872 | - if ($hemisphere !== 'sud') { |
|
| 873 | - $hemisphere = 'nord'; |
|
| 874 | - } |
|
| 872 | + if ($hemisphere !== 'sud') { |
|
| 873 | + $hemisphere = 'nord'; |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 876 | + return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | /** |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | * La date formatée |
| 902 | 902 | **/ |
| 903 | 903 | function affdate($numdate, $format = 'entier'): string { |
| 904 | - return affdate_base($numdate, $format); |
|
| 904 | + return affdate_base($numdate, $format); |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | * La date formatée |
| 929 | 929 | **/ |
| 930 | 930 | function affdate_court($numdate, $annee_courante = null): string { |
| 931 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 931 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | |
@@ -955,7 +955,7 @@ discard block |
||
| 955 | 955 | * La date formatée |
| 956 | 956 | **/ |
| 957 | 957 | function affdate_jourcourt($numdate, $annee_courante = null): string { |
| 958 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 958 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | /** |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | * La date formatée |
| 974 | 974 | **/ |
| 975 | 975 | function affdate_mois_annee($numdate): string { |
| 976 | - return affdate_base($numdate, 'mois_annee'); |
|
| 976 | + return affdate_base($numdate, 'mois_annee'); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -991,16 +991,16 @@ discard block |
||
| 991 | 991 | * La date formatée, sinon '' |
| 992 | 992 | **/ |
| 993 | 993 | function affdate_heure($numdate): string { |
| 994 | - $date_array = recup_date($numdate); |
|
| 995 | - if (!$date_array) { |
|
| 996 | - return ''; |
|
| 997 | - } |
|
| 998 | - [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 999 | - |
|
| 1000 | - return _T('date_fmt_jour_heure', [ |
|
| 1001 | - 'jour' => affdate($numdate), |
|
| 1002 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1003 | - ]); |
|
| 994 | + $date_array = recup_date($numdate); |
|
| 995 | + if (!$date_array) { |
|
| 996 | + return ''; |
|
| 997 | + } |
|
| 998 | + [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 999 | + |
|
| 1000 | + return _T('date_fmt_jour_heure', [ |
|
| 1001 | + 'jour' => affdate($numdate), |
|
| 1002 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1003 | + ]); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
@@ -1032,117 +1032,117 @@ discard block |
||
| 1032 | 1032 | * Texte de la date |
| 1033 | 1033 | */ |
| 1034 | 1034 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = ''): string { |
| 1035 | - $abbr = $jour = ''; |
|
| 1036 | - $affdate = 'affdate_jourcourt'; |
|
| 1037 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1038 | - $abbr = 'abbr'; |
|
| 1039 | - } |
|
| 1040 | - if (strpos($forme, 'annee') !== false) { |
|
| 1041 | - $affdate = 'affdate'; |
|
| 1042 | - } |
|
| 1043 | - if (strpos($forme, 'jour') !== false) { |
|
| 1044 | - $jour = 'jour'; |
|
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1048 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1049 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1050 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1051 | - $dtabbr = '</abbr>'; |
|
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - $date_debut = strtotime($date_debut); |
|
| 1055 | - $date_fin = strtotime($date_fin); |
|
| 1056 | - $d = date('Y-m-d', $date_debut); |
|
| 1057 | - $f = date('Y-m-d', $date_fin); |
|
| 1058 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1059 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1060 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1061 | - |
|
| 1062 | - if ($d == $f) { // meme jour |
|
| 1063 | - $nomjour = nom_jour($d, $abbr); |
|
| 1064 | - $s = $affdate($d); |
|
| 1065 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1066 | - if ($h) { |
|
| 1067 | - if ($hd == $hf) { |
|
| 1068 | - // Lundi 20 fevrier a 18h25 |
|
| 1069 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1070 | - $s = "$dtstart$s$dtabbr"; |
|
| 1071 | - } else { |
|
| 1072 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1073 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1074 | - $s = _T( |
|
| 1075 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1076 | - [ |
|
| 1077 | - 'jour' => spip_ucfirst($s), |
|
| 1078 | - 'heure_debut' => $hd, |
|
| 1079 | - 'heure_fin' => $hf, |
|
| 1080 | - 'dtstart' => $dtstart, |
|
| 1081 | - 'dtend' => $dtend, |
|
| 1082 | - 'dtabbr' => $dtabbr |
|
| 1083 | - ], |
|
| 1084 | - [ |
|
| 1085 | - 'sanitize' => false |
|
| 1086 | - ] |
|
| 1087 | - ); |
|
| 1088 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1089 | - else { |
|
| 1090 | - $s = spip_ucfirst(_T( |
|
| 1091 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1092 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1093 | - )); |
|
| 1094 | - } |
|
| 1095 | - } |
|
| 1096 | - } else { |
|
| 1097 | - if ($dtabbr && $dtstart) { |
|
| 1098 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1099 | - } else { |
|
| 1100 | - $s = spip_ucfirst($s); |
|
| 1101 | - } |
|
| 1102 | - } |
|
| 1103 | - } else { |
|
| 1104 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1105 | - if (!$h) { |
|
| 1106 | - $date_debut = jour($d); |
|
| 1107 | - } else { |
|
| 1108 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1109 | - } |
|
| 1110 | - $date_fin = $affdate($f); |
|
| 1111 | - if ($jour) { |
|
| 1112 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1113 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1114 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1115 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1116 | - } |
|
| 1117 | - if ($h) { |
|
| 1118 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1119 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1120 | - } |
|
| 1121 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1122 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1123 | - |
|
| 1124 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1125 | - } else { |
|
| 1126 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1127 | - $date_fin = $affdate($f); |
|
| 1128 | - if ($jour) { |
|
| 1129 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1130 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1131 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1132 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1133 | - } |
|
| 1134 | - if ($h) { |
|
| 1135 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1136 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1137 | - } |
|
| 1138 | - |
|
| 1139 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1140 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1141 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1142 | - } |
|
| 1143 | - } |
|
| 1144 | - |
|
| 1145 | - return $s; |
|
| 1035 | + $abbr = $jour = ''; |
|
| 1036 | + $affdate = 'affdate_jourcourt'; |
|
| 1037 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1038 | + $abbr = 'abbr'; |
|
| 1039 | + } |
|
| 1040 | + if (strpos($forme, 'annee') !== false) { |
|
| 1041 | + $affdate = 'affdate'; |
|
| 1042 | + } |
|
| 1043 | + if (strpos($forme, 'jour') !== false) { |
|
| 1044 | + $jour = 'jour'; |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1048 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1049 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1050 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1051 | + $dtabbr = '</abbr>'; |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + $date_debut = strtotime($date_debut); |
|
| 1055 | + $date_fin = strtotime($date_fin); |
|
| 1056 | + $d = date('Y-m-d', $date_debut); |
|
| 1057 | + $f = date('Y-m-d', $date_fin); |
|
| 1058 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1059 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1060 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1061 | + |
|
| 1062 | + if ($d == $f) { // meme jour |
|
| 1063 | + $nomjour = nom_jour($d, $abbr); |
|
| 1064 | + $s = $affdate($d); |
|
| 1065 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1066 | + if ($h) { |
|
| 1067 | + if ($hd == $hf) { |
|
| 1068 | + // Lundi 20 fevrier a 18h25 |
|
| 1069 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1070 | + $s = "$dtstart$s$dtabbr"; |
|
| 1071 | + } else { |
|
| 1072 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1073 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1074 | + $s = _T( |
|
| 1075 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1076 | + [ |
|
| 1077 | + 'jour' => spip_ucfirst($s), |
|
| 1078 | + 'heure_debut' => $hd, |
|
| 1079 | + 'heure_fin' => $hf, |
|
| 1080 | + 'dtstart' => $dtstart, |
|
| 1081 | + 'dtend' => $dtend, |
|
| 1082 | + 'dtabbr' => $dtabbr |
|
| 1083 | + ], |
|
| 1084 | + [ |
|
| 1085 | + 'sanitize' => false |
|
| 1086 | + ] |
|
| 1087 | + ); |
|
| 1088 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1089 | + else { |
|
| 1090 | + $s = spip_ucfirst(_T( |
|
| 1091 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1092 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1093 | + )); |
|
| 1094 | + } |
|
| 1095 | + } |
|
| 1096 | + } else { |
|
| 1097 | + if ($dtabbr && $dtstart) { |
|
| 1098 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1099 | + } else { |
|
| 1100 | + $s = spip_ucfirst($s); |
|
| 1101 | + } |
|
| 1102 | + } |
|
| 1103 | + } else { |
|
| 1104 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1105 | + if (!$h) { |
|
| 1106 | + $date_debut = jour($d); |
|
| 1107 | + } else { |
|
| 1108 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1109 | + } |
|
| 1110 | + $date_fin = $affdate($f); |
|
| 1111 | + if ($jour) { |
|
| 1112 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1113 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1114 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1115 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1116 | + } |
|
| 1117 | + if ($h) { |
|
| 1118 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1119 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1120 | + } |
|
| 1121 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1122 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1123 | + |
|
| 1124 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1125 | + } else { |
|
| 1126 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1127 | + $date_fin = $affdate($f); |
|
| 1128 | + if ($jour) { |
|
| 1129 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1130 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1131 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1132 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1133 | + } |
|
| 1134 | + if ($h) { |
|
| 1135 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1136 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1137 | + } |
|
| 1138 | + |
|
| 1139 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1140 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1141 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1142 | + } |
|
| 1143 | + } |
|
| 1144 | + |
|
| 1145 | + return $s; |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | /** |
@@ -1163,10 +1163,10 @@ discard block |
||
| 1163 | 1163 | * Date au format ical |
| 1164 | 1164 | **/ |
| 1165 | 1165 | function date_ical($date, $addminutes = 0): string { |
| 1166 | - [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1167 | - [$annee, $mois, $jour] = recup_date($date); |
|
| 1166 | + [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1167 | + [$annee, $mois, $jour] = recup_date($date); |
|
| 1168 | 1168 | |
| 1169 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1169 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | 1172 | |
@@ -1190,11 +1190,11 @@ discard block |
||
| 1190 | 1190 | * La date formatée |
| 1191 | 1191 | **/ |
| 1192 | 1192 | function date_iso($date_heure): string { |
| 1193 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1194 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1195 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1193 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1194 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1195 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1196 | 1196 | |
| 1197 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1197 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | /** |
@@ -1217,11 +1217,11 @@ discard block |
||
| 1217 | 1217 | * La date formatée |
| 1218 | 1218 | **/ |
| 1219 | 1219 | function date_822($date_heure): string { |
| 1220 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1221 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1222 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1220 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1221 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1222 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1223 | 1223 | |
| 1224 | - return date('r', $time); |
|
| 1224 | + return date('r', $time); |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | /** |
@@ -1237,11 +1237,11 @@ discard block |
||
| 1237 | 1237 | * Date au format `Ymd` |
| 1238 | 1238 | **/ |
| 1239 | 1239 | function date_anneemoisjour($d): string { |
| 1240 | - if (!$d) { |
|
| 1241 | - $d = date('Y-m-d'); |
|
| 1242 | - } |
|
| 1240 | + if (!$d) { |
|
| 1241 | + $d = date('Y-m-d'); |
|
| 1242 | + } |
|
| 1243 | 1243 | |
| 1244 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1244 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | /** |
@@ -1257,11 +1257,11 @@ discard block |
||
| 1257 | 1257 | * Date au format `Ym` |
| 1258 | 1258 | **/ |
| 1259 | 1259 | function date_anneemois($d): string { |
| 1260 | - if (!$d) { |
|
| 1261 | - $d = date('Y-m-d'); |
|
| 1262 | - } |
|
| 1260 | + if (!$d) { |
|
| 1261 | + $d = date('Y-m-d'); |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1264 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | /** |
@@ -1277,13 +1277,13 @@ discard block |
||
| 1277 | 1277 | * Date au lundi de la même semaine au format `Ymd` |
| 1278 | 1278 | **/ |
| 1279 | 1279 | function date_debut_semaine($annee, $mois, $jour): string { |
| 1280 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1281 | - if ($w_day == 0) { |
|
| 1282 | - $w_day = 7; |
|
| 1283 | - } // Gaffe: le dimanche est zero |
|
| 1284 | - $debut = $jour - $w_day + 1; |
|
| 1280 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1281 | + if ($w_day == 0) { |
|
| 1282 | + $w_day = 7; |
|
| 1283 | + } // Gaffe: le dimanche est zero |
|
| 1284 | + $debut = $jour - $w_day + 1; |
|
| 1285 | 1285 | |
| 1286 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1286 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | 1289 | /** |
@@ -1299,11 +1299,11 @@ discard block |
||
| 1299 | 1299 | * Date au dimanche de la même semaine au format `Ymd` |
| 1300 | 1300 | **/ |
| 1301 | 1301 | function date_fin_semaine($annee, $mois, $jour): string { |
| 1302 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1303 | - if ($w_day == 0) { |
|
| 1304 | - $w_day = 7; |
|
| 1305 | - } // Gaffe: le dimanche est zero |
|
| 1306 | - $debut = $jour - $w_day + 1; |
|
| 1302 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1303 | + if ($w_day == 0) { |
|
| 1304 | + $w_day = 7; |
|
| 1305 | + } // Gaffe: le dimanche est zero |
|
| 1306 | + $debut = $jour - $w_day + 1; |
|
| 1307 | 1307 | |
| 1308 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1308 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1309 | 1309 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | function extraire_date($texte): string { |
| 40 | 40 | // format = 2001-08 |
| 41 | 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'; |
|
| 42 | + return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01'; |
|
| 43 | 43 | } |
| 44 | 44 | return ''; |
| 45 | 45 | } |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 72 | 72 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 73 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 73 | + $date = $regs[1].'-00-00'.$regs[3]; |
|
| 74 | 74 | } else { |
| 75 | 75 | if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 76 | 76 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 77 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 77 | + $date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3]; |
|
| 78 | 78 | } else { |
| 79 | 79 | $date = date('Y-m-d H:i:s', strtotime($date)); |
| 80 | 80 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | function vider_date($letexte, $verif_format_date = false): string { |
| 101 | 101 | if ( |
| 102 | 102 | !$verif_format_date |
| 103 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 103 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 104 | 104 | preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
| 105 | 105 | ) { |
| 106 | 106 | if (strncmp('0000-00-00', $letexte, 10) == 0) { |
@@ -387,17 +387,17 @@ discard block |
||
| 387 | 387 | if ($decal > 3600 * 24 * 30) { |
| 388 | 388 | $mois = floor($decal / (3600 * 24 * 30)); |
| 389 | 389 | if ($mois < 2) { |
| 390 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 390 | + $delai = "$mois "._T('date_un_mois'); |
|
| 391 | 391 | } else { |
| 392 | - $delai = "$mois " . _T('date_mois'); |
|
| 392 | + $delai = "$mois "._T('date_mois'); |
|
| 393 | 393 | } |
| 394 | 394 | } else { |
| 395 | 395 | if ($decal > 3600 * 24 * 7) { |
| 396 | 396 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 397 | 397 | if ($semaines < 2) { |
| 398 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 398 | + $delai = "$semaines "._T('date_une_semaine'); |
|
| 399 | 399 | } else { |
| 400 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 400 | + $delai = "$semaines "._T('date_semaines'); |
|
| 401 | 401 | } |
| 402 | 402 | } else { |
| 403 | 403 | if ($decal > 3600 * 24) { |
@@ -405,30 +405,30 @@ discard block |
||
| 405 | 405 | if ($jours < 2) { |
| 406 | 406 | return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
| 407 | 407 | } else { |
| 408 | - $delai = "$jours " . _T('date_jours'); |
|
| 408 | + $delai = "$jours "._T('date_jours'); |
|
| 409 | 409 | } |
| 410 | 410 | } else { |
| 411 | 411 | if ($decal >= 3600) { |
| 412 | 412 | $heures = floor($decal / 3600); |
| 413 | 413 | if ($heures < 2) { |
| 414 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 414 | + $delai = "$heures "._T('date_une_heure'); |
|
| 415 | 415 | } else { |
| 416 | - $delai = "$heures " . _T('date_heures'); |
|
| 416 | + $delai = "$heures "._T('date_heures'); |
|
| 417 | 417 | } |
| 418 | 418 | } else { |
| 419 | 419 | if ($decal >= 60) { |
| 420 | 420 | $minutes = floor($decal / 60); |
| 421 | 421 | if ($minutes < 2) { |
| 422 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 422 | + $delai = "$minutes "._T('date_une_minute'); |
|
| 423 | 423 | } else { |
| 424 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 424 | + $delai = "$minutes "._T('date_minutes'); |
|
| 425 | 425 | } |
| 426 | 426 | } else { |
| 427 | 427 | $secondes = ceil($decal); |
| 428 | 428 | if ($secondes < 2) { |
| 429 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 429 | + $delai = "$secondes "._T('date_une_seconde'); |
|
| 430 | 430 | } else { |
| 431 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 431 | + $delai = "$secondes "._T('date_secondes'); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | } |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | $njour = 0; |
| 522 | 522 | } else { |
| 523 | 523 | $njour = intval($jour); |
| 524 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 524 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 525 | 525 | $jour = $jourth; |
| 526 | 526 | } |
| 527 | 527 | } |
@@ -529,10 +529,10 @@ discard block |
||
| 529 | 529 | $mois = intval($mois); |
| 530 | 530 | if ($mois > 0 and $mois < 13) { |
| 531 | 531 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 532 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 533 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 532 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : ''); |
|
| 533 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 534 | 534 | if ($jour) { |
| 535 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 535 | + $jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 536 | 536 | } else { |
| 537 | 537 | $jourmois = $nommois; |
| 538 | 538 | } |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | if ($annee < 0) { |
| 545 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 545 | + $annee = -$annee.' '._T('date_avant_jc'); |
|
| 546 | 546 | $avjc = true; |
| 547 | 547 | } else { |
| 548 | 548 | $avjc = false; |
@@ -568,11 +568,11 @@ discard block |
||
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | if ($vue == 'saison') { |
| 571 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 571 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 572 | 572 | } else { |
| 573 | 573 | return $saison ? trim(_T( |
| 574 | 574 | 'date_fmt_saison_annee', |
| 575 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 575 | + ['saison' => _T('date_saison_'.$saison), 'annee' => $annee] |
|
| 576 | 576 | )) : ''; |
| 577 | 577 | } |
| 578 | 578 | |
@@ -649,9 +649,9 @@ discard block |
||
| 649 | 649 | } |
| 650 | 650 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 651 | 651 | $nom = 1 + date('w', $nom); |
| 652 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 652 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 653 | 653 | |
| 654 | - return _T('date_jour_' . $nom . $param); |
|
| 654 | + return _T('date_jour_'.$nom.$param); |
|
| 655 | 655 | |
| 656 | 656 | case 'mois_annee': |
| 657 | 657 | if ($avjc) { |
@@ -1046,8 +1046,8 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | $dtstart = $dtend = $dtabbr = ''; |
| 1048 | 1048 | if (strpos($forme, 'hcal') !== false) { |
| 1049 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1050 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1049 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1050 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1051 | 1051 | $dtabbr = '</abbr>'; |
| 1052 | 1052 | } |
| 1053 | 1053 | |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | } |
| 1096 | 1096 | } else { |
| 1097 | 1097 | if ($dtabbr && $dtstart) { |
| 1098 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1098 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1099 | 1099 | } else { |
| 1100 | 1100 | $s = spip_ucfirst($s); |
| 1101 | 1101 | } |
@@ -1118,8 +1118,8 @@ discard block |
||
| 1118 | 1118 | $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
| 1119 | 1119 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1120 | 1120 | } |
| 1121 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1122 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1121 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1122 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1123 | 1123 | |
| 1124 | 1124 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1125 | 1125 | } else { |
@@ -1136,8 +1136,8 @@ discard block |
||
| 1136 | 1136 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1140 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1139 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1140 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1141 | 1141 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1142 | 1142 | } |
| 1143 | 1143 | } |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | $d = date('Y-m-d'); |
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1244 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | $d = date('Y-m-d'); |
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1264 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | /** |
@@ -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,28 +280,28 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet) { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 289 | - return $qui[$objet][$id_objet] = ''; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - include_spip('inc/drapeau_edition'); |
|
| 293 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 294 | - if (!$modif) { |
|
| 295 | - return $qui[$objet][$id_objet] = ''; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - include_spip('base/objets'); |
|
| 299 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 300 | - if (isset($infos['texte_signale_edition'])) { |
|
| 301 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - 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 | + if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 289 | + return $qui[$objet][$id_objet] = ''; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + include_spip('inc/drapeau_edition'); |
|
| 293 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 294 | + if (!$modif) { |
|
| 295 | + return $qui[$objet][$id_objet] = ''; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + include_spip('base/objets'); |
|
| 299 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 300 | + if (isset($infos['texte_signale_edition'])) { |
|
| 301 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -319,53 +319,53 @@ discard block |
||
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | 321 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 322 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 323 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - switch ($quoi) { |
|
| 327 | - case 'redacteurs': |
|
| 328 | - $statut = AUTEURS_MIN_REDAC; |
|
| 329 | - $statut = explode(',', $statut); |
|
| 330 | - if ($en_base) { |
|
| 331 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 332 | - $retire = array_diff($statut, $check); |
|
| 333 | - $statut = array_diff($statut, $retire); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - return array_unique($statut); |
|
| 337 | - |
|
| 338 | - case 'visiteurs': |
|
| 339 | - $statut = []; |
|
| 340 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 341 | - $exclus = explode(',', $exclus); |
|
| 342 | - if (!$en_base) { |
|
| 343 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 344 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 345 | - } |
|
| 346 | - $s_complement = array_column( |
|
| 347 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 348 | - 'statut' |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 352 | - |
|
| 353 | - default: |
|
| 354 | - case 'tous': |
|
| 355 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 356 | - $s_complement = array_column( |
|
| 357 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 358 | - 'statut' |
|
| 359 | - ); |
|
| 360 | - $statut = array_merge($statut, $s_complement); |
|
| 361 | - if ($en_base) { |
|
| 362 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 363 | - $retire = array_diff($statut, $check); |
|
| 364 | - $statut = array_diff($statut, $retire); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - return array_unique($statut); |
|
| 368 | - } |
|
| 322 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 323 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + switch ($quoi) { |
|
| 327 | + case 'redacteurs': |
|
| 328 | + $statut = AUTEURS_MIN_REDAC; |
|
| 329 | + $statut = explode(',', $statut); |
|
| 330 | + if ($en_base) { |
|
| 331 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 332 | + $retire = array_diff($statut, $check); |
|
| 333 | + $statut = array_diff($statut, $retire); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + return array_unique($statut); |
|
| 337 | + |
|
| 338 | + case 'visiteurs': |
|
| 339 | + $statut = []; |
|
| 340 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 341 | + $exclus = explode(',', $exclus); |
|
| 342 | + if (!$en_base) { |
|
| 343 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 344 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 345 | + } |
|
| 346 | + $s_complement = array_column( |
|
| 347 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 348 | + 'statut' |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 352 | + |
|
| 353 | + default: |
|
| 354 | + case 'tous': |
|
| 355 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 356 | + $s_complement = array_column( |
|
| 357 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 358 | + 'statut' |
|
| 359 | + ); |
|
| 360 | + $statut = array_merge($statut, $s_complement); |
|
| 361 | + if ($en_base) { |
|
| 362 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 363 | + $retire = array_diff($statut, $check); |
|
| 364 | + $statut = array_diff($statut, $retire); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + return array_unique($statut); |
|
| 368 | + } |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -381,28 +381,28 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 383 | 383 | |
| 384 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 385 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 386 | - ? '' |
|
| 387 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 388 | - |
|
| 389 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 390 | - if ($objet == 'rubrique') { |
|
| 391 | - $id_rubrique = 0; |
|
| 392 | - } else { |
|
| 393 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 397 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 398 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 399 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 400 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - return $id_rubrique; |
|
| 384 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 385 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 386 | + ? '' |
|
| 387 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 388 | + |
|
| 389 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 390 | + if ($objet == 'rubrique') { |
|
| 391 | + $id_rubrique = 0; |
|
| 392 | + } else { |
|
| 393 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 397 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 398 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 399 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 400 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + return $id_rubrique; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -413,12 +413,12 @@ discard block |
||
| 413 | 413 | * @return string |
| 414 | 414 | */ |
| 415 | 415 | function lien_article_virtuel($virtuel) { |
| 416 | - include_spip('inc/lien'); |
|
| 417 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 418 | - return ''; |
|
| 419 | - } |
|
| 416 | + include_spip('inc/lien'); |
|
| 417 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 418 | + return ''; |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - return propre('[->' . $virtuel . ']'); |
|
| 421 | + return propre('[->' . $virtuel . ']'); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | * @filtre |
| 442 | 442 | */ |
| 443 | 443 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 444 | - include_spip('inc/acces'); |
|
| 445 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 444 | + include_spip('inc/acces'); |
|
| 445 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 446 | 446 | |
| 447 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 448 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 447 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 448 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | |
@@ -457,76 +457,76 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function alertes_auteur($id_auteur): string { |
| 459 | 459 | |
| 460 | - $alertes = []; |
|
| 461 | - |
|
| 462 | - if ( |
|
| 463 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 464 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 465 | - ) { |
|
| 466 | - include_spip('genie/maintenance'); |
|
| 467 | - if ($msg = message_crash_tables()) { |
|
| 468 | - $alertes[] = $msg; |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if ( |
|
| 473 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 474 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 475 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 476 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 477 | - ) { |
|
| 478 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 479 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 483 | - if ( |
|
| 484 | - $a |
|
| 485 | - and is_array($a = unserialize($a)) |
|
| 486 | - and count($a) |
|
| 487 | - ) { |
|
| 488 | - $update = false; |
|
| 489 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 490 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 491 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - $update = true; |
|
| 493 | - } |
|
| 494 | - if (isset($a[''])) { |
|
| 495 | - $alertes = array_merge($alertes, $a['']); |
|
| 496 | - unset($a['']); |
|
| 497 | - $update = true; |
|
| 498 | - } |
|
| 499 | - if ($update) { |
|
| 500 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - if ( |
|
| 505 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 506 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 507 | - ) { |
|
| 508 | - include_spip('inc/plugin'); |
|
| 509 | - $alertes[] = plugin_donne_erreurs(); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - $alertes = pipeline( |
|
| 513 | - 'alertes_auteur', |
|
| 514 | - [ |
|
| 515 | - 'args' => [ |
|
| 516 | - 'id_auteur' => $id_auteur, |
|
| 517 | - 'exec' => _request('exec'), |
|
| 518 | - ], |
|
| 519 | - 'data' => $alertes |
|
| 520 | - ] |
|
| 521 | - ); |
|
| 522 | - |
|
| 523 | - if ($alertes = array_filter($alertes)) { |
|
| 524 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 525 | - join(' | ', $alertes) |
|
| 526 | - . '</div></div>'; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return ''; |
|
| 460 | + $alertes = []; |
|
| 461 | + |
|
| 462 | + if ( |
|
| 463 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 464 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 465 | + ) { |
|
| 466 | + include_spip('genie/maintenance'); |
|
| 467 | + if ($msg = message_crash_tables()) { |
|
| 468 | + $alertes[] = $msg; |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if ( |
|
| 473 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 474 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 475 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 476 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 477 | + ) { |
|
| 478 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 479 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 483 | + if ( |
|
| 484 | + $a |
|
| 485 | + and is_array($a = unserialize($a)) |
|
| 486 | + and count($a) |
|
| 487 | + ) { |
|
| 488 | + $update = false; |
|
| 489 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 490 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 491 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + $update = true; |
|
| 493 | + } |
|
| 494 | + if (isset($a[''])) { |
|
| 495 | + $alertes = array_merge($alertes, $a['']); |
|
| 496 | + unset($a['']); |
|
| 497 | + $update = true; |
|
| 498 | + } |
|
| 499 | + if ($update) { |
|
| 500 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + if ( |
|
| 505 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 506 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 507 | + ) { |
|
| 508 | + include_spip('inc/plugin'); |
|
| 509 | + $alertes[] = plugin_donne_erreurs(); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + $alertes = pipeline( |
|
| 513 | + 'alertes_auteur', |
|
| 514 | + [ |
|
| 515 | + 'args' => [ |
|
| 516 | + 'id_auteur' => $id_auteur, |
|
| 517 | + 'exec' => _request('exec'), |
|
| 518 | + ], |
|
| 519 | + 'data' => $alertes |
|
| 520 | + ] |
|
| 521 | + ); |
|
| 522 | + |
|
| 523 | + if ($alertes = array_filter($alertes)) { |
|
| 524 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 525 | + join(' | ', $alertes) |
|
| 526 | + . '</div></div>'; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return ''; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -536,9 +536,9 @@ discard block |
||
| 536 | 536 | * @return string |
| 537 | 537 | */ |
| 538 | 538 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 539 | - include_spip('inc/presenter_enfants'); |
|
| 539 | + include_spip('inc/presenter_enfants'); |
|
| 540 | 540 | |
| 541 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 541 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -556,15 +556,15 @@ discard block |
||
| 556 | 556 | * @return string |
| 557 | 557 | */ |
| 558 | 558 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 559 | - $titre = attribut_html($titre); |
|
| 560 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | - |
|
| 563 | - if (!$titre_lien) { |
|
| 564 | - return $icone; |
|
| 565 | - } else { |
|
| 566 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | - } |
|
| 559 | + $titre = attribut_html($titre); |
|
| 560 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | + |
|
| 563 | + if (!$titre_lien) { |
|
| 564 | + return $icone; |
|
| 565 | + } else { |
|
| 566 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | + } |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -583,17 +583,17 @@ discard block |
||
| 583 | 583 | * @return array |
| 584 | 584 | */ |
| 585 | 585 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 586 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 587 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 588 | - return []; |
|
| 589 | - } |
|
| 590 | - $r = reset($res); |
|
| 591 | - if (isset($r['rang_lien'])) { |
|
| 592 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 593 | - asort($l); |
|
| 594 | - $l = array_keys($l); |
|
| 595 | - } else { |
|
| 596 | - $l = array_column($res, $objet_source); |
|
| 597 | - } |
|
| 598 | - return $l; |
|
| 586 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 587 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 588 | + return []; |
|
| 589 | + } |
|
| 590 | + $r = reset($res); |
|
| 591 | + if (isset($r['rang_lien'])) { |
|
| 592 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 593 | + asort($l); |
|
| 594 | + $l = array_keys($l); |
|
| 595 | + } else { |
|
| 596 | + $l = array_column($res, $objet_source); |
|
| 597 | + } |
|
| 598 | + return $l; |
|
| 599 | 599 | } |