@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -39,28 +39,28 @@ discard block |
||
| 39 | 39 | * Tableau des champs et valeurs collectées |
| 40 | 40 | */ |
| 41 | 41 | function collecter_requests($white_list, $black_list = array(), $set = null, $tous = false) { |
| 42 | - $c = $set; |
|
| 43 | - if (!$c) { |
|
| 44 | - $c = array(); |
|
| 45 | - foreach ($white_list as $champ) { |
|
| 46 | - // on ne collecte que les champs reellement envoyes par defaut. |
|
| 47 | - // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
|
| 48 | - $val = _request($champ); |
|
| 49 | - if ($tous or $val !== null) { |
|
| 50 | - $c[$champ] = $val; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - // on ajoute toujours la lang en saisie possible |
|
| 54 | - // meme si pas prevu au depart pour l'objet concerne |
|
| 55 | - if ($l = _request('changer_lang')) { |
|
| 56 | - $c['lang'] = $l; |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - foreach ($black_list as $champ) { |
|
| 60 | - unset($c[$champ]); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - return $c; |
|
| 42 | + $c = $set; |
|
| 43 | + if (!$c) { |
|
| 44 | + $c = array(); |
|
| 45 | + foreach ($white_list as $champ) { |
|
| 46 | + // on ne collecte que les champs reellement envoyes par defaut. |
|
| 47 | + // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
|
| 48 | + $val = _request($champ); |
|
| 49 | + if ($tous or $val !== null) { |
|
| 50 | + $c[$champ] = $val; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + // on ajoute toujours la lang en saisie possible |
|
| 54 | + // meme si pas prevu au depart pour l'objet concerne |
|
| 55 | + if ($l = _request('changer_lang')) { |
|
| 56 | + $c['lang'] = $l; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + foreach ($black_list as $champ) { |
|
| 60 | + unset($c[$champ]); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + return $c; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -97,213 +97,213 @@ discard block |
||
| 97 | 97 | * - chaîne : Texte d'un message d'erreur |
| 98 | 98 | */ |
| 99 | 99 | function objet_modifier_champs($objet, $id_objet, $options, $c = null, $serveur = '') { |
| 100 | - if (!$id_objet = intval($id_objet)) { |
|
| 101 | - spip_log('Erreur $id_objet non defini', 'warn'); |
|
| 102 | - |
|
| 103 | - return _T('erreur_technique_enregistrement_impossible'); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - include_spip('inc/filtres'); |
|
| 107 | - |
|
| 108 | - $table_objet = table_objet($objet, $serveur); |
|
| 109 | - $spip_table_objet = table_objet_sql($objet, $serveur); |
|
| 110 | - $id_table_objet = id_table_objet($objet, $serveur); |
|
| 111 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 112 | - $desc = $trouver_table($spip_table_objet, $serveur); |
|
| 113 | - |
|
| 114 | - // Appels incomplets (sans $c) |
|
| 115 | - if (!is_array($c)) { |
|
| 116 | - spip_log('erreur appel objet_modifier_champs(' . $objet . '), manque $c'); |
|
| 117 | - |
|
| 118 | - return _T('erreur_technique_enregistrement_impossible'); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 122 | - // car elles ne relevent pas de autoriser(xxx, modifier) ; |
|
| 123 | - // il faut passer par instituer_XX() |
|
| 124 | - // TODO: faut-il passer ces variables interdites |
|
| 125 | - // dans un fichier de description separe ? |
|
| 126 | - unset($c['statut']); |
|
| 127 | - unset($c['id_parent']); |
|
| 128 | - unset($c['id_rubrique']); |
|
| 129 | - unset($c['id_secteur']); |
|
| 130 | - |
|
| 131 | - // Gerer les champs non vides |
|
| 132 | - if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 133 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 134 | - if (isset($c[$champ]) and $c[$champ] === '') { |
|
| 135 | - $c[$champ] = $sinon; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - // N'accepter que les champs qui existent |
|
| 142 | - // TODO: ici aussi on peut valider les contenus |
|
| 143 | - // en fonction du type |
|
| 144 | - $champs = array(); |
|
| 145 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 146 | - if (isset($c[$champ])) { |
|
| 147 | - $champs[$champ] = $c[$champ]; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - // Nettoyer les valeurs |
|
| 152 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 153 | - |
|
| 154 | - // Envoyer aux plugins |
|
| 155 | - $champs = pipeline('pre_edition', |
|
| 156 | - array( |
|
| 157 | - 'args' => array( |
|
| 158 | - 'table' => $spip_table_objet, // compatibilite |
|
| 159 | - 'table_objet' => $table_objet, |
|
| 160 | - 'spip_table_objet' => $spip_table_objet, |
|
| 161 | - 'desc' => $desc, |
|
| 162 | - 'type' => $objet, |
|
| 163 | - 'id_objet' => $id_objet, |
|
| 164 | - 'data' => isset($options['data']) ? $options['data'] : null, |
|
| 165 | - 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ? |
|
| 166 | - 'serveur' => $serveur, |
|
| 167 | - 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 168 | - ), |
|
| 169 | - 'data' => $champs |
|
| 170 | - ) |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - if (!$champs) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - // marquer le fait que l'objet est travaille par toto a telle date |
|
| 179 | - if ($GLOBALS['meta']['articles_modif'] != 'non') { |
|
| 180 | - include_spip('inc/drapeau_edition'); |
|
| 181 | - signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 185 | - include_spip('inc/editer'); |
|
| 186 | - if (!isset($options['data']) or is_null($options['data'])){ |
|
| 187 | - $options['data'] = &$_POST; |
|
| 188 | - } |
|
| 189 | - $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
|
| 190 | - // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
|
| 191 | - // et gere l'interface |
|
| 192 | - // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
|
| 193 | - if ($conflits) { |
|
| 194 | - return _T('titre_conflit_edition'); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - if ($champs) { |
|
| 198 | - // cas particulier de la langue : passer par instituer_langue_objet |
|
| 199 | - if (isset($champs['lang'])) { |
|
| 200 | - if ($changer_lang = $champs['lang']) { |
|
| 201 | - $id_rubrique = 0; |
|
| 202 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 203 | - $parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique'; |
|
| 204 | - $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=" . intval($id_objet)); |
|
| 205 | - } |
|
| 206 | - $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
|
| 207 | - $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur); |
|
| 208 | - } |
|
| 209 | - // on laisse 'lang' dans $champs, |
|
| 210 | - // ca permet de passer dans le pipeline post_edition et de journaliser |
|
| 211 | - // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir |
|
| 212 | - // deja pris en compte |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - // la modif peut avoir lieu |
|
| 216 | - |
|
| 217 | - // faut-il ajouter date_modif ? |
|
| 218 | - if (isset($options['date_modif']) and $options['date_modif'] |
|
| 219 | - and !isset($champs[$options['date_modif']]) |
|
| 220 | - ) { |
|
| 221 | - $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - // allez on commit la modif |
|
| 225 | - sql_updateq($spip_table_objet, $champs, "$id_table_objet=" . intval($id_objet), $serveur); |
|
| 226 | - |
|
| 227 | - // on verifie si elle est bien passee |
|
| 228 | - $moof = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=" . intval($id_objet), array(), array(), |
|
| 229 | - '', array(), $serveur); |
|
| 230 | - // si difference entre les champs, reperer les champs mal enregistres |
|
| 231 | - if ($moof != $champs) { |
|
| 232 | - $liste = array(); |
|
| 233 | - foreach ($moof as $k => $v) { |
|
| 234 | - if ($v !== $champs[$k] |
|
| 235 | - // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
|
| 236 | - and (!is_numeric($v) or intval($v) !== intval($champs[$k])) |
|
| 237 | - // ne pas alerter si le champ est date, qu'on a envoye une valeur vide et qu'on recupere une date nulle |
|
| 238 | - and (strlen($champs[$k]) or !in_array($v, ['0000-00-00 00:00:00', '0000-00-00'])) |
|
| 239 | - ) { |
|
| 240 | - $liste[] = $k; |
|
| 241 | - $conflits[$k]['post'] = $champs[$k]; |
|
| 242 | - $conflits[$k]['save'] = $v; |
|
| 243 | - |
|
| 244 | - // cas specifique MySQL+emoji : si l'un est la |
|
| 245 | - // conversion utf8_noplanes de l'autre alors c'est OK |
|
| 246 | - if (defined('_MYSQL_NOPLANES') && _MYSQL_NOPLANES) { |
|
| 247 | - include_spip('inc/charsets'); |
|
| 248 | - if ($v == utf8_noplanes($champs[$k])) { |
|
| 249 | - array_pop($liste); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
|
| 255 | - // c'est un cas exceptionnel |
|
| 256 | - if (count($liste)) { |
|
| 257 | - spip_log("Erreur enregistrement en base $objet/$id_objet champs :" . var_export($conflits, true), |
|
| 258 | - 'modifier.' . _LOG_CRITIQUE); |
|
| 259 | - |
|
| 260 | - return _T('erreur_technique_enregistrement_champs', |
|
| 261 | - array('champs' => "<i>'" . implode("'</i>,<i>'", $liste) . "'</i>")); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - // Invalider les caches |
|
| 266 | - if (isset($options['invalideur']) and $options['invalideur']) { |
|
| 267 | - include_spip('inc/invalideur'); |
|
| 268 | - if (is_array($options['invalideur'])) { |
|
| 269 | - array_map('suivre_invalideur', $options['invalideur']); |
|
| 270 | - } else { |
|
| 271 | - suivre_invalideur($options['invalideur']); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - // Notifications, gestion des revisions... |
|
| 276 | - // en standard, appelle |nouvelle_revision ci-dessous |
|
| 277 | - pipeline('post_edition', |
|
| 278 | - array( |
|
| 279 | - 'args' => array( |
|
| 280 | - 'table' => $spip_table_objet, |
|
| 281 | - 'table_objet' => $table_objet, |
|
| 282 | - 'spip_table_objet' => $spip_table_objet, |
|
| 283 | - 'desc' => $desc, |
|
| 284 | - 'type' => $objet, |
|
| 285 | - 'id_objet' => $id_objet, |
|
| 286 | - 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] kesako ? |
|
| 287 | - 'serveur' => $serveur, |
|
| 288 | - 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 289 | - ), |
|
| 290 | - 'data' => $champs |
|
| 291 | - ) |
|
| 292 | - ); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // journaliser l'affaire |
|
| 296 | - // message a affiner :-) |
|
| 297 | - include_spip('inc/filtres_mini'); |
|
| 298 | - $qui = isset($GLOBALS['visiteur_session']['nom']) and $GLOBALS['visiteur_session']['nom'] ? $GLOBALS['visiteur_session']['nom'] : $GLOBALS['ip']; |
|
| 299 | - journal(_L($qui . ' a édité l’' . $objet . ' ' . $id_objet . ' (' . join('+', |
|
| 300 | - array_diff(array_keys($champs), array('date_modif'))) . ')'), array( |
|
| 301 | - 'faire' => 'modifier', |
|
| 302 | - 'quoi' => $objet, |
|
| 303 | - 'id' => $id_objet |
|
| 304 | - )); |
|
| 305 | - |
|
| 306 | - return ''; |
|
| 100 | + if (!$id_objet = intval($id_objet)) { |
|
| 101 | + spip_log('Erreur $id_objet non defini', 'warn'); |
|
| 102 | + |
|
| 103 | + return _T('erreur_technique_enregistrement_impossible'); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + include_spip('inc/filtres'); |
|
| 107 | + |
|
| 108 | + $table_objet = table_objet($objet, $serveur); |
|
| 109 | + $spip_table_objet = table_objet_sql($objet, $serveur); |
|
| 110 | + $id_table_objet = id_table_objet($objet, $serveur); |
|
| 111 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 112 | + $desc = $trouver_table($spip_table_objet, $serveur); |
|
| 113 | + |
|
| 114 | + // Appels incomplets (sans $c) |
|
| 115 | + if (!is_array($c)) { |
|
| 116 | + spip_log('erreur appel objet_modifier_champs(' . $objet . '), manque $c'); |
|
| 117 | + |
|
| 118 | + return _T('erreur_technique_enregistrement_impossible'); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 122 | + // car elles ne relevent pas de autoriser(xxx, modifier) ; |
|
| 123 | + // il faut passer par instituer_XX() |
|
| 124 | + // TODO: faut-il passer ces variables interdites |
|
| 125 | + // dans un fichier de description separe ? |
|
| 126 | + unset($c['statut']); |
|
| 127 | + unset($c['id_parent']); |
|
| 128 | + unset($c['id_rubrique']); |
|
| 129 | + unset($c['id_secteur']); |
|
| 130 | + |
|
| 131 | + // Gerer les champs non vides |
|
| 132 | + if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 133 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 134 | + if (isset($c[$champ]) and $c[$champ] === '') { |
|
| 135 | + $c[$champ] = $sinon; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + // N'accepter que les champs qui existent |
|
| 142 | + // TODO: ici aussi on peut valider les contenus |
|
| 143 | + // en fonction du type |
|
| 144 | + $champs = array(); |
|
| 145 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 146 | + if (isset($c[$champ])) { |
|
| 147 | + $champs[$champ] = $c[$champ]; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + // Nettoyer les valeurs |
|
| 152 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 153 | + |
|
| 154 | + // Envoyer aux plugins |
|
| 155 | + $champs = pipeline('pre_edition', |
|
| 156 | + array( |
|
| 157 | + 'args' => array( |
|
| 158 | + 'table' => $spip_table_objet, // compatibilite |
|
| 159 | + 'table_objet' => $table_objet, |
|
| 160 | + 'spip_table_objet' => $spip_table_objet, |
|
| 161 | + 'desc' => $desc, |
|
| 162 | + 'type' => $objet, |
|
| 163 | + 'id_objet' => $id_objet, |
|
| 164 | + 'data' => isset($options['data']) ? $options['data'] : null, |
|
| 165 | + 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ? |
|
| 166 | + 'serveur' => $serveur, |
|
| 167 | + 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 168 | + ), |
|
| 169 | + 'data' => $champs |
|
| 170 | + ) |
|
| 171 | + ); |
|
| 172 | + |
|
| 173 | + if (!$champs) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + // marquer le fait que l'objet est travaille par toto a telle date |
|
| 179 | + if ($GLOBALS['meta']['articles_modif'] != 'non') { |
|
| 180 | + include_spip('inc/drapeau_edition'); |
|
| 181 | + signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 185 | + include_spip('inc/editer'); |
|
| 186 | + if (!isset($options['data']) or is_null($options['data'])){ |
|
| 187 | + $options['data'] = &$_POST; |
|
| 188 | + } |
|
| 189 | + $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
|
| 190 | + // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
|
| 191 | + // et gere l'interface |
|
| 192 | + // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
|
| 193 | + if ($conflits) { |
|
| 194 | + return _T('titre_conflit_edition'); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + if ($champs) { |
|
| 198 | + // cas particulier de la langue : passer par instituer_langue_objet |
|
| 199 | + if (isset($champs['lang'])) { |
|
| 200 | + if ($changer_lang = $champs['lang']) { |
|
| 201 | + $id_rubrique = 0; |
|
| 202 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 203 | + $parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique'; |
|
| 204 | + $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=" . intval($id_objet)); |
|
| 205 | + } |
|
| 206 | + $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
|
| 207 | + $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur); |
|
| 208 | + } |
|
| 209 | + // on laisse 'lang' dans $champs, |
|
| 210 | + // ca permet de passer dans le pipeline post_edition et de journaliser |
|
| 211 | + // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir |
|
| 212 | + // deja pris en compte |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // la modif peut avoir lieu |
|
| 216 | + |
|
| 217 | + // faut-il ajouter date_modif ? |
|
| 218 | + if (isset($options['date_modif']) and $options['date_modif'] |
|
| 219 | + and !isset($champs[$options['date_modif']]) |
|
| 220 | + ) { |
|
| 221 | + $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + // allez on commit la modif |
|
| 225 | + sql_updateq($spip_table_objet, $champs, "$id_table_objet=" . intval($id_objet), $serveur); |
|
| 226 | + |
|
| 227 | + // on verifie si elle est bien passee |
|
| 228 | + $moof = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=" . intval($id_objet), array(), array(), |
|
| 229 | + '', array(), $serveur); |
|
| 230 | + // si difference entre les champs, reperer les champs mal enregistres |
|
| 231 | + if ($moof != $champs) { |
|
| 232 | + $liste = array(); |
|
| 233 | + foreach ($moof as $k => $v) { |
|
| 234 | + if ($v !== $champs[$k] |
|
| 235 | + // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
|
| 236 | + and (!is_numeric($v) or intval($v) !== intval($champs[$k])) |
|
| 237 | + // ne pas alerter si le champ est date, qu'on a envoye une valeur vide et qu'on recupere une date nulle |
|
| 238 | + and (strlen($champs[$k]) or !in_array($v, ['0000-00-00 00:00:00', '0000-00-00'])) |
|
| 239 | + ) { |
|
| 240 | + $liste[] = $k; |
|
| 241 | + $conflits[$k]['post'] = $champs[$k]; |
|
| 242 | + $conflits[$k]['save'] = $v; |
|
| 243 | + |
|
| 244 | + // cas specifique MySQL+emoji : si l'un est la |
|
| 245 | + // conversion utf8_noplanes de l'autre alors c'est OK |
|
| 246 | + if (defined('_MYSQL_NOPLANES') && _MYSQL_NOPLANES) { |
|
| 247 | + include_spip('inc/charsets'); |
|
| 248 | + if ($v == utf8_noplanes($champs[$k])) { |
|
| 249 | + array_pop($liste); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
|
| 255 | + // c'est un cas exceptionnel |
|
| 256 | + if (count($liste)) { |
|
| 257 | + spip_log("Erreur enregistrement en base $objet/$id_objet champs :" . var_export($conflits, true), |
|
| 258 | + 'modifier.' . _LOG_CRITIQUE); |
|
| 259 | + |
|
| 260 | + return _T('erreur_technique_enregistrement_champs', |
|
| 261 | + array('champs' => "<i>'" . implode("'</i>,<i>'", $liste) . "'</i>")); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + // Invalider les caches |
|
| 266 | + if (isset($options['invalideur']) and $options['invalideur']) { |
|
| 267 | + include_spip('inc/invalideur'); |
|
| 268 | + if (is_array($options['invalideur'])) { |
|
| 269 | + array_map('suivre_invalideur', $options['invalideur']); |
|
| 270 | + } else { |
|
| 271 | + suivre_invalideur($options['invalideur']); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + // Notifications, gestion des revisions... |
|
| 276 | + // en standard, appelle |nouvelle_revision ci-dessous |
|
| 277 | + pipeline('post_edition', |
|
| 278 | + array( |
|
| 279 | + 'args' => array( |
|
| 280 | + 'table' => $spip_table_objet, |
|
| 281 | + 'table_objet' => $table_objet, |
|
| 282 | + 'spip_table_objet' => $spip_table_objet, |
|
| 283 | + 'desc' => $desc, |
|
| 284 | + 'type' => $objet, |
|
| 285 | + 'id_objet' => $id_objet, |
|
| 286 | + 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] kesako ? |
|
| 287 | + 'serveur' => $serveur, |
|
| 288 | + 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 289 | + ), |
|
| 290 | + 'data' => $champs |
|
| 291 | + ) |
|
| 292 | + ); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // journaliser l'affaire |
|
| 296 | + // message a affiner :-) |
|
| 297 | + include_spip('inc/filtres_mini'); |
|
| 298 | + $qui = isset($GLOBALS['visiteur_session']['nom']) and $GLOBALS['visiteur_session']['nom'] ? $GLOBALS['visiteur_session']['nom'] : $GLOBALS['ip']; |
|
| 299 | + journal(_L($qui . ' a édité l’' . $objet . ' ' . $id_objet . ' (' . join('+', |
|
| 300 | + array_diff(array_keys($champs), array('date_modif'))) . ')'), array( |
|
| 301 | + 'faire' => 'modifier', |
|
| 302 | + 'quoi' => $objet, |
|
| 303 | + 'id' => $id_objet |
|
| 304 | + )); |
|
| 305 | + |
|
| 306 | + return ''; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | * false sinon (erreur ou aucun champ modifié) |
| 329 | 329 | */ |
| 330 | 330 | function modifier_contenu($type, $id, $options, $c = null, $serveur = '') { |
| 331 | - $res = objet_modifier_champs($type, $id, $options, $c, $serveur); |
|
| 331 | + $res = objet_modifier_champs($type, $id, $options, $c, $serveur); |
|
| 332 | 332 | |
| 333 | - return ($res === '' ? true : false); |
|
| 333 | + return ($res === '' ? true : false); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | * @return mixed|string |
| 352 | 352 | */ |
| 353 | 353 | function revision_objet($objet, $id_objet, $c = null) { |
| 354 | - $objet = objet_type($objet); // securite |
|
| 355 | - include_spip('action/editer_objet'); |
|
| 354 | + $objet = objet_type($objet); // securite |
|
| 355 | + include_spip('action/editer_objet'); |
|
| 356 | 356 | |
| 357 | - return objet_modifier($objet, $id_objet, $c); |
|
| 357 | + return objet_modifier($objet, $id_objet, $c); |
|
| 358 | 358 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * Date au format SQL tel que `2008-04-01` |
| 37 | 37 | **/ |
| 38 | 38 | function extraire_date($texte) { |
| 39 | - // format = 2001-08 |
|
| 40 | - if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
|
| 41 | - return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 42 | - } |
|
| 39 | + // format = 2001-08 |
|
| 40 | + if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
|
| 41 | + return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -61,29 +61,29 @@ discard block |
||
| 61 | 61 | * - une chaîne vide si la date est considérée nulle |
| 62 | 62 | **/ |
| 63 | 63 | function normaliser_date($date, $forcer_jour = false) { |
| 64 | - $date = vider_date($date); |
|
| 65 | - if ($date) { |
|
| 66 | - if (preg_match("/^[0-9]{8,10}$/", $date)) { |
|
| 67 | - $date = date("Y-m-d H:i:s", $date); |
|
| 68 | - } |
|
| 69 | - if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 70 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | - $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 72 | - } else { |
|
| 73 | - if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 74 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | - $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 76 | - } else { |
|
| 77 | - $date = date("Y-m-d H:i:s", strtotime($date)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($forcer_jour) { |
|
| 82 | - $date = str_replace('-00', '-01', $date); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return $date; |
|
| 64 | + $date = vider_date($date); |
|
| 65 | + if ($date) { |
|
| 66 | + if (preg_match("/^[0-9]{8,10}$/", $date)) { |
|
| 67 | + $date = date("Y-m-d H:i:s", $date); |
|
| 68 | + } |
|
| 69 | + if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 70 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | + $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 72 | + } else { |
|
| 73 | + if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
|
| 74 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | + $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 76 | + } else { |
|
| 77 | + $date = date("Y-m-d H:i:s", strtotime($date)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($forcer_jour) { |
|
| 82 | + $date = str_replace('-00', '-01', $date); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return $date; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -96,21 +96,21 @@ discard block |
||
| 96 | 96 | * - Une chaine vide |
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | - if (!$verif_format_date |
|
| 100 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 101 | - preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/", $letexte))) { |
|
| 102 | - |
|
| 103 | - if (strncmp("0000-00-00", $letexte, 10) == 0) { |
|
| 104 | - return ''; |
|
| 105 | - } |
|
| 106 | - if (strncmp("0001-01-01", $letexte, 10) == 0) { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - if (strncmp("1970-01-01", $letexte, 10) == 0) { |
|
| 110 | - return ''; |
|
| 111 | - } // eviter le bug GMT-1 |
|
| 112 | - } |
|
| 113 | - return $letexte; |
|
| 99 | + if (!$verif_format_date |
|
| 100 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 101 | + preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/", $letexte))) { |
|
| 102 | + |
|
| 103 | + if (strncmp("0000-00-00", $letexte, 10) == 0) { |
|
| 104 | + return ''; |
|
| 105 | + } |
|
| 106 | + if (strncmp("0001-01-01", $letexte, 10) == 0) { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + if (strncmp("1970-01-01", $letexte, 10) == 0) { |
|
| 110 | + return ''; |
|
| 111 | + } // eviter le bug GMT-1 |
|
| 112 | + } |
|
| 113 | + return $letexte; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | **/ |
| 127 | 127 | function recup_heure($date) { |
| 128 | 128 | |
| 129 | - static $d = array(0, 0, 0); |
|
| 130 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 131 | - return $d; |
|
| 132 | - } |
|
| 129 | + static $d = array(0, 0, 0); |
|
| 130 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 131 | + return $d; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - array_shift($r); |
|
| 134 | + array_shift($r); |
|
| 135 | 135 | |
| 136 | - return $r; |
|
| 136 | + return $r; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | * @return int heures, sinon 0 |
| 148 | 148 | **/ |
| 149 | 149 | function heures($numdate) { |
| 150 | - $date_array = recup_heure($numdate); |
|
| 151 | - if ($date_array) { |
|
| 152 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 153 | - } |
|
| 150 | + $date_array = recup_heure($numdate); |
|
| 151 | + if ($date_array) { |
|
| 152 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - return $heures; |
|
| 155 | + return $heures; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | * @return int minutes, sinon 0 |
| 167 | 167 | **/ |
| 168 | 168 | function minutes($numdate) { |
| 169 | - $date_array = recup_heure($numdate); |
|
| 170 | - if ($date_array) { |
|
| 171 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 172 | - } |
|
| 169 | + $date_array = recup_heure($numdate); |
|
| 170 | + if ($date_array) { |
|
| 171 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - return $minutes; |
|
| 174 | + return $minutes; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | * @return int secondes, sinon 0 |
| 186 | 186 | **/ |
| 187 | 187 | function secondes($numdate) { |
| 188 | - $date_array = recup_heure($numdate); |
|
| 189 | - if ($date_array) { |
|
| 190 | - list($heures, $minutes, $secondes) = $date_array; |
|
| 191 | - } |
|
| 188 | + $date_array = recup_heure($numdate); |
|
| 189 | + if ($date_array) { |
|
| 190 | + list($heures, $minutes, $secondes) = $date_array; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - return $secondes; |
|
| 193 | + return $secondes; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | * @return string L'heure formatée dans la langue en cours. |
| 210 | 210 | **/ |
| 211 | 211 | function heures_minutes($numdate, $forme='') { |
| 212 | - if ($forme !='abbr') { |
|
| 213 | - return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 214 | - } |
|
| 215 | - else { |
|
| 216 | - return _T('date_fmt_heures_minutes_court', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 217 | - } |
|
| 212 | + if ($forme !='abbr') { |
|
| 213 | + return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 214 | + } |
|
| 215 | + else { |
|
| 216 | + return _T('date_fmt_heures_minutes_court', array('h' => heures($numdate), 'm' => minutes($numdate))); |
|
| 217 | + } |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -239,57 +239,57 @@ discard block |
||
| 239 | 239 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 240 | 240 | **/ |
| 241 | 241 | function recup_date($numdate, $forcer_jour = true) { |
| 242 | - if (!$numdate) { |
|
| 243 | - return ''; |
|
| 244 | - } |
|
| 245 | - $heures = $minutes = $secondes = 0; |
|
| 246 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 247 | - $jour = $regs[1]; |
|
| 248 | - $mois = $regs[2]; |
|
| 249 | - $annee = $regs[3]; |
|
| 250 | - if ($annee < 90) { |
|
| 251 | - $annee = 2000 + $annee; |
|
| 252 | - } elseif ($annee < 100) { |
|
| 253 | - $annee = 1900 + $annee; |
|
| 254 | - } |
|
| 255 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 256 | - |
|
| 257 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 258 | - $annee = $regs[1]; |
|
| 259 | - $mois = $regs[2]; |
|
| 260 | - $jour = $regs[3]; |
|
| 261 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 262 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 263 | - $annee = $regs[1]; |
|
| 264 | - $mois = $regs[2]; |
|
| 265 | - $jour = ''; |
|
| 266 | - list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 267 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 268 | - $annee = $regs[1]; |
|
| 269 | - $mois = $regs[2]; |
|
| 270 | - $jour = $regs[3]; |
|
| 271 | - $heures = $regs[4]; |
|
| 272 | - $minutes = $regs[5]; |
|
| 273 | - $secondes = $regs[6]; |
|
| 274 | - } else { |
|
| 275 | - $annee = $mois = $jour = ''; |
|
| 276 | - } |
|
| 277 | - if ($annee > 4000) { |
|
| 278 | - $annee -= 9000; |
|
| 279 | - } |
|
| 280 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 281 | - $jour = substr($jour, 1); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - if ($forcer_jour and $jour == '0') { |
|
| 285 | - $jour = '1'; |
|
| 286 | - } |
|
| 287 | - if ($forcer_jour and $mois == '0') { |
|
| 288 | - $mois = '1'; |
|
| 289 | - } |
|
| 290 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 291 | - return array($annee, $mois, $jour, $heures, $minutes, $secondes); |
|
| 292 | - } |
|
| 242 | + if (!$numdate) { |
|
| 243 | + return ''; |
|
| 244 | + } |
|
| 245 | + $heures = $minutes = $secondes = 0; |
|
| 246 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 247 | + $jour = $regs[1]; |
|
| 248 | + $mois = $regs[2]; |
|
| 249 | + $annee = $regs[3]; |
|
| 250 | + if ($annee < 90) { |
|
| 251 | + $annee = 2000 + $annee; |
|
| 252 | + } elseif ($annee < 100) { |
|
| 253 | + $annee = 1900 + $annee; |
|
| 254 | + } |
|
| 255 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 256 | + |
|
| 257 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 258 | + $annee = $regs[1]; |
|
| 259 | + $mois = $regs[2]; |
|
| 260 | + $jour = $regs[3]; |
|
| 261 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 262 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 263 | + $annee = $regs[1]; |
|
| 264 | + $mois = $regs[2]; |
|
| 265 | + $jour = ''; |
|
| 266 | + list($heures, $minutes, $secondes) = recup_heure($numdate); |
|
| 267 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 268 | + $annee = $regs[1]; |
|
| 269 | + $mois = $regs[2]; |
|
| 270 | + $jour = $regs[3]; |
|
| 271 | + $heures = $regs[4]; |
|
| 272 | + $minutes = $regs[5]; |
|
| 273 | + $secondes = $regs[6]; |
|
| 274 | + } else { |
|
| 275 | + $annee = $mois = $jour = ''; |
|
| 276 | + } |
|
| 277 | + if ($annee > 4000) { |
|
| 278 | + $annee -= 9000; |
|
| 279 | + } |
|
| 280 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 281 | + $jour = substr($jour, 1); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + if ($forcer_jour and $jour == '0') { |
|
| 285 | + $jour = '1'; |
|
| 286 | + } |
|
| 287 | + if ($forcer_jour and $mois == '0') { |
|
| 288 | + $mois = '1'; |
|
| 289 | + } |
|
| 290 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 291 | + return array($annee, $mois, $jour, $heures, $minutes, $secondes); |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * La date relative ou complète |
| 317 | 317 | **/ |
| 318 | 318 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) { |
| 319 | - return sinon( |
|
| 320 | - date_relative($date, $decalage_maxi), |
|
| 321 | - affdate_heure($date) |
|
| 322 | - ); |
|
| 319 | + return sinon( |
|
| 320 | + date_relative($date, $decalage_maxi), |
|
| 321 | + affdate_heure($date) |
|
| 322 | + ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -352,85 +352,85 @@ discard block |
||
| 352 | 352 | **/ |
| 353 | 353 | function date_relative($date, $decalage_maxi = 0, $ref_date = null) { |
| 354 | 354 | |
| 355 | - if (is_null($ref_date)) { |
|
| 356 | - $ref_time = time(); |
|
| 357 | - } else { |
|
| 358 | - $ref_time = strtotime($ref_date); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - if (!$date) { |
|
| 362 | - return; |
|
| 363 | - } |
|
| 364 | - $decal = date("U", $ref_time) - date("U", strtotime($date)); |
|
| 365 | - |
|
| 366 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 367 | - return ''; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - if ($decal < 0) { |
|
| 371 | - $il_y_a = "date_dans"; |
|
| 372 | - $decal = -1 * $decal; |
|
| 373 | - } else { |
|
| 374 | - $il_y_a = "date_il_y_a"; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 378 | - return affdate_court($date); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - if ($decal > 3600 * 24 * 30) { |
|
| 382 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 383 | - if ($mois < 2) { |
|
| 384 | - $delai = "$mois " . _T("date_un_mois"); |
|
| 385 | - } else { |
|
| 386 | - $delai = "$mois " . _T("date_mois"); |
|
| 387 | - } |
|
| 388 | - } else { |
|
| 389 | - if ($decal > 3600 * 24 * 7) { |
|
| 390 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 391 | - if ($semaines < 2) { |
|
| 392 | - $delai = "$semaines " . _T("date_une_semaine"); |
|
| 393 | - } else { |
|
| 394 | - $delai = "$semaines " . _T("date_semaines"); |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - if ($decal > 3600 * 24) { |
|
| 398 | - $jours = floor($decal / (3600 * 24)); |
|
| 399 | - if ($jours < 2) { |
|
| 400 | - return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
|
| 401 | - } else { |
|
| 402 | - $delai = "$jours " . _T("date_jours"); |
|
| 403 | - } |
|
| 404 | - } else { |
|
| 405 | - if ($decal >= 3600) { |
|
| 406 | - $heures = floor($decal / 3600); |
|
| 407 | - if ($heures < 2) { |
|
| 408 | - $delai = "$heures " . _T("date_une_heure"); |
|
| 409 | - } else { |
|
| 410 | - $delai = "$heures " . _T("date_heures"); |
|
| 411 | - } |
|
| 412 | - } else { |
|
| 413 | - if ($decal >= 60) { |
|
| 414 | - $minutes = floor($decal / 60); |
|
| 415 | - if ($minutes < 2) { |
|
| 416 | - $delai = "$minutes " . _T("date_une_minute"); |
|
| 417 | - } else { |
|
| 418 | - $delai = "$minutes " . _T("date_minutes"); |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - $secondes = ceil($decal); |
|
| 422 | - if ($secondes < 2) { |
|
| 423 | - $delai = "$secondes " . _T("date_une_seconde"); |
|
| 424 | - } else { |
|
| 425 | - $delai = "$secondes " . _T("date_secondes"); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - return _T($il_y_a, array("delai" => $delai)); |
|
| 355 | + if (is_null($ref_date)) { |
|
| 356 | + $ref_time = time(); |
|
| 357 | + } else { |
|
| 358 | + $ref_time = strtotime($ref_date); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + if (!$date) { |
|
| 362 | + return; |
|
| 363 | + } |
|
| 364 | + $decal = date("U", $ref_time) - date("U", strtotime($date)); |
|
| 365 | + |
|
| 366 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 367 | + return ''; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + if ($decal < 0) { |
|
| 371 | + $il_y_a = "date_dans"; |
|
| 372 | + $decal = -1 * $decal; |
|
| 373 | + } else { |
|
| 374 | + $il_y_a = "date_il_y_a"; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 378 | + return affdate_court($date); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + if ($decal > 3600 * 24 * 30) { |
|
| 382 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 383 | + if ($mois < 2) { |
|
| 384 | + $delai = "$mois " . _T("date_un_mois"); |
|
| 385 | + } else { |
|
| 386 | + $delai = "$mois " . _T("date_mois"); |
|
| 387 | + } |
|
| 388 | + } else { |
|
| 389 | + if ($decal > 3600 * 24 * 7) { |
|
| 390 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 391 | + if ($semaines < 2) { |
|
| 392 | + $delai = "$semaines " . _T("date_une_semaine"); |
|
| 393 | + } else { |
|
| 394 | + $delai = "$semaines " . _T("date_semaines"); |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + if ($decal > 3600 * 24) { |
|
| 398 | + $jours = floor($decal / (3600 * 24)); |
|
| 399 | + if ($jours < 2) { |
|
| 400 | + return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
|
| 401 | + } else { |
|
| 402 | + $delai = "$jours " . _T("date_jours"); |
|
| 403 | + } |
|
| 404 | + } else { |
|
| 405 | + if ($decal >= 3600) { |
|
| 406 | + $heures = floor($decal / 3600); |
|
| 407 | + if ($heures < 2) { |
|
| 408 | + $delai = "$heures " . _T("date_une_heure"); |
|
| 409 | + } else { |
|
| 410 | + $delai = "$heures " . _T("date_heures"); |
|
| 411 | + } |
|
| 412 | + } else { |
|
| 413 | + if ($decal >= 60) { |
|
| 414 | + $minutes = floor($decal / 60); |
|
| 415 | + if ($minutes < 2) { |
|
| 416 | + $delai = "$minutes " . _T("date_une_minute"); |
|
| 417 | + } else { |
|
| 418 | + $delai = "$minutes " . _T("date_minutes"); |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + $secondes = ceil($decal); |
|
| 422 | + if ($secondes < 2) { |
|
| 423 | + $delai = "$secondes " . _T("date_une_seconde"); |
|
| 424 | + } else { |
|
| 425 | + $delai = "$secondes " . _T("date_secondes"); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + return _T($il_y_a, array("delai" => $delai)); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
@@ -456,32 +456,32 @@ discard block |
||
| 456 | 456 | **/ |
| 457 | 457 | function date_relativecourt($date, $decalage_maxi = 0) { |
| 458 | 458 | |
| 459 | - if (!$date) { |
|
| 460 | - return; |
|
| 461 | - } |
|
| 462 | - $decal = date("U", strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 463 | - |
|
| 464 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 465 | - return ''; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - if ($decal < -24 * 3600) { |
|
| 469 | - $retour = date_relative($date, $decalage_maxi); |
|
| 470 | - } elseif ($decal < 0) { |
|
| 471 | - $retour = _T("date_demain"); |
|
| 472 | - } else { |
|
| 473 | - if ($decal < (3600 * 24)) { |
|
| 474 | - $retour = _T("date_aujourdhui"); |
|
| 475 | - } else { |
|
| 476 | - if ($decal < (3600 * 24 * 2)) { |
|
| 477 | - $retour = _T("date_hier"); |
|
| 478 | - } else { |
|
| 479 | - $retour = date_relative($date, $decalage_maxi); |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return $retour; |
|
| 459 | + if (!$date) { |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | + $decal = date("U", strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 463 | + |
|
| 464 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 465 | + return ''; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + if ($decal < -24 * 3600) { |
|
| 469 | + $retour = date_relative($date, $decalage_maxi); |
|
| 470 | + } elseif ($decal < 0) { |
|
| 471 | + $retour = _T("date_demain"); |
|
| 472 | + } else { |
|
| 473 | + if ($decal < (3600 * 24)) { |
|
| 474 | + $retour = _T("date_aujourdhui"); |
|
| 475 | + } else { |
|
| 476 | + if ($decal < (3600 * 24 * 2)) { |
|
| 477 | + $retour = _T("date_hier"); |
|
| 478 | + } else { |
|
| 479 | + $retour = date_relative($date, $decalage_maxi); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return $retour; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -500,165 +500,165 @@ discard block |
||
| 500 | 500 | * @return mixed|string |
| 501 | 501 | */ |
| 502 | 502 | function affdate_base($numdate, $vue, $options = array()) { |
| 503 | - if (is_string($options)) { |
|
| 504 | - $options = array('param' => $options); |
|
| 505 | - } |
|
| 506 | - $date_array = recup_date($numdate, false); |
|
| 507 | - if (!$date_array) { |
|
| 508 | - return; |
|
| 509 | - } |
|
| 510 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 511 | - |
|
| 512 | - // 1er, 21st, etc. |
|
| 513 | - $journum = $jour; |
|
| 514 | - |
|
| 515 | - if ($jour == 0) { |
|
| 516 | - $jour = ''; |
|
| 517 | - $njour = 0; |
|
| 518 | - } else { |
|
| 519 | - $njour = intval($jour); |
|
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 521 | - $jour = $jourth; |
|
| 522 | - } |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - $mois = intval($mois); |
|
| 526 | - if ($mois > 0 and $mois < 13) { |
|
| 527 | - $nommois = _T('date_mois_' . $mois); |
|
| 528 | - if ($jour) { |
|
| 529 | - $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 530 | - } else { |
|
| 531 | - $jourmois = $nommois; |
|
| 532 | - } |
|
| 533 | - } else { |
|
| 534 | - $nommois = ''; |
|
| 535 | - $jourmois = ''; |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - if ($annee < 0) { |
|
| 539 | - $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 540 | - $avjc = true; |
|
| 541 | - } else { |
|
| 542 | - $avjc = false; |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - switch ($vue) { |
|
| 546 | - case 'saison': |
|
| 547 | - case 'saison_annee': |
|
| 548 | - $saison = ''; |
|
| 549 | - if ($mois > 0) { |
|
| 550 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 551 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 552 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 553 | - } |
|
| 554 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 555 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 556 | - } |
|
| 557 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 558 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 559 | - } |
|
| 560 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 561 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 562 | - } |
|
| 563 | - } |
|
| 564 | - if ($vue == 'saison') { |
|
| 565 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 566 | - } else { |
|
| 567 | - return $saison ? trim(_T('date_fmt_saison_annee', |
|
| 568 | - array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - case 'court': |
|
| 572 | - if ($avjc) { |
|
| 573 | - return $annee; |
|
| 574 | - } |
|
| 575 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 576 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 577 | - return $annee; |
|
| 578 | - } |
|
| 579 | - if ($annee != $a) { |
|
| 580 | - return _T('date_fmt_mois_annee', |
|
| 581 | - array('mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee)); |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - return _T('date_fmt_jour_mois', |
|
| 585 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 586 | - |
|
| 587 | - case 'jourcourt': |
|
| 588 | - if ($avjc) { |
|
| 589 | - return $annee; |
|
| 590 | - } |
|
| 591 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 592 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 593 | - return $annee; |
|
| 594 | - } |
|
| 595 | - if ($annee != $a) { |
|
| 596 | - return _T('date_fmt_jour_mois_annee', |
|
| 597 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - return _T('date_fmt_jour_mois', |
|
| 601 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 602 | - |
|
| 603 | - case 'entier': |
|
| 604 | - if ($avjc) { |
|
| 605 | - return $annee; |
|
| 606 | - } |
|
| 607 | - if ($jour) { |
|
| 608 | - return _T('date_fmt_jour_mois_annee', |
|
| 609 | - array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 610 | - } elseif ($mois) { |
|
| 611 | - return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 612 | - } else { |
|
| 613 | - return $annee; |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - case 'nom_mois': |
|
| 617 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 618 | - if ($param and $mois) { |
|
| 619 | - return _T('date_mois_' . $mois . $param); |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - return $nommois; |
|
| 623 | - |
|
| 624 | - case 'mois': |
|
| 625 | - return sprintf("%02s", $mois); |
|
| 626 | - |
|
| 627 | - case 'jour': |
|
| 628 | - return $jour; |
|
| 629 | - |
|
| 630 | - case 'journum': |
|
| 631 | - return $journum; |
|
| 632 | - |
|
| 633 | - case 'nom_jour': |
|
| 634 | - if (!$mois or !$njour) { |
|
| 635 | - return ''; |
|
| 636 | - } |
|
| 637 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 638 | - $nom = 1 + date('w', $nom); |
|
| 639 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 640 | - |
|
| 641 | - return _T('date_jour_' . $nom . $param); |
|
| 642 | - |
|
| 643 | - case 'mois_annee': |
|
| 644 | - if ($avjc) { |
|
| 645 | - return $annee; |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 649 | - |
|
| 650 | - case 'annee': |
|
| 651 | - return $annee; |
|
| 652 | - |
|
| 653 | - // Cas d'une vue non definie : retomber sur le format |
|
| 654 | - // de date propose par http://www.php.net/date |
|
| 655 | - default: |
|
| 656 | - list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 657 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 658 | - $time = strtotime($numdate); |
|
| 659 | - } |
|
| 660 | - return date($vue, $time); |
|
| 661 | - } |
|
| 503 | + if (is_string($options)) { |
|
| 504 | + $options = array('param' => $options); |
|
| 505 | + } |
|
| 506 | + $date_array = recup_date($numdate, false); |
|
| 507 | + if (!$date_array) { |
|
| 508 | + return; |
|
| 509 | + } |
|
| 510 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 511 | + |
|
| 512 | + // 1er, 21st, etc. |
|
| 513 | + $journum = $jour; |
|
| 514 | + |
|
| 515 | + if ($jour == 0) { |
|
| 516 | + $jour = ''; |
|
| 517 | + $njour = 0; |
|
| 518 | + } else { |
|
| 519 | + $njour = intval($jour); |
|
| 520 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 521 | + $jour = $jourth; |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + $mois = intval($mois); |
|
| 526 | + if ($mois > 0 and $mois < 13) { |
|
| 527 | + $nommois = _T('date_mois_' . $mois); |
|
| 528 | + if ($jour) { |
|
| 529 | + $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 530 | + } else { |
|
| 531 | + $jourmois = $nommois; |
|
| 532 | + } |
|
| 533 | + } else { |
|
| 534 | + $nommois = ''; |
|
| 535 | + $jourmois = ''; |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + if ($annee < 0) { |
|
| 539 | + $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 540 | + $avjc = true; |
|
| 541 | + } else { |
|
| 542 | + $avjc = false; |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + switch ($vue) { |
|
| 546 | + case 'saison': |
|
| 547 | + case 'saison_annee': |
|
| 548 | + $saison = ''; |
|
| 549 | + if ($mois > 0) { |
|
| 550 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 551 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 552 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 553 | + } |
|
| 554 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 555 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 556 | + } |
|
| 557 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 558 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 559 | + } |
|
| 560 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 561 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 562 | + } |
|
| 563 | + } |
|
| 564 | + if ($vue == 'saison') { |
|
| 565 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 566 | + } else { |
|
| 567 | + return $saison ? trim(_T('date_fmt_saison_annee', |
|
| 568 | + array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + case 'court': |
|
| 572 | + if ($avjc) { |
|
| 573 | + return $annee; |
|
| 574 | + } |
|
| 575 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 576 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 577 | + return $annee; |
|
| 578 | + } |
|
| 579 | + if ($annee != $a) { |
|
| 580 | + return _T('date_fmt_mois_annee', |
|
| 581 | + array('mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee)); |
|
| 582 | + } |
|
| 583 | + |
|
| 584 | + return _T('date_fmt_jour_mois', |
|
| 585 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 586 | + |
|
| 587 | + case 'jourcourt': |
|
| 588 | + if ($avjc) { |
|
| 589 | + return $annee; |
|
| 590 | + } |
|
| 591 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 592 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 593 | + return $annee; |
|
| 594 | + } |
|
| 595 | + if ($annee != $a) { |
|
| 596 | + return _T('date_fmt_jour_mois_annee', |
|
| 597 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + return _T('date_fmt_jour_mois', |
|
| 601 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 602 | + |
|
| 603 | + case 'entier': |
|
| 604 | + if ($avjc) { |
|
| 605 | + return $annee; |
|
| 606 | + } |
|
| 607 | + if ($jour) { |
|
| 608 | + return _T('date_fmt_jour_mois_annee', |
|
| 609 | + array('jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee)); |
|
| 610 | + } elseif ($mois) { |
|
| 611 | + return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 612 | + } else { |
|
| 613 | + return $annee; |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + case 'nom_mois': |
|
| 617 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 618 | + if ($param and $mois) { |
|
| 619 | + return _T('date_mois_' . $mois . $param); |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + return $nommois; |
|
| 623 | + |
|
| 624 | + case 'mois': |
|
| 625 | + return sprintf("%02s", $mois); |
|
| 626 | + |
|
| 627 | + case 'jour': |
|
| 628 | + return $jour; |
|
| 629 | + |
|
| 630 | + case 'journum': |
|
| 631 | + return $journum; |
|
| 632 | + |
|
| 633 | + case 'nom_jour': |
|
| 634 | + if (!$mois or !$njour) { |
|
| 635 | + return ''; |
|
| 636 | + } |
|
| 637 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 638 | + $nom = 1 + date('w', $nom); |
|
| 639 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 640 | + |
|
| 641 | + return _T('date_jour_' . $nom . $param); |
|
| 642 | + |
|
| 643 | + case 'mois_annee': |
|
| 644 | + if ($avjc) { |
|
| 645 | + return $annee; |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + return trim(_T('date_fmt_mois_annee', array('mois' => $mois, 'nommois' => $nommois, 'annee' => $annee))); |
|
| 649 | + |
|
| 650 | + case 'annee': |
|
| 651 | + return $annee; |
|
| 652 | + |
|
| 653 | + // Cas d'une vue non definie : retomber sur le format |
|
| 654 | + // de date propose par http://www.php.net/date |
|
| 655 | + default: |
|
| 656 | + list($annee, $mois, $jour, $heures, $minutes, $secondes) = $date_array; |
|
| 657 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee)) { |
|
| 658 | + $time = strtotime($numdate); |
|
| 659 | + } |
|
| 660 | + return date($vue, $time); |
|
| 661 | + } |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | |
@@ -685,11 +685,11 @@ discard block |
||
| 685 | 685 | * Nom du jour |
| 686 | 686 | **/ |
| 687 | 687 | function nom_jour($numdate, $forme = '') { |
| 688 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 689 | - $forme = ''; |
|
| 690 | - } |
|
| 688 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 689 | + $forme = ''; |
|
| 690 | + } |
|
| 691 | 691 | |
| 692 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 692 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | * Numéro du jour |
| 712 | 712 | **/ |
| 713 | 713 | function jour($numdate) { |
| 714 | - return affdate_base($numdate, 'jour'); |
|
| 714 | + return affdate_base($numdate, 'jour'); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | * Numéro du jour |
| 730 | 730 | **/ |
| 731 | 731 | function journum($numdate) { |
| 732 | - return affdate_base($numdate, 'journum'); |
|
| 732 | + return affdate_base($numdate, 'journum'); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /** |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | * Numéro du mois (sur 2 chiffres) |
| 748 | 748 | **/ |
| 749 | 749 | function mois($numdate) { |
| 750 | - return affdate_base($numdate, 'mois'); |
|
| 750 | + return affdate_base($numdate, 'mois'); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | /** |
@@ -771,11 +771,11 @@ discard block |
||
| 771 | 771 | * Nom du mois |
| 772 | 772 | **/ |
| 773 | 773 | function nom_mois($numdate, $forme = '') { |
| 774 | - if (!($forme == 'abbr')) { |
|
| 775 | - $forme = ''; |
|
| 776 | - } |
|
| 774 | + if (!($forme == 'abbr')) { |
|
| 775 | + $forme = ''; |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 778 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | * Année (sur 4 chiffres) |
| 794 | 794 | **/ |
| 795 | 795 | function annee($numdate) { |
| 796 | - return affdate_base($numdate, 'annee'); |
|
| 796 | + return affdate_base($numdate, 'annee'); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | |
@@ -823,11 +823,11 @@ discard block |
||
| 823 | 823 | * La date formatée |
| 824 | 824 | **/ |
| 825 | 825 | function saison($numdate, $hemisphere = 'nord') { |
| 826 | - if ($hemisphere != 'sud') { |
|
| 827 | - $hemisphere = 'nord'; |
|
| 828 | - } |
|
| 826 | + if ($hemisphere != 'sud') { |
|
| 827 | + $hemisphere = 'nord'; |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 830 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | |
@@ -856,11 +856,11 @@ discard block |
||
| 856 | 856 | * La date formatée |
| 857 | 857 | **/ |
| 858 | 858 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 859 | - if ($hemisphere != 'sud') { |
|
| 860 | - $hemisphere = 'nord'; |
|
| 861 | - } |
|
| 859 | + if ($hemisphere != 'sud') { |
|
| 860 | + $hemisphere = 'nord'; |
|
| 861 | + } |
|
| 862 | 862 | |
| 863 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 863 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | * La date formatée |
| 889 | 889 | **/ |
| 890 | 890 | function affdate($numdate, $format = 'entier') { |
| 891 | - return affdate_base($numdate, $format); |
|
| 891 | + return affdate_base($numdate, $format); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | * La date formatée |
| 916 | 916 | **/ |
| 917 | 917 | function affdate_court($numdate, $annee_courante = null) { |
| 918 | - return affdate_base($numdate, 'court', array('annee_courante' => $annee_courante)); |
|
| 918 | + return affdate_base($numdate, 'court', array('annee_courante' => $annee_courante)); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | * La date formatée |
| 943 | 943 | **/ |
| 944 | 944 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 945 | - return affdate_base($numdate, 'jourcourt', array('annee_courante' => $annee_courante)); |
|
| 945 | + return affdate_base($numdate, 'jourcourt', array('annee_courante' => $annee_courante)); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | /** |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | * La date formatée |
| 961 | 961 | **/ |
| 962 | 962 | function affdate_mois_annee($numdate) { |
| 963 | - return affdate_base($numdate, 'mois_annee'); |
|
| 963 | + return affdate_base($numdate, 'mois_annee'); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | /** |
@@ -978,16 +978,16 @@ discard block |
||
| 978 | 978 | * La date formatée |
| 979 | 979 | **/ |
| 980 | 980 | function affdate_heure($numdate) { |
| 981 | - $date_array = recup_date($numdate); |
|
| 982 | - if (!$date_array) { |
|
| 983 | - return; |
|
| 984 | - } |
|
| 985 | - list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 986 | - |
|
| 987 | - return _T('date_fmt_jour_heure', array( |
|
| 988 | - 'jour' => affdate($numdate), |
|
| 989 | - 'heure' => _T('date_fmt_heures_minutes', array('h' => $heures, 'm' => $minutes)) |
|
| 990 | - )); |
|
| 981 | + $date_array = recup_date($numdate); |
|
| 982 | + if (!$date_array) { |
|
| 983 | + return; |
|
| 984 | + } |
|
| 985 | + list($annee, $mois, $jour, $heures, $minutes, $sec) = $date_array; |
|
| 986 | + |
|
| 987 | + return _T('date_fmt_jour_heure', array( |
|
| 988 | + 'jour' => affdate($numdate), |
|
| 989 | + 'heure' => _T('date_fmt_heures_minutes', array('h' => $heures, 'm' => $minutes)) |
|
| 990 | + )); |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | /** |
@@ -1019,114 +1019,114 @@ discard block |
||
| 1019 | 1019 | * Texte de la date |
| 1020 | 1020 | */ |
| 1021 | 1021 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1022 | - $abbr = $jour = ''; |
|
| 1023 | - $affdate = "affdate_jourcourt"; |
|
| 1024 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1025 | - $abbr = 'abbr'; |
|
| 1026 | - } |
|
| 1027 | - if (strpos($forme, 'annee') !== false) { |
|
| 1028 | - $affdate = 'affdate'; |
|
| 1029 | - } |
|
| 1030 | - if (strpos($forme, 'jour') !== false) { |
|
| 1031 | - $jour = 'jour'; |
|
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - $dtstart = $dtend = $dtabbr = ""; |
|
| 1035 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1036 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1037 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1038 | - $dtabbr = "</abbr>"; |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - $date_debut = strtotime($date_debut); |
|
| 1042 | - $date_fin = strtotime($date_fin); |
|
| 1043 | - $d = date("Y-m-d", $date_debut); |
|
| 1044 | - $f = date("Y-m-d", $date_fin); |
|
| 1045 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1046 | - $hd = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_debut), 'm' => date("i", $date_debut))); |
|
| 1047 | - $hf = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_fin), 'm' => date("i", $date_fin))); |
|
| 1048 | - |
|
| 1049 | - if ($d == $f) { // meme jour |
|
| 1050 | - $nomjour = nom_jour($d, $abbr); |
|
| 1051 | - $s = $affdate($d); |
|
| 1052 | - $s = _T('date_fmt_jour', array('nomjour' => $nomjour, 'jour' => $s)); |
|
| 1053 | - if ($h) { |
|
| 1054 | - if ($hd == $hf) { |
|
| 1055 | - // Lundi 20 fevrier a 18h25 |
|
| 1056 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', array('jour' => $s, 'heure' => $hd))); |
|
| 1057 | - $s = "$dtstart$s$dtabbr"; |
|
| 1058 | - } else { |
|
| 1059 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1060 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1061 | - $s = _T('date_fmt_jour_heure_debut_fin_abbr', array( |
|
| 1062 | - 'jour' => spip_ucfirst($s), |
|
| 1063 | - 'heure_debut' => $hd, |
|
| 1064 | - 'heure_fin' => $hf, |
|
| 1065 | - 'dtstart' => $dtstart, |
|
| 1066 | - 'dtend' => $dtend, |
|
| 1067 | - 'dtabbr' => $dtabbr |
|
| 1068 | - ), |
|
| 1069 | - array( |
|
| 1070 | - 'sanitize' => false |
|
| 1071 | - ) |
|
| 1072 | - ); |
|
| 1073 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1074 | - else { |
|
| 1075 | - $s = spip_ucfirst(_T('date_fmt_jour_heure_debut_fin', |
|
| 1076 | - array('jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf))); |
|
| 1077 | - } |
|
| 1078 | - } |
|
| 1079 | - } else { |
|
| 1080 | - if ($dtabbr && $dtstart) { |
|
| 1081 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1082 | - } else { |
|
| 1083 | - $s = spip_ucfirst($s); |
|
| 1084 | - } |
|
| 1085 | - } |
|
| 1086 | - } else { |
|
| 1087 | - if ((date("Y-m", $date_debut)) == date("Y-m", $date_fin)) { // meme annee et mois, jours differents |
|
| 1088 | - if (!$h) { |
|
| 1089 | - $date_debut = jour($d); |
|
| 1090 | - } else { |
|
| 1091 | - $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1092 | - } |
|
| 1093 | - $date_fin = $affdate($f); |
|
| 1094 | - if ($jour) { |
|
| 1095 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1096 | - $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1097 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1098 | - $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1099 | - } |
|
| 1100 | - if ($h) { |
|
| 1101 | - $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1102 | - $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1103 | - } |
|
| 1104 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1105 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1106 | - |
|
| 1107 | - $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1108 | - } else { |
|
| 1109 | - $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1110 | - $date_fin = $affdate($f); |
|
| 1111 | - if ($jour) { |
|
| 1112 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1113 | - $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1114 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1115 | - $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1116 | - } |
|
| 1117 | - if ($h) { |
|
| 1118 | - $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1119 | - $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1123 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1124 | - $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1125 | - |
|
| 1126 | - } |
|
| 1127 | - } |
|
| 1128 | - |
|
| 1129 | - return $s; |
|
| 1022 | + $abbr = $jour = ''; |
|
| 1023 | + $affdate = "affdate_jourcourt"; |
|
| 1024 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1025 | + $abbr = 'abbr'; |
|
| 1026 | + } |
|
| 1027 | + if (strpos($forme, 'annee') !== false) { |
|
| 1028 | + $affdate = 'affdate'; |
|
| 1029 | + } |
|
| 1030 | + if (strpos($forme, 'jour') !== false) { |
|
| 1031 | + $jour = 'jour'; |
|
| 1032 | + } |
|
| 1033 | + |
|
| 1034 | + $dtstart = $dtend = $dtabbr = ""; |
|
| 1035 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1036 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1037 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1038 | + $dtabbr = "</abbr>"; |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + $date_debut = strtotime($date_debut); |
|
| 1042 | + $date_fin = strtotime($date_fin); |
|
| 1043 | + $d = date("Y-m-d", $date_debut); |
|
| 1044 | + $f = date("Y-m-d", $date_fin); |
|
| 1045 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1046 | + $hd = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_debut), 'm' => date("i", $date_debut))); |
|
| 1047 | + $hf = _T('date_fmt_heures_minutes_court', array('h' => date("H", $date_fin), 'm' => date("i", $date_fin))); |
|
| 1048 | + |
|
| 1049 | + if ($d == $f) { // meme jour |
|
| 1050 | + $nomjour = nom_jour($d, $abbr); |
|
| 1051 | + $s = $affdate($d); |
|
| 1052 | + $s = _T('date_fmt_jour', array('nomjour' => $nomjour, 'jour' => $s)); |
|
| 1053 | + if ($h) { |
|
| 1054 | + if ($hd == $hf) { |
|
| 1055 | + // Lundi 20 fevrier a 18h25 |
|
| 1056 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', array('jour' => $s, 'heure' => $hd))); |
|
| 1057 | + $s = "$dtstart$s$dtabbr"; |
|
| 1058 | + } else { |
|
| 1059 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1060 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1061 | + $s = _T('date_fmt_jour_heure_debut_fin_abbr', array( |
|
| 1062 | + 'jour' => spip_ucfirst($s), |
|
| 1063 | + 'heure_debut' => $hd, |
|
| 1064 | + 'heure_fin' => $hf, |
|
| 1065 | + 'dtstart' => $dtstart, |
|
| 1066 | + 'dtend' => $dtend, |
|
| 1067 | + 'dtabbr' => $dtabbr |
|
| 1068 | + ), |
|
| 1069 | + array( |
|
| 1070 | + 'sanitize' => false |
|
| 1071 | + ) |
|
| 1072 | + ); |
|
| 1073 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1074 | + else { |
|
| 1075 | + $s = spip_ucfirst(_T('date_fmt_jour_heure_debut_fin', |
|
| 1076 | + array('jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf))); |
|
| 1077 | + } |
|
| 1078 | + } |
|
| 1079 | + } else { |
|
| 1080 | + if ($dtabbr && $dtstart) { |
|
| 1081 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1082 | + } else { |
|
| 1083 | + $s = spip_ucfirst($s); |
|
| 1084 | + } |
|
| 1085 | + } |
|
| 1086 | + } else { |
|
| 1087 | + if ((date("Y-m", $date_debut)) == date("Y-m", $date_fin)) { // meme annee et mois, jours differents |
|
| 1088 | + if (!$h) { |
|
| 1089 | + $date_debut = jour($d); |
|
| 1090 | + } else { |
|
| 1091 | + $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1092 | + } |
|
| 1093 | + $date_fin = $affdate($f); |
|
| 1094 | + if ($jour) { |
|
| 1095 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1096 | + $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1097 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1098 | + $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1099 | + } |
|
| 1100 | + if ($h) { |
|
| 1101 | + $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1102 | + $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1103 | + } |
|
| 1104 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1105 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1106 | + |
|
| 1107 | + $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1108 | + } else { |
|
| 1109 | + $date_debut = affdate_jourcourt($d, date("Y", $date_fin)); |
|
| 1110 | + $date_fin = $affdate($f); |
|
| 1111 | + if ($jour) { |
|
| 1112 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1113 | + $date_debut = _T('date_fmt_jour', array('nomjour' => $nomjour_debut, 'jour' => $date_debut)); |
|
| 1114 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1115 | + $date_fin = _T('date_fmt_jour', array('nomjour' => $nomjour_fin, 'jour' => $date_fin)); |
|
| 1116 | + } |
|
| 1117 | + if ($h) { |
|
| 1118 | + $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
|
| 1119 | + $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1123 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1124 | + $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
|
| 1125 | + |
|
| 1126 | + } |
|
| 1127 | + } |
|
| 1128 | + |
|
| 1129 | + return $s; |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | /** |
@@ -1147,10 +1147,10 @@ discard block |
||
| 1147 | 1147 | * Date au format ical |
| 1148 | 1148 | **/ |
| 1149 | 1149 | function date_ical($date, $addminutes = 0) { |
| 1150 | - list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1151 | - list($annee, $mois, $jour) = recup_date($date); |
|
| 1150 | + list($heures, $minutes, $secondes) = recup_heure($date); |
|
| 1151 | + list($annee, $mois, $jour) = recup_date($date); |
|
| 1152 | 1152 | |
| 1153 | - return gmdate("Ymd\THis\Z", mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1153 | + return gmdate("Ymd\THis\Z", mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | |
@@ -1174,11 +1174,11 @@ discard block |
||
| 1174 | 1174 | * La date formatée |
| 1175 | 1175 | **/ |
| 1176 | 1176 | function date_iso($date_heure) { |
| 1177 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1178 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1179 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1177 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1178 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1179 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1180 | 1180 | |
| 1181 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1181 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | /** |
@@ -1201,11 +1201,11 @@ discard block |
||
| 1201 | 1201 | * La date formatée |
| 1202 | 1202 | **/ |
| 1203 | 1203 | function date_822($date_heure) { |
| 1204 | - list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1205 | - list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1206 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1204 | + list($annee, $mois, $jour) = recup_date($date_heure); |
|
| 1205 | + list($heures, $minutes, $secondes) = recup_heure($date_heure); |
|
| 1206 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1207 | 1207 | |
| 1208 | - return date('r', $time); |
|
| 1208 | + return date('r', $time); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | /** |
@@ -1221,11 +1221,11 @@ discard block |
||
| 1221 | 1221 | * Date au format `Ymd` |
| 1222 | 1222 | **/ |
| 1223 | 1223 | function date_anneemoisjour($d) { |
| 1224 | - if (!$d) { |
|
| 1225 | - $d = date("Y-m-d"); |
|
| 1226 | - } |
|
| 1224 | + if (!$d) { |
|
| 1225 | + $d = date("Y-m-d"); |
|
| 1226 | + } |
|
| 1227 | 1227 | |
| 1228 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1228 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | /** |
@@ -1241,11 +1241,11 @@ discard block |
||
| 1241 | 1241 | * Date au format `Ym` |
| 1242 | 1242 | **/ |
| 1243 | 1243 | function date_anneemois($d) { |
| 1244 | - if (!$d) { |
|
| 1245 | - $d = date("Y-m-d"); |
|
| 1246 | - } |
|
| 1244 | + if (!$d) { |
|
| 1245 | + $d = date("Y-m-d"); |
|
| 1246 | + } |
|
| 1247 | 1247 | |
| 1248 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1248 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | /** |
@@ -1261,13 +1261,13 @@ discard block |
||
| 1261 | 1261 | * Date au lundi de la même semaine au format `Ymd` |
| 1262 | 1262 | **/ |
| 1263 | 1263 | function date_debut_semaine($annee, $mois, $jour) { |
| 1264 | - $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1265 | - if ($w_day == 0) { |
|
| 1266 | - $w_day = 7; |
|
| 1267 | - } // Gaffe: le dimanche est zero |
|
| 1268 | - $debut = $jour - $w_day + 1; |
|
| 1264 | + $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1265 | + if ($w_day == 0) { |
|
| 1266 | + $w_day = 7; |
|
| 1267 | + } // Gaffe: le dimanche est zero |
|
| 1268 | + $debut = $jour - $w_day + 1; |
|
| 1269 | 1269 | |
| 1270 | - return date("Ymd", mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1270 | + return date("Ymd", mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | /** |
@@ -1283,12 +1283,12 @@ discard block |
||
| 1283 | 1283 | * Date au dimanche de la même semaine au format `Ymd` |
| 1284 | 1284 | **/ |
| 1285 | 1285 | function date_fin_semaine($annee, $mois, $jour) { |
| 1286 | - $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1287 | - if ($w_day == 0) { |
|
| 1288 | - $w_day = 7; |
|
| 1289 | - } // Gaffe: le dimanche est zero |
|
| 1290 | - $debut = $jour - $w_day + 1; |
|
| 1286 | + $w_day = date("w", mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1287 | + if ($w_day == 0) { |
|
| 1288 | + $w_day = 7; |
|
| 1289 | + } // Gaffe: le dimanche est zero |
|
| 1290 | + $debut = $jour - $w_day + 1; |
|
| 1291 | 1291 | |
| 1292 | - return date("Ymd", mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1292 | + return date("Ymd", mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function extraire_date($texte) { |
| 39 | 39 | // format = 2001-08 |
| 40 | 40 | if (preg_match(",([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),", $texte, $regs)) { |
| 41 | - return $regs[1] . "-" . sprintf("%02d", $regs[2]) . "-01"; |
|
| 41 | + return $regs[1]."-".sprintf("%02d", $regs[2])."-01"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | if (preg_match("#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
| 70 | 70 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 71 | - $date = $regs[1] . "-00-00" . $regs[3]; |
|
| 71 | + $date = $regs[1]."-00-00".$regs[3]; |
|
| 72 | 72 | } else { |
| 73 | 73 | if (preg_match("#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#", $date, $regs)) { |
| 74 | 74 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 75 | - $date = preg_replace("@/@", "-", $regs[1]) . "-00" . $regs[3]; |
|
| 75 | + $date = preg_replace("@/@", "-", $regs[1])."-00".$regs[3]; |
|
| 76 | 76 | } else { |
| 77 | 77 | $date = date("Y-m-d H:i:s", strtotime($date)); |
| 78 | 78 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | 99 | if (!$verif_format_date |
| 100 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 100 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 101 | 101 | preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/", $letexte))) { |
| 102 | 102 | |
| 103 | 103 | if (strncmp("0000-00-00", $letexte, 10) == 0) { |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * - si 'abbr' ne précise pas l'unité des minutes : 12h10 |
| 209 | 209 | * @return string L'heure formatée dans la langue en cours. |
| 210 | 210 | **/ |
| 211 | -function heures_minutes($numdate, $forme='') { |
|
| 212 | - if ($forme !='abbr') { |
|
| 211 | +function heures_minutes($numdate, $forme = '') { |
|
| 212 | + if ($forme != 'abbr') { |
|
| 213 | 213 | return _T('date_fmt_heures_minutes', array('h' => heures($numdate), 'm' => minutes($numdate))); |
| 214 | 214 | } |
| 215 | 215 | else { |
@@ -381,17 +381,17 @@ discard block |
||
| 381 | 381 | if ($decal > 3600 * 24 * 30) { |
| 382 | 382 | $mois = floor($decal / (3600 * 24 * 30)); |
| 383 | 383 | if ($mois < 2) { |
| 384 | - $delai = "$mois " . _T("date_un_mois"); |
|
| 384 | + $delai = "$mois "._T("date_un_mois"); |
|
| 385 | 385 | } else { |
| 386 | - $delai = "$mois " . _T("date_mois"); |
|
| 386 | + $delai = "$mois "._T("date_mois"); |
|
| 387 | 387 | } |
| 388 | 388 | } else { |
| 389 | 389 | if ($decal > 3600 * 24 * 7) { |
| 390 | 390 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 391 | 391 | if ($semaines < 2) { |
| 392 | - $delai = "$semaines " . _T("date_une_semaine"); |
|
| 392 | + $delai = "$semaines "._T("date_une_semaine"); |
|
| 393 | 393 | } else { |
| 394 | - $delai = "$semaines " . _T("date_semaines"); |
|
| 394 | + $delai = "$semaines "._T("date_semaines"); |
|
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | 397 | if ($decal > 3600 * 24) { |
@@ -399,30 +399,30 @@ discard block |
||
| 399 | 399 | if ($jours < 2) { |
| 400 | 400 | return $il_y_a == "date_dans" ? _T("date_demain") : _T("date_hier"); |
| 401 | 401 | } else { |
| 402 | - $delai = "$jours " . _T("date_jours"); |
|
| 402 | + $delai = "$jours "._T("date_jours"); |
|
| 403 | 403 | } |
| 404 | 404 | } else { |
| 405 | 405 | if ($decal >= 3600) { |
| 406 | 406 | $heures = floor($decal / 3600); |
| 407 | 407 | if ($heures < 2) { |
| 408 | - $delai = "$heures " . _T("date_une_heure"); |
|
| 408 | + $delai = "$heures "._T("date_une_heure"); |
|
| 409 | 409 | } else { |
| 410 | - $delai = "$heures " . _T("date_heures"); |
|
| 410 | + $delai = "$heures "._T("date_heures"); |
|
| 411 | 411 | } |
| 412 | 412 | } else { |
| 413 | 413 | if ($decal >= 60) { |
| 414 | 414 | $minutes = floor($decal / 60); |
| 415 | 415 | if ($minutes < 2) { |
| 416 | - $delai = "$minutes " . _T("date_une_minute"); |
|
| 416 | + $delai = "$minutes "._T("date_une_minute"); |
|
| 417 | 417 | } else { |
| 418 | - $delai = "$minutes " . _T("date_minutes"); |
|
| 418 | + $delai = "$minutes "._T("date_minutes"); |
|
| 419 | 419 | } |
| 420 | 420 | } else { |
| 421 | 421 | $secondes = ceil($decal); |
| 422 | 422 | if ($secondes < 2) { |
| 423 | - $delai = "$secondes " . _T("date_une_seconde"); |
|
| 423 | + $delai = "$secondes "._T("date_une_seconde"); |
|
| 424 | 424 | } else { |
| 425 | - $delai = "$secondes " . _T("date_secondes"); |
|
| 425 | + $delai = "$secondes "._T("date_secondes"); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -517,16 +517,16 @@ discard block |
||
| 517 | 517 | $njour = 0; |
| 518 | 518 | } else { |
| 519 | 519 | $njour = intval($jour); |
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 520 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 521 | 521 | $jour = $jourth; |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | $mois = intval($mois); |
| 526 | 526 | if ($mois > 0 and $mois < 13) { |
| 527 | - $nommois = _T('date_mois_' . $mois); |
|
| 527 | + $nommois = _T('date_mois_'.$mois); |
|
| 528 | 528 | if ($jour) { |
| 529 | - $jourmois = _T('date_de_mois_' . $mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 529 | + $jourmois = _T('date_de_mois_'.$mois, array('j' => $jour, 'nommois' => $nommois)); |
|
| 530 | 530 | } else { |
| 531 | 531 | $jourmois = $nommois; |
| 532 | 532 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | if ($annee < 0) { |
| 539 | - $annee = -$annee . " " . _T('date_avant_jc'); |
|
| 539 | + $annee = -$annee." "._T('date_avant_jc'); |
|
| 540 | 540 | $avjc = true; |
| 541 | 541 | } else { |
| 542 | 542 | $avjc = false; |
@@ -562,10 +562,10 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | if ($vue == 'saison') { |
| 565 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 565 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 566 | 566 | } else { |
| 567 | 567 | return $saison ? trim(_T('date_fmt_saison_annee', |
| 568 | - array('saison' => _T('date_saison_' . $saison), 'annee' => $annee))) : ''; |
|
| 568 | + array('saison' => _T('date_saison_'.$saison), 'annee' => $annee))) : ''; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | case 'court': |
@@ -614,9 +614,9 @@ discard block |
||
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | case 'nom_mois': |
| 617 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 617 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 618 | 618 | if ($param and $mois) { |
| 619 | - return _T('date_mois_' . $mois . $param); |
|
| 619 | + return _T('date_mois_'.$mois.$param); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | return $nommois; |
@@ -636,9 +636,9 @@ discard block |
||
| 636 | 636 | } |
| 637 | 637 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 638 | 638 | $nom = 1 + date('w', $nom); |
| 639 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 639 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 640 | 640 | |
| 641 | - return _T('date_jour_' . $nom . $param); |
|
| 641 | + return _T('date_jour_'.$nom.$param); |
|
| 642 | 642 | |
| 643 | 643 | case 'mois_annee': |
| 644 | 644 | if ($avjc) { |
@@ -1033,8 +1033,8 @@ discard block |
||
| 1033 | 1033 | |
| 1034 | 1034 | $dtstart = $dtend = $dtabbr = ""; |
| 1035 | 1035 | if (strpos($forme, 'hcal') !== false) { |
| 1036 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1037 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1036 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1037 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1038 | 1038 | $dtabbr = "</abbr>"; |
| 1039 | 1039 | } |
| 1040 | 1040 | |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | } |
| 1079 | 1079 | } else { |
| 1080 | 1080 | if ($dtabbr && $dtstart) { |
| 1081 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1081 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1082 | 1082 | } else { |
| 1083 | 1083 | $s = spip_ucfirst($s); |
| 1084 | 1084 | } |
@@ -1101,8 +1101,8 @@ discard block |
||
| 1101 | 1101 | $date_debut = _T('date_fmt_jour_heure', array('jour' => $date_debut, 'heure' => $hd)); |
| 1102 | 1102 | $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
| 1103 | 1103 | } |
| 1104 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1105 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1104 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1105 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1106 | 1106 | |
| 1107 | 1107 | $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
| 1108 | 1108 | } else { |
@@ -1119,8 +1119,8 @@ discard block |
||
| 1119 | 1119 | $date_fin = _T('date_fmt_jour_heure', array('jour' => $date_fin, 'heure' => $hf)); |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1123 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1122 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1123 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1124 | 1124 | $s = _T('date_fmt_periode', array('date_debut' => $date_debut, 'date_fin' => $date_fin)); |
| 1125 | 1125 | |
| 1126 | 1126 | } |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | $d = date("Y-m-d"); |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1228 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | /** |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | $d = date("Y-m-d"); |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1248 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | /** |