@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -45,29 +45,29 @@ discard block |
||
| 45 | 45 | * sinon code HTML de la page après le traitement effectué. |
| 46 | 46 | **/ |
| 47 | 47 | function inc_admin_dist($script, $titre, $comment = '', $anonymous = false) { |
| 48 | - $reprise = true; |
|
| 49 | - if ( |
|
| 50 | - !isset($GLOBALS['meta'][$script]) |
|
| 51 | - or !isset($GLOBALS['meta']['admin']) |
|
| 52 | - ) { |
|
| 53 | - $reprise = false; |
|
| 54 | - $res = debut_admin($script, $titre, $comment); |
|
| 55 | - if ($res) { |
|
| 56 | - return $res; |
|
| 57 | - } |
|
| 58 | - spip_log("meta: $script " . print_r($_POST, true)); |
|
| 59 | - ecrire_meta($script, serialize($_POST)); |
|
| 60 | - } |
|
| 48 | + $reprise = true; |
|
| 49 | + if ( |
|
| 50 | + !isset($GLOBALS['meta'][$script]) |
|
| 51 | + or !isset($GLOBALS['meta']['admin']) |
|
| 52 | + ) { |
|
| 53 | + $reprise = false; |
|
| 54 | + $res = debut_admin($script, $titre, $comment); |
|
| 55 | + if ($res) { |
|
| 56 | + return $res; |
|
| 57 | + } |
|
| 58 | + spip_log("meta: $script " . print_r($_POST, true)); |
|
| 59 | + ecrire_meta($script, serialize($_POST)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $res = admin_verifie_session($script, $anonymous); |
|
| 63 | - if ($res) { |
|
| 64 | - return $res; |
|
| 65 | - } |
|
| 66 | - $base = charger_fonction($script, 'base'); |
|
| 67 | - $base($titre, $reprise); |
|
| 68 | - fin_admin($script); |
|
| 62 | + $res = admin_verifie_session($script, $anonymous); |
|
| 63 | + if ($res) { |
|
| 64 | + return $res; |
|
| 65 | + } |
|
| 66 | + $base = charger_fonction($script, 'base'); |
|
| 67 | + $base($titre, $reprise); |
|
| 68 | + fin_admin($script); |
|
| 69 | 69 | |
| 70 | - return ''; |
|
| 70 | + return ''; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -98,35 +98,35 @@ discard block |
||
| 98 | 98 | * Code HTML si message d'erreur, '' sinon; |
| 99 | 99 | */ |
| 100 | 100 | function admin_verifie_session($script, $anonymous = false) { |
| 101 | - include_spip('base/abstract_sql'); |
|
| 102 | - $pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 103 | - $signal = fichier_admin($script, "$script$pref"); |
|
| 104 | - $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'"); |
|
| 105 | - if ($valeur === null) { |
|
| 106 | - ecrire_meta('admin', $signal, 'non'); |
|
| 107 | - } else { |
|
| 108 | - if (!$anonymous and ($valeur != $signal)) { |
|
| 109 | - if ( |
|
| 110 | - !preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l) |
|
| 111 | - or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur'] |
|
| 112 | - ) { |
|
| 113 | - include_spip('inc/minipres'); |
|
| 114 | - spip_log("refus de lancer $script, priorite a $valeur"); |
|
| 101 | + include_spip('base/abstract_sql'); |
|
| 102 | + $pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 103 | + $signal = fichier_admin($script, "$script$pref"); |
|
| 104 | + $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'"); |
|
| 105 | + if ($valeur === null) { |
|
| 106 | + ecrire_meta('admin', $signal, 'non'); |
|
| 107 | + } else { |
|
| 108 | + if (!$anonymous and ($valeur != $signal)) { |
|
| 109 | + if ( |
|
| 110 | + !preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l) |
|
| 111 | + or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur'] |
|
| 112 | + ) { |
|
| 113 | + include_spip('inc/minipres'); |
|
| 114 | + spip_log("refus de lancer $script, priorite a $valeur"); |
|
| 115 | 115 | |
| 116 | - return minipres(_T('info_travaux_texte'), '', ['status' => 503]); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - $journal = 'spip'; |
|
| 121 | - if (autoriser('configurer')) { |
|
| 122 | - // c'est une action webmestre, soit par ftp soit par statut webmestre |
|
| 123 | - $journal = 'webmestre'; |
|
| 124 | - } |
|
| 125 | - // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ? |
|
| 116 | + return minipres(_T('info_travaux_texte'), '', ['status' => 503]); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + $journal = 'spip'; |
|
| 121 | + if (autoriser('configurer')) { |
|
| 122 | + // c'est une action webmestre, soit par ftp soit par statut webmestre |
|
| 123 | + $journal = 'webmestre'; |
|
| 124 | + } |
|
| 125 | + // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ? |
|
| 126 | 126 | |
| 127 | - spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal); |
|
| 127 | + spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal); |
|
| 128 | 128 | |
| 129 | - return ''; |
|
| 129 | + return ''; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | * Chemin du répertoire. |
| 140 | 140 | **/ |
| 141 | 141 | function dir_admin() { |
| 142 | - if (autoriser('configurer')) { |
|
| 143 | - return _DIR_TMP; |
|
| 144 | - } else { |
|
| 145 | - return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/'; |
|
| 146 | - } |
|
| 142 | + if (autoriser('configurer')) { |
|
| 143 | + return _DIR_TMP; |
|
| 144 | + } else { |
|
| 145 | + return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/'; |
|
| 146 | + } |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * Nom du fichier |
| 161 | 161 | **/ |
| 162 | 162 | function fichier_admin($action, $pref = 'admin_') { |
| 163 | - return $pref . |
|
| 164 | - substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10); |
|
| 163 | + return $pref . |
|
| 164 | + substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -187,73 +187,73 @@ discard block |
||
| 187 | 187 | * sinon chaîne vide si déjà fait. |
| 188 | 188 | **/ |
| 189 | 189 | function debut_admin($script, $action = '', $corps = '') { |
| 190 | - if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) { |
|
| 191 | - include_spip('inc/minipres'); |
|
| 190 | + if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) { |
|
| 191 | + include_spip('inc/minipres'); |
|
| 192 | 192 | |
| 193 | - return minipres(); |
|
| 194 | - } else { |
|
| 195 | - $dir = dir_admin(); |
|
| 196 | - $signal = fichier_admin($script); |
|
| 197 | - if (@file_exists($dir . $signal)) { |
|
| 198 | - spip_log("Action admin: $action"); |
|
| 193 | + return minipres(); |
|
| 194 | + } else { |
|
| 195 | + $dir = dir_admin(); |
|
| 196 | + $signal = fichier_admin($script); |
|
| 197 | + if (@file_exists($dir . $signal)) { |
|
| 198 | + spip_log("Action admin: $action"); |
|
| 199 | 199 | |
| 200 | - return ''; |
|
| 201 | - } |
|
| 202 | - include_spip('inc/minipres'); |
|
| 200 | + return ''; |
|
| 201 | + } |
|
| 202 | + include_spip('inc/minipres'); |
|
| 203 | 203 | |
| 204 | - // Si on est un super-admin, un bouton de validation suffit |
|
| 205 | - // sauf dans les cas destroy |
|
| 206 | - if ( |
|
| 207 | - (autoriser('webmestre') or $script === 'repair') |
|
| 208 | - and $script != 'delete_all' |
|
| 209 | - ) { |
|
| 210 | - if (_request('validation_admin') == $signal) { |
|
| 211 | - spip_log("Action super-admin: $action"); |
|
| 204 | + // Si on est un super-admin, un bouton de validation suffit |
|
| 205 | + // sauf dans les cas destroy |
|
| 206 | + if ( |
|
| 207 | + (autoriser('webmestre') or $script === 'repair') |
|
| 208 | + and $script != 'delete_all' |
|
| 209 | + ) { |
|
| 210 | + if (_request('validation_admin') == $signal) { |
|
| 211 | + spip_log("Action super-admin: $action"); |
|
| 212 | 212 | |
| 213 | - return ''; |
|
| 214 | - } |
|
| 215 | - $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />'; |
|
| 216 | - $suivant = _T('bouton_valider'); |
|
| 217 | - $js = ''; |
|
| 218 | - } else { |
|
| 219 | - // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj) |
|
| 220 | - // l'insertion du script a cet endroit n'est pas xhtml licite |
|
| 221 | - // mais evite de l'embarquer dans toutes les pages minipres |
|
| 222 | - $corps .= http_script('', 'spip_barre.js'); |
|
| 213 | + return ''; |
|
| 214 | + } |
|
| 215 | + $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />'; |
|
| 216 | + $suivant = _T('bouton_valider'); |
|
| 217 | + $js = ''; |
|
| 218 | + } else { |
|
| 219 | + // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj) |
|
| 220 | + // l'insertion du script a cet endroit n'est pas xhtml licite |
|
| 221 | + // mais evite de l'embarquer dans toutes les pages minipres |
|
| 222 | + $corps .= http_script('', 'spip_barre.js'); |
|
| 223 | 223 | |
| 224 | - $corps .= '<fieldset><legend>' |
|
| 225 | - . _T('info_authentification_ftp') |
|
| 226 | - . aider('ftp_auth') |
|
| 227 | - . "</legend>\n<label for='fichier'>" |
|
| 228 | - . _T('info_creer_repertoire') |
|
| 229 | - . "</label>\n" |
|
| 230 | - . "<span id='signal' class='formo'>" . $signal . '</span>' |
|
| 231 | - . "<input type='hidden' id='fichier' name='fichier' value='" |
|
| 232 | - . $signal |
|
| 233 | - . "' />" |
|
| 234 | - . _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)]) |
|
| 235 | - . '</fieldset>'; |
|
| 224 | + $corps .= '<fieldset><legend>' |
|
| 225 | + . _T('info_authentification_ftp') |
|
| 226 | + . aider('ftp_auth') |
|
| 227 | + . "</legend>\n<label for='fichier'>" |
|
| 228 | + . _T('info_creer_repertoire') |
|
| 229 | + . "</label>\n" |
|
| 230 | + . "<span id='signal' class='formo'>" . $signal . '</span>' |
|
| 231 | + . "<input type='hidden' id='fichier' name='fichier' value='" |
|
| 232 | + . $signal |
|
| 233 | + . "' />" |
|
| 234 | + . _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)]) |
|
| 235 | + . '</fieldset>'; |
|
| 236 | 236 | |
| 237 | - $suivant = _T('bouton_recharger_page'); |
|
| 237 | + $suivant = _T('bouton_recharger_page'); |
|
| 238 | 238 | |
| 239 | - // code volontairement tordu: |
|
| 240 | - // provoquer la copie dans le presse papier du nom du repertoire |
|
| 241 | - // en remettant a vide le champ pour que ca marche aussi en cas |
|
| 242 | - // de JavaScript inactif. |
|
| 243 | - $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'"; |
|
| 244 | - } |
|
| 239 | + // code volontairement tordu: |
|
| 240 | + // provoquer la copie dans le presse papier du nom du repertoire |
|
| 241 | + // en remettant a vide le champ pour que ca marche aussi en cas |
|
| 242 | + // de JavaScript inactif. |
|
| 243 | + $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'"; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - // admin/xxx correspond |
|
| 247 | - // a exec/base_xxx de preference |
|
| 248 | - // et exec/xxx sinon (compat) |
|
| 249 | - if (tester_url_ecrire("base_$script")) { |
|
| 250 | - $script = "base_$script"; |
|
| 251 | - } |
|
| 252 | - $form = copy_request($script, $corps, $suivant); |
|
| 253 | - $info_action = _T('info_action', ['action' => "$action"]); |
|
| 246 | + // admin/xxx correspond |
|
| 247 | + // a exec/base_xxx de preference |
|
| 248 | + // et exec/xxx sinon (compat) |
|
| 249 | + if (tester_url_ecrire("base_$script")) { |
|
| 250 | + $script = "base_$script"; |
|
| 251 | + } |
|
| 252 | + $form = copy_request($script, $corps, $suivant); |
|
| 253 | + $info_action = _T('info_action', ['action' => "$action"]); |
|
| 254 | 254 | |
| 255 | - return minipres($info_action, $form, $js); |
|
| 256 | - } |
|
| 255 | + return minipres($info_action, $form, $js); |
|
| 256 | + } |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -264,13 +264,13 @@ discard block |
||
| 264 | 264 | * Nom de l'action (en base) qui a été exécutée |
| 265 | 265 | **/ |
| 266 | 266 | function fin_admin($action) { |
| 267 | - $signal = dir_admin() . fichier_admin($action); |
|
| 268 | - spip_unlink($signal); |
|
| 269 | - if ($action != 'delete_all') { |
|
| 270 | - effacer_meta($action); |
|
| 271 | - effacer_meta('admin'); |
|
| 272 | - spip_log("efface les meta admin et $action "); |
|
| 273 | - } |
|
| 267 | + $signal = dir_admin() . fichier_admin($action); |
|
| 268 | + spip_unlink($signal); |
|
| 269 | + if ($action != 'delete_all') { |
|
| 270 | + effacer_meta($action); |
|
| 271 | + effacer_meta('admin'); |
|
| 272 | + spip_log("efface les meta admin et $action "); |
|
| 273 | + } |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -289,14 +289,14 @@ discard block |
||
| 289 | 289 | * Code HTML du formulaire |
| 290 | 290 | **/ |
| 291 | 291 | function copy_request($script, $suite, $submit = '') { |
| 292 | - include_spip('inc/filtres'); |
|
| 293 | - foreach (array_merge($_POST, $_GET) as $n => $c) { |
|
| 294 | - if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) { |
|
| 295 | - $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" . |
|
| 296 | - entites_html($c) . |
|
| 297 | - "' />"; |
|
| 298 | - } |
|
| 299 | - } |
|
| 292 | + include_spip('inc/filtres'); |
|
| 293 | + foreach (array_merge($_POST, $_GET) as $n => $c) { |
|
| 294 | + if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) { |
|
| 295 | + $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" . |
|
| 296 | + entites_html($c) . |
|
| 297 | + "' />"; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - return generer_form_ecrire($script, $suite, '', $submit); |
|
| 301 | + return generer_form_ecrire($script, $suite, '', $submit); |
|
| 302 | 302 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if ($res) { |
| 56 | 56 | return $res; |
| 57 | 57 | } |
| 58 | - spip_log("meta: $script " . print_r($_POST, true)); |
|
| 58 | + spip_log("meta: $script ".print_r($_POST, true)); |
|
| 59 | 59 | ecrire_meta($script, serialize($_POST)); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ? |
| 126 | 126 | |
| 127 | - spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal); |
|
| 127 | + spip_log("admin $pref".($valeur ? ' (reprise)' : ' (init)'), $journal); |
|
| 128 | 128 | |
| 129 | 129 | return ''; |
| 130 | 130 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | if (autoriser('configurer')) { |
| 143 | 143 | return _DIR_TMP; |
| 144 | 144 | } else { |
| 145 | - return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/'; |
|
| 145 | + return _DIR_TRANSFERT.$GLOBALS['visiteur_session']['login'].'/'; |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * Nom du fichier |
| 161 | 161 | **/ |
| 162 | 162 | function fichier_admin($action, $pref = 'admin_') { |
| 163 | - return $pref . |
|
| 164 | - substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10); |
|
| 163 | + return $pref. |
|
| 164 | + substr(md5($action.(time() & ~2047).$GLOBALS['visiteur_session']['login']), 0, 10); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } else { |
| 195 | 195 | $dir = dir_admin(); |
| 196 | 196 | $signal = fichier_admin($script); |
| 197 | - if (@file_exists($dir . $signal)) { |
|
| 197 | + if (@file_exists($dir.$signal)) { |
|
| 198 | 198 | spip_log("Action admin: $action"); |
| 199 | 199 | |
| 200 | 200 | return ''; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | return ''; |
| 214 | 214 | } |
| 215 | - $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />'; |
|
| 215 | + $corps .= '<input type="hidden" name="validation_admin" value="'.$signal.'" />'; |
|
| 216 | 216 | $suivant = _T('bouton_valider'); |
| 217 | 217 | $js = ''; |
| 218 | 218 | } else { |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | . "</legend>\n<label for='fichier'>" |
| 228 | 228 | . _T('info_creer_repertoire') |
| 229 | 229 | . "</label>\n" |
| 230 | - . "<span id='signal' class='formo'>" . $signal . '</span>' |
|
| 230 | + . "<span id='signal' class='formo'>".$signal.'</span>' |
|
| 231 | 231 | . "<input type='hidden' id='fichier' name='fichier' value='" |
| 232 | 232 | . $signal |
| 233 | 233 | . "' />" |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * Nom de l'action (en base) qui a été exécutée |
| 265 | 265 | **/ |
| 266 | 266 | function fin_admin($action) { |
| 267 | - $signal = dir_admin() . fichier_admin($action); |
|
| 267 | + $signal = dir_admin().fichier_admin($action); |
|
| 268 | 268 | spip_unlink($signal); |
| 269 | 269 | if ($action != 'delete_all') { |
| 270 | 270 | effacer_meta($action); |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | include_spip('inc/filtres'); |
| 293 | 293 | foreach (array_merge($_POST, $_GET) as $n => $c) { |
| 294 | 294 | if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) { |
| 295 | - $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" . |
|
| 296 | - entites_html($c) . |
|
| 295 | + $suite .= "\n<input type='hidden' name='".spip_htmlspecialchars($n)."' value='". |
|
| 296 | + entites_html($c). |
|
| 297 | 297 | "' />"; |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $contenu = @gzfile($fichier); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return is_array($contenu) ? join('', $contenu) : (string)$contenu; |
|
| 125 | + return is_array($contenu) ? join('', $contenu) : (string) $contenu; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | function ecrire_fichier_securise($fichier, $contenu, $ecrire_quand_meme = false, $truncate = true) { |
| 317 | 317 | if (substr($fichier, -4) !== '.php') { |
| 318 | - spip_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 318 | + spip_log('Erreur de programmation: '.$fichier.' doit finir par .php'); |
|
| 319 | 319 | } |
| 320 | - $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 320 | + $contenu = '<'."?php die ('Acces interdit'); ?".">\n".$contenu; |
|
| 321 | 321 | |
| 322 | 322 | return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
| 323 | 323 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @return bool |
| 331 | 331 | */ |
| 332 | 332 | function ecrire_fichier_calcule_si_modifie($fichier, $contenu, $force = false, $use_copy = false) { |
| 333 | - $fichier_tmp = $fichier . '.last'; |
|
| 333 | + $fichier_tmp = $fichier.'.last'; |
|
| 334 | 334 | if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
| 335 | 335 | return false; |
| 336 | 336 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | function lire_fichier_securise($fichier, &$contenu, $options = []) { |
| 372 | 372 | if ($res = lire_fichier($fichier, $contenu, $options)) { |
| 373 | - $contenu = substr($contenu, strlen('<' . "?php die ('Acces interdit'); ?" . ">\n")); |
|
| 373 | + $contenu = substr($contenu, strlen('<'."?php die ('Acces interdit'); ?".">\n")); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | return $res; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $wait = 0; |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | - spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 543 | + spip_log('Probleme de configuration opcache.revalidate_freq '.$duree.'s : on attend '.$wait.'s', _LOG_INFO_IMPORTANTE); |
|
| 544 | 544 | if ($wait) { |
| 545 | 545 | sleep($duree + 1); |
| 546 | 546 | } |
@@ -568,9 +568,9 @@ discard block |
||
| 568 | 568 | if ($item == '.' || $item == '..') { |
| 569 | 569 | continue; |
| 570 | 570 | } |
| 571 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 572 | - @chmod($dir . '/' . $item, 0777); |
|
| 573 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 571 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 572 | + @chmod($dir.'/'.$item, 0777); |
|
| 573 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 574 | 574 | return false; |
| 575 | 575 | } |
| 576 | 576 | }; |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | if (!strlen($subdir)) { |
| 616 | 616 | $n = strrpos($base, '/'); |
| 617 | 617 | if ($n === false) { |
| 618 | - return $nobase ? '' : ($base . '/'); |
|
| 618 | + return $nobase ? '' : ($base.'/'); |
|
| 619 | 619 | } |
| 620 | 620 | $subdir = substr($base, $n + 1); |
| 621 | 621 | $base = substr($base, 0, $n + 1); |
@@ -625,14 +625,14 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | $baseaff = $nobase ? '' : $base; |
| 628 | - if (isset($dirs[$base . $subdir])) { |
|
| 629 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 628 | + if (isset($dirs[$base.$subdir])) { |
|
| 629 | + return $baseaff.$dirs[$base.$subdir]; |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 632 | + $path = $base.$subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 633 | 633 | |
| 634 | 634 | if (file_exists("$path/.ok")) { |
| 635 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 635 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | @mkdir($path, _SPIP_CHMOD); |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | @touch("$path/.ok"); |
| 643 | 643 | spip_log("creation $base$subdir/"); |
| 644 | 644 | |
| 645 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 645 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
@@ -652,10 +652,10 @@ discard block |
||
| 652 | 652 | return ''; |
| 653 | 653 | } |
| 654 | 654 | if (!_DIR_RESTREINT) { |
| 655 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 655 | + $base = preg_replace(',^'._DIR_RACINE.',', '', $base); |
|
| 656 | 656 | } |
| 657 | 657 | $base .= $subdir; |
| 658 | - raler_fichier($base . '/.ok'); |
|
| 658 | + raler_fichier($base.'/.ok'); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | $maxfiles - $nbfiles, |
| 729 | 729 | $recurs |
| 730 | 730 | ); |
| 731 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 731 | + $fichiers = array_merge((array) $beginning, (array) $end); |
|
| 732 | 732 | $nbfiles = count($fichiers); |
| 733 | 733 | } |
| 734 | 734 | } |
@@ -341,8 +341,7 @@ |
||
| 341 | 341 | ) { |
| 342 | 342 | if ($use_copy) { |
| 343 | 343 | @copy($fichier_tmp, $fichier); |
| 344 | - } |
|
| 345 | - else { |
|
| 344 | + } else { |
|
| 346 | 345 | @rename($fichier_tmp, $fichier); |
| 347 | 346 | } |
| 348 | 347 | // eviter que PHP ne reserve le vieux timestamp |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_TEST_FILE_EXISTS')) { |
| 24 | - /** Permettre d'éviter des tests file_exists sur certains hébergeurs */ |
|
| 25 | - define('_TEST_FILE_EXISTS', preg_match(',(online|free)[.]fr$,', $_ENV['HTTP_HOST'] ?? '')); |
|
| 24 | + /** Permettre d'éviter des tests file_exists sur certains hébergeurs */ |
|
| 25 | + define('_TEST_FILE_EXISTS', preg_match(',(online|free)[.]fr$,', $_ENV['HTTP_HOST'] ?? '')); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #define('_SPIP_LOCK_MODE',0); // ne pas utiliser de lock (deconseille) |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | #define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip |
| 31 | 31 | |
| 32 | 32 | if (_SPIP_LOCK_MODE == 2) { |
| 33 | - include_spip('inc/nfslock'); |
|
| 33 | + include_spip('inc/nfslock'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $GLOBALS['liste_verrous'] = []; |
@@ -53,24 +53,24 @@ discard block |
||
| 53 | 53 | * Ressource sur le fichier ouvert, sinon false. |
| 54 | 54 | **/ |
| 55 | 55 | function spip_fopen_lock($fichier, $mode, $verrou) { |
| 56 | - if (_SPIP_LOCK_MODE == 1) { |
|
| 57 | - if ($fl = @fopen($fichier, $mode)) { |
|
| 58 | - // verrou |
|
| 59 | - @flock($fl, $verrou); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - return $fl; |
|
| 63 | - } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 64 | - if (($verrou = spip_nfslock($fichier)) && ($fl = @fopen($fichier, $mode))) { |
|
| 65 | - $GLOBALS['liste_verrous'][$fl] = [$fichier, $verrou]; |
|
| 66 | - |
|
| 67 | - return $fl; |
|
| 68 | - } else { |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return @fopen($fichier, $mode); |
|
| 56 | + if (_SPIP_LOCK_MODE == 1) { |
|
| 57 | + if ($fl = @fopen($fichier, $mode)) { |
|
| 58 | + // verrou |
|
| 59 | + @flock($fl, $verrou); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + return $fl; |
|
| 63 | + } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 64 | + if (($verrou = spip_nfslock($fichier)) && ($fl = @fopen($fichier, $mode))) { |
|
| 65 | + $GLOBALS['liste_verrous'][$fl] = [$fichier, $verrou]; |
|
| 66 | + |
|
| 67 | + return $fl; |
|
| 68 | + } else { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return @fopen($fichier, $mode); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | * true si succès, false sinon. |
| 86 | 86 | **/ |
| 87 | 87 | function spip_fclose_unlock($handle) { |
| 88 | - if (_SPIP_LOCK_MODE == 1) { |
|
| 89 | - @flock($handle, LOCK_UN); |
|
| 90 | - } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 91 | - spip_nfsunlock(reset($GLOBALS['liste_verrous'][$handle]), end($GLOBALS['liste_verrous'][$handle])); |
|
| 92 | - unset($GLOBALS['liste_verrous'][$handle]); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - return @fclose($handle); |
|
| 88 | + if (_SPIP_LOCK_MODE == 1) { |
|
| 89 | + @flock($handle, LOCK_UN); |
|
| 90 | + } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 91 | + spip_nfsunlock(reset($GLOBALS['liste_verrous'][$handle]), end($GLOBALS['liste_verrous'][$handle])); |
|
| 92 | + unset($GLOBALS['liste_verrous'][$handle]); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + return @fclose($handle); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
@@ -106,23 +106,23 @@ discard block |
||
| 106 | 106 | * Contenu du fichier |
| 107 | 107 | **/ |
| 108 | 108 | function spip_file_get_contents($fichier) { |
| 109 | - if (substr($fichier, -3) != '.gz') { |
|
| 110 | - if (function_exists('file_get_contents')) { |
|
| 111 | - // quand on est sous windows on ne sait pas si file_get_contents marche |
|
| 112 | - // on essaye : si ca retourne du contenu alors c'est bon |
|
| 113 | - // sinon on fait un file() pour avoir le coeur net |
|
| 114 | - $contenu = @file_get_contents($fichier); |
|
| 115 | - if (!$contenu and _OS_SERVEUR == 'windows') { |
|
| 116 | - $contenu = @file($fichier); |
|
| 117 | - } |
|
| 118 | - } else { |
|
| 119 | - $contenu = @file($fichier); |
|
| 120 | - } |
|
| 121 | - } else { |
|
| 122 | - $contenu = @gzfile($fichier); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return is_array($contenu) ? join('', $contenu) : (string)$contenu; |
|
| 109 | + if (substr($fichier, -3) != '.gz') { |
|
| 110 | + if (function_exists('file_get_contents')) { |
|
| 111 | + // quand on est sous windows on ne sait pas si file_get_contents marche |
|
| 112 | + // on essaye : si ca retourne du contenu alors c'est bon |
|
| 113 | + // sinon on fait un file() pour avoir le coeur net |
|
| 114 | + $contenu = @file_get_contents($fichier); |
|
| 115 | + if (!$contenu and _OS_SERVEUR == 'windows') { |
|
| 116 | + $contenu = @file($fichier); |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + $contenu = @file($fichier); |
|
| 120 | + } |
|
| 121 | + } else { |
|
| 122 | + $contenu = @gzfile($fichier); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return is_array($contenu) ? join('', $contenu) : (string)$contenu; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -147,48 +147,48 @@ discard block |
||
| 147 | 147 | * true si l'opération a réussie, false sinon. |
| 148 | 148 | **/ |
| 149 | 149 | function lire_fichier($fichier, &$contenu, $options = []) { |
| 150 | - $contenu = ''; |
|
| 151 | - // inutile car si le fichier n'existe pas, le lock va renvoyer false juste apres |
|
| 152 | - // economisons donc les acces disque, sauf chez free qui rale pour un rien |
|
| 153 | - if (_TEST_FILE_EXISTS and !@file_exists($fichier)) { |
|
| 154 | - return false; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - #spip_timer('lire_fichier'); |
|
| 158 | - |
|
| 159 | - // pas de @ sur spip_fopen_lock qui est silencieux de toute facon |
|
| 160 | - if ($fl = spip_fopen_lock($fichier, 'r', LOCK_SH)) { |
|
| 161 | - // lire le fichier avant tout |
|
| 162 | - $contenu = spip_file_get_contents($fichier); |
|
| 163 | - |
|
| 164 | - // le fichier a-t-il ete supprime par le locker ? |
|
| 165 | - // on ne verifie que si la tentative de lecture a echoue |
|
| 166 | - // pour discriminer un contenu vide d'un fichier absent |
|
| 167 | - // et eviter un acces disque |
|
| 168 | - if (!$contenu and !@file_exists($fichier)) { |
|
| 169 | - spip_fclose_unlock($fl); |
|
| 170 | - |
|
| 171 | - return false; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // liberer le verrou |
|
| 175 | - spip_fclose_unlock($fl); |
|
| 176 | - |
|
| 177 | - // Verifications |
|
| 178 | - $ok = true; |
|
| 179 | - if (isset($options['phpcheck']) and $options['phpcheck'] == 'oui') { |
|
| 180 | - $ok &= (preg_match(",[?]>\n?$,", $contenu)); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - #spip_log("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 184 | - if (!$ok) { |
|
| 185 | - spip_log("echec lecture $fichier"); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return $ok; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return false; |
|
| 150 | + $contenu = ''; |
|
| 151 | + // inutile car si le fichier n'existe pas, le lock va renvoyer false juste apres |
|
| 152 | + // economisons donc les acces disque, sauf chez free qui rale pour un rien |
|
| 153 | + if (_TEST_FILE_EXISTS and !@file_exists($fichier)) { |
|
| 154 | + return false; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + #spip_timer('lire_fichier'); |
|
| 158 | + |
|
| 159 | + // pas de @ sur spip_fopen_lock qui est silencieux de toute facon |
|
| 160 | + if ($fl = spip_fopen_lock($fichier, 'r', LOCK_SH)) { |
|
| 161 | + // lire le fichier avant tout |
|
| 162 | + $contenu = spip_file_get_contents($fichier); |
|
| 163 | + |
|
| 164 | + // le fichier a-t-il ete supprime par le locker ? |
|
| 165 | + // on ne verifie que si la tentative de lecture a echoue |
|
| 166 | + // pour discriminer un contenu vide d'un fichier absent |
|
| 167 | + // et eviter un acces disque |
|
| 168 | + if (!$contenu and !@file_exists($fichier)) { |
|
| 169 | + spip_fclose_unlock($fl); |
|
| 170 | + |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // liberer le verrou |
|
| 175 | + spip_fclose_unlock($fl); |
|
| 176 | + |
|
| 177 | + // Verifications |
|
| 178 | + $ok = true; |
|
| 179 | + if (isset($options['phpcheck']) and $options['phpcheck'] == 'oui') { |
|
| 180 | + $ok &= (preg_match(",[?]>\n?$,", $contenu)); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + #spip_log("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 184 | + if (!$ok) { |
|
| 185 | + spip_log("echec lecture $fichier"); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return $ok; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return false; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
@@ -216,85 +216,85 @@ discard block |
||
| 216 | 216 | **/ |
| 217 | 217 | function ecrire_fichier($fichier, $contenu, $ignorer_echec = false, $truncate = true) { |
| 218 | 218 | |
| 219 | - #spip_timer('ecrire_fichier'); |
|
| 220 | - |
|
| 221 | - // verrouiller le fichier destination |
|
| 222 | - if ($fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 223 | - // ecrire les donnees, compressees le cas echeant |
|
| 224 | - // (on ouvre un nouveau pointeur sur le fichier, ce qui a l'avantage |
|
| 225 | - // de le recreer si le locker qui nous precede l'avait supprime...) |
|
| 226 | - if (substr($fichier, -3) == '.gz') { |
|
| 227 | - $contenu = gzencode($contenu); |
|
| 228 | - } |
|
| 229 | - // si c'est une ecriture avec troncation , on fait plutot une ecriture complete a cote suivie unlink+rename |
|
| 230 | - // pour etre sur d'avoir une operation atomique |
|
| 231 | - // y compris en NFS : http://www.ietf.org/rfc/rfc1094.txt |
|
| 232 | - // sauf sous wintruc ou ca ne marche pas |
|
| 233 | - $ok = false; |
|
| 234 | - if ($truncate and _OS_SERVEUR != 'windows') { |
|
| 235 | - if (!function_exists('creer_uniqid')) { |
|
| 236 | - include_spip('inc/acces'); |
|
| 237 | - } |
|
| 238 | - $id = creer_uniqid(); |
|
| 239 | - // on ouvre un pointeur sur un fichier temporaire en ecriture +raz |
|
| 240 | - if ($fp2 = spip_fopen_lock("$fichier.$id", 'w', LOCK_EX)) { |
|
| 241 | - $s = @fputs($fp2, $contenu, $a = strlen($contenu)); |
|
| 242 | - $ok = ($s == $a); |
|
| 243 | - spip_fclose_unlock($fp2); |
|
| 244 | - spip_fclose_unlock($fp); |
|
| 245 | - // unlink direct et pas spip_unlink car on avait deja le verrou |
|
| 246 | - // a priori pas besoin car rename ecrase la cible |
|
| 247 | - // @unlink($fichier); |
|
| 248 | - // le rename aussitot, atomique quand on est pas sous windows |
|
| 249 | - // au pire on arrive en second en cas de concourance, et le rename echoue |
|
| 250 | - // --> on a la version de l'autre process qui doit etre identique |
|
| 251 | - @rename("$fichier.$id", $fichier); |
|
| 252 | - // precaution en cas d'echec du rename |
|
| 253 | - if (!_TEST_FILE_EXISTS or @file_exists("$fichier.$id")) { |
|
| 254 | - @unlink("$fichier.$id"); |
|
| 255 | - } |
|
| 256 | - if ($ok) { |
|
| 257 | - $ok = file_exists($fichier); |
|
| 258 | - } |
|
| 259 | - } else // echec mais penser a fermer .. |
|
| 260 | - { |
|
| 261 | - spip_fclose_unlock($fp); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - // sinon ou si methode precedente a echoueee |
|
| 265 | - // on se rabat sur la methode ancienne |
|
| 266 | - if (!$ok) { |
|
| 267 | - // ici on est en ajout ou sous windows, cas desespere |
|
| 268 | - if ($truncate) { |
|
| 269 | - @ftruncate($fp, 0); |
|
| 270 | - } |
|
| 271 | - $s = @fputs($fp, $contenu, $a = strlen($contenu)); |
|
| 272 | - |
|
| 273 | - $ok = ($s == $a); |
|
| 274 | - spip_fclose_unlock($fp); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - // liberer le verrou et fermer le fichier |
|
| 278 | - @chmod($fichier, _SPIP_CHMOD & 0666); |
|
| 279 | - if ($ok) { |
|
| 280 | - if (strpos($fichier, '.php') !== false) { |
|
| 281 | - spip_clear_opcode_cache(realpath($fichier)); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - return $ok; |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if (!$ignorer_echec) { |
|
| 289 | - include_spip('inc/autoriser'); |
|
| 290 | - if (autoriser('chargerftp')) { |
|
| 291 | - raler_fichier($fichier); |
|
| 292 | - } |
|
| 293 | - spip_unlink($fichier); |
|
| 294 | - } |
|
| 295 | - spip_log("Ecriture fichier $fichier impossible", _LOG_INFO_IMPORTANTE); |
|
| 296 | - |
|
| 297 | - return false; |
|
| 219 | + #spip_timer('ecrire_fichier'); |
|
| 220 | + |
|
| 221 | + // verrouiller le fichier destination |
|
| 222 | + if ($fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 223 | + // ecrire les donnees, compressees le cas echeant |
|
| 224 | + // (on ouvre un nouveau pointeur sur le fichier, ce qui a l'avantage |
|
| 225 | + // de le recreer si le locker qui nous precede l'avait supprime...) |
|
| 226 | + if (substr($fichier, -3) == '.gz') { |
|
| 227 | + $contenu = gzencode($contenu); |
|
| 228 | + } |
|
| 229 | + // si c'est une ecriture avec troncation , on fait plutot une ecriture complete a cote suivie unlink+rename |
|
| 230 | + // pour etre sur d'avoir une operation atomique |
|
| 231 | + // y compris en NFS : http://www.ietf.org/rfc/rfc1094.txt |
|
| 232 | + // sauf sous wintruc ou ca ne marche pas |
|
| 233 | + $ok = false; |
|
| 234 | + if ($truncate and _OS_SERVEUR != 'windows') { |
|
| 235 | + if (!function_exists('creer_uniqid')) { |
|
| 236 | + include_spip('inc/acces'); |
|
| 237 | + } |
|
| 238 | + $id = creer_uniqid(); |
|
| 239 | + // on ouvre un pointeur sur un fichier temporaire en ecriture +raz |
|
| 240 | + if ($fp2 = spip_fopen_lock("$fichier.$id", 'w', LOCK_EX)) { |
|
| 241 | + $s = @fputs($fp2, $contenu, $a = strlen($contenu)); |
|
| 242 | + $ok = ($s == $a); |
|
| 243 | + spip_fclose_unlock($fp2); |
|
| 244 | + spip_fclose_unlock($fp); |
|
| 245 | + // unlink direct et pas spip_unlink car on avait deja le verrou |
|
| 246 | + // a priori pas besoin car rename ecrase la cible |
|
| 247 | + // @unlink($fichier); |
|
| 248 | + // le rename aussitot, atomique quand on est pas sous windows |
|
| 249 | + // au pire on arrive en second en cas de concourance, et le rename echoue |
|
| 250 | + // --> on a la version de l'autre process qui doit etre identique |
|
| 251 | + @rename("$fichier.$id", $fichier); |
|
| 252 | + // precaution en cas d'echec du rename |
|
| 253 | + if (!_TEST_FILE_EXISTS or @file_exists("$fichier.$id")) { |
|
| 254 | + @unlink("$fichier.$id"); |
|
| 255 | + } |
|
| 256 | + if ($ok) { |
|
| 257 | + $ok = file_exists($fichier); |
|
| 258 | + } |
|
| 259 | + } else // echec mais penser a fermer .. |
|
| 260 | + { |
|
| 261 | + spip_fclose_unlock($fp); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + // sinon ou si methode precedente a echoueee |
|
| 265 | + // on se rabat sur la methode ancienne |
|
| 266 | + if (!$ok) { |
|
| 267 | + // ici on est en ajout ou sous windows, cas desespere |
|
| 268 | + if ($truncate) { |
|
| 269 | + @ftruncate($fp, 0); |
|
| 270 | + } |
|
| 271 | + $s = @fputs($fp, $contenu, $a = strlen($contenu)); |
|
| 272 | + |
|
| 273 | + $ok = ($s == $a); |
|
| 274 | + spip_fclose_unlock($fp); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + // liberer le verrou et fermer le fichier |
|
| 278 | + @chmod($fichier, _SPIP_CHMOD & 0666); |
|
| 279 | + if ($ok) { |
|
| 280 | + if (strpos($fichier, '.php') !== false) { |
|
| 281 | + spip_clear_opcode_cache(realpath($fichier)); |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + return $ok; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + if (!$ignorer_echec) { |
|
| 289 | + include_spip('inc/autoriser'); |
|
| 290 | + if (autoriser('chargerftp')) { |
|
| 291 | + raler_fichier($fichier); |
|
| 292 | + } |
|
| 293 | + spip_unlink($fichier); |
|
| 294 | + } |
|
| 295 | + spip_log("Ecriture fichier $fichier impossible", _LOG_INFO_IMPORTANTE); |
|
| 296 | + |
|
| 297 | + return false; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | * Écriture avec troncation ? |
| 315 | 315 | */ |
| 316 | 316 | function ecrire_fichier_securise($fichier, $contenu, $ecrire_quand_meme = false, $truncate = true) { |
| 317 | - if (substr($fichier, -4) !== '.php') { |
|
| 318 | - spip_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 319 | - } |
|
| 320 | - $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 317 | + if (substr($fichier, -4) !== '.php') { |
|
| 318 | + spip_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 319 | + } |
|
| 320 | + $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 321 | 321 | |
| 322 | - return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
|
| 322 | + return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | * @return bool |
| 331 | 331 | */ |
| 332 | 332 | function ecrire_fichier_calcule_si_modifie($fichier, $contenu, $force = false, $use_copy = false) { |
| 333 | - $fichier_tmp = $fichier . '.last'; |
|
| 334 | - if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
|
| 335 | - return false; |
|
| 336 | - } |
|
| 337 | - if ( |
|
| 338 | - $force |
|
| 339 | - or !file_exists($fichier) |
|
| 340 | - or md5_file($fichier) != md5_file($fichier_tmp) |
|
| 341 | - ) { |
|
| 342 | - if ($use_copy) { |
|
| 343 | - @copy($fichier_tmp, $fichier); |
|
| 344 | - } |
|
| 345 | - else { |
|
| 346 | - @rename($fichier_tmp, $fichier); |
|
| 347 | - } |
|
| 348 | - // eviter que PHP ne reserve le vieux timestamp |
|
| 349 | - clearstatcache(true, $fichier); |
|
| 350 | - } |
|
| 351 | - return true; |
|
| 333 | + $fichier_tmp = $fichier . '.last'; |
|
| 334 | + if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
|
| 335 | + return false; |
|
| 336 | + } |
|
| 337 | + if ( |
|
| 338 | + $force |
|
| 339 | + or !file_exists($fichier) |
|
| 340 | + or md5_file($fichier) != md5_file($fichier_tmp) |
|
| 341 | + ) { |
|
| 342 | + if ($use_copy) { |
|
| 343 | + @copy($fichier_tmp, $fichier); |
|
| 344 | + } |
|
| 345 | + else { |
|
| 346 | + @rename($fichier_tmp, $fichier); |
|
| 347 | + } |
|
| 348 | + // eviter que PHP ne reserve le vieux timestamp |
|
| 349 | + clearstatcache(true, $fichier); |
|
| 350 | + } |
|
| 351 | + return true; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | |
@@ -369,11 +369,11 @@ discard block |
||
| 369 | 369 | * true si l'opération a réussie, false sinon. |
| 370 | 370 | */ |
| 371 | 371 | function lire_fichier_securise($fichier, &$contenu, $options = []) { |
| 372 | - if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 373 | - $contenu = substr($contenu, strlen('<' . "?php die ('Acces interdit'); ?" . ">\n")); |
|
| 374 | - } |
|
| 372 | + if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 373 | + $contenu = substr($contenu, strlen('<' . "?php die ('Acces interdit'); ?" . ">\n")); |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - return $res; |
|
| 376 | + return $res; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -388,25 +388,25 @@ discard block |
||
| 388 | 388 | * Chemin du fichier |
| 389 | 389 | **/ |
| 390 | 390 | function raler_fichier($fichier) { |
| 391 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 392 | - spip_initialisation_suite(); |
|
| 393 | - } |
|
| 394 | - include_spip('inc/minipres'); |
|
| 395 | - $dir = dirname($fichier); |
|
| 396 | - http_response_code(401); |
|
| 397 | - echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 398 | - . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 399 | - . " <a href='" |
|
| 400 | - . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 401 | - . "'>" |
|
| 402 | - . _T('texte_inc_meta_2') |
|
| 403 | - . '</a> ' |
|
| 404 | - . _T( |
|
| 405 | - 'texte_inc_meta_3', |
|
| 406 | - ['repertoire' => joli_repertoire($dir)] |
|
| 407 | - ) |
|
| 408 | - . "</h4>\n"); |
|
| 409 | - exit; |
|
| 391 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 392 | + spip_initialisation_suite(); |
|
| 393 | + } |
|
| 394 | + include_spip('inc/minipres'); |
|
| 395 | + $dir = dirname($fichier); |
|
| 396 | + http_response_code(401); |
|
| 397 | + echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 398 | + . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 399 | + . " <a href='" |
|
| 400 | + . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 401 | + . "'>" |
|
| 402 | + . _T('texte_inc_meta_2') |
|
| 403 | + . '</a> ' |
|
| 404 | + . _T( |
|
| 405 | + 'texte_inc_meta_3', |
|
| 406 | + ['repertoire' => joli_repertoire($dir)] |
|
| 407 | + ) |
|
| 408 | + . "</h4>\n"); |
|
| 409 | + exit; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | * - true si récent, false sinon |
| 422 | 422 | */ |
| 423 | 423 | function jeune_fichier($fichier, $n) { |
| 424 | - if (!file_exists($fichier)) { |
|
| 425 | - return false; |
|
| 426 | - } |
|
| 427 | - if (!$c = @filemtime($fichier)) { |
|
| 428 | - return false; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - return (time() - $n <= $c); |
|
| 424 | + if (!file_exists($fichier)) { |
|
| 425 | + return false; |
|
| 426 | + } |
|
| 427 | + if (!$c = @filemtime($fichier)) { |
|
| 428 | + return false; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + return (time() - $n <= $c); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -443,22 +443,22 @@ discard block |
||
| 443 | 443 | * - false si on n'arrive pas poser le verrou ou si la suppression échoue |
| 444 | 444 | */ |
| 445 | 445 | function supprimer_fichier($fichier, $lock = true) { |
| 446 | - if (!@file_exists($fichier)) { |
|
| 447 | - return true; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - if ($lock) { |
|
| 451 | - // verrouiller le fichier destination |
|
| 452 | - if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 453 | - return false; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - // liberer le verrou |
|
| 457 | - spip_fclose_unlock($fp); |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - // supprimer |
|
| 461 | - return @unlink($fichier); |
|
| 446 | + if (!@file_exists($fichier)) { |
|
| 447 | + return true; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + if ($lock) { |
|
| 451 | + // verrouiller le fichier destination |
|
| 452 | + if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 453 | + return false; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + // liberer le verrou |
|
| 457 | + spip_fclose_unlock($fp); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + // supprimer |
|
| 461 | + return @unlink($fichier); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -468,12 +468,12 @@ discard block |
||
| 468 | 468 | * Chemin du fichier |
| 469 | 469 | */ |
| 470 | 470 | function spip_unlink($f) { |
| 471 | - if (!is_dir($f)) { |
|
| 472 | - supprimer_fichier($f, false); |
|
| 473 | - } else { |
|
| 474 | - @unlink("$f/.ok"); |
|
| 475 | - @rmdir($f); |
|
| 476 | - } |
|
| 471 | + if (!is_dir($f)) { |
|
| 472 | + supprimer_fichier($f, false); |
|
| 473 | + } else { |
|
| 474 | + @unlink("$f/.ok"); |
|
| 475 | + @rmdir($f); |
|
| 476 | + } |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
@@ -487,26 +487,26 @@ discard block |
||
| 487 | 487 | * The absolute path of the PHP file to invalidate. |
| 488 | 488 | */ |
| 489 | 489 | function spip_clear_opcode_cache($filepath) { |
| 490 | - clearstatcache(true, $filepath); |
|
| 491 | - |
|
| 492 | - // Zend OPcache |
|
| 493 | - if (function_exists('opcache_invalidate')) { |
|
| 494 | - $invalidate = @opcache_invalidate($filepath, true); |
|
| 495 | - // si l'invalidation a echoue lever un flag |
|
| 496 | - if (!$invalidate and !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 497 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 498 | - } |
|
| 499 | - } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 500 | - // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 501 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 502 | - } |
|
| 503 | - // APC. |
|
| 504 | - if (function_exists('apc_delete_file')) { |
|
| 505 | - // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 506 | - // not compiled yet. |
|
| 507 | - // @see http://php.net/apc-delete-file |
|
| 508 | - @apc_delete_file($filepath); |
|
| 509 | - } |
|
| 490 | + clearstatcache(true, $filepath); |
|
| 491 | + |
|
| 492 | + // Zend OPcache |
|
| 493 | + if (function_exists('opcache_invalidate')) { |
|
| 494 | + $invalidate = @opcache_invalidate($filepath, true); |
|
| 495 | + // si l'invalidation a echoue lever un flag |
|
| 496 | + if (!$invalidate and !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 497 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 498 | + } |
|
| 499 | + } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 500 | + // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 501 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 502 | + } |
|
| 503 | + // APC. |
|
| 504 | + if (function_exists('apc_delete_file')) { |
|
| 505 | + // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 506 | + // not compiled yet. |
|
| 507 | + // @see http://php.net/apc-delete-file |
|
| 508 | + @apc_delete_file($filepath); |
|
| 509 | + } |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -529,25 +529,25 @@ discard block |
||
| 529 | 529 | * |
| 530 | 530 | */ |
| 531 | 531 | function spip_attend_invalidation_opcode_cache($timestamp = null) { |
| 532 | - if ( |
|
| 533 | - function_exists('opcache_get_configuration') |
|
| 534 | - and @ini_get('opcache.enable') |
|
| 535 | - and @ini_get('opcache.validate_timestamps') |
|
| 536 | - and ($duree = intval(@ini_get('opcache.revalidate_freq')) or $duree = 2) |
|
| 537 | - and defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 538 | - ) { |
|
| 539 | - $wait = $duree + 1; |
|
| 540 | - if ($timestamp) { |
|
| 541 | - $wait -= (time() - $timestamp); |
|
| 542 | - if ($wait < 0) { |
|
| 543 | - $wait = 0; |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 547 | - if ($wait) { |
|
| 548 | - sleep($duree + 1); |
|
| 549 | - } |
|
| 550 | - } |
|
| 532 | + if ( |
|
| 533 | + function_exists('opcache_get_configuration') |
|
| 534 | + and @ini_get('opcache.enable') |
|
| 535 | + and @ini_get('opcache.validate_timestamps') |
|
| 536 | + and ($duree = intval(@ini_get('opcache.revalidate_freq')) or $duree = 2) |
|
| 537 | + and defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 538 | + ) { |
|
| 539 | + $wait = $duree + 1; |
|
| 540 | + if ($timestamp) { |
|
| 541 | + $wait -= (time() - $timestamp); |
|
| 542 | + if ($wait < 0) { |
|
| 543 | + $wait = 0; |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 547 | + if ($wait) { |
|
| 548 | + sleep($duree + 1); |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | |
@@ -560,26 +560,26 @@ discard block |
||
| 560 | 560 | * @return bool Suppression reussie. |
| 561 | 561 | */ |
| 562 | 562 | function supprimer_repertoire($dir) { |
| 563 | - if (!file_exists($dir)) { |
|
| 564 | - return true; |
|
| 565 | - } |
|
| 566 | - if (!is_dir($dir) || is_link($dir)) { |
|
| 567 | - return @unlink($dir); |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - foreach (scandir($dir) as $item) { |
|
| 571 | - if ($item == '.' || $item == '..') { |
|
| 572 | - continue; |
|
| 573 | - } |
|
| 574 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 575 | - @chmod($dir . '/' . $item, 0777); |
|
| 576 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 577 | - return false; |
|
| 578 | - } |
|
| 579 | - }; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - return @rmdir($dir); |
|
| 563 | + if (!file_exists($dir)) { |
|
| 564 | + return true; |
|
| 565 | + } |
|
| 566 | + if (!is_dir($dir) || is_link($dir)) { |
|
| 567 | + return @unlink($dir); |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + foreach (scandir($dir) as $item) { |
|
| 571 | + if ($item == '.' || $item == '..') { |
|
| 572 | + continue; |
|
| 573 | + } |
|
| 574 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 575 | + @chmod($dir . '/' . $item, 0777); |
|
| 576 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 577 | + return false; |
|
| 578 | + } |
|
| 579 | + }; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + return @rmdir($dir); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
@@ -608,57 +608,57 @@ discard block |
||
| 608 | 608 | * Chemin du répertoire créé. |
| 609 | 609 | **/ |
| 610 | 610 | function sous_repertoire($base, $subdir = '', $nobase = false, $tantpis = false) { |
| 611 | - static $dirs = []; |
|
| 612 | - |
|
| 613 | - $base = str_replace('//', '/', $base); |
|
| 614 | - |
|
| 615 | - # suppr le dernier caractere si c'est un / |
|
| 616 | - $base = rtrim($base, '/'); |
|
| 617 | - |
|
| 618 | - if (!strlen($subdir)) { |
|
| 619 | - $n = strrpos($base, '/'); |
|
| 620 | - if ($n === false) { |
|
| 621 | - return $nobase ? '' : ($base . '/'); |
|
| 622 | - } |
|
| 623 | - $subdir = substr($base, $n + 1); |
|
| 624 | - $base = substr($base, 0, $n + 1); |
|
| 625 | - } else { |
|
| 626 | - $base .= '/'; |
|
| 627 | - $subdir = str_replace('/', '', $subdir); |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - $baseaff = $nobase ? '' : $base; |
|
| 631 | - if (isset($dirs[$base . $subdir])) { |
|
| 632 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 636 | - |
|
| 637 | - if (file_exists("$path/.ok")) { |
|
| 638 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - @mkdir($path, _SPIP_CHMOD); |
|
| 642 | - @chmod($path, _SPIP_CHMOD); |
|
| 643 | - |
|
| 644 | - if (is_dir($path) && is_writable($path)) { |
|
| 645 | - @touch("$path/.ok"); |
|
| 646 | - spip_log("creation $base$subdir/"); |
|
| 647 | - |
|
| 648 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 652 | - // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 653 | - spip_log("echec creation $base${subdir}"); |
|
| 654 | - if ($tantpis) { |
|
| 655 | - return ''; |
|
| 656 | - } |
|
| 657 | - if (!_DIR_RESTREINT) { |
|
| 658 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 659 | - } |
|
| 660 | - $base .= $subdir; |
|
| 661 | - raler_fichier($base . '/.ok'); |
|
| 611 | + static $dirs = []; |
|
| 612 | + |
|
| 613 | + $base = str_replace('//', '/', $base); |
|
| 614 | + |
|
| 615 | + # suppr le dernier caractere si c'est un / |
|
| 616 | + $base = rtrim($base, '/'); |
|
| 617 | + |
|
| 618 | + if (!strlen($subdir)) { |
|
| 619 | + $n = strrpos($base, '/'); |
|
| 620 | + if ($n === false) { |
|
| 621 | + return $nobase ? '' : ($base . '/'); |
|
| 622 | + } |
|
| 623 | + $subdir = substr($base, $n + 1); |
|
| 624 | + $base = substr($base, 0, $n + 1); |
|
| 625 | + } else { |
|
| 626 | + $base .= '/'; |
|
| 627 | + $subdir = str_replace('/', '', $subdir); |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + $baseaff = $nobase ? '' : $base; |
|
| 631 | + if (isset($dirs[$base . $subdir])) { |
|
| 632 | + return $baseaff . $dirs[$base . $subdir]; |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 636 | + |
|
| 637 | + if (file_exists("$path/.ok")) { |
|
| 638 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + @mkdir($path, _SPIP_CHMOD); |
|
| 642 | + @chmod($path, _SPIP_CHMOD); |
|
| 643 | + |
|
| 644 | + if (is_dir($path) && is_writable($path)) { |
|
| 645 | + @touch("$path/.ok"); |
|
| 646 | + spip_log("creation $base$subdir/"); |
|
| 647 | + |
|
| 648 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 652 | + // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 653 | + spip_log("echec creation $base${subdir}"); |
|
| 654 | + if ($tantpis) { |
|
| 655 | + return ''; |
|
| 656 | + } |
|
| 657 | + if (!_DIR_RESTREINT) { |
|
| 658 | + $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 659 | + } |
|
| 660 | + $base .= $subdir; |
|
| 661 | + raler_fichier($base . '/.ok'); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | |
@@ -691,56 +691,56 @@ discard block |
||
| 691 | 691 | * Chemins des fichiers trouvés. |
| 692 | 692 | **/ |
| 693 | 693 | function preg_files($dir, $pattern = -1 /* AUTO */, $maxfiles = 10000, $recurs = []) { |
| 694 | - $nbfiles = 0; |
|
| 695 | - if ($pattern == -1) { |
|
| 696 | - $pattern = "^$dir"; |
|
| 697 | - } |
|
| 698 | - $fichiers = []; |
|
| 699 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 700 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 701 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 702 | - if ($dir == '') { |
|
| 703 | - $dir = '.'; |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 707 | - while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 708 | - if ( |
|
| 709 | - $f[0] != '.' # ignorer . .. .svn etc |
|
| 710 | - and $f != 'CVS' |
|
| 711 | - and $f != 'remove.txt' |
|
| 712 | - and is_readable($f = "$dir/$f") |
|
| 713 | - ) { |
|
| 714 | - if (is_file($f)) { |
|
| 715 | - if (preg_match(";$pattern;iS", $f)) { |
|
| 716 | - $fichiers[] = $f; |
|
| 717 | - $nbfiles++; |
|
| 718 | - } |
|
| 719 | - } else { |
|
| 720 | - if (is_dir($f) and is_array($recurs)) { |
|
| 721 | - $rp = @realpath($f); |
|
| 722 | - if (!is_string($rp) or !strlen($rp)) { |
|
| 723 | - $rp = $f; |
|
| 724 | - } # realpath n'est peut etre pas autorise |
|
| 725 | - if (!isset($recurs[$rp])) { |
|
| 726 | - $recurs[$rp] = true; |
|
| 727 | - $beginning = $fichiers; |
|
| 728 | - $end = preg_files( |
|
| 729 | - "$f/", |
|
| 730 | - $pattern, |
|
| 731 | - $maxfiles - $nbfiles, |
|
| 732 | - $recurs |
|
| 733 | - ); |
|
| 734 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 735 | - $nbfiles = count($fichiers); |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - closedir($d); |
|
| 742 | - } |
|
| 743 | - sort($fichiers); |
|
| 744 | - |
|
| 745 | - return $fichiers; |
|
| 694 | + $nbfiles = 0; |
|
| 695 | + if ($pattern == -1) { |
|
| 696 | + $pattern = "^$dir"; |
|
| 697 | + } |
|
| 698 | + $fichiers = []; |
|
| 699 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 700 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 701 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 702 | + if ($dir == '') { |
|
| 703 | + $dir = '.'; |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 707 | + while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 708 | + if ( |
|
| 709 | + $f[0] != '.' # ignorer . .. .svn etc |
|
| 710 | + and $f != 'CVS' |
|
| 711 | + and $f != 'remove.txt' |
|
| 712 | + and is_readable($f = "$dir/$f") |
|
| 713 | + ) { |
|
| 714 | + if (is_file($f)) { |
|
| 715 | + if (preg_match(";$pattern;iS", $f)) { |
|
| 716 | + $fichiers[] = $f; |
|
| 717 | + $nbfiles++; |
|
| 718 | + } |
|
| 719 | + } else { |
|
| 720 | + if (is_dir($f) and is_array($recurs)) { |
|
| 721 | + $rp = @realpath($f); |
|
| 722 | + if (!is_string($rp) or !strlen($rp)) { |
|
| 723 | + $rp = $f; |
|
| 724 | + } # realpath n'est peut etre pas autorise |
|
| 725 | + if (!isset($recurs[$rp])) { |
|
| 726 | + $recurs[$rp] = true; |
|
| 727 | + $beginning = $fichiers; |
|
| 728 | + $end = preg_files( |
|
| 729 | + "$f/", |
|
| 730 | + $pattern, |
|
| 731 | + $maxfiles - $nbfiles, |
|
| 732 | + $recurs |
|
| 733 | + ); |
|
| 734 | + $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 735 | + $nbfiles = count($fichiers); |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + closedir($d); |
|
| 742 | + } |
|
| 743 | + sort($fichiers); |
|
| 744 | + |
|
| 745 | + return $fichiers; |
|
| 746 | 746 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -38,70 +38,70 @@ discard block |
||
| 38 | 38 | * @return array|string |
| 39 | 39 | */ |
| 40 | 40 | function inc_couleurs_dist($choix = null, $ajouter = false) { |
| 41 | - static $couleurs_spip = [ |
|
| 42 | - // Violet soutenu |
|
| 43 | - 9 => ['couleur_theme' => '#9a6ef2'], |
|
| 44 | - // Violet rosé |
|
| 45 | - 4 => ['couleur_theme' => '#c464cb'], |
|
| 46 | - // Rose interface SPIP |
|
| 47 | - 2 => ['couleur_theme' => '#F02364'], |
|
| 48 | - // Rouge |
|
| 49 | - 8 => ['couleur_theme' => '#ff4524'], |
|
| 50 | - // Orange |
|
| 51 | - 3 => ['couleur_theme' => '#c97500'], |
|
| 52 | - // Vert SPIP |
|
| 53 | - 1 => ['couleur_theme' => '#9dba00'], |
|
| 54 | - // Vert Troglo |
|
| 55 | - 7 => ['couleur_theme' => '#419a2c'], |
|
| 56 | - // Bleu-vert |
|
| 57 | - 12 => ['couleur_theme' => '#269681'], |
|
| 58 | - // Bleu pastel |
|
| 59 | - 5 => ['couleur_theme' => '#3190ae'], |
|
| 60 | - // Bleu Kermesse |
|
| 61 | - 11 => ['couleur_theme' => '#288bdd'], |
|
| 62 | - // Gris bleuté |
|
| 63 | - 6 => ['couleur_theme' => '#7d90a2'], |
|
| 64 | - // Gris |
|
| 65 | - 10 => ['couleur_theme' => '#909090'], |
|
| 66 | - ]; |
|
| 41 | + static $couleurs_spip = [ |
|
| 42 | + // Violet soutenu |
|
| 43 | + 9 => ['couleur_theme' => '#9a6ef2'], |
|
| 44 | + // Violet rosé |
|
| 45 | + 4 => ['couleur_theme' => '#c464cb'], |
|
| 46 | + // Rose interface SPIP |
|
| 47 | + 2 => ['couleur_theme' => '#F02364'], |
|
| 48 | + // Rouge |
|
| 49 | + 8 => ['couleur_theme' => '#ff4524'], |
|
| 50 | + // Orange |
|
| 51 | + 3 => ['couleur_theme' => '#c97500'], |
|
| 52 | + // Vert SPIP |
|
| 53 | + 1 => ['couleur_theme' => '#9dba00'], |
|
| 54 | + // Vert Troglo |
|
| 55 | + 7 => ['couleur_theme' => '#419a2c'], |
|
| 56 | + // Bleu-vert |
|
| 57 | + 12 => ['couleur_theme' => '#269681'], |
|
| 58 | + // Bleu pastel |
|
| 59 | + 5 => ['couleur_theme' => '#3190ae'], |
|
| 60 | + // Bleu Kermesse |
|
| 61 | + 11 => ['couleur_theme' => '#288bdd'], |
|
| 62 | + // Gris bleuté |
|
| 63 | + 6 => ['couleur_theme' => '#7d90a2'], |
|
| 64 | + // Gris |
|
| 65 | + 10 => ['couleur_theme' => '#909090'], |
|
| 66 | + ]; |
|
| 67 | 67 | |
| 68 | - if (is_numeric($choix)) { |
|
| 69 | - $c = $couleurs_spip[$choix]; |
|
| 70 | - // compat < SPIP 3.3 |
|
| 71 | - include_spip('inc/filtres_images_mini'); |
|
| 72 | - $c['couleur_foncee'] = $c['couleur_theme']; |
|
| 73 | - $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5); |
|
| 68 | + if (is_numeric($choix)) { |
|
| 69 | + $c = $couleurs_spip[$choix]; |
|
| 70 | + // compat < SPIP 3.3 |
|
| 71 | + include_spip('inc/filtres_images_mini'); |
|
| 72 | + $c['couleur_foncee'] = $c['couleur_theme']; |
|
| 73 | + $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5); |
|
| 74 | 74 | |
| 75 | - return |
|
| 76 | - 'couleur_theme=' . substr($c['couleur_theme'], 1) |
|
| 77 | - // compat < SPIP 3.3 |
|
| 78 | - . '&couleur_claire=' . substr($c['couleur_claire'], 1) |
|
| 79 | - . '&couleur_foncee=' . substr($c['couleur_foncee'], 1); |
|
| 80 | - } else { |
|
| 81 | - if (is_array($choix)) { |
|
| 82 | - // compat < SPIP 3.3 |
|
| 83 | - $compat_spip_33 = function ($c) { |
|
| 84 | - if (!isset($c['couleur_theme'])) { |
|
| 85 | - $c['couleur_theme'] = $c['couleur_foncee']; |
|
| 86 | - unset($c['couleur_foncee']); |
|
| 87 | - unset($c['couleur_claire']); |
|
| 88 | - unset($c['couleur_lien']); |
|
| 89 | - unset($c['couleur_lien_off']); |
|
| 90 | - } |
|
| 91 | - return $c; |
|
| 92 | - }; |
|
| 93 | - if ($ajouter) { |
|
| 94 | - foreach ($choix as $c) { |
|
| 95 | - $couleurs_spip[] = $compat_spip_33($c); |
|
| 96 | - } |
|
| 75 | + return |
|
| 76 | + 'couleur_theme=' . substr($c['couleur_theme'], 1) |
|
| 77 | + // compat < SPIP 3.3 |
|
| 78 | + . '&couleur_claire=' . substr($c['couleur_claire'], 1) |
|
| 79 | + . '&couleur_foncee=' . substr($c['couleur_foncee'], 1); |
|
| 80 | + } else { |
|
| 81 | + if (is_array($choix)) { |
|
| 82 | + // compat < SPIP 3.3 |
|
| 83 | + $compat_spip_33 = function ($c) { |
|
| 84 | + if (!isset($c['couleur_theme'])) { |
|
| 85 | + $c['couleur_theme'] = $c['couleur_foncee']; |
|
| 86 | + unset($c['couleur_foncee']); |
|
| 87 | + unset($c['couleur_claire']); |
|
| 88 | + unset($c['couleur_lien']); |
|
| 89 | + unset($c['couleur_lien_off']); |
|
| 90 | + } |
|
| 91 | + return $c; |
|
| 92 | + }; |
|
| 93 | + if ($ajouter) { |
|
| 94 | + foreach ($choix as $c) { |
|
| 95 | + $couleurs_spip[] = $compat_spip_33($c); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return $couleurs_spip; |
|
| 99 | - } else { |
|
| 100 | - $choix = array_map($compat_spip_33, $choix); |
|
| 101 | - return $couleurs_spip = $choix; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } |
|
| 98 | + return $couleurs_spip; |
|
| 99 | + } else { |
|
| 100 | + $choix = array_map($compat_spip_33, $choix); |
|
| 101 | + return $couleurs_spip = $choix; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - return $couleurs_spip; |
|
| 106 | + return $couleurs_spip; |
|
| 107 | 107 | } |
@@ -70,17 +70,17 @@ |
||
| 70 | 70 | // compat < SPIP 3.3 |
| 71 | 71 | include_spip('inc/filtres_images_mini'); |
| 72 | 72 | $c['couleur_foncee'] = $c['couleur_theme']; |
| 73 | - $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5); |
|
| 73 | + $c['couleur_claire'] = '#'.couleur_eclaircir($c['couleur_theme'], .5); |
|
| 74 | 74 | |
| 75 | 75 | return |
| 76 | - 'couleur_theme=' . substr($c['couleur_theme'], 1) |
|
| 76 | + 'couleur_theme='.substr($c['couleur_theme'], 1) |
|
| 77 | 77 | // compat < SPIP 3.3 |
| 78 | - . '&couleur_claire=' . substr($c['couleur_claire'], 1) |
|
| 79 | - . '&couleur_foncee=' . substr($c['couleur_foncee'], 1); |
|
| 78 | + . '&couleur_claire='.substr($c['couleur_claire'], 1) |
|
| 79 | + . '&couleur_foncee='.substr($c['couleur_foncee'], 1); |
|
| 80 | 80 | } else { |
| 81 | 81 | if (is_array($choix)) { |
| 82 | 82 | // compat < SPIP 3.3 |
| 83 | - $compat_spip_33 = function ($c) { |
|
| 83 | + $compat_spip_33 = function($c) { |
|
| 84 | 84 | if (!isset($c['couleur_theme'])) { |
| 85 | 85 | $c['couleur_theme'] = $c['couleur_foncee']; |
| 86 | 86 | unset($c['couleur_foncee']); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * - ou tableau d'information sur le squelette. |
| 37 | 37 | */ |
| 38 | 38 | function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) { |
| 39 | - // compat avec anciens appels |
|
| 40 | - $objet = objet_type($objet); |
|
| 39 | + // compat avec anciens appels |
|
| 40 | + $objet = objet_type($objet); |
|
| 41 | 41 | |
| 42 | - return recuperer_fond( |
|
| 43 | - 'prive/objets/editer/logo', |
|
| 44 | - ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | - ); |
|
| 42 | + return recuperer_fond( |
|
| 43 | + 'prive/objets/editer/logo', |
|
| 44 | + ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | + ); |
|
| 46 | 46 | } |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | if (!defined('_AUTO_SELECTION_RUBRIQUE')) { |
| 17 | - define('_AUTO_SELECTION_RUBRIQUE', false); |
|
| 17 | + define('_AUTO_SELECTION_RUBRIQUE', false); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | |
@@ -28,39 +28,39 @@ discard block |
||
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) { |
| 31 | - if (!_AUTO_SELECTION_RUBRIQUE) { |
|
| 32 | - return ''; |
|
| 33 | - } |
|
| 31 | + if (!_AUTO_SELECTION_RUBRIQUE) { |
|
| 32 | + return ''; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - if (!isset($row['id_rubrique'])) { |
|
| 36 | - return ''; |
|
| 37 | - } |
|
| 35 | + if (!isset($row['id_rubrique'])) { |
|
| 36 | + return ''; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $id_rubrique = ''; |
|
| 40 | - if ($GLOBALS['connect_id_rubrique']) { |
|
| 41 | - // si admin restreint : sa rubrique |
|
| 42 | - $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 43 | - } elseif ( |
|
| 44 | - is_int(_AUTO_SELECTION_RUBRIQUE) |
|
| 45 | - and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 46 | - ) { |
|
| 47 | - $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
|
| 48 | - } else { |
|
| 49 | - // sinon la derniere rubrique cree |
|
| 50 | - $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1'); |
|
| 51 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 52 | - } |
|
| 53 | - // si le choix ne convient pas, on cherche dans un secteur |
|
| 54 | - if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 55 | - $id_rubrique = ''; |
|
| 56 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 57 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 58 | - while (!$id_rubrique and $row_rub = sql_fetch($res)) { |
|
| 59 | - if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 60 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 39 | + $id_rubrique = ''; |
|
| 40 | + if ($GLOBALS['connect_id_rubrique']) { |
|
| 41 | + // si admin restreint : sa rubrique |
|
| 42 | + $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 43 | + } elseif ( |
|
| 44 | + is_int(_AUTO_SELECTION_RUBRIQUE) |
|
| 45 | + and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 46 | + ) { |
|
| 47 | + $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
|
| 48 | + } else { |
|
| 49 | + // sinon la derniere rubrique cree |
|
| 50 | + $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1'); |
|
| 51 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 52 | + } |
|
| 53 | + // si le choix ne convient pas, on cherche dans un secteur |
|
| 54 | + if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 55 | + $id_rubrique = ''; |
|
| 56 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 57 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 58 | + while (!$id_rubrique and $row_rub = sql_fetch($res)) { |
|
| 59 | + if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 60 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return $id_rubrique; |
|
| 65 | + return $id_rubrique; |
|
| 66 | 66 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
| 43 | 43 | } elseif ( |
| 44 | 44 | is_int(_AUTO_SELECTION_RUBRIQUE) |
| 45 | - and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 45 | + and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique='.intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 46 | 46 | ) { |
| 47 | 47 | $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
| 48 | 48 | } else { |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | $id_rubrique = $row_rub['id_rubrique']; |
| 52 | 52 | } |
| 53 | 53 | // si le choix ne convient pas, on cherche dans un secteur |
| 54 | - if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 54 | + if (!autoriser('creer'.$objet.'dans', 'rubrique', $id_rubrique)) { |
|
| 55 | 55 | $id_rubrique = ''; |
| 56 | 56 | // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
| 57 | 57 | $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
| 58 | 58 | while (!$id_rubrique and $row_rub = sql_fetch($res)) { |
| 59 | - if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 59 | + if (autoriser('creer'.$objet.'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 60 | 60 | $id_rubrique = $row_rub['id_rubrique']; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | $p !== false |
| 138 | 138 | and ($morceau = substr($txt, $d, $p - $d)) |
| 139 | 139 | and (($nopen += preg_match_all( |
| 140 | - '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 140 | + '{<'.preg_quote($closing_tag).'(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | 141 | $morceau, |
| 142 | 142 | $matches, |
| 143 | 143 | PREG_SET_ORDER |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | * - false si l'arbre xml ne peut être créé ou est vide |
| 48 | 48 | **/ |
| 49 | 49 | function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1_048_576, $datas = '', $profondeur = -1) { |
| 50 | - $contenu = ''; |
|
| 51 | - if (tester_url_absolue($fichier)) { |
|
| 52 | - include_spip('inc/distant'); |
|
| 53 | - $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | - $contenu = $contenu['page'] ?? ''; |
|
| 55 | - } else { |
|
| 56 | - lire_fichier($fichier, $contenu); |
|
| 57 | - } |
|
| 58 | - $arbre = []; |
|
| 59 | - if ($contenu) { |
|
| 60 | - $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | - } |
|
| 50 | + $contenu = ''; |
|
| 51 | + if (tester_url_absolue($fichier)) { |
|
| 52 | + include_spip('inc/distant'); |
|
| 53 | + $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | + $contenu = $contenu['page'] ?? ''; |
|
| 55 | + } else { |
|
| 56 | + lire_fichier($fichier, $contenu); |
|
| 57 | + } |
|
| 58 | + $arbre = []; |
|
| 59 | + if ($contenu) { |
|
| 60 | + $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return count($arbre) ? $arbre : false; |
|
| 63 | + return count($arbre) ? $arbre : false; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!defined('_SPIP_XML_TAG_SPLIT')) { |
| 67 | - define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS'); |
|
| 67 | + define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,153 +83,153 @@ discard block |
||
| 83 | 83 | * - false si l'arbre xml ne peut être créé ou est vide |
| 84 | 84 | **/ |
| 85 | 85 | function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) { |
| 86 | - $out = []; |
|
| 87 | - // enlever les commentaires |
|
| 88 | - $charset = 'AUTO'; |
|
| 89 | - if ($clean === true) { |
|
| 90 | - if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | - $charset = $regs[2]; |
|
| 92 | - } |
|
| 93 | - $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | - $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | - include_spip('inc/charsets'); |
|
| 96 | - $clean = $charset; |
|
| 97 | - //$texte = importer_charset($texte,$charset); |
|
| 98 | - } |
|
| 99 | - if (is_string($clean)) { |
|
| 100 | - $charset = $clean; |
|
| 101 | - } |
|
| 102 | - $txt = $texte; |
|
| 86 | + $out = []; |
|
| 87 | + // enlever les commentaires |
|
| 88 | + $charset = 'AUTO'; |
|
| 89 | + if ($clean === true) { |
|
| 90 | + if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | + $charset = $regs[2]; |
|
| 92 | + } |
|
| 93 | + $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | + $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | + include_spip('inc/charsets'); |
|
| 96 | + $clean = $charset; |
|
| 97 | + //$texte = importer_charset($texte,$charset); |
|
| 98 | + } |
|
| 99 | + if (is_string($clean)) { |
|
| 100 | + $charset = $clean; |
|
| 101 | + } |
|
| 102 | + $txt = $texte; |
|
| 103 | 103 | |
| 104 | - // tant qu'il y a des tags |
|
| 105 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | - while ((is_countable($chars) ? count($chars) : 0) >= 2) { |
|
| 107 | - // tag ouvrant |
|
| 108 | - //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 104 | + // tant qu'il y a des tags |
|
| 105 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | + while ((is_countable($chars) ? count($chars) : 0) >= 2) { |
|
| 107 | + // tag ouvrant |
|
| 108 | + //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 109 | 109 | |
| 110 | - // $before doit etre vide ou des espaces uniquements! |
|
| 111 | - $before = trim($chars[0]); |
|
| 110 | + // $before doit etre vide ou des espaces uniquements! |
|
| 111 | + $before = trim($chars[0]); |
|
| 112 | 112 | |
| 113 | - if (strlen($before) > 0) { |
|
| 114 | - return importer_charset($texte, $charset); |
|
| 115 | - }//$texte; // before non vide, donc on est dans du texte |
|
| 113 | + if (strlen($before) > 0) { |
|
| 114 | + return importer_charset($texte, $charset); |
|
| 115 | + }//$texte; // before non vide, donc on est dans du texte |
|
| 116 | 116 | |
| 117 | - $tag = rtrim($chars[1]); |
|
| 118 | - $txt = $chars[2]; |
|
| 117 | + $tag = rtrim($chars[1]); |
|
| 118 | + $txt = $chars[2]; |
|
| 119 | 119 | |
| 120 | - if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | - return importer_charset($texte, $charset); |
|
| 122 | - }//$texte; |
|
| 123 | - if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | - $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | - $out[$tag][] = ''; |
|
| 126 | - } else { |
|
| 127 | - $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | - $closing_tag = reset($closing_tag); |
|
| 129 | - // tag fermant |
|
| 130 | - $ncclos = strlen("</$closing_tag>"); |
|
| 131 | - $p = strpos($txt, (string) "</$closing_tag>"); |
|
| 132 | - if ($p !== false and (strpos($txt, '<') < $p)) { |
|
| 133 | - $nclose = 0; |
|
| 134 | - $nopen = 0; |
|
| 135 | - $d = 0; |
|
| 136 | - while ( |
|
| 137 | - $p !== false |
|
| 138 | - and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | - and (($nopen += preg_match_all( |
|
| 140 | - '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | - $morceau, |
|
| 142 | - $matches, |
|
| 143 | - PREG_SET_ORDER |
|
| 144 | - )) > $nclose) |
|
| 145 | - ) { |
|
| 146 | - $nclose++; |
|
| 147 | - $d = $p + $ncclos; |
|
| 148 | - $p = strpos($txt, (string) "</$closing_tag>", $d); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - if ($p === false) { |
|
| 152 | - if ($strict) { |
|
| 153 | - $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 120 | + if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | + return importer_charset($texte, $charset); |
|
| 122 | + }//$texte; |
|
| 123 | + if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | + $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | + $out[$tag][] = ''; |
|
| 126 | + } else { |
|
| 127 | + $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | + $closing_tag = reset($closing_tag); |
|
| 129 | + // tag fermant |
|
| 130 | + $ncclos = strlen("</$closing_tag>"); |
|
| 131 | + $p = strpos($txt, (string) "</$closing_tag>"); |
|
| 132 | + if ($p !== false and (strpos($txt, '<') < $p)) { |
|
| 133 | + $nclose = 0; |
|
| 134 | + $nopen = 0; |
|
| 135 | + $d = 0; |
|
| 136 | + while ( |
|
| 137 | + $p !== false |
|
| 138 | + and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | + and (($nopen += preg_match_all( |
|
| 140 | + '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | + $morceau, |
|
| 142 | + $matches, |
|
| 143 | + PREG_SET_ORDER |
|
| 144 | + )) > $nclose) |
|
| 145 | + ) { |
|
| 146 | + $nclose++; |
|
| 147 | + $d = $p + $ncclos; |
|
| 148 | + $p = strpos($txt, (string) "</$closing_tag>", $d); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + if ($p === false) { |
|
| 152 | + if ($strict) { |
|
| 153 | + $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 154 | 154 | |
| 155 | - return $out; |
|
| 156 | - } else { |
|
| 157 | - return importer_charset($texte, $charset); |
|
| 158 | - }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 159 | - } |
|
| 160 | - $content = substr($txt, 0, $p); |
|
| 161 | - $txt = substr($txt, $p + $ncclos); |
|
| 162 | - if ($profondeur == 0 or strpos($content, '<') === false) { // eviter une recursion si pas utile |
|
| 163 | - $out[$tag][] = importer_charset($content, $charset); |
|
| 164 | - }//$content; |
|
| 165 | - else { |
|
| 166 | - $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 170 | - } |
|
| 171 | - if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 172 | - return $out; |
|
| 173 | - } else { |
|
| 174 | - return importer_charset($texte, $charset); |
|
| 175 | - }//$texte; |
|
| 155 | + return $out; |
|
| 156 | + } else { |
|
| 157 | + return importer_charset($texte, $charset); |
|
| 158 | + }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 159 | + } |
|
| 160 | + $content = substr($txt, 0, $p); |
|
| 161 | + $txt = substr($txt, $p + $ncclos); |
|
| 162 | + if ($profondeur == 0 or strpos($content, '<') === false) { // eviter une recursion si pas utile |
|
| 163 | + $out[$tag][] = importer_charset($content, $charset); |
|
| 164 | + }//$content; |
|
| 165 | + else { |
|
| 166 | + $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 170 | + } |
|
| 171 | + if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 172 | + return $out; |
|
| 173 | + } else { |
|
| 174 | + return importer_charset($texte, $charset); |
|
| 175 | + }//$texte; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // https://code.spip.net/@spip_xml_aplatit |
| 179 | 179 | function spip_xml_aplatit($arbre, $separateur = ' ') { |
| 180 | - $s = ''; |
|
| 181 | - if (is_array($arbre)) { |
|
| 182 | - foreach ($arbre as $tag => $feuille) { |
|
| 183 | - if (is_array($feuille)) { |
|
| 184 | - if ($tag !== intval($tag)) { |
|
| 185 | - $f = spip_xml_aplatit($feuille, $separateur); |
|
| 186 | - if (strlen($f)) { |
|
| 187 | - $tagf = explode(' ', $tag); |
|
| 188 | - $tagf = $tagf[0]; |
|
| 189 | - $s .= "<$tag>$f</$tagf>"; |
|
| 190 | - } else { |
|
| 191 | - $s .= "<$tag />"; |
|
| 192 | - } |
|
| 193 | - } else { |
|
| 194 | - $s .= spip_xml_aplatit($feuille); |
|
| 195 | - } |
|
| 196 | - $s .= $separateur; |
|
| 197 | - } else { |
|
| 198 | - $s .= "$feuille$separateur"; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 180 | + $s = ''; |
|
| 181 | + if (is_array($arbre)) { |
|
| 182 | + foreach ($arbre as $tag => $feuille) { |
|
| 183 | + if (is_array($feuille)) { |
|
| 184 | + if ($tag !== intval($tag)) { |
|
| 185 | + $f = spip_xml_aplatit($feuille, $separateur); |
|
| 186 | + if (strlen($f)) { |
|
| 187 | + $tagf = explode(' ', $tag); |
|
| 188 | + $tagf = $tagf[0]; |
|
| 189 | + $s .= "<$tag>$f</$tagf>"; |
|
| 190 | + } else { |
|
| 191 | + $s .= "<$tag />"; |
|
| 192 | + } |
|
| 193 | + } else { |
|
| 194 | + $s .= spip_xml_aplatit($feuille); |
|
| 195 | + } |
|
| 196 | + $s .= $separateur; |
|
| 197 | + } else { |
|
| 198 | + $s .= "$feuille$separateur"; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 203 | + return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // https://code.spip.net/@spip_xml_tagname |
| 207 | 207 | function spip_xml_tagname($tag) { |
| 208 | - if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 209 | - return $reg[1]; |
|
| 210 | - } |
|
| 208 | + if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 209 | + return $reg[1]; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - return ''; |
|
| 212 | + return ''; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // https://code.spip.net/@spip_xml_decompose_tag |
| 216 | 216 | function spip_xml_decompose_tag($tag) { |
| 217 | - $tagname = spip_xml_tagname($tag); |
|
| 218 | - $liste = []; |
|
| 219 | - $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 220 | - $p = strpos($tag, '='); |
|
| 221 | - while ($p !== false) { |
|
| 222 | - $attr = trim(substr($tag, 0, $p)); |
|
| 223 | - $tag = ltrim(substr($tag, $p + 1)); |
|
| 224 | - $quote = $tag[0]; |
|
| 225 | - $p = strpos($tag, $quote, 1); |
|
| 226 | - $cont = substr($tag, 1, $p - 1); |
|
| 227 | - $liste[$attr] = $cont; |
|
| 228 | - $tag = substr($tag, $p + 1); |
|
| 229 | - $p = strpos($tag, '='); |
|
| 230 | - } |
|
| 217 | + $tagname = spip_xml_tagname($tag); |
|
| 218 | + $liste = []; |
|
| 219 | + $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 220 | + $p = strpos($tag, '='); |
|
| 221 | + while ($p !== false) { |
|
| 222 | + $attr = trim(substr($tag, 0, $p)); |
|
| 223 | + $tag = ltrim(substr($tag, $p + 1)); |
|
| 224 | + $quote = $tag[0]; |
|
| 225 | + $p = strpos($tag, $quote, 1); |
|
| 226 | + $cont = substr($tag, 1, $p - 1); |
|
| 227 | + $liste[$attr] = $cont; |
|
| 228 | + $tag = substr($tag, $p + 1); |
|
| 229 | + $p = strpos($tag, '='); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return [$tagname, $liste]; |
|
| 232 | + return [$tagname, $liste]; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -252,21 +252,21 @@ discard block |
||
| 252 | 252 | * false si aucun élément ne valide l'expression régulière, true sinon. |
| 253 | 253 | **/ |
| 254 | 254 | function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) { |
| 255 | - if ($init) { |
|
| 256 | - $matches = []; |
|
| 257 | - } |
|
| 258 | - if (is_array($arbre) && count($arbre)) { |
|
| 259 | - foreach (array_keys($arbre) as $tag) { |
|
| 260 | - if (preg_match($regexp, $tag)) { |
|
| 261 | - $matches[$tag] = &$arbre[$tag]; |
|
| 262 | - } |
|
| 263 | - if (is_array($arbre[$tag])) { |
|
| 264 | - foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 265 | - spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - } |
|
| 255 | + if ($init) { |
|
| 256 | + $matches = []; |
|
| 257 | + } |
|
| 258 | + if (is_array($arbre) && count($arbre)) { |
|
| 259 | + foreach (array_keys($arbre) as $tag) { |
|
| 260 | + if (preg_match($regexp, $tag)) { |
|
| 261 | + $matches[$tag] = &$arbre[$tag]; |
|
| 262 | + } |
|
| 263 | + if (is_array($arbre[$tag])) { |
|
| 264 | + foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 265 | + spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - return (is_countable($matches) ? count($matches) : 0); |
|
| 271 | + return (is_countable($matches) ? count($matches) : 0); |
|
| 272 | 272 | } |
@@ -335,8 +335,7 @@ |
||
| 335 | 335 | if (!autoriser('modifier', $type, intval($id))) { |
| 336 | 336 | $valeurs['editable'] = ''; |
| 337 | 337 | } |
| 338 | - } |
|
| 339 | - else { |
|
| 338 | + } else { |
|
| 340 | 339 | if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
| 341 | 340 | $valeurs['editable'] = ''; |
| 342 | 341 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('base/abstract_sql'); |
| 23 | 23 | |
@@ -59,56 +59,56 @@ discard block |
||
| 59 | 59 | * Retour des traitements. |
| 60 | 60 | **/ |
| 61 | 61 | function formulaires_editer_objet_traiter( |
| 62 | - $type, |
|
| 63 | - $id = 'new', |
|
| 64 | - $id_parent = 0, |
|
| 65 | - $lier_trad = 0, |
|
| 66 | - $retour = '', |
|
| 67 | - $config_fonc = 'articles_edit_config', |
|
| 68 | - $row = [], |
|
| 69 | - $hidden = '' |
|
| 62 | + $type, |
|
| 63 | + $id = 'new', |
|
| 64 | + $id_parent = 0, |
|
| 65 | + $lier_trad = 0, |
|
| 66 | + $retour = '', |
|
| 67 | + $config_fonc = 'articles_edit_config', |
|
| 68 | + $row = [], |
|
| 69 | + $hidden = '' |
|
| 70 | 70 | ) { |
| 71 | 71 | |
| 72 | - $res = []; |
|
| 73 | - // eviter la redirection forcee par l'action... |
|
| 74 | - set_request('redirect'); |
|
| 75 | - if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | - [$id, $err] = $action_editer($id); |
|
| 77 | - } else { |
|
| 78 | - $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | - [$id, $err] = $action_editer($id, $type); |
|
| 80 | - } |
|
| 81 | - $id_table_objet = id_table_objet($type); |
|
| 82 | - $res[$id_table_objet] = $id; |
|
| 83 | - if ($err or !$id) { |
|
| 84 | - $res['message_erreur'] = ($err ?: _T('erreur')); |
|
| 85 | - } else { |
|
| 86 | - // Un lien de trad a prendre en compte |
|
| 87 | - if ($lier_trad) { |
|
| 88 | - // referencer la traduction |
|
| 89 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 90 | - $referencer_traduction($type, $id, $lier_trad); |
|
| 91 | - // actions de recopie de champs / liens sur le nouvel objet créé |
|
| 92 | - $completer_traduction = charger_fonction('completer_traduction', 'inc'); |
|
| 93 | - $err = $completer_traduction($type, $id, $lier_trad); |
|
| 94 | - if ($err) { |
|
| 95 | - $res['message_erreur'] = $err; |
|
| 96 | - return $res; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $res['message_ok'] = _T('info_modification_enregistree'); |
|
| 101 | - if ($retour) { |
|
| 102 | - if (strncmp($retour, 'javascript:', 11) == 0) { |
|
| 103 | - $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 104 | - $res['editable'] = true; |
|
| 105 | - } else { |
|
| 106 | - $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return $res; |
|
| 72 | + $res = []; |
|
| 73 | + // eviter la redirection forcee par l'action... |
|
| 74 | + set_request('redirect'); |
|
| 75 | + if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | + [$id, $err] = $action_editer($id); |
|
| 77 | + } else { |
|
| 78 | + $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | + [$id, $err] = $action_editer($id, $type); |
|
| 80 | + } |
|
| 81 | + $id_table_objet = id_table_objet($type); |
|
| 82 | + $res[$id_table_objet] = $id; |
|
| 83 | + if ($err or !$id) { |
|
| 84 | + $res['message_erreur'] = ($err ?: _T('erreur')); |
|
| 85 | + } else { |
|
| 86 | + // Un lien de trad a prendre en compte |
|
| 87 | + if ($lier_trad) { |
|
| 88 | + // referencer la traduction |
|
| 89 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 90 | + $referencer_traduction($type, $id, $lier_trad); |
|
| 91 | + // actions de recopie de champs / liens sur le nouvel objet créé |
|
| 92 | + $completer_traduction = charger_fonction('completer_traduction', 'inc'); |
|
| 93 | + $err = $completer_traduction($type, $id, $lier_trad); |
|
| 94 | + if ($err) { |
|
| 95 | + $res['message_erreur'] = $err; |
|
| 96 | + return $res; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $res['message_ok'] = _T('info_modification_enregistree'); |
|
| 101 | + if ($retour) { |
|
| 102 | + if (strncmp($retour, 'javascript:', 11) == 0) { |
|
| 103 | + $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 104 | + $res['editable'] = true; |
|
| 105 | + } else { |
|
| 106 | + $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + return $res; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -132,29 +132,29 @@ discard block |
||
| 132 | 132 | * Tableau des erreurs |
| 133 | 133 | **/ |
| 134 | 134 | function formulaires_editer_objet_verifier($type, $id = 'new', $oblis = []) { |
| 135 | - $erreurs = []; |
|
| 136 | - if (intval($id)) { |
|
| 137 | - $conflits = controler_contenu($type, $id); |
|
| 138 | - if ($conflits and is_countable($conflits) ? count($conflits) : 0) { |
|
| 139 | - foreach ($conflits as $champ => $conflit) { |
|
| 140 | - if (!isset($erreurs[$champ])) { |
|
| 141 | - $erreurs[$champ] = ''; |
|
| 142 | - } |
|
| 143 | - $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - foreach ($oblis as $obli) { |
|
| 148 | - $value = _request($obli); |
|
| 149 | - if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) { |
|
| 150 | - if (!isset($erreurs[$obli])) { |
|
| 151 | - $erreurs[$obli] = ''; |
|
| 152 | - } |
|
| 153 | - $erreurs[$obli] .= _T('info_obligatoire'); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return $erreurs; |
|
| 135 | + $erreurs = []; |
|
| 136 | + if (intval($id)) { |
|
| 137 | + $conflits = controler_contenu($type, $id); |
|
| 138 | + if ($conflits and is_countable($conflits) ? count($conflits) : 0) { |
|
| 139 | + foreach ($conflits as $champ => $conflit) { |
|
| 140 | + if (!isset($erreurs[$champ])) { |
|
| 141 | + $erreurs[$champ] = ''; |
|
| 142 | + } |
|
| 143 | + $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + foreach ($oblis as $obli) { |
|
| 148 | + $value = _request($obli); |
|
| 149 | + if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) { |
|
| 150 | + if (!isset($erreurs[$obli])) { |
|
| 151 | + $erreurs[$obli] = ''; |
|
| 152 | + } |
|
| 153 | + $erreurs[$obli] .= _T('info_obligatoire'); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return $erreurs; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -199,152 +199,152 @@ discard block |
||
| 199 | 199 | * Environnement du formulaire. |
| 200 | 200 | **/ |
| 201 | 201 | function formulaires_editer_objet_charger( |
| 202 | - $type, |
|
| 203 | - $id = 'new', |
|
| 204 | - $id_parent = 0, |
|
| 205 | - $lier_trad = 0, |
|
| 206 | - $retour = '', |
|
| 207 | - $config_fonc = 'articles_edit_config', |
|
| 208 | - $row = [], |
|
| 209 | - $hidden = '' |
|
| 202 | + $type, |
|
| 203 | + $id = 'new', |
|
| 204 | + $id_parent = 0, |
|
| 205 | + $lier_trad = 0, |
|
| 206 | + $retour = '', |
|
| 207 | + $config_fonc = 'articles_edit_config', |
|
| 208 | + $row = [], |
|
| 209 | + $hidden = '' |
|
| 210 | 210 | ) { |
| 211 | 211 | |
| 212 | - $valeurs = []; |
|
| 213 | - $table_objet = table_objet($type); |
|
| 214 | - $table_objet_sql = table_objet_sql($type); |
|
| 215 | - $id_table_objet = id_table_objet($type); |
|
| 216 | - |
|
| 217 | - // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 218 | - if ( |
|
| 219 | - $config_fonc |
|
| 220 | - and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 221 | - and $config_fonc !== $table_objet . '_edit_config' |
|
| 222 | - ) { |
|
| 223 | - if ( |
|
| 224 | - $args = test_formulaire_inclus_par_modele() |
|
| 225 | - and in_array($config_fonc, $args) |
|
| 226 | - ) { |
|
| 227 | - $config_fonc = ''; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - $new = !is_numeric($id); |
|
| 232 | - $lang_default = ''; |
|
| 233 | - // Appel direct dans un squelette |
|
| 234 | - if (!$row) { |
|
| 235 | - if (!$new or $lier_trad) { |
|
| 236 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 237 | - $row = $select($id, $id_parent, $lier_trad); |
|
| 238 | - // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 239 | - $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 240 | - } else { |
|
| 241 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 242 | - } |
|
| 243 | - if (!$new) { |
|
| 244 | - $md5 = controles_md5($row); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - if (!$row) { |
|
| 248 | - $row = []; |
|
| 249 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 250 | - if ($desc = $trouver_table($table_objet)) { |
|
| 251 | - foreach ($desc['field'] as $k => $v) { |
|
| 252 | - $row[$k] = ''; |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 259 | - // (et donc: pas de lien de traduction) |
|
| 260 | - $id = ($new or $lier_trad) |
|
| 261 | - ? 'oui' |
|
| 262 | - : $row[$id_table_objet]; |
|
| 263 | - $row[$id_table_objet] = $id; |
|
| 264 | - |
|
| 265 | - $contexte = $row; |
|
| 266 | - if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 267 | - if (!isset($contexte['id_parent'])) { |
|
| 268 | - unset($contexte['id_rubrique']); |
|
| 269 | - } |
|
| 270 | - $contexte['id_parent'] = $id_parent; |
|
| 271 | - } elseif (!isset($contexte['id_parent'])) { |
|
| 272 | - // id_rubrique dans id_parent si possible |
|
| 273 | - if (isset($contexte['id_rubrique'])) { |
|
| 274 | - $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 275 | - unset($contexte['id_rubrique']); |
|
| 276 | - } else { |
|
| 277 | - $contexte['id_parent'] = ''; |
|
| 278 | - } |
|
| 279 | - if ( |
|
| 280 | - !$contexte['id_parent'] |
|
| 281 | - and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 282 | - ) { |
|
| 283 | - $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - $config = []; |
|
| 288 | - if ($config_fonc) { |
|
| 289 | - $contexte['config'] = $config = $config_fonc($contexte); |
|
| 290 | - if (!$lang_default) { |
|
| 291 | - $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - $config = $config + [ |
|
| 295 | - 'lignes' => 0, |
|
| 296 | - 'langue' => '', |
|
| 297 | - ]; |
|
| 298 | - |
|
| 299 | - $att_text = " class='textarea' " |
|
| 300 | - . " rows='" |
|
| 301 | - . ($config['lignes'] + 15) |
|
| 302 | - . "' cols='40'"; |
|
| 303 | - if (isset($contexte['texte'])) { |
|
| 304 | - [$contexte['texte'], $contexte['_texte_trop_long']] = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - // on veut conserver la langue de l'interface ; |
|
| 308 | - // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 309 | - // voudrait l'exploiter |
|
| 310 | - if (isset($contexte['lang'])) { |
|
| 311 | - $contexte['langue'] = $contexte['lang']; |
|
| 312 | - unset($contexte['lang']); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 316 | - (!$lier_trad ? '' : |
|
| 317 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 318 | - $lier_trad . |
|
| 319 | - "' />" . |
|
| 320 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 321 | - $lang_default . |
|
| 322 | - "' />")) |
|
| 323 | - . $hidden |
|
| 324 | - . ($md5 ?? ''); |
|
| 325 | - |
|
| 326 | - // preciser que le formulaire doit passer dans un pipeline |
|
| 327 | - $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]]; |
|
| 328 | - |
|
| 329 | - // preciser que le formulaire doit etre securise auteur/action |
|
| 330 | - // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 331 | - // on le garde pour compat |
|
| 332 | - $contexte['_action'] = ["editer_$type", $id]; |
|
| 333 | - |
|
| 334 | - // et in fine placer l'autorisation |
|
| 335 | - include_spip('inc/autoriser'); |
|
| 336 | - if (intval($id)) { |
|
| 337 | - if (!autoriser('modifier', $type, intval($id))) { |
|
| 338 | - $valeurs['editable'] = ''; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - else { |
|
| 342 | - if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
|
| 343 | - $valeurs['editable'] = ''; |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - return $contexte; |
|
| 212 | + $valeurs = []; |
|
| 213 | + $table_objet = table_objet($type); |
|
| 214 | + $table_objet_sql = table_objet_sql($type); |
|
| 215 | + $id_table_objet = id_table_objet($type); |
|
| 216 | + |
|
| 217 | + // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 218 | + if ( |
|
| 219 | + $config_fonc |
|
| 220 | + and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 221 | + and $config_fonc !== $table_objet . '_edit_config' |
|
| 222 | + ) { |
|
| 223 | + if ( |
|
| 224 | + $args = test_formulaire_inclus_par_modele() |
|
| 225 | + and in_array($config_fonc, $args) |
|
| 226 | + ) { |
|
| 227 | + $config_fonc = ''; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + $new = !is_numeric($id); |
|
| 232 | + $lang_default = ''; |
|
| 233 | + // Appel direct dans un squelette |
|
| 234 | + if (!$row) { |
|
| 235 | + if (!$new or $lier_trad) { |
|
| 236 | + if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 237 | + $row = $select($id, $id_parent, $lier_trad); |
|
| 238 | + // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 239 | + $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 240 | + } else { |
|
| 241 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 242 | + } |
|
| 243 | + if (!$new) { |
|
| 244 | + $md5 = controles_md5($row); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + if (!$row) { |
|
| 248 | + $row = []; |
|
| 249 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 250 | + if ($desc = $trouver_table($table_objet)) { |
|
| 251 | + foreach ($desc['field'] as $k => $v) { |
|
| 252 | + $row[$k] = ''; |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 259 | + // (et donc: pas de lien de traduction) |
|
| 260 | + $id = ($new or $lier_trad) |
|
| 261 | + ? 'oui' |
|
| 262 | + : $row[$id_table_objet]; |
|
| 263 | + $row[$id_table_objet] = $id; |
|
| 264 | + |
|
| 265 | + $contexte = $row; |
|
| 266 | + if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 267 | + if (!isset($contexte['id_parent'])) { |
|
| 268 | + unset($contexte['id_rubrique']); |
|
| 269 | + } |
|
| 270 | + $contexte['id_parent'] = $id_parent; |
|
| 271 | + } elseif (!isset($contexte['id_parent'])) { |
|
| 272 | + // id_rubrique dans id_parent si possible |
|
| 273 | + if (isset($contexte['id_rubrique'])) { |
|
| 274 | + $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 275 | + unset($contexte['id_rubrique']); |
|
| 276 | + } else { |
|
| 277 | + $contexte['id_parent'] = ''; |
|
| 278 | + } |
|
| 279 | + if ( |
|
| 280 | + !$contexte['id_parent'] |
|
| 281 | + and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 282 | + ) { |
|
| 283 | + $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + $config = []; |
|
| 288 | + if ($config_fonc) { |
|
| 289 | + $contexte['config'] = $config = $config_fonc($contexte); |
|
| 290 | + if (!$lang_default) { |
|
| 291 | + $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + $config = $config + [ |
|
| 295 | + 'lignes' => 0, |
|
| 296 | + 'langue' => '', |
|
| 297 | + ]; |
|
| 298 | + |
|
| 299 | + $att_text = " class='textarea' " |
|
| 300 | + . " rows='" |
|
| 301 | + . ($config['lignes'] + 15) |
|
| 302 | + . "' cols='40'"; |
|
| 303 | + if (isset($contexte['texte'])) { |
|
| 304 | + [$contexte['texte'], $contexte['_texte_trop_long']] = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + // on veut conserver la langue de l'interface ; |
|
| 308 | + // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 309 | + // voudrait l'exploiter |
|
| 310 | + if (isset($contexte['lang'])) { |
|
| 311 | + $contexte['langue'] = $contexte['lang']; |
|
| 312 | + unset($contexte['lang']); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 316 | + (!$lier_trad ? '' : |
|
| 317 | + ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 318 | + $lier_trad . |
|
| 319 | + "' />" . |
|
| 320 | + "\n<input type='hidden' name='changer_lang' value='" . |
|
| 321 | + $lang_default . |
|
| 322 | + "' />")) |
|
| 323 | + . $hidden |
|
| 324 | + . ($md5 ?? ''); |
|
| 325 | + |
|
| 326 | + // preciser que le formulaire doit passer dans un pipeline |
|
| 327 | + $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]]; |
|
| 328 | + |
|
| 329 | + // preciser que le formulaire doit etre securise auteur/action |
|
| 330 | + // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 331 | + // on le garde pour compat |
|
| 332 | + $contexte['_action'] = ["editer_$type", $id]; |
|
| 333 | + |
|
| 334 | + // et in fine placer l'autorisation |
|
| 335 | + include_spip('inc/autoriser'); |
|
| 336 | + if (intval($id)) { |
|
| 337 | + if (!autoriser('modifier', $type, intval($id))) { |
|
| 338 | + $valeurs['editable'] = ''; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + else { |
|
| 342 | + if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
|
| 343 | + $valeurs['editable'] = ''; |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + return $contexte; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -355,29 +355,29 @@ discard block |
||
| 355 | 355 | * @return array |
| 356 | 356 | */ |
| 357 | 357 | function coupe_trop_long($texte) { |
| 358 | - $aider = charger_fonction('aider', 'inc'); |
|
| 359 | - if (strlen($texte) > 28 * 1024) { |
|
| 360 | - $texte = str_replace("\r\n", "\n", $texte); |
|
| 361 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 362 | - if ($pos > 0 and $pos < 32 * 1024) { |
|
| 363 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 364 | - $suite = substr($texte, $pos + 2); |
|
| 365 | - } else { |
|
| 366 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 367 | - if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 368 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 369 | - $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 370 | - } else { |
|
| 371 | - $decalage = 1; |
|
| 372 | - } |
|
| 373 | - $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 374 | - $suite = substr($texte, $pos + $decalage); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - return ([$debut, $suite]); |
|
| 378 | - } else { |
|
| 379 | - return ([$texte, '']); |
|
| 380 | - } |
|
| 358 | + $aider = charger_fonction('aider', 'inc'); |
|
| 359 | + if (strlen($texte) > 28 * 1024) { |
|
| 360 | + $texte = str_replace("\r\n", "\n", $texte); |
|
| 361 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 362 | + if ($pos > 0 and $pos < 32 * 1024) { |
|
| 363 | + $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 364 | + $suite = substr($texte, $pos + 2); |
|
| 365 | + } else { |
|
| 366 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 367 | + if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 368 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 369 | + $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 370 | + } else { |
|
| 371 | + $decalage = 1; |
|
| 372 | + } |
|
| 373 | + $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 374 | + $suite = substr($texte, $pos + $decalage); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + return ([$debut, $suite]); |
|
| 378 | + } else { |
|
| 379 | + return ([$texte, '']); |
|
| 380 | + } |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -388,25 +388,25 @@ discard block |
||
| 388 | 388 | * @return array |
| 389 | 389 | */ |
| 390 | 390 | function editer_texte_recolle($texte, $att_text) { |
| 391 | - if ( |
|
| 392 | - (strlen($texte) < 29 * 1024) |
|
| 393 | - or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 394 | - ) { |
|
| 395 | - return [$texte, '']; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - include_spip('inc/barre'); |
|
| 399 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 400 | - $nombre = 0; |
|
| 401 | - |
|
| 402 | - while (strlen($texte) > 29 * 1024) { |
|
| 403 | - $nombre++; |
|
| 404 | - [$texte1, $texte] = coupe_trop_long($texte); |
|
| 405 | - $textes_supplement .= '<br />' . |
|
| 406 | - "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - return [$texte, $textes_supplement]; |
|
| 391 | + if ( |
|
| 392 | + (strlen($texte) < 29 * 1024) |
|
| 393 | + or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 394 | + ) { |
|
| 395 | + return [$texte, '']; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + include_spip('inc/barre'); |
|
| 399 | + $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 400 | + $nombre = 0; |
|
| 401 | + |
|
| 402 | + while (strlen($texte) > 29 * 1024) { |
|
| 403 | + $nombre++; |
|
| 404 | + [$texte1, $texte] = coupe_trop_long($texte); |
|
| 405 | + $textes_supplement .= '<br />' . |
|
| 406 | + "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + return [$texte, $textes_supplement]; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -417,17 +417,17 @@ discard block |
||
| 417 | 417 | * @param int $longueur |
| 418 | 418 | */ |
| 419 | 419 | function titre_automatique($champ_titre, $champs_contenu, $longueur = null) { |
| 420 | - if (!_request($champ_titre)) { |
|
| 421 | - $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 422 | - if (!is_null($longueur)) { |
|
| 423 | - $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 424 | - } else { |
|
| 425 | - $t = $titrer_contenu($champs_contenu); |
|
| 426 | - } |
|
| 427 | - if ($t) { |
|
| 428 | - set_request($champ_titre, $t); |
|
| 429 | - } |
|
| 430 | - } |
|
| 420 | + if (!_request($champ_titre)) { |
|
| 421 | + $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 422 | + if (!is_null($longueur)) { |
|
| 423 | + $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 424 | + } else { |
|
| 425 | + $t = $titrer_contenu($champs_contenu); |
|
| 426 | + } |
|
| 427 | + if ($t) { |
|
| 428 | + set_request($champ_titre, $t); |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -447,20 +447,20 @@ discard block |
||
| 447 | 447 | * @return string |
| 448 | 448 | */ |
| 449 | 449 | function inc_titrer_contenu_dist($champs_contenu, $c = null, $longueur = 50) { |
| 450 | - // trouver un champ texte non vide |
|
| 451 | - $t = ''; |
|
| 452 | - foreach ($champs_contenu as $champ) { |
|
| 453 | - if ($t = _request($champ, $c)) { |
|
| 454 | - break; |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - if ($t) { |
|
| 459 | - include_spip('inc/texte_mini'); |
|
| 460 | - $t = couper($t, $longueur, '...'); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - return $t; |
|
| 450 | + // trouver un champ texte non vide |
|
| 451 | + $t = ''; |
|
| 452 | + foreach ($champs_contenu as $champ) { |
|
| 453 | + if ($t = _request($champ, $c)) { |
|
| 454 | + break; |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + if ($t) { |
|
| 459 | + include_spip('inc/texte_mini'); |
|
| 460 | + $t = couper($t, $longueur, '...'); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + return $t; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
@@ -482,26 +482,26 @@ discard block |
||
| 482 | 482 | * - array sinon couples ('$prefixe$colonne => md5) |
| 483 | 483 | **/ |
| 484 | 484 | function controles_md5(array $data, string $prefixe = 'ctr_', string $format = 'html') { |
| 485 | - $ctr = []; |
|
| 486 | - foreach ($data as $key => $val) { |
|
| 487 | - $m = md5($val ?? ''); |
|
| 488 | - $k = $prefixe . $key; |
|
| 489 | - |
|
| 490 | - switch ($format) { |
|
| 491 | - case 'html': |
|
| 492 | - $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 493 | - break; |
|
| 494 | - default: |
|
| 495 | - $ctr[$k] = $m; |
|
| 496 | - break; |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - if ($format === 'html') { |
|
| 501 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 502 | - } else { |
|
| 503 | - return $ctr; |
|
| 504 | - } |
|
| 485 | + $ctr = []; |
|
| 486 | + foreach ($data as $key => $val) { |
|
| 487 | + $m = md5($val ?? ''); |
|
| 488 | + $k = $prefixe . $key; |
|
| 489 | + |
|
| 490 | + switch ($format) { |
|
| 491 | + case 'html': |
|
| 492 | + $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 493 | + break; |
|
| 494 | + default: |
|
| 495 | + $ctr[$k] = $m; |
|
| 496 | + break; |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + if ($format === 'html') { |
|
| 501 | + return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 502 | + } else { |
|
| 503 | + return $ctr; |
|
| 504 | + } |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
@@ -540,80 +540,80 @@ discard block |
||
| 540 | 540 | * - post : le contenu posté |
| 541 | 541 | **/ |
| 542 | 542 | function controler_contenu($type, $id, $options = [], $c = false, $serveur = '') { |
| 543 | - include_spip('inc/filtres'); |
|
| 544 | - |
|
| 545 | - $table_objet = table_objet($type); |
|
| 546 | - $spip_table_objet = table_objet_sql($type); |
|
| 547 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 548 | - $desc = $trouver_table($table_objet, $serveur); |
|
| 549 | - |
|
| 550 | - // Appels incomplets (sans $c) |
|
| 551 | - if (!is_array($c)) { |
|
| 552 | - $c = []; |
|
| 553 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 554 | - if (_request($champ)) { |
|
| 555 | - $c[$champ] = _request($champ); |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 561 | - // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 562 | - // il faut passer par instituer_XX() |
|
| 563 | - // TODO: faut-il passer ces variables interdites |
|
| 564 | - // dans un fichier de description separe ? |
|
| 565 | - unset($c['statut']); |
|
| 566 | - unset($c['id_parent']); |
|
| 567 | - unset($c['id_rubrique']); |
|
| 568 | - unset($c['id_secteur']); |
|
| 569 | - |
|
| 570 | - // Gerer les champs non vides |
|
| 571 | - if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 572 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 573 | - if ($c[$champ] === '') { |
|
| 574 | - $c[$champ] = $sinon; |
|
| 575 | - } |
|
| 576 | - } |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - // N'accepter que les champs qui existent |
|
| 580 | - // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 581 | - $champs = []; |
|
| 582 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 583 | - if (isset($c[$champ])) { |
|
| 584 | - $champs[$champ] = $c[$champ]; |
|
| 585 | - } |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - // Nettoyer les valeurs |
|
| 589 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 590 | - |
|
| 591 | - // Envoyer aux plugins |
|
| 592 | - $champs = pipeline( |
|
| 593 | - 'pre_edition', |
|
| 594 | - [ |
|
| 595 | - 'args' => [ |
|
| 596 | - 'table' => $spip_table_objet, // compatibilite |
|
| 597 | - 'table_objet' => $table_objet, |
|
| 598 | - 'spip_table_objet' => $spip_table_objet, |
|
| 599 | - 'type' => $type, |
|
| 600 | - 'id_objet' => $id, |
|
| 601 | - 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 602 | - 'action' => 'controler', |
|
| 603 | - 'serveur' => $serveur, |
|
| 604 | - ], |
|
| 605 | - 'data' => $champs |
|
| 606 | - ] |
|
| 607 | - ); |
|
| 608 | - |
|
| 609 | - if (!$champs) { |
|
| 610 | - return false; |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 614 | - $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_'); |
|
| 615 | - |
|
| 616 | - return $conflits; |
|
| 543 | + include_spip('inc/filtres'); |
|
| 544 | + |
|
| 545 | + $table_objet = table_objet($type); |
|
| 546 | + $spip_table_objet = table_objet_sql($type); |
|
| 547 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 548 | + $desc = $trouver_table($table_objet, $serveur); |
|
| 549 | + |
|
| 550 | + // Appels incomplets (sans $c) |
|
| 551 | + if (!is_array($c)) { |
|
| 552 | + $c = []; |
|
| 553 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 554 | + if (_request($champ)) { |
|
| 555 | + $c[$champ] = _request($champ); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 561 | + // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 562 | + // il faut passer par instituer_XX() |
|
| 563 | + // TODO: faut-il passer ces variables interdites |
|
| 564 | + // dans un fichier de description separe ? |
|
| 565 | + unset($c['statut']); |
|
| 566 | + unset($c['id_parent']); |
|
| 567 | + unset($c['id_rubrique']); |
|
| 568 | + unset($c['id_secteur']); |
|
| 569 | + |
|
| 570 | + // Gerer les champs non vides |
|
| 571 | + if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 572 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 573 | + if ($c[$champ] === '') { |
|
| 574 | + $c[$champ] = $sinon; |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + // N'accepter que les champs qui existent |
|
| 580 | + // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 581 | + $champs = []; |
|
| 582 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 583 | + if (isset($c[$champ])) { |
|
| 584 | + $champs[$champ] = $c[$champ]; |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + // Nettoyer les valeurs |
|
| 589 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 590 | + |
|
| 591 | + // Envoyer aux plugins |
|
| 592 | + $champs = pipeline( |
|
| 593 | + 'pre_edition', |
|
| 594 | + [ |
|
| 595 | + 'args' => [ |
|
| 596 | + 'table' => $spip_table_objet, // compatibilite |
|
| 597 | + 'table_objet' => $table_objet, |
|
| 598 | + 'spip_table_objet' => $spip_table_objet, |
|
| 599 | + 'type' => $type, |
|
| 600 | + 'id_objet' => $id, |
|
| 601 | + 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 602 | + 'action' => 'controler', |
|
| 603 | + 'serveur' => $serveur, |
|
| 604 | + ], |
|
| 605 | + 'data' => $champs |
|
| 606 | + ] |
|
| 607 | + ); |
|
| 608 | + |
|
| 609 | + if (!$champs) { |
|
| 610 | + return false; |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 614 | + $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_'); |
|
| 615 | + |
|
| 616 | + return $conflits; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | |
@@ -643,64 +643,64 @@ discard block |
||
| 643 | 643 | * - post : le contenu posté |
| 644 | 644 | **/ |
| 645 | 645 | function controler_md5(&$champs, $ctr, $type, $id, $serveur, $prefix = 'ctr_') { |
| 646 | - $spip_table_objet = table_objet_sql($type); |
|
| 647 | - $id_table_objet = id_table_objet($type); |
|
| 648 | - |
|
| 649 | - // Controle des MD5 envoyes |
|
| 650 | - // On elimine les donnees non modifiees par le formulaire (mais |
|
| 651 | - // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 652 | - foreach ($champs as $key => $val) { |
|
| 653 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 654 | - if (is_scalar($val) and $m == md5($val)) { |
|
| 655 | - unset($champs[$key]); |
|
| 656 | - } |
|
| 657 | - } |
|
| 658 | - } |
|
| 659 | - if (!$champs) { |
|
| 660 | - return; |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - // On veut savoir si notre modif va avoir un impact |
|
| 664 | - // par rapport aux donnees contenues dans la base |
|
| 665 | - // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 666 | - $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 667 | - $intact = true; |
|
| 668 | - foreach ($champs as $ch => $val) { |
|
| 669 | - $intact &= ($s[$ch] == $val); |
|
| 670 | - } |
|
| 671 | - if ($intact) { |
|
| 672 | - return; |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - // Detection de conflits : |
|
| 676 | - // On verifie si notre modif ne provient pas d'un formulaire |
|
| 677 | - // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 678 | - // on compare a ce qui est dans la base, et on bloque en cas |
|
| 679 | - // de conflit. |
|
| 680 | - $ctrh = $ctrq = $conflits = []; |
|
| 681 | - foreach (array_keys($champs) as $key) { |
|
| 682 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 683 | - $ctrh[$key] = $m; |
|
| 684 | - $ctrq[] = $key; |
|
| 685 | - } |
|
| 686 | - } |
|
| 687 | - if ($ctrq) { |
|
| 688 | - $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 689 | - foreach ($ctrh as $key => $m) { |
|
| 690 | - if ( |
|
| 691 | - $m != md5($ctrq[$key]) |
|
| 692 | - and $champs[$key] !== $ctrq[$key] |
|
| 693 | - ) { |
|
| 694 | - $conflits[$key] = [ |
|
| 695 | - 'base' => $ctrq[$key], |
|
| 696 | - 'post' => $champs[$key] |
|
| 697 | - ]; |
|
| 698 | - unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 699 | - } |
|
| 700 | - } |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - return $conflits; |
|
| 646 | + $spip_table_objet = table_objet_sql($type); |
|
| 647 | + $id_table_objet = id_table_objet($type); |
|
| 648 | + |
|
| 649 | + // Controle des MD5 envoyes |
|
| 650 | + // On elimine les donnees non modifiees par le formulaire (mais |
|
| 651 | + // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 652 | + foreach ($champs as $key => $val) { |
|
| 653 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 654 | + if (is_scalar($val) and $m == md5($val)) { |
|
| 655 | + unset($champs[$key]); |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + } |
|
| 659 | + if (!$champs) { |
|
| 660 | + return; |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + // On veut savoir si notre modif va avoir un impact |
|
| 664 | + // par rapport aux donnees contenues dans la base |
|
| 665 | + // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 666 | + $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 667 | + $intact = true; |
|
| 668 | + foreach ($champs as $ch => $val) { |
|
| 669 | + $intact &= ($s[$ch] == $val); |
|
| 670 | + } |
|
| 671 | + if ($intact) { |
|
| 672 | + return; |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + // Detection de conflits : |
|
| 676 | + // On verifie si notre modif ne provient pas d'un formulaire |
|
| 677 | + // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 678 | + // on compare a ce qui est dans la base, et on bloque en cas |
|
| 679 | + // de conflit. |
|
| 680 | + $ctrh = $ctrq = $conflits = []; |
|
| 681 | + foreach (array_keys($champs) as $key) { |
|
| 682 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 683 | + $ctrh[$key] = $m; |
|
| 684 | + $ctrq[] = $key; |
|
| 685 | + } |
|
| 686 | + } |
|
| 687 | + if ($ctrq) { |
|
| 688 | + $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 689 | + foreach ($ctrh as $key => $m) { |
|
| 690 | + if ( |
|
| 691 | + $m != md5($ctrq[$key]) |
|
| 692 | + and $champs[$key] !== $ctrq[$key] |
|
| 693 | + ) { |
|
| 694 | + $conflits[$key] = [ |
|
| 695 | + 'base' => $ctrq[$key], |
|
| 696 | + 'post' => $champs[$key] |
|
| 697 | + ]; |
|
| 698 | + unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + return $conflits; |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | /** |
@@ -712,11 +712,11 @@ discard block |
||
| 712 | 712 | * @return string |
| 713 | 713 | */ |
| 714 | 714 | function display_conflit_champ($x) { |
| 715 | - if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 716 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 717 | - } else { |
|
| 718 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 719 | - } |
|
| 715 | + if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 716 | + return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 717 | + } else { |
|
| 718 | + return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 719 | + } |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -734,57 +734,57 @@ discard block |
||
| 734 | 734 | * @return string |
| 735 | 735 | */ |
| 736 | 736 | function signaler_conflits_edition($conflits, $redirect = '') { |
| 737 | - include_spip('inc/minipres'); |
|
| 738 | - include_spip('inc/revisions'); |
|
| 739 | - include_spip('afficher_diff/champ'); |
|
| 740 | - include_spip('inc/suivi_versions'); |
|
| 741 | - include_spip('inc/diff'); |
|
| 742 | - $diffs = []; |
|
| 743 | - foreach ($conflits as $champ => $a) { |
|
| 744 | - // probleme de stockage ou conflit d'edition ? |
|
| 745 | - $base = $a['save'] ?? $a['base']; |
|
| 746 | - |
|
| 747 | - $diff = new Diff(new DiffTexte()); |
|
| 748 | - $n = preparer_diff($a['post']); |
|
| 749 | - $o = preparer_diff($base); |
|
| 750 | - $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o)))); |
|
| 751 | - |
|
| 752 | - $titre = isset($a['save']) ? _L( |
|
| 753 | - 'Echec lors de l\'enregistrement du champ @champ@', |
|
| 754 | - ['champ' => $champ] |
|
| 755 | - ) : $champ; |
|
| 756 | - |
|
| 757 | - $diffs[] = "<h2>$titre</h2>\n" |
|
| 758 | - . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 759 | - . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 760 | - . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 761 | - . display_conflit_champ($a['post']) |
|
| 762 | - . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 763 | - . display_conflit_champ($base); |
|
| 764 | - } |
|
| 765 | - |
|
| 766 | - if ($redirect) { |
|
| 767 | - $id = uniqid(random_int(0, mt_getrandmax())); |
|
| 768 | - $redirect = "<form action='$redirect' method='get' |
|
| 737 | + include_spip('inc/minipres'); |
|
| 738 | + include_spip('inc/revisions'); |
|
| 739 | + include_spip('afficher_diff/champ'); |
|
| 740 | + include_spip('inc/suivi_versions'); |
|
| 741 | + include_spip('inc/diff'); |
|
| 742 | + $diffs = []; |
|
| 743 | + foreach ($conflits as $champ => $a) { |
|
| 744 | + // probleme de stockage ou conflit d'edition ? |
|
| 745 | + $base = $a['save'] ?? $a['base']; |
|
| 746 | + |
|
| 747 | + $diff = new Diff(new DiffTexte()); |
|
| 748 | + $n = preparer_diff($a['post']); |
|
| 749 | + $o = preparer_diff($base); |
|
| 750 | + $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o)))); |
|
| 751 | + |
|
| 752 | + $titre = isset($a['save']) ? _L( |
|
| 753 | + 'Echec lors de l\'enregistrement du champ @champ@', |
|
| 754 | + ['champ' => $champ] |
|
| 755 | + ) : $champ; |
|
| 756 | + |
|
| 757 | + $diffs[] = "<h2>$titre</h2>\n" |
|
| 758 | + . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 759 | + . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 760 | + . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 761 | + . display_conflit_champ($a['post']) |
|
| 762 | + . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 763 | + . display_conflit_champ($base); |
|
| 764 | + } |
|
| 765 | + |
|
| 766 | + if ($redirect) { |
|
| 767 | + $id = uniqid(random_int(0, mt_getrandmax())); |
|
| 768 | + $redirect = "<form action='$redirect' method='get' |
|
| 769 | 769 | id='$id' |
| 770 | 770 | style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n" |
| 771 | - . form_hidden($redirect) |
|
| 772 | - . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 771 | + . form_hidden($redirect) |
|
| 772 | + . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 773 | 773 | </form>\n"; |
| 774 | 774 | |
| 775 | - // pour les documents, on est probablement en ajax : il faut ajaxer |
|
| 776 | - if (_AJAX) { |
|
| 777 | - $redirect .= '<script type="text/javascript">' |
|
| 778 | - . 'setTimeout(function(){$("#' . $id . '") |
|
| 775 | + // pour les documents, on est probablement en ajax : il faut ajaxer |
|
| 776 | + if (_AJAX) { |
|
| 777 | + $redirect .= '<script type="text/javascript">' |
|
| 778 | + . 'setTimeout(function(){$("#' . $id . '") |
|
| 779 | 779 | .ajaxForm({target:$("#' . $id . '").parent()}); |
| 780 | 780 | }, 200);' |
| 781 | - . "</script>\n"; |
|
| 782 | - } |
|
| 783 | - } |
|
| 781 | + . "</script>\n"; |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | 784 | |
| 785 | - echo minipres( |
|
| 786 | - _T('titre_conflit_edition'), |
|
| 787 | - '<style> |
|
| 785 | + echo minipres( |
|
| 786 | + _T('titre_conflit_edition'), |
|
| 787 | + '<style> |
|
| 788 | 788 | .diff-para-deplace { background: #e8e8ff; } |
| 789 | 789 | .diff-para-ajoute { background: #d0ffc0; color: #000; } |
| 790 | 790 | .diff-para-supprime { background: #ffd0c0; color: #904040; text-decoration: line-through; } |
@@ -795,12 +795,12 @@ discard block |
||
| 795 | 795 | .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; } |
| 796 | 796 | .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; } |
| 797 | 797 | </style>' |
| 798 | - . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 799 | - . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 800 | - . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 801 | - . join("\n", $diffs) |
|
| 802 | - . "</div>\n" |
|
| 803 | - |
|
| 804 | - . $redirect |
|
| 805 | - ); |
|
| 798 | + . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 799 | + . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 800 | + . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 801 | + . join("\n", $diffs) |
|
| 802 | + . "</div>\n" |
|
| 803 | + |
|
| 804 | + . $redirect |
|
| 805 | + ); |
|
| 806 | 806 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $res['message_ok'] = _T('info_modification_enregistree'); |
| 101 | 101 | if ($retour) { |
| 102 | 102 | if (strncmp($retour, 'javascript:', 11) == 0) { |
| 103 | - $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 103 | + $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/'.substr($retour, 11).'/*]]>*/</script>'; |
|
| 104 | 104 | $res['editable'] = true; |
| 105 | 105 | } else { |
| 106 | 106 | $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | if (!isset($erreurs[$champ])) { |
| 141 | 141 | $erreurs[$champ] = ''; |
| 142 | 142 | } |
| 143 | - $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 143 | + $erreurs[$champ] .= _T('alerte_modif_info_concourante')."<br /><textarea readonly='readonly' class='forml'>".entites_html($conflit['base']).'</textarea>'; |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | if ( |
| 219 | 219 | $config_fonc |
| 220 | 220 | and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
| 221 | - and $config_fonc !== $table_objet . '_edit_config' |
|
| 221 | + and $config_fonc !== $table_objet.'_edit_config' |
|
| 222 | 222 | ) { |
| 223 | 223 | if ( |
| 224 | 224 | $args = test_formulaire_inclus_par_modele() |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | // Appel direct dans un squelette |
| 234 | 234 | if (!$row) { |
| 235 | 235 | if (!$new or $lier_trad) { |
| 236 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 236 | + if ($select = charger_fonction('precharger_'.$type, 'inc', true)) { |
|
| 237 | 237 | $row = $select($id, $id_parent, $lier_trad); |
| 238 | 238 | // si on a une fonction precharger, elle pu faire un reglage de langue |
| 239 | 239 | $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
| 240 | 240 | } else { |
| 241 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 241 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet.'='.intval($id)); |
|
| 242 | 242 | } |
| 243 | 243 | if (!$new) { |
| 244 | 244 | $md5 = controles_md5($row); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | if ($config_fonc) { |
| 289 | 289 | $contexte['config'] = $config = $config_fonc($contexte); |
| 290 | 290 | if (!$lang_default) { |
| 291 | - $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 291 | + $lang_default = $config['langue'] ?? session_get('lang'); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | $config = $config + [ |
@@ -312,13 +312,12 @@ discard block |
||
| 312 | 312 | unset($contexte['lang']); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 316 | - (!$lier_trad ? '' : |
|
| 317 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 318 | - $lier_trad . |
|
| 319 | - "' />" . |
|
| 320 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 321 | - $lang_default . |
|
| 315 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n". |
|
| 316 | + (!$lier_trad ? '' : ("\n<input type='hidden' name='lier_trad' value='". |
|
| 317 | + $lier_trad. |
|
| 318 | + "' />". |
|
| 319 | + "\n<input type='hidden' name='changer_lang' value='". |
|
| 320 | + $lang_default. |
|
| 322 | 321 | "' />")) |
| 323 | 322 | . $hidden |
| 324 | 323 | . ($md5 ?? ''); |
@@ -358,14 +357,14 @@ discard block |
||
| 358 | 357 | $aider = charger_fonction('aider', 'inc'); |
| 359 | 358 | if (strlen($texte) > 28 * 1024) { |
| 360 | 359 | $texte = str_replace("\r\n", "\n", $texte); |
| 361 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 360 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 362 | 361 | if ($pos > 0 and $pos < 32 * 1024) { |
| 363 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 362 | + $debut = substr($texte, 0, $pos)."\n\n<!--SPIP-->\n"; |
|
| 364 | 363 | $suite = substr($texte, $pos + 2); |
| 365 | 364 | } else { |
| 366 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 365 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 367 | 366 | if (!($pos > 0 and $pos < 32 * 1024)) { |
| 368 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 367 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 369 | 368 | $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
| 370 | 369 | } else { |
| 371 | 370 | $decalage = 1; |
@@ -396,13 +395,13 @@ discard block |
||
| 396 | 395 | } |
| 397 | 396 | |
| 398 | 397 | include_spip('inc/barre'); |
| 399 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 398 | + $textes_supplement = "<br /><span style='color: red'>"._T('info_texte_long')."</span>\n"; |
|
| 400 | 399 | $nombre = 0; |
| 401 | 400 | |
| 402 | 401 | while (strlen($texte) > 29 * 1024) { |
| 403 | 402 | $nombre++; |
| 404 | 403 | [$texte1, $texte] = coupe_trop_long($texte); |
| 405 | - $textes_supplement .= '<br />' . |
|
| 404 | + $textes_supplement .= '<br />'. |
|
| 406 | 405 | "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
| 407 | 406 | } |
| 408 | 407 | |
@@ -485,7 +484,7 @@ discard block |
||
| 485 | 484 | $ctr = []; |
| 486 | 485 | foreach ($data as $key => $val) { |
| 487 | 486 | $m = md5($val ?? ''); |
| 488 | - $k = $prefixe . $key; |
|
| 487 | + $k = $prefixe.$key; |
|
| 489 | 488 | |
| 490 | 489 | switch ($format) { |
| 491 | 490 | case 'html': |
@@ -498,7 +497,7 @@ discard block |
||
| 498 | 497 | } |
| 499 | 498 | |
| 500 | 499 | if ($format === 'html') { |
| 501 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 500 | + return "\n\n<!-- controles md5 -->\n".join("\n", $ctr)."\n\n"; |
|
| 502 | 501 | } else { |
| 503 | 502 | return $ctr; |
| 504 | 503 | } |
@@ -650,7 +649,7 @@ discard block |
||
| 650 | 649 | // On elimine les donnees non modifiees par le formulaire (mais |
| 651 | 650 | // potentiellement modifiees entre temps par un autre utilisateur) |
| 652 | 651 | foreach ($champs as $key => $val) { |
| 653 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 652 | + if (isset($ctr[$prefix.$key]) and $m = $ctr[$prefix.$key]) { |
|
| 654 | 653 | if (is_scalar($val) and $m == md5($val)) { |
| 655 | 654 | unset($champs[$key]); |
| 656 | 655 | } |
@@ -679,7 +678,7 @@ discard block |
||
| 679 | 678 | // de conflit. |
| 680 | 679 | $ctrh = $ctrq = $conflits = []; |
| 681 | 680 | foreach (array_keys($champs) as $key) { |
| 682 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 681 | + if (isset($ctr[$prefix.$key]) and $m = $ctr[$prefix.$key]) { |
|
| 683 | 682 | $ctrh[$key] = $m; |
| 684 | 683 | $ctrq[] = $key; |
| 685 | 684 | } |
@@ -713,9 +712,9 @@ discard block |
||
| 713 | 712 | */ |
| 714 | 713 | function display_conflit_champ($x) { |
| 715 | 714 | if (strstr($x, "\n") or strlen($x) > 80) { |
| 716 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 715 | + return "<textarea style='width:99%; height:10em;'>".entites_html($x)."</textarea>\n"; |
|
| 717 | 716 | } else { |
| 718 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 717 | + return "<input type='text' size='40' style='width:99%' value=\"".entites_html($x)."\" />\n"; |
|
| 719 | 718 | } |
| 720 | 719 | } |
| 721 | 720 | |
@@ -755,11 +754,11 @@ discard block |
||
| 755 | 754 | ) : $champ; |
| 756 | 755 | |
| 757 | 756 | $diffs[] = "<h2>$titre</h2>\n" |
| 758 | - . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 759 | - . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 760 | - . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 757 | + . '<h3>'._T('info_conflit_edition_differences')."</h3>\n" |
|
| 758 | + . "<div style='max-height:8em; overflow: auto; width:99%;'>".$d."</div>\n" |
|
| 759 | + . '<h4>'._T('info_conflit_edition_votre_version').'</h4>' |
|
| 761 | 760 | . display_conflit_champ($a['post']) |
| 762 | - . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 761 | + . '<h4>'._T('info_conflit_edition_version_enregistree').'</h4>' |
|
| 763 | 762 | . display_conflit_champ($base); |
| 764 | 763 | } |
| 765 | 764 | |
@@ -767,16 +766,16 @@ discard block |
||
| 767 | 766 | $id = uniqid(random_int(0, mt_getrandmax())); |
| 768 | 767 | $redirect = "<form action='$redirect' method='get' |
| 769 | 768 | id='$id' |
| 770 | - style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n" |
|
| 769 | + style='float:".$GLOBALS['spip_lang_right']."; margin-top:2em;'>\n" |
|
| 771 | 770 | . form_hidden($redirect) |
| 772 | - . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 771 | + . "<input type='submit' value='"._T('icone_retour')."' /> |
|
| 773 | 772 | </form>\n"; |
| 774 | 773 | |
| 775 | 774 | // pour les documents, on est probablement en ajax : il faut ajaxer |
| 776 | 775 | if (_AJAX) { |
| 777 | 776 | $redirect .= '<script type="text/javascript">' |
| 778 | - . 'setTimeout(function(){$("#' . $id . '") |
|
| 779 | - .ajaxForm({target:$("#' . $id . '").parent()}); |
|
| 777 | + . 'setTimeout(function(){$("#'.$id.'") |
|
| 778 | + .ajaxForm({target:$("#' . $id.'").parent()}); |
|
| 780 | 779 | }, 200);' |
| 781 | 780 | . "</script>\n"; |
| 782 | 781 | } |
@@ -795,9 +794,9 @@ discard block |
||
| 795 | 794 | .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; } |
| 796 | 795 | .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; } |
| 797 | 796 | </style>' |
| 798 | - . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 799 | - . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 800 | - . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 797 | + . '<p>'._T('info_conflit_edition_avis_non_sauvegarde').'</p>' |
|
| 798 | + . '<p>'._T('texte_conflit_edition_correction').'</p>' |
|
| 799 | + . "<div style='text-align:".$GLOBALS['spip_lang_left'].";'>" |
|
| 801 | 800 | . join("\n", $diffs) |
| 802 | 801 | . "</div>\n" |
| 803 | 802 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | static $dirs = []; |
| 42 | 42 | $liste = []; |
| 43 | 43 | foreach (creer_chemin() as $dir) { |
| 44 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 44 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 45 | 45 | $dirs[$a] = (is_dir($a) || !$a); |
| 46 | 46 | } |
| 47 | 47 | if ($dirs[$a]) { |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | **/ |
| 68 | 68 | function chercher_module_lang($module, $lang = '') { |
| 69 | 69 | if ($lang) { |
| 70 | - $lang = '_' . $lang; |
|
| 70 | + $lang = '_'.$lang; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
| 74 | 74 | if ( |
| 75 | 75 | $f = ($module == 'local' |
| 76 | - ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | - : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 76 | + ? find_in_path($module.$lang.'.php', 'lang/') |
|
| 77 | + : find_langs_in_path($module.$lang.'.php', 'lang/')) |
|
| 78 | 78 | ) { |
| 79 | 79 | return is_array($f) ? $f : [$f]; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // 2) directement dans le chemin (old style, uniquement pour local) |
| 83 | 83 | return (($module == 'local') or strpos($module, '/')) |
| 84 | - ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 84 | + ? (($f = find_in_path($module.$lang.'.php')) ? [$f] : false) |
|
| 85 | 85 | : false; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | **/ |
| 106 | 106 | function charger_langue($lang, $module = 'spip') { |
| 107 | 107 | static $langs = []; |
| 108 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 108 | + $var = 'i18n_'.$module.'_'.$lang; |
|
| 109 | 109 | if (!isset($langs[$lang])) { |
| 110 | 110 | $langs[$lang] = []; |
| 111 | 111 | if ($lang) { |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | foreach ($langs[$lang] as $l) { |
| 122 | 122 | if ($fichiers_lang = chercher_module_lang($module, $l)) { |
| 123 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 123 | + $GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$l; |
|
| 124 | 124 | include(array_shift($fichiers_lang)); |
| 125 | 125 | surcharger_langue($fichiers_lang); |
| 126 | 126 | if ($l !== $lang) { |
| 127 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 127 | + $GLOBALS[$var] = &$GLOBALS['i18n_'.$module.'_'.$l]; |
|
| 128 | 128 | } |
| 129 | - $GLOBALS['lang_' . $var] = $l; |
|
| 129 | + $GLOBALS['lang_'.$var] = $l; |
|
| 130 | 130 | #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
| 131 | 131 | break; |
| 132 | 132 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | foreach ($fichiers as $fichier) { |
| 165 | 165 | if (!isset($surcharges[$fichier])) { |
| 166 | 166 | $idx_lang_normal = $GLOBALS['idx_lang']; |
| 167 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 167 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'].'@temporaire'; |
|
| 168 | 168 | include($fichier); |
| 169 | 169 | $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
| 170 | 170 | unset($GLOBALS[$GLOBALS['idx_lang']]); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | if (is_array($surcharges[$fichier])) { |
| 174 | 174 | $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
| 175 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 175 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array) $GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | 176 | $surcharges[$fichier] |
| 177 | 177 | ); |
| 178 | 178 | } |
@@ -250,27 +250,27 @@ discard block |
||
| 250 | 250 | } else { |
| 251 | 251 | $modules = ['spip', 'ecrire']; |
| 252 | 252 | $code = $ori; |
| 253 | - $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 253 | + $ori_complet = implode('|', $modules).':'.$ori; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $desc = new SPIP_Traductions_Description(); |
| 257 | 257 | |
| 258 | 258 | // parcourir tous les modules jusqu'a ce qu'on trouve |
| 259 | 259 | foreach ($modules as $module) { |
| 260 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 260 | + $var = 'i18n_'.$module.'_'.$lang; |
|
| 261 | 261 | |
| 262 | 262 | if (empty($GLOBALS[$var])) { |
| 263 | 263 | charger_langue($lang, $module); |
| 264 | 264 | // surcharges persos -- on cherche |
| 265 | 265 | // (lang/)local_xx.php et/ou (lang/)local.php ... |
| 266 | - if (!isset($local['local_' . $lang])) { |
|
| 266 | + if (!isset($local['local_'.$lang])) { |
|
| 267 | 267 | // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
| 268 | 268 | $GLOBALS['idx_lang'] = $var; |
| 269 | 269 | // ... (lang/)local_xx.php |
| 270 | - $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 270 | + $local['local_'.$lang] = chercher_module_lang('local', $lang); |
|
| 271 | 271 | } |
| 272 | - if ($local['local_' . $lang]) { |
|
| 273 | - surcharger_langue($local['local_' . $lang]); |
|
| 272 | + if ($local['local_'.$lang]) { |
|
| 273 | + surcharger_langue($local['local_'.$lang]); |
|
| 274 | 274 | } |
| 275 | 275 | // ... puis (lang/)local.php |
| 276 | 276 | if (!isset($local['local'])) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if (isset($GLOBALS[$var][$code])) { |
| 285 | 285 | $desc->code = $code; |
| 286 | 286 | $desc->module = $module; |
| 287 | - $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 287 | + $desc->langue = $GLOBALS['lang_'.$var]; |
|
| 288 | 288 | $desc->texte = $GLOBALS[$var][$code]; |
| 289 | 289 | break; |
| 290 | 290 | } |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | if (!$desc->mode and $desc->texte) { |
| 340 | 340 | // ne pas modifier 2 fois l'affichage |
| 341 | 341 | $desc->mode = 'traduction'; |
| 342 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 342 | + $classe = 'debug-traduction'.($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 343 | 343 | $desc->texte = '<span ' |
| 344 | - . 'lang=' . $desc->langue |
|
| 345 | - . ' class=' . $classe |
|
| 346 | - . ' data-module=' . $desc->module |
|
| 347 | - . ' data-code=' . $desc->code |
|
| 348 | - . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 344 | + . 'lang='.$desc->langue |
|
| 345 | + . ' class='.$classe |
|
| 346 | + . ' data-module='.$desc->module |
|
| 347 | + . ' data-code='.$desc->code |
|
| 348 | + . ' title='.$modules.'('.$desc->langue.')>' |
|
| 349 | 349 | . $desc->texte |
| 350 | 350 | . '</span>'; |
| 351 | 351 | $desc->texte = str_replace( |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | * Liste des fichiers de langue trouvés, dans l'ordre des chemins |
| 39 | 39 | */ |
| 40 | 40 | function find_langs_in_path($file, $dirname = 'lang') { |
| 41 | - static $dirs = []; |
|
| 42 | - $liste = []; |
|
| 43 | - foreach (creer_chemin() as $dir) { |
|
| 44 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 45 | - $dirs[$a] = (is_dir($a) || !$a); |
|
| 46 | - } |
|
| 47 | - if ($dirs[$a]) { |
|
| 48 | - if (is_readable($a .= $file)) { |
|
| 49 | - $liste[] = $a; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 41 | + static $dirs = []; |
|
| 42 | + $liste = []; |
|
| 43 | + foreach (creer_chemin() as $dir) { |
|
| 44 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 45 | + $dirs[$a] = (is_dir($a) || !$a); |
|
| 46 | + } |
|
| 47 | + if ($dirs[$a]) { |
|
| 48 | + if (is_readable($a .= $file)) { |
|
| 49 | + $liste[] = $a; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return array_reverse($liste); |
|
| 54 | + return array_reverse($liste); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | * Liste des fichiers touvés pour ce module et cette langue. |
| 67 | 67 | **/ |
| 68 | 68 | function chercher_module_lang($module, $lang = '') { |
| 69 | - if ($lang) { |
|
| 70 | - $lang = '_' . $lang; |
|
| 71 | - } |
|
| 69 | + if ($lang) { |
|
| 70 | + $lang = '_' . $lang; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
|
| 74 | - if ( |
|
| 75 | - $f = ($module == 'local' |
|
| 76 | - ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | - : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 78 | - ) { |
|
| 79 | - return is_array($f) ? $f : [$f]; |
|
| 80 | - } |
|
| 73 | + // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
|
| 74 | + if ( |
|
| 75 | + $f = ($module == 'local' |
|
| 76 | + ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | + : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 78 | + ) { |
|
| 79 | + return is_array($f) ? $f : [$f]; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // 2) directement dans le chemin (old style, uniquement pour local) |
|
| 83 | - return (($module == 'local') or strpos($module, '/')) |
|
| 84 | - ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 85 | - : false; |
|
| 82 | + // 2) directement dans le chemin (old style, uniquement pour local) |
|
| 83 | + return (($module == 'local') or strpos($module, '/')) |
|
| 84 | + ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 85 | + : false; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -104,33 +104,33 @@ discard block |
||
| 104 | 104 | * @return string Langue du module chargé, sinon chaîne vide. |
| 105 | 105 | **/ |
| 106 | 106 | function charger_langue($lang, $module = 'spip') { |
| 107 | - static $langs = []; |
|
| 108 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 109 | - if (!isset($langs[$lang])) { |
|
| 110 | - $langs[$lang] = []; |
|
| 111 | - if ($lang) { |
|
| 112 | - $langs[$lang][] = $lang; |
|
| 113 | - if (strpos($lang, '_') !== false) { |
|
| 114 | - $l = explode('_', $lang); |
|
| 115 | - $langs[$lang][] = reset($l); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - $langs[$lang][] = $GLOBALS['meta']['langue_site']; |
|
| 119 | - $langs[$lang][] = _LANGUE_PAR_DEFAUT; |
|
| 120 | - } |
|
| 121 | - foreach ($langs[$lang] as $l) { |
|
| 122 | - if ($fichiers_lang = chercher_module_lang($module, $l)) { |
|
| 123 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 124 | - include(array_shift($fichiers_lang)); |
|
| 125 | - surcharger_langue($fichiers_lang); |
|
| 126 | - if ($l !== $lang) { |
|
| 127 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 128 | - } |
|
| 129 | - $GLOBALS['lang_' . $var] = $l; |
|
| 130 | - #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
|
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - } |
|
| 107 | + static $langs = []; |
|
| 108 | + $var = 'i18n_' . $module . '_' . $lang; |
|
| 109 | + if (!isset($langs[$lang])) { |
|
| 110 | + $langs[$lang] = []; |
|
| 111 | + if ($lang) { |
|
| 112 | + $langs[$lang][] = $lang; |
|
| 113 | + if (strpos($lang, '_') !== false) { |
|
| 114 | + $l = explode('_', $lang); |
|
| 115 | + $langs[$lang][] = reset($l); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + $langs[$lang][] = $GLOBALS['meta']['langue_site']; |
|
| 119 | + $langs[$lang][] = _LANGUE_PAR_DEFAUT; |
|
| 120 | + } |
|
| 121 | + foreach ($langs[$lang] as $l) { |
|
| 122 | + if ($fichiers_lang = chercher_module_lang($module, $l)) { |
|
| 123 | + $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 124 | + include(array_shift($fichiers_lang)); |
|
| 125 | + surcharger_langue($fichiers_lang); |
|
| 126 | + if ($l !== $lang) { |
|
| 127 | + $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 128 | + } |
|
| 129 | + $GLOBALS['lang_' . $var] = $l; |
|
| 130 | + #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -150,50 +150,50 @@ discard block |
||
| 150 | 150 | * Liste des chemins de fichiers de langue à surcharger. |
| 151 | 151 | **/ |
| 152 | 152 | function surcharger_langue($fichiers) { |
| 153 | - static $surcharges = []; |
|
| 154 | - if (!isset($GLOBALS['idx_lang'])) { |
|
| 155 | - return; |
|
| 156 | - } |
|
| 153 | + static $surcharges = []; |
|
| 154 | + if (!isset($GLOBALS['idx_lang'])) { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - if (!is_array($fichiers)) { |
|
| 159 | - $fichiers = [$fichiers]; |
|
| 160 | - } |
|
| 161 | - if (!count($fichiers)) { |
|
| 162 | - return; |
|
| 163 | - } |
|
| 164 | - foreach ($fichiers as $fichier) { |
|
| 165 | - if (!isset($surcharges[$fichier])) { |
|
| 166 | - $idx_lang_normal = $GLOBALS['idx_lang']; |
|
| 167 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 168 | - include($fichier); |
|
| 169 | - $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
|
| 170 | - unset($GLOBALS[$GLOBALS['idx_lang']]); |
|
| 171 | - $GLOBALS['idx_lang'] = $idx_lang_normal; |
|
| 172 | - } |
|
| 173 | - if (is_array($surcharges[$fichier])) { |
|
| 174 | - $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
|
| 175 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | - $surcharges[$fichier] |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - } |
|
| 158 | + if (!is_array($fichiers)) { |
|
| 159 | + $fichiers = [$fichiers]; |
|
| 160 | + } |
|
| 161 | + if (!count($fichiers)) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 164 | + foreach ($fichiers as $fichier) { |
|
| 165 | + if (!isset($surcharges[$fichier])) { |
|
| 166 | + $idx_lang_normal = $GLOBALS['idx_lang']; |
|
| 167 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 168 | + include($fichier); |
|
| 169 | + $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
|
| 170 | + unset($GLOBALS[$GLOBALS['idx_lang']]); |
|
| 171 | + $GLOBALS['idx_lang'] = $idx_lang_normal; |
|
| 172 | + } |
|
| 173 | + if (is_array($surcharges[$fichier])) { |
|
| 174 | + $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
|
| 175 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | + $surcharges[$fichier] |
|
| 177 | + ); |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | class SPIP_Traductions_Description { |
| 185 | - /** @var string code de langue (hors module) */ |
|
| 186 | - public $code; |
|
| 187 | - /** @var string nom du module de langue */ |
|
| 188 | - public $module; |
|
| 189 | - /** @var string langue de la traduction */ |
|
| 190 | - public $langue; |
|
| 191 | - /** @var string traduction */ |
|
| 192 | - public $texte; |
|
| 193 | - /** @var string var mode particulier appliqué ? */ |
|
| 194 | - public $mode; |
|
| 195 | - /** @var bool Corrections des textes appliqué ? */ |
|
| 196 | - public $corrections = false; |
|
| 185 | + /** @var string code de langue (hors module) */ |
|
| 186 | + public $code; |
|
| 187 | + /** @var string nom du module de langue */ |
|
| 188 | + public $module; |
|
| 189 | + /** @var string langue de la traduction */ |
|
| 190 | + public $langue; |
|
| 191 | + /** @var string traduction */ |
|
| 192 | + public $texte; |
|
| 193 | + /** @var string var mode particulier appliqué ? */ |
|
| 194 | + public $mode; |
|
| 195 | + /** @var bool Corrections des textes appliqué ? */ |
|
| 196 | + public $corrections = false; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -235,99 +235,99 @@ discard block |
||
| 235 | 235 | * - SPIP_Traductions_Description : traduction et description (texte, module, langue) |
| 236 | 236 | **/ |
| 237 | 237 | function inc_traduire_dist($ori, $lang, $raw = false) { |
| 238 | - static $deja_vu = []; |
|
| 239 | - static $local = []; |
|
| 238 | + static $deja_vu = []; |
|
| 239 | + static $local = []; |
|
| 240 | 240 | |
| 241 | - if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { |
|
| 242 | - return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte; |
|
| 243 | - } |
|
| 241 | + if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { |
|
| 242 | + return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES |
|
| 246 | - if (strpos($ori, ':')) { |
|
| 247 | - [$modules, $code] = explode(':', $ori, 2); |
|
| 248 | - $modules = explode('|', $modules); |
|
| 249 | - $ori_complet = $ori; |
|
| 250 | - } else { |
|
| 251 | - $modules = ['spip', 'ecrire']; |
|
| 252 | - $code = $ori; |
|
| 253 | - $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 254 | - } |
|
| 245 | + // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES |
|
| 246 | + if (strpos($ori, ':')) { |
|
| 247 | + [$modules, $code] = explode(':', $ori, 2); |
|
| 248 | + $modules = explode('|', $modules); |
|
| 249 | + $ori_complet = $ori; |
|
| 250 | + } else { |
|
| 251 | + $modules = ['spip', 'ecrire']; |
|
| 252 | + $code = $ori; |
|
| 253 | + $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - $desc = new SPIP_Traductions_Description(); |
|
| 256 | + $desc = new SPIP_Traductions_Description(); |
|
| 257 | 257 | |
| 258 | - // parcourir tous les modules jusqu'a ce qu'on trouve |
|
| 259 | - foreach ($modules as $module) { |
|
| 260 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 258 | + // parcourir tous les modules jusqu'a ce qu'on trouve |
|
| 259 | + foreach ($modules as $module) { |
|
| 260 | + $var = 'i18n_' . $module . '_' . $lang; |
|
| 261 | 261 | |
| 262 | - if (empty($GLOBALS[$var])) { |
|
| 263 | - charger_langue($lang, $module); |
|
| 264 | - // surcharges persos -- on cherche |
|
| 265 | - // (lang/)local_xx.php et/ou (lang/)local.php ... |
|
| 266 | - if (!isset($local['local_' . $lang])) { |
|
| 267 | - // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
|
| 268 | - $GLOBALS['idx_lang'] = $var; |
|
| 269 | - // ... (lang/)local_xx.php |
|
| 270 | - $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 271 | - } |
|
| 272 | - if ($local['local_' . $lang]) { |
|
| 273 | - surcharger_langue($local['local_' . $lang]); |
|
| 274 | - } |
|
| 275 | - // ... puis (lang/)local.php |
|
| 276 | - if (!isset($local['local'])) { |
|
| 277 | - $local['local'] = chercher_module_lang('local'); |
|
| 278 | - } |
|
| 279 | - if ($local['local']) { |
|
| 280 | - surcharger_langue($local['local']); |
|
| 281 | - } |
|
| 282 | - } |
|
| 262 | + if (empty($GLOBALS[$var])) { |
|
| 263 | + charger_langue($lang, $module); |
|
| 264 | + // surcharges persos -- on cherche |
|
| 265 | + // (lang/)local_xx.php et/ou (lang/)local.php ... |
|
| 266 | + if (!isset($local['local_' . $lang])) { |
|
| 267 | + // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
|
| 268 | + $GLOBALS['idx_lang'] = $var; |
|
| 269 | + // ... (lang/)local_xx.php |
|
| 270 | + $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 271 | + } |
|
| 272 | + if ($local['local_' . $lang]) { |
|
| 273 | + surcharger_langue($local['local_' . $lang]); |
|
| 274 | + } |
|
| 275 | + // ... puis (lang/)local.php |
|
| 276 | + if (!isset($local['local'])) { |
|
| 277 | + $local['local'] = chercher_module_lang('local'); |
|
| 278 | + } |
|
| 279 | + if ($local['local']) { |
|
| 280 | + surcharger_langue($local['local']); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - if (isset($GLOBALS[$var][$code])) { |
|
| 285 | - $desc->code = $code; |
|
| 286 | - $desc->module = $module; |
|
| 287 | - $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 288 | - $desc->texte = $GLOBALS[$var][$code]; |
|
| 289 | - break; |
|
| 290 | - } |
|
| 291 | - } |
|
| 284 | + if (isset($GLOBALS[$var][$code])) { |
|
| 285 | + $desc->code = $code; |
|
| 286 | + $desc->module = $module; |
|
| 287 | + $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 288 | + $desc->texte = $GLOBALS[$var][$code]; |
|
| 289 | + break; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - if (!$desc->corrections) { |
|
| 294 | - $desc->corrections = true; |
|
| 295 | - // Retour aux sources si la chaine est absente dans la langue cible ; |
|
| 296 | - // on essaie d'abord la langue du site, puis a defaut la langue fr |
|
| 297 | - if ( |
|
| 298 | - ($desc->texte === null || !strlen($desc->texte)) |
|
| 299 | - and $lang !== _LANGUE_PAR_DEFAUT |
|
| 300 | - ) { |
|
| 301 | - if ($lang !== $GLOBALS['meta']['langue_site']) { |
|
| 302 | - $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true); |
|
| 303 | - } else { |
|
| 304 | - $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true); |
|
| 305 | - } |
|
| 306 | - } |
|
| 293 | + if (!$desc->corrections) { |
|
| 294 | + $desc->corrections = true; |
|
| 295 | + // Retour aux sources si la chaine est absente dans la langue cible ; |
|
| 296 | + // on essaie d'abord la langue du site, puis a defaut la langue fr |
|
| 297 | + if ( |
|
| 298 | + ($desc->texte === null || !strlen($desc->texte)) |
|
| 299 | + and $lang !== _LANGUE_PAR_DEFAUT |
|
| 300 | + ) { |
|
| 301 | + if ($lang !== $GLOBALS['meta']['langue_site']) { |
|
| 302 | + $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true); |
|
| 303 | + } else { |
|
| 304 | + $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - // Supprimer la mention <NEW> ou <MODIF> |
|
| 309 | - if ($desc->texte && substr($desc->texte, 0, 1) === '<') { |
|
| 310 | - $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte); |
|
| 311 | - } |
|
| 308 | + // Supprimer la mention <NEW> ou <MODIF> |
|
| 309 | + if ($desc->texte && substr($desc->texte, 0, 1) === '<') { |
|
| 310 | + $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - // Si on n'est pas en utf-8, la chaine peut l'etre... |
|
| 314 | - // le cas echeant on la convertit en entites html &#xxx; |
|
| 315 | - if ( |
|
| 316 | - (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8') |
|
| 317 | - and preg_match(',[\x7f-\xff],S', $desc->texte) |
|
| 318 | - ) { |
|
| 319 | - include_spip('inc/charsets'); |
|
| 320 | - $desc->texte = charset2unicode($desc->texte, 'utf-8'); |
|
| 321 | - } |
|
| 322 | - } |
|
| 313 | + // Si on n'est pas en utf-8, la chaine peut l'etre... |
|
| 314 | + // le cas echeant on la convertit en entites html &#xxx; |
|
| 315 | + if ( |
|
| 316 | + (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8') |
|
| 317 | + and preg_match(',[\x7f-\xff],S', $desc->texte) |
|
| 318 | + ) { |
|
| 319 | + include_spip('inc/charsets'); |
|
| 320 | + $desc->texte = charset2unicode($desc->texte, 'utf-8'); |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - if (_request('var_mode') == 'traduction') { |
|
| 325 | - $desc = definir_details_traduction($desc, $ori_complet); |
|
| 326 | - } else { |
|
| 327 | - $deja_vu[$lang][$ori] = $desc; |
|
| 328 | - } |
|
| 324 | + if (_request('var_mode') == 'traduction') { |
|
| 325 | + $desc = definir_details_traduction($desc, $ori_complet); |
|
| 326 | + } else { |
|
| 327 | + $deja_vu[$lang][$ori] = $desc; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - return $raw ? $desc : $desc->texte; |
|
| 330 | + return $raw ? $desc : $desc->texte; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -339,23 +339,23 @@ discard block |
||
| 339 | 339 | * @return SPIP_Traductions_Description |
| 340 | 340 | */ |
| 341 | 341 | function definir_details_traduction($desc, $modules) { |
| 342 | - if (!$desc->mode and $desc->texte) { |
|
| 343 | - // ne pas modifier 2 fois l'affichage |
|
| 344 | - $desc->mode = 'traduction'; |
|
| 345 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 346 | - $desc->texte = '<span ' |
|
| 347 | - . 'lang=' . $desc->langue |
|
| 348 | - . ' class=' . $classe |
|
| 349 | - . ' data-module=' . $desc->module |
|
| 350 | - . ' data-code=' . $desc->code |
|
| 351 | - . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 352 | - . $desc->texte |
|
| 353 | - . '</span>'; |
|
| 354 | - $desc->texte = str_replace( |
|
| 355 | - ["$desc->module:", "$desc->module|"], |
|
| 356 | - ["*$desc->module*:", "*$desc->module*|"], |
|
| 357 | - $desc->texte |
|
| 358 | - ); |
|
| 359 | - } |
|
| 360 | - return $desc; |
|
| 342 | + if (!$desc->mode and $desc->texte) { |
|
| 343 | + // ne pas modifier 2 fois l'affichage |
|
| 344 | + $desc->mode = 'traduction'; |
|
| 345 | + $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 346 | + $desc->texte = '<span ' |
|
| 347 | + . 'lang=' . $desc->langue |
|
| 348 | + . ' class=' . $classe |
|
| 349 | + . ' data-module=' . $desc->module |
|
| 350 | + . ' data-code=' . $desc->code |
|
| 351 | + . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 352 | + . $desc->texte |
|
| 353 | + . '</span>'; |
|
| 354 | + $desc->texte = str_replace( |
|
| 355 | + ["$desc->module:", "$desc->module|"], |
|
| 356 | + ["*$desc->module*:", "*$desc->module*|"], |
|
| 357 | + $desc->texte |
|
| 358 | + ); |
|
| 359 | + } |
|
| 360 | + return $desc; |
|
| 361 | 361 | } |
@@ -18,206 +18,206 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $GLOBALS['codes_langues'] = [ |
| 25 | - 'aa' => 'Afar', |
|
| 26 | - 'ab' => 'Abkhazian', |
|
| 27 | - 'af' => 'Afrikaans', |
|
| 28 | - 'am' => 'Amharic', |
|
| 29 | - 'an' => 'Aragonés', |
|
| 30 | - 'ar' => 'عربي', |
|
| 31 | - 'as' => 'Assamese', |
|
| 32 | - 'ast' => 'asturianu', |
|
| 33 | - 'ay' => 'Aymara', |
|
| 34 | - 'az' => 'Azərbaycan dili', |
|
| 35 | - 'ba' => 'Bashkir', |
|
| 36 | - 'be' => 'Беларуская', |
|
| 37 | - 'ber_tam' => 'Tamazigh', |
|
| 38 | - 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | - 'bg' => 'български', |
|
| 40 | - 'bh' => 'Bihari', |
|
| 41 | - 'bi' => 'Bislama', |
|
| 42 | - 'bm' => 'Bambara', |
|
| 43 | - 'bn' => 'Bengali; Bangla', |
|
| 44 | - 'bo' => 'Tibetan', |
|
| 45 | - 'br' => 'brezhoneg', |
|
| 46 | - 'bs' => 'bosanski', |
|
| 47 | - 'ca' => 'català', |
|
| 48 | - 'co' => 'corsu', |
|
| 49 | - 'cpf' => 'Kréol réyoné', |
|
| 50 | - 'cpf_dom' => 'Kreyòl', |
|
| 51 | - 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | - 'cs' => 'čeština', |
|
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | - 'da' => 'dansk', |
|
| 55 | - 'de' => 'Deutsch', |
|
| 56 | - 'dz' => 'Bhutani', |
|
| 57 | - 'el' => 'ελληνικά', |
|
| 58 | - 'en' => 'English', |
|
| 59 | - 'en_hx' => 'H4ck3R', |
|
| 60 | - 'en_sm' => 'Smurf', |
|
| 61 | - 'eo' => 'Esperanto', |
|
| 62 | - 'es' => 'Español', |
|
| 63 | - 'es_co' => 'Colombiano', |
|
| 64 | - 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | - 'et' => 'eesti', |
|
| 66 | - 'eu' => 'euskara', |
|
| 67 | - 'fa' => 'فارسى', |
|
| 68 | - 'ff' => 'Fulah', // peul |
|
| 69 | - 'fi' => 'suomi', |
|
| 70 | - 'fj' => 'Fiji', |
|
| 71 | - 'fo' => 'føroyskt', |
|
| 72 | - 'fon' => 'fongbè', |
|
| 73 | - 'fr' => 'français', |
|
| 74 | - 'fr_fem' => 'français féminin', |
|
| 75 | - 'fr_sc' => 'schtroumpf', |
|
| 76 | - 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | - 'fr_lsf' => 'langue des signes française', |
|
| 78 | - 'fr_spl' => 'français simplifié', |
|
| 79 | - 'fr_tu' => 'français copain', |
|
| 80 | - 'fy' => 'Frisian', |
|
| 81 | - 'ga' => 'Irish', |
|
| 82 | - 'gd' => 'Scots Gaelic', |
|
| 83 | - 'gl' => 'galego', |
|
| 84 | - 'gn' => 'Guarani', |
|
| 85 | - 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | - 'gu' => 'Gujarati', |
|
| 87 | - 'ha' => 'Hausa', |
|
| 88 | - 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | - 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | - 'haz' => 'هزاره گی', |
|
| 91 | - 'he' => 'עברית', |
|
| 92 | - 'hi' => 'हिंदी', |
|
| 93 | - 'hr' => 'hrvatski', |
|
| 94 | - 'hu' => 'magyar', |
|
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 96 | - 'ia' => 'Interlingua', |
|
| 97 | - 'id' => 'Indonesia', |
|
| 98 | - 'ie' => 'Interlingue', |
|
| 99 | - 'ik' => 'Inupiak', |
|
| 100 | - 'is' => 'íslenska', |
|
| 101 | - 'it' => 'italiano', |
|
| 102 | - 'it_fem' => 'italiana', |
|
| 103 | - 'iu' => 'Inuktitut', |
|
| 104 | - 'ja' => '日本語', |
|
| 105 | - 'jv' => 'Javanese', |
|
| 106 | - 'ka' => 'ქართული', |
|
| 107 | - 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | - 'kl' => 'kalaallisut', |
|
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | - 'kn' => 'Kannada', |
|
| 111 | - 'ko' => '한국어', |
|
| 112 | - 'kok' => 'कोंकणी', |
|
| 113 | - 'ks' => 'Kashmiri', |
|
| 114 | - 'ku' => 'کوردی', |
|
| 115 | - 'ky' => 'Kirghiz', |
|
| 116 | - 'la' => 'lingua latina', |
|
| 117 | - 'lb' => 'Lëtzebuergesch', |
|
| 118 | - 'ln' => 'Lingala', |
|
| 119 | - 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | - 'lt' => 'lietuvių', |
|
| 121 | - 'lu' => 'luba-katanga', |
|
| 122 | - 'lv' => 'latviešu', |
|
| 123 | - 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | - 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | - 'mg' => 'Malagasy', |
|
| 126 | - 'mi' => 'Maori', |
|
| 127 | - 'mk' => 'македонски јазик', |
|
| 128 | - 'ml' => 'Malayalam', |
|
| 129 | - 'mn' => 'Монгол хэл', |
|
| 130 | - 'mo' => 'Moldavian', |
|
| 131 | - 'mos' => 'Moré', |
|
| 132 | - 'mr' => 'मराठी', |
|
| 133 | - 'ms' => 'Bahasa Malaysia', |
|
| 134 | - 'mt' => 'Maltese', |
|
| 135 | - 'my' => 'Burmese', |
|
| 136 | - 'na' => 'Nauru', |
|
| 137 | - 'nap' => 'napulitano', |
|
| 138 | - 'ne' => 'Nepali', |
|
| 139 | - 'nqo' => "N'ko", // www.manden.org |
|
| 140 | - 'nl' => 'Nederlands', |
|
| 141 | - 'no' => 'norsk', |
|
| 142 | - 'nb' => 'norsk bokmål', |
|
| 143 | - 'nn' => 'norsk nynorsk', |
|
| 144 | - 'oc' => 'òc', |
|
| 145 | - 'oc_lnc' => 'òc lengadocian', |
|
| 146 | - 'oc_ni' => 'òc niçard', |
|
| 147 | - 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | - 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | - 'oc_prv' => 'òc provençau', |
|
| 150 | - 'oc_gsc' => 'òc gascon', |
|
| 151 | - 'oc_lms' => 'òc lemosin', |
|
| 152 | - 'oc_auv' => 'òc auvernhat', |
|
| 153 | - 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | - 'om' => '(Afan) Oromo', |
|
| 155 | - 'or' => 'Oriya', |
|
| 156 | - 'pa' => 'Punjabi', |
|
| 157 | - 'pbb' => 'Nasa Yuwe', |
|
| 158 | - 'pl' => 'polski', |
|
| 159 | - 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | - 'ps' => 'پښتو', |
|
| 161 | - 'pt' => 'Português', |
|
| 162 | - 'pt_br' => 'Português do Brasil', |
|
| 163 | - 'qu' => 'Quechua', |
|
| 164 | - 'rm' => 'Rhaeto-Romance', |
|
| 165 | - 'rn' => 'Kirundi', |
|
| 166 | - 'ro' => 'română', |
|
| 167 | - 'roa' => "ch'ti", |
|
| 168 | - 'ru' => 'русский', |
|
| 169 | - 'rw' => 'Kinyarwanda', |
|
| 170 | - 'sa' => 'संस्कृत', |
|
| 171 | - 'sc' => 'sardu', |
|
| 172 | - 'scn' => 'sicilianu', |
|
| 173 | - 'sd' => 'Sindhi', |
|
| 174 | - 'sg' => 'Sangho', |
|
| 175 | - 'sh' => 'srpskohrvastski', |
|
| 176 | - 'sh_latn' => 'srpskohrvastski', |
|
| 177 | - 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | - 'si' => 'Sinhalese', |
|
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | - 'sm' => 'Samoan', |
|
| 182 | - 'sn' => 'Shona', |
|
| 183 | - 'so' => 'Somali', |
|
| 184 | - 'sq' => 'shqip', |
|
| 185 | - 'sr' => 'српски', |
|
| 186 | - 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | - 'sro' => 'sardu campidanésu', |
|
| 188 | - 'ss' => 'Siswati', |
|
| 189 | - 'st' => 'Sesotho', |
|
| 190 | - 'su' => 'Sundanese', |
|
| 191 | - 'sv' => 'svenska', |
|
| 192 | - 'sw' => 'Kiswahili', |
|
| 193 | - 'ta' => 'தமிழ்', // Tamil |
|
| 194 | - 'te' => 'Telugu', |
|
| 195 | - 'tg' => 'Tajik', |
|
| 196 | - 'th' => 'ไทย', |
|
| 197 | - 'ti' => 'Tigrinya', |
|
| 198 | - 'tk' => 'Turkmen', |
|
| 199 | - 'tl' => 'Tagalog', |
|
| 200 | - 'tn' => 'Setswana', |
|
| 201 | - 'to' => 'Tonga', |
|
| 202 | - 'tr' => 'Türkçe', |
|
| 203 | - 'ts' => 'Tsonga', |
|
| 204 | - 'tt' => 'Татар', |
|
| 205 | - 'tw' => 'Twi', |
|
| 206 | - 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | - 'ug' => 'Uighur', |
|
| 208 | - 'uk' => 'українська', |
|
| 209 | - 'ur' => 'ٱردو', |
|
| 210 | - 'uz' => "O'zbekcha", |
|
| 211 | - 'vi' => 'Tiếng Việt', |
|
| 212 | - 'vo' => 'Volapuk', |
|
| 213 | - 'wa' => 'walon', |
|
| 214 | - 'wo' => 'Wolof', |
|
| 215 | - 'xh' => 'Xhosa', |
|
| 216 | - 'yi' => 'Yiddish', |
|
| 217 | - 'yo' => 'Yoruba', |
|
| 218 | - 'za' => 'Zhuang', |
|
| 219 | - 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | - 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | - 'zu' => 'Zulu' |
|
| 25 | + 'aa' => 'Afar', |
|
| 26 | + 'ab' => 'Abkhazian', |
|
| 27 | + 'af' => 'Afrikaans', |
|
| 28 | + 'am' => 'Amharic', |
|
| 29 | + 'an' => 'Aragonés', |
|
| 30 | + 'ar' => 'عربي', |
|
| 31 | + 'as' => 'Assamese', |
|
| 32 | + 'ast' => 'asturianu', |
|
| 33 | + 'ay' => 'Aymara', |
|
| 34 | + 'az' => 'Azərbaycan dili', |
|
| 35 | + 'ba' => 'Bashkir', |
|
| 36 | + 'be' => 'Беларуская', |
|
| 37 | + 'ber_tam' => 'Tamazigh', |
|
| 38 | + 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | + 'bg' => 'български', |
|
| 40 | + 'bh' => 'Bihari', |
|
| 41 | + 'bi' => 'Bislama', |
|
| 42 | + 'bm' => 'Bambara', |
|
| 43 | + 'bn' => 'Bengali; Bangla', |
|
| 44 | + 'bo' => 'Tibetan', |
|
| 45 | + 'br' => 'brezhoneg', |
|
| 46 | + 'bs' => 'bosanski', |
|
| 47 | + 'ca' => 'català', |
|
| 48 | + 'co' => 'corsu', |
|
| 49 | + 'cpf' => 'Kréol réyoné', |
|
| 50 | + 'cpf_dom' => 'Kreyòl', |
|
| 51 | + 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | + 'cs' => 'čeština', |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | + 'da' => 'dansk', |
|
| 55 | + 'de' => 'Deutsch', |
|
| 56 | + 'dz' => 'Bhutani', |
|
| 57 | + 'el' => 'ελληνικά', |
|
| 58 | + 'en' => 'English', |
|
| 59 | + 'en_hx' => 'H4ck3R', |
|
| 60 | + 'en_sm' => 'Smurf', |
|
| 61 | + 'eo' => 'Esperanto', |
|
| 62 | + 'es' => 'Español', |
|
| 63 | + 'es_co' => 'Colombiano', |
|
| 64 | + 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | + 'et' => 'eesti', |
|
| 66 | + 'eu' => 'euskara', |
|
| 67 | + 'fa' => 'فارسى', |
|
| 68 | + 'ff' => 'Fulah', // peul |
|
| 69 | + 'fi' => 'suomi', |
|
| 70 | + 'fj' => 'Fiji', |
|
| 71 | + 'fo' => 'føroyskt', |
|
| 72 | + 'fon' => 'fongbè', |
|
| 73 | + 'fr' => 'français', |
|
| 74 | + 'fr_fem' => 'français féminin', |
|
| 75 | + 'fr_sc' => 'schtroumpf', |
|
| 76 | + 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | + 'fr_lsf' => 'langue des signes française', |
|
| 78 | + 'fr_spl' => 'français simplifié', |
|
| 79 | + 'fr_tu' => 'français copain', |
|
| 80 | + 'fy' => 'Frisian', |
|
| 81 | + 'ga' => 'Irish', |
|
| 82 | + 'gd' => 'Scots Gaelic', |
|
| 83 | + 'gl' => 'galego', |
|
| 84 | + 'gn' => 'Guarani', |
|
| 85 | + 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | + 'gu' => 'Gujarati', |
|
| 87 | + 'ha' => 'Hausa', |
|
| 88 | + 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | + 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | + 'haz' => 'هزاره گی', |
|
| 91 | + 'he' => 'עברית', |
|
| 92 | + 'hi' => 'हिंदी', |
|
| 93 | + 'hr' => 'hrvatski', |
|
| 94 | + 'hu' => 'magyar', |
|
| 95 | + 'hy' => 'Հայերեն',// Arménien |
|
| 96 | + 'ia' => 'Interlingua', |
|
| 97 | + 'id' => 'Indonesia', |
|
| 98 | + 'ie' => 'Interlingue', |
|
| 99 | + 'ik' => 'Inupiak', |
|
| 100 | + 'is' => 'íslenska', |
|
| 101 | + 'it' => 'italiano', |
|
| 102 | + 'it_fem' => 'italiana', |
|
| 103 | + 'iu' => 'Inuktitut', |
|
| 104 | + 'ja' => '日本語', |
|
| 105 | + 'jv' => 'Javanese', |
|
| 106 | + 'ka' => 'ქართული', |
|
| 107 | + 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | + 'kl' => 'kalaallisut', |
|
| 109 | + 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | + 'kn' => 'Kannada', |
|
| 111 | + 'ko' => '한국어', |
|
| 112 | + 'kok' => 'कोंकणी', |
|
| 113 | + 'ks' => 'Kashmiri', |
|
| 114 | + 'ku' => 'کوردی', |
|
| 115 | + 'ky' => 'Kirghiz', |
|
| 116 | + 'la' => 'lingua latina', |
|
| 117 | + 'lb' => 'Lëtzebuergesch', |
|
| 118 | + 'ln' => 'Lingala', |
|
| 119 | + 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | + 'lt' => 'lietuvių', |
|
| 121 | + 'lu' => 'luba-katanga', |
|
| 122 | + 'lv' => 'latviešu', |
|
| 123 | + 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | + 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | + 'mg' => 'Malagasy', |
|
| 126 | + 'mi' => 'Maori', |
|
| 127 | + 'mk' => 'македонски јазик', |
|
| 128 | + 'ml' => 'Malayalam', |
|
| 129 | + 'mn' => 'Монгол хэл', |
|
| 130 | + 'mo' => 'Moldavian', |
|
| 131 | + 'mos' => 'Moré', |
|
| 132 | + 'mr' => 'मराठी', |
|
| 133 | + 'ms' => 'Bahasa Malaysia', |
|
| 134 | + 'mt' => 'Maltese', |
|
| 135 | + 'my' => 'Burmese', |
|
| 136 | + 'na' => 'Nauru', |
|
| 137 | + 'nap' => 'napulitano', |
|
| 138 | + 'ne' => 'Nepali', |
|
| 139 | + 'nqo' => "N'ko", // www.manden.org |
|
| 140 | + 'nl' => 'Nederlands', |
|
| 141 | + 'no' => 'norsk', |
|
| 142 | + 'nb' => 'norsk bokmål', |
|
| 143 | + 'nn' => 'norsk nynorsk', |
|
| 144 | + 'oc' => 'òc', |
|
| 145 | + 'oc_lnc' => 'òc lengadocian', |
|
| 146 | + 'oc_ni' => 'òc niçard', |
|
| 147 | + 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | + 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | + 'oc_prv' => 'òc provençau', |
|
| 150 | + 'oc_gsc' => 'òc gascon', |
|
| 151 | + 'oc_lms' => 'òc lemosin', |
|
| 152 | + 'oc_auv' => 'òc auvernhat', |
|
| 153 | + 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | + 'om' => '(Afan) Oromo', |
|
| 155 | + 'or' => 'Oriya', |
|
| 156 | + 'pa' => 'Punjabi', |
|
| 157 | + 'pbb' => 'Nasa Yuwe', |
|
| 158 | + 'pl' => 'polski', |
|
| 159 | + 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | + 'ps' => 'پښتو', |
|
| 161 | + 'pt' => 'Português', |
|
| 162 | + 'pt_br' => 'Português do Brasil', |
|
| 163 | + 'qu' => 'Quechua', |
|
| 164 | + 'rm' => 'Rhaeto-Romance', |
|
| 165 | + 'rn' => 'Kirundi', |
|
| 166 | + 'ro' => 'română', |
|
| 167 | + 'roa' => "ch'ti", |
|
| 168 | + 'ru' => 'русский', |
|
| 169 | + 'rw' => 'Kinyarwanda', |
|
| 170 | + 'sa' => 'संस्कृत', |
|
| 171 | + 'sc' => 'sardu', |
|
| 172 | + 'scn' => 'sicilianu', |
|
| 173 | + 'sd' => 'Sindhi', |
|
| 174 | + 'sg' => 'Sangho', |
|
| 175 | + 'sh' => 'srpskohrvastski', |
|
| 176 | + 'sh_latn' => 'srpskohrvastski', |
|
| 177 | + 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | + 'si' => 'Sinhalese', |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | + 'sm' => 'Samoan', |
|
| 182 | + 'sn' => 'Shona', |
|
| 183 | + 'so' => 'Somali', |
|
| 184 | + 'sq' => 'shqip', |
|
| 185 | + 'sr' => 'српски', |
|
| 186 | + 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | + 'sro' => 'sardu campidanésu', |
|
| 188 | + 'ss' => 'Siswati', |
|
| 189 | + 'st' => 'Sesotho', |
|
| 190 | + 'su' => 'Sundanese', |
|
| 191 | + 'sv' => 'svenska', |
|
| 192 | + 'sw' => 'Kiswahili', |
|
| 193 | + 'ta' => 'தமிழ்', // Tamil |
|
| 194 | + 'te' => 'Telugu', |
|
| 195 | + 'tg' => 'Tajik', |
|
| 196 | + 'th' => 'ไทย', |
|
| 197 | + 'ti' => 'Tigrinya', |
|
| 198 | + 'tk' => 'Turkmen', |
|
| 199 | + 'tl' => 'Tagalog', |
|
| 200 | + 'tn' => 'Setswana', |
|
| 201 | + 'to' => 'Tonga', |
|
| 202 | + 'tr' => 'Türkçe', |
|
| 203 | + 'ts' => 'Tsonga', |
|
| 204 | + 'tt' => 'Татар', |
|
| 205 | + 'tw' => 'Twi', |
|
| 206 | + 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | + 'ug' => 'Uighur', |
|
| 208 | + 'uk' => 'українська', |
|
| 209 | + 'ur' => 'ٱردو', |
|
| 210 | + 'uz' => "O'zbekcha", |
|
| 211 | + 'vi' => 'Tiếng Việt', |
|
| 212 | + 'vo' => 'Volapuk', |
|
| 213 | + 'wa' => 'walon', |
|
| 214 | + 'wo' => 'Wolof', |
|
| 215 | + 'xh' => 'Xhosa', |
|
| 216 | + 'yi' => 'Yiddish', |
|
| 217 | + 'yo' => 'Yoruba', |
|
| 218 | + 'za' => 'Zhuang', |
|
| 219 | + 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | + 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | + 'zu' => 'Zulu' |
|
| 222 | 222 | |
| 223 | 223 | ]; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'cpf_dom' => 'Kreyòl', |
| 51 | 51 | 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
| 52 | 52 | 'cs' => 'čeština', |
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | 54 | 'da' => 'dansk', |
| 55 | 55 | 'de' => 'Deutsch', |
| 56 | 56 | 'dz' => 'Bhutani', |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | 'hi' => 'हिंदी', |
| 93 | 93 | 'hr' => 'hrvatski', |
| 94 | 94 | 'hu' => 'magyar', |
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 95 | + 'hy' => 'Հայերեն', // Arménien |
|
| 96 | 96 | 'ia' => 'Interlingua', |
| 97 | 97 | 'id' => 'Indonesia', |
| 98 | 98 | 'ie' => 'Interlingue', |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'ka' => 'ქართული', |
| 107 | 107 | 'kk' => 'қазақ тілі', // Kazakh |
| 108 | 108 | 'kl' => 'kalaallisut', |
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 109 | + 'km' => 'ភាសាខ្មែរ', // Khmer |
|
| 110 | 110 | 'kn' => 'Kannada', |
| 111 | 111 | 'ko' => '한국어', |
| 112 | 112 | 'kok' => 'कोंकणी', |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | 'sh_latn' => 'srpskohrvastski', |
| 177 | 177 | 'sh_cyrl' => 'Српскохрватски', |
| 178 | 178 | 'si' => 'Sinhalese', |
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | 181 | 'sm' => 'Samoan', |
| 182 | 182 | 'sn' => 'Shona', |
| 183 | 183 | 'so' => 'Somali', |