@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/autoriser'); |
@@ -34,42 +34,42 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function action_menu_rubriques_dist() { |
| 36 | 36 | |
| 37 | - // si pas acces a ecrire, pas acces au menu |
|
| 38 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 39 | - if (!autoriser('ecrire')) { |
|
| 40 | - $retour = |
|
| 41 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | - '</a>' . |
|
| 46 | - '</li>' . |
|
| 47 | - '</ul>'; |
|
| 48 | - include_spip('inc/actions'); |
|
| 49 | - ajax_retour($retour); |
|
| 50 | - exit; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if ($date = (int) _request('date')) { |
|
| 54 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $r = gen_liste_rubriques(); |
|
| 58 | - if ( |
|
| 59 | - !$r |
|
| 60 | - && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 61 | - && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 62 | - ) { |
|
| 63 | - include_spip('inc/headers'); |
|
| 64 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | - http_response_code(304); |
|
| 66 | - exit; |
|
| 67 | - } else { |
|
| 68 | - include_spip('inc/actions'); |
|
| 69 | - $ret = menu_rubriques(); |
|
| 70 | - ajax_retour($ret); |
|
| 71 | - exit; |
|
| 72 | - } |
|
| 37 | + // si pas acces a ecrire, pas acces au menu |
|
| 38 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 39 | + if (!autoriser('ecrire')) { |
|
| 40 | + $retour = |
|
| 41 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | + '</a>' . |
|
| 46 | + '</li>' . |
|
| 47 | + '</ul>'; |
|
| 48 | + include_spip('inc/actions'); |
|
| 49 | + ajax_retour($retour); |
|
| 50 | + exit; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if ($date = (int) _request('date')) { |
|
| 54 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $r = gen_liste_rubriques(); |
|
| 58 | + if ( |
|
| 59 | + !$r |
|
| 60 | + && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 61 | + && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 62 | + ) { |
|
| 63 | + include_spip('inc/headers'); |
|
| 64 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | + http_response_code(304); |
|
| 66 | + exit; |
|
| 67 | + } else { |
|
| 68 | + include_spip('inc/actions'); |
|
| 69 | + $ret = menu_rubriques(); |
|
| 70 | + ajax_retour($ret); |
|
| 71 | + exit; |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -83,44 +83,44 @@ discard block |
||
| 83 | 83 | * Code HTML présentant la liste des rubriques |
| 84 | 84 | **/ |
| 85 | 85 | function menu_rubriques($complet = true) { |
| 86 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 87 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 89 | - . '</a>' |
|
| 90 | - . '</li>'; |
|
| 91 | - |
|
| 92 | - if (!$complet) { |
|
| 93 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 97 | - gen_liste_rubriques(); |
|
| 98 | - } |
|
| 99 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 100 | - |
|
| 101 | - $total_lignes = $i = count($arr_low); |
|
| 102 | - |
|
| 103 | - if ($i > 0) { |
|
| 104 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 105 | - if ($nb_col <= 1) { |
|
| 106 | - $nb_col = ceil($total_lignes / 10); |
|
| 107 | - } |
|
| 108 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 109 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 110 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 111 | - $i++; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 116 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 117 | - . $ret |
|
| 118 | - . "\n</ul>\n"; |
|
| 119 | - } else { |
|
| 120 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $ret; |
|
| 86 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 87 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 89 | + . '</a>' |
|
| 90 | + . '</li>'; |
|
| 91 | + |
|
| 92 | + if (!$complet) { |
|
| 93 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 97 | + gen_liste_rubriques(); |
|
| 98 | + } |
|
| 99 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 100 | + |
|
| 101 | + $total_lignes = $i = count($arr_low); |
|
| 102 | + |
|
| 103 | + if ($i > 0) { |
|
| 104 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 105 | + if ($nb_col <= 1) { |
|
| 106 | + $nb_col = ceil($total_lignes / 10); |
|
| 107 | + } |
|
| 108 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 109 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 110 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 111 | + $i++; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 116 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 117 | + . $ret |
|
| 118 | + . "\n</ul>\n"; |
|
| 119 | + } else { |
|
| 120 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $ret; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -141,47 +141,47 @@ discard block |
||
| 141 | 141 | * Code HTML présentant la liste des rubriques |
| 142 | 142 | **/ |
| 143 | 143 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 144 | - static $zmax = 6; |
|
| 145 | - $profondeur_next = $profondeur + 1; |
|
| 146 | - |
|
| 147 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 149 | - . "</a>\n"; |
|
| 150 | - |
|
| 151 | - // Limiter volontairement le nombre de sous-menus |
|
| 152 | - if (!(--$zmax)) { |
|
| 153 | - $zmax++; |
|
| 154 | - |
|
| 155 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 159 | - $i = count($arr_rub); |
|
| 160 | - if (!$i) { |
|
| 161 | - $zmax++; |
|
| 162 | - |
|
| 163 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - $nb_col = 1; |
|
| 168 | - if ($nb_rub = count($arr_rub)) { |
|
| 169 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 170 | - } |
|
| 171 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 172 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 173 | - . $nav |
|
| 174 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 175 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 176 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 177 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 178 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 179 | - $i++; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - $zmax++; |
|
| 183 | - |
|
| 184 | - return $ret . "</ul></li>\n"; |
|
| 144 | + static $zmax = 6; |
|
| 145 | + $profondeur_next = $profondeur + 1; |
|
| 146 | + |
|
| 147 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 149 | + . "</a>\n"; |
|
| 150 | + |
|
| 151 | + // Limiter volontairement le nombre de sous-menus |
|
| 152 | + if (!(--$zmax)) { |
|
| 153 | + $zmax++; |
|
| 154 | + |
|
| 155 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 159 | + $i = count($arr_rub); |
|
| 160 | + if (!$i) { |
|
| 161 | + $zmax++; |
|
| 162 | + |
|
| 163 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + $nb_col = 1; |
|
| 168 | + if ($nb_rub = count($arr_rub)) { |
|
| 169 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 170 | + } |
|
| 171 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 172 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 173 | + . $nav |
|
| 174 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 175 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 176 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 177 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 178 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 179 | + $i++; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + $zmax++; |
|
| 183 | + |
|
| 184 | + return $ret . "</ul></li>\n"; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 200 | 200 | **/ |
| 201 | 201 | function extraire_article($id_p, $t) { |
| 202 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 202 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -215,42 +215,42 @@ discard block |
||
| 215 | 215 | **/ |
| 216 | 216 | function gen_liste_rubriques() { |
| 217 | 217 | |
| 218 | - $cache = null; |
|
| 219 | - include_spip('inc/config'); |
|
| 220 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 221 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 222 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 223 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 224 | - if ($date == $last) { |
|
| 225 | - return false; |
|
| 226 | - } // c'etait en cache :-) |
|
| 227 | - } |
|
| 228 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 229 | - |
|
| 230 | - $where = sql_in_select( |
|
| 231 | - 'id_rubrique', |
|
| 232 | - 'id_rubrique', |
|
| 233 | - 'spip_rubriques', |
|
| 234 | - '', |
|
| 235 | - '', |
|
| 236 | - 'id_parent=0 DESC, date DESC', |
|
| 237 | - _CACHE_RUBRIQUES_MAX |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 241 | - |
|
| 242 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 243 | - |
|
| 244 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 245 | - // car on met le resultat en cache, commun a tout le monde |
|
| 246 | - $GLOBALS['db_art_cache'] = []; |
|
| 247 | - while ($r = sql_fetch($res)) { |
|
| 248 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 249 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 253 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 254 | - |
|
| 255 | - return true; |
|
| 218 | + $cache = null; |
|
| 219 | + include_spip('inc/config'); |
|
| 220 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 221 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 222 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 223 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 224 | + if ($date == $last) { |
|
| 225 | + return false; |
|
| 226 | + } // c'etait en cache :-) |
|
| 227 | + } |
|
| 228 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 229 | + |
|
| 230 | + $where = sql_in_select( |
|
| 231 | + 'id_rubrique', |
|
| 232 | + 'id_rubrique', |
|
| 233 | + 'spip_rubriques', |
|
| 234 | + '', |
|
| 235 | + '', |
|
| 236 | + 'id_parent=0 DESC, date DESC', |
|
| 237 | + _CACHE_RUBRIQUES_MAX |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 241 | + |
|
| 242 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 243 | + |
|
| 244 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 245 | + // car on met le resultat en cache, commun a tout le monde |
|
| 246 | + $GLOBALS['db_art_cache'] = []; |
|
| 247 | + while ($r = sql_fetch($res)) { |
|
| 248 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 249 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 253 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 254 | + |
|
| 255 | + return true; |
|
| 256 | 256 | } |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
| 39 | 39 | if (!autoriser('ecrire')) { |
| 40 | 40 | $retour = |
| 41 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | - '</a>' . |
|
| 46 | - '</li>' . |
|
| 41 | + '<ul class="deroulant__sous-menu" data-profondeur="1">'. |
|
| 42 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">'. |
|
| 43 | + '<a class="deroulant__lien" href="'.generer_url_ecrire('accueil').'" data-profondeur="1">'. |
|
| 44 | + '<span class="libelle">'._T('public:lien_connecter').'</span>'. |
|
| 45 | + '</a>'. |
|
| 46 | + '</li>'. |
|
| 47 | 47 | '</ul>'; |
| 48 | 48 | include_spip('inc/actions'); |
| 49 | 49 | ajax_retour($retour); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ($date = (int) _request('date')) { |
| 54 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 54 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $r = gen_liste_rubriques(); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
| 62 | 62 | ) { |
| 63 | 63 | include_spip('inc/headers'); |
| 64 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 64 | + header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']); |
|
| 65 | 65 | http_response_code(304); |
| 66 | 66 | exit; |
| 67 | 67 | } else { |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | **/ |
| 85 | 85 | function menu_rubriques($complet = true) { |
| 86 | 86 | $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
| 87 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 87 | + . '<a class="deroulant__lien" href="'.generer_url_ecrire('plan').'" data-profondeur="1">' |
|
| 88 | + . '<span class="libelle">'._T('info_tout_site').'</span>' |
|
| 89 | 89 | . '</a>' |
| 90 | 90 | . '</li>'; |
| 91 | 91 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | static $zmax = 6; |
| 145 | 145 | $profondeur_next = $profondeur + 1; |
| 146 | 146 | |
| 147 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 147 | + $nav = '<a class="deroulant__lien" href="'.generer_objet_url($id_rubrique, 'rubrique', '', '', false)."\" data-profondeur=\"$profondeur\">" |
|
| 148 | + . '<span class="libelle">'.supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)).'</span>' |
|
| 149 | 149 | . "</a>\n"; |
| 150 | 150 | |
| 151 | 151 | // Limiter volontairement le nombre de sous-menus |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | $zmax++; |
| 183 | 183 | |
| 184 | - return $ret . "</ul></li>\n"; |
|
| 184 | + return $ret."</ul></li>\n"; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -31,28 +31,28 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_desinstaller_plugin_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 36 | - [$dir_plugins, $plugin] = explode('::', (string) $arg); |
|
| 37 | - $dir_type = '_DIR_PLUGINS'; |
|
| 38 | - if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 39 | - $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 40 | - } |
|
| 41 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 42 | - $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 43 | - if ($infos && !$infos['install_test'][0]) { |
|
| 44 | - include_spip('inc/plugin'); |
|
| 45 | - ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 46 | - $erreur = ''; |
|
| 47 | - } else { |
|
| 48 | - $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 49 | - } |
|
| 50 | - if ($redirect = _request('redirect')) { |
|
| 51 | - include_spip('inc/headers'); |
|
| 52 | - if ($erreur) { |
|
| 53 | - $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 54 | - } |
|
| 55 | - $redirect = str_replace('&', '&', (string) $redirect); |
|
| 56 | - redirige_par_entete($redirect); |
|
| 57 | - } |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | + [$dir_plugins, $plugin] = explode('::', (string) $arg); |
|
| 37 | + $dir_type = '_DIR_PLUGINS'; |
|
| 38 | + if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 39 | + $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 40 | + } |
|
| 41 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 42 | + $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 43 | + if ($infos && !$infos['install_test'][0]) { |
|
| 44 | + include_spip('inc/plugin'); |
|
| 45 | + ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 46 | + $erreur = ''; |
|
| 47 | + } else { |
|
| 48 | + $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 49 | + } |
|
| 50 | + if ($redirect = _request('redirect')) { |
|
| 51 | + include_spip('inc/headers'); |
|
| 52 | + if ($erreur) { |
|
| 53 | + $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 54 | + } |
|
| 55 | + $redirect = str_replace('&', '&', (string) $redirect); |
|
| 56 | + redirige_par_entete($redirect); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -28,24 +28,24 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function action_instituer_objet_dist($arg = null) { |
| 30 | 30 | |
| 31 | - if (is_null($arg)) { |
|
| 32 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | - $arg = $securiser_action(); |
|
| 34 | - } |
|
| 31 | + if (is_null($arg)) { |
|
| 32 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | + $arg = $securiser_action(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - [$objet, $id_objet, $statut] = preg_split('/\W/', (string) $arg); |
|
| 37 | - if (!$statut) { |
|
| 38 | - $statut = _request('statut_nouv'); |
|
| 39 | - } // cas POST |
|
| 40 | - if (!$statut) { |
|
| 41 | - return; |
|
| 42 | - } // impossible mais sait-on jamais |
|
| 36 | + [$objet, $id_objet, $statut] = preg_split('/\W/', (string) $arg); |
|
| 37 | + if (!$statut) { |
|
| 38 | + $statut = _request('statut_nouv'); |
|
| 39 | + } // cas POST |
|
| 40 | + if (!$statut) { |
|
| 41 | + return; |
|
| 42 | + } // impossible mais sait-on jamais |
|
| 43 | 43 | |
| 44 | - if ( |
|
| 45 | - ($id_objet = (int) $id_objet) |
|
| 46 | - && autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut]) |
|
| 47 | - ) { |
|
| 48 | - include_spip('action/editer_objet'); |
|
| 49 | - objet_modifier($objet, $id_objet, ['statut' => $statut]); |
|
| 50 | - } |
|
| 44 | + if ( |
|
| 45 | + ($id_objet = (int) $id_objet) |
|
| 46 | + && autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut]) |
|
| 47 | + ) { |
|
| 48 | + include_spip('action/editer_objet'); |
|
| 49 | + objet_modifier($objet, $id_objet, ['statut' => $statut]); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | 27 | function action_annuler_job_dist() { |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $id_job = $securiser_action(); |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $id_job = $securiser_action(); |
|
| 30 | 30 | |
| 31 | - if ( |
|
| 32 | - ($id_job = (int) $id_job) |
|
| 33 | - && autoriser('annuler', 'job', $id_job) |
|
| 34 | - ) { |
|
| 35 | - job_queue_remove($id_job); |
|
| 36 | - } |
|
| 31 | + if ( |
|
| 32 | + ($id_job = (int) $id_job) |
|
| 33 | + && autoriser('annuler', 'job', $id_job) |
|
| 34 | + ) { |
|
| 35 | + job_queue_remove($id_job); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -15,98 +15,98 @@ |
||
| 15 | 15 | * Collecte les raccourcis liens [titre->url] de SPIP |
| 16 | 16 | */ |
| 17 | 17 | class Liens extends AbstractCollecteur { |
| 18 | - protected static string $markPrefix = 'LIEN'; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * La preg pour découper et collecter les modèles |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected string $preg_lien; |
|
| 25 | - |
|
| 26 | - public function __construct(?string $preg = null) { |
|
| 27 | - |
|
| 28 | - // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
|
| 29 | - // Laisser passer des paires de crochets pour la balise multi |
|
| 30 | - // mais refuser plus d'imbrications ou de mauvaises imbrications |
|
| 31 | - // sinon les crochets ne peuvent plus servir qu'a ce type de raccourci |
|
| 32 | - $this->preg_lien = ($preg ?: '/\[([^][]*?([[][^]>-]*[]][^][]*)*)->(>?)([^]]*)\]/msS'); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Sanitizer une collection d'occurences de liens : il faut sanitizer le href et le texte uniquement |
|
| 38 | - * |
|
| 39 | - * @param array $collection |
|
| 40 | - * @param string $sanitize_callback |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - protected function sanitizer_collection(array $collection, string $sanitize_callback): array { |
|
| 44 | - foreach ($collection as &$lien) { |
|
| 45 | - $t = $sanitize_callback($lien['texte']); |
|
| 46 | - if ($t !== $lien['texte']) { |
|
| 47 | - $lien['raw'] = str_replace($lien['texte'], $t, (string) $lien['raw']); |
|
| 48 | - $lien['texte'] = $t; |
|
| 49 | - } |
|
| 50 | - $href = $sanitize_callback($lien['href']); |
|
| 51 | - if ($href !== $lien['href']) { |
|
| 52 | - $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 53 | - $lien['href'] = $href; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - return $collection; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @param string $texte |
|
| 62 | - * @param array $options |
|
| 63 | - * bool $collecter_liens |
|
| 64 | - * @return array |
|
| 65 | - */ |
|
| 66 | - public function collecter(string $texte, array $options = []): array { |
|
| 67 | - if (!$texte) { |
|
| 68 | - return []; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $liens = []; |
|
| 72 | - if (str_contains($texte, '->')) { |
|
| 73 | - $desechappe_crochets = false; |
|
| 74 | - // si il y a un crochet ouvrant échappé ou un crochet fermant échappé, les substituer pour les ignorer |
|
| 75 | - if (str_contains($texte, '\[') || str_contains($texte, '\]')) { |
|
| 76 | - $texte = str_replace(['\[', '\]'], ["\x1\x5", "\x1\x6"], $texte); |
|
| 77 | - $desechappe_crochets = true; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // collecter les matchs de la preg |
|
| 81 | - $liens = static::collecteur($texte, '->', '[', $this->preg_lien, empty($options['detecter_presence']) ? 0 : 1); |
|
| 82 | - |
|
| 83 | - // si on veut seulement detecter la présence, on peut retourner tel quel |
|
| 84 | - if (empty($options['detecter_presence'])) { |
|
| 85 | - foreach ($liens as $k => &$lien) { |
|
| 86 | - $lien['href'] = end($lien['match']); |
|
| 87 | - $lien['texte'] = $lien['match'][1]; |
|
| 88 | - $lien['ouvrant'] = $lien['match'][3] ?? ''; |
|
| 89 | - |
|
| 90 | - // la mise en lien automatique est passee par la a tort ! |
|
| 91 | - // corrigeons pour eviter d'avoir un <a...> dans un href... |
|
| 92 | - if (str_starts_with((string) $lien['href'], '<a')) { |
|
| 93 | - $href = extraire_attribut($lien['href'], 'href'); |
|
| 94 | - // remplacons dans la source qui peut etre reinjectee dans les arguments |
|
| 95 | - // d'un modele |
|
| 96 | - $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 97 | - // et prenons le href comme la vraie url a linker |
|
| 98 | - $lien['href'] = $href; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - if ($desechappe_crochets && str_contains((string) $lien['raw'], "\x1")) { |
|
| 102 | - $lien['raw'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['raw']); |
|
| 103 | - $lien['texte'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['texte']); |
|
| 104 | - $lien['href'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['href']); |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return $liens; |
|
| 111 | - } |
|
| 18 | + protected static string $markPrefix = 'LIEN'; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * La preg pour découper et collecter les modèles |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected string $preg_lien; |
|
| 25 | + |
|
| 26 | + public function __construct(?string $preg = null) { |
|
| 27 | + |
|
| 28 | + // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
|
| 29 | + // Laisser passer des paires de crochets pour la balise multi |
|
| 30 | + // mais refuser plus d'imbrications ou de mauvaises imbrications |
|
| 31 | + // sinon les crochets ne peuvent plus servir qu'a ce type de raccourci |
|
| 32 | + $this->preg_lien = ($preg ?: '/\[([^][]*?([[][^]>-]*[]][^][]*)*)->(>?)([^]]*)\]/msS'); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Sanitizer une collection d'occurences de liens : il faut sanitizer le href et le texte uniquement |
|
| 38 | + * |
|
| 39 | + * @param array $collection |
|
| 40 | + * @param string $sanitize_callback |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + protected function sanitizer_collection(array $collection, string $sanitize_callback): array { |
|
| 44 | + foreach ($collection as &$lien) { |
|
| 45 | + $t = $sanitize_callback($lien['texte']); |
|
| 46 | + if ($t !== $lien['texte']) { |
|
| 47 | + $lien['raw'] = str_replace($lien['texte'], $t, (string) $lien['raw']); |
|
| 48 | + $lien['texte'] = $t; |
|
| 49 | + } |
|
| 50 | + $href = $sanitize_callback($lien['href']); |
|
| 51 | + if ($href !== $lien['href']) { |
|
| 52 | + $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 53 | + $lien['href'] = $href; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + return $collection; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param string $texte |
|
| 62 | + * @param array $options |
|
| 63 | + * bool $collecter_liens |
|
| 64 | + * @return array |
|
| 65 | + */ |
|
| 66 | + public function collecter(string $texte, array $options = []): array { |
|
| 67 | + if (!$texte) { |
|
| 68 | + return []; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $liens = []; |
|
| 72 | + if (str_contains($texte, '->')) { |
|
| 73 | + $desechappe_crochets = false; |
|
| 74 | + // si il y a un crochet ouvrant échappé ou un crochet fermant échappé, les substituer pour les ignorer |
|
| 75 | + if (str_contains($texte, '\[') || str_contains($texte, '\]')) { |
|
| 76 | + $texte = str_replace(['\[', '\]'], ["\x1\x5", "\x1\x6"], $texte); |
|
| 77 | + $desechappe_crochets = true; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // collecter les matchs de la preg |
|
| 81 | + $liens = static::collecteur($texte, '->', '[', $this->preg_lien, empty($options['detecter_presence']) ? 0 : 1); |
|
| 82 | + |
|
| 83 | + // si on veut seulement detecter la présence, on peut retourner tel quel |
|
| 84 | + if (empty($options['detecter_presence'])) { |
|
| 85 | + foreach ($liens as $k => &$lien) { |
|
| 86 | + $lien['href'] = end($lien['match']); |
|
| 87 | + $lien['texte'] = $lien['match'][1]; |
|
| 88 | + $lien['ouvrant'] = $lien['match'][3] ?? ''; |
|
| 89 | + |
|
| 90 | + // la mise en lien automatique est passee par la a tort ! |
|
| 91 | + // corrigeons pour eviter d'avoir un <a...> dans un href... |
|
| 92 | + if (str_starts_with((string) $lien['href'], '<a')) { |
|
| 93 | + $href = extraire_attribut($lien['href'], 'href'); |
|
| 94 | + // remplacons dans la source qui peut etre reinjectee dans les arguments |
|
| 95 | + // d'un modele |
|
| 96 | + $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 97 | + // et prenons le href comme la vraie url a linker |
|
| 98 | + $lien['href'] = $href; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + if ($desechappe_crochets && str_contains((string) $lien['raw'], "\x1")) { |
|
| 102 | + $lien['raw'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['raw']); |
|
| 103 | + $lien['texte'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['texte']); |
|
| 104 | + $lien['href'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['href']); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return $liens; |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $page_title = ($options['page_title'] ?? $GLOBALS['meta']['nom_site']); |
| 67 | 67 | $doctype = ($options['doctype'] ?? '<!DOCTYPE html>'); |
| 68 | - $doctype = trim((string) $doctype) . "\n"; |
|
| 68 | + $doctype = trim((string) $doctype)."\n"; |
|
| 69 | 69 | $charset = ($options['charset'] ?? 'utf-8'); |
| 70 | 70 | $all_inline = ($options['all_inline'] ?? true); |
| 71 | 71 | $onLoad = ($options['onLoad'] ?? ''); |
| 72 | 72 | if ($onLoad) { |
| 73 | - $onLoad = ' onload="' . attribut_html($onLoad) . '"'; |
|
| 73 | + $onLoad = ' onload="'.attribut_html($onLoad).'"'; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | # envoyer le charset |
| 77 | 77 | if (!headers_sent()) { |
| 78 | - header('Content-Type: text/html; charset=' . $charset); |
|
| 78 | + header('Content-Type: text/html; charset='.$charset); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $css = ''; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | . "--minipage-color-theme--s: $s;" |
| 95 | 95 | . "--minipage-color-theme--l: $l;}"; |
| 96 | 96 | $vars = file_get_contents(find_in_theme('minipage.vars.css')); |
| 97 | - $inline .= "\n" . trim($vars); |
|
| 97 | + $inline .= "\n".trim($vars); |
|
| 98 | 98 | if (function_exists('minifier')) { |
| 99 | 99 | $inline = minifier($inline, 'css'); |
| 100 | 100 | } |
@@ -121,31 +121,31 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | $css = "$inline\n$css"; |
| 123 | 123 | if (!empty($options['css'])) { |
| 124 | - $css .= "\n" . $options['css']; |
|
| 124 | + $css .= "\n".$options['css']; |
|
| 125 | 125 | } |
| 126 | 126 | $css = "<style type='text/css'>$css</style>"; |
| 127 | 127 | } else { |
| 128 | 128 | $css = "<style type='text/css'>$inline</style>"; |
| 129 | 129 | foreach ($files as $name) { |
| 130 | 130 | $file = timestamp(direction_css($name)); |
| 131 | - $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n"; |
|
| 131 | + $css .= "<link rel='stylesheet' href='".attribut_html($file)."' type='text/css' />\n"; |
|
| 132 | 132 | } |
| 133 | 133 | if (!empty($options['css'])) { |
| 134 | - $css .= "<style type='text/css'>" . $options['css'] . '</style>'; |
|
| 134 | + $css .= "<style type='text/css'>".$options['css'].'</style>'; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - return $doctype . |
|
| 139 | - html_lang_attributes() . |
|
| 140 | - "<head>\n" . |
|
| 141 | - '<title>' . |
|
| 142 | - textebrut($page_title) . |
|
| 143 | - "</title>\n" . |
|
| 144 | - "<meta name=\"viewport\" content=\"width=device-width\" />\n" . |
|
| 145 | - $css . |
|
| 146 | - (empty($options['head']) ? '' : $options['head']) . |
|
| 147 | - "</head>\n" . |
|
| 148 | - "<body{$onLoad} class=\"minipage" . ($this::TYPE ? ' minipage--' . $this::TYPE : '') . "\">\n" . |
|
| 138 | + return $doctype. |
|
| 139 | + html_lang_attributes(). |
|
| 140 | + "<head>\n". |
|
| 141 | + '<title>'. |
|
| 142 | + textebrut($page_title). |
|
| 143 | + "</title>\n". |
|
| 144 | + "<meta name=\"viewport\" content=\"width=device-width\" />\n". |
|
| 145 | + $css. |
|
| 146 | + (empty($options['head']) ? '' : $options['head']). |
|
| 147 | + "</head>\n". |
|
| 148 | + "<body{$onLoad} class=\"minipage".($this::TYPE ? ' minipage--'.$this::TYPE : '')."\">\n". |
|
| 149 | 149 | "\t<div class=\"minipage-bloc\">\n"; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function ouvreCorps($options = []) { |
| 158 | 158 | $url_site = url_de_base(); |
| 159 | - $header = "<header>\n" . |
|
| 160 | - '<h1><a href="' . attribut_html($url_site) . '">' . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n"; |
|
| 159 | + $header = "<header>\n". |
|
| 160 | + '<h1><a href="'.attribut_html($url_site).'">'.interdire_scripts($GLOBALS['meta']['nom_site'] ?? '')."</a></h1>\n"; |
|
| 161 | 161 | |
| 162 | 162 | $titre = ($options['titre'] ?? ''); |
| 163 | 163 | if ($titre) { |
| 164 | - $header .= '<h2>' . interdire_scripts($titre) . '</h2>'; |
|
| 164 | + $header .= '<h2>'.interdire_scripts($titre).'</h2>'; |
|
| 165 | 165 | } |
| 166 | 166 | $header .= '</header>'; |
| 167 | 167 | |
| 168 | - return $header . "<div class='corps'>\n"; |
|
| 168 | + return $header."<div class='corps'>\n"; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | if (isset($options['footer'])) { |
| 180 | 180 | $footer = $options['footer']; |
| 181 | 181 | } else { |
| 182 | - $footer = '<a href="' . attribut_html($url_site) . '">' . _T('retour') . "</a>\n"; |
|
| 182 | + $footer = '<a href="'.attribut_html($url_site).'">'._T('retour')."</a>\n"; |
|
| 183 | 183 | } |
| 184 | 184 | if (!empty($footer)) { |
| 185 | 185 | $footer = "<footer>\n{$footer}</footer>"; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - return "</div>\n" . $footer; |
|
| 188 | + return "</div>\n".$footer; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -15,265 +15,265 @@ |
||
| 15 | 15 | * Présentation des pages simplifiées |
| 16 | 16 | **/ |
| 17 | 17 | abstract class AbstractPage { |
| 18 | - public const TYPE = ''; |
|
| 18 | + public const TYPE = ''; |
|
| 19 | 19 | |
| 20 | - public function __construct() { |
|
| 21 | - include_fichiers_fonctions(); |
|
| 22 | - include_spip('inc/headers'); |
|
| 23 | - include_spip('inc/texte'); //inclue inc/lang et inc/filtres |
|
| 24 | - include_spip('inc/filtres_images_mini'); |
|
| 25 | - } |
|
| 20 | + public function __construct() { |
|
| 21 | + include_fichiers_fonctions(); |
|
| 22 | + include_spip('inc/headers'); |
|
| 23 | + include_spip('inc/texte'); //inclue inc/lang et inc/filtres |
|
| 24 | + include_spip('inc/filtres_images_mini'); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Retourne le début d'une page HTML minimale |
|
| 29 | - * |
|
| 30 | - * Le contenu de CSS minimales (reset.css, clear.css, minipage.css) est inséré |
|
| 31 | - * dans une balise script inline (compactée si possible) |
|
| 32 | - * |
|
| 33 | - * @param array $options |
|
| 34 | - * string $lang : forcer la langue utilisateur |
|
| 35 | - * string $page_title : titre éventuel de la page (nom du site par défaut) |
|
| 36 | - * string $couleur_fond : pour la couleur dominante de la page (par défaut on reprend le réglage de la page de login) |
|
| 37 | - * bool $all_inline : inliner les CSS pour envoyer toute la page en 1 hit |
|
| 38 | - * string $doctype |
|
| 39 | - * string $charset |
|
| 40 | - * string $onload |
|
| 41 | - * array $css_files : ajouter des fichiers css |
|
| 42 | - * string $css : ajouter du CSS inline |
|
| 43 | - * string $head : contenu à ajouter à la fin <head> (pour inclusion de JS ou JS inline...) |
|
| 44 | - * @return string |
|
| 45 | - * Code HTML |
|
| 46 | - * |
|
| 47 | - * @uses html_lang_attributes() |
|
| 48 | - * @uses minifier() si le plugin compresseur est présent |
|
| 49 | - * @uses url_absolue_css() |
|
| 50 | - * |
|
| 51 | - * @uses utiliser_langue_visiteur() |
|
| 52 | - * @uses http_no_cache() |
|
| 53 | - */ |
|
| 54 | - protected function ouvreBody($options = []) { |
|
| 55 | - $h = null; |
|
| 56 | - $s = null; |
|
| 57 | - $l = null; |
|
| 58 | - if (empty($options['lang'])) { |
|
| 59 | - // on se limite sur une langue de $GLOBALS['meta']['langues_multilingue'] car on est dans le public |
|
| 60 | - utiliser_langue_visiteur($GLOBALS['meta']['langues_multilingue'] ?? null); |
|
| 61 | - } else { |
|
| 62 | - changer_langue($options['lang']); |
|
| 63 | - } |
|
| 64 | - http_no_cache(); |
|
| 27 | + /** |
|
| 28 | + * Retourne le début d'une page HTML minimale |
|
| 29 | + * |
|
| 30 | + * Le contenu de CSS minimales (reset.css, clear.css, minipage.css) est inséré |
|
| 31 | + * dans une balise script inline (compactée si possible) |
|
| 32 | + * |
|
| 33 | + * @param array $options |
|
| 34 | + * string $lang : forcer la langue utilisateur |
|
| 35 | + * string $page_title : titre éventuel de la page (nom du site par défaut) |
|
| 36 | + * string $couleur_fond : pour la couleur dominante de la page (par défaut on reprend le réglage de la page de login) |
|
| 37 | + * bool $all_inline : inliner les CSS pour envoyer toute la page en 1 hit |
|
| 38 | + * string $doctype |
|
| 39 | + * string $charset |
|
| 40 | + * string $onload |
|
| 41 | + * array $css_files : ajouter des fichiers css |
|
| 42 | + * string $css : ajouter du CSS inline |
|
| 43 | + * string $head : contenu à ajouter à la fin <head> (pour inclusion de JS ou JS inline...) |
|
| 44 | + * @return string |
|
| 45 | + * Code HTML |
|
| 46 | + * |
|
| 47 | + * @uses html_lang_attributes() |
|
| 48 | + * @uses minifier() si le plugin compresseur est présent |
|
| 49 | + * @uses url_absolue_css() |
|
| 50 | + * |
|
| 51 | + * @uses utiliser_langue_visiteur() |
|
| 52 | + * @uses http_no_cache() |
|
| 53 | + */ |
|
| 54 | + protected function ouvreBody($options = []) { |
|
| 55 | + $h = null; |
|
| 56 | + $s = null; |
|
| 57 | + $l = null; |
|
| 58 | + if (empty($options['lang'])) { |
|
| 59 | + // on se limite sur une langue de $GLOBALS['meta']['langues_multilingue'] car on est dans le public |
|
| 60 | + utiliser_langue_visiteur($GLOBALS['meta']['langues_multilingue'] ?? null); |
|
| 61 | + } else { |
|
| 62 | + changer_langue($options['lang']); |
|
| 63 | + } |
|
| 64 | + http_no_cache(); |
|
| 65 | 65 | |
| 66 | - $page_title = ($options['page_title'] ?? $GLOBALS['meta']['nom_site']); |
|
| 67 | - $doctype = ($options['doctype'] ?? '<!DOCTYPE html>'); |
|
| 68 | - $doctype = trim((string) $doctype) . "\n"; |
|
| 69 | - $charset = ($options['charset'] ?? 'utf-8'); |
|
| 70 | - $all_inline = ($options['all_inline'] ?? true); |
|
| 71 | - $onLoad = ($options['onLoad'] ?? ''); |
|
| 72 | - if ($onLoad) { |
|
| 73 | - $onLoad = ' onload="' . attribut_html($onLoad) . '"'; |
|
| 74 | - } |
|
| 66 | + $page_title = ($options['page_title'] ?? $GLOBALS['meta']['nom_site']); |
|
| 67 | + $doctype = ($options['doctype'] ?? '<!DOCTYPE html>'); |
|
| 68 | + $doctype = trim((string) $doctype) . "\n"; |
|
| 69 | + $charset = ($options['charset'] ?? 'utf-8'); |
|
| 70 | + $all_inline = ($options['all_inline'] ?? true); |
|
| 71 | + $onLoad = ($options['onLoad'] ?? ''); |
|
| 72 | + if ($onLoad) { |
|
| 73 | + $onLoad = ' onload="' . attribut_html($onLoad) . '"'; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - # envoyer le charset |
|
| 77 | - if (!headers_sent()) { |
|
| 78 | - header('Content-Type: text/html; charset=' . $charset); |
|
| 79 | - } |
|
| 76 | + # envoyer le charset |
|
| 77 | + if (!headers_sent()) { |
|
| 78 | + header('Content-Type: text/html; charset=' . $charset); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $css = ''; |
|
| 81 | + $css = ''; |
|
| 82 | 82 | |
| 83 | - if (function_exists('couleur_hex_to_hsl')) { |
|
| 84 | - $couleur_fond = empty($options['couleur_fond']) |
|
| 85 | - ? lire_config('couleur_login', '#db1762') |
|
| 86 | - : $options['couleur_fond']; |
|
| 87 | - $h = couleur_hex_to_hsl($couleur_fond, 'h'); |
|
| 88 | - $s = couleur_hex_to_hsl($couleur_fond, 's'); |
|
| 89 | - $l = couleur_hex_to_hsl($couleur_fond, 'l'); |
|
| 90 | - } |
|
| 83 | + if (function_exists('couleur_hex_to_hsl')) { |
|
| 84 | + $couleur_fond = empty($options['couleur_fond']) |
|
| 85 | + ? lire_config('couleur_login', '#db1762') |
|
| 86 | + : $options['couleur_fond']; |
|
| 87 | + $h = couleur_hex_to_hsl($couleur_fond, 'h'); |
|
| 88 | + $s = couleur_hex_to_hsl($couleur_fond, 's'); |
|
| 89 | + $l = couleur_hex_to_hsl($couleur_fond, 'l'); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $inline = ':root {' |
|
| 93 | - . "--minipage-color-theme--h: $h;" |
|
| 94 | - . "--minipage-color-theme--s: $s;" |
|
| 95 | - . "--minipage-color-theme--l: $l;}"; |
|
| 96 | - $vars = file_get_contents(find_in_theme('minipage.vars.css')); |
|
| 97 | - $inline .= "\n" . trim($vars); |
|
| 98 | - if (function_exists('minifier')) { |
|
| 99 | - $inline = minifier($inline, 'css'); |
|
| 100 | - } |
|
| 101 | - $files = [ |
|
| 102 | - find_in_theme('reset.css'), |
|
| 103 | - find_in_theme('clear.css'), |
|
| 104 | - find_in_theme('minipage.css'), |
|
| 105 | - ]; |
|
| 106 | - if (!empty($options['css_files'])) { |
|
| 107 | - foreach ($options['css_files'] as $css_file) { |
|
| 108 | - $files[] = $css_file; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - if ($all_inline) { |
|
| 112 | - // inliner les CSS (optimisation de la page minipage qui passe en un seul hit a la demande) |
|
| 113 | - foreach ($files as $name) { |
|
| 114 | - $file = direction_css($name); |
|
| 115 | - if (function_exists('minifier')) { |
|
| 116 | - $file = minifier($file); |
|
| 117 | - } else { |
|
| 118 | - $file = url_absolue_css($file); // precaution |
|
| 119 | - } |
|
| 120 | - $css .= file_get_contents($file); |
|
| 121 | - } |
|
| 122 | - $css = "$inline\n$css"; |
|
| 123 | - if (!empty($options['css'])) { |
|
| 124 | - $css .= "\n" . $options['css']; |
|
| 125 | - } |
|
| 126 | - $css = "<style type='text/css'>$css</style>"; |
|
| 127 | - } else { |
|
| 128 | - $css = "<style type='text/css'>$inline</style>"; |
|
| 129 | - foreach ($files as $name) { |
|
| 130 | - $file = timestamp(direction_css($name)); |
|
| 131 | - $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n"; |
|
| 132 | - } |
|
| 133 | - if (!empty($options['css'])) { |
|
| 134 | - $css .= "<style type='text/css'>" . $options['css'] . '</style>'; |
|
| 135 | - } |
|
| 136 | - } |
|
| 92 | + $inline = ':root {' |
|
| 93 | + . "--minipage-color-theme--h: $h;" |
|
| 94 | + . "--minipage-color-theme--s: $s;" |
|
| 95 | + . "--minipage-color-theme--l: $l;}"; |
|
| 96 | + $vars = file_get_contents(find_in_theme('minipage.vars.css')); |
|
| 97 | + $inline .= "\n" . trim($vars); |
|
| 98 | + if (function_exists('minifier')) { |
|
| 99 | + $inline = minifier($inline, 'css'); |
|
| 100 | + } |
|
| 101 | + $files = [ |
|
| 102 | + find_in_theme('reset.css'), |
|
| 103 | + find_in_theme('clear.css'), |
|
| 104 | + find_in_theme('minipage.css'), |
|
| 105 | + ]; |
|
| 106 | + if (!empty($options['css_files'])) { |
|
| 107 | + foreach ($options['css_files'] as $css_file) { |
|
| 108 | + $files[] = $css_file; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + if ($all_inline) { |
|
| 112 | + // inliner les CSS (optimisation de la page minipage qui passe en un seul hit a la demande) |
|
| 113 | + foreach ($files as $name) { |
|
| 114 | + $file = direction_css($name); |
|
| 115 | + if (function_exists('minifier')) { |
|
| 116 | + $file = minifier($file); |
|
| 117 | + } else { |
|
| 118 | + $file = url_absolue_css($file); // precaution |
|
| 119 | + } |
|
| 120 | + $css .= file_get_contents($file); |
|
| 121 | + } |
|
| 122 | + $css = "$inline\n$css"; |
|
| 123 | + if (!empty($options['css'])) { |
|
| 124 | + $css .= "\n" . $options['css']; |
|
| 125 | + } |
|
| 126 | + $css = "<style type='text/css'>$css</style>"; |
|
| 127 | + } else { |
|
| 128 | + $css = "<style type='text/css'>$inline</style>"; |
|
| 129 | + foreach ($files as $name) { |
|
| 130 | + $file = timestamp(direction_css($name)); |
|
| 131 | + $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n"; |
|
| 132 | + } |
|
| 133 | + if (!empty($options['css'])) { |
|
| 134 | + $css .= "<style type='text/css'>" . $options['css'] . '</style>'; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - return $doctype . |
|
| 139 | - html_lang_attributes() . |
|
| 140 | - "<head>\n" . |
|
| 141 | - '<title>' . |
|
| 142 | - textebrut($page_title) . |
|
| 143 | - "</title>\n" . |
|
| 144 | - "<meta name=\"viewport\" content=\"width=device-width\" />\n" . |
|
| 145 | - $css . |
|
| 146 | - (empty($options['head']) ? '' : $options['head']) . |
|
| 147 | - "</head>\n" . |
|
| 148 | - "<body{$onLoad} class=\"minipage" . ($this::TYPE ? ' minipage--' . $this::TYPE : '') . "\">\n" . |
|
| 149 | - "\t<div class=\"minipage-bloc\">\n"; |
|
| 150 | - } |
|
| 138 | + return $doctype . |
|
| 139 | + html_lang_attributes() . |
|
| 140 | + "<head>\n" . |
|
| 141 | + '<title>' . |
|
| 142 | + textebrut($page_title) . |
|
| 143 | + "</title>\n" . |
|
| 144 | + "<meta name=\"viewport\" content=\"width=device-width\" />\n" . |
|
| 145 | + $css . |
|
| 146 | + (empty($options['head']) ? '' : $options['head']) . |
|
| 147 | + "</head>\n" . |
|
| 148 | + "<body{$onLoad} class=\"minipage" . ($this::TYPE ? ' minipage--' . $this::TYPE : '') . "\">\n" . |
|
| 149 | + "\t<div class=\"minipage-bloc\">\n"; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Ouvre le corps : affiche le header avec un éventuel titre + ouvre le div corps |
|
| 154 | - * @param array options |
|
| 155 | - * @return string |
|
| 156 | - */ |
|
| 157 | - protected function ouvreCorps($options = []) { |
|
| 158 | - $url_site = url_de_base(); |
|
| 159 | - $header = "<header>\n" . |
|
| 160 | - '<h1><a href="' . attribut_html($url_site) . '">' . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n"; |
|
| 152 | + /** |
|
| 153 | + * Ouvre le corps : affiche le header avec un éventuel titre + ouvre le div corps |
|
| 154 | + * @param array options |
|
| 155 | + * @return string |
|
| 156 | + */ |
|
| 157 | + protected function ouvreCorps($options = []) { |
|
| 158 | + $url_site = url_de_base(); |
|
| 159 | + $header = "<header>\n" . |
|
| 160 | + '<h1><a href="' . attribut_html($url_site) . '">' . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n"; |
|
| 161 | 161 | |
| 162 | - $titre = ($options['titre'] ?? ''); |
|
| 163 | - if ($titre) { |
|
| 164 | - $header .= '<h2>' . interdire_scripts($titre) . '</h2>'; |
|
| 165 | - } |
|
| 166 | - $header .= '</header>'; |
|
| 162 | + $titre = ($options['titre'] ?? ''); |
|
| 163 | + if ($titre) { |
|
| 164 | + $header .= '<h2>' . interdire_scripts($titre) . '</h2>'; |
|
| 165 | + } |
|
| 166 | + $header .= '</header>'; |
|
| 167 | 167 | |
| 168 | - return $header . "<div class='corps'>\n"; |
|
| 169 | - } |
|
| 168 | + return $header . "<div class='corps'>\n"; |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Ferme le corps : affiche le footer par défaut ou custom et ferme le div corps |
|
| 173 | - * @param array $options |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - protected function fermeCorps($options = []) { |
|
| 177 | - $url_site = url_de_base(); |
|
| 171 | + /** |
|
| 172 | + * Ferme le corps : affiche le footer par défaut ou custom et ferme le div corps |
|
| 173 | + * @param array $options |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + protected function fermeCorps($options = []) { |
|
| 177 | + $url_site = url_de_base(); |
|
| 178 | 178 | |
| 179 | - if (isset($options['footer'])) { |
|
| 180 | - $footer = $options['footer']; |
|
| 181 | - } else { |
|
| 182 | - $footer = '<a href="' . attribut_html($url_site) . '">' . _T('retour') . "</a>\n"; |
|
| 183 | - } |
|
| 184 | - if (!empty($footer)) { |
|
| 185 | - $footer = "<footer>\n{$footer}</footer>"; |
|
| 186 | - } |
|
| 179 | + if (isset($options['footer'])) { |
|
| 180 | + $footer = $options['footer']; |
|
| 181 | + } else { |
|
| 182 | + $footer = '<a href="' . attribut_html($url_site) . '">' . _T('retour') . "</a>\n"; |
|
| 183 | + } |
|
| 184 | + if (!empty($footer)) { |
|
| 185 | + $footer = "<footer>\n{$footer}</footer>"; |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - return "</div>\n" . $footer; |
|
| 189 | - } |
|
| 188 | + return "</div>\n" . $footer; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Retourne la fin d'une page HTML minimale |
|
| 194 | - * |
|
| 195 | - * @return string Code HTML |
|
| 196 | - */ |
|
| 197 | - protected function fermeBody() { |
|
| 198 | - return "\n\t</div>\n</body>\n</html>"; |
|
| 199 | - } |
|
| 192 | + /** |
|
| 193 | + * Retourne la fin d'une page HTML minimale |
|
| 194 | + * |
|
| 195 | + * @return string Code HTML |
|
| 196 | + */ |
|
| 197 | + protected function fermeBody() { |
|
| 198 | + return "\n\t</div>\n</body>\n</html>"; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * Retourne une page HTML contenant, dans une présentation minimale, |
|
| 204 | - * le contenu transmis dans `$corps`. |
|
| 205 | - * |
|
| 206 | - * Appelée pour afficher un message ou une demande de confirmation simple et rapide |
|
| 207 | - * |
|
| 208 | - * @param string $corps |
|
| 209 | - * Corps de la page |
|
| 210 | - * @param array $options |
|
| 211 | - * @return string |
|
| 212 | - * HTML de la page |
|
| 213 | - * @see ouvreBody() |
|
| 214 | - * @see ouvreCorps() |
|
| 215 | - * string $titre : Titre à l'affichage (différent de $page_title) |
|
| 216 | - * int $status : status de la page |
|
| 217 | - * string $footer : pied de la box en remplacement du bouton retour par défaut |
|
| 218 | - * @uses ouvreBody() |
|
| 219 | - * @uses ouvreCorps() |
|
| 220 | - * @uses fermeCorps() |
|
| 221 | - * @uses fermeBody() |
|
| 222 | - * |
|
| 223 | - */ |
|
| 224 | - public function page($corps, $options = []) { |
|
| 202 | + /** |
|
| 203 | + * Retourne une page HTML contenant, dans une présentation minimale, |
|
| 204 | + * le contenu transmis dans `$corps`. |
|
| 205 | + * |
|
| 206 | + * Appelée pour afficher un message ou une demande de confirmation simple et rapide |
|
| 207 | + * |
|
| 208 | + * @param string $corps |
|
| 209 | + * Corps de la page |
|
| 210 | + * @param array $options |
|
| 211 | + * @return string |
|
| 212 | + * HTML de la page |
|
| 213 | + * @see ouvreBody() |
|
| 214 | + * @see ouvreCorps() |
|
| 215 | + * string $titre : Titre à l'affichage (différent de $page_title) |
|
| 216 | + * int $status : status de la page |
|
| 217 | + * string $footer : pied de la box en remplacement du bouton retour par défaut |
|
| 218 | + * @uses ouvreBody() |
|
| 219 | + * @uses ouvreCorps() |
|
| 220 | + * @uses fermeCorps() |
|
| 221 | + * @uses fermeBody() |
|
| 222 | + * |
|
| 223 | + */ |
|
| 224 | + public function page($corps, $options = []) { |
|
| 225 | 225 | |
| 226 | - // par securite |
|
| 227 | - if (!defined('_AJAX')) { |
|
| 228 | - define('_AJAX', false); |
|
| 229 | - } |
|
| 226 | + // par securite |
|
| 227 | + if (!defined('_AJAX')) { |
|
| 228 | + define('_AJAX', false); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - $status = ((int) ($options['status'] ?? 200)) ?: 200; |
|
| 231 | + $status = ((int) ($options['status'] ?? 200)) ?: 200; |
|
| 232 | 232 | |
| 233 | - http_response_code($status); |
|
| 233 | + http_response_code($status); |
|
| 234 | 234 | |
| 235 | - $html = $this->ouvreBody($options) |
|
| 236 | - . $this->ouvreCorps($options) |
|
| 237 | - . $corps |
|
| 238 | - . $this->fermeCorps($options) |
|
| 239 | - . $this->fermeBody(); |
|
| 235 | + $html = $this->ouvreBody($options) |
|
| 236 | + . $this->ouvreCorps($options) |
|
| 237 | + . $corps |
|
| 238 | + . $this->fermeCorps($options) |
|
| 239 | + . $this->fermeBody(); |
|
| 240 | 240 | |
| 241 | - if ( |
|
| 242 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 243 | - && empty($options['all_inline']) |
|
| 244 | - ) { |
|
| 245 | - define('_SET_HTML_BASE', true); |
|
| 246 | - include_spip('public/assembler'); |
|
| 247 | - $GLOBALS['html'] = true; |
|
| 248 | - page_base_href($html); |
|
| 249 | - } |
|
| 250 | - return $html; |
|
| 251 | - } |
|
| 241 | + if ( |
|
| 242 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 243 | + && empty($options['all_inline']) |
|
| 244 | + ) { |
|
| 245 | + define('_SET_HTML_BASE', true); |
|
| 246 | + include_spip('public/assembler'); |
|
| 247 | + $GLOBALS['html'] = true; |
|
| 248 | + page_base_href($html); |
|
| 249 | + } |
|
| 250 | + return $html; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Fonction helper pour les erreurs |
|
| 255 | - * @param ?string $message_erreur |
|
| 256 | - * @param array $options |
|
| 257 | - * @see page() |
|
| 258 | - * @return string |
|
| 259 | - * |
|
| 260 | - */ |
|
| 261 | - public function pageErreur($message_erreur = null, $options = []) { |
|
| 253 | + /** |
|
| 254 | + * Fonction helper pour les erreurs |
|
| 255 | + * @param ?string $message_erreur |
|
| 256 | + * @param array $options |
|
| 257 | + * @see page() |
|
| 258 | + * @return string |
|
| 259 | + * |
|
| 260 | + */ |
|
| 261 | + public function pageErreur($message_erreur = null, $options = []) { |
|
| 262 | 262 | |
| 263 | - if (empty($message_erreur)) { |
|
| 264 | - if (empty($options['lang'])) { |
|
| 265 | - utiliser_langue_visiteur(); |
|
| 266 | - } else { |
|
| 267 | - changer_langue($options['lang']); |
|
| 268 | - } |
|
| 269 | - $message_erreur = _T('info_acces_interdit'); |
|
| 270 | - } |
|
| 271 | - $corps = "<div class='msg-alert error'>" |
|
| 272 | - . $message_erreur |
|
| 273 | - . '</div>'; |
|
| 274 | - if (empty($options['status'])) { |
|
| 275 | - $options['status'] = 403; |
|
| 276 | - } |
|
| 277 | - return $this->page($corps, $options); |
|
| 278 | - } |
|
| 263 | + if (empty($message_erreur)) { |
|
| 264 | + if (empty($options['lang'])) { |
|
| 265 | + utiliser_langue_visiteur(); |
|
| 266 | + } else { |
|
| 267 | + changer_langue($options['lang']); |
|
| 268 | + } |
|
| 269 | + $message_erreur = _T('info_acces_interdit'); |
|
| 270 | + } |
|
| 271 | + $corps = "<div class='msg-alert error'>" |
|
| 272 | + . $message_erreur |
|
| 273 | + . '</div>'; |
|
| 274 | + if (empty($options['status'])) { |
|
| 275 | + $options['status'] = 403; |
|
| 276 | + } |
|
| 277 | + return $this->page($corps, $options); |
|
| 278 | + } |
|
| 279 | 279 | } |
@@ -12,6 +12,6 @@ |
||
| 12 | 12 | * @return string Le SHA de la chaîne |
| 13 | 13 | */ |
| 14 | 14 | function spip_sha256($str) { |
| 15 | - trigger_deprecation('spip', '5.0', 'Using "%s" is deprecated, use "%s" instead.', 'spip_sha256($str)', 'hash(\'sha256\', $str)'); |
|
| 16 | - return hash('sha256', $str); |
|
| 15 | + trigger_deprecation('spip', '5.0', 'Using "%s" is deprecated, use "%s" instead.', 'spip_sha256($str)', 'hash(\'sha256\', $str)'); |
|
| 16 | + return hash('sha256', $str); |
|
| 17 | 17 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Filtres |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -36,29 +36,29 @@ discard block |
||
| 36 | 36 | * - une chaîne vide si la date est considérée nulle |
| 37 | 37 | **/ |
| 38 | 38 | function normaliser_date($date, $forcer_jour = false): string { |
| 39 | - $date = vider_date($date); |
|
| 40 | - if ($date) { |
|
| 41 | - if (preg_match('/^\d{8,10}$/', $date)) { |
|
| 42 | - $date = date('Y-m-d H:i:s', $date); |
|
| 43 | - } |
|
| 44 | - if (preg_match('#^([12]\d{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 45 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 46 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 47 | - } else { |
|
| 48 | - if (preg_match('#^([12]\d{3}[-/][01]?\d)([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 49 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 50 | - $date = preg_replace('@/@', '-', (string) $regs[1]) . '-00' . $regs[3]; |
|
| 51 | - } else { |
|
| 52 | - $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - if ($forcer_jour) { |
|
| 57 | - $date = str_replace('-00', '-01', $date); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - return $date; |
|
| 39 | + $date = vider_date($date); |
|
| 40 | + if ($date) { |
|
| 41 | + if (preg_match('/^\d{8,10}$/', $date)) { |
|
| 42 | + $date = date('Y-m-d H:i:s', $date); |
|
| 43 | + } |
|
| 44 | + if (preg_match('#^([12]\d{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 45 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 46 | + $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 47 | + } else { |
|
| 48 | + if (preg_match('#^([12]\d{3}[-/][01]?\d)([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 49 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 50 | + $date = preg_replace('@/@', '-', (string) $regs[1]) . '-00' . $regs[3]; |
|
| 51 | + } else { |
|
| 52 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + if ($forcer_jour) { |
|
| 57 | + $date = str_replace('-00', '-01', $date); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + return $date; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -71,22 +71,22 @@ discard block |
||
| 71 | 71 | * - Une chaine vide |
| 72 | 72 | **/ |
| 73 | 73 | function vider_date($letexte, $verif_format_date = false): string { |
| 74 | - $letexte ??= ''; |
|
| 75 | - if ( |
|
| 76 | - !$verif_format_date |
|
| 77 | - || in_array(strlen($letexte), [10,19]) && preg_match('/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?$/', $letexte) |
|
| 78 | - ) { |
|
| 79 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 80 | - return ''; |
|
| 81 | - } |
|
| 82 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 83 | - return ''; |
|
| 84 | - } |
|
| 85 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 86 | - return ''; |
|
| 87 | - } // eviter le bug GMT-1 |
|
| 88 | - } |
|
| 89 | - return $letexte; |
|
| 74 | + $letexte ??= ''; |
|
| 75 | + if ( |
|
| 76 | + !$verif_format_date |
|
| 77 | + || in_array(strlen($letexte), [10,19]) && preg_match('/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?$/', $letexte) |
|
| 78 | + ) { |
|
| 79 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 80 | + return ''; |
|
| 81 | + } |
|
| 82 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 83 | + return ''; |
|
| 84 | + } |
|
| 85 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 86 | + return ''; |
|
| 87 | + } // eviter le bug GMT-1 |
|
| 88 | + } |
|
| 89 | + return $letexte; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | **/ |
| 103 | 103 | function recup_heure($date): array { |
| 104 | 104 | |
| 105 | - if (preg_match('#(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?#', $date, $elements)) { |
|
| 106 | - array_shift($elements); |
|
| 107 | - if (!isset($elements[2])) { |
|
| 108 | - $elements[2] = 0; |
|
| 109 | - } |
|
| 110 | - $heure = $elements; |
|
| 111 | - } else { |
|
| 112 | - $heure = [0, 0, 0]; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - return $heure; |
|
| 105 | + if (preg_match('#(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?#', $date, $elements)) { |
|
| 106 | + array_shift($elements); |
|
| 107 | + if (!isset($elements[2])) { |
|
| 108 | + $elements[2] = 0; |
|
| 109 | + } |
|
| 110 | + $heure = $elements; |
|
| 111 | + } else { |
|
| 112 | + $heure = [0, 0, 0]; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + return $heure; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | * @return string heures, sinon 0 |
| 127 | 127 | **/ |
| 128 | 128 | function heures($numdate): string { |
| 129 | - $heures = null; |
|
| 130 | - $date_array = recup_heure($numdate); |
|
| 131 | - if ($date_array) { |
|
| 132 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 133 | - } |
|
| 129 | + $heures = null; |
|
| 130 | + $date_array = recup_heure($numdate); |
|
| 131 | + if ($date_array) { |
|
| 132 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - return $heures; |
|
| 135 | + return $heures; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -146,13 +146,13 @@ discard block |
||
| 146 | 146 | * @return string minutes, sinon 0 |
| 147 | 147 | **/ |
| 148 | 148 | function minutes($numdate): string { |
| 149 | - $minutes = null; |
|
| 150 | - $date_array = recup_heure($numdate); |
|
| 151 | - if ($date_array) { |
|
| 152 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 153 | - } |
|
| 149 | + $minutes = null; |
|
| 150 | + $date_array = recup_heure($numdate); |
|
| 151 | + if ($date_array) { |
|
| 152 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - return $minutes; |
|
| 155 | + return $minutes; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | * @return string secondes, sinon 0 |
| 167 | 167 | **/ |
| 168 | 168 | function secondes($numdate): string { |
| 169 | - $secondes = null; |
|
| 170 | - $date_array = recup_heure($numdate); |
|
| 171 | - if ($date_array) { |
|
| 172 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 173 | - } |
|
| 169 | + $secondes = null; |
|
| 170 | + $date_array = recup_heure($numdate); |
|
| 171 | + if ($date_array) { |
|
| 172 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - return $secondes; |
|
| 175 | + return $secondes; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | * @return string L'heure formatée dans la langue en cours. |
| 192 | 192 | **/ |
| 193 | 193 | function heures_minutes($numdate, $forme = ''): string { |
| 194 | - if ($forme !== 'abbr') { |
|
| 195 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 196 | - } else { |
|
| 197 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 198 | - } |
|
| 194 | + if ($forme !== 'abbr') { |
|
| 195 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 196 | + } else { |
|
| 197 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 198 | + } |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -220,57 +220,57 @@ discard block |
||
| 220 | 220 | * @return array [année, mois, jour, heures, minutes, secondes] ou [] |
| 221 | 221 | **/ |
| 222 | 222 | function recup_date($numdate, $forcer_jour = true): array { |
| 223 | - if (!$numdate) { |
|
| 224 | - return []; |
|
| 225 | - } |
|
| 226 | - $heures = $minutes = $secondes = 0; |
|
| 227 | - if (preg_match('#(\d{1,2})/(\d{1,2})/(\d{4}|\d{1,2})#', $numdate, $regs)) { |
|
| 228 | - $jour = $regs[1]; |
|
| 229 | - $mois = $regs[2]; |
|
| 230 | - $annee = $regs[3]; |
|
| 231 | - if ($annee < 90) { |
|
| 232 | - $annee = 2000 + $annee; |
|
| 233 | - } elseif ($annee < 100) { |
|
| 234 | - $annee = 1900 + $annee; |
|
| 235 | - } |
|
| 236 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 237 | - } elseif (preg_match('#(\d{4})-(\d{1,2})-(\d{1,2})#', $numdate, $regs)) { |
|
| 238 | - $annee = $regs[1]; |
|
| 239 | - $mois = $regs[2]; |
|
| 240 | - $jour = $regs[3]; |
|
| 241 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 242 | - } elseif (preg_match('#(\d{4})-(\d{2})#', $numdate, $regs)) { |
|
| 243 | - $annee = $regs[1]; |
|
| 244 | - $mois = $regs[2]; |
|
| 245 | - $jour = ''; |
|
| 246 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 247 | - } elseif (preg_match('#^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$#', $numdate, $regs)) { |
|
| 248 | - $annee = $regs[1]; |
|
| 249 | - $mois = $regs[2]; |
|
| 250 | - $jour = $regs[3]; |
|
| 251 | - $heures = $regs[4]; |
|
| 252 | - $minutes = $regs[5]; |
|
| 253 | - $secondes = $regs[6]; |
|
| 254 | - } else { |
|
| 255 | - $annee = $mois = $jour = ''; |
|
| 256 | - } |
|
| 257 | - if ($annee > 4000) { |
|
| 258 | - $annee -= 9000; |
|
| 259 | - } |
|
| 260 | - if (strlen($jour) && str_starts_with($jour, '0')) { |
|
| 261 | - $jour = substr($jour, 1); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - if ($forcer_jour && $jour == '0') { |
|
| 265 | - $jour = '1'; |
|
| 266 | - } |
|
| 267 | - if ($forcer_jour && $mois == '0') { |
|
| 268 | - $mois = '1'; |
|
| 269 | - } |
|
| 270 | - if ($annee || $mois || $jour || $heures || $minutes || $secondes) { |
|
| 271 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 272 | - } |
|
| 273 | - return []; |
|
| 223 | + if (!$numdate) { |
|
| 224 | + return []; |
|
| 225 | + } |
|
| 226 | + $heures = $minutes = $secondes = 0; |
|
| 227 | + if (preg_match('#(\d{1,2})/(\d{1,2})/(\d{4}|\d{1,2})#', $numdate, $regs)) { |
|
| 228 | + $jour = $regs[1]; |
|
| 229 | + $mois = $regs[2]; |
|
| 230 | + $annee = $regs[3]; |
|
| 231 | + if ($annee < 90) { |
|
| 232 | + $annee = 2000 + $annee; |
|
| 233 | + } elseif ($annee < 100) { |
|
| 234 | + $annee = 1900 + $annee; |
|
| 235 | + } |
|
| 236 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 237 | + } elseif (preg_match('#(\d{4})-(\d{1,2})-(\d{1,2})#', $numdate, $regs)) { |
|
| 238 | + $annee = $regs[1]; |
|
| 239 | + $mois = $regs[2]; |
|
| 240 | + $jour = $regs[3]; |
|
| 241 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 242 | + } elseif (preg_match('#(\d{4})-(\d{2})#', $numdate, $regs)) { |
|
| 243 | + $annee = $regs[1]; |
|
| 244 | + $mois = $regs[2]; |
|
| 245 | + $jour = ''; |
|
| 246 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 247 | + } elseif (preg_match('#^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$#', $numdate, $regs)) { |
|
| 248 | + $annee = $regs[1]; |
|
| 249 | + $mois = $regs[2]; |
|
| 250 | + $jour = $regs[3]; |
|
| 251 | + $heures = $regs[4]; |
|
| 252 | + $minutes = $regs[5]; |
|
| 253 | + $secondes = $regs[6]; |
|
| 254 | + } else { |
|
| 255 | + $annee = $mois = $jour = ''; |
|
| 256 | + } |
|
| 257 | + if ($annee > 4000) { |
|
| 258 | + $annee -= 9000; |
|
| 259 | + } |
|
| 260 | + if (strlen($jour) && str_starts_with($jour, '0')) { |
|
| 261 | + $jour = substr($jour, 1); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + if ($forcer_jour && $jour == '0') { |
|
| 265 | + $jour = '1'; |
|
| 266 | + } |
|
| 267 | + if ($forcer_jour && $mois == '0') { |
|
| 268 | + $mois = '1'; |
|
| 269 | + } |
|
| 270 | + if ($annee || $mois || $jour || $heures || $minutes || $secondes) { |
|
| 271 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 272 | + } |
|
| 273 | + return []; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | * La date relative ou complète |
| 298 | 298 | **/ |
| 299 | 299 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */): string { |
| 300 | - return sinon( |
|
| 301 | - date_relative($date, $decalage_maxi), |
|
| 302 | - affdate_heure($date) |
|
| 303 | - ); |
|
| 300 | + return sinon( |
|
| 301 | + date_relative($date, $decalage_maxi), |
|
| 302 | + affdate_heure($date) |
|
| 303 | + ); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -333,72 +333,72 @@ discard block |
||
| 333 | 333 | **/ |
| 334 | 334 | function date_relative($date, $decalage_maxi = 0, $ref_date = null): string { |
| 335 | 335 | |
| 336 | - if (!$date) { |
|
| 337 | - return ''; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $ref_time = is_null($ref_date) ? time() : strtotime($ref_date); |
|
| 341 | - |
|
| 342 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 343 | - |
|
| 344 | - if ($decalage_maxi && ($decal > $decalage_maxi || $decal < 0)) { |
|
| 345 | - return ''; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - if ($decal < 0) { |
|
| 349 | - $il_y_a = 'date_dans'; |
|
| 350 | - $decal = -1 * $decal; |
|
| 351 | - } else { |
|
| 352 | - $il_y_a = 'date_il_y_a'; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 356 | - return affdate_court($date); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - if ($decal > 3600 * 24 * 30) { |
|
| 360 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 361 | - $delai = $mois < 2 |
|
| 362 | - ? "$mois " . _T('date_un_mois') |
|
| 363 | - : "$mois " . _T('date_mois'); |
|
| 364 | - } else { |
|
| 365 | - if ($decal > 3600 * 24 * 7) { |
|
| 366 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 367 | - $delai = $semaines < 2 |
|
| 368 | - ? "$semaines " . _T('date_une_semaine') |
|
| 369 | - : "$semaines " . _T('date_semaines'); |
|
| 370 | - } else { |
|
| 371 | - if ($decal > 3600 * 24) { |
|
| 372 | - $jours = floor($decal / (3600 * 24)); |
|
| 373 | - if ($jours < 2) { |
|
| 374 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 375 | - } else { |
|
| 376 | - $delai = "$jours " . _T('date_jours'); |
|
| 377 | - } |
|
| 378 | - } else { |
|
| 379 | - if ($decal >= 3600) { |
|
| 380 | - $heures = floor($decal / 3600); |
|
| 381 | - $delai = $heures < 2 |
|
| 382 | - ? "$heures " . _T('date_une_heure') |
|
| 383 | - : "$heures " . _T('date_heures'); |
|
| 384 | - } else { |
|
| 385 | - if ($decal >= 60) { |
|
| 386 | - $minutes = floor($decal / 60); |
|
| 387 | - $delai = $minutes < 2 |
|
| 388 | - ? "$minutes " . _T('date_une_minute') |
|
| 389 | - : "$minutes " . _T('date_minutes'); |
|
| 390 | - } else { |
|
| 391 | - $secondes = ceil($decal); |
|
| 392 | - $delai = $secondes < 2 |
|
| 393 | - ? "$secondes " . _T('date_une_seconde') |
|
| 394 | - : "$secondes " . _T('date_secondes'); |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 336 | + if (!$date) { |
|
| 337 | + return ''; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $ref_time = is_null($ref_date) ? time() : strtotime($ref_date); |
|
| 341 | + |
|
| 342 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 343 | + |
|
| 344 | + if ($decalage_maxi && ($decal > $decalage_maxi || $decal < 0)) { |
|
| 345 | + return ''; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + if ($decal < 0) { |
|
| 349 | + $il_y_a = 'date_dans'; |
|
| 350 | + $decal = -1 * $decal; |
|
| 351 | + } else { |
|
| 352 | + $il_y_a = 'date_il_y_a'; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 356 | + return affdate_court($date); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + if ($decal > 3600 * 24 * 30) { |
|
| 360 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 361 | + $delai = $mois < 2 |
|
| 362 | + ? "$mois " . _T('date_un_mois') |
|
| 363 | + : "$mois " . _T('date_mois'); |
|
| 364 | + } else { |
|
| 365 | + if ($decal > 3600 * 24 * 7) { |
|
| 366 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 367 | + $delai = $semaines < 2 |
|
| 368 | + ? "$semaines " . _T('date_une_semaine') |
|
| 369 | + : "$semaines " . _T('date_semaines'); |
|
| 370 | + } else { |
|
| 371 | + if ($decal > 3600 * 24) { |
|
| 372 | + $jours = floor($decal / (3600 * 24)); |
|
| 373 | + if ($jours < 2) { |
|
| 374 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 375 | + } else { |
|
| 376 | + $delai = "$jours " . _T('date_jours'); |
|
| 377 | + } |
|
| 378 | + } else { |
|
| 379 | + if ($decal >= 3600) { |
|
| 380 | + $heures = floor($decal / 3600); |
|
| 381 | + $delai = $heures < 2 |
|
| 382 | + ? "$heures " . _T('date_une_heure') |
|
| 383 | + : "$heures " . _T('date_heures'); |
|
| 384 | + } else { |
|
| 385 | + if ($decal >= 60) { |
|
| 386 | + $minutes = floor($decal / 60); |
|
| 387 | + $delai = $minutes < 2 |
|
| 388 | + ? "$minutes " . _T('date_une_minute') |
|
| 389 | + : "$minutes " . _T('date_minutes'); |
|
| 390 | + } else { |
|
| 391 | + $secondes = ceil($decal); |
|
| 392 | + $delai = $secondes < 2 |
|
| 393 | + ? "$secondes " . _T('date_une_seconde') |
|
| 394 | + : "$secondes " . _T('date_secondes'); |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | |
@@ -424,30 +424,30 @@ discard block |
||
| 424 | 424 | **/ |
| 425 | 425 | function date_relativecourt($date, $decalage_maxi = 0): string { |
| 426 | 426 | |
| 427 | - if (!$date) { |
|
| 428 | - return ''; |
|
| 429 | - } |
|
| 430 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 431 | - |
|
| 432 | - if ($decalage_maxi && ($decal > $decalage_maxi || $decal < 0)) { |
|
| 433 | - return ''; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - if ($decal < -24 * 3600) { |
|
| 437 | - $retour = date_relative($date, $decalage_maxi); |
|
| 438 | - } elseif ($decal < 0) { |
|
| 439 | - $retour = _T('date_demain'); |
|
| 440 | - } else { |
|
| 441 | - if ($decal < (3600 * 24)) { |
|
| 442 | - $retour = _T('date_aujourdhui'); |
|
| 443 | - } else { |
|
| 444 | - $retour = $decal < (3600 * 24 * 2) |
|
| 445 | - ? _T('date_hier') |
|
| 446 | - : date_relative($date, $decalage_maxi); |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - return $retour; |
|
| 427 | + if (!$date) { |
|
| 428 | + return ''; |
|
| 429 | + } |
|
| 430 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 431 | + |
|
| 432 | + if ($decalage_maxi && ($decal > $decalage_maxi || $decal < 0)) { |
|
| 433 | + return ''; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + if ($decal < -24 * 3600) { |
|
| 437 | + $retour = date_relative($date, $decalage_maxi); |
|
| 438 | + } elseif ($decal < 0) { |
|
| 439 | + $retour = _T('date_demain'); |
|
| 440 | + } else { |
|
| 441 | + if ($decal < (3600 * 24)) { |
|
| 442 | + $retour = _T('date_aujourdhui'); |
|
| 443 | + } else { |
|
| 444 | + $retour = $decal < (3600 * 24 * 2) |
|
| 445 | + ? _T('date_hier') |
|
| 446 | + : date_relative($date, $decalage_maxi); |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + return $retour; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /** |
@@ -464,173 +464,173 @@ discard block |
||
| 464 | 464 | * @return string |
| 465 | 465 | */ |
| 466 | 466 | function affdate_base($numdate, $vue, $options = []): string { |
| 467 | - if (is_string($options)) { |
|
| 468 | - $options = ['param' => $options]; |
|
| 469 | - } |
|
| 470 | - $date_array = recup_date($numdate, false); |
|
| 471 | - if (!$date_array) { |
|
| 472 | - return ''; |
|
| 473 | - } |
|
| 474 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 475 | - |
|
| 476 | - // 1er, 21st, etc. |
|
| 477 | - $journum = $jour; |
|
| 478 | - |
|
| 479 | - if ($jour == 0) { |
|
| 480 | - $jour = ''; |
|
| 481 | - $njour = 0; |
|
| 482 | - } else { |
|
| 483 | - $njour = (int) $jour; |
|
| 484 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 485 | - $jour = $jourth; |
|
| 486 | - } |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - $mois = (int) $mois; |
|
| 490 | - if ($mois > 0 && $mois < 13) { |
|
| 491 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 492 | - $param = ((isset($options['param']) && $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 493 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 494 | - $jourmois = $jour |
|
| 495 | - ? _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]) |
|
| 496 | - : $nommois; |
|
| 497 | - } else { |
|
| 498 | - $nommois = ''; |
|
| 499 | - $jourmois = ''; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - if ($annee < 0) { |
|
| 503 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 504 | - $avjc = true; |
|
| 505 | - } else { |
|
| 506 | - $avjc = false; |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - switch ($vue) { |
|
| 510 | - case 'saison': |
|
| 511 | - case 'saison_annee': |
|
| 512 | - $saison = ''; |
|
| 513 | - if ($mois > 0) { |
|
| 514 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 515 | - if ($mois == 3 && $jour >= 21 || $mois > 3) { |
|
| 516 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 517 | - } |
|
| 518 | - if ($mois == 6 && $jour >= 21 || $mois > 6) { |
|
| 519 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 520 | - } |
|
| 521 | - if ($mois == 9 && $jour >= 21 || $mois > 9) { |
|
| 522 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 523 | - } |
|
| 524 | - if ($mois == 12 && $jour >= 21 || $mois > 12) { |
|
| 525 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - if ($vue == 'saison') { |
|
| 529 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 530 | - } else { |
|
| 531 | - return $saison ? trim((string) _T( |
|
| 532 | - 'date_fmt_saison_annee', |
|
| 533 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 534 | - )) : ''; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - case 'court': |
|
| 538 | - if ($avjc) { |
|
| 539 | - return $annee; |
|
| 540 | - } |
|
| 541 | - $a = ((isset($options['annee_courante']) && $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 542 | - if ($annee < ($a - 100) || $annee > ($a + 100)) { |
|
| 543 | - return $annee; |
|
| 544 | - } |
|
| 545 | - if ($annee != $a) { |
|
| 546 | - return _T( |
|
| 547 | - 'date_fmt_mois_annee', |
|
| 548 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 549 | - ); |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - return _T( |
|
| 553 | - 'date_fmt_jour_mois', |
|
| 554 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 555 | - ); |
|
| 556 | - |
|
| 557 | - case 'jourcourt': |
|
| 558 | - if ($avjc) { |
|
| 559 | - return $annee; |
|
| 560 | - } |
|
| 561 | - $a = ((isset($options['annee_courante']) && $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 562 | - if ($annee < ($a - 100) || $annee > ($a + 100)) { |
|
| 563 | - return $annee; |
|
| 564 | - } |
|
| 565 | - if ($annee != $a) { |
|
| 566 | - return _T( |
|
| 567 | - 'date_fmt_jour_mois_annee', |
|
| 568 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 569 | - ); |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - return _T( |
|
| 573 | - 'date_fmt_jour_mois', |
|
| 574 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 575 | - ); |
|
| 576 | - |
|
| 577 | - case 'entier': |
|
| 578 | - if ($avjc) { |
|
| 579 | - return $annee; |
|
| 580 | - } |
|
| 581 | - if ($jour) { |
|
| 582 | - return _T( |
|
| 583 | - 'date_fmt_jour_mois_annee', |
|
| 584 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 585 | - ); |
|
| 586 | - } elseif ($mois) { |
|
| 587 | - return trim((string) _T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 588 | - } else { |
|
| 589 | - return $annee; |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - case 'nom_mois': |
|
| 593 | - return $nommois; |
|
| 594 | - |
|
| 595 | - case 'mois': |
|
| 596 | - return sprintf('%02s', $mois); |
|
| 597 | - |
|
| 598 | - case 'jour': |
|
| 599 | - return $jour; |
|
| 600 | - |
|
| 601 | - case 'journum': |
|
| 602 | - return $journum; |
|
| 603 | - |
|
| 604 | - case 'nom_jour': |
|
| 605 | - if (!$mois || !$njour) { |
|
| 606 | - return ''; |
|
| 607 | - } |
|
| 608 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 609 | - $nom = 1 + (int) date('w', $nom); |
|
| 610 | - $param = ((isset($options['param']) && $options['param']) ? '_' . $options['param'] : ''); |
|
| 611 | - |
|
| 612 | - return _T('date_jour_' . $nom . $param); |
|
| 613 | - |
|
| 614 | - case 'mois_annee': |
|
| 615 | - if ($avjc) { |
|
| 616 | - return $annee; |
|
| 617 | - } |
|
| 618 | - |
|
| 619 | - return trim((string) _T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 620 | - |
|
| 621 | - case 'annee': |
|
| 622 | - return $annee; |
|
| 623 | - |
|
| 624 | - // Cas d'une vue non definie : retomber sur le format |
|
| 625 | - // de date propose par http://www.php.net/date |
|
| 626 | - default: |
|
| 627 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 628 | - // il faut envoyer jour = 1 si jour pas défini, c'est le comportement qu'on avait historiquement en envoyant '' |
|
| 629 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, is_numeric($jour) ? $jour : 1, $annee)) { |
|
| 630 | - $time = strtotime($numdate); |
|
| 631 | - } |
|
| 632 | - return date($vue, $time); |
|
| 633 | - } |
|
| 467 | + if (is_string($options)) { |
|
| 468 | + $options = ['param' => $options]; |
|
| 469 | + } |
|
| 470 | + $date_array = recup_date($numdate, false); |
|
| 471 | + if (!$date_array) { |
|
| 472 | + return ''; |
|
| 473 | + } |
|
| 474 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 475 | + |
|
| 476 | + // 1er, 21st, etc. |
|
| 477 | + $journum = $jour; |
|
| 478 | + |
|
| 479 | + if ($jour == 0) { |
|
| 480 | + $jour = ''; |
|
| 481 | + $njour = 0; |
|
| 482 | + } else { |
|
| 483 | + $njour = (int) $jour; |
|
| 484 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 485 | + $jour = $jourth; |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + $mois = (int) $mois; |
|
| 490 | + if ($mois > 0 && $mois < 13) { |
|
| 491 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 492 | + $param = ((isset($options['param']) && $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 493 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 494 | + $jourmois = $jour |
|
| 495 | + ? _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]) |
|
| 496 | + : $nommois; |
|
| 497 | + } else { |
|
| 498 | + $nommois = ''; |
|
| 499 | + $jourmois = ''; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + if ($annee < 0) { |
|
| 503 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 504 | + $avjc = true; |
|
| 505 | + } else { |
|
| 506 | + $avjc = false; |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + switch ($vue) { |
|
| 510 | + case 'saison': |
|
| 511 | + case 'saison_annee': |
|
| 512 | + $saison = ''; |
|
| 513 | + if ($mois > 0) { |
|
| 514 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 515 | + if ($mois == 3 && $jour >= 21 || $mois > 3) { |
|
| 516 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 517 | + } |
|
| 518 | + if ($mois == 6 && $jour >= 21 || $mois > 6) { |
|
| 519 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 520 | + } |
|
| 521 | + if ($mois == 9 && $jour >= 21 || $mois > 9) { |
|
| 522 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 523 | + } |
|
| 524 | + if ($mois == 12 && $jour >= 21 || $mois > 12) { |
|
| 525 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + if ($vue == 'saison') { |
|
| 529 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 530 | + } else { |
|
| 531 | + return $saison ? trim((string) _T( |
|
| 532 | + 'date_fmt_saison_annee', |
|
| 533 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 534 | + )) : ''; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + case 'court': |
|
| 538 | + if ($avjc) { |
|
| 539 | + return $annee; |
|
| 540 | + } |
|
| 541 | + $a = ((isset($options['annee_courante']) && $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 542 | + if ($annee < ($a - 100) || $annee > ($a + 100)) { |
|
| 543 | + return $annee; |
|
| 544 | + } |
|
| 545 | + if ($annee != $a) { |
|
| 546 | + return _T( |
|
| 547 | + 'date_fmt_mois_annee', |
|
| 548 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 549 | + ); |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + return _T( |
|
| 553 | + 'date_fmt_jour_mois', |
|
| 554 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 555 | + ); |
|
| 556 | + |
|
| 557 | + case 'jourcourt': |
|
| 558 | + if ($avjc) { |
|
| 559 | + return $annee; |
|
| 560 | + } |
|
| 561 | + $a = ((isset($options['annee_courante']) && $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 562 | + if ($annee < ($a - 100) || $annee > ($a + 100)) { |
|
| 563 | + return $annee; |
|
| 564 | + } |
|
| 565 | + if ($annee != $a) { |
|
| 566 | + return _T( |
|
| 567 | + 'date_fmt_jour_mois_annee', |
|
| 568 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 569 | + ); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + return _T( |
|
| 573 | + 'date_fmt_jour_mois', |
|
| 574 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 575 | + ); |
|
| 576 | + |
|
| 577 | + case 'entier': |
|
| 578 | + if ($avjc) { |
|
| 579 | + return $annee; |
|
| 580 | + } |
|
| 581 | + if ($jour) { |
|
| 582 | + return _T( |
|
| 583 | + 'date_fmt_jour_mois_annee', |
|
| 584 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 585 | + ); |
|
| 586 | + } elseif ($mois) { |
|
| 587 | + return trim((string) _T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 588 | + } else { |
|
| 589 | + return $annee; |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + case 'nom_mois': |
|
| 593 | + return $nommois; |
|
| 594 | + |
|
| 595 | + case 'mois': |
|
| 596 | + return sprintf('%02s', $mois); |
|
| 597 | + |
|
| 598 | + case 'jour': |
|
| 599 | + return $jour; |
|
| 600 | + |
|
| 601 | + case 'journum': |
|
| 602 | + return $journum; |
|
| 603 | + |
|
| 604 | + case 'nom_jour': |
|
| 605 | + if (!$mois || !$njour) { |
|
| 606 | + return ''; |
|
| 607 | + } |
|
| 608 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 609 | + $nom = 1 + (int) date('w', $nom); |
|
| 610 | + $param = ((isset($options['param']) && $options['param']) ? '_' . $options['param'] : ''); |
|
| 611 | + |
|
| 612 | + return _T('date_jour_' . $nom . $param); |
|
| 613 | + |
|
| 614 | + case 'mois_annee': |
|
| 615 | + if ($avjc) { |
|
| 616 | + return $annee; |
|
| 617 | + } |
|
| 618 | + |
|
| 619 | + return trim((string) _T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 620 | + |
|
| 621 | + case 'annee': |
|
| 622 | + return $annee; |
|
| 623 | + |
|
| 624 | + // Cas d'une vue non definie : retomber sur le format |
|
| 625 | + // de date propose par http://www.php.net/date |
|
| 626 | + default: |
|
| 627 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 628 | + // il faut envoyer jour = 1 si jour pas défini, c'est le comportement qu'on avait historiquement en envoyant '' |
|
| 629 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, is_numeric($jour) ? $jour : 1, $annee)) { |
|
| 630 | + $time = strtotime($numdate); |
|
| 631 | + } |
|
| 632 | + return date($vue, $time); |
|
| 633 | + } |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | |
@@ -657,11 +657,11 @@ discard block |
||
| 657 | 657 | * Nom du jour |
| 658 | 658 | **/ |
| 659 | 659 | function nom_jour($numdate, $forme = ''): string { |
| 660 | - if ($forme !== 'abbr' && $forme !== 'initiale') { |
|
| 661 | - $forme = ''; |
|
| 662 | - } |
|
| 660 | + if ($forme !== 'abbr' && $forme !== 'initiale') { |
|
| 661 | + $forme = ''; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 664 | + return affdate_base($numdate, 'nom_jour', ['param' => $forme]); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | * Numéro du jour |
| 684 | 684 | **/ |
| 685 | 685 | function jour($numdate): string { |
| 686 | - return affdate_base($numdate, 'jour'); |
|
| 686 | + return affdate_base($numdate, 'jour'); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | * Numéro du jour |
| 702 | 702 | **/ |
| 703 | 703 | function journum($numdate): string { |
| 704 | - return affdate_base($numdate, 'journum'); |
|
| 704 | + return affdate_base($numdate, 'journum'); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | * Numéro du mois (sur 2 chiffres) |
| 720 | 720 | **/ |
| 721 | 721 | function mois($numdate): string { |
| 722 | - return affdate_base($numdate, 'mois'); |
|
| 722 | + return affdate_base($numdate, 'mois'); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
@@ -743,11 +743,11 @@ discard block |
||
| 743 | 743 | * Nom du mois |
| 744 | 744 | **/ |
| 745 | 745 | function nom_mois($numdate, $forme = ''): string { |
| 746 | - if ($forme !== 'abbr') { |
|
| 747 | - $forme = ''; |
|
| 748 | - } |
|
| 746 | + if ($forme !== 'abbr') { |
|
| 747 | + $forme = ''; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 750 | + return affdate_base($numdate, 'nom_mois', ['param' => $forme]); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | /** |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | * Année (sur 4 chiffres) |
| 766 | 766 | **/ |
| 767 | 767 | function annee($numdate): string { |
| 768 | - return affdate_base($numdate, 'annee'); |
|
| 768 | + return affdate_base($numdate, 'annee'); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -795,11 +795,11 @@ discard block |
||
| 795 | 795 | * La date formatée |
| 796 | 796 | **/ |
| 797 | 797 | function saison($numdate, $hemisphere = 'nord'): string { |
| 798 | - if ($hemisphere !== 'sud') { |
|
| 799 | - $hemisphere = 'nord'; |
|
| 800 | - } |
|
| 798 | + if ($hemisphere !== 'sud') { |
|
| 799 | + $hemisphere = 'nord'; |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | - return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 802 | + return affdate_base($numdate, 'saison', ['param' => $hemisphere]); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | |
@@ -828,11 +828,11 @@ discard block |
||
| 828 | 828 | * La date formatée |
| 829 | 829 | **/ |
| 830 | 830 | function saison_annee($numdate, $hemisphere = 'nord'): string { |
| 831 | - if ($hemisphere !== 'sud') { |
|
| 832 | - $hemisphere = 'nord'; |
|
| 833 | - } |
|
| 831 | + if ($hemisphere !== 'sud') { |
|
| 832 | + $hemisphere = 'nord'; |
|
| 833 | + } |
|
| 834 | 834 | |
| 835 | - return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 835 | + return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | * La date formatée |
| 861 | 861 | **/ |
| 862 | 862 | function affdate($numdate, $format = 'entier'): string { |
| 863 | - return affdate_base($numdate, $format); |
|
| 863 | + return affdate_base($numdate, $format); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * La date formatée |
| 888 | 888 | **/ |
| 889 | 889 | function affdate_court($numdate, $annee_courante = null): string { |
| 890 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 890 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | * La date formatée |
| 915 | 915 | **/ |
| 916 | 916 | function affdate_jourcourt($numdate, $annee_courante = null): string { |
| 917 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 917 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | * La date formatée |
| 933 | 933 | **/ |
| 934 | 934 | function affdate_mois_annee($numdate): string { |
| 935 | - return affdate_base($numdate, 'mois_annee'); |
|
| 935 | + return affdate_base($numdate, 'mois_annee'); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -950,16 +950,16 @@ discard block |
||
| 950 | 950 | * La date formatée, sinon '' |
| 951 | 951 | **/ |
| 952 | 952 | function affdate_heure($numdate): string { |
| 953 | - $date_array = recup_date($numdate); |
|
| 954 | - if (!$date_array) { |
|
| 955 | - return ''; |
|
| 956 | - } |
|
| 957 | - [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 958 | - |
|
| 959 | - return _T('date_fmt_jour_heure', [ |
|
| 960 | - 'jour' => affdate($numdate), |
|
| 961 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 962 | - ]); |
|
| 953 | + $date_array = recup_date($numdate); |
|
| 954 | + if (!$date_array) { |
|
| 955 | + return ''; |
|
| 956 | + } |
|
| 957 | + [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 958 | + |
|
| 959 | + return _T('date_fmt_jour_heure', [ |
|
| 960 | + 'jour' => affdate($numdate), |
|
| 961 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 962 | + ]); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | /** |
@@ -991,113 +991,113 @@ discard block |
||
| 991 | 991 | * texte de la date |
| 992 | 992 | */ |
| 993 | 993 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = ''): string { |
| 994 | - $abbr = $jour = ''; |
|
| 995 | - $affdate = 'affdate_jourcourt'; |
|
| 996 | - if (str_contains($forme, 'abbr')) { |
|
| 997 | - $abbr = 'abbr'; |
|
| 998 | - } |
|
| 999 | - if (str_contains($forme, 'annee')) { |
|
| 1000 | - $affdate = 'affdate'; |
|
| 1001 | - } |
|
| 1002 | - if (str_contains($forme, 'jour')) { |
|
| 1003 | - $jour = 'jour'; |
|
| 1004 | - } |
|
| 1005 | - |
|
| 1006 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1007 | - if (str_contains($forme, 'hcal')) { |
|
| 1008 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1009 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1010 | - $dtabbr = '</abbr>'; |
|
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - $date_debut = strtotime($date_debut); |
|
| 1014 | - $date_fin = strtotime($date_fin); |
|
| 1015 | - $d = date('Y-m-d', $date_debut); |
|
| 1016 | - $f = date('Y-m-d', $date_fin); |
|
| 1017 | - $h = ($horaire === 'oui' || $horaire === true); |
|
| 1018 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1019 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1020 | - |
|
| 1021 | - if ($d === $f) { // meme jour |
|
| 1022 | - $nomjour = nom_jour($d, $abbr); |
|
| 1023 | - $s = $affdate($d); |
|
| 1024 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1025 | - if ($h) { |
|
| 1026 | - if ($hd === $hf) { |
|
| 1027 | - // Lundi 20 fevrier a 18h25 |
|
| 1028 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1029 | - $s = "$dtstart$s$dtabbr"; |
|
| 1030 | - } else { |
|
| 1031 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1032 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1033 | - $s = _T( |
|
| 1034 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1035 | - [ |
|
| 1036 | - 'jour' => spip_ucfirst($s), |
|
| 1037 | - 'heure_debut' => $hd, |
|
| 1038 | - 'heure_fin' => $hf, |
|
| 1039 | - 'dtstart' => $dtstart, |
|
| 1040 | - 'dtend' => $dtend, |
|
| 1041 | - 'dtabbr' => $dtabbr |
|
| 1042 | - ], |
|
| 1043 | - [ |
|
| 1044 | - 'sanitize' => false |
|
| 1045 | - ] |
|
| 1046 | - ); |
|
| 1047 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1048 | - else { |
|
| 1049 | - $s = spip_ucfirst(_T( |
|
| 1050 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1051 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1052 | - )); |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - } else { |
|
| 1056 | - $s = $dtabbr && $dtstart |
|
| 1057 | - ? $dtstart . spip_ucfirst($s) . $dtabbr |
|
| 1058 | - : spip_ucfirst($s); |
|
| 1059 | - } |
|
| 1060 | - } else { |
|
| 1061 | - if (date('Y-m', $date_debut) === date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1062 | - $date_debut = $h |
|
| 1063 | - ? affdate_jourcourt($d, date('Y', $date_fin)) |
|
| 1064 | - : jour($d); |
|
| 1065 | - $date_fin = $affdate($f); |
|
| 1066 | - if ($jour) { |
|
| 1067 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1068 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1069 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1070 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1071 | - } |
|
| 1072 | - if ($h) { |
|
| 1073 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1074 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1075 | - } |
|
| 1076 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1077 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1078 | - |
|
| 1079 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1080 | - } else { |
|
| 1081 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1082 | - $date_fin = $affdate($f); |
|
| 1083 | - if ($jour) { |
|
| 1084 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1085 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1086 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1087 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1088 | - } |
|
| 1089 | - if ($h) { |
|
| 1090 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1091 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1095 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1096 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - return $s; |
|
| 994 | + $abbr = $jour = ''; |
|
| 995 | + $affdate = 'affdate_jourcourt'; |
|
| 996 | + if (str_contains($forme, 'abbr')) { |
|
| 997 | + $abbr = 'abbr'; |
|
| 998 | + } |
|
| 999 | + if (str_contains($forme, 'annee')) { |
|
| 1000 | + $affdate = 'affdate'; |
|
| 1001 | + } |
|
| 1002 | + if (str_contains($forme, 'jour')) { |
|
| 1003 | + $jour = 'jour'; |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1007 | + if (str_contains($forme, 'hcal')) { |
|
| 1008 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1009 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1010 | + $dtabbr = '</abbr>'; |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + $date_debut = strtotime($date_debut); |
|
| 1014 | + $date_fin = strtotime($date_fin); |
|
| 1015 | + $d = date('Y-m-d', $date_debut); |
|
| 1016 | + $f = date('Y-m-d', $date_fin); |
|
| 1017 | + $h = ($horaire === 'oui' || $horaire === true); |
|
| 1018 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1019 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1020 | + |
|
| 1021 | + if ($d === $f) { // meme jour |
|
| 1022 | + $nomjour = nom_jour($d, $abbr); |
|
| 1023 | + $s = $affdate($d); |
|
| 1024 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1025 | + if ($h) { |
|
| 1026 | + if ($hd === $hf) { |
|
| 1027 | + // Lundi 20 fevrier a 18h25 |
|
| 1028 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1029 | + $s = "$dtstart$s$dtabbr"; |
|
| 1030 | + } else { |
|
| 1031 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1032 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1033 | + $s = _T( |
|
| 1034 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1035 | + [ |
|
| 1036 | + 'jour' => spip_ucfirst($s), |
|
| 1037 | + 'heure_debut' => $hd, |
|
| 1038 | + 'heure_fin' => $hf, |
|
| 1039 | + 'dtstart' => $dtstart, |
|
| 1040 | + 'dtend' => $dtend, |
|
| 1041 | + 'dtabbr' => $dtabbr |
|
| 1042 | + ], |
|
| 1043 | + [ |
|
| 1044 | + 'sanitize' => false |
|
| 1045 | + ] |
|
| 1046 | + ); |
|
| 1047 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1048 | + else { |
|
| 1049 | + $s = spip_ucfirst(_T( |
|
| 1050 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1051 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1052 | + )); |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | + } else { |
|
| 1056 | + $s = $dtabbr && $dtstart |
|
| 1057 | + ? $dtstart . spip_ucfirst($s) . $dtabbr |
|
| 1058 | + : spip_ucfirst($s); |
|
| 1059 | + } |
|
| 1060 | + } else { |
|
| 1061 | + if (date('Y-m', $date_debut) === date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1062 | + $date_debut = $h |
|
| 1063 | + ? affdate_jourcourt($d, date('Y', $date_fin)) |
|
| 1064 | + : jour($d); |
|
| 1065 | + $date_fin = $affdate($f); |
|
| 1066 | + if ($jour) { |
|
| 1067 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1068 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1069 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1070 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1071 | + } |
|
| 1072 | + if ($h) { |
|
| 1073 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1074 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1075 | + } |
|
| 1076 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1077 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1078 | + |
|
| 1079 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1080 | + } else { |
|
| 1081 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1082 | + $date_fin = $affdate($f); |
|
| 1083 | + if ($jour) { |
|
| 1084 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1085 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1086 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1087 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1088 | + } |
|
| 1089 | + if ($h) { |
|
| 1090 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1091 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1095 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1096 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1097 | + } |
|
| 1098 | + } |
|
| 1099 | + |
|
| 1100 | + return $s; |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1118,10 +1118,10 @@ discard block |
||
| 1118 | 1118 | * Date au format ical |
| 1119 | 1119 | **/ |
| 1120 | 1120 | function date_ical($date, $addminutes = 0): string { |
| 1121 | - [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1122 | - [$annee, $mois, $jour] = recup_date($date); |
|
| 1121 | + [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1122 | + [$annee, $mois, $jour] = recup_date($date); |
|
| 1123 | 1123 | |
| 1124 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1124 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | |
@@ -1145,14 +1145,14 @@ discard block |
||
| 1145 | 1145 | * La date formatée |
| 1146 | 1146 | **/ |
| 1147 | 1147 | function date_iso($date_heure): string { |
| 1148 | - $date = recup_date($date_heure); |
|
| 1149 | - $annee = $date[0] ?? null; |
|
| 1150 | - $mois = $date[1] ?? null; |
|
| 1151 | - $jour = $date[2] ?? null; |
|
| 1152 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1153 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1154 | - |
|
| 1155 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1148 | + $date = recup_date($date_heure); |
|
| 1149 | + $annee = $date[0] ?? null; |
|
| 1150 | + $mois = $date[1] ?? null; |
|
| 1151 | + $jour = $date[2] ?? null; |
|
| 1152 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1153 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1154 | + |
|
| 1155 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | /** |
@@ -1175,11 +1175,11 @@ discard block |
||
| 1175 | 1175 | * La date formatée |
| 1176 | 1176 | **/ |
| 1177 | 1177 | function date_822($date_heure): string { |
| 1178 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1179 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1180 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1178 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1179 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1180 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1181 | 1181 | |
| 1182 | - return date('r', $time); |
|
| 1182 | + return date('r', $time); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | /** |
@@ -1195,11 +1195,11 @@ discard block |
||
| 1195 | 1195 | * Date au format `Ymd` |
| 1196 | 1196 | **/ |
| 1197 | 1197 | function date_anneemoisjour($d): string { |
| 1198 | - if (!$d) { |
|
| 1199 | - $d = date('Y-m-d'); |
|
| 1200 | - } |
|
| 1198 | + if (!$d) { |
|
| 1199 | + $d = date('Y-m-d'); |
|
| 1200 | + } |
|
| 1201 | 1201 | |
| 1202 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1202 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | /** |
@@ -1215,11 +1215,11 @@ discard block |
||
| 1215 | 1215 | * Date au format `Ym` |
| 1216 | 1216 | **/ |
| 1217 | 1217 | function date_anneemois($d): string { |
| 1218 | - if (!$d) { |
|
| 1219 | - $d = date('Y-m-d'); |
|
| 1220 | - } |
|
| 1218 | + if (!$d) { |
|
| 1219 | + $d = date('Y-m-d'); |
|
| 1220 | + } |
|
| 1221 | 1221 | |
| 1222 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1222 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | /** |
@@ -1235,13 +1235,13 @@ discard block |
||
| 1235 | 1235 | * Date au lundi de la même semaine au format `Ymd` |
| 1236 | 1236 | **/ |
| 1237 | 1237 | function date_debut_semaine($annee, $mois, $jour): string { |
| 1238 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1239 | - if ($w_day == 0) { |
|
| 1240 | - $w_day = 7; |
|
| 1241 | - } // Gaffe: le dimanche est zero |
|
| 1242 | - $debut = $jour - $w_day + 1; |
|
| 1238 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1239 | + if ($w_day == 0) { |
|
| 1240 | + $w_day = 7; |
|
| 1241 | + } // Gaffe: le dimanche est zero |
|
| 1242 | + $debut = $jour - $w_day + 1; |
|
| 1243 | 1243 | |
| 1244 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1244 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | /** |
@@ -1257,11 +1257,11 @@ discard block |
||
| 1257 | 1257 | * Date au dimanche de la même semaine au format `Ymd` |
| 1258 | 1258 | **/ |
| 1259 | 1259 | function date_fin_semaine($annee, $mois, $jour): string { |
| 1260 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1261 | - if ($w_day == 0) { |
|
| 1262 | - $w_day = 7; |
|
| 1263 | - } // Gaffe: le dimanche est zero |
|
| 1264 | - $debut = $jour - $w_day + 1; |
|
| 1260 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1261 | + if ($w_day == 0) { |
|
| 1262 | + $w_day = 7; |
|
| 1263 | + } // Gaffe: le dimanche est zero |
|
| 1264 | + $debut = $jour - $w_day + 1; |
|
| 1265 | 1265 | |
| 1266 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1266 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1267 | 1267 | } |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | if (preg_match('#^([12]\d{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 45 | 45 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 46 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 46 | + $date = $regs[1].'-00-00'.$regs[3]; |
|
| 47 | 47 | } else { |
| 48 | 48 | if (preg_match('#^([12]\d{3}[-/][01]?\d)([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 49 | 49 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 50 | - $date = preg_replace('@/@', '-', (string) $regs[1]) . '-00' . $regs[3]; |
|
| 50 | + $date = preg_replace('@/@', '-', (string) $regs[1]).'-00'.$regs[3]; |
|
| 51 | 51 | } else { |
| 52 | 52 | $date = date('Y-m-d H:i:s', strtotime($date)); |
| 53 | 53 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $letexte ??= ''; |
| 75 | 75 | if ( |
| 76 | 76 | !$verif_format_date |
| 77 | - || in_array(strlen($letexte), [10,19]) && preg_match('/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?$/', $letexte) |
|
| 77 | + || in_array(strlen($letexte), [10, 19]) && preg_match('/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?$/', $letexte) |
|
| 78 | 78 | ) { |
| 79 | 79 | if (strncmp('0000-00-00', $letexte, 10) == 0) { |
| 80 | 80 | return ''; |
@@ -359,39 +359,39 @@ discard block |
||
| 359 | 359 | if ($decal > 3600 * 24 * 30) { |
| 360 | 360 | $mois = floor($decal / (3600 * 24 * 30)); |
| 361 | 361 | $delai = $mois < 2 |
| 362 | - ? "$mois " . _T('date_un_mois') |
|
| 363 | - : "$mois " . _T('date_mois'); |
|
| 362 | + ? "$mois "._T('date_un_mois') |
|
| 363 | + : "$mois "._T('date_mois'); |
|
| 364 | 364 | } else { |
| 365 | 365 | if ($decal > 3600 * 24 * 7) { |
| 366 | 366 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 367 | 367 | $delai = $semaines < 2 |
| 368 | - ? "$semaines " . _T('date_une_semaine') |
|
| 369 | - : "$semaines " . _T('date_semaines'); |
|
| 368 | + ? "$semaines "._T('date_une_semaine') |
|
| 369 | + : "$semaines "._T('date_semaines'); |
|
| 370 | 370 | } else { |
| 371 | 371 | if ($decal > 3600 * 24) { |
| 372 | 372 | $jours = floor($decal / (3600 * 24)); |
| 373 | 373 | if ($jours < 2) { |
| 374 | 374 | return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
| 375 | 375 | } else { |
| 376 | - $delai = "$jours " . _T('date_jours'); |
|
| 376 | + $delai = "$jours "._T('date_jours'); |
|
| 377 | 377 | } |
| 378 | 378 | } else { |
| 379 | 379 | if ($decal >= 3600) { |
| 380 | 380 | $heures = floor($decal / 3600); |
| 381 | 381 | $delai = $heures < 2 |
| 382 | - ? "$heures " . _T('date_une_heure') |
|
| 383 | - : "$heures " . _T('date_heures'); |
|
| 382 | + ? "$heures "._T('date_une_heure') |
|
| 383 | + : "$heures "._T('date_heures'); |
|
| 384 | 384 | } else { |
| 385 | 385 | if ($decal >= 60) { |
| 386 | 386 | $minutes = floor($decal / 60); |
| 387 | 387 | $delai = $minutes < 2 |
| 388 | - ? "$minutes " . _T('date_une_minute') |
|
| 389 | - : "$minutes " . _T('date_minutes'); |
|
| 388 | + ? "$minutes "._T('date_une_minute') |
|
| 389 | + : "$minutes "._T('date_minutes'); |
|
| 390 | 390 | } else { |
| 391 | 391 | $secondes = ceil($decal); |
| 392 | 392 | $delai = $secondes < 2 |
| 393 | - ? "$secondes " . _T('date_une_seconde') |
|
| 394 | - : "$secondes " . _T('date_secondes'); |
|
| 393 | + ? "$secondes "._T('date_une_seconde') |
|
| 394 | + : "$secondes "._T('date_secondes'); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $njour = 0; |
| 482 | 482 | } else { |
| 483 | 483 | $njour = (int) $jour; |
| 484 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 484 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 485 | 485 | $jour = $jourth; |
| 486 | 486 | } |
| 487 | 487 | } |
@@ -489,10 +489,10 @@ discard block |
||
| 489 | 489 | $mois = (int) $mois; |
| 490 | 490 | if ($mois > 0 && $mois < 13) { |
| 491 | 491 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 492 | - $param = ((isset($options['param']) && $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 493 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 492 | + $param = ((isset($options['param']) && $options['param'] === 'abbr') ? '_'.$options['param'] : ''); |
|
| 493 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 494 | 494 | $jourmois = $jour |
| 495 | - ? _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]) |
|
| 495 | + ? _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]) |
|
| 496 | 496 | : $nommois; |
| 497 | 497 | } else { |
| 498 | 498 | $nommois = ''; |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | if ($annee < 0) { |
| 503 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 503 | + $annee = -$annee.' '._T('date_avant_jc'); |
|
| 504 | 504 | $avjc = true; |
| 505 | 505 | } else { |
| 506 | 506 | $avjc = false; |
@@ -526,11 +526,11 @@ discard block |
||
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | if ($vue == 'saison') { |
| 529 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 529 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 530 | 530 | } else { |
| 531 | 531 | return $saison ? trim((string) _T( |
| 532 | 532 | 'date_fmt_saison_annee', |
| 533 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 533 | + ['saison' => _T('date_saison_'.$saison), 'annee' => $annee] |
|
| 534 | 534 | )) : ''; |
| 535 | 535 | } |
| 536 | 536 | |
@@ -607,9 +607,9 @@ discard block |
||
| 607 | 607 | } |
| 608 | 608 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 609 | 609 | $nom = 1 + (int) date('w', $nom); |
| 610 | - $param = ((isset($options['param']) && $options['param']) ? '_' . $options['param'] : ''); |
|
| 610 | + $param = ((isset($options['param']) && $options['param']) ? '_'.$options['param'] : ''); |
|
| 611 | 611 | |
| 612 | - return _T('date_jour_' . $nom . $param); |
|
| 612 | + return _T('date_jour_'.$nom.$param); |
|
| 613 | 613 | |
| 614 | 614 | case 'mois_annee': |
| 615 | 615 | if ($avjc) { |
@@ -1005,8 +1005,8 @@ discard block |
||
| 1005 | 1005 | |
| 1006 | 1006 | $dtstart = $dtend = $dtabbr = ''; |
| 1007 | 1007 | if (str_contains($forme, 'hcal')) { |
| 1008 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1009 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1008 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1009 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1010 | 1010 | $dtabbr = '</abbr>'; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | } |
| 1055 | 1055 | } else { |
| 1056 | 1056 | $s = $dtabbr && $dtstart |
| 1057 | - ? $dtstart . spip_ucfirst($s) . $dtabbr |
|
| 1057 | + ? $dtstart.spip_ucfirst($s).$dtabbr |
|
| 1058 | 1058 | : spip_ucfirst($s); |
| 1059 | 1059 | } |
| 1060 | 1060 | } else { |
@@ -1073,8 +1073,8 @@ discard block |
||
| 1073 | 1073 | $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
| 1074 | 1074 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1075 | 1075 | } |
| 1076 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1077 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1076 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1077 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1078 | 1078 | |
| 1079 | 1079 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1080 | 1080 | } else { |
@@ -1091,8 +1091,8 @@ discard block |
||
| 1091 | 1091 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1095 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1094 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1095 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1096 | 1096 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1097 | 1097 | } |
| 1098 | 1098 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | $d = date('Y-m-d'); |
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1202 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | /** |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | $d = date('Y-m-d'); |
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1222 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | /** |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Logos |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -34,23 +34,23 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function inc_chercher_logo_dist(int $id, string $_id_objet, string $mode = 'on', bool $compat_old_logos = false): array { |
| 36 | 36 | |
| 37 | - $mode = preg_replace(',\W,', '', $mode); |
|
| 38 | - if ($mode) { |
|
| 39 | - // chercher dans la base |
|
| 40 | - $mode_document = 'logo' . $mode; |
|
| 41 | - $objet = objet_type($_id_objet); |
|
| 42 | - $doc = sql_fetsel( |
|
| 43 | - 'D.*', |
|
| 44 | - 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', |
|
| 45 | - 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . $id |
|
| 46 | - ); |
|
| 47 | - if ($doc) { |
|
| 48 | - include_spip('inc/documents'); |
|
| 49 | - $d = get_spip_doc($doc['fichier']); |
|
| 50 | - return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 51 | - } |
|
| 52 | - } |
|
| 37 | + $mode = preg_replace(',\W,', '', $mode); |
|
| 38 | + if ($mode) { |
|
| 39 | + // chercher dans la base |
|
| 40 | + $mode_document = 'logo' . $mode; |
|
| 41 | + $objet = objet_type($_id_objet); |
|
| 42 | + $doc = sql_fetsel( |
|
| 43 | + 'D.*', |
|
| 44 | + 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', |
|
| 45 | + 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . $id |
|
| 46 | + ); |
|
| 47 | + if ($doc) { |
|
| 48 | + include_spip('inc/documents'); |
|
| 49 | + $d = get_spip_doc($doc['fichier']); |
|
| 50 | + return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - # coherence de type pour servir comme filtre (formulaire_login) |
|
| 55 | - return []; |
|
| 54 | + # coherence de type pour servir comme filtre (formulaire_login) |
|
| 55 | + return []; |
|
| 56 | 56 | } |
@@ -37,12 +37,12 @@ |
||
| 37 | 37 | $mode = preg_replace(',\W,', '', $mode); |
| 38 | 38 | if ($mode) { |
| 39 | 39 | // chercher dans la base |
| 40 | - $mode_document = 'logo' . $mode; |
|
| 40 | + $mode_document = 'logo'.$mode; |
|
| 41 | 41 | $objet = objet_type($_id_objet); |
| 42 | 42 | $doc = sql_fetsel( |
| 43 | 43 | 'D.*', |
| 44 | 44 | 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', |
| 45 | - 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . $id |
|
| 45 | + 'D.mode='.sql_quote($mode_document).' AND L.objet='.sql_quote($objet).' AND id_objet='.$id |
|
| 46 | 46 | ); |
| 47 | 47 | if ($doc) { |
| 48 | 48 | include_spip('inc/documents'); |