@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 192 | + return $rejouer.(defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | // |
| 236 | 236 | if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
| 237 | 237 | if ($vcs['vcs'] === 'GIT') { |
| 238 | - $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 238 | + $url = 'https://git.spip.net/spip/spip/commit/'.$vcs['commit']; |
|
| 239 | 239 | } elseif ($vcs['vcs'] === 'SVN') { |
| 240 | - $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 240 | + $url = 'https://core.spip.net/projects/spip/repository/revisions/'.$vcs['commit']; |
|
| 241 | 241 | } else { |
| 242 | 242 | $url = ''; |
| 243 | 243 | } |
@@ -247,21 +247,21 @@ discard block |
||
| 247 | 247 | $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
| 248 | 248 | } |
| 249 | 249 | if ($vcs['branch']) { |
| 250 | - $commit = $vcs['branch'] . ': ' . $commit; |
|
| 250 | + $commit = $vcs['branch'].': '.$commit; |
|
| 251 | 251 | } |
| 252 | 252 | $version .= " {$vcs['vcs']} [$commit]"; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // et la version de l'ecran de securite |
| 256 | 256 | $secu = defined('_ECRAN_SECURITE') |
| 257 | - ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 257 | + ? '<br />'._T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 258 | 258 | : ''; |
| 259 | 259 | |
| 260 | 260 | return _T( |
| 261 | 261 | 'info_copyright', |
| 262 | 262 | [ |
| 263 | 263 | 'spip' => "<b>SPIP $version</b> ", |
| 264 | - 'lien_gpl' => '<a href="https://www.gnu.org/licenses/gpl-3.0.html">' . _T('info_copyright_gpl') . '</a>' |
|
| 264 | + 'lien_gpl' => '<a href="https://www.gnu.org/licenses/gpl-3.0.html">'._T('info_copyright_gpl').'</a>' |
|
| 265 | 265 | ] |
| 266 | 266 | ) |
| 267 | 267 | . $secu; |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | $onfocus = ''; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 292 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 291 | + $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"'.$onfocus.' />'; |
|
| 292 | + $form .= "<input type='image' src='".chemin_image('rechercher-20.png')."' name='submit' class='submit' alt='"._T('info_rechercher')."' />"; |
|
| 293 | 293 | |
| 294 | - return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 294 | + return "<div class='spip_recherche'>".generer_form_ecrire($page, $form.$complement, " method='get'").'</div>'; |
|
| 295 | 295 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Affichage |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @return string Code HTML |
| 25 | 25 | */ |
| 26 | 26 | function debut_grand_cadre() { |
| 27 | - return "\n<div class = 'table_page'>\n"; |
|
| 27 | + return "\n<div class = 'table_page'>\n"; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @return string Code HTML |
| 34 | 34 | */ |
| 35 | 35 | function fin_grand_cadre() { |
| 36 | - return "\n</div>"; |
|
| 36 | + return "\n</div>"; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Debut de la colonne de gauche |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @return string Code HTML |
| 49 | 49 | */ |
| 50 | 50 | function debut_gauche() { |
| 51 | - return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 51 | + return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @return string Code HTML |
| 58 | 58 | */ |
| 59 | 59 | function fin_gauche() { |
| 60 | - return "</div></div><br class = 'nettoyeur' />"; |
|
| 60 | + return "</div></div><br class = 'nettoyeur' />"; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | * @return string Code HTML |
| 67 | 67 | */ |
| 68 | 68 | function creer_colonne_droite() { |
| 69 | - static $deja_colonne_droite; |
|
| 70 | - if ($deja_colonne_droite) { |
|
| 71 | - return ''; |
|
| 72 | - } |
|
| 73 | - $deja_colonne_droite = true; |
|
| 69 | + static $deja_colonne_droite; |
|
| 70 | + if ($deja_colonne_droite) { |
|
| 71 | + return ''; |
|
| 72 | + } |
|
| 73 | + $deja_colonne_droite = true; |
|
| 74 | 74 | |
| 75 | - return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 75 | + return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | * @return string Code HTML |
| 82 | 82 | */ |
| 83 | 83 | function debut_droite() { |
| 84 | - return liste_objets_bloques(_request('exec')) |
|
| 85 | - . creer_colonne_droite() |
|
| 86 | - . '</div>' |
|
| 87 | - . "\n<div id='contenu'>"; |
|
| 84 | + return liste_objets_bloques(_request('exec')) |
|
| 85 | + . creer_colonne_droite() |
|
| 86 | + . '</div>' |
|
| 87 | + . "\n<div id='contenu'>"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -106,32 +106,32 @@ discard block |
||
| 106 | 106 | * Code HTML |
| 107 | 107 | **/ |
| 108 | 108 | function liste_objets_bloques($exec, $contexte = [], $auteur = null): string { |
| 109 | - $res = ''; |
|
| 110 | - include_spip('inc/config'); |
|
| 111 | - if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 112 | - include_spip('inc/drapeau_edition'); |
|
| 113 | - if (is_null($auteur)) { |
|
| 114 | - $auteur = $GLOBALS['visiteur_session']; |
|
| 115 | - } |
|
| 116 | - if ( |
|
| 117 | - ($en_cours = trouver_objet_exec($exec)) |
|
| 118 | - && $en_cours['edition'] |
|
| 119 | - && ($type = $en_cours['type']) |
|
| 120 | - && (isset($contexte[$en_cours['id_table_objet']]) |
|
| 121 | - && ($id = $contexte[$en_cours['id_table_objet']]) || ($id = _request($en_cours['id_table_objet']))) |
|
| 122 | - ) { |
|
| 123 | - // marquer le fait que l'objet est ouvert en edition par toto |
|
| 124 | - // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 125 | - signale_edition($id, $auteur, $type); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 129 | - if ($objets_ouverts !== []) { |
|
| 130 | - $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]); |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - return $res; |
|
| 109 | + $res = ''; |
|
| 110 | + include_spip('inc/config'); |
|
| 111 | + if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 112 | + include_spip('inc/drapeau_edition'); |
|
| 113 | + if (is_null($auteur)) { |
|
| 114 | + $auteur = $GLOBALS['visiteur_session']; |
|
| 115 | + } |
|
| 116 | + if ( |
|
| 117 | + ($en_cours = trouver_objet_exec($exec)) |
|
| 118 | + && $en_cours['edition'] |
|
| 119 | + && ($type = $en_cours['type']) |
|
| 120 | + && (isset($contexte[$en_cours['id_table_objet']]) |
|
| 121 | + && ($id = $contexte[$en_cours['id_table_objet']]) || ($id = _request($en_cours['id_table_objet']))) |
|
| 122 | + ) { |
|
| 123 | + // marquer le fait que l'objet est ouvert en edition par toto |
|
| 124 | + // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 125 | + signale_edition($id, $auteur, $type); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 129 | + if ($objets_ouverts !== []) { |
|
| 130 | + $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + return $res; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
@@ -145,23 +145,23 @@ discard block |
||
| 145 | 145 | * @return string Code HTML |
| 146 | 146 | **/ |
| 147 | 147 | function fin_page() { |
| 148 | - include_spip('inc/pipelines'); |
|
| 149 | - // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 150 | - $debug = (_request('exec') !== 'valider_xml' |
|
| 151 | - && ( |
|
| 152 | - _request('var_mode') == 'debug' |
|
| 153 | - || isset($GLOBALS['tableau_des_temps']) && $GLOBALS['tableau_des_temps'] |
|
| 154 | - && isset($_COOKIE['spip_admin']) |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - $t = '</div><div id="pied"><div class="largeur">' |
|
| 158 | - . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 159 | - . '</div>' |
|
| 160 | - . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 161 | - . ($debug ? erreur_squelette() : '') |
|
| 162 | - . "</body></html>\n"; |
|
| 163 | - |
|
| 164 | - return f_queue($t); |
|
| 148 | + include_spip('inc/pipelines'); |
|
| 149 | + // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 150 | + $debug = (_request('exec') !== 'valider_xml' |
|
| 151 | + && ( |
|
| 152 | + _request('var_mode') == 'debug' |
|
| 153 | + || isset($GLOBALS['tableau_des_temps']) && $GLOBALS['tableau_des_temps'] |
|
| 154 | + && isset($_COOKIE['spip_admin']) |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + $t = '</div><div id="pied"><div class="largeur">' |
|
| 158 | + . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 159 | + . '</div>' |
|
| 160 | + . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 161 | + . ($debug ? erreur_squelette() : '') |
|
| 162 | + . "</body></html>\n"; |
|
| 163 | + |
|
| 164 | + return f_queue($t); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | * @return string Code HTML |
| 177 | 177 | **/ |
| 178 | 178 | function html_tests_js() { |
| 179 | - if (_SPIP_AJAX && !defined('_TESTER_NOSCRIPT')) { |
|
| 180 | - // pour le pied de page (deja defini si on est validation XML) |
|
| 181 | - define( |
|
| 182 | - '_TESTER_NOSCRIPT', |
|
| 183 | - "<noscript>\n<div style='display:none;'><img src='" |
|
| 184 | - . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 185 | - . "' width='1' height='1' alt='' /></div></noscript>\n" |
|
| 186 | - ); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $rejouer = ''; |
|
| 190 | - if (defined('_SESSION_REJOUER')) { |
|
| 191 | - $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 179 | + if (_SPIP_AJAX && !defined('_TESTER_NOSCRIPT')) { |
|
| 180 | + // pour le pied de page (deja defini si on est validation XML) |
|
| 181 | + define( |
|
| 182 | + '_TESTER_NOSCRIPT', |
|
| 183 | + "<noscript>\n<div style='display:none;'><img src='" |
|
| 184 | + . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 185 | + . "' width='1' height='1' alt='' /></div></noscript>\n" |
|
| 186 | + ); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $rejouer = ''; |
|
| 190 | + if (defined('_SESSION_REJOUER')) { |
|
| 191 | + $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -201,25 +201,25 @@ discard block |
||
| 201 | 201 | **/ |
| 202 | 202 | function info_maj_spip() { |
| 203 | 203 | |
| 204 | - $maj = $GLOBALS['meta']['info_maj_spip'] ?? null; |
|
| 205 | - if (!$maj) { |
|
| 206 | - return ''; |
|
| 207 | - } |
|
| 204 | + $maj = $GLOBALS['meta']['info_maj_spip'] ?? null; |
|
| 205 | + if (!$maj) { |
|
| 206 | + return ''; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - $maj = explode('|', (string) $maj); |
|
| 210 | - // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 211 | - if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 212 | - return ''; |
|
| 213 | - } |
|
| 209 | + $maj = explode('|', (string) $maj); |
|
| 210 | + // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 211 | + if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 212 | + return ''; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if (!autoriser('webmestre')) { |
|
| 216 | - return ''; |
|
| 217 | - } |
|
| 215 | + if (!autoriser('webmestre')) { |
|
| 216 | + return ''; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - array_shift($maj); |
|
| 220 | - $maj = implode('|', $maj); |
|
| 219 | + array_shift($maj); |
|
| 220 | + $maj = implode('|', $maj); |
|
| 221 | 221 | |
| 222 | - return "$maj<br />"; |
|
| 222 | + return "$maj<br />"; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -230,43 +230,43 @@ discard block |
||
| 230 | 230 | **/ |
| 231 | 231 | function info_copyright() { |
| 232 | 232 | |
| 233 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 234 | - |
|
| 235 | - // |
|
| 236 | - // Mention, le cas echeant, de la revision SVN courante |
|
| 237 | - // |
|
| 238 | - if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 239 | - if ($vcs['vcs'] === 'GIT') { |
|
| 240 | - $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 241 | - } elseif ($vcs['vcs'] === 'SVN') { |
|
| 242 | - $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 243 | - } else { |
|
| 244 | - $url = ''; |
|
| 245 | - } |
|
| 246 | - // affichage "GIT [master: abcdef]" |
|
| 247 | - $commit = $vcs['commit_short'] ?? $vcs['commit']; |
|
| 248 | - if ($url) { |
|
| 249 | - $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 250 | - } |
|
| 251 | - if ($vcs['branch']) { |
|
| 252 | - $commit = $vcs['branch'] . ': ' . $commit; |
|
| 253 | - } |
|
| 254 | - $version .= " {$vcs['vcs']} [$commit]"; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // et la version de l'ecran de securite |
|
| 258 | - $secu = defined('_ECRAN_SECURITE') |
|
| 259 | - ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 260 | - : ''; |
|
| 261 | - |
|
| 262 | - return _T( |
|
| 263 | - 'info_copyright', |
|
| 264 | - [ |
|
| 265 | - 'spip' => "<b>SPIP $version</b> ", |
|
| 266 | - 'lien_gpl' => '<a href="https://www.gnu.org/licenses/gpl-3.0.html">' . _T('info_copyright_gpl') . '</a>' |
|
| 267 | - ] |
|
| 268 | - ) |
|
| 269 | - . $secu; |
|
| 233 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 234 | + |
|
| 235 | + // |
|
| 236 | + // Mention, le cas echeant, de la revision SVN courante |
|
| 237 | + // |
|
| 238 | + if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 239 | + if ($vcs['vcs'] === 'GIT') { |
|
| 240 | + $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 241 | + } elseif ($vcs['vcs'] === 'SVN') { |
|
| 242 | + $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 243 | + } else { |
|
| 244 | + $url = ''; |
|
| 245 | + } |
|
| 246 | + // affichage "GIT [master: abcdef]" |
|
| 247 | + $commit = $vcs['commit_short'] ?? $vcs['commit']; |
|
| 248 | + if ($url) { |
|
| 249 | + $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 250 | + } |
|
| 251 | + if ($vcs['branch']) { |
|
| 252 | + $commit = $vcs['branch'] . ': ' . $commit; |
|
| 253 | + } |
|
| 254 | + $version .= " {$vcs['vcs']} [$commit]"; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // et la version de l'ecran de securite |
|
| 258 | + $secu = defined('_ECRAN_SECURITE') |
|
| 259 | + ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 260 | + : ''; |
|
| 261 | + |
|
| 262 | + return _T( |
|
| 263 | + 'info_copyright', |
|
| 264 | + [ |
|
| 265 | + 'spip' => "<b>SPIP $version</b> ", |
|
| 266 | + 'lien_gpl' => '<a href="https://www.gnu.org/licenses/gpl-3.0.html">' . _T('info_copyright_gpl') . '</a>' |
|
| 267 | + ] |
|
| 268 | + ) |
|
| 269 | + . $secu; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | * @return string Code HTML |
| 282 | 282 | **/ |
| 283 | 283 | function formulaire_recherche($page, $complement = '') { |
| 284 | - $recherche = _request('recherche'); |
|
| 285 | - $recherche_aff = entites_html($recherche); |
|
| 286 | - if (!strlen((string) $recherche)) { |
|
| 287 | - $recherche_aff = _T('info_rechercher'); |
|
| 288 | - $onfocus = " onfocus=\"this.value='';\""; |
|
| 289 | - } else { |
|
| 290 | - $onfocus = ''; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 294 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 295 | - |
|
| 296 | - return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 284 | + $recherche = _request('recherche'); |
|
| 285 | + $recherche_aff = entites_html($recherche); |
|
| 286 | + if (!strlen((string) $recherche)) { |
|
| 287 | + $recherche_aff = _T('info_rechercher'); |
|
| 288 | + $onfocus = " onfocus=\"this.value='';\""; |
|
| 289 | + } else { |
|
| 290 | + $onfocus = ''; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 294 | + $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 295 | + |
|
| 296 | + return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 297 | 297 | } |
@@ -185,8 +185,7 @@ |
||
| 185 | 185 | $trads = $m['trads']; |
| 186 | 186 | if (empty($trads)) { |
| 187 | 187 | $trad = ''; |
| 188 | - } |
|
| 189 | - elseif ($l = approcher_langue($trads, $lang)) { |
|
| 188 | + } elseif ($l = approcher_langue($trads, $lang)) { |
|
| 190 | 189 | $trad = $trads[$l]; |
| 191 | 190 | } else { |
| 192 | 191 | if ($lang_defaut == 'aucune') { |
@@ -27,203 +27,203 @@ |
||
| 27 | 27 | * Ne pas mettre de span@lang=fr si on est déjà en fr. |
| 28 | 28 | */ |
| 29 | 29 | class Multis extends AbstractCollecteur { |
| 30 | - protected static string $markPrefix = 'MULTI'; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * La preg pour découper et collecter les modèles |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - protected string $preg_multi; |
|
| 37 | - |
|
| 38 | - public function __construct(?string $preg = null) { |
|
| 39 | - |
|
| 40 | - $this->preg_multi = ($preg ?: '@<multi>(.*?)</multi>@sS'); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Sanitizer une collection d'occurences de multi : on sanitize chaque texte de langue séparemment |
|
| 45 | - * |
|
| 46 | - * @param array $collection |
|
| 47 | - * @param string $sanitize_callback |
|
| 48 | - * @return array |
|
| 49 | - */ |
|
| 50 | - protected function sanitizer_collection(array $collection, string $sanitize_callback): array { |
|
| 51 | - |
|
| 52 | - foreach ($collection as &$multi) { |
|
| 53 | - $changed = false; |
|
| 54 | - foreach ($multi['trads'] as $lang => $trad) { |
|
| 55 | - $t = $sanitize_callback($trad); |
|
| 56 | - if ($t !== $trad) { |
|
| 57 | - $changed = true; |
|
| 58 | - $multi['trads'][$lang] = $t; |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - if ($changed) { |
|
| 62 | - $texte = $this->agglomerer_trads($multi['trads']); |
|
| 63 | - $multi['raw'] = str_replace($multi['texte'], $texte, (string) $multi['raw']); |
|
| 64 | - $multi['texte'] = $texte; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $collection; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Convertit le contenu d'une balise `<multi>` en un tableau |
|
| 73 | - * |
|
| 74 | - * Exemple de blocs. |
|
| 75 | - * - `texte par défaut [fr] en français [en] en anglais` |
|
| 76 | - * - `[fr] en français [en] en anglais` |
|
| 77 | - * |
|
| 78 | - * @param string $bloc |
|
| 79 | - * Le contenu intérieur d'un bloc multi |
|
| 80 | - * @return array [code de langue => texte] |
|
| 81 | - * Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué. |
|
| 82 | - **/ |
|
| 83 | - protected function extraire_trads($bloc) { |
|
| 84 | - $trads = []; |
|
| 85 | - |
|
| 86 | - if (strlen($bloc)) { |
|
| 87 | - $langs = static::collecteur($bloc, ']', '[', '@[\[]([a-z]{2,3}(_[a-z]{2,3})?(_[a-z]{2,3})?)[\]]@siS'); |
|
| 88 | - $lang = ''; |
|
| 89 | - $pos_prev = 0; |
|
| 90 | - foreach ($langs as $l) { |
|
| 91 | - $pos = $l['pos']; |
|
| 92 | - if ($lang || $pos > $pos_prev) { |
|
| 93 | - $trads[$lang] = substr($bloc, $pos_prev, $pos - $pos_prev); |
|
| 94 | - } |
|
| 95 | - $lang = $l['match'][1]; |
|
| 96 | - $pos_prev = $pos + $l['length']; |
|
| 97 | - } |
|
| 98 | - $trads[$lang] = substr($bloc, $pos_prev); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $trads; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Recoller ensemble les trads pour reconstituer le texte dans la balise <multi>...</multi> |
|
| 106 | - * @param array<string,string> $trads |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - protected function agglomerer_trads($trads) { |
|
| 110 | - $texte = ''; |
|
| 111 | - foreach ($trads as $lang => $trad) { |
|
| 112 | - if ($texte || $lang) { |
|
| 113 | - $texte .= "[$lang]"; |
|
| 114 | - } |
|
| 115 | - $texte .= $trad; |
|
| 116 | - } |
|
| 117 | - return $texte; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @param string $texte |
|
| 122 | - * @param array $options |
|
| 123 | - * bool $collecter_liens |
|
| 124 | - * @return array |
|
| 125 | - */ |
|
| 126 | - public function collecter(string $texte, array $options = []): array { |
|
| 127 | - if (!$texte) { |
|
| 128 | - return []; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - // collecter les matchs de la preg |
|
| 132 | - $multis = static::collecteur($texte, '', '<multi', $this->preg_multi, empty($options['detecter_presence']) ? 0 : 1); |
|
| 133 | - // si on veut seulement detecter la présence, on peut retourner tel quel |
|
| 134 | - if (empty($options['detecter_presence'])) { |
|
| 135 | - foreach ($multis as $k => &$multi) { |
|
| 136 | - $multi['texte'] = $multi['match'][1]; |
|
| 137 | - // extraire les trads du texte |
|
| 138 | - $multi['trads'] = $this->extraire_trads($multi['texte']); |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - return $multis; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Traiter les multis d'un texte |
|
| 147 | - * |
|
| 148 | - * @uses approcher_langue() |
|
| 149 | - * @uses lang_typo() |
|
| 150 | - * @uses code_echappement() |
|
| 151 | - * @uses echappe_retour() |
|
| 152 | - * |
|
| 153 | - * @param string $texte |
|
| 154 | - * @param array $options |
|
| 155 | - * ?string $lang |
|
| 156 | - * ?string $lang_defaut |
|
| 157 | - * ?bool echappe_span |
|
| 158 | - * ?bool appliquer_typo |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function traiter(string $texte, array $options) { |
|
| 162 | - if ($texte) { |
|
| 163 | - $multis = $this->collecter($texte); |
|
| 164 | - if ($multis !== []) { |
|
| 165 | - $lang = $options['lang'] ?? $GLOBALS['spip_lang']; |
|
| 166 | - $lang_defaut = $options['lang_defaut'] ?? _LANGUE_PAR_DEFAUT; |
|
| 167 | - $echappe_span = $options['echappe_span'] ?? false; |
|
| 168 | - $appliquer_typo = $options['appliquer_typo'] ?? true; |
|
| 169 | - |
|
| 170 | - if (!function_exists('approcher_langue')) { |
|
| 171 | - include_spip('inc/lang'); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $offset_pos = 0; |
|
| 175 | - foreach ($multis as $m) { |
|
| 176 | - // chercher la version de la langue courante |
|
| 177 | - $trads = $m['trads']; |
|
| 178 | - if (empty($trads)) { |
|
| 179 | - $trad = ''; |
|
| 180 | - } |
|
| 181 | - elseif ($l = approcher_langue($trads, $lang)) { |
|
| 182 | - $trad = $trads[$l]; |
|
| 183 | - } else { |
|
| 184 | - if ($lang_defaut == 'aucune') { |
|
| 185 | - $trad = ''; |
|
| 186 | - } else { |
|
| 187 | - // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 188 | - // ou la premiere dispo |
|
| 189 | - if (!$l = approcher_langue($trads, $lang_defaut)) { |
|
| 190 | - $l = array_keys($trads); |
|
| 191 | - $l = reset($l); |
|
| 192 | - } |
|
| 193 | - $trad = $trads[$l]; |
|
| 194 | - |
|
| 195 | - // mais typographier le texte selon les regles de celle-ci |
|
| 196 | - // Attention aux blocs multi sur plusieurs lignes |
|
| 197 | - if ($appliquer_typo) { |
|
| 198 | - $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 199 | - $trad = $typographie($trad); |
|
| 200 | - |
|
| 201 | - // Tester si on echappe en span ou en div |
|
| 202 | - // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 203 | - include_spip('inc/texte'); |
|
| 204 | - $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', (string) propre($trad)); |
|
| 205 | - $isBloc = self::echappementTexteContientBaliseBloc($trad_propre); |
|
| 206 | - if ($isBloc) { |
|
| 207 | - $trad = rtrim((string) $trad) . "\n\n"; |
|
| 208 | - } |
|
| 209 | - $attributs = ['lang' => $l]; |
|
| 210 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 211 | - $attributs['dir'] = lang_dir($l); |
|
| 212 | - } |
|
| 213 | - $trad = self::echappementHtmlBase64($trad, 'multi', $isBloc, $attributs); |
|
| 214 | - if (!$echappe_span) { |
|
| 215 | - $trad = self::retablir_depuisHtmlBase64($trad, 'multi'); |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - $texte = substr_replace($texte, (string) $trad, $m['pos'] + $offset_pos, $m['length']); |
|
| 222 | - $offset_pos += strlen((string) $trad) - $m['length']; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $texte; |
|
| 228 | - } |
|
| 30 | + protected static string $markPrefix = 'MULTI'; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * La preg pour découper et collecter les modèles |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + protected string $preg_multi; |
|
| 37 | + |
|
| 38 | + public function __construct(?string $preg = null) { |
|
| 39 | + |
|
| 40 | + $this->preg_multi = ($preg ?: '@<multi>(.*?)</multi>@sS'); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Sanitizer une collection d'occurences de multi : on sanitize chaque texte de langue séparemment |
|
| 45 | + * |
|
| 46 | + * @param array $collection |
|
| 47 | + * @param string $sanitize_callback |
|
| 48 | + * @return array |
|
| 49 | + */ |
|
| 50 | + protected function sanitizer_collection(array $collection, string $sanitize_callback): array { |
|
| 51 | + |
|
| 52 | + foreach ($collection as &$multi) { |
|
| 53 | + $changed = false; |
|
| 54 | + foreach ($multi['trads'] as $lang => $trad) { |
|
| 55 | + $t = $sanitize_callback($trad); |
|
| 56 | + if ($t !== $trad) { |
|
| 57 | + $changed = true; |
|
| 58 | + $multi['trads'][$lang] = $t; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + if ($changed) { |
|
| 62 | + $texte = $this->agglomerer_trads($multi['trads']); |
|
| 63 | + $multi['raw'] = str_replace($multi['texte'], $texte, (string) $multi['raw']); |
|
| 64 | + $multi['texte'] = $texte; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $collection; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Convertit le contenu d'une balise `<multi>` en un tableau |
|
| 73 | + * |
|
| 74 | + * Exemple de blocs. |
|
| 75 | + * - `texte par défaut [fr] en français [en] en anglais` |
|
| 76 | + * - `[fr] en français [en] en anglais` |
|
| 77 | + * |
|
| 78 | + * @param string $bloc |
|
| 79 | + * Le contenu intérieur d'un bloc multi |
|
| 80 | + * @return array [code de langue => texte] |
|
| 81 | + * Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué. |
|
| 82 | + **/ |
|
| 83 | + protected function extraire_trads($bloc) { |
|
| 84 | + $trads = []; |
|
| 85 | + |
|
| 86 | + if (strlen($bloc)) { |
|
| 87 | + $langs = static::collecteur($bloc, ']', '[', '@[\[]([a-z]{2,3}(_[a-z]{2,3})?(_[a-z]{2,3})?)[\]]@siS'); |
|
| 88 | + $lang = ''; |
|
| 89 | + $pos_prev = 0; |
|
| 90 | + foreach ($langs as $l) { |
|
| 91 | + $pos = $l['pos']; |
|
| 92 | + if ($lang || $pos > $pos_prev) { |
|
| 93 | + $trads[$lang] = substr($bloc, $pos_prev, $pos - $pos_prev); |
|
| 94 | + } |
|
| 95 | + $lang = $l['match'][1]; |
|
| 96 | + $pos_prev = $pos + $l['length']; |
|
| 97 | + } |
|
| 98 | + $trads[$lang] = substr($bloc, $pos_prev); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $trads; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Recoller ensemble les trads pour reconstituer le texte dans la balise <multi>...</multi> |
|
| 106 | + * @param array<string,string> $trads |
|
| 107 | + * @return string |
|
| 108 | + */ |
|
| 109 | + protected function agglomerer_trads($trads) { |
|
| 110 | + $texte = ''; |
|
| 111 | + foreach ($trads as $lang => $trad) { |
|
| 112 | + if ($texte || $lang) { |
|
| 113 | + $texte .= "[$lang]"; |
|
| 114 | + } |
|
| 115 | + $texte .= $trad; |
|
| 116 | + } |
|
| 117 | + return $texte; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @param string $texte |
|
| 122 | + * @param array $options |
|
| 123 | + * bool $collecter_liens |
|
| 124 | + * @return array |
|
| 125 | + */ |
|
| 126 | + public function collecter(string $texte, array $options = []): array { |
|
| 127 | + if (!$texte) { |
|
| 128 | + return []; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + // collecter les matchs de la preg |
|
| 132 | + $multis = static::collecteur($texte, '', '<multi', $this->preg_multi, empty($options['detecter_presence']) ? 0 : 1); |
|
| 133 | + // si on veut seulement detecter la présence, on peut retourner tel quel |
|
| 134 | + if (empty($options['detecter_presence'])) { |
|
| 135 | + foreach ($multis as $k => &$multi) { |
|
| 136 | + $multi['texte'] = $multi['match'][1]; |
|
| 137 | + // extraire les trads du texte |
|
| 138 | + $multi['trads'] = $this->extraire_trads($multi['texte']); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + return $multis; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Traiter les multis d'un texte |
|
| 147 | + * |
|
| 148 | + * @uses approcher_langue() |
|
| 149 | + * @uses lang_typo() |
|
| 150 | + * @uses code_echappement() |
|
| 151 | + * @uses echappe_retour() |
|
| 152 | + * |
|
| 153 | + * @param string $texte |
|
| 154 | + * @param array $options |
|
| 155 | + * ?string $lang |
|
| 156 | + * ?string $lang_defaut |
|
| 157 | + * ?bool echappe_span |
|
| 158 | + * ?bool appliquer_typo |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function traiter(string $texte, array $options) { |
|
| 162 | + if ($texte) { |
|
| 163 | + $multis = $this->collecter($texte); |
|
| 164 | + if ($multis !== []) { |
|
| 165 | + $lang = $options['lang'] ?? $GLOBALS['spip_lang']; |
|
| 166 | + $lang_defaut = $options['lang_defaut'] ?? _LANGUE_PAR_DEFAUT; |
|
| 167 | + $echappe_span = $options['echappe_span'] ?? false; |
|
| 168 | + $appliquer_typo = $options['appliquer_typo'] ?? true; |
|
| 169 | + |
|
| 170 | + if (!function_exists('approcher_langue')) { |
|
| 171 | + include_spip('inc/lang'); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $offset_pos = 0; |
|
| 175 | + foreach ($multis as $m) { |
|
| 176 | + // chercher la version de la langue courante |
|
| 177 | + $trads = $m['trads']; |
|
| 178 | + if (empty($trads)) { |
|
| 179 | + $trad = ''; |
|
| 180 | + } |
|
| 181 | + elseif ($l = approcher_langue($trads, $lang)) { |
|
| 182 | + $trad = $trads[$l]; |
|
| 183 | + } else { |
|
| 184 | + if ($lang_defaut == 'aucune') { |
|
| 185 | + $trad = ''; |
|
| 186 | + } else { |
|
| 187 | + // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 188 | + // ou la premiere dispo |
|
| 189 | + if (!$l = approcher_langue($trads, $lang_defaut)) { |
|
| 190 | + $l = array_keys($trads); |
|
| 191 | + $l = reset($l); |
|
| 192 | + } |
|
| 193 | + $trad = $trads[$l]; |
|
| 194 | + |
|
| 195 | + // mais typographier le texte selon les regles de celle-ci |
|
| 196 | + // Attention aux blocs multi sur plusieurs lignes |
|
| 197 | + if ($appliquer_typo) { |
|
| 198 | + $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 199 | + $trad = $typographie($trad); |
|
| 200 | + |
|
| 201 | + // Tester si on echappe en span ou en div |
|
| 202 | + // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 203 | + include_spip('inc/texte'); |
|
| 204 | + $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', (string) propre($trad)); |
|
| 205 | + $isBloc = self::echappementTexteContientBaliseBloc($trad_propre); |
|
| 206 | + if ($isBloc) { |
|
| 207 | + $trad = rtrim((string) $trad) . "\n\n"; |
|
| 208 | + } |
|
| 209 | + $attributs = ['lang' => $l]; |
|
| 210 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 211 | + $attributs['dir'] = lang_dir($l); |
|
| 212 | + } |
|
| 213 | + $trad = self::echappementHtmlBase64($trad, 'multi', $isBloc, $attributs); |
|
| 214 | + if (!$echappe_span) { |
|
| 215 | + $trad = self::retablir_depuisHtmlBase64($trad, 'multi'); |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + $texte = substr_replace($texte, (string) $trad, $m['pos'] + $offset_pos, $m['length']); |
|
| 222 | + $offset_pos += strlen((string) $trad) - $m['length']; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $texte; |
|
| 228 | + } |
|
| 229 | 229 | } |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', (string) propre($trad)); |
| 205 | 205 | $isBloc = self::echappementTexteContientBaliseBloc($trad_propre); |
| 206 | 206 | if ($isBloc) { |
| 207 | - $trad = rtrim((string) $trad) . "\n\n"; |
|
| 207 | + $trad = rtrim((string) $trad)."\n\n"; |
|
| 208 | 208 | } |
| 209 | 209 | $attributs = ['lang' => $l]; |
| 210 | 210 | if (lang_dir($l) !== lang_dir($lang)) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -20,18 +20,18 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | function req_sqlite3_dist($addr, $port, $login, #[\SensitiveParameter] $pass, $db = '', $prefixe = '') { |
| 23 | - return req_sqlite_dist($addr, $port, $login, $pass, $db, $prefixe, $sqlite_version = 3); |
|
| 23 | + return req_sqlite_dist($addr, $port, $login, $pass, $db, $prefixe, $sqlite_version = 3); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | function spip_sqlite3_constantes() { |
| 28 | - if (!defined('SPIP_SQLITE3_ASSOC')) { |
|
| 29 | - define('SPIP_SQLITE3_ASSOC', PDO::FETCH_ASSOC); |
|
| 30 | - define('SPIP_SQLITE3_NUM', PDO::FETCH_NUM); |
|
| 31 | - define('SPIP_SQLITE3_BOTH', PDO::FETCH_BOTH); |
|
| 32 | - } |
|
| 28 | + if (!defined('SPIP_SQLITE3_ASSOC')) { |
|
| 29 | + define('SPIP_SQLITE3_ASSOC', PDO::FETCH_ASSOC); |
|
| 30 | + define('SPIP_SQLITE3_NUM', PDO::FETCH_NUM); |
|
| 31 | + define('SPIP_SQLITE3_BOTH', PDO::FETCH_BOTH); |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function spip_versions_sqlite3() { |
| 36 | - return _sqlite_charger_version(3) ? 3 : false; |
|
| 36 | + return _sqlite_charger_version(3) ? 3 : false; |
|
| 37 | 37 | } |
@@ -16,5 +16,5 @@ |
||
| 16 | 16 | * Présentation des pages simplifiées publiques pour envoyer un message à un utilisateur |
| 17 | 17 | **/ |
| 18 | 18 | class Page extends AbstractPage { |
| 19 | - public const TYPE = 'public'; |
|
| 19 | + public const TYPE = 'public'; |
|
| 20 | 20 | } |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | if (!is_null($options['range'])) { |
| 55 | 55 | spip_livrer_fichier_partie($fichier, $options['range']); |
| 56 | - } |
|
| 57 | - else { |
|
| 56 | + } else { |
|
| 58 | 57 | spip_livrer_fichier_entier($fichier); |
| 59 | 58 | } |
| 60 | 59 | } |
@@ -92,8 +91,7 @@ discard block |
||
| 92 | 91 | header('Expires: 0'); // set expiration time |
| 93 | 92 | header('Pragma: public'); |
| 94 | 93 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 95 | - } |
|
| 96 | - else { |
|
| 94 | + } else { |
|
| 97 | 95 | $f = (is_string($attachment) ? $attachment : basename($fichier)); |
| 98 | 96 | header("Content-Disposition: inline; filename=\"$f\";"); |
| 99 | 97 | header('Expires: ' . $expires); // set expiration time |
@@ -160,8 +158,7 @@ discard block |
||
| 160 | 158 | } |
| 161 | 159 | |
| 162 | 160 | $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
| 163 | - } |
|
| 164 | - else { |
|
| 161 | + } else { |
|
| 165 | 162 | // si pas de range valide, on delegue a la methode d'envoi complet |
| 166 | 163 | spip_livrer_fichier_entier($fichier); |
| 167 | 164 | // redondant, mais facilite la comprehension du code |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Fichier |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -35,28 +35,28 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function spip_livrer_fichier($fichier, $content_type = 'application/octet-stream', $options = []) { |
| 37 | 37 | |
| 38 | - $defaut = [ |
|
| 39 | - 'attachment' => false, |
|
| 40 | - 'expires' => 3600, |
|
| 41 | - 'range' => null, |
|
| 42 | - ]; |
|
| 43 | - $options = array_merge($defaut, $options); |
|
| 44 | - if (is_numeric($options['expires']) && $options['expires'] > 0) { |
|
| 45 | - $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - if (is_null($options) && isset($_SERVER['HTTP_RANGE'])) { |
|
| 49 | - $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - spip_livrer_fichier_entetes($fichier, $content_type, ($options['attachment'] && !$options['range']) ? $options['attachment'] : false, $options['expires']); |
|
| 53 | - |
|
| 54 | - if (!is_null($options['range'])) { |
|
| 55 | - spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 56 | - } |
|
| 57 | - else { |
|
| 58 | - spip_livrer_fichier_entier($fichier); |
|
| 59 | - } |
|
| 38 | + $defaut = [ |
|
| 39 | + 'attachment' => false, |
|
| 40 | + 'expires' => 3600, |
|
| 41 | + 'range' => null, |
|
| 42 | + ]; |
|
| 43 | + $options = array_merge($defaut, $options); |
|
| 44 | + if (is_numeric($options['expires']) && $options['expires'] > 0) { |
|
| 45 | + $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + if (is_null($options) && isset($_SERVER['HTTP_RANGE'])) { |
|
| 49 | + $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + spip_livrer_fichier_entetes($fichier, $content_type, ($options['attachment'] && !$options['range']) ? $options['attachment'] : false, $options['expires']); |
|
| 53 | + |
|
| 54 | + if (!is_null($options['range'])) { |
|
| 55 | + spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 56 | + } |
|
| 57 | + else { |
|
| 58 | + spip_livrer_fichier_entier($fichier); |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -69,33 +69,33 @@ discard block |
||
| 69 | 69 | * @param int|string $expires |
| 70 | 70 | */ |
| 71 | 71 | function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) { |
| 72 | - // toujours envoyer un content type, meme vide ! |
|
| 73 | - header('Accept-Ranges: bytes'); |
|
| 74 | - header('Content-Type: ' . $content_type); |
|
| 75 | - |
|
| 76 | - if (($fs = stat($fichier)) && !empty($fs['size']) && !empty($fs['mtime'])) { |
|
| 77 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fs['mtime']) . ' GMT'); |
|
| 78 | - header(sprintf('Etag: "%x-%x"', $fs['size'], str_pad($fs['mtime'], 16, '0'))); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($attachment) { |
|
| 82 | - $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 83 | - // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 84 | - header('Content-Type: application/octet-stream'); |
|
| 85 | - |
|
| 86 | - header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 87 | - header('Content-Transfer-Encoding: binary'); |
|
| 88 | - |
|
| 89 | - // fix for IE caching or PHP bug issue |
|
| 90 | - header('Expires: 0'); // set expiration time |
|
| 91 | - header('Pragma: public'); |
|
| 92 | - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 93 | - } |
|
| 94 | - else { |
|
| 95 | - $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 96 | - header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 97 | - header('Expires: ' . $expires); // set expiration time |
|
| 98 | - } |
|
| 72 | + // toujours envoyer un content type, meme vide ! |
|
| 73 | + header('Accept-Ranges: bytes'); |
|
| 74 | + header('Content-Type: ' . $content_type); |
|
| 75 | + |
|
| 76 | + if (($fs = stat($fichier)) && !empty($fs['size']) && !empty($fs['mtime'])) { |
|
| 77 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fs['mtime']) . ' GMT'); |
|
| 78 | + header(sprintf('Etag: "%x-%x"', $fs['size'], str_pad($fs['mtime'], 16, '0'))); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($attachment) { |
|
| 82 | + $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 83 | + // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 84 | + header('Content-Type: application/octet-stream'); |
|
| 85 | + |
|
| 86 | + header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 87 | + header('Content-Transfer-Encoding: binary'); |
|
| 88 | + |
|
| 89 | + // fix for IE caching or PHP bug issue |
|
| 90 | + header('Expires: 0'); // set expiration time |
|
| 91 | + header('Pragma: public'); |
|
| 92 | + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 93 | + } |
|
| 94 | + else { |
|
| 95 | + $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 96 | + header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 97 | + header('Expires: ' . $expires); // set expiration time |
|
| 98 | + } |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | * @param string $fichier |
| 104 | 104 | */ |
| 105 | 105 | function spip_livrer_fichier_entier($fichier) { |
| 106 | - if (!file_exists($fichier)) { |
|
| 107 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 108 | - } |
|
| 106 | + if (!file_exists($fichier)) { |
|
| 107 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - if (!is_readable($fichier)) { |
|
| 111 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 112 | - } |
|
| 110 | + if (!is_readable($fichier)) { |
|
| 111 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - if ($size = filesize($fichier)) { |
|
| 115 | - header(sprintf('Content-Length: %d', $size)); |
|
| 116 | - } |
|
| 114 | + if ($size = filesize($fichier)) { |
|
| 115 | + header(sprintf('Content-Length: %d', $size)); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - readfile($fichier); |
|
| 119 | - exit(); |
|
| 118 | + readfile($fichier); |
|
| 119 | + exit(); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -129,98 +129,98 @@ discard block |
||
| 129 | 129 | * @throws Exception |
| 130 | 130 | */ |
| 131 | 131 | function spip_livrer_fichier_partie($fichier, $range = null) { |
| 132 | - if (!file_exists($fichier)) { |
|
| 133 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 134 | - } |
|
| 132 | + if (!file_exists($fichier)) { |
|
| 133 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - if (!is_readable($fichier)) { |
|
| 137 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 138 | - } |
|
| 136 | + if (!is_readable($fichier)) { |
|
| 137 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | |
| 141 | - // Par defaut on envoie tout |
|
| 142 | - $byteOffset = 0; |
|
| 143 | - $byteLength = $fileSize = filesize($fichier); |
|
| 141 | + // Par defaut on envoie tout |
|
| 142 | + $byteOffset = 0; |
|
| 143 | + $byteLength = $fileSize = filesize($fichier); |
|
| 144 | 144 | |
| 145 | 145 | |
| 146 | - // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 147 | - if ($range && preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 148 | - ### Offset signifies where we should begin to read the file |
|
| 149 | - $byteOffset = (int)$match[1]; |
|
| 146 | + // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 147 | + if ($range && preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 148 | + ### Offset signifies where we should begin to read the file |
|
| 149 | + $byteOffset = (int)$match[1]; |
|
| 150 | 150 | |
| 151 | 151 | |
| 152 | - ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 153 | - if (isset($match[2])) { |
|
| 154 | - $finishBytes = (int)$match[2]; |
|
| 155 | - $byteLength = $finishBytes + 1; |
|
| 156 | - } else { |
|
| 157 | - $finishBytes = $fileSize - 1; |
|
| 158 | - } |
|
| 152 | + ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 153 | + if (isset($match[2])) { |
|
| 154 | + $finishBytes = (int)$match[2]; |
|
| 155 | + $byteLength = $finishBytes + 1; |
|
| 156 | + } else { |
|
| 157 | + $finishBytes = $fileSize - 1; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 161 | - } |
|
| 162 | - else { |
|
| 163 | - // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 164 | - spip_livrer_fichier_entier($fichier); |
|
| 165 | - // redondant, mais facilite la comprehension du code |
|
| 166 | - exit(); |
|
| 167 | - } |
|
| 160 | + $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 161 | + } |
|
| 162 | + else { |
|
| 163 | + // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 164 | + spip_livrer_fichier_entier($fichier); |
|
| 165 | + // redondant, mais facilite la comprehension du code |
|
| 166 | + exit(); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - // Remove headers that might unnecessarily clutter up the output |
|
| 170 | - header_remove('Cache-Control'); |
|
| 171 | - header_remove('Pragma'); |
|
| 169 | + // Remove headers that might unnecessarily clutter up the output |
|
| 170 | + header_remove('Cache-Control'); |
|
| 171 | + header_remove('Pragma'); |
|
| 172 | 172 | |
| 173 | - // partial content |
|
| 174 | - header('HTTP/1.1 206 Partial content'); |
|
| 175 | - header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 173 | + // partial content |
|
| 174 | + header('HTTP/1.1 206 Partial content'); |
|
| 175 | + header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | - $byteRange = $byteLength - $byteOffset; |
|
| 178 | + $byteRange = $byteLength - $byteOffset; |
|
| 179 | 179 | |
| 180 | - header(sprintf('Content-Length: %d', $byteRange)); |
|
| 180 | + header(sprintf('Content-Length: %d', $byteRange)); |
|
| 181 | 181 | |
| 182 | - // Variable containing the buffer |
|
| 183 | - $buffer = ''; |
|
| 184 | - // Just a reasonable buffer size |
|
| 185 | - $bufferSize = 512 * 16; |
|
| 186 | - // Contains how much is left to read of the byteRange |
|
| 187 | - $bytePool = $byteRange; |
|
| 182 | + // Variable containing the buffer |
|
| 183 | + $buffer = ''; |
|
| 184 | + // Just a reasonable buffer size |
|
| 185 | + $bufferSize = 512 * 16; |
|
| 186 | + // Contains how much is left to read of the byteRange |
|
| 187 | + $bytePool = $byteRange; |
|
| 188 | 188 | |
| 189 | - if (!$handle = fopen($fichier, 'r')) { |
|
| 190 | - throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 191 | - } |
|
| 189 | + if (!$handle = fopen($fichier, 'r')) { |
|
| 190 | + throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 194 | - throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 195 | - } |
|
| 193 | + if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 194 | + throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | |
| 198 | - while ($bytePool > 0) { |
|
| 199 | - // How many bytes we request on this iteration |
|
| 200 | - $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 198 | + while ($bytePool > 0) { |
|
| 199 | + // How many bytes we request on this iteration |
|
| 200 | + $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 201 | 201 | |
| 202 | - // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 203 | - $buffer = fread($handle, $chunkSizeRequested); |
|
| 202 | + // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 203 | + $buffer = fread($handle, $chunkSizeRequested); |
|
| 204 | 204 | |
| 205 | - // Store how many bytes were actually read |
|
| 206 | - $chunkSizeActual = strlen($buffer); |
|
| 205 | + // Store how many bytes were actually read |
|
| 206 | + $chunkSizeActual = strlen($buffer); |
|
| 207 | 207 | |
| 208 | - // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 209 | - if ($chunkSizeActual == 0) { |
|
| 210 | - // For production servers this should go in your php error log, since it will break the output |
|
| 211 | - trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 212 | - break; |
|
| 213 | - } |
|
| 208 | + // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 209 | + if ($chunkSizeActual == 0) { |
|
| 210 | + // For production servers this should go in your php error log, since it will break the output |
|
| 211 | + trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 216 | - $bytePool -= $chunkSizeActual; |
|
| 215 | + // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 216 | + $bytePool -= $chunkSizeActual; |
|
| 217 | 217 | |
| 218 | - // Write the buffer to output |
|
| 219 | - print $buffer; |
|
| 218 | + // Write the buffer to output |
|
| 219 | + print $buffer; |
|
| 220 | 220 | |
| 221 | - // Try to output the data to the client immediately |
|
| 222 | - flush(); |
|
| 223 | - } |
|
| 221 | + // Try to output the data to the client immediately |
|
| 222 | + flush(); |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - exit(); |
|
| 225 | + exit(); |
|
| 226 | 226 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | ]; |
| 43 | 43 | $options = array_merge($defaut, $options); |
| 44 | 44 | if (is_numeric($options['expires']) && $options['expires'] > 0) { |
| 45 | - $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 45 | + $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']).' GMT'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | if (is_null($options) && isset($_SERVER['HTTP_RANGE'])) { |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) { |
| 72 | 72 | // toujours envoyer un content type, meme vide ! |
| 73 | 73 | header('Accept-Ranges: bytes'); |
| 74 | - header('Content-Type: ' . $content_type); |
|
| 74 | + header('Content-Type: '.$content_type); |
|
| 75 | 75 | |
| 76 | 76 | if (($fs = stat($fichier)) && !empty($fs['size']) && !empty($fs['mtime'])) { |
| 77 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fs['mtime']) . ' GMT'); |
|
| 77 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fs['mtime']).' GMT'); |
|
| 78 | 78 | header(sprintf('Etag: "%x-%x"', $fs['size'], str_pad($fs['mtime'], 16, '0'))); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | else { |
| 95 | 95 | $f = (is_string($attachment) ? $attachment : basename($fichier)); |
| 96 | 96 | header("Content-Disposition: inline; filename=\"$f\";"); |
| 97 | - header('Expires: ' . $expires); // set expiration time |
|
| 97 | + header('Expires: '.$expires); // set expiration time |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
| 147 | 147 | if ($range && preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
| 148 | 148 | ### Offset signifies where we should begin to read the file |
| 149 | - $byteOffset = (int)$match[1]; |
|
| 149 | + $byteOffset = (int) $match[1]; |
|
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
| 153 | 153 | if (isset($match[2])) { |
| 154 | - $finishBytes = (int)$match[2]; |
|
| 154 | + $finishBytes = (int) $match[2]; |
|
| 155 | 155 | $byteLength = $finishBytes + 1; |
| 156 | 156 | } else { |
| 157 | 157 | $finishBytes = $fileSize - 1; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | // partial content |
| 174 | 174 | header('HTTP/1.1 206 Partial content'); |
| 175 | - header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 175 | + header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | $byteRange = $byteLength - $byteOffset; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * JSON des différentes informations |
| 34 | 34 | */ |
| 35 | 35 | function informer_auteur($bof) { |
| 36 | - include_spip('inc/json'); |
|
| 37 | - include_spip('formulaires/login'); |
|
| 38 | - include_spip('inc/auth'); |
|
| 39 | - $login = (string) _request('var_login'); |
|
| 40 | - $row = auth_informer_login($login); |
|
| 41 | - if ($row && is_array($row) && isset($row['id_auteur'])) { |
|
| 42 | - unset($row['id_auteur']); |
|
| 43 | - } |
|
| 36 | + include_spip('inc/json'); |
|
| 37 | + include_spip('formulaires/login'); |
|
| 38 | + include_spip('inc/auth'); |
|
| 39 | + $login = (string) _request('var_login'); |
|
| 40 | + $row = auth_informer_login($login); |
|
| 41 | + if ($row && is_array($row) && isset($row['id_auteur'])) { |
|
| 42 | + unset($row['id_auteur']); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // on encode tout pour ne pas avoir de probleme au deballage dans le JS |
|
| 46 | - return json_encode($row, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
|
| 45 | + // on encode tout pour ne pas avoir de probleme au deballage dans le JS |
|
| 46 | + return json_encode($row, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
|
| 47 | 47 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // un checkbox seul de name X non coche n'est pas poste. |
| 40 | 40 | // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
| 41 | 41 | foreach (['multi_secteurs'] as $m) { |
| 42 | - if (!is_null(_request($m . '_check'))) { |
|
| 42 | + if (!is_null(_request($m.'_check'))) { |
|
| 43 | 43 | ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | . "'>" |
| 113 | 113 | . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
| 114 | 114 | . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
| 115 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 115 | + . "<label for='{$name}_$code_langue'>".$nom_langue." <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | 116 | . '</li>'; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if ($res) { |
| 120 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 120 | + $res = "<ul id='langues_bloquees'>".$res."</ul><div class='nettoyeur'></div>"; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $res .= "<ul id='langues_proposees'>"; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | . "<label for='{$name}_$code_langue'" |
| 138 | 138 | . ($checked ? " class='on'" : '') |
| 139 | 139 | . '>' |
| 140 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 140 | + . $nom_langue." <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | 141 | . '</li>'; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 145 | + return $res."</ul><div class='nettoyeur'></div>"; |
|
| 146 | 146 | } |
@@ -10,53 +10,53 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_multilinguisme_charger_dist() { |
| 17 | - $valeurs = []; |
|
| 18 | - $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 19 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 20 | - $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if ( |
|
| 24 | - (is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0) |
|
| 25 | - || count(explode(',', (string) $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 26 | - ) { |
|
| 27 | - $selection = (is_null(_request('multi_objets')) ? |
|
| 28 | - explode(',', (string) $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 29 | - $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 30 | - $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - return $valeurs; |
|
| 17 | + $valeurs = []; |
|
| 18 | + $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 19 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 20 | + $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if ( |
|
| 24 | + (is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0) |
|
| 25 | + || count(explode(',', (string) $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 26 | + ) { |
|
| 27 | + $selection = (is_null(_request('multi_objets')) ? |
|
| 28 | + explode(',', (string) $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 29 | + $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 30 | + $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + return $valeurs; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | function formulaires_configurer_multilinguisme_traiter_dist() { |
| 38 | - $res = ['editable' => true]; |
|
| 39 | - // un checkbox seul de name X non coche n'est pas poste. |
|
| 40 | - // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 41 | - foreach (['multi_secteurs'] as $m) { |
|
| 42 | - if (!is_null(_request($m . '_check'))) { |
|
| 43 | - ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 47 | - if (!is_null($v = _request($m))) { |
|
| 48 | - // join et enlever la valeur vide '' |
|
| 49 | - ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (($i = _request('langues_auth')) && is_array($i)) { |
|
| 54 | - $i = array_unique(array_merge($i, explode(',', (string) $GLOBALS['meta']['langues_utilisees']))); |
|
| 55 | - ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 56 | - } |
|
| 57 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 58 | - |
|
| 59 | - return $res; |
|
| 38 | + $res = ['editable' => true]; |
|
| 39 | + // un checkbox seul de name X non coche n'est pas poste. |
|
| 40 | + // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 41 | + foreach (['multi_secteurs'] as $m) { |
|
| 42 | + if (!is_null(_request($m . '_check'))) { |
|
| 43 | + ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 47 | + if (!is_null($v = _request($m))) { |
|
| 48 | + // join et enlever la valeur vide '' |
|
| 49 | + ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (($i = _request('langues_auth')) && is_array($i)) { |
|
| 54 | + $i = array_unique(array_merge($i, explode(',', (string) $GLOBALS['meta']['langues_utilisees']))); |
|
| 55 | + ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 56 | + } |
|
| 57 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 58 | + |
|
| 59 | + return $res; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | 68 | function table_supporte_lang($table_sql) { |
| 69 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 70 | - $desc = $trouver_table($table_sql); |
|
| 71 | - if (!$desc || !isset($desc['field']['lang'])) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 69 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 70 | + $desc = $trouver_table($table_sql); |
|
| 71 | + if (!$desc || !isset($desc['field']['lang'])) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return ' '; |
|
| 75 | + return ' '; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -82,65 +82,65 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function table_supporte_trad($table_sql) { |
| 85 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 86 | - $desc = $trouver_table($table_sql); |
|
| 87 | - if (!$desc || !isset($desc['field']['id_trad'])) { |
|
| 88 | - return ''; |
|
| 89 | - } |
|
| 85 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 86 | + $desc = $trouver_table($table_sql); |
|
| 87 | + if (!$desc || !isset($desc['field']['id_trad'])) { |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return ' '; |
|
| 91 | + return ' '; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | function saisie_langues_utiles($name, $selection) { |
| 96 | - include_spip('inc/lang_liste'); |
|
| 97 | - $langues = $GLOBALS['codes_langues']; |
|
| 98 | - |
|
| 99 | - $langues_installees = explode(',', (string) $GLOBALS['meta']['langues_proposees']); |
|
| 100 | - $langues_trad = array_flip($langues_installees); |
|
| 101 | - |
|
| 102 | - $langues_bloquees = explode(',', (string) $GLOBALS['meta']['langues_utilisees']); |
|
| 103 | - |
|
| 104 | - $res = ''; |
|
| 105 | - |
|
| 106 | - $i = 0; |
|
| 107 | - foreach ($langues_bloquees as $code_langue) { |
|
| 108 | - $nom_langue = $langues[$code_langue]; |
|
| 109 | - $res .= "<li class='choix " |
|
| 110 | - . alterner(++$i, 'odd', 'even') |
|
| 111 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 112 | - . "'>" |
|
| 113 | - . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 114 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 115 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | - . '</li>'; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($res) { |
|
| 120 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $res .= "<ul id='langues_proposees'>"; |
|
| 124 | - |
|
| 125 | - $i = 0; |
|
| 126 | - $langues_bloquees = array_flip($langues_bloquees); |
|
| 127 | - foreach ($langues as $code_langue => $nom_langue) { |
|
| 128 | - if (!isset($langues_bloquees[$code_langue])) { |
|
| 129 | - $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 130 | - $res .= "<li class='choix " |
|
| 131 | - . alterner(++$i, 'odd', 'even') |
|
| 132 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 133 | - . "'>" |
|
| 134 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 135 | - . $checked |
|
| 136 | - . '/>' |
|
| 137 | - . "<label for='{$name}_$code_langue'" |
|
| 138 | - . ($checked ? " class='on'" : '') |
|
| 139 | - . '>' |
|
| 140 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | - . '</li>'; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 96 | + include_spip('inc/lang_liste'); |
|
| 97 | + $langues = $GLOBALS['codes_langues']; |
|
| 98 | + |
|
| 99 | + $langues_installees = explode(',', (string) $GLOBALS['meta']['langues_proposees']); |
|
| 100 | + $langues_trad = array_flip($langues_installees); |
|
| 101 | + |
|
| 102 | + $langues_bloquees = explode(',', (string) $GLOBALS['meta']['langues_utilisees']); |
|
| 103 | + |
|
| 104 | + $res = ''; |
|
| 105 | + |
|
| 106 | + $i = 0; |
|
| 107 | + foreach ($langues_bloquees as $code_langue) { |
|
| 108 | + $nom_langue = $langues[$code_langue]; |
|
| 109 | + $res .= "<li class='choix " |
|
| 110 | + . alterner(++$i, 'odd', 'even') |
|
| 111 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 112 | + . "'>" |
|
| 113 | + . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 114 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 115 | + . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | + . '</li>'; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($res) { |
|
| 120 | + $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $res .= "<ul id='langues_proposees'>"; |
|
| 124 | + |
|
| 125 | + $i = 0; |
|
| 126 | + $langues_bloquees = array_flip($langues_bloquees); |
|
| 127 | + foreach ($langues as $code_langue => $nom_langue) { |
|
| 128 | + if (!isset($langues_bloquees[$code_langue])) { |
|
| 129 | + $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 130 | + $res .= "<li class='choix " |
|
| 131 | + . alterner(++$i, 'odd', 'even') |
|
| 132 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 133 | + . "'>" |
|
| 134 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 135 | + . $checked |
|
| 136 | + . '/>' |
|
| 137 | + . "<label for='{$name}_$code_langue'" |
|
| 138 | + . ($checked ? " class='on'" : '') |
|
| 139 | + . '>' |
|
| 140 | + . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | + . '</li>'; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 146 | 146 | } |
@@ -10,33 +10,33 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_transcodeur_charger_dist() { |
| 17 | - return [ |
|
| 18 | - 'charset' => $GLOBALS['meta']['charset'], |
|
| 19 | - ]; |
|
| 17 | + return [ |
|
| 18 | + 'charset' => $GLOBALS['meta']['charset'], |
|
| 19 | + ]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | function formulaires_configurer_transcodeur_verifier_dist() { |
| 23 | - include_spip('inc/charsets'); |
|
| 23 | + include_spip('inc/charsets'); |
|
| 24 | 24 | |
| 25 | - $erreurs = []; |
|
| 26 | - if (!$charset = _request('charset')) { |
|
| 27 | - $erreurs['charset'] = _T('info_obligatoire'); |
|
| 28 | - } elseif ($charset != 'utf-8' && !load_charset($charset)) { |
|
| 29 | - $erreurs['charset'] = _T('utf8_convert_erreur_orig', ['charset' => entites_html($charset)]); |
|
| 30 | - } |
|
| 25 | + $erreurs = []; |
|
| 26 | + if (!$charset = _request('charset')) { |
|
| 27 | + $erreurs['charset'] = _T('info_obligatoire'); |
|
| 28 | + } elseif ($charset != 'utf-8' && !load_charset($charset)) { |
|
| 29 | + $erreurs['charset'] = _T('utf8_convert_erreur_orig', ['charset' => entites_html($charset)]); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return $erreurs; |
|
| 32 | + return $erreurs; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | function formulaires_configurer_transcodeur_traiter_dist() { |
| 37 | - $res = ['editable' => true]; |
|
| 38 | - ecrire_meta('charset', _request('charset')); |
|
| 39 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 37 | + $res = ['editable' => true]; |
|
| 38 | + ecrire_meta('charset', _request('charset')); |
|
| 39 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 40 | 40 | |
| 41 | - return $res; |
|
| 41 | + return $res; |
|
| 42 | 42 | } |
@@ -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 | |
@@ -44,136 +44,136 @@ discard block |
||
| 44 | 44 | **/ |
| 45 | 45 | function formulaires_dater_charger_dist($objet, $id_objet, $retour = '', $options = []) { |
| 46 | 46 | |
| 47 | - $jour = null; |
|
| 48 | - $mois = null; |
|
| 49 | - $annee = null; |
|
| 50 | - $heure = null; |
|
| 51 | - $minute = null; |
|
| 52 | - $objet = objet_type($objet); |
|
| 53 | - if (!$objet || !(int) $id_objet) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if (!is_array($options)) { |
|
| 58 | - $options = unserialize($options); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $_id_objet = id_table_objet($objet); |
|
| 62 | - $table = table_objet($objet); |
|
| 63 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | - $desc = $trouver_table($table); |
|
| 65 | - |
|
| 66 | - if (!$desc) { |
|
| 67 | - return false; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $champ_date = $desc['date'] ?: 'date'; |
|
| 71 | - if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 72 | - $champ_date = $options['champ_date']; |
|
| 73 | - } |
|
| 74 | - if (!isset($desc['field'][$champ_date])) { |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $valeurs = [ |
|
| 79 | - 'objet' => $objet, |
|
| 80 | - 'id_objet' => $id_objet, |
|
| 81 | - 'id' => $id_objet, |
|
| 82 | - ]; |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - $select = "$champ_date as date"; |
|
| 86 | - $champ_date_redac = 'date_redac'; |
|
| 87 | - if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 88 | - $champ_date_redac = $options['champ_date_redac']; |
|
| 89 | - } |
|
| 90 | - if (isset($desc['field'][$champ_date_redac])) { |
|
| 91 | - $select .= ",$champ_date_redac as date_redac"; |
|
| 92 | - } |
|
| 93 | - if (isset($desc['field']['statut'])) { |
|
| 94 | - $select .= ',statut'; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . (int) $id_objet); |
|
| 99 | - $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
|
| 100 | - |
|
| 101 | - $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
|
| 102 | - |
|
| 103 | - $possedeDateRedac = false; |
|
| 104 | - |
|
| 105 | - if ( |
|
| 106 | - isset($row['date_redac']) |
|
| 107 | - && ($regs = recup_date($row['date_redac'], false)) |
|
| 108 | - ) { |
|
| 109 | - $annee_redac = $regs[0]; |
|
| 110 | - $mois_redac = $regs[1]; |
|
| 111 | - $jour_redac = $regs[2]; |
|
| 112 | - $heure_redac = $regs[3]; |
|
| 113 | - $minute_redac = $regs[4]; |
|
| 114 | - $possedeDateRedac = true; |
|
| 115 | - // attention : les vrai dates de l'annee 1 sont stockee avec +9000 => 9001 |
|
| 116 | - // mais reviennent ici en annee 1 par recup_date |
|
| 117 | - // on verifie donc que le intval($row['date_redac']) qui ressort l'annee |
|
| 118 | - // est bien lui aussi <=1 : dans ce cas c'est une date sql 'nulle' ou presque, selon |
|
| 119 | - // le gestionnnaire sql utilise (0001-01-01 pour PG par exemple) |
|
| 120 | - if ((int) $row['date_redac'] <= 1 && $annee_redac <= 1 && $mois_redac <= 1 && $jour_redac <= 1) { |
|
| 121 | - $possedeDateRedac = false; |
|
| 122 | - } |
|
| 123 | - } else { |
|
| 124 | - $annee_redac = $mois_redac = $jour_redac = $heure_redac = $minute_redac = 0; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - if ($regs = recup_date($row['date'], false)) { |
|
| 128 | - $annee = $regs[0]; |
|
| 129 | - $mois = $regs[1]; |
|
| 130 | - $jour = $regs[2]; |
|
| 131 | - $heure = $regs[3]; |
|
| 132 | - $minute = $regs[4]; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // attention, si la variable s'appelle date ou date_redac, le compilo va |
|
| 136 | - // la normaliser, ce qu'on ne veut pas ici. |
|
| 137 | - $valeurs['afficher_date_redac'] = ($possedeDateRedac ? $row['date_redac'] : ''); |
|
| 138 | - $valeurs['date_redac_jour'] = dater_formater_saisie_jour($jour_redac, $mois_redac, $annee_redac); |
|
| 139 | - $valeurs['date_redac_heure'] = "$heure_redac:$minute_redac"; |
|
| 140 | - |
|
| 141 | - $valeurs['afficher_date'] = $row['date']; |
|
| 142 | - $valeurs['date_jour'] = dater_formater_saisie_jour($jour, $mois, $annee); |
|
| 143 | - $valeurs['date_heure'] = "$heure:$minute"; |
|
| 144 | - |
|
| 145 | - $valeurs['sans_redac'] = !$possedeDateRedac; |
|
| 146 | - |
|
| 147 | - if (isset($options['date_redac'])) { |
|
| 148 | - $valeurs['_editer_date_anterieure'] = $options['date_redac']; |
|
| 149 | - } else { |
|
| 150 | - $valeurs['_editer_date_anterieure'] = ($objet == 'article' && ($GLOBALS['meta']['articles_redac'] != 'non' || $possedeDateRedac)); |
|
| 151 | - } |
|
| 152 | - $valeurs['_label_date'] = (($statut == 'publie') ? |
|
| 153 | - _T('texte_date_publication_objet') : _T('texte_date_creation_objet')); |
|
| 154 | - if (isset($options['label_date']) && $options['label_date']) { |
|
| 155 | - $valeurs['_label_date'] = $options['label_date']; |
|
| 156 | - } |
|
| 157 | - if (isset($options['label_date_redac']) && $options['label_date_redac']) { |
|
| 158 | - $valeurs['_label_date_redac'] = $options['label_date_redac']; |
|
| 159 | - } |
|
| 160 | - if (isset($options['texte_sans_date_redac']) && $options['texte_sans_date_redac']) { |
|
| 161 | - $valeurs['_texte_sans_date_redac'] = $options['texte_sans_date_redac']; |
|
| 162 | - } |
|
| 163 | - if (isset($options['class']) && $options['class']) { |
|
| 164 | - $valeurs['_class'] = $options['class']; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $valeurs['_saisie_en_cours'] = (_request('_saisie_en_cours') !== null || _request('date_jour') !== null); |
|
| 168 | - |
|
| 169 | - // cas ou l'on ne peut pas dater mais on peut modifier la date de redac anterieure |
|
| 170 | - // https://core.spip.net/issues/3494 |
|
| 171 | - $valeurs['_editer_date'] = $valeurs['editable']; |
|
| 172 | - if ($valeurs['_editer_date_anterieure'] && !$valeurs['editable']) { |
|
| 173 | - $valeurs['editable'] = autoriser('modifier', $objet, $id_objet); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - return $valeurs; |
|
| 47 | + $jour = null; |
|
| 48 | + $mois = null; |
|
| 49 | + $annee = null; |
|
| 50 | + $heure = null; |
|
| 51 | + $minute = null; |
|
| 52 | + $objet = objet_type($objet); |
|
| 53 | + if (!$objet || !(int) $id_objet) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if (!is_array($options)) { |
|
| 58 | + $options = unserialize($options); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $_id_objet = id_table_objet($objet); |
|
| 62 | + $table = table_objet($objet); |
|
| 63 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | + $desc = $trouver_table($table); |
|
| 65 | + |
|
| 66 | + if (!$desc) { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $champ_date = $desc['date'] ?: 'date'; |
|
| 71 | + if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 72 | + $champ_date = $options['champ_date']; |
|
| 73 | + } |
|
| 74 | + if (!isset($desc['field'][$champ_date])) { |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $valeurs = [ |
|
| 79 | + 'objet' => $objet, |
|
| 80 | + 'id_objet' => $id_objet, |
|
| 81 | + 'id' => $id_objet, |
|
| 82 | + ]; |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + $select = "$champ_date as date"; |
|
| 86 | + $champ_date_redac = 'date_redac'; |
|
| 87 | + if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 88 | + $champ_date_redac = $options['champ_date_redac']; |
|
| 89 | + } |
|
| 90 | + if (isset($desc['field'][$champ_date_redac])) { |
|
| 91 | + $select .= ",$champ_date_redac as date_redac"; |
|
| 92 | + } |
|
| 93 | + if (isset($desc['field']['statut'])) { |
|
| 94 | + $select .= ',statut'; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . (int) $id_objet); |
|
| 99 | + $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
|
| 100 | + |
|
| 101 | + $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
|
| 102 | + |
|
| 103 | + $possedeDateRedac = false; |
|
| 104 | + |
|
| 105 | + if ( |
|
| 106 | + isset($row['date_redac']) |
|
| 107 | + && ($regs = recup_date($row['date_redac'], false)) |
|
| 108 | + ) { |
|
| 109 | + $annee_redac = $regs[0]; |
|
| 110 | + $mois_redac = $regs[1]; |
|
| 111 | + $jour_redac = $regs[2]; |
|
| 112 | + $heure_redac = $regs[3]; |
|
| 113 | + $minute_redac = $regs[4]; |
|
| 114 | + $possedeDateRedac = true; |
|
| 115 | + // attention : les vrai dates de l'annee 1 sont stockee avec +9000 => 9001 |
|
| 116 | + // mais reviennent ici en annee 1 par recup_date |
|
| 117 | + // on verifie donc que le intval($row['date_redac']) qui ressort l'annee |
|
| 118 | + // est bien lui aussi <=1 : dans ce cas c'est une date sql 'nulle' ou presque, selon |
|
| 119 | + // le gestionnnaire sql utilise (0001-01-01 pour PG par exemple) |
|
| 120 | + if ((int) $row['date_redac'] <= 1 && $annee_redac <= 1 && $mois_redac <= 1 && $jour_redac <= 1) { |
|
| 121 | + $possedeDateRedac = false; |
|
| 122 | + } |
|
| 123 | + } else { |
|
| 124 | + $annee_redac = $mois_redac = $jour_redac = $heure_redac = $minute_redac = 0; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + if ($regs = recup_date($row['date'], false)) { |
|
| 128 | + $annee = $regs[0]; |
|
| 129 | + $mois = $regs[1]; |
|
| 130 | + $jour = $regs[2]; |
|
| 131 | + $heure = $regs[3]; |
|
| 132 | + $minute = $regs[4]; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // attention, si la variable s'appelle date ou date_redac, le compilo va |
|
| 136 | + // la normaliser, ce qu'on ne veut pas ici. |
|
| 137 | + $valeurs['afficher_date_redac'] = ($possedeDateRedac ? $row['date_redac'] : ''); |
|
| 138 | + $valeurs['date_redac_jour'] = dater_formater_saisie_jour($jour_redac, $mois_redac, $annee_redac); |
|
| 139 | + $valeurs['date_redac_heure'] = "$heure_redac:$minute_redac"; |
|
| 140 | + |
|
| 141 | + $valeurs['afficher_date'] = $row['date']; |
|
| 142 | + $valeurs['date_jour'] = dater_formater_saisie_jour($jour, $mois, $annee); |
|
| 143 | + $valeurs['date_heure'] = "$heure:$minute"; |
|
| 144 | + |
|
| 145 | + $valeurs['sans_redac'] = !$possedeDateRedac; |
|
| 146 | + |
|
| 147 | + if (isset($options['date_redac'])) { |
|
| 148 | + $valeurs['_editer_date_anterieure'] = $options['date_redac']; |
|
| 149 | + } else { |
|
| 150 | + $valeurs['_editer_date_anterieure'] = ($objet == 'article' && ($GLOBALS['meta']['articles_redac'] != 'non' || $possedeDateRedac)); |
|
| 151 | + } |
|
| 152 | + $valeurs['_label_date'] = (($statut == 'publie') ? |
|
| 153 | + _T('texte_date_publication_objet') : _T('texte_date_creation_objet')); |
|
| 154 | + if (isset($options['label_date']) && $options['label_date']) { |
|
| 155 | + $valeurs['_label_date'] = $options['label_date']; |
|
| 156 | + } |
|
| 157 | + if (isset($options['label_date_redac']) && $options['label_date_redac']) { |
|
| 158 | + $valeurs['_label_date_redac'] = $options['label_date_redac']; |
|
| 159 | + } |
|
| 160 | + if (isset($options['texte_sans_date_redac']) && $options['texte_sans_date_redac']) { |
|
| 161 | + $valeurs['_texte_sans_date_redac'] = $options['texte_sans_date_redac']; |
|
| 162 | + } |
|
| 163 | + if (isset($options['class']) && $options['class']) { |
|
| 164 | + $valeurs['_class'] = $options['class']; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $valeurs['_saisie_en_cours'] = (_request('_saisie_en_cours') !== null || _request('date_jour') !== null); |
|
| 168 | + |
|
| 169 | + // cas ou l'on ne peut pas dater mais on peut modifier la date de redac anterieure |
|
| 170 | + // https://core.spip.net/issues/3494 |
|
| 171 | + $valeurs['_editer_date'] = $valeurs['editable']; |
|
| 172 | + if ($valeurs['_editer_date_anterieure'] && !$valeurs['editable']) { |
|
| 173 | + $valeurs['editable'] = autoriser('modifier', $objet, $id_objet); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + return $valeurs; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -191,20 +191,20 @@ discard block |
||
| 191 | 191 | * Date formatée tel que `02/10/2012` |
| 192 | 192 | **/ |
| 193 | 193 | function dater_formater_saisie_jour($jour, $mois, $annee, $sep = '/') { |
| 194 | - $annee = str_pad($annee, 4, '0', STR_PAD_LEFT); |
|
| 195 | - if ((int) $jour) { |
|
| 196 | - $jour = str_pad($jour, 2, '0', STR_PAD_LEFT); |
|
| 197 | - $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 194 | + $annee = str_pad($annee, 4, '0', STR_PAD_LEFT); |
|
| 195 | + if ((int) $jour) { |
|
| 196 | + $jour = str_pad($jour, 2, '0', STR_PAD_LEFT); |
|
| 197 | + $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 198 | 198 | |
| 199 | - return "$jour$sep$mois$sep$annee"; |
|
| 200 | - } |
|
| 201 | - if ((int) $mois) { |
|
| 202 | - $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 199 | + return "$jour$sep$mois$sep$annee"; |
|
| 200 | + } |
|
| 201 | + if ((int) $mois) { |
|
| 202 | + $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 203 | 203 | |
| 204 | - return "$mois$sep$annee"; |
|
| 205 | - } |
|
| 204 | + return "$mois$sep$annee"; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - return $annee; |
|
| 207 | + return $annee; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * Hash du formulaire |
| 224 | 224 | **/ |
| 225 | 225 | function formulaires_dater_identifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 226 | - return serialize([$objet, $id_objet]); |
|
| 226 | + return serialize([$objet, $id_objet]); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -241,30 +241,30 @@ discard block |
||
| 241 | 241 | * Tableau des erreurs |
| 242 | 242 | */ |
| 243 | 243 | function formulaires_dater_verifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 244 | - $erreurs = []; |
|
| 245 | - |
|
| 246 | - // ouvrir le formulaire en edition ? |
|
| 247 | - if (_request('_saisie_en_cours')) { |
|
| 248 | - $erreurs['message_erreur'] = ''; |
|
| 249 | - |
|
| 250 | - return $erreurs; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - if (_request('changer')) { |
|
| 254 | - foreach (['date', 'date_redac'] as $k) { |
|
| 255 | - if (($v = _request($k . '_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 256 | - $erreurs[$k] = _T('format_date_incorrecte'); |
|
| 257 | - } elseif (($v = _request($k . '_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 258 | - $erreurs[$k] = _T('format_heure_incorrecte'); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if (!_request('date_jour')) { |
|
| 263 | - $erreurs['date'] = _T('info_obligatoire'); |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return $erreurs; |
|
| 244 | + $erreurs = []; |
|
| 245 | + |
|
| 246 | + // ouvrir le formulaire en edition ? |
|
| 247 | + if (_request('_saisie_en_cours')) { |
|
| 248 | + $erreurs['message_erreur'] = ''; |
|
| 249 | + |
|
| 250 | + return $erreurs; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + if (_request('changer')) { |
|
| 254 | + foreach (['date', 'date_redac'] as $k) { |
|
| 255 | + if (($v = _request($k . '_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 256 | + $erreurs[$k] = _T('format_date_incorrecte'); |
|
| 257 | + } elseif (($v = _request($k . '_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 258 | + $erreurs[$k] = _T('format_heure_incorrecte'); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if (!_request('date_jour')) { |
|
| 263 | + $erreurs['date'] = _T('info_obligatoire'); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return $erreurs; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -282,79 +282,79 @@ discard block |
||
| 282 | 282 | * Retours des traitements |
| 283 | 283 | */ |
| 284 | 284 | function formulaires_dater_traiter_dist($objet, $id_objet, $retour = '', $options = []) { |
| 285 | - $res = ['editable' => ' ']; |
|
| 286 | - |
|
| 287 | - if (_request('changer')) { |
|
| 288 | - $table = table_objet($objet); |
|
| 289 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 290 | - $desc = $trouver_table($table); |
|
| 291 | - |
|
| 292 | - if (!$desc) { |
|
| 293 | - return ['message_erreur' => _L('erreur')]; |
|
| 294 | - } #impossible en principe |
|
| 295 | - |
|
| 296 | - $champ_date = $desc['date'] ?: 'date'; |
|
| 297 | - if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 298 | - $champ_date = $options['champ_date']; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - $set = []; |
|
| 302 | - |
|
| 303 | - $charger = charger_fonction('charger', 'formulaires/dater/'); |
|
| 304 | - $v = $charger($objet, $id_objet, $retour, $options); |
|
| 305 | - |
|
| 306 | - if ($v['_editer_date']) { |
|
| 307 | - if (!$d = dater_recuperer_date_saisie(_request('date_jour'))) { |
|
| 308 | - $d = [date('Y'), date('m'), date('d')]; |
|
| 309 | - } |
|
| 310 | - if (!$h = dater_recuperer_heure_saisie(_request('date_heure'))) { |
|
| 311 | - $h = [0, 0]; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - $champ_date_redac = 'date_redac'; |
|
| 318 | - if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 319 | - $champ_date_redac = $options['champ_date_redac']; |
|
| 320 | - } |
|
| 321 | - if (isset($desc['field'][$champ_date_redac]) && $v['_editer_date_anterieure']) { |
|
| 322 | - if (!_request('date_redac_jour') || _request('sans_redac')) { |
|
| 323 | - $set[$champ_date_redac] = sql_format_date(0, 0, 0, 0, 0, 0); |
|
| 324 | - } else { |
|
| 325 | - if (!$d = dater_recuperer_date_saisie(_request('date_redac_jour'), 'date_redac')) { |
|
| 326 | - $d = [date('Y'), date('m'), date('d')]; |
|
| 327 | - } |
|
| 328 | - if (!$h = dater_recuperer_heure_saisie(_request('date_redac_heure'))) { |
|
| 329 | - $h = [0, 0]; |
|
| 330 | - } |
|
| 331 | - $set[$champ_date_redac] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - if ($set !== []) { |
|
| 336 | - $publie_avant = objet_test_si_publie($objet, $id_objet); |
|
| 337 | - include_spip('action/editer_objet'); |
|
| 338 | - objet_modifier($objet, $id_objet, $set); |
|
| 339 | - $publie_apres = objet_test_si_publie($objet, $id_objet); |
|
| 340 | - if ($publie_avant !== $publie_apres) { |
|
| 341 | - // on refuse ajax pour forcer le rechargement de la page ici |
|
| 342 | - // on refera traiter une 2eme fois, mais c'est sans consequence |
|
| 343 | - refuser_traiter_formulaire_ajax(); |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - if ($retour) { |
|
| 349 | - $res['redirect'] = $retour; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - set_request('date_jour'); |
|
| 353 | - set_request('date_redac_jour'); |
|
| 354 | - set_request('date_heure'); |
|
| 355 | - set_request('date_redac_heure'); |
|
| 356 | - |
|
| 357 | - return $res; |
|
| 285 | + $res = ['editable' => ' ']; |
|
| 286 | + |
|
| 287 | + if (_request('changer')) { |
|
| 288 | + $table = table_objet($objet); |
|
| 289 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 290 | + $desc = $trouver_table($table); |
|
| 291 | + |
|
| 292 | + if (!$desc) { |
|
| 293 | + return ['message_erreur' => _L('erreur')]; |
|
| 294 | + } #impossible en principe |
|
| 295 | + |
|
| 296 | + $champ_date = $desc['date'] ?: 'date'; |
|
| 297 | + if (isset($options['champ_date']) && $options['champ_date']) { |
|
| 298 | + $champ_date = $options['champ_date']; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + $set = []; |
|
| 302 | + |
|
| 303 | + $charger = charger_fonction('charger', 'formulaires/dater/'); |
|
| 304 | + $v = $charger($objet, $id_objet, $retour, $options); |
|
| 305 | + |
|
| 306 | + if ($v['_editer_date']) { |
|
| 307 | + if (!$d = dater_recuperer_date_saisie(_request('date_jour'))) { |
|
| 308 | + $d = [date('Y'), date('m'), date('d')]; |
|
| 309 | + } |
|
| 310 | + if (!$h = dater_recuperer_heure_saisie(_request('date_heure'))) { |
|
| 311 | + $h = [0, 0]; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + $champ_date_redac = 'date_redac'; |
|
| 318 | + if (isset($options['champ_date_redac']) && $options['champ_date_redac']) { |
|
| 319 | + $champ_date_redac = $options['champ_date_redac']; |
|
| 320 | + } |
|
| 321 | + if (isset($desc['field'][$champ_date_redac]) && $v['_editer_date_anterieure']) { |
|
| 322 | + if (!_request('date_redac_jour') || _request('sans_redac')) { |
|
| 323 | + $set[$champ_date_redac] = sql_format_date(0, 0, 0, 0, 0, 0); |
|
| 324 | + } else { |
|
| 325 | + if (!$d = dater_recuperer_date_saisie(_request('date_redac_jour'), 'date_redac')) { |
|
| 326 | + $d = [date('Y'), date('m'), date('d')]; |
|
| 327 | + } |
|
| 328 | + if (!$h = dater_recuperer_heure_saisie(_request('date_redac_heure'))) { |
|
| 329 | + $h = [0, 0]; |
|
| 330 | + } |
|
| 331 | + $set[$champ_date_redac] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + if ($set !== []) { |
|
| 336 | + $publie_avant = objet_test_si_publie($objet, $id_objet); |
|
| 337 | + include_spip('action/editer_objet'); |
|
| 338 | + objet_modifier($objet, $id_objet, $set); |
|
| 339 | + $publie_apres = objet_test_si_publie($objet, $id_objet); |
|
| 340 | + if ($publie_avant !== $publie_apres) { |
|
| 341 | + // on refuse ajax pour forcer le rechargement de la page ici |
|
| 342 | + // on refera traiter une 2eme fois, mais c'est sans consequence |
|
| 343 | + refuser_traiter_formulaire_ajax(); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + if ($retour) { |
|
| 349 | + $res['redirect'] = $retour; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + set_request('date_jour'); |
|
| 353 | + set_request('date_redac_jour'); |
|
| 354 | + set_request('date_heure'); |
|
| 355 | + set_request('date_redac_heure'); |
|
| 356 | + |
|
| 357 | + return $res; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -365,24 +365,24 @@ discard block |
||
| 365 | 365 | * @return array|string Chaîne vide si date invalide, tableau (année, mois, jour) sinon. |
| 366 | 366 | */ |
| 367 | 367 | function dater_recuperer_date_saisie($post, $quoi = 'date') { |
| 368 | - if (!preg_match('#^(?:(?:(\d{1,2})[/-])?(\d{1,2})[/-])?(\d{4}|\d{1,2})#', $post, $regs)) { |
|
| 369 | - return ''; |
|
| 370 | - } |
|
| 371 | - if ($quoi == 'date_redac') { |
|
| 372 | - if ($regs[3] != '' && $regs[3] < 1001) { |
|
| 373 | - $regs[3] += 9000; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return [$regs[3], $regs[2], $regs[1]]; |
|
| 377 | - } else { |
|
| 378 | - if ( |
|
| 379 | - checkdate((int) $regs[2], (int) $regs[1], (int) $regs[3]) |
|
| 380 | - && ($t = mktime(0, 0, 0, $regs[2], $regs[1], $regs[3])) |
|
| 381 | - ) { |
|
| 382 | - return [date('Y', $t), date('m', $t), date('d', $t)]; |
|
| 383 | - } |
|
| 384 | - return ''; |
|
| 385 | - } |
|
| 368 | + if (!preg_match('#^(?:(?:(\d{1,2})[/-])?(\d{1,2})[/-])?(\d{4}|\d{1,2})#', $post, $regs)) { |
|
| 369 | + return ''; |
|
| 370 | + } |
|
| 371 | + if ($quoi == 'date_redac') { |
|
| 372 | + if ($regs[3] != '' && $regs[3] < 1001) { |
|
| 373 | + $regs[3] += 9000; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return [$regs[3], $regs[2], $regs[1]]; |
|
| 377 | + } else { |
|
| 378 | + if ( |
|
| 379 | + checkdate((int) $regs[2], (int) $regs[1], (int) $regs[3]) |
|
| 380 | + && ($t = mktime(0, 0, 0, $regs[2], $regs[1], $regs[3])) |
|
| 381 | + ) { |
|
| 382 | + return [date('Y', $t), date('m', $t), date('d', $t)]; |
|
| 383 | + } |
|
| 384 | + return ''; |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -392,12 +392,12 @@ discard block |
||
| 392 | 392 | * @return array |
| 393 | 393 | */ |
| 394 | 394 | function dater_recuperer_heure_saisie($post) { |
| 395 | - if (!preg_match('#(\d{1,2})(?:[h:](?:(\d{1,2}))?)?#', $post, $regs)) { |
|
| 396 | - return ''; |
|
| 397 | - } |
|
| 398 | - if ($regs[1] > 23 || $regs[2] > 59) { |
|
| 399 | - return ''; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - return [$regs[1], $regs[2]]; |
|
| 395 | + if (!preg_match('#(\d{1,2})(?:[h:](?:(\d{1,2}))?)?#', $post, $regs)) { |
|
| 396 | + return ''; |
|
| 397 | + } |
|
| 398 | + if ($regs[1] > 23 || $regs[2] > 59) { |
|
| 399 | + return ''; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + return [$regs[1], $regs[2]]; |
|
| 403 | 403 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | - $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . (int) $id_objet); |
|
| 98 | + $row = sql_fetsel($select, $desc['table'], "$_id_objet=".(int) $id_objet); |
|
| 99 | 99 | $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
| 100 | 100 | |
| 101 | 101 | $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | if (_request('changer')) { |
| 254 | 254 | foreach (['date', 'date_redac'] as $k) { |
| 255 | - if (($v = _request($k . '_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 255 | + if (($v = _request($k.'_jour')) && !dater_recuperer_date_saisie($v, $k)) { |
|
| 256 | 256 | $erreurs[$k] = _T('format_date_incorrecte'); |
| 257 | - } elseif (($v = _request($k . '_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 257 | + } elseif (($v = _request($k.'_heure')) && !dater_recuperer_heure_saisie($v)) { |
|
| 258 | 258 | $erreurs[$k] = _T('format_heure_incorrecte'); |
| 259 | 259 | } |
| 260 | 260 | } |