@@ -92,10 +92,12 @@ |
||
| 92 | 92 | $store = &$_GET; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - foreach ($c as $k => $v) // on ecrase pas si saisi a nouveau ! |
|
| 95 | + foreach ($c as $k => $v) { |
|
| 96 | + // on ecrase pas si saisi a nouveau ! |
|
| 96 | 97 | { |
| 97 | 98 | if (!isset($store[$k])) { |
| 98 | 99 | $_REQUEST[$k] = $store[$k] = $v; |
| 100 | + } |
|
| 99 | 101 | } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
| 100 | 102 | elseif (is_array($store[$k]) |
| 101 | 103 | and is_array($v) |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $erreurs_etapes = array(); |
| 230 | 230 | $derniere_etape_ok = 0; |
| 231 | 231 | $e = 0; |
| 232 | - while ($e < max($etape, $etape_demandee -1) and $e < $etapes) { |
|
| 232 | + while ($e < max($etape, $etape_demandee - 1) and $e < $etapes) { |
|
| 233 | 233 | $e++; |
| 234 | 234 | $erreurs_etapes[$e] = array(); |
| 235 | 235 | if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | // si la derniere etape OK etait la derniere |
| 268 | 268 | // on renvoie le flux inchange et ca declenche traiter |
| 269 | 269 | if ($derniere_etape_ok == $etapes |
| 270 | - and (!$etape_demandee or $etape_demandee>=$etapes)) { |
|
| 270 | + and (!$etape_demandee or $etape_demandee >= $etapes)) { |
|
| 271 | 271 | return $erreurs; |
| 272 | 272 | } else { |
| 273 | 273 | $etape = $derniere_etape_ok + 1; |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | and ($e = $flux['args']['contexte']['_etape']) > 1 |
| 310 | 310 | and $ext = $flux['args']['ext'] |
| 311 | 311 | and $f = $flux['data'] |
| 312 | - and file_exists($f . "_$e.$ext") |
|
| 312 | + and file_exists($f."_$e.$ext") |
|
| 313 | 313 | ) { |
| 314 | - $flux['data'] = $f . "_$e"; |
|
| 314 | + $flux['data'] = $f."_$e"; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | return $flux; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | 68 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 69 | - return; |
|
| 69 | + return; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -77,45 +77,45 @@ discard block |
||
| 77 | 77 | * @return array |
| 78 | 78 | */ |
| 79 | 79 | function cvtmulti_recuperer_post_precedents($form) { |
| 80 | - include_spip('inc/filtres'); |
|
| 81 | - if ($form |
|
| 82 | - and $c = _request('cvtm_prev_post') |
|
| 83 | - and $c = decoder_contexte_ajax($c, $form) |
|
| 84 | - ) { |
|
| 85 | - #var_dump($c); |
|
| 80 | + include_spip('inc/filtres'); |
|
| 81 | + if ($form |
|
| 82 | + and $c = _request('cvtm_prev_post') |
|
| 83 | + and $c = decoder_contexte_ajax($c, $form) |
|
| 84 | + ) { |
|
| 85 | + #var_dump($c); |
|
| 86 | 86 | |
| 87 | - # reinjecter dans la bonne variable pour permettre de retrouver |
|
| 88 | - # toutes les saisies dans un seul tableau |
|
| 89 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 90 | - $store = &$_POST; |
|
| 91 | - } else { |
|
| 92 | - $store = &$_GET; |
|
| 93 | - } |
|
| 87 | + # reinjecter dans la bonne variable pour permettre de retrouver |
|
| 88 | + # toutes les saisies dans un seul tableau |
|
| 89 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 90 | + $store = &$_POST; |
|
| 91 | + } else { |
|
| 92 | + $store = &$_GET; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - foreach ($c as $k => $v) // on ecrase pas si saisi a nouveau ! |
|
| 96 | - { |
|
| 97 | - if (!isset($store[$k])) { |
|
| 98 | - $_REQUEST[$k] = $store[$k] = $v; |
|
| 99 | - } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
|
| 100 | - elseif (is_array($store[$k]) |
|
| 101 | - and is_array($v) |
|
| 102 | - and $z = array_keys($v) |
|
| 103 | - and !is_numeric(reset($z)) |
|
| 104 | - and $z = array_keys($store[$k]) |
|
| 105 | - and !is_numeric(reset($z)) |
|
| 106 | - ) { |
|
| 107 | - $_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]); |
|
| 108 | - } |
|
| 109 | - } |
|
| 95 | + foreach ($c as $k => $v) // on ecrase pas si saisi a nouveau ! |
|
| 96 | + { |
|
| 97 | + if (!isset($store[$k])) { |
|
| 98 | + $_REQUEST[$k] = $store[$k] = $v; |
|
| 99 | + } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
|
| 100 | + elseif (is_array($store[$k]) |
|
| 101 | + and is_array($v) |
|
| 102 | + and $z = array_keys($v) |
|
| 103 | + and !is_numeric(reset($z)) |
|
| 104 | + and $z = array_keys($store[$k]) |
|
| 105 | + and !is_numeric(reset($z)) |
|
| 106 | + ) { |
|
| 107 | + $_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - // vider pour eviter un second appel a verifier_n |
|
| 112 | - // en cas de double implementation (unipotence) |
|
| 113 | - set_request('cvtm_prev_post'); |
|
| 111 | + // vider pour eviter un second appel a verifier_n |
|
| 112 | + // en cas de double implementation (unipotence) |
|
| 113 | + set_request('cvtm_prev_post'); |
|
| 114 | 114 | |
| 115 | - return array($c['_etape'], $c['_etapes']); |
|
| 116 | - } |
|
| 115 | + return array($c['_etape'], $c['_etapes']); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return false; |
|
| 118 | + return false; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -128,28 +128,28 @@ discard block |
||
| 128 | 128 | * @return array |
| 129 | 129 | */ |
| 130 | 130 | function cvtmulti_sauver_post($form, $je_suis_poste, &$valeurs) { |
| 131 | - if (!isset($valeurs['_cvtm_prev_post'])) { |
|
| 132 | - $post = array('_etape' => $valeurs['_etape'], '_etapes' => $valeurs['_etapes']); |
|
| 133 | - foreach (array_keys($valeurs) as $champ) { |
|
| 134 | - if (substr($champ, 0, 1) !== '_') { |
|
| 135 | - if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
|
| 136 | - if (($v = _request($champ)) !== null) { |
|
| 137 | - $post[$champ] = $v; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - include_spip('inc/filtres'); |
|
| 143 | - $c = encoder_contexte_ajax($post, $form); |
|
| 144 | - if (!isset($valeurs['_hidden'])) { |
|
| 145 | - $valeurs['_hidden'] = ''; |
|
| 146 | - } |
|
| 147 | - $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
|
| 148 | - // marquer comme fait, pour eviter double encodage (unipotence) |
|
| 149 | - $valeurs['_cvtm_prev_post'] = true; |
|
| 150 | - } |
|
| 131 | + if (!isset($valeurs['_cvtm_prev_post'])) { |
|
| 132 | + $post = array('_etape' => $valeurs['_etape'], '_etapes' => $valeurs['_etapes']); |
|
| 133 | + foreach (array_keys($valeurs) as $champ) { |
|
| 134 | + if (substr($champ, 0, 1) !== '_') { |
|
| 135 | + if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
|
| 136 | + if (($v = _request($champ)) !== null) { |
|
| 137 | + $post[$champ] = $v; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + include_spip('inc/filtres'); |
|
| 143 | + $c = encoder_contexte_ajax($post, $form); |
|
| 144 | + if (!isset($valeurs['_hidden'])) { |
|
| 145 | + $valeurs['_hidden'] = ''; |
|
| 146 | + } |
|
| 147 | + $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
|
| 148 | + // marquer comme fait, pour eviter double encodage (unipotence) |
|
| 149 | + $valeurs['_cvtm_prev_post'] = true; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - return $valeurs; |
|
| 152 | + return $valeurs; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | 164 | function cvtmulti_formulaire_charger($flux) { |
| 165 | - if (is_array($flux['data']) |
|
| 166 | - and isset($flux['data']['_etapes']) |
|
| 167 | - ) { |
|
| 168 | - $flux['data'] = cvtmulti_formulaire_charger_etapes($flux['args'], $flux['data']); |
|
| 169 | - } |
|
| 165 | + if (is_array($flux['data']) |
|
| 166 | + and isset($flux['data']['_etapes']) |
|
| 167 | + ) { |
|
| 168 | + $flux['data'] = cvtmulti_formulaire_charger_etapes($flux['args'], $flux['data']); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - return $flux; |
|
| 171 | + return $flux; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | * @return array |
| 179 | 179 | */ |
| 180 | 180 | function cvtmulti_formulaire_charger_etapes($args, $valeurs) { |
| 181 | - if (!isset($valeurs['_etape'])) { |
|
| 182 | - $form = $args['form']; |
|
| 183 | - $je_suis_poste = $args['je_suis_poste']; |
|
| 184 | - $nb_etapes = $valeurs['_etapes']; |
|
| 185 | - $etape = _request('_etape'); |
|
| 186 | - $etape = min(max($etape, 1), $nb_etapes); |
|
| 187 | - set_request('_etape', $etape); |
|
| 188 | - $valeurs['_etape'] = $etape; |
|
| 181 | + if (!isset($valeurs['_etape'])) { |
|
| 182 | + $form = $args['form']; |
|
| 183 | + $je_suis_poste = $args['je_suis_poste']; |
|
| 184 | + $nb_etapes = $valeurs['_etapes']; |
|
| 185 | + $etape = _request('_etape'); |
|
| 186 | + $etape = min(max($etape, 1), $nb_etapes); |
|
| 187 | + set_request('_etape', $etape); |
|
| 188 | + $valeurs['_etape'] = $etape; |
|
| 189 | 189 | |
| 190 | - // sauver les posts de cette etape pour les avoir a la prochaine etape |
|
| 191 | - $valeurs = cvtmulti_sauver_post($form, $je_suis_poste, $valeurs); |
|
| 192 | - } |
|
| 193 | - return $valeurs; |
|
| 190 | + // sauver les posts de cette etape pour les avoir a la prochaine etape |
|
| 191 | + $valeurs = cvtmulti_sauver_post($form, $je_suis_poste, $valeurs); |
|
| 192 | + } |
|
| 193 | + return $valeurs; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | 204 | function cvtmulti_formulaire_verifier($flux) { |
| 205 | - $flux['data'] = cvtmulti_formulaire_verifier_etapes($flux['args'], $flux['data']); |
|
| 206 | - return $flux; |
|
| 205 | + $flux['data'] = cvtmulti_formulaire_verifier_etapes($flux['args'], $flux['data']); |
|
| 206 | + return $flux; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,84 +214,84 @@ discard block |
||
| 214 | 214 | * @return array |
| 215 | 215 | */ |
| 216 | 216 | function cvtmulti_formulaire_verifier_etapes($args, $erreurs) { |
| 217 | - #var_dump('Pipe verifier'); |
|
| 217 | + #var_dump('Pipe verifier'); |
|
| 218 | 218 | |
| 219 | - if ($form = $args['form'] |
|
| 220 | - and ($e = cvtmulti_recuperer_post_precedents($form)) !== false |
|
| 221 | - ) { |
|
| 222 | - // recuperer l'etape saisie et le nombre d'etapes total |
|
| 223 | - list($etape, $etapes) = $e; |
|
| 224 | - $etape_demandee = intval(_request('aller_a_etape')); // possibilite de poster un entier dans aller_a_etape |
|
| 219 | + if ($form = $args['form'] |
|
| 220 | + and ($e = cvtmulti_recuperer_post_precedents($form)) !== false |
|
| 221 | + ) { |
|
| 222 | + // recuperer l'etape saisie et le nombre d'etapes total |
|
| 223 | + list($etape, $etapes) = $e; |
|
| 224 | + $etape_demandee = intval(_request('aller_a_etape')); // possibilite de poster un entier dans aller_a_etape |
|
| 225 | 225 | |
| 226 | - $args['etape_saisie'] = $etape; |
|
| 227 | - $args['etapes'] = $etapes; |
|
| 228 | - // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
|
| 229 | - $erreurs_etapes = array(); |
|
| 230 | - $derniere_etape_ok = 0; |
|
| 231 | - $e = 0; |
|
| 232 | - while ($e < max($etape, $etape_demandee -1) and $e < $etapes) { |
|
| 233 | - $e++; |
|
| 234 | - $erreurs_etapes[$e] = array(); |
|
| 235 | - if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) { |
|
| 236 | - $erreurs_etapes[$e] = call_user_func_array($verifier, $args['args']); |
|
| 237 | - } elseif ($verifier = charger_fonction("verifier_etape", "formulaires/$form/", true)) { |
|
| 238 | - $a = $args['args']; |
|
| 239 | - array_unshift($a, $e); |
|
| 240 | - $erreurs_etapes[$e] = call_user_func_array($verifier, $a); |
|
| 241 | - } |
|
| 242 | - // et on appelle un pipeline dedie aux etapes, plus easy |
|
| 243 | - $args['etape'] = $e; |
|
| 244 | - $args['etape_demandee'] = $etape_demandee; |
|
| 245 | - $erreurs_etapes[$e] = pipeline( |
|
| 246 | - 'formulaire_verifier_etape', |
|
| 247 | - array( |
|
| 248 | - 'args' => $args, |
|
| 249 | - 'data' => $erreurs_etapes[$e] |
|
| 250 | - ) |
|
| 251 | - ); |
|
| 226 | + $args['etape_saisie'] = $etape; |
|
| 227 | + $args['etapes'] = $etapes; |
|
| 228 | + // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
|
| 229 | + $erreurs_etapes = array(); |
|
| 230 | + $derniere_etape_ok = 0; |
|
| 231 | + $e = 0; |
|
| 232 | + while ($e < max($etape, $etape_demandee -1) and $e < $etapes) { |
|
| 233 | + $e++; |
|
| 234 | + $erreurs_etapes[$e] = array(); |
|
| 235 | + if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) { |
|
| 236 | + $erreurs_etapes[$e] = call_user_func_array($verifier, $args['args']); |
|
| 237 | + } elseif ($verifier = charger_fonction("verifier_etape", "formulaires/$form/", true)) { |
|
| 238 | + $a = $args['args']; |
|
| 239 | + array_unshift($a, $e); |
|
| 240 | + $erreurs_etapes[$e] = call_user_func_array($verifier, $a); |
|
| 241 | + } |
|
| 242 | + // et on appelle un pipeline dedie aux etapes, plus easy |
|
| 243 | + $args['etape'] = $e; |
|
| 244 | + $args['etape_demandee'] = $etape_demandee; |
|
| 245 | + $erreurs_etapes[$e] = pipeline( |
|
| 246 | + 'formulaire_verifier_etape', |
|
| 247 | + array( |
|
| 248 | + 'args' => $args, |
|
| 249 | + 'data' => $erreurs_etapes[$e] |
|
| 250 | + ) |
|
| 251 | + ); |
|
| 252 | 252 | |
| 253 | - if ($derniere_etape_ok == $e - 1 and !count($erreurs_etapes[$e])) { |
|
| 254 | - $derniere_etape_ok = $e; |
|
| 255 | - } |
|
| 256 | - // possibilite de poster dans _retour_etape_x ou aller_a_etape |
|
| 257 | - if (!is_null(_request("_retour_etape_$e"))) { |
|
| 258 | - $etape_demandee = $e; |
|
| 259 | - } |
|
| 260 | - // Il se peut que les verifications ait décidé de faire sauter des étapes |
|
| 261 | - if ($aller_a_etape = intval(_request('aller_a_etape'))) { |
|
| 262 | - $etape_demandee = $aller_a_etape; // possibilite de poster un entier dans aller_a_etape |
|
| 263 | - } |
|
| 264 | - } |
|
| 253 | + if ($derniere_etape_ok == $e - 1 and !count($erreurs_etapes[$e])) { |
|
| 254 | + $derniere_etape_ok = $e; |
|
| 255 | + } |
|
| 256 | + // possibilite de poster dans _retour_etape_x ou aller_a_etape |
|
| 257 | + if (!is_null(_request("_retour_etape_$e"))) { |
|
| 258 | + $etape_demandee = $e; |
|
| 259 | + } |
|
| 260 | + // Il se peut que les verifications ait décidé de faire sauter des étapes |
|
| 261 | + if ($aller_a_etape = intval(_request('aller_a_etape'))) { |
|
| 262 | + $etape_demandee = $aller_a_etape; // possibilite de poster un entier dans aller_a_etape |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | |
| 267 | - // si la derniere etape OK etait la derniere |
|
| 268 | - // on renvoie le flux inchange et ca declenche traiter |
|
| 269 | - if ($derniere_etape_ok == $etapes |
|
| 270 | - and (!$etape_demandee or $etape_demandee>=$etapes)) { |
|
| 271 | - return $erreurs; |
|
| 272 | - } else { |
|
| 273 | - $etape = $derniere_etape_ok + 1; |
|
| 274 | - if ($etape_demandee > 0 and $etape_demandee < $etape) { |
|
| 275 | - $etape = $etape_demandee; |
|
| 276 | - } |
|
| 277 | - $etape = min($etape, $etapes); |
|
| 278 | - #var_dump("prochaine etape $etape"); |
|
| 279 | - // retourner les erreurs de l'etape ciblee |
|
| 280 | - $erreurs = isset($erreurs_etapes[$etape]) ? $erreurs_etapes[$etape] : array(); |
|
| 281 | - // Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur ! |
|
| 282 | - if ($erreurs) { |
|
| 283 | - if (!isset($erreurs['message_erreur'])) { |
|
| 284 | - $erreurs['message_erreur'] = singulier_ou_pluriel(count($erreurs), 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie'); |
|
| 285 | - } |
|
| 286 | - } else { |
|
| 287 | - $erreurs['message_erreur'] = ''; |
|
| 288 | - } |
|
| 289 | - $erreurs['_etapes'] = "etape suivante $etape"; |
|
| 290 | - set_request('_etape', $etape); |
|
| 291 | - } |
|
| 292 | - } |
|
| 267 | + // si la derniere etape OK etait la derniere |
|
| 268 | + // on renvoie le flux inchange et ca declenche traiter |
|
| 269 | + if ($derniere_etape_ok == $etapes |
|
| 270 | + and (!$etape_demandee or $etape_demandee>=$etapes)) { |
|
| 271 | + return $erreurs; |
|
| 272 | + } else { |
|
| 273 | + $etape = $derniere_etape_ok + 1; |
|
| 274 | + if ($etape_demandee > 0 and $etape_demandee < $etape) { |
|
| 275 | + $etape = $etape_demandee; |
|
| 276 | + } |
|
| 277 | + $etape = min($etape, $etapes); |
|
| 278 | + #var_dump("prochaine etape $etape"); |
|
| 279 | + // retourner les erreurs de l'etape ciblee |
|
| 280 | + $erreurs = isset($erreurs_etapes[$etape]) ? $erreurs_etapes[$etape] : array(); |
|
| 281 | + // Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur ! |
|
| 282 | + if ($erreurs) { |
|
| 283 | + if (!isset($erreurs['message_erreur'])) { |
|
| 284 | + $erreurs['message_erreur'] = singulier_ou_pluriel(count($erreurs), 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie'); |
|
| 285 | + } |
|
| 286 | + } else { |
|
| 287 | + $erreurs['message_erreur'] = ''; |
|
| 288 | + } |
|
| 289 | + $erreurs['_etapes'] = "etape suivante $etape"; |
|
| 290 | + set_request('_etape', $etape); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - return $erreurs; |
|
| 294 | + return $erreurs; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -303,16 +303,16 @@ discard block |
||
| 303 | 303 | * @return array |
| 304 | 304 | */ |
| 305 | 305 | function cvtmulti_styliser($flux) { |
| 306 | - if (strncmp($flux['args']['fond'], 'formulaires/', 12) == 0 |
|
| 307 | - and isset($flux['args']['contexte']['_etapes']) |
|
| 308 | - and isset($flux['args']['contexte']['_etape']) |
|
| 309 | - and ($e = $flux['args']['contexte']['_etape']) > 1 |
|
| 310 | - and $ext = $flux['args']['ext'] |
|
| 311 | - and $f = $flux['data'] |
|
| 312 | - and file_exists($f . "_$e.$ext") |
|
| 313 | - ) { |
|
| 314 | - $flux['data'] = $f . "_$e"; |
|
| 315 | - } |
|
| 306 | + if (strncmp($flux['args']['fond'], 'formulaires/', 12) == 0 |
|
| 307 | + and isset($flux['args']['contexte']['_etapes']) |
|
| 308 | + and isset($flux['args']['contexte']['_etape']) |
|
| 309 | + and ($e = $flux['args']['contexte']['_etape']) > 1 |
|
| 310 | + and $ext = $flux['args']['ext'] |
|
| 311 | + and $f = $flux['data'] |
|
| 312 | + and file_exists($f . "_$e.$ext") |
|
| 313 | + ) { |
|
| 314 | + $flux['data'] = $f . "_$e"; |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - return $flux; |
|
| 317 | + return $flux; |
|
| 318 | 318 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $_id = $e['id_table_objet']; |
| 51 | 51 | if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
| 52 | 52 | $table = $e['table_objet_sql']; |
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=".intval($id)); |
|
| 54 | 54 | if (isset($row['id_rubrique'])) { |
| 55 | 55 | $contexte['id_rubrique'] = $row['id_rubrique']; |
| 56 | 56 | if (isset($row['id_secteur'])) { |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
| 112 | 112 | + array( |
| 113 | 113 | $id => new Bouton( |
| 114 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 115 | - $infos['titre'], // titre |
|
| 114 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 115 | + $infos['titre'], // titre |
|
| 116 | 116 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 117 | 117 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 118 | 118 | ) |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | $boutons_admin = array_slice($boutons_admin, 0, $position) |
| 129 | 129 | + array( |
| 130 | 130 | $id => new Bouton( |
| 131 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 132 | - $infos['titre'], // titre |
|
| 131 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 132 | + $infos['titre'], // titre |
|
| 133 | 133 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 134 | 134 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 135 | 135 | ) |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $libelles = $isfavoris = $favoris = array(); |
| 171 | 171 | foreach ($menu->sousmenu as $key => $item) { |
| 172 | 172 | $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
| 173 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 173 | + $isfavoris[$key] = (bool) $item->favori; |
|
| 174 | 174 | $favoris[$key] = $item->favori; |
| 175 | 175 | } |
| 176 | 176 | if ($avec_favoris) { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $url = str_replace('&', '&', $url); |
| 213 | 213 | while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
| 214 | 214 | if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
| 215 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 215 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 216 | 216 | } |
| 217 | 217 | $val = _request($matches[2], $contexte); |
| 218 | 218 | $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
@@ -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/boutons'); |
@@ -37,33 +37,33 @@ discard block |
||
| 37 | 37 | * Contexte |
| 38 | 38 | **/ |
| 39 | 39 | function definir_barre_contexte($contexte = null) { |
| 40 | - if (is_null($contexte)) { |
|
| 41 | - $contexte = $_GET; |
|
| 42 | - } elseif (is_string($contexte)) { |
|
| 43 | - $contexte = unserialize($contexte); |
|
| 44 | - } |
|
| 45 | - if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | - if (!function_exists('trouver_objet_exec')) { |
|
| 47 | - include_spip('inc/pipelines_ecrire'); |
|
| 48 | - } |
|
| 49 | - if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | - $_id = $e['id_table_objet']; |
|
| 51 | - if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | - $table = $e['table_objet_sql']; |
|
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | - if (isset($row['id_rubrique'])) { |
|
| 55 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | - if (isset($row['id_secteur'])) { |
|
| 57 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | - } |
|
| 59 | - } elseif (isset($row['id_groupe'])) { |
|
| 60 | - // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | - $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $contexte; |
|
| 40 | + if (is_null($contexte)) { |
|
| 41 | + $contexte = $_GET; |
|
| 42 | + } elseif (is_string($contexte)) { |
|
| 43 | + $contexte = unserialize($contexte); |
|
| 44 | + } |
|
| 45 | + if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | + if (!function_exists('trouver_objet_exec')) { |
|
| 47 | + include_spip('inc/pipelines_ecrire'); |
|
| 48 | + } |
|
| 49 | + if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | + $_id = $e['id_table_objet']; |
|
| 51 | + if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | + $table = $e['table_objet_sql']; |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | + if (isset($row['id_rubrique'])) { |
|
| 55 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | + if (isset($row['id_secteur'])) { |
|
| 57 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | + } |
|
| 59 | + } elseif (isset($row['id_groupe'])) { |
|
| 60 | + // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | + $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $contexte; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -79,88 +79,88 @@ discard block |
||
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | 81 | function definir_barre_boutons($contexte = array(), $icones = true, $autorise = true) { |
| 82 | - include_spip('inc/autoriser'); |
|
| 83 | - $boutons_admin = array(); |
|
| 82 | + include_spip('inc/autoriser'); |
|
| 83 | + $boutons_admin = array(); |
|
| 84 | 84 | |
| 85 | - // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | - $liste_boutons = array(); |
|
| 85 | + // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | + $liste_boutons = array(); |
|
| 87 | 87 | |
| 88 | - // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | - if (function_exists('boutons_plugins') |
|
| 90 | - and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 91 | - ) { |
|
| 92 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 93 | - } |
|
| 88 | + // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | + if (function_exists('boutons_plugins') |
|
| 90 | + and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 91 | + ) { |
|
| 92 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - foreach ($liste_boutons as $id => $infos) { |
|
| 96 | - $parent = ''; |
|
| 97 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 98 | - if (!isset($infos['parent']) |
|
| 99 | - or !($parent = $infos['parent']) |
|
| 100 | - or !$autorise |
|
| 101 | - or autoriser('menu', "_$id", 0, null, array('contexte' => $contexte)) |
|
| 102 | - ) { |
|
| 103 | - if ($parent |
|
| 104 | - and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 105 | - and isset($boutons_admin[$parent]) |
|
| 106 | - ) { |
|
| 107 | - if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 108 | - $boutons_admin[$parent]->sousmenu = array(); |
|
| 109 | - } |
|
| 110 | - $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 111 | - if ($position < 0) { |
|
| 112 | - $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 113 | - } |
|
| 114 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 115 | - + array( |
|
| 116 | - $id => new Bouton( |
|
| 117 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 118 | - $infos['titre'], // titre |
|
| 119 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 120 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 121 | - ) |
|
| 122 | - ) |
|
| 123 | - + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 124 | - } |
|
| 125 | - if (!$parent |
|
| 126 | - // provisoire, eviter les vieux boutons |
|
| 127 | - and (!in_array($id, array('forum', 'statistiques_visites'))) |
|
| 128 | - and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, array('contexte' => $contexte))) |
|
| 129 | - ) { |
|
| 130 | - $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 131 | - $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 132 | - + array( |
|
| 133 | - $id => new Bouton( |
|
| 134 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 135 | - $infos['titre'], // titre |
|
| 136 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 137 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 138 | - ) |
|
| 139 | - ) |
|
| 140 | - + array_slice($boutons_admin, $position, 100); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 95 | + foreach ($liste_boutons as $id => $infos) { |
|
| 96 | + $parent = ''; |
|
| 97 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 98 | + if (!isset($infos['parent']) |
|
| 99 | + or !($parent = $infos['parent']) |
|
| 100 | + or !$autorise |
|
| 101 | + or autoriser('menu', "_$id", 0, null, array('contexte' => $contexte)) |
|
| 102 | + ) { |
|
| 103 | + if ($parent |
|
| 104 | + and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 105 | + and isset($boutons_admin[$parent]) |
|
| 106 | + ) { |
|
| 107 | + if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 108 | + $boutons_admin[$parent]->sousmenu = array(); |
|
| 109 | + } |
|
| 110 | + $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 111 | + if ($position < 0) { |
|
| 112 | + $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 113 | + } |
|
| 114 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 115 | + + array( |
|
| 116 | + $id => new Bouton( |
|
| 117 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 118 | + $infos['titre'], // titre |
|
| 119 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 120 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 121 | + ) |
|
| 122 | + ) |
|
| 123 | + + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 124 | + } |
|
| 125 | + if (!$parent |
|
| 126 | + // provisoire, eviter les vieux boutons |
|
| 127 | + and (!in_array($id, array('forum', 'statistiques_visites'))) |
|
| 128 | + and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, array('contexte' => $contexte))) |
|
| 129 | + ) { |
|
| 130 | + $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 131 | + $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 132 | + + array( |
|
| 133 | + $id => new Bouton( |
|
| 134 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 135 | + $infos['titre'], // titre |
|
| 136 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 137 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 138 | + ) |
|
| 139 | + ) |
|
| 140 | + + array_slice($boutons_admin, $position, 100); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 145 | 145 | |
| 146 | - // définir les favoris et positions d’origine |
|
| 147 | - if ($boutons_admin) { |
|
| 148 | - $menus_favoris = obtenir_menus_favoris(); |
|
| 149 | - $i = 1; |
|
| 150 | - foreach ($boutons_admin as $key => $menu) { |
|
| 151 | - $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 152 | - $menu->position = $i++; |
|
| 153 | - if ($menu->sousmenu) { |
|
| 154 | - $j = 1; |
|
| 155 | - foreach ($menu->sousmenu as $key => $bouton) { |
|
| 156 | - $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 157 | - $bouton->position = $j++; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 146 | + // définir les favoris et positions d’origine |
|
| 147 | + if ($boutons_admin) { |
|
| 148 | + $menus_favoris = obtenir_menus_favoris(); |
|
| 149 | + $i = 1; |
|
| 150 | + foreach ($boutons_admin as $key => $menu) { |
|
| 151 | + $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 152 | + $menu->position = $i++; |
|
| 153 | + if ($menu->sousmenu) { |
|
| 154 | + $j = 1; |
|
| 155 | + foreach ($menu->sousmenu as $key => $bouton) { |
|
| 156 | + $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 157 | + $bouton->position = $j++; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - return $boutons_admin; |
|
| 163 | + return $boutons_admin; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -172,22 +172,22 @@ discard block |
||
| 172 | 172 | * @return Bouton[] |
| 173 | 173 | */ |
| 174 | 174 | function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) { |
| 175 | - foreach ($menus as $menu) { |
|
| 176 | - if ($menu->sousmenu) { |
|
| 177 | - $libelles = $isfavoris = $favoris = array(); |
|
| 178 | - foreach ($menu->sousmenu as $key => $item) { |
|
| 179 | - $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 180 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 181 | - $favoris[$key] = $item->favori; |
|
| 182 | - } |
|
| 183 | - if ($avec_favoris) { |
|
| 184 | - array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 185 | - } else { |
|
| 186 | - array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - return $menus; |
|
| 175 | + foreach ($menus as $menu) { |
|
| 176 | + if ($menu->sousmenu) { |
|
| 177 | + $libelles = $isfavoris = $favoris = array(); |
|
| 178 | + foreach ($menu->sousmenu as $key => $item) { |
|
| 179 | + $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 180 | + $isfavoris[$key] = (bool)$item->favori; |
|
| 181 | + $favoris[$key] = $item->favori; |
|
| 182 | + } |
|
| 183 | + if ($avec_favoris) { |
|
| 184 | + array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 185 | + } else { |
|
| 186 | + array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + return $menus; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return Bouton[] |
| 199 | 199 | */ |
| 200 | 200 | function trier_boutons_enfants_par_favoris_alpha($menus) { |
| 201 | - return trier_boutons_enfants_par_alpha($menus, true); |
|
| 201 | + return trier_boutons_enfants_par_alpha($menus, true); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -211,23 +211,23 @@ discard block |
||
| 211 | 211 | * @return string |
| 212 | 212 | */ |
| 213 | 213 | function bandeau_creer_url($url, $args = '', $contexte = null) { |
| 214 | - if (!preg_match(',[\/\?],', $url)) { |
|
| 215 | - $url = generer_url_ecrire($url, $args, true); |
|
| 216 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 217 | - // &truc=@machin@ |
|
| 218 | - // @machin@ etant remplace par _request('machin') |
|
| 219 | - $url = str_replace('&', '&', $url); |
|
| 220 | - while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 221 | - if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 222 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 223 | - } |
|
| 224 | - $val = _request($matches[2], $contexte); |
|
| 225 | - $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 226 | - } |
|
| 227 | - $url = str_replace('&', '&', $url); |
|
| 228 | - } |
|
| 214 | + if (!preg_match(',[\/\?],', $url)) { |
|
| 215 | + $url = generer_url_ecrire($url, $args, true); |
|
| 216 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 217 | + // &truc=@machin@ |
|
| 218 | + // @machin@ etant remplace par _request('machin') |
|
| 219 | + $url = str_replace('&', '&', $url); |
|
| 220 | + while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 221 | + if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 222 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 223 | + } |
|
| 224 | + $val = _request($matches[2], $contexte); |
|
| 225 | + $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 226 | + } |
|
| 227 | + $url = str_replace('&', '&', $url); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - return $url; |
|
| 230 | + return $url; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * Code HTML du bandeau |
| 238 | 238 | */ |
| 239 | 239 | function inc_bandeau_dist() { |
| 240 | - return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 240 | + return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | 248 | function obtenir_menus_favoris() { |
| 249 | - if ( |
|
| 250 | - isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 251 | - and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 252 | - and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 253 | - ) { |
|
| 254 | - return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 255 | - } |
|
| 256 | - $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 257 | - return $definir_menus_favoris(); |
|
| 249 | + if ( |
|
| 250 | + isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 251 | + and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 252 | + and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 253 | + ) { |
|
| 254 | + return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 255 | + } |
|
| 256 | + $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 257 | + return $definir_menus_favoris(); |
|
| 258 | 258 | } |
| 259 | 259 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | * @param array $opt |
| 25 | 25 | */ |
| 26 | 26 | function inc_journal_dist($phrase, $opt = array()) { |
| 27 | - if (!strlen($phrase)) { |
|
| 28 | - return; |
|
| 29 | - } |
|
| 30 | - if ($opt) { |
|
| 31 | - $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt)); |
|
| 32 | - } |
|
| 33 | - spip_log($phrase, 'journal'); |
|
| 27 | + if (!strlen($phrase)) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 30 | + if ($opt) { |
|
| 31 | + $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt)); |
|
| 32 | + } |
|
| 33 | + spip_log($phrase, 'journal'); |
|
| 34 | 34 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | 30 | if ($opt) { |
| 31 | - $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt)); |
|
| 31 | + $phrase .= ' :: '.str_replace("\n", ' ', join(', ', $opt)); |
|
| 32 | 32 | } |
| 33 | 33 | spip_log($phrase, 'journal'); |
| 34 | 34 | } |
@@ -144,11 +144,13 @@ |
||
| 144 | 144 | |
| 145 | 145 | // creer l'<option> pour la rubrique $root |
| 146 | 146 | |
| 147 | - if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 147 | + if (isset($data[$root])) { |
|
| 148 | + # pas de racine sauf pour les rubriques |
|
| 148 | 149 | { |
| 149 | 150 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 150 | 151 | . $data[$root] |
| 151 | 152 | . '</option>' . "\n"; |
| 153 | + } |
|
| 152 | 154 | } else { |
| 153 | 155 | $r = ''; |
| 154 | 156 | } |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_SPIP_SELECT_RUBRIQUES')) { |
| 25 | - /** |
|
| 26 | - * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | - * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | - * mettre 100000 pour desactiver ajax |
|
| 29 | - */ |
|
| 30 | - define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 25 | + /** |
|
| 26 | + * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | + * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | + * mettre 100000 pour desactiver ajax |
|
| 29 | + */ |
|
| 30 | + define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | * Code HTML du sélecteur |
| 56 | 56 | **/ |
| 57 | 57 | function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 58 | - if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Mode sans Ajax : |
|
| 63 | - // - soit parce que le cookie ajax n'est pas la |
|
| 64 | - // - soit parce qu'il y a peu de rubriques |
|
| 65 | - if (_SPIP_AJAX < 1 |
|
| 66 | - or $type == 'breve' |
|
| 67 | - or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 68 | - ) { |
|
| 69 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 70 | - } else { |
|
| 71 | - return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 72 | - } |
|
| 58 | + if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Mode sans Ajax : |
|
| 63 | + // - soit parce que le cookie ajax n'est pas la |
|
| 64 | + // - soit parce qu'il y a peu de rubriques |
|
| 65 | + if (_SPIP_AJAX < 1 |
|
| 66 | + or $type == 'breve' |
|
| 67 | + or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 68 | + ) { |
|
| 69 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 70 | + } else { |
|
| 71 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | **/ |
| 88 | 88 | function style_menu_rubriques($i) { |
| 89 | 89 | |
| 90 | - $espace = ''; |
|
| 91 | - $style = ''; |
|
| 92 | - for ($count = 1; $count <= $i; $count++) { |
|
| 93 | - $espace .= " "; |
|
| 94 | - } |
|
| 95 | - if ($i == 1) { |
|
| 96 | - $espace = ""; |
|
| 97 | - } |
|
| 98 | - $class = "niveau_$i"; |
|
| 99 | - |
|
| 100 | - return array($class, $style, $espace); |
|
| 90 | + $espace = ''; |
|
| 91 | + $style = ''; |
|
| 92 | + for ($count = 1; $count <= $i; $count++) { |
|
| 93 | + $espace .= " "; |
|
| 94 | + } |
|
| 95 | + if ($i == 1) { |
|
| 96 | + $espace = ""; |
|
| 97 | + } |
|
| 98 | + $class = "niveau_$i"; |
|
| 99 | + |
|
| 100 | + return array($class, $style, $espace); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -121,52 +121,52 @@ discard block |
||
| 121 | 121 | * Code HTML du sélecteur |
| 122 | 122 | **/ |
| 123 | 123 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 124 | - static $decalage_secteur; |
|
| 125 | - |
|
| 126 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | - if ($exclus > 0 |
|
| 128 | - and $root == $exclus |
|
| 129 | - ) { |
|
| 130 | - return ''; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 134 | - |
|
| 135 | - // selected ? |
|
| 136 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 137 | - |
|
| 138 | - // le style en fonction de la profondeur |
|
| 139 | - list($class, $style, $espace) = style_menu_rubriques($niv); |
|
| 140 | - |
|
| 141 | - $class .= " selec_rub"; |
|
| 142 | - |
|
| 143 | - // creer l'<option> pour la rubrique $root |
|
| 144 | - |
|
| 145 | - if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 146 | - { |
|
| 147 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | - . $data[$root] |
|
| 149 | - . '</option>' . "\n"; |
|
| 150 | - } else { |
|
| 151 | - $r = ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // et le sous-menu pour ses enfants |
|
| 155 | - $sous = ''; |
|
| 156 | - if (isset($enfants[$root])) { |
|
| 157 | - foreach ($enfants[$root] as $sousrub) { |
|
| 158 | - $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
|
| 159 | - $niv + 1, $data, $enfants, $exclus, $restreint, $type); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 164 | - if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 165 | - return $sous; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // et voila le travail |
|
| 169 | - return $r . $sous; |
|
| 124 | + static $decalage_secteur; |
|
| 125 | + |
|
| 126 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | + if ($exclus > 0 |
|
| 128 | + and $root == $exclus |
|
| 129 | + ) { |
|
| 130 | + return ''; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 134 | + |
|
| 135 | + // selected ? |
|
| 136 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 137 | + |
|
| 138 | + // le style en fonction de la profondeur |
|
| 139 | + list($class, $style, $espace) = style_menu_rubriques($niv); |
|
| 140 | + |
|
| 141 | + $class .= " selec_rub"; |
|
| 142 | + |
|
| 143 | + // creer l'<option> pour la rubrique $root |
|
| 144 | + |
|
| 145 | + if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 146 | + { |
|
| 147 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | + . $data[$root] |
|
| 149 | + . '</option>' . "\n"; |
|
| 150 | + } else { |
|
| 151 | + $r = ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // et le sous-menu pour ses enfants |
|
| 155 | + $sous = ''; |
|
| 156 | + if (isset($enfants[$root])) { |
|
| 157 | + foreach ($enfants[$root] as $sousrub) { |
|
| 158 | + $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
|
| 159 | + $niv + 1, $data, $enfants, $exclus, $restreint, $type); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 164 | + if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 165 | + return $sous; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // et voila le travail |
|
| 169 | + return $r . $sous; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -187,67 +187,67 @@ discard block |
||
| 187 | 187 | * Code HTML du sélecteur |
| 188 | 188 | **/ |
| 189 | 189 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
| 190 | - $data = array(); |
|
| 191 | - if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 192 | - $data[0] = _T('info_racine_site'); |
|
| 193 | - } |
|
| 194 | - # premier choix = neant |
|
| 195 | - # si auteur (rubriques restreintes) |
|
| 196 | - # ou si creation avec id_rubrique=0 |
|
| 197 | - elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 198 | - $data[0] = ' '; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // |
|
| 202 | - // creer une structure contenant toute l'arborescence |
|
| 203 | - // |
|
| 204 | - |
|
| 205 | - include_spip('base/abstract_sql'); |
|
| 206 | - $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", |
|
| 207 | - ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 208 | - while ($r = sql_fetch($q)) { |
|
| 209 | - if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 210 | - // titre largeur maxi a 50 |
|
| 211 | - $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50); |
|
| 212 | - if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 213 | - and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0) |
|
| 214 | - ) { |
|
| 215 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 216 | - } |
|
| 217 | - $data[$r['id_rubrique']] = $titre; |
|
| 218 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 219 | - if ($id_rubrique == $r['id_rubrique']) { |
|
| 220 | - $id_parent = $r['id_parent']; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // si une seule rubrique comme choix possible, |
|
| 226 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 227 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 228 | - if (count($data) == 2 |
|
| 229 | - and isset($data[0]) |
|
| 230 | - and !in_array($type, array('auteur', 'rubrique')) |
|
| 231 | - and !$id_rubrique |
|
| 232 | - ) { |
|
| 233 | - unset($data[0]); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 238 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 239 | - |
|
| 240 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 241 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 242 | - } else { |
|
| 243 | - $r = "<select" . $att . " size='1'>\n$opt</select>\n"; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - # message pour neuneus (a supprimer ?) |
|
| 190 | + $data = array(); |
|
| 191 | + if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 192 | + $data[0] = _T('info_racine_site'); |
|
| 193 | + } |
|
| 194 | + # premier choix = neant |
|
| 195 | + # si auteur (rubriques restreintes) |
|
| 196 | + # ou si creation avec id_rubrique=0 |
|
| 197 | + elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 198 | + $data[0] = ' '; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // |
|
| 202 | + // creer une structure contenant toute l'arborescence |
|
| 203 | + // |
|
| 204 | + |
|
| 205 | + include_spip('base/abstract_sql'); |
|
| 206 | + $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", |
|
| 207 | + ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 208 | + while ($r = sql_fetch($q)) { |
|
| 209 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 210 | + // titre largeur maxi a 50 |
|
| 211 | + $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50); |
|
| 212 | + if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 213 | + and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0) |
|
| 214 | + ) { |
|
| 215 | + $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 216 | + } |
|
| 217 | + $data[$r['id_rubrique']] = $titre; |
|
| 218 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 219 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 220 | + $id_parent = $r['id_parent']; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // si une seule rubrique comme choix possible, |
|
| 226 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 227 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 228 | + if (count($data) == 2 |
|
| 229 | + and isset($data[0]) |
|
| 230 | + and !in_array($type, array('auteur', 'rubrique')) |
|
| 231 | + and !$id_rubrique |
|
| 232 | + ) { |
|
| 233 | + unset($data[0]); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 238 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 239 | + |
|
| 240 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 241 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 242 | + } else { |
|
| 243 | + $r = "<select" . $att . " size='1'>\n$opt</select>\n"; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + # message pour neuneus (a supprimer ?) |
|
| 247 | 247 | # if ($type != 'auteur' AND $type != 'breve') |
| 248 | 248 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 249 | 249 | |
| 250 | - return $r; |
|
| 250 | + return $r; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -281,26 +281,26 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 283 | 283 | |
| 284 | - if ($id_rubrique) { |
|
| 285 | - $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
| 286 | - } else { |
|
| 287 | - if ($type == 'auteur') { |
|
| 288 | - $titre = ' '; |
|
| 289 | - } else { |
|
| 290 | - $titre = _T('info_racine_site'); |
|
| 291 | - } |
|
| 292 | - } |
|
| 284 | + if ($id_rubrique) { |
|
| 285 | + $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
| 286 | + } else { |
|
| 287 | + if ($type == 'auteur') { |
|
| 288 | + $titre = ' '; |
|
| 289 | + } else { |
|
| 290 | + $titre = _T('info_racine_site'); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 295 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 294 | + $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 295 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 296 | 296 | |
| 297 | - $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 298 | - . (!$idem ? '' : "&exclus=$idem") |
|
| 299 | - . ($restreint ? "" : "&racine=oui") |
|
| 300 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 297 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 298 | + . (!$idem ? '' : "&exclus=$idem") |
|
| 299 | + . ($restreint ? "" : "&racine=oui") |
|
| 300 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 303 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -330,30 +330,30 @@ discard block |
||
| 330 | 330 | * Code HTML du sélecteur de rubrique AJAX |
| 331 | 331 | **/ |
| 332 | 332 | function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
| 333 | - $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 334 | - // si icone de recherche on embed le svg |
|
| 335 | - $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 336 | - $img_icone = $balise(chemin_image($icone, _T('titre_image_selecteur'))); |
|
| 337 | - |
|
| 338 | - return |
|
| 339 | - "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 340 | - . $js |
|
| 341 | - . " jQuery(this).toggleClass('toggled'); " |
|
| 342 | - . "return charger_node_url_si_vide('" |
|
| 343 | - . $url |
|
| 344 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 345 | - . $img_icone |
|
| 346 | - . "</a><img src='" |
|
| 347 | - . chemin_image('loader.svg') |
|
| 348 | - . "' class='loader' id='img_" |
|
| 349 | - . $idom |
|
| 350 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 351 | - . "<input id='titreparent' name='titreparent' class='text'" |
|
| 352 | - . $init |
|
| 353 | - . " />" |
|
| 354 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 355 | - . $id |
|
| 356 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 357 | - . $idom |
|
| 358 | - . "'\nstyle='display: none;'></div>"; |
|
| 333 | + $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 334 | + // si icone de recherche on embed le svg |
|
| 335 | + $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 336 | + $img_icone = $balise(chemin_image($icone, _T('titre_image_selecteur'))); |
|
| 337 | + |
|
| 338 | + return |
|
| 339 | + "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 340 | + . $js |
|
| 341 | + . " jQuery(this).toggleClass('toggled'); " |
|
| 342 | + . "return charger_node_url_si_vide('" |
|
| 343 | + . $url |
|
| 344 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 345 | + . $img_icone |
|
| 346 | + . "</a><img src='" |
|
| 347 | + . chemin_image('loader.svg') |
|
| 348 | + . "' class='loader' id='img_" |
|
| 349 | + . $idom |
|
| 350 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 351 | + . "<input id='titreparent' name='titreparent' class='text'" |
|
| 352 | + . $init |
|
| 353 | + . " />" |
|
| 354 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 355 | + . $id |
|
| 356 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 357 | + . $idom |
|
| 358 | + . "'\nstyle='display: none;'></div>"; |
|
| 359 | 359 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 148 | 148 | . $data[$root] |
| 149 | - . '</option>' . "\n"; |
|
| 149 | + . '</option>'."\n"; |
|
| 150 | 150 | } else { |
| 151 | 151 | $r = ''; |
| 152 | 152 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // et voila le travail |
| 169 | - return $r . $sous; |
|
| 169 | + return $r.$sous; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -208,11 +208,11 @@ discard block |
||
| 208 | 208 | while ($r = sql_fetch($q)) { |
| 209 | 209 | if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
| 210 | 210 | // titre largeur maxi a 50 |
| 211 | - $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50); |
|
| 211 | + $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
|
| 212 | 212 | if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 213 | 213 | and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0) |
| 214 | 214 | ) { |
| 215 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 215 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 216 | 216 | } |
| 217 | 217 | $data[$r['id_rubrique']] = $titre; |
| 218 | 218 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 239 | 239 | |
| 240 | 240 | if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
| 241 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 241 | + $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2]; |
|
| 242 | 242 | } else { |
| 243 | - $r = "<select" . $att . " size='1'>\n$opt</select>\n"; |
|
| 243 | + $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | # message pour neuneus (a supprimer ?) |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 283 | 283 | |
| 284 | 284 | if ($id_rubrique) { |
| 285 | - $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
| 285 | + $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 286 | 286 | } else { |
| 287 | 287 | if ($type == 'auteur') { |
| 288 | 288 | $titre = ' '; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 295 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 295 | + $init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'"; |
|
| 296 | 296 | |
| 297 | 297 | $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
| 298 | 298 | . (!$idem ? '' : "&exclus=$idem") |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | . " jQuery(this).toggleClass('toggled'); " |
| 342 | 342 | . "return charger_node_url_si_vide('" |
| 343 | 343 | . $url |
| 344 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 344 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>" |
|
| 345 | 345 | . $img_icone |
| 346 | 346 | . "</a><img src='" |
| 347 | 347 | . chemin_image('loader.svg') |
@@ -20,21 +20,21 @@ |
||
| 20 | 20 | * Retourne la liste des menus favoris par défaut ainsi que leur rang |
| 21 | 21 | */ |
| 22 | 22 | function inc_definir_menus_favoris_dist() { |
| 23 | - $liste = array( |
|
| 23 | + $liste = array( |
|
| 24 | 24 | |
| 25 | - // Menu Édition, |
|
| 26 | - 'auteurs' => 1, |
|
| 27 | - 'rubriques' => 2, |
|
| 28 | - 'articles' => 3, |
|
| 25 | + // Menu Édition, |
|
| 26 | + 'auteurs' => 1, |
|
| 27 | + 'rubriques' => 2, |
|
| 28 | + 'articles' => 3, |
|
| 29 | 29 | |
| 30 | - // Menu Maintenance |
|
| 31 | - 'admin_vider' => 1, |
|
| 30 | + // Menu Maintenance |
|
| 31 | + 'admin_vider' => 1, |
|
| 32 | 32 | |
| 33 | - // Menu Configurations |
|
| 34 | - 'configurer_identite' => 1, |
|
| 35 | - 'admin_plugin' => 2, |
|
| 33 | + // Menu Configurations |
|
| 34 | + 'configurer_identite' => 1, |
|
| 35 | + 'admin_plugin' => 2, |
|
| 36 | 36 | |
| 37 | - ); |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - return $liste; |
|
| 39 | + return $liste; |
|
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | include_spip('base/objets'); |
| 24 | 24 | |
@@ -58,114 +58,114 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | */ |
| 60 | 60 | function urls_decoder_url($url, $fond = '', $contexte = array(), $assembler = false) { |
| 61 | - static $current_base = null; |
|
| 61 | + static $current_base = null; |
|
| 62 | 62 | |
| 63 | - // les anciennes fonctions modifient directement les globales |
|
| 64 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 65 | - $save = array( |
|
| 66 | - isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, |
|
| 67 | - isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, |
|
| 68 | - isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, |
|
| 69 | - isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, |
|
| 70 | - $GLOBALS['profondeur_url'] |
|
| 71 | - ); |
|
| 63 | + // les anciennes fonctions modifient directement les globales |
|
| 64 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 65 | + $save = array( |
|
| 66 | + isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, |
|
| 67 | + isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, |
|
| 68 | + isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, |
|
| 69 | + isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, |
|
| 70 | + $GLOBALS['profondeur_url'] |
|
| 71 | + ); |
|
| 72 | 72 | |
| 73 | - if (is_null($current_base)) { |
|
| 74 | - include_spip('inc/filtres_mini'); |
|
| 75 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 76 | - $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); |
|
| 77 | - } |
|
| 78 | - if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 79 | - $url = substr($url, strlen($current_base)); |
|
| 80 | - } |
|
| 73 | + if (is_null($current_base)) { |
|
| 74 | + include_spip('inc/filtres_mini'); |
|
| 75 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 76 | + $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); |
|
| 77 | + } |
|
| 78 | + if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 79 | + $url = substr($url, strlen($current_base)); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // si on est en train d'assembler la page principale, |
|
| 83 | - // recuperer l'url depuis les globales url propres si fournies |
|
| 84 | - // sinon extraire la bonne portion d'url |
|
| 85 | - if ($assembler) { |
|
| 86 | - if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 87 | - $url = $_SERVER['REDIRECT_url_propre']; |
|
| 88 | - } elseif (isset($_ENV['url_propre'])) { |
|
| 89 | - $url = $_ENV['url_propre']; |
|
| 90 | - } else { |
|
| 91 | - $qs = explode("?", $url); |
|
| 92 | - // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 93 | - $url = ltrim($qs[0], '/'); |
|
| 94 | - $url = explode('/', $url); |
|
| 95 | - while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 96 | - array_shift($url); |
|
| 97 | - } |
|
| 98 | - $qs[0] = implode('/', $url); |
|
| 99 | - $url = implode("?", $qs); |
|
| 100 | - } |
|
| 101 | - } |
|
| 82 | + // si on est en train d'assembler la page principale, |
|
| 83 | + // recuperer l'url depuis les globales url propres si fournies |
|
| 84 | + // sinon extraire la bonne portion d'url |
|
| 85 | + if ($assembler) { |
|
| 86 | + if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 87 | + $url = $_SERVER['REDIRECT_url_propre']; |
|
| 88 | + } elseif (isset($_ENV['url_propre'])) { |
|
| 89 | + $url = $_ENV['url_propre']; |
|
| 90 | + } else { |
|
| 91 | + $qs = explode("?", $url); |
|
| 92 | + // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 93 | + $url = ltrim($qs[0], '/'); |
|
| 94 | + $url = explode('/', $url); |
|
| 95 | + while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 96 | + array_shift($url); |
|
| 97 | + } |
|
| 98 | + $qs[0] = implode('/', $url); |
|
| 99 | + $url = implode("?", $qs); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 104 | - unset($_ENV['url_propre']); |
|
| 105 | - include_spip('inc/filtres_mini'); |
|
| 106 | - if (strpos($url, "://") === false) { |
|
| 107 | - $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 108 | - } else { |
|
| 109 | - $GLOBALS['profondeur_url'] = max(0, substr_count($url, "/") - substr_count($current_base, "/")); |
|
| 110 | - } |
|
| 103 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 104 | + unset($_ENV['url_propre']); |
|
| 105 | + include_spip('inc/filtres_mini'); |
|
| 106 | + if (strpos($url, "://") === false) { |
|
| 107 | + $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 108 | + } else { |
|
| 109 | + $GLOBALS['profondeur_url'] = max(0, substr_count($url, "/") - substr_count($current_base, "/")); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - $url_redirect = ""; |
|
| 113 | - $renommer = generer_url_entite('', '', '', '', true); |
|
| 114 | - if (!$renommer and !function_exists('recuperer_parametres_url')) { |
|
| 115 | - $renommer = charger_fonction('page', 'urls'); |
|
| 116 | - } // fallback pour decoder l'url |
|
| 117 | - if ($renommer) { |
|
| 118 | - $a = $renommer($url, $fond, $contexte); |
|
| 119 | - if (is_array($a)) { |
|
| 120 | - list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 121 | - if ($url_redirect == $url) { |
|
| 122 | - $url_redirect = ""; |
|
| 123 | - } // securite pour eviter une redirection infinie |
|
| 124 | - if ($assembler and strlen($url_redirect)) { |
|
| 125 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 126 | - include_spip('inc/headers'); |
|
| 127 | - redirige_par_entete($url_redirect, '', 301); |
|
| 128 | - } |
|
| 129 | - if (isset($nfond)) { |
|
| 130 | - $fond = $nfond; |
|
| 131 | - } else { |
|
| 132 | - if ($fond == '' |
|
| 133 | - or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 134 | - ) { |
|
| 135 | - $fond = $type; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - if (isset($ncontexte)) { |
|
| 139 | - $contexte = $ncontexte; |
|
| 140 | - } |
|
| 141 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 142 | - $contexte['type'] = $type; |
|
| 143 | - } |
|
| 144 | - if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 145 | - $contexte['type-page'] = $type; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } // compatibilite <= 1.9.2 |
|
| 149 | - elseif (function_exists('recuperer_parametres_url')) { |
|
| 150 | - $GLOBALS['fond'] = $fond; |
|
| 151 | - $GLOBALS['contexte'] = $contexte; |
|
| 152 | - recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 153 | - // fond est en principe modifiee directement |
|
| 154 | - $contexte = $GLOBALS['contexte']; |
|
| 155 | - } |
|
| 112 | + $url_redirect = ""; |
|
| 113 | + $renommer = generer_url_entite('', '', '', '', true); |
|
| 114 | + if (!$renommer and !function_exists('recuperer_parametres_url')) { |
|
| 115 | + $renommer = charger_fonction('page', 'urls'); |
|
| 116 | + } // fallback pour decoder l'url |
|
| 117 | + if ($renommer) { |
|
| 118 | + $a = $renommer($url, $fond, $contexte); |
|
| 119 | + if (is_array($a)) { |
|
| 120 | + list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 121 | + if ($url_redirect == $url) { |
|
| 122 | + $url_redirect = ""; |
|
| 123 | + } // securite pour eviter une redirection infinie |
|
| 124 | + if ($assembler and strlen($url_redirect)) { |
|
| 125 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 126 | + include_spip('inc/headers'); |
|
| 127 | + redirige_par_entete($url_redirect, '', 301); |
|
| 128 | + } |
|
| 129 | + if (isset($nfond)) { |
|
| 130 | + $fond = $nfond; |
|
| 131 | + } else { |
|
| 132 | + if ($fond == '' |
|
| 133 | + or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 134 | + ) { |
|
| 135 | + $fond = $type; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + if (isset($ncontexte)) { |
|
| 139 | + $contexte = $ncontexte; |
|
| 140 | + } |
|
| 141 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 142 | + $contexte['type'] = $type; |
|
| 143 | + } |
|
| 144 | + if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 145 | + $contexte['type-page'] = $type; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } // compatibilite <= 1.9.2 |
|
| 149 | + elseif (function_exists('recuperer_parametres_url')) { |
|
| 150 | + $GLOBALS['fond'] = $fond; |
|
| 151 | + $GLOBALS['contexte'] = $contexte; |
|
| 152 | + recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 153 | + // fond est en principe modifiee directement |
|
| 154 | + $contexte = $GLOBALS['contexte']; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - // retablir les globales |
|
| 158 | - list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; |
|
| 157 | + // retablir les globales |
|
| 158 | + list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; |
|
| 159 | 159 | |
| 160 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 161 | - // d'inversion url => objet |
|
| 162 | - // maintenir pour compat ? |
|
| 163 | - #if ($assembler) { |
|
| 164 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 165 | - # unset($_ENV['url_propre']); |
|
| 166 | - #} |
|
| 160 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 161 | + // d'inversion url => objet |
|
| 162 | + // maintenir pour compat ? |
|
| 163 | + #if ($assembler) { |
|
| 164 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 165 | + # unset($_ENV['url_propre']); |
|
| 166 | + #} |
|
| 167 | 167 | |
| 168 | - return array($fond, $contexte, $url_redirect); |
|
| 168 | + return array($fond, $contexte, $url_redirect); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | * @return string|array |
| 180 | 180 | */ |
| 181 | 181 | function urls_liste_objets($preg = true) { |
| 182 | - static $url_objets = null; |
|
| 183 | - if (is_null($url_objets)) { |
|
| 184 | - $url_objets = array(); |
|
| 185 | - // recuperer les tables_objets_sql declarees |
|
| 186 | - $tables_objets = lister_tables_objets_sql(); |
|
| 187 | - foreach ($tables_objets as $t => $infos) { |
|
| 188 | - if ($infos['page']) { |
|
| 189 | - $url_objets[] = $infos['type']; |
|
| 190 | - $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 194 | - } |
|
| 195 | - if (!$preg) { |
|
| 196 | - return $url_objets; |
|
| 197 | - } |
|
| 182 | + static $url_objets = null; |
|
| 183 | + if (is_null($url_objets)) { |
|
| 184 | + $url_objets = array(); |
|
| 185 | + // recuperer les tables_objets_sql declarees |
|
| 186 | + $tables_objets = lister_tables_objets_sql(); |
|
| 187 | + foreach ($tables_objets as $t => $infos) { |
|
| 188 | + if ($infos['page']) { |
|
| 189 | + $url_objets[] = $infos['type']; |
|
| 190 | + $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 194 | + } |
|
| 195 | + if (!$preg) { |
|
| 196 | + return $url_objets; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - return implode('|', array_map('preg_quote', $url_objets)); |
|
| 199 | + return implode('|', array_map('preg_quote', $url_objets)); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -210,25 +210,25 @@ discard block |
||
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | 212 | function nettoyer_url_page($url, $contexte = array()) { |
| 213 | - $url_objets = urls_liste_objets(); |
|
| 214 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 213 | + $url_objets = urls_liste_objets(); |
|
| 214 | + $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | + $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 217 | 217 | |
| 218 | - if (preg_match($raccourci_url_page_html, $url, $regs) |
|
| 219 | - or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 220 | - or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 221 | - ) { |
|
| 222 | - $regs = array_pad($regs, 4, null); |
|
| 223 | - $type = objet_type($regs[1]); |
|
| 224 | - $_id = id_table_objet($type); |
|
| 225 | - $contexte[$_id] = $regs[2]; |
|
| 226 | - $suite = $regs[3]; |
|
| 218 | + if (preg_match($raccourci_url_page_html, $url, $regs) |
|
| 219 | + or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 220 | + or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 221 | + ) { |
|
| 222 | + $regs = array_pad($regs, 4, null); |
|
| 223 | + $type = objet_type($regs[1]); |
|
| 224 | + $_id = id_table_objet($type); |
|
| 225 | + $contexte[$_id] = $regs[2]; |
|
| 226 | + $suite = $regs[3]; |
|
| 227 | 227 | |
| 228 | - return array($contexte, $type, null, $type, $suite); |
|
| 229 | - } |
|
| 228 | + return array($contexte, $type, null, $type, $suite); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - return array(); |
|
| 231 | + return array(); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -247,32 +247,32 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | */ |
| 249 | 249 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, $connect = '') { |
| 250 | - static $furls = array(); |
|
| 251 | - if (!isset($furls[$objet])) { |
|
| 252 | - if (function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 253 | - // ou definie par un plugin |
|
| 254 | - or $f = charger_fonction($f, 'urls', true) |
|
| 255 | - ) { |
|
| 256 | - $furls[$objet] = $f; |
|
| 257 | - } else { |
|
| 258 | - $furls[$objet] = ''; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - if ($furls[$objet]) { |
|
| 262 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 263 | - } |
|
| 264 | - // si pas de flag public fourni |
|
| 265 | - // le calculer en fonction de la declaration de statut |
|
| 266 | - if (is_null($public) and !$connect) { |
|
| 267 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 268 | - } |
|
| 269 | - if ($public or $connect) { |
|
| 270 | - return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 271 | - } |
|
| 272 | - $a = id_table_objet($objet) . "=" . intval($id); |
|
| 273 | - if (!function_exists('objet_info')) { |
|
| 274 | - include_spip('inc/filtres'); |
|
| 275 | - } |
|
| 250 | + static $furls = array(); |
|
| 251 | + if (!isset($furls[$objet])) { |
|
| 252 | + if (function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 253 | + // ou definie par un plugin |
|
| 254 | + or $f = charger_fonction($f, 'urls', true) |
|
| 255 | + ) { |
|
| 256 | + $furls[$objet] = $f; |
|
| 257 | + } else { |
|
| 258 | + $furls[$objet] = ''; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + if ($furls[$objet]) { |
|
| 262 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 263 | + } |
|
| 264 | + // si pas de flag public fourni |
|
| 265 | + // le calculer en fonction de la declaration de statut |
|
| 266 | + if (is_null($public) and !$connect) { |
|
| 267 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 268 | + } |
|
| 269 | + if ($public or $connect) { |
|
| 270 | + return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 271 | + } |
|
| 272 | + $a = id_table_objet($objet) . "=" . intval($id); |
|
| 273 | + if (!function_exists('objet_info')) { |
|
| 274 | + include_spip('inc/filtres'); |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 277 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 278 | 278 | } |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function nettoyer_url_page($url, $contexte = array()) { |
| 213 | 213 | $url_objets = urls_liste_objets(); |
| 214 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 214 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,'; |
|
| 217 | 217 | |
| 218 | 218 | if (preg_match($raccourci_url_page_html, $url, $regs) |
| 219 | 219 | or preg_match($raccourci_url_page_id, $url, $regs) |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, $connect = '') { |
| 250 | 250 | static $furls = array(); |
| 251 | 251 | if (!isset($furls[$objet])) { |
| 252 | - if (function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 252 | + if (function_exists($f = 'generer_url_ecrire_'.$objet) |
|
| 253 | 253 | // ou definie par un plugin |
| 254 | 254 | or $f = charger_fonction($f, 'urls', true) |
| 255 | 255 | ) { |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | if ($public or $connect) { |
| 270 | 270 | return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
| 271 | 271 | } |
| 272 | - $a = id_table_objet($objet) . "=" . intval($id); |
|
| 272 | + $a = id_table_objet($objet)."=".intval($id); |
|
| 273 | 273 | if (!function_exists('objet_info')) { |
| 274 | 274 | include_spip('inc/filtres'); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 277 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : ''); |
|
| 278 | 278 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @package SPIP\Core\Drapeaux\Edition |
| 31 | 31 | **/ |
| 32 | 32 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 33 | - return; |
|
| 33 | + return; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -45,46 +45,46 @@ discard block |
||
| 45 | 45 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 46 | 46 | **/ |
| 47 | 47 | function lire_tableau_edition() { |
| 48 | - $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | - if (!$edition) { |
|
| 50 | - return array(); |
|
| 51 | - } |
|
| 52 | - $changed = false; |
|
| 48 | + $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | + if (!$edition) { |
|
| 50 | + return array(); |
|
| 51 | + } |
|
| 52 | + $changed = false; |
|
| 53 | 53 | |
| 54 | - $bon_pour_le_service = time() - 3600; |
|
| 55 | - // parcourir le tableau et virer les vieux |
|
| 56 | - foreach ($edition as $objet => $data) { |
|
| 57 | - if (!is_array($data)) { |
|
| 58 | - unset($edition[$objet]); |
|
| 59 | - } // vieille version |
|
| 60 | - else { |
|
| 61 | - foreach ($data as $id => $tab) { |
|
| 62 | - if (!is_array($tab)) { |
|
| 63 | - unset($edition[$objet][$tab]); |
|
| 64 | - } // vieille version |
|
| 65 | - else { |
|
| 66 | - foreach ($tab as $n => $duo) { |
|
| 67 | - if (current($duo) < $bon_pour_le_service) { |
|
| 68 | - unset($edition[$objet][$id][$n]); |
|
| 69 | - $changed = true; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - if (!$edition[$objet][$id]) { |
|
| 74 | - unset($edition[$objet][$id]); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (!$edition[$objet]) { |
|
| 79 | - unset($edition[$objet]); |
|
| 80 | - } |
|
| 81 | - } |
|
| 54 | + $bon_pour_le_service = time() - 3600; |
|
| 55 | + // parcourir le tableau et virer les vieux |
|
| 56 | + foreach ($edition as $objet => $data) { |
|
| 57 | + if (!is_array($data)) { |
|
| 58 | + unset($edition[$objet]); |
|
| 59 | + } // vieille version |
|
| 60 | + else { |
|
| 61 | + foreach ($data as $id => $tab) { |
|
| 62 | + if (!is_array($tab)) { |
|
| 63 | + unset($edition[$objet][$tab]); |
|
| 64 | + } // vieille version |
|
| 65 | + else { |
|
| 66 | + foreach ($tab as $n => $duo) { |
|
| 67 | + if (current($duo) < $bon_pour_le_service) { |
|
| 68 | + unset($edition[$objet][$id][$n]); |
|
| 69 | + $changed = true; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + if (!$edition[$objet][$id]) { |
|
| 74 | + unset($edition[$objet][$id]); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (!$edition[$objet]) { |
|
| 79 | + unset($edition[$objet]); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($changed) { |
|
| 84 | - ecrire_tableau_edition($edition); |
|
| 85 | - } |
|
| 83 | + if ($changed) { |
|
| 84 | + ecrire_tableau_edition($edition); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $edition; |
|
| 87 | + return $edition; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 98 | 98 | **/ |
| 99 | 99 | function ecrire_tableau_edition($edition) { |
| 100 | - ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 100 | + ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | * Type d'objet édité |
| 118 | 118 | */ |
| 119 | 119 | function signale_edition($id, $auteur, $type = 'article') { |
| 120 | - include_spip('base/objets'); |
|
| 121 | - include_spip('inc/filtres'); |
|
| 122 | - if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | - return; |
|
| 124 | - } |
|
| 120 | + include_spip('base/objets'); |
|
| 121 | + include_spip('inc/filtres'); |
|
| 122 | + if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $edition = lire_tableau_edition(); |
|
| 127 | - if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | - $nom = $auteur['nom']; |
|
| 129 | - } else { |
|
| 130 | - $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | - } |
|
| 126 | + $edition = lire_tableau_edition(); |
|
| 127 | + if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | + $nom = $auteur['nom']; |
|
| 129 | + } else { |
|
| 130 | + $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | - $edition[$type][$id] = array(); |
|
| 135 | - } |
|
| 136 | - $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | - ecrire_tableau_edition($edition); |
|
| 133 | + if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | + $edition[$type][$id] = array(); |
|
| 135 | + } |
|
| 136 | + $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | + ecrire_tableau_edition($edition); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function qui_edite($id, $type = 'article') { |
| 153 | 153 | |
| 154 | - $edition = lire_tableau_edition(); |
|
| 154 | + $edition = lire_tableau_edition(); |
|
| 155 | 155 | |
| 156 | - return empty($edition[$type][$id]) ? array() : $edition[$type][$id]; |
|
| 156 | + return empty($edition[$type][$id]) ? array() : $edition[$type][$id]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | * Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]` |
| 168 | 168 | */ |
| 169 | 169 | function mention_qui_edite($id, $type = 'article') { |
| 170 | - $modif = qui_edite($id, $type); |
|
| 171 | - unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 170 | + $modif = qui_edite($id, $type); |
|
| 171 | + unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 172 | 172 | |
| 173 | - if ($modif) { |
|
| 174 | - $quand = 0; |
|
| 175 | - foreach ($modif as $duo) { |
|
| 176 | - $auteurs[] = typo(key($duo)); |
|
| 177 | - $quand = max($quand, current($duo)); |
|
| 178 | - } |
|
| 173 | + if ($modif) { |
|
| 174 | + $quand = 0; |
|
| 175 | + foreach ($modif as $duo) { |
|
| 176 | + $auteurs[] = typo(key($duo)); |
|
| 177 | + $quand = max($quand, current($duo)); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | - return array( |
|
| 182 | - 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | - 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | - ); |
|
| 185 | - } |
|
| 180 | + // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | + return array( |
|
| 182 | + 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | + 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -196,24 +196,24 @@ discard block |
||
| 196 | 196 | * Liste de tableaux `['objet' => x, 'id_objet' => n]` |
| 197 | 197 | */ |
| 198 | 198 | function liste_drapeau_edition($id_auteur) { |
| 199 | - $edition = lire_tableau_edition(); |
|
| 200 | - $objets_ouverts = array(); |
|
| 199 | + $edition = lire_tableau_edition(); |
|
| 200 | + $objets_ouverts = array(); |
|
| 201 | 201 | |
| 202 | - foreach ($edition as $objet => $data) { |
|
| 203 | - foreach ($data as $id => $auteurs) { |
|
| 204 | - if (isset($auteurs[$id_auteur]) |
|
| 205 | - and is_array($auteurs[$id_auteur]) // precaution |
|
| 206 | - and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 207 | - ) { |
|
| 208 | - $objets_ouverts[] = array( |
|
| 209 | - 'objet' => $objet, |
|
| 210 | - 'id_objet' => $id, |
|
| 211 | - ); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - } |
|
| 202 | + foreach ($edition as $objet => $data) { |
|
| 203 | + foreach ($data as $id => $auteurs) { |
|
| 204 | + if (isset($auteurs[$id_auteur]) |
|
| 205 | + and is_array($auteurs[$id_auteur]) // precaution |
|
| 206 | + and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 207 | + ) { |
|
| 208 | + $objets_ouverts[] = array( |
|
| 209 | + 'objet' => $objet, |
|
| 210 | + 'id_objet' => $id, |
|
| 211 | + ); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - return $objets_ouverts; |
|
| 216 | + return $objets_ouverts; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -226,15 +226,15 @@ discard block |
||
| 226 | 226 | * @return void |
| 227 | 227 | */ |
| 228 | 228 | function debloquer_tous($id_auteur) { |
| 229 | - $edition = lire_tableau_edition(); |
|
| 230 | - foreach ($edition as $objet => $data) { |
|
| 231 | - foreach ($data as $id => $auteurs) { |
|
| 232 | - if (isset($auteurs[$id_auteur])) { |
|
| 233 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 234 | - ecrire_tableau_edition($edition); |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - } |
|
| 229 | + $edition = lire_tableau_edition(); |
|
| 230 | + foreach ($edition as $objet => $data) { |
|
| 231 | + foreach ($data as $id => $auteurs) { |
|
| 232 | + if (isset($auteurs[$id_auteur])) { |
|
| 233 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 234 | + ecrire_tableau_edition($edition); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -252,18 +252,18 @@ discard block |
||
| 252 | 252 | * @return void |
| 253 | 253 | */ |
| 254 | 254 | function debloquer_edition($id_auteur, $id_objet, $type = 'article') { |
| 255 | - $edition = lire_tableau_edition(); |
|
| 255 | + $edition = lire_tableau_edition(); |
|
| 256 | 256 | |
| 257 | - foreach ($edition as $objet => $data) { |
|
| 258 | - if ($objet == $type) { |
|
| 259 | - foreach ($data as $id => $auteurs) { |
|
| 260 | - if ($id == $id_objet |
|
| 261 | - and isset($auteurs[$id_auteur]) |
|
| 262 | - ) { |
|
| 263 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 264 | - ecrire_tableau_edition($edition); |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 257 | + foreach ($edition as $objet => $data) { |
|
| 258 | + if ($objet == $type) { |
|
| 259 | + foreach ($data as $id => $auteurs) { |
|
| 260 | + if ($id == $id_objet |
|
| 261 | + and isset($auteurs[$id_auteur]) |
|
| 262 | + ) { |
|
| 263 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 264 | + ecrire_tableau_edition($edition); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | function surligner_mots($page, $surcharge_surligne = '') { |
| 54 | 54 | $surlignejs_engines = array( |
| 55 | 55 | array( |
| 56 | - "," . str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']) . ",i", |
|
| 56 | + ",".str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']).",i", |
|
| 57 | 57 | ",recherche=([^&]+),i" |
| 58 | 58 | ), //SPIP |
| 59 | 59 | array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google |
@@ -89,20 +89,20 @@ discard block |
||
| 89 | 89 | //good referrer found or var_recherche is not null |
| 90 | 90 | include_spip('inc/filtres'); |
| 91 | 91 | $script = " |
| 92 | - <script type='text/javascript' src='" . url_absolue(find_in_path('javascript/SearchHighlight.js')) . "'></script> |
|
| 92 | + <script type='text/javascript' src='" . url_absolue(find_in_path('javascript/SearchHighlight.js'))."'></script> |
|
| 93 | 93 | <script type='text/javascript'>/*<![CDATA[*/ |
| 94 | 94 | if (window.jQuery) |
| 95 | 95 | (function(\$){\$(function(){ |
| 96 | 96 | \$(document).SearchHighlight({ |
| 97 | - tag_name:'" . (html5_permis() ? 'mark' : 'span') . "', |
|
| 97 | + tag_name:'" . (html5_permis() ? 'mark' : 'span')."', |
|
| 98 | 98 | style_name:'spip_surligne', |
| 99 | 99 | exact:'whole', |
| 100 | 100 | style_name_suffix:false, |
| 101 | - engines:[/^" . str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']) . "/i,/recherche=([^&]+)/i], |
|
| 101 | + engines:[/^" . str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site'])."/i,/recherche=([^&]+)/i], |
|
| 102 | 102 | highlight:'.surlignable', |
| 103 | 103 | nohighlight:'.pas_surlignable'" . |
| 104 | 104 | ($surcharge_surligne ? ", |
| 105 | - keys:'$surcharge_surligne'" : "") . ", |
|
| 105 | + keys:'$surcharge_surligne'" : "").", |
|
| 106 | 106 | min_length: 3 |
| 107 | 107 | }) |
| 108 | 108 | }); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Surligne |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -35,44 +35,44 @@ discard block |
||
| 35 | 35 | * Page HTML |
| 36 | 36 | **/ |
| 37 | 37 | function surligner_mots($page, $surcharge_surligne = '') { |
| 38 | - $surlignejs_engines = array( |
|
| 39 | - array( |
|
| 40 | - "," . str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']) . ",i", |
|
| 41 | - ",recherche=([^&]+),i" |
|
| 42 | - ), //SPIP |
|
| 43 | - array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google |
|
| 44 | - array(",^http://(www\.)?search\.yahoo\.,i", ",p=([^&]+),i"), // Yahoo |
|
| 45 | - array(",^http://(www\.)?search\.msn\.,i", ",q=([^&]+),i"), // MSN |
|
| 46 | - array(",^http://(www\.)?search\.live\.,i", ",query=([^&]+),i"), // MSN Live |
|
| 47 | - array(",^http://(www\.)?search\.aol\.,i", ",userQuery=([^&]+),i"), // AOL |
|
| 48 | - array(",^http://(www\.)?ask\.com,i", ",q=([^&]+),i"), // Ask.com |
|
| 49 | - array(",^http://(www\.)?altavista\.,i", ",q=([^&]+),i"), // AltaVista |
|
| 50 | - array(",^http://(www\.)?feedster\.,i", ",q=([^&]+),i"), // Feedster |
|
| 51 | - array(",^http://(www\.)?search\.lycos\.,i", ",q=([^&]+),i"), // Lycos |
|
| 52 | - array(",^http://(www\.)?alltheweb\.,i", ",q=([^&]+),i"), // AllTheWeb |
|
| 53 | - array(",^http://(www\.)?technorati\.com,i", ",([^\?\/]+)(?:\?.*)$,i"), // Technorati |
|
| 54 | - ); |
|
| 38 | + $surlignejs_engines = array( |
|
| 39 | + array( |
|
| 40 | + "," . str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']) . ",i", |
|
| 41 | + ",recherche=([^&]+),i" |
|
| 42 | + ), //SPIP |
|
| 43 | + array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google |
|
| 44 | + array(",^http://(www\.)?search\.yahoo\.,i", ",p=([^&]+),i"), // Yahoo |
|
| 45 | + array(",^http://(www\.)?search\.msn\.,i", ",q=([^&]+),i"), // MSN |
|
| 46 | + array(",^http://(www\.)?search\.live\.,i", ",query=([^&]+),i"), // MSN Live |
|
| 47 | + array(",^http://(www\.)?search\.aol\.,i", ",userQuery=([^&]+),i"), // AOL |
|
| 48 | + array(",^http://(www\.)?ask\.com,i", ",q=([^&]+),i"), // Ask.com |
|
| 49 | + array(",^http://(www\.)?altavista\.,i", ",q=([^&]+),i"), // AltaVista |
|
| 50 | + array(",^http://(www\.)?feedster\.,i", ",q=([^&]+),i"), // Feedster |
|
| 51 | + array(",^http://(www\.)?search\.lycos\.,i", ",q=([^&]+),i"), // Lycos |
|
| 52 | + array(",^http://(www\.)?alltheweb\.,i", ",q=([^&]+),i"), // AllTheWeb |
|
| 53 | + array(",^http://(www\.)?technorati\.com,i", ",([^\?\/]+)(?:\?.*)$,i"), // Technorati |
|
| 54 | + ); |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
| 58 | - //avoid a js injection |
|
| 59 | - if ($surcharge_surligne) { |
|
| 60 | - $surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", "$1\\\\$2", $surcharge_surligne); |
|
| 61 | - $surcharge_surligne = str_replace("\\", "\\\\", $surcharge_surligne); |
|
| 62 | - if ($GLOBALS['meta']['charset'] == 'utf-8') { |
|
| 63 | - include_spip('inc/charsets'); |
|
| 64 | - if (!is_utf8($surcharge_surligne)) { |
|
| 65 | - $surcharge_surligne = utf8_encode($surcharge_surligne); |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - $surcharge_surligne = preg_replace(',\*$,', '', trim($surcharge_surligne)); # supprimer un * final |
|
| 69 | - } |
|
| 70 | - foreach ($surlignejs_engines as $engine) { |
|
| 71 | - if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))) { |
|
| 57 | + $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
| 58 | + //avoid a js injection |
|
| 59 | + if ($surcharge_surligne) { |
|
| 60 | + $surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", "$1\\\\$2", $surcharge_surligne); |
|
| 61 | + $surcharge_surligne = str_replace("\\", "\\\\", $surcharge_surligne); |
|
| 62 | + if ($GLOBALS['meta']['charset'] == 'utf-8') { |
|
| 63 | + include_spip('inc/charsets'); |
|
| 64 | + if (!is_utf8($surcharge_surligne)) { |
|
| 65 | + $surcharge_surligne = utf8_encode($surcharge_surligne); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + $surcharge_surligne = preg_replace(',\*$,', '', trim($surcharge_surligne)); # supprimer un * final |
|
| 69 | + } |
|
| 70 | + foreach ($surlignejs_engines as $engine) { |
|
| 71 | + if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))) { |
|
| 72 | 72 | |
| 73 | - //good referrer found or var_recherche is not null |
|
| 74 | - include_spip('inc/filtres'); |
|
| 75 | - $script = " |
|
| 73 | + //good referrer found or var_recherche is not null |
|
| 74 | + include_spip('inc/filtres'); |
|
| 75 | + $script = " |
|
| 76 | 76 | <script type='text/javascript' src='" . url_absolue(find_in_path('javascript/SearchHighlight.js')) . "'></script> |
| 77 | 77 | <script type='text/javascript'>/*<![CDATA[*/ |
| 78 | 78 | if (window.jQuery) |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | engines:[/^" . str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']) . "/i,/recherche=([^&]+)/i], |
| 86 | 86 | highlight:'.surlignable', |
| 87 | 87 | nohighlight:'.pas_surlignable'" . |
| 88 | - ($surcharge_surligne ? ", |
|
| 88 | + ($surcharge_surligne ? ", |
|
| 89 | 89 | keys:'$surcharge_surligne'" : "") . ", |
| 90 | 90 | min_length: 3 |
| 91 | 91 | }) |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | })(jQuery); |
| 94 | 94 | /*]]>*/</script> |
| 95 | 95 | "; |
| 96 | - // on l'insere juste avant </head>, sinon tout en bas |
|
| 97 | - if (is_null($l = strpos($page, '</head>'))) { |
|
| 98 | - $l = strlen($page); |
|
| 99 | - } |
|
| 100 | - $page = substr_replace($page, $script, $l, 0); |
|
| 101 | - break; |
|
| 102 | - } |
|
| 103 | - } |
|
| 96 | + // on l'insere juste avant </head>, sinon tout en bas |
|
| 97 | + if (is_null($l = strpos($page, '</head>'))) { |
|
| 98 | + $l = strlen($page); |
|
| 99 | + } |
|
| 100 | + $page = substr_replace($page, $script, $l, 0); |
|
| 101 | + break; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $page; |
|
| 105 | + return $page; |
|
| 106 | 106 | } |
@@ -171,10 +171,12 @@ |
||
| 171 | 171 | |
| 172 | 172 | if (!autoriser('chargerftp') |
| 173 | 173 | or $type == 'logos' |
| 174 | - ) # on ne le permet pas pour les logos |
|
| 174 | + ) { |
|
| 175 | + # on ne le permet pas pour les logos |
|
| 175 | 176 | { |
| 176 | 177 | return false; |
| 177 | 178 | } |
| 179 | + } |
|
| 178 | 180 | |
| 179 | 181 | $repertoire = _DIR_TRANSFERT; |
| 180 | 182 | if (!@is_dir($repertoire)) { |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | $dest = preg_replace(',-r(90|180|270)$,', '', $dest); |
| 141 | 141 | |
| 142 | 142 | // Si le document "source" est deja au bon endroit, ne rien faire |
| 143 | - if ($source == ($dir . $dest . '.' . $ext)) { |
|
| 143 | + if ($source == ($dir.$dest.'.'.$ext)) { |
|
| 144 | 144 | return $source; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // sinon tourner jusqu'a trouver un numero correct |
| 148 | 148 | $n = 0; |
| 149 | - while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) { |
|
| 149 | + while (@file_exists($newFile = $dir.$dest.($n++ ? ('-'.$n) : '').'.'.$ext)) { |
|
| 150 | 150 | ; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | function deplacer_fichier_upload($source, $dest, $move = false) { |
| 208 | 208 | // Securite |
| 209 | 209 | if (substr($dest, 0, strlen(_DIR_RACINE)) == _DIR_RACINE) { |
| 210 | - $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen(_DIR_RACINE))); |
|
| 210 | + $dest = _DIR_RACINE.preg_replace(',\.\.+,', '.', substr($dest, strlen(_DIR_RACINE))); |
|
| 211 | 211 | } else { |
| 212 | 212 | $dest = preg_replace(',\.\.+,', '.', $dest); |
| 213 | 213 | } |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | default: /* autre */ |
| 286 | 286 | if (!$msg) { |
| 287 | - $msg = _T('pass_erreur') . ' ' . $error |
|
| 288 | - . '<br />' . propre("[->http://php.net/manual/fr/features.file-upload.errors.php]"); |
|
| 287 | + $msg = _T('pass_erreur').' '.$error |
|
| 288 | + . '<br />'.propre("[->http://php.net/manual/fr/features.file-upload.errors.php]"); |
|
| 289 | 289 | } |
| 290 | 290 | break; |
| 291 | 291 | } |
@@ -302,6 +302,6 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | include_spip('inc/minipres'); |
| 304 | 304 | echo minipres($msg, |
| 305 | - "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>"); |
|
| 305 | + "<div style='text-align: ".$GLOBALS['spip_lang_right']."'><a href='".rawurldecode($GLOBALS['redirect'])."'><button type='button'>"._T('ecrire:bouton_suivant')."</button></a></div>"); |
|
| 306 | 306 | exit; |
| 307 | 307 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @uses _DIR_IMG |
| 44 | 44 | * |
| 45 | 45 | * @param string $fichier |
| 46 | - * @return bool|string |
|
| 46 | + * @return string|false |
|
| 47 | 47 | */ |
| 48 | 48 | function get_spip_doc($fichier) { |
| 49 | 49 | // fichier distant |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param string $orig |
| 131 | 131 | * @param string $source |
| 132 | 132 | * @param string $subdir |
| 133 | - * @return bool|mixed|string |
|
| 133 | + * @return string|false |
|
| 134 | 134 | */ |
| 135 | 135 | function copier_document($ext, $orig, $source, $subdir = null) { |
| 136 | 136 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @uses sous_repertoire() |
| 168 | 168 | * |
| 169 | 169 | * @param string $type |
| 170 | - * @return bool|string |
|
| 170 | + * @return string |
|
| 171 | 171 | */ |
| 172 | 172 | function determine_upload($type = '') { |
| 173 | 173 | if (!function_exists('autoriser')) { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @param bool $move |
| 208 | 208 | * - `true` : on déplace le fichier source vers le fichier de destination |
| 209 | 209 | * - `false` : valeur par défaut. On ne fait que copier le fichier source vers la destination. |
| 210 | - * @return bool|mixed|string |
|
| 210 | + * @return string|false |
|
| 211 | 211 | */ |
| 212 | 212 | function deplacer_fichier_upload($source, $dest, $move = false) { |
| 213 | 213 | // Securite |
@@ -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 | /** |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | function set_spip_doc($fichier) { |
| 33 | - if (strpos($fichier, _DIR_IMG) === 0) { |
|
| 34 | - return substr($fichier, strlen(_DIR_IMG)); |
|
| 35 | - } else { |
|
| 36 | - return $fichier; |
|
| 37 | - } // ex: fichier distant |
|
| 33 | + if (strpos($fichier, _DIR_IMG) === 0) { |
|
| 34 | + return substr($fichier, strlen(_DIR_IMG)); |
|
| 35 | + } else { |
|
| 36 | + return $fichier; |
|
| 37 | + } // ex: fichier distant |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | * @return bool|string |
| 47 | 47 | */ |
| 48 | 48 | function get_spip_doc($fichier) { |
| 49 | - // fichier distant |
|
| 50 | - if (tester_url_absolue($fichier)) { |
|
| 51 | - return $fichier; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // gestion d'erreurs, fichier='' |
|
| 55 | - if (!strlen($fichier)) { |
|
| 56 | - return false; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $fichier = ( |
|
| 60 | - strncmp($fichier, _DIR_IMG, strlen(_DIR_IMG)) != 0 |
|
| 61 | - ) |
|
| 62 | - ? _DIR_IMG . $fichier |
|
| 63 | - : $fichier; |
|
| 64 | - |
|
| 65 | - // fichier normal |
|
| 66 | - return $fichier; |
|
| 49 | + // fichier distant |
|
| 50 | + if (tester_url_absolue($fichier)) { |
|
| 51 | + return $fichier; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // gestion d'erreurs, fichier='' |
|
| 55 | + if (!strlen($fichier)) { |
|
| 56 | + return false; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $fichier = ( |
|
| 60 | + strncmp($fichier, _DIR_IMG, strlen(_DIR_IMG)) != 0 |
|
| 61 | + ) |
|
| 62 | + ? _DIR_IMG . $fichier |
|
| 63 | + : $fichier; |
|
| 64 | + |
|
| 65 | + // fichier normal |
|
| 66 | + return $fichier; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -77,24 +77,24 @@ discard block |
||
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| 79 | 79 | function creer_repertoire_documents($ext) { |
| 80 | - $rep = sous_repertoire(_DIR_IMG, $ext); |
|
| 81 | - |
|
| 82 | - if (!$ext or !$rep) { |
|
| 83 | - spip_log("creer_repertoire_documents '$rep' interdit"); |
|
| 84 | - exit; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 88 | - // par exemple acces_restreint |
|
| 89 | - // sauf pour logo/ utilise pour stocker les logoon et logooff |
|
| 90 | - if (isset($GLOBALS['meta']["creer_htaccess"]) |
|
| 91 | - and $GLOBALS['meta']["creer_htaccess"] == 'oui' |
|
| 92 | - and $ext !== 'logo') { |
|
| 93 | - include_spip('inc/acces'); |
|
| 94 | - verifier_htaccess($rep); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return $rep; |
|
| 80 | + $rep = sous_repertoire(_DIR_IMG, $ext); |
|
| 81 | + |
|
| 82 | + if (!$ext or !$rep) { |
|
| 83 | + spip_log("creer_repertoire_documents '$rep' interdit"); |
|
| 84 | + exit; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 88 | + // par exemple acces_restreint |
|
| 89 | + // sauf pour logo/ utilise pour stocker les logoon et logooff |
|
| 90 | + if (isset($GLOBALS['meta']["creer_htaccess"]) |
|
| 91 | + and $GLOBALS['meta']["creer_htaccess"] == 'oui' |
|
| 92 | + and $ext !== 'logo') { |
|
| 93 | + include_spip('inc/acces'); |
|
| 94 | + verifier_htaccess($rep); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return $rep; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -103,21 +103,21 @@ discard block |
||
| 103 | 103 | * @param string $nom |
| 104 | 104 | */ |
| 105 | 105 | function effacer_repertoire_temporaire($nom) { |
| 106 | - if ($d = opendir($nom)) { |
|
| 107 | - while (($f = readdir($d)) !== false) { |
|
| 108 | - if (is_file("$nom/$f")) { |
|
| 109 | - spip_unlink("$nom/$f"); |
|
| 110 | - } else { |
|
| 111 | - if ($f <> '.' and $f <> '..' |
|
| 112 | - and is_dir("$nom/$f") |
|
| 113 | - ) { |
|
| 114 | - effacer_repertoire_temporaire("$nom/$f"); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - closedir($d); |
|
| 120 | - @rmdir($nom); |
|
| 106 | + if ($d = opendir($nom)) { |
|
| 107 | + while (($f = readdir($d)) !== false) { |
|
| 108 | + if (is_file("$nom/$f")) { |
|
| 109 | + spip_unlink("$nom/$f"); |
|
| 110 | + } else { |
|
| 111 | + if ($f <> '.' and $f <> '..' |
|
| 112 | + and is_dir("$nom/$f") |
|
| 113 | + ) { |
|
| 114 | + effacer_repertoire_temporaire("$nom/$f"); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + closedir($d); |
|
| 120 | + @rmdir($nom); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // |
@@ -134,28 +134,28 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | function copier_document($ext, $orig, $source, $subdir = null) { |
| 136 | 136 | |
| 137 | - $orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc |
|
| 138 | - $dir = creer_repertoire_documents($subdir ? $subdir : $ext); |
|
| 139 | - $dest = preg_replace("/[^.=\w-]+/", "_", |
|
| 140 | - translitteration(preg_replace("/\.([^.]+)$/", "", |
|
| 141 | - preg_replace("/<[^>]*>/", '', basename($orig))))); |
|
| 137 | + $orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc |
|
| 138 | + $dir = creer_repertoire_documents($subdir ? $subdir : $ext); |
|
| 139 | + $dest = preg_replace("/[^.=\w-]+/", "_", |
|
| 140 | + translitteration(preg_replace("/\.([^.]+)$/", "", |
|
| 141 | + preg_replace("/<[^>]*>/", '', basename($orig))))); |
|
| 142 | 142 | |
| 143 | - // ne pas accepter de noms de la forme -r90.jpg qui sont reserves |
|
| 144 | - // pour les images transformees par rotation (action/documenter) |
|
| 145 | - $dest = preg_replace(',-r(90|180|270)$,', '', $dest); |
|
| 143 | + // ne pas accepter de noms de la forme -r90.jpg qui sont reserves |
|
| 144 | + // pour les images transformees par rotation (action/documenter) |
|
| 145 | + $dest = preg_replace(',-r(90|180|270)$,', '', $dest); |
|
| 146 | 146 | |
| 147 | - // Si le document "source" est deja au bon endroit, ne rien faire |
|
| 148 | - if ($source == ($dir . $dest . '.' . $ext)) { |
|
| 149 | - return $source; |
|
| 150 | - } |
|
| 147 | + // Si le document "source" est deja au bon endroit, ne rien faire |
|
| 148 | + if ($source == ($dir . $dest . '.' . $ext)) { |
|
| 149 | + return $source; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - // sinon tourner jusqu'a trouver un numero correct |
|
| 153 | - $n = 0; |
|
| 154 | - while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) { |
|
| 155 | - ; |
|
| 156 | - } |
|
| 152 | + // sinon tourner jusqu'a trouver un numero correct |
|
| 153 | + $n = 0; |
|
| 154 | + while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) { |
|
| 155 | + ; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - return deplacer_fichier_upload($source, $newFile); |
|
| 158 | + return deplacer_fichier_upload($source, $newFile); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -170,28 +170,28 @@ discard block |
||
| 170 | 170 | * @return bool|string |
| 171 | 171 | */ |
| 172 | 172 | function determine_upload($type = '') { |
| 173 | - if (!function_exists('autoriser')) { |
|
| 174 | - include_spip('inc/autoriser'); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - if (!autoriser('chargerftp') |
|
| 178 | - or $type == 'logos' |
|
| 179 | - ) # on ne le permet pas pour les logos |
|
| 180 | - { |
|
| 181 | - return false; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $repertoire = _DIR_TRANSFERT; |
|
| 185 | - if (!@is_dir($repertoire)) { |
|
| 186 | - $repertoire = str_replace(_DIR_TMP, '', $repertoire); |
|
| 187 | - $repertoire = sous_repertoire(_DIR_TMP, $repertoire); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - if (!$GLOBALS['visiteur_session']['restreint']) { |
|
| 191 | - return $repertoire; |
|
| 192 | - } else { |
|
| 193 | - return sous_repertoire($repertoire, $GLOBALS['visiteur_session']['login']); |
|
| 194 | - } |
|
| 173 | + if (!function_exists('autoriser')) { |
|
| 174 | + include_spip('inc/autoriser'); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + if (!autoriser('chargerftp') |
|
| 178 | + or $type == 'logos' |
|
| 179 | + ) # on ne le permet pas pour les logos |
|
| 180 | + { |
|
| 181 | + return false; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $repertoire = _DIR_TRANSFERT; |
|
| 185 | + if (!@is_dir($repertoire)) { |
|
| 186 | + $repertoire = str_replace(_DIR_TMP, '', $repertoire); |
|
| 187 | + $repertoire = sous_repertoire(_DIR_TMP, $repertoire); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + if (!$GLOBALS['visiteur_session']['restreint']) { |
|
| 191 | + return $repertoire; |
|
| 192 | + } else { |
|
| 193 | + return sous_repertoire($repertoire, $GLOBALS['visiteur_session']['login']); |
|
| 194 | + } |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -210,35 +210,35 @@ discard block |
||
| 210 | 210 | * @return bool|mixed|string |
| 211 | 211 | */ |
| 212 | 212 | function deplacer_fichier_upload($source, $dest, $move = false) { |
| 213 | - // Securite |
|
| 214 | - if (substr($dest, 0, strlen(_DIR_RACINE)) == _DIR_RACINE) { |
|
| 215 | - $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen(_DIR_RACINE))); |
|
| 216 | - } else { |
|
| 217 | - $dest = preg_replace(',\.\.+,', '.', $dest); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - if ($move) { |
|
| 221 | - $ok = @rename($source, $dest); |
|
| 222 | - } else { |
|
| 223 | - $ok = @copy($source, $dest); |
|
| 224 | - } |
|
| 225 | - if (!$ok) { |
|
| 226 | - $ok = @move_uploaded_file($source, $dest); |
|
| 227 | - } |
|
| 228 | - if ($ok) { |
|
| 229 | - @chmod($dest, _SPIP_CHMOD & ~0111); |
|
| 230 | - } else { |
|
| 231 | - $f = @fopen($dest, 'w'); |
|
| 232 | - if ($f) { |
|
| 233 | - fclose($f); |
|
| 234 | - } else { |
|
| 235 | - include_spip('inc/flock'); |
|
| 236 | - raler_fichier($dest); |
|
| 237 | - } |
|
| 238 | - spip_unlink($dest); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $ok ? $dest : false; |
|
| 213 | + // Securite |
|
| 214 | + if (substr($dest, 0, strlen(_DIR_RACINE)) == _DIR_RACINE) { |
|
| 215 | + $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen(_DIR_RACINE))); |
|
| 216 | + } else { |
|
| 217 | + $dest = preg_replace(',\.\.+,', '.', $dest); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + if ($move) { |
|
| 221 | + $ok = @rename($source, $dest); |
|
| 222 | + } else { |
|
| 223 | + $ok = @copy($source, $dest); |
|
| 224 | + } |
|
| 225 | + if (!$ok) { |
|
| 226 | + $ok = @move_uploaded_file($source, $dest); |
|
| 227 | + } |
|
| 228 | + if ($ok) { |
|
| 229 | + @chmod($dest, _SPIP_CHMOD & ~0111); |
|
| 230 | + } else { |
|
| 231 | + $f = @fopen($dest, 'w'); |
|
| 232 | + if ($f) { |
|
| 233 | + fclose($f); |
|
| 234 | + } else { |
|
| 235 | + include_spip('inc/flock'); |
|
| 236 | + raler_fichier($dest); |
|
| 237 | + } |
|
| 238 | + spip_unlink($dest); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $ok ? $dest : false; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -262,51 +262,51 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function check_upload_error($error, $msg = '', $return = false) { |
| 264 | 264 | |
| 265 | - if (!$error) { |
|
| 266 | - return false; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - spip_log("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php"); |
|
| 270 | - |
|
| 271 | - switch ($error) { |
|
| 272 | - |
|
| 273 | - case 4: /* UPLOAD_ERR_NO_FILE */ |
|
| 274 | - return true; |
|
| 275 | - |
|
| 276 | - # on peut affiner les differents messages d'erreur |
|
| 277 | - case 1: /* UPLOAD_ERR_INI_SIZE */ |
|
| 278 | - $msg = _T('upload_limit', |
|
| 279 | - array('max' => ini_get('upload_max_filesize'))); |
|
| 280 | - break; |
|
| 281 | - case 2: /* UPLOAD_ERR_FORM_SIZE */ |
|
| 282 | - $msg = _T('upload_limit', |
|
| 283 | - array('max' => ini_get('upload_max_filesize'))); |
|
| 284 | - break; |
|
| 285 | - case 3: /* UPLOAD_ERR_PARTIAL */ |
|
| 286 | - $msg = _T('upload_limit', |
|
| 287 | - array('max' => ini_get('upload_max_filesize'))); |
|
| 288 | - break; |
|
| 289 | - |
|
| 290 | - default: /* autre */ |
|
| 291 | - if (!$msg) { |
|
| 292 | - $msg = _T('pass_erreur') . ' ' . $error |
|
| 293 | - . '<br />' . propre("[->http://php.net/manual/fr/features.file-upload.errors.php]"); |
|
| 294 | - } |
|
| 295 | - break; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - spip_log("erreur upload $error"); |
|
| 299 | - if ($return) { |
|
| 300 | - return $msg; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - if (_request("iframe") == "iframe") { |
|
| 304 | - echo "<div class='upload_answer upload_error'>$msg</div>"; |
|
| 305 | - exit; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - include_spip('inc/minipres'); |
|
| 309 | - echo minipres($msg, |
|
| 310 | - "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>"); |
|
| 311 | - exit; |
|
| 265 | + if (!$error) { |
|
| 266 | + return false; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + spip_log("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php"); |
|
| 270 | + |
|
| 271 | + switch ($error) { |
|
| 272 | + |
|
| 273 | + case 4: /* UPLOAD_ERR_NO_FILE */ |
|
| 274 | + return true; |
|
| 275 | + |
|
| 276 | + # on peut affiner les differents messages d'erreur |
|
| 277 | + case 1: /* UPLOAD_ERR_INI_SIZE */ |
|
| 278 | + $msg = _T('upload_limit', |
|
| 279 | + array('max' => ini_get('upload_max_filesize'))); |
|
| 280 | + break; |
|
| 281 | + case 2: /* UPLOAD_ERR_FORM_SIZE */ |
|
| 282 | + $msg = _T('upload_limit', |
|
| 283 | + array('max' => ini_get('upload_max_filesize'))); |
|
| 284 | + break; |
|
| 285 | + case 3: /* UPLOAD_ERR_PARTIAL */ |
|
| 286 | + $msg = _T('upload_limit', |
|
| 287 | + array('max' => ini_get('upload_max_filesize'))); |
|
| 288 | + break; |
|
| 289 | + |
|
| 290 | + default: /* autre */ |
|
| 291 | + if (!$msg) { |
|
| 292 | + $msg = _T('pass_erreur') . ' ' . $error |
|
| 293 | + . '<br />' . propre("[->http://php.net/manual/fr/features.file-upload.errors.php]"); |
|
| 294 | + } |
|
| 295 | + break; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + spip_log("erreur upload $error"); |
|
| 299 | + if ($return) { |
|
| 300 | + return $msg; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + if (_request("iframe") == "iframe") { |
|
| 304 | + echo "<div class='upload_answer upload_error'>$msg</div>"; |
|
| 305 | + exit; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + include_spip('inc/minipres'); |
|
| 309 | + echo minipres($msg, |
|
| 310 | + "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>"); |
|
| 311 | + exit; |
|
| 312 | 312 | } |