@@ -23,8 +23,8 @@ |
||
| 23 | 23 | $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40; |
| 24 | 24 | $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35; |
| 25 | 25 | |
| 26 | - if (strlen($url)>$long_url) { |
|
| 27 | - $url = substr($url,0,$coupe_url).'...'; |
|
| 26 | + if (strlen($url) > $long_url) { |
|
| 27 | + $url = substr($url, 0, $coupe_url).'...'; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return $url; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | // lier_trad = l'associer a l'article numero $lier_trad |
| 22 | 22 | // new=oui = article a creer si on valide le formulaire |
| 23 | 23 | // http://doc.spip.org/@inc_article_select_dist |
| 24 | -function inc_precharger_article_dist($id_article, $id_rubrique=0, $lier_trad=0) { |
|
| 24 | +function inc_precharger_article_dist($id_article, $id_rubrique = 0, $lier_trad = 0) { |
|
| 25 | 25 | return precharger_objet('article', $id_article, $id_rubrique, $lier_trad, 'titre'); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | // on initialise les donnees de maniere specifique |
| 32 | 32 | // |
| 33 | 33 | // (fonction facultative si pas de changement dans les traitements) |
| 34 | -function inc_precharger_traduction_article_dist($id_article, $id_rubrique=0, $lier_trad=0) { |
|
| 34 | +function inc_precharger_traduction_article_dist($id_article, $id_rubrique = 0, $lier_trad = 0) { |
|
| 35 | 35 | return precharger_traduction_objet('article', $id_article, $id_rubrique, $lier_trad, 'titre'); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param bool $public |
| 31 | 31 | * @return array|string |
| 32 | 32 | */ |
| 33 | -function generer_action_auteur($action, $arg, $redirect = "", $mode = false, $att = '', $public = false){ |
|
| 33 | +function generer_action_auteur($action, $arg, $redirect = "", $mode = false, $att = '', $public = false) { |
|
| 34 | 34 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 35 | 35 | return $securiser_action($action, $arg, $redirect, $mode, $att, $public); |
| 36 | 36 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | // http://doc.spip.org/@redirige_action_auteur |
| 39 | 39 | function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) { |
| 40 | 40 | |
| 41 | - $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) .generer_url_ecrire($ret, $gra, true, true); |
|
| 41 | + $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT).generer_url_ecrire($ret, $gra, true, true); |
|
| 42 | 42 | |
| 43 | 43 | return generer_action_auteur($action, $arg, $r, $mode, $atts, $public); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // http://doc.spip.org/@redirige_action_post |
| 47 | -function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = ''){ |
|
| 47 | +function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') { |
|
| 48 | 48 | $r = _DIR_RESTREINT.generer_url_ecrire($ret, $gra, false, true); |
| 49 | 49 | return generer_action_auteur($action, $arg, $r, $corps, $att." method='post'"); |
| 50 | 50 | } |
@@ -62,21 +62,21 @@ discard block |
||
| 62 | 62 | * La valeur speciale false fournit text/html sans entete xml. Elle equivaut a |
| 63 | 63 | * passer "text/html" comme $content_type |
| 64 | 64 | */ |
| 65 | -function ajax_retour($corps, $content_type = null){ |
|
| 65 | +function ajax_retour($corps, $content_type = null) { |
|
| 66 | 66 | $xml = false; |
| 67 | - if (is_null($content_type) OR $content_type===true){ |
|
| 67 | + if (is_null($content_type) OR $content_type === true) { |
|
| 68 | 68 | $xml = true; |
| 69 | 69 | $content_type = 'text/html'; |
| 70 | 70 | } |
| 71 | - elseif (!$content_type OR !is_string($content_type) OR strpos($content_type,'/')===false) { |
|
| 71 | + elseif (!$content_type OR !is_string($content_type) OR strpos($content_type, '/') === false) { |
|
| 72 | 72 | $content_type = 'text/html'; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $e = ""; |
| 76 | 76 | if (isset($_COOKIE['spip_admin']) |
| 77 | - AND ((_request('var_mode')=='debug') OR !empty($GLOBALS['tableau_des_temps']))) |
|
| 77 | + AND ((_request('var_mode') == 'debug') OR !empty($GLOBALS['tableau_des_temps']))) |
|
| 78 | 78 | $e = erreur_squelette(); |
| 79 | - if (isset($GLOBALS['transformer_xml']) OR (isset($GLOBALS['exec']) AND $GLOBALS['exec']=='valider_xml')){ |
|
| 79 | + if (isset($GLOBALS['transformer_xml']) OR (isset($GLOBALS['exec']) AND $GLOBALS['exec'] == 'valider_xml')) { |
|
| 80 | 80 | $debut = _DOCTYPE_ECRIRE |
| 81 | 81 | ."<html><head><title>Debug Spip Ajax</title></head>" |
| 82 | 82 | ."<body><div>\n\n" |
@@ -71,38 +71,38 @@ discard block |
||
| 71 | 71 | * @param string $form |
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | -function cvtmulti_recuperer_post_precedents($form){ |
|
| 74 | +function cvtmulti_recuperer_post_precedents($form) { |
|
| 75 | 75 | include_spip('inc/filtres'); |
| 76 | 76 | if ($form |
| 77 | 77 | AND $c = _request('cvtm_prev_post') |
| 78 | - AND $c = decoder_contexte_ajax($c, $form)){ |
|
| 78 | + AND $c = decoder_contexte_ajax($c, $form)) { |
|
| 79 | 79 | #var_dump($c); |
| 80 | 80 | |
| 81 | 81 | # reinjecter dans la bonne variable pour permettre de retrouver |
| 82 | 82 | # toutes les saisies dans un seul tableau |
| 83 | - if ($_SERVER['REQUEST_METHOD']=='POST') |
|
| 83 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 84 | 84 | $store = &$_POST; |
| 85 | 85 | else |
| 86 | 86 | $store = &$_GET; |
| 87 | 87 | |
| 88 | - foreach($c as $k=>$v) |
|
| 88 | + foreach ($c as $k=>$v) |
|
| 89 | 89 | // on ecrase pas si saisi a nouveau ! |
| 90 | 90 | if (!isset($store[$k])) |
| 91 | 91 | $_REQUEST[$k] = $store[$k] = $v; |
| 92 | 92 | // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
| 93 | - elseif(is_array($store[$k]) |
|
| 93 | + elseif (is_array($store[$k]) |
|
| 94 | 94 | AND is_array($v) |
| 95 | 95 | AND $z = array_keys($v) |
| 96 | 96 | AND !is_numeric(reset($z)) |
| 97 | 97 | AND $z = array_keys($store[$k]) |
| 98 | 98 | AND !is_numeric(reset($z)) |
| 99 | 99 | ) |
| 100 | - $_REQUEST[$k] = $store[$k] = array_merge($v,$store[$k]); |
|
| 100 | + $_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]); |
|
| 101 | 101 | |
| 102 | 102 | // vider pour eviter un second appel a verifier_n |
| 103 | 103 | // en cas de double implementation (unipotence) |
| 104 | 104 | set_request('cvtm_prev_post'); |
| 105 | - return array($c['_etape'],$c['_etapes']); |
|
| 105 | + return array($c['_etape'], $c['_etapes']); |
|
| 106 | 106 | } |
| 107 | 107 | return false; |
| 108 | 108 | } |
@@ -116,19 +116,19 @@ discard block |
||
| 116 | 116 | * @param array $valeurs |
| 117 | 117 | * @return array |
| 118 | 118 | */ |
| 119 | -function cvtmulti_sauver_post($form, $je_suis_poste, &$valeurs){ |
|
| 120 | - if (!isset($valeurs['_cvtm_prev_post'])){ |
|
| 121 | - $post = array('_etape'=>$valeurs['_etape'],'_etapes'=>$valeurs['_etapes']); |
|
| 122 | - foreach(array_keys($valeurs) as $champ){ |
|
| 123 | - if (substr($champ,0,1)!=='_'){ |
|
| 119 | +function cvtmulti_sauver_post($form, $je_suis_poste, &$valeurs) { |
|
| 120 | + if (!isset($valeurs['_cvtm_prev_post'])) { |
|
| 121 | + $post = array('_etape'=>$valeurs['_etape'], '_etapes'=>$valeurs['_etapes']); |
|
| 122 | + foreach (array_keys($valeurs) as $champ) { |
|
| 123 | + if (substr($champ, 0, 1) !== '_') { |
|
| 124 | 124 | if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
| 125 | - if (($v = _request($champ))!==NULL) |
|
| 125 | + if (($v = _request($champ)) !== NULL) |
|
| 126 | 126 | $post[$champ] = $v; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | include_spip('inc/filtres'); |
| 131 | - $c = encoder_contexte_ajax($post,$form); |
|
| 131 | + $c = encoder_contexte_ajax($post, $form); |
|
| 132 | 132 | if (!isset($valeurs['_hidden'])) |
| 133 | 133 | $valeurs['_hidden'] = ''; |
| 134 | 134 | $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
@@ -146,16 +146,16 @@ discard block |
||
| 146 | 146 | * @param <type> $flux |
| 147 | 147 | * @return <type> |
| 148 | 148 | */ |
| 149 | -function cvtmulti_formulaire_charger($flux){ |
|
| 149 | +function cvtmulti_formulaire_charger($flux) { |
|
| 150 | 150 | #var_dump($flux['data']['_etapes']); |
| 151 | 151 | if (is_array($flux['data']) |
| 152 | - AND isset($flux['data']['_etapes'])){ |
|
| 152 | + AND isset($flux['data']['_etapes'])) { |
|
| 153 | 153 | $form = $flux['args']['form']; |
| 154 | 154 | $je_suis_poste = $flux['args']['je_suis_poste']; |
| 155 | 155 | $nb_etapes = $flux['data']['_etapes']; |
| 156 | 156 | $etape = _request('_etape'); |
| 157 | - $etape = min(max($etape,1),$nb_etapes); |
|
| 158 | - set_request('_etape',$etape); |
|
| 157 | + $etape = min(max($etape, 1), $nb_etapes); |
|
| 158 | + set_request('_etape', $etape); |
|
| 159 | 159 | $flux['data']['_etape'] = $etape; |
| 160 | 160 | |
| 161 | 161 | // sauver les posts de cette etape pour les avoir a la prochaine etape |
@@ -172,30 +172,30 @@ discard block |
||
| 172 | 172 | * @param array $flux |
| 173 | 173 | * @return array |
| 174 | 174 | */ |
| 175 | -function cvtmulti_formulaire_verifier($flux){ |
|
| 175 | +function cvtmulti_formulaire_verifier($flux) { |
|
| 176 | 176 | #var_dump('Pipe verifier'); |
| 177 | 177 | |
| 178 | 178 | if ($form = $flux['args']['form'] |
| 179 | - AND ($e = cvtmulti_recuperer_post_precedents($form))!==false){ |
|
| 179 | + AND ($e = cvtmulti_recuperer_post_precedents($form)) !== false) { |
|
| 180 | 180 | // recuperer l'etape saisie et le nombre d'etapes total |
| 181 | - list($etape,$etapes) = $e; |
|
| 181 | + list($etape, $etapes) = $e; |
|
| 182 | 182 | $etape_demandee = _request('aller_a_etape'); // possibilite de poster en entier dans aller_a_etape |
| 183 | 183 | |
| 184 | 184 | // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
| 185 | 185 | $erreurs = array(); |
| 186 | 186 | $derniere_etape_ok = 0; |
| 187 | 187 | $e = 0; |
| 188 | - while ($e<$etape AND $e<$etapes){ |
|
| 188 | + while ($e < $etape AND $e < $etapes) { |
|
| 189 | 189 | $e++; |
| 190 | 190 | $erreurs[$e] = array(); |
| 191 | - if ($verifier = charger_fonction("verifier_$e","formulaires/$form/",true)) |
|
| 191 | + if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) |
|
| 192 | 192 | $erreurs[$e] = call_user_func_array($verifier, $flux['args']['args']); |
| 193 | - elseif ($verifier = charger_fonction("verifier_etape","formulaires/$form/",true)){ |
|
| 193 | + elseif ($verifier = charger_fonction("verifier_etape", "formulaires/$form/", true)) { |
|
| 194 | 194 | $args = $flux['args']['args']; |
| 195 | 195 | array_unshift($args, $e); |
| 196 | 196 | $erreurs[$e] = call_user_func_array($verifier, $args); |
| 197 | 197 | } |
| 198 | - if ($derniere_etape_ok==$e-1 AND !count($erreurs[$e])) |
|
| 198 | + if ($derniere_etape_ok == $e - 1 AND !count($erreurs[$e])) |
|
| 199 | 199 | $derniere_etape_ok = $e; |
| 200 | 200 | // possibilite de poster dans _retour_etape_x |
| 201 | 201 | if (!is_null(_request("_retour_etape_$e"))) |
@@ -204,19 +204,19 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | // si la derniere etape OK etait la derniere |
| 206 | 206 | // on renvoie le flux inchange et ca declenche traiter |
| 207 | - if ($derniere_etape_ok==$etapes AND !$etape_demandee){ |
|
| 207 | + if ($derniere_etape_ok == $etapes AND !$etape_demandee) { |
|
| 208 | 208 | return $flux; |
| 209 | 209 | } |
| 210 | 210 | else { |
| 211 | - $etape = $derniere_etape_ok+1; |
|
| 212 | - if ($etape_demandee>0 AND $etape_demandee<$etape) |
|
| 211 | + $etape = $derniere_etape_ok + 1; |
|
| 212 | + if ($etape_demandee > 0 AND $etape_demandee < $etape) |
|
| 213 | 213 | $etape = $etape_demandee; |
| 214 | - $etape = min($etape,$etapes); |
|
| 214 | + $etape = min($etape, $etapes); |
|
| 215 | 215 | #var_dump("prochaine etape $etape"); |
| 216 | 216 | // retourner les erreurs de l'etape ciblee |
| 217 | - $flux['data'] = isset($erreurs[$etape]) ? $erreurs[$etape] : array() ; |
|
| 217 | + $flux['data'] = isset($erreurs[$etape]) ? $erreurs[$etape] : array(); |
|
| 218 | 218 | $flux['data']['_etapes'] = "etape suivante $etape"; |
| 219 | - set_request('_etape',$etape); |
|
| 219 | + set_request('_etape', $etape); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | return $flux; |
@@ -230,13 +230,13 @@ discard block |
||
| 230 | 230 | * @param array $flux |
| 231 | 231 | * @return array |
| 232 | 232 | */ |
| 233 | -function cvtmulti_styliser($flux){ |
|
| 234 | - if (strncmp($flux['args']['fond'],'formulaires/',12)==0 |
|
| 233 | +function cvtmulti_styliser($flux) { |
|
| 234 | + if (strncmp($flux['args']['fond'], 'formulaires/', 12) == 0 |
|
| 235 | 235 | AND isset($flux['args']['contexte']['_etapes']) |
| 236 | 236 | AND isset($flux['args']['contexte']['_etape']) |
| 237 | - AND ($e=$flux['args']['contexte']['_etape'])>1 |
|
| 237 | + AND ($e = $flux['args']['contexte']['_etape']) > 1 |
|
| 238 | 238 | AND $ext = $flux['args']['ext'] |
| 239 | - AND $f=$flux['data'] |
|
| 239 | + AND $f = $flux['data'] |
|
| 240 | 240 | AND file_exists($f."_$e.$ext")) |
| 241 | 241 | $flux['data'] = $f."_$e"; |
| 242 | 242 | return $flux; |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | function inc_genie_dist($taches = array()) { |
| 55 | 55 | include_spip('inc/queue'); |
| 56 | 56 | |
| 57 | - if (_request('exec')=='job_queue') |
|
| 57 | + if (_request('exec') == 'job_queue') |
|
| 58 | 58 | return false; |
| 59 | 59 | |
| 60 | 60 | $force_jobs = array(); |
| 61 | 61 | // l'ancienne facon de lancer une tache cron immediatement |
| 62 | 62 | // etait de la passer en parametre a ing_genie_dist |
| 63 | 63 | // on reroute en ajoutant simplement le job a la queue, ASAP |
| 64 | - foreach($taches as $function=>$period) |
|
| 65 | - $force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function'=>$function)), array(time()-abs($period)), "genie/"); |
|
| 64 | + foreach ($taches as $function=>$period) |
|
| 65 | + $force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function'=>$function)), array(time() - abs($period)), "genie/"); |
|
| 66 | 66 | |
| 67 | 67 | // et on passe la main a la gestion de la queue ! |
| 68 | 68 | // en forcant eventuellement les jobs ajoute a l'instant |
| 69 | - return queue_schedule(count($force_jobs)?$force_jobs:null); |
|
| 69 | + return queue_schedule(count($force_jobs) ? $force_jobs : null); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // verifier que toutes les taches cron sont planifiees |
| 84 | 84 | // c'est une tache cron ! |
| 85 | - $taches_generales['queue_watch'] = 3600*24; |
|
| 85 | + $taches_generales['queue_watch'] = 3600 * 24; |
|
| 86 | 86 | |
| 87 | 87 | // MAJ des rubriques publiques (cas de la publication post-datee) |
| 88 | 88 | // est fait au coup par coup a present |
| 89 | 89 | // $taches_generales['rubriques'] = 3600; |
| 90 | 90 | |
| 91 | 91 | // Optimisation de la base |
| 92 | - $taches_generales['optimiser'] = 3600*48; |
|
| 92 | + $taches_generales['optimiser'] = 3600 * 48; |
|
| 93 | 93 | |
| 94 | 94 | // cache (chaque 10 minutes => 1/16eme du repertoire cache, |
| 95 | 95 | // soit toutes les 2h40 sur le meme rep) |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | // nouveautes |
| 99 | 99 | if ($GLOBALS['meta']['adresse_neuf'] AND $GLOBALS['meta']['jours_neuf'] |
| 100 | 100 | AND ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')) |
| 101 | - $taches_generales['mail']= 3600 * 24 * $GLOBALS['meta']['jours_neuf']; |
|
| 101 | + $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf']; |
|
| 102 | 102 | |
| 103 | 103 | // maintenance (ajax, verifications diverses) |
| 104 | 104 | $taches_generales['maintenance'] = 3600 * 2; |
| 105 | 105 | |
| 106 | 106 | // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement) |
| 107 | - $taches_generales['mise_a_jour'] = 3*24*3600; |
|
| 107 | + $taches_generales['mise_a_jour'] = 3 * 24 * 3600; |
|
| 108 | 108 | |
| 109 | - return pipeline('taches_generales_cron',$taches_generales); |
|
| 109 | + return pipeline('taches_generales_cron', $taches_generales); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Pas de fichier a part pour une fonction aussi petite: |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return int |
| 135 | 135 | */ |
| 136 | -function genie_queue_watch_dist(){ |
|
| 136 | +function genie_queue_watch_dist() { |
|
| 137 | 137 | static $deja_la = false; |
| 138 | 138 | if ($deja_la) return; // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple) |
| 139 | 139 | $deja_la = true; |
| 140 | 140 | $taches = taches_generales(); |
| 141 | - $programmees = sql_allfetsel('fonction','spip_jobs',sql_in('fonction',array_keys($taches))); |
|
| 142 | - $programmees = array_map('reset',$programmees); |
|
| 143 | - foreach($taches as $tache=>$periode){ |
|
| 144 | - if (!in_array($tache,$programmees)) |
|
| 145 | - queue_genie_replan_job($tache,$periode,time()-round(rand(1,$periode)),0); |
|
| 141 | + $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches))); |
|
| 142 | + $programmees = array_map('reset', $programmees); |
|
| 143 | + foreach ($taches as $tache=>$periode) { |
|
| 144 | + if (!in_array($tache, $programmees)) |
|
| 145 | + queue_genie_replan_job($tache, $periode, time() - round(rand(1, $periode)), 0); |
|
| 146 | 146 | } |
| 147 | 147 | $deja_la = false; |
| 148 | 148 | return 1; |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | * priorite |
| 166 | 166 | * @return void |
| 167 | 167 | */ |
| 168 | -function queue_genie_replan_job($function,$period,$last=0,$time=null, $priority=0){ |
|
| 168 | +function queue_genie_replan_job($function, $period, $last = 0, $time = null, $priority = 0) { |
|
| 169 | 169 | static $done = array(); |
| 170 | 170 | if (isset($done[$function])) return; |
| 171 | 171 | $done[$function] = true; |
| 172 | - if (is_null($time)){ |
|
| 173 | - $time=time(); |
|
| 172 | + if (is_null($time)) { |
|
| 173 | + $time = time(); |
|
| 174 | 174 | if ($last) |
| 175 | - $time = max($last+$period,$time); |
|
| 175 | + $time = max($last + $period, $time); |
|
| 176 | 176 | } |
| 177 | 177 | if (!$last) |
| 178 | - $last = $time-$period; |
|
| 179 | - spip_log("replan_job $function $period $last $time $priority",'queue'); |
|
| 178 | + $last = $time - $period; |
|
| 179 | + spip_log("replan_job $function $period $last $time $priority", 'queue'); |
|
| 180 | 180 | include_spip('inc/queue'); |
| 181 | 181 | // on replanifie un job cron |
| 182 | 182 | // uniquement si il n'y en a pas deja un avec le meme nom |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | include_spip('inc/boutons'); |
| 16 | 16 | include_spip('base/objets'); |
| 17 | 17 | |
| 18 | -function inc_icone_renommer_dist($fond,$fonction){ |
|
| 18 | +function inc_icone_renommer_dist($fond, $fonction) { |
|
| 19 | 19 | $size = 24; |
| 20 | - if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i",$fond,$match) |
|
| 20 | + if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i", $fond, $match) |
|
| 21 | 21 | AND ((isset($match[0]) AND $match[0]) OR (isset($match[1]) AND $match[1]))) { |
| 22 | 22 | if (isset($match[1]) AND $match[1]) { |
| 23 | 23 | $size = $match[1]; |
| 24 | 24 | } |
| 25 | - $type = substr($fond,0,-strlen($match[0])); |
|
| 25 | + $type = substr($fond, 0, -strlen($match[0])); |
|
| 26 | 26 | if (!isset($match[2]) OR !$match[2]) { |
| 27 | 27 | $fond .= ".png"; |
| 28 | 28 | } |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $rtl = false; |
| 36 | - if (preg_match(',[-_]rtl$,i',$type,$match)){ |
|
| 36 | + if (preg_match(',[-_]rtl$,i', $type, $match)) { |
|
| 37 | 37 | $rtl = true; |
| 38 | - $type = substr($type,0,-strlen($match[0])); |
|
| 38 | + $type = substr($type, 0, -strlen($match[0])); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $dir = "images/"; |
| 46 | 46 | $f = "$type-$size.png"; |
| 47 | - if ($icone = find_in_theme($dir.$f)){ |
|
| 47 | + if ($icone = find_in_theme($dir.$f)) { |
|
| 48 | 48 | $dir = dirname($icone); |
| 49 | 49 | $fond = $icone; |
| 50 | 50 | |
@@ -54,21 +54,21 @@ discard block |
||
| 54 | 54 | $type = "$type-rtl"; |
| 55 | 55 | |
| 56 | 56 | $action = $fonction; |
| 57 | - if ($action=="supprimer.gif"){ |
|
| 57 | + if ($action == "supprimer.gif") { |
|
| 58 | 58 | $action = "del"; |
| 59 | 59 | } |
| 60 | - elseif ($action=="creer.gif"){ |
|
| 60 | + elseif ($action == "creer.gif") { |
|
| 61 | 61 | $action = "new"; |
| 62 | 62 | } |
| 63 | - elseif ($action=="edit.gif"){ |
|
| 63 | + elseif ($action == "edit.gif") { |
|
| 64 | 64 | $action = "edit"; |
| 65 | 65 | } |
| 66 | - if (!in_array($action,array('del','new','edit'))) |
|
| 66 | + if (!in_array($action, array('del', 'new', 'edit'))) |
|
| 67 | 67 | $action = ""; |
| 68 | - if ($action){ |
|
| 68 | + if ($action) { |
|
| 69 | 69 | if ($fa = "$type-$action-$size.png" |
| 70 | - AND file_exists($dir.'/'.$fa)){ |
|
| 71 | - $fond = $dir .'/'. $fa; |
|
| 70 | + AND file_exists($dir.'/'.$fa)) { |
|
| 71 | + $fond = $dir.'/'.$fa; |
|
| 72 | 72 | $fonction = ""; |
| 73 | 73 | } |
| 74 | 74 | else { |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | // c'est bon ! |
| 79 | - return array($fond,$fonction); |
|
| 79 | + return array($fond, $fonction); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - return array($fond,$fonction); |
|
| 82 | + return array($fond, $fonction); |
|
| 83 | 83 | } |
| 84 | 84 | ?> |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | * @return <type> |
| 23 | 23 | */ |
| 24 | 24 | function balise_BOITE_OUVRIR_dist($p) { |
| 25 | - $_titre = interprete_argument_balise(1,$p); |
|
| 26 | - $_class = interprete_argument_balise(2,$p); |
|
| 27 | - $_head_class = interprete_argument_balise(3,$p); |
|
| 28 | - $_titre = ($_titre?$_titre:"''"); |
|
| 29 | - $_class = ($_class?", $_class":", 'simple'"); |
|
| 30 | - $_head_class = ($_head_class?", $_head_class":""); |
|
| 25 | + $_titre = interprete_argument_balise(1, $p); |
|
| 26 | + $_class = interprete_argument_balise(2, $p); |
|
| 27 | + $_head_class = interprete_argument_balise(3, $p); |
|
| 28 | + $_titre = ($_titre ? $_titre : "''"); |
|
| 29 | + $_class = ($_class ? ", $_class" : ", 'simple'"); |
|
| 30 | + $_head_class = ($_head_class ? ", $_head_class" : ""); |
|
| 31 | 31 | |
| 32 | 32 | $f = chercher_filtre('boite_ouvrir'); |
| 33 | 33 | $p->code = "$f($_titre$_class$_head_class)"; |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * @return <type> |
| 44 | 44 | */ |
| 45 | 45 | function balise_BOITE_PIED_dist($p) { |
| 46 | - $_class = interprete_argument_balise(1,$p); |
|
| 47 | - $_class = ($_class?"$_class":""); |
|
| 46 | + $_class = interprete_argument_balise(1, $p); |
|
| 47 | + $_class = ($_class ? "$_class" : ""); |
|
| 48 | 48 | |
| 49 | 49 | $f = chercher_filtre('boite_pied'); |
| 50 | 50 | $p->code = "$f($_class)"; |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | * @param string $class |
| 75 | 75 | * @return <type> |
| 76 | 76 | */ |
| 77 | -function boite_ouvrir($titre, $class='', $head_class='', $id=""){ |
|
| 77 | +function boite_ouvrir($titre, $class = '', $head_class = '', $id = "") { |
|
| 78 | 78 | $class = "box $class"; |
| 79 | 79 | $head_class = "hd $head_class"; |
| 80 | 80 | // dans l'espace prive, titrer en h3 si pas de balise <hn> |
| 81 | - if (test_espace_prive() AND strlen($titre) AND strpos($titre,'<h')===false) |
|
| 81 | + if (test_espace_prive() AND strlen($titre) AND strpos($titre, '<h') === false) |
|
| 82 | 82 | $titre = "<h3>$titre</h3>"; |
| 83 | - return '<div class="'.$class.($id?"\" id=\"$id":"").'">' |
|
| 83 | + return '<div class="'.$class.($id ? "\" id=\"$id" : "").'">' |
|
| 84 | 84 | .'<b class="top"><b class="tl"></b><b class="tr"></b></b>' |
| 85 | 85 | .'<div class="inner">' |
| 86 | - .($titre?'<div class="'.$head_class.'">'.$titre.'<div class="nettoyeur"></div><!--/hd--></div>':'') |
|
| 86 | + .($titre ? '<div class="'.$head_class.'">'.$titre.'<div class="nettoyeur"></div><!--/hd--></div>' : '') |
|
| 87 | 87 | .'<div class="bd">'; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param <type> $class |
| 95 | 95 | * @return <type> |
| 96 | 96 | */ |
| 97 | -function boite_pied($class='act'){ |
|
| 97 | +function boite_pied($class = 'act') { |
|
| 98 | 98 | $class = "ft $class"; |
| 99 | 99 | return '<div class="nettoyeur"></div></div>' |
| 100 | 100 | .'<div class="'.$class.'">'; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return <type> |
| 108 | 108 | */ |
| 109 | -function boite_fermer(){ |
|
| 109 | +function boite_fermer() { |
|
| 110 | 110 | return '<div class="nettoyeur"></div></div></div>' |
| 111 | 111 | .'<b class="bottom"><b class="bl"></b><b class="br"></b></b>' |
| 112 | 112 | .'</div>'; |
@@ -17,20 +17,20 @@ discard block |
||
| 17 | 17 | // en evitant les attaques par la redirection (souvent indique par 1 $_GET) |
| 18 | 18 | |
| 19 | 19 | // http://doc.spip.org/@redirige_par_entete |
| 20 | -function redirige_par_entete($url, $equiv='', $status = 302) { |
|
| 21 | - if (!in_array($status,array(301,302))) |
|
| 20 | +function redirige_par_entete($url, $equiv = '', $status = 302) { |
|
| 21 | + if (!in_array($status, array(301, 302))) |
|
| 22 | 22 | $status = 302; |
| 23 | 23 | |
| 24 | 24 | $url = trim(strtr($url, "\n\r", " ")); |
| 25 | 25 | # en theorie on devrait faire ca tout le temps, mais quand la chaine |
| 26 | 26 | # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
| 27 | - if ($url[0]=='?') |
|
| 27 | + if ($url[0] == '?') |
|
| 28 | 28 | $url = url_de_base().$url; |
| 29 | - if ($url[0]=='#') |
|
| 29 | + if ($url[0] == '#') |
|
| 30 | 30 | $url = self('&').$url; |
| 31 | 31 | # si profondeur non nulle et url relative, il faut la passer en absolue |
| 32 | - if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2) |
|
| 33 | - AND !preg_match(",^(\w+:)?//,",$url)){ |
|
| 32 | + if ($GLOBALS['profondeur_url'] > (_DIR_RESTREINT ? 1 : 2) |
|
| 33 | + AND !preg_match(",^(\w+:)?//,", $url)) { |
|
| 34 | 34 | include_spip("inc/filtres_mini"); |
| 35 | 35 | $url = url_absolue($url); |
| 36 | 36 | } |
@@ -42,30 +42,30 @@ discard block |
||
| 42 | 42 | $url = parametre_url($url, 'var_ajax_redir', 1, '&'); |
| 43 | 43 | |
| 44 | 44 | // ne pas laisser passer n'importe quoi dans l'url |
| 45 | - $url = str_replace(array('<','"'),array('<','"'),$url); |
|
| 45 | + $url = str_replace(array('<', '"'), array('<', '"'), $url); |
|
| 46 | 46 | // interdire les url inline avec des pseudo-protocoles : |
| 47 | 47 | if ( |
| 48 | - (preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url)) |
|
| 49 | - OR preg_match(",(javascript|mailto):,i",$url) |
|
| 48 | + (preg_match(",data:,i", $url) AND preg_match("/base64\s*,/i", $url)) |
|
| 49 | + OR preg_match(",(javascript|mailto):,i", $url) |
|
| 50 | 50 | ) |
| 51 | - $url ="./"; |
|
| 51 | + $url = "./"; |
|
| 52 | 52 | |
| 53 | 53 | // Il n'y a que sous Apache que setcookie puis redirection fonctionne |
| 54 | 54 | include_spip('inc/cookie'); |
| 55 | - if ((!$equiv AND !spip_cookie_envoye()) OR ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'],6)==0) OR defined('_SERVER_APACHE'))) { |
|
| 56 | - @header("Location: " . $url); |
|
| 57 | - $equiv=""; |
|
| 55 | + if ((!$equiv AND !spip_cookie_envoye()) OR ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'], 6) == 0) OR defined('_SERVER_APACHE'))) { |
|
| 56 | + @header("Location: ".$url); |
|
| 57 | + $equiv = ""; |
|
| 58 | 58 | } else { |
| 59 | - @header("Refresh: 0; url=" . $url); |
|
| 59 | + @header("Refresh: 0; url=".$url); |
|
| 60 | 60 | $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>"; |
| 61 | 61 | } |
| 62 | 62 | include_spip('inc/lang'); |
| 63 | - if ($status!=302) |
|
| 63 | + if ($status != 302) |
|
| 64 | 64 | http_status($status); |
| 65 | - echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n", |
|
| 66 | - html_lang_attributes(),' |
|
| 65 | + echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n", |
|
| 66 | + html_lang_attributes(), ' |
|
| 67 | 67 | <head>', |
| 68 | - $equiv,' |
|
| 68 | + $equiv, ' |
|
| 69 | 69 | <title>HTTP '.$status.'</title> |
| 70 | 70 | </head> |
| 71 | 71 | <body> |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // http://doc.spip.org/@redirige_formulaire |
| 85 | -function redirige_formulaire($url, $equiv = '', $format='message') { |
|
| 85 | +function redirige_formulaire($url, $equiv = '', $format = 'message') { |
|
| 86 | 86 | if (!_AJAX |
| 87 | 87 | AND !headers_sent() |
| 88 | 88 | AND !_request('var_ajax')) { |
| 89 | - redirige_par_entete(str_replace('&','&',$url), $equiv); |
|
| 89 | + redirige_par_entete(str_replace('&', '&', $url), $equiv); |
|
| 90 | 90 | } |
| 91 | 91 | // si c'est une ancre, fixer simplement le window.location.hash |
| 92 | - elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) { |
|
| 92 | + elseif ($format == 'ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i', $url)) { |
|
| 93 | 93 | return array( |
| 94 | 94 | // on renvoie un lien masque qui sera traite par ajaxCallback.js |
| 95 | 95 | "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>", |
@@ -98,17 +98,17 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | else { |
| 100 | 100 | // ne pas laisser passer n'importe quoi dans l'url |
| 101 | - $url = str_replace(array('<','"'),array('<','"'),$url); |
|
| 101 | + $url = str_replace(array('<', '"'), array('<', '"'), $url); |
|
| 102 | 102 | |
| 103 | 103 | $url = strtr($url, "\n\r", " "); |
| 104 | 104 | # en theorie on devrait faire ca tout le temps, mais quand la chaine |
| 105 | 105 | # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
| 106 | - if ($url[0]=='?') |
|
| 106 | + if ($url[0] == '?') |
|
| 107 | 107 | $url = url_de_base().$url; |
| 108 | - $url = str_replace('&','&',$url); |
|
| 108 | + $url = str_replace('&', '&', $url); |
|
| 109 | 109 | spip_log("redirige formulaire ajax: $url"); |
| 110 | 110 | include_spip('inc/filtres'); |
| 111 | - if ($format=='ajaxform') |
|
| 111 | + if ($format == 'ajaxform') |
|
| 112 | 112 | return array( |
| 113 | 113 | // on renvoie un lien masque qui sera traite par ajaxCallback.js |
| 114 | 114 | '<a href="'.quote_amp($url).'" name="ajax_redirect" style="display:none;">'._T('navigateur_pas_redirige').'</a>', |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | return |
| 120 | 120 | // ie poste les formulaires dans une iframe, il faut donc rediriger son parent |
| 121 | 121 | "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>" |
| 122 | - . http_img_pack('searching.gif','') |
|
| 122 | + . http_img_pack('searching.gif', '') |
|
| 123 | 123 | . '<br />' |
| 124 | 124 | . '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // http://doc.spip.org/@redirige_url_ecrire |
| 129 | -function redirige_url_ecrire($script='', $args='', $equiv='') { |
|
| 129 | +function redirige_url_ecrire($script = '', $args = '', $equiv = '') { |
|
| 130 | 130 | return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // http://doc.spip.org/@http_no_cache |
| 159 | 159 | function http_no_cache() { |
| 160 | 160 | if (headers_sent()) |
| 161 | - { spip_log("http_no_cache arrive trop tard"); return;} |
|
| 161 | + { spip_log("http_no_cache arrive trop tard"); return; } |
|
| 162 | 162 | $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset']; |
| 163 | 163 | |
| 164 | 164 | // selon http://developer.apple.com/internet/safari/faq.html#anchor5 |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | header("Content-Type: text/html; charset=$charset"); |
| 171 | 171 | header("Expires: 0"); |
| 172 | - header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT"); |
|
| 172 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 173 | 173 | header("Cache-Control: no-cache, must-revalidate"); |
| 174 | 174 | header("Pragma: no-cache"); |
| 175 | 175 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | if (!strlen($phrase)) |
| 26 | 26 | return; |
| 27 | 27 | if ($opt) |
| 28 | - $phrase .= " :: ".str_replace("\n", ' ', join(', ',$opt)); |
|
| 28 | + $phrase .= " :: ".str_replace("\n", ' ', join(', ', $opt)); |
|
| 29 | 29 | spip_log($phrase, 'journal'); |
| 30 | 30 | } |
| 31 | 31 | |