@@ -18,69 +18,69 @@ |
||
| 18 | 18 | $pvirg = substr_count($t, ';'); |
| 19 | 19 | $tab = substr_count($t, "\t"); |
| 20 | 20 | if ($virg > $pvirg) |
| 21 | - { $sep = ','; $hs = ',';} |
|
| 22 | - else { $sep = ';'; $hs = ';'; $virg = $pvirg;} |
|
| 23 | - if ($tab > $virg) {$sep = "\t"; $hs = "\t";} |
|
| 21 | + { $sep = ','; $hs = ','; } |
|
| 22 | + else { $sep = ';'; $hs = ';'; $virg = $pvirg; } |
|
| 23 | + if ($tab > $virg) {$sep = "\t"; $hs = "\t"; } |
|
| 24 | 24 | |
| 25 | 25 | $t = preg_replace('/\r?\n/', "\n", |
| 26 | 26 | preg_replace('/[\r\n]+/', "\n", $t)); |
| 27 | 27 | // un separateur suivi de 3 guillemets attention ! |
| 28 | 28 | // attention au ; suceptible d'etre confondu avec un separateur |
| 29 | 29 | // on substitue un # et on remplacera a la fin |
| 30 | - $t = preg_replace("/([\n$sep])\"\"\"/",'\\1""#',$t); |
|
| 31 | - $t = str_replace('""','"#',$t); |
|
| 30 | + $t = preg_replace("/([\n$sep])\"\"\"/", '\\1""#', $t); |
|
| 31 | + $t = str_replace('""', '"#', $t); |
|
| 32 | 32 | preg_match_all('/"[^"]*"/', $t, $r); |
| 33 | - foreach($r[0] as $cell) |
|
| 33 | + foreach ($r[0] as $cell) |
|
| 34 | 34 | $t = str_replace($cell, |
| 35 | 35 | str_replace($sep, $hs, |
| 36 | 36 | str_replace("\n", "<br />", |
| 37 | - substr($cell,1,-1))), |
|
| 37 | + substr($cell, 1, -1))), |
|
| 38 | 38 | $t); |
| 39 | - list($entete, $corps) = explode("\n",$t,2); |
|
| 39 | + list($entete, $corps) = explode("\n", $t, 2); |
|
| 40 | 40 | $caption = ''; |
| 41 | 41 | // sauter la ligne de tete formee seulement de separateurs |
| 42 | 42 | if (substr_count($entete, $sep) == strlen($entete)) { |
| 43 | - list($entete, $corps) = explode("\n",$corps,2); |
|
| 43 | + list($entete, $corps) = explode("\n", $corps, 2); |
|
| 44 | 44 | } |
| 45 | 45 | // si une seule colonne, en faire le titre |
| 46 | 46 | if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
| 47 | - $caption = "\n||" . $l[1] . "|"; |
|
| 48 | - list($entete, $corps) = explode("\n",$corps,2); |
|
| 47 | + $caption = "\n||".$l[1]."|"; |
|
| 48 | + list($entete, $corps) = explode("\n", $corps, 2); |
|
| 49 | 49 | } |
| 50 | 50 | // si premiere colonne vide, le raccourci doit quand meme produire <th... |
| 51 | - if ($entete[0] == $sep) $entete = ' ' . $entete; |
|
| 51 | + if ($entete[0] == $sep) $entete = ' '.$entete; |
|
| 52 | 52 | |
| 53 | 53 | $lignes = explode("\n", $corps); |
| 54 | 54 | |
| 55 | 55 | // retrait des lignes vides finales |
| 56 | - while(count($lignes) > 0 |
|
| 57 | - AND preg_match("/^$sep*$/", $lignes[count($lignes)-1])) |
|
| 58 | - unset($lignes[count($lignes)-1]); |
|
| 56 | + while (count($lignes) > 0 |
|
| 57 | + AND preg_match("/^$sep*$/", $lignes[count($lignes) - 1])) |
|
| 58 | + unset($lignes[count($lignes) - 1]); |
|
| 59 | 59 | // calcul du nombre de colonne a chaque ligne |
| 60 | 60 | $nbcols = array(); |
| 61 | 61 | $max = $mil = substr_count($entete, $sep); |
| 62 | - foreach($lignes as $k=>$v) { |
|
| 63 | - if ($max <> ($nbcols[$k]= substr_count($v, $sep))) { |
|
| 62 | + foreach ($lignes as $k=>$v) { |
|
| 63 | + if ($max <> ($nbcols[$k] = substr_count($v, $sep))) { |
|
| 64 | 64 | if ($max > $nbcols[$k]) |
| 65 | 65 | $mil = $nbcols[$k]; |
| 66 | - else { $mil = $max; $max = $nbcols[$k];} |
|
| 66 | + else { $mil = $max; $max = $nbcols[$k]; } |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | // Si pas le meme nombre, cadrer au nombre max |
| 70 | 70 | if ($mil <> $max) |
| 71 | - foreach($nbcols as $k=>$v) { |
|
| 72 | - if ($v < $max) $lignes[$k].= str_repeat($sep, $max-$v); |
|
| 71 | + foreach ($nbcols as $k=>$v) { |
|
| 72 | + if ($v < $max) $lignes[$k] .= str_repeat($sep, $max - $v); |
|
| 73 | 73 | } |
| 74 | 74 | // et retirer les colonnes integralement vides |
| 75 | - while(true) { |
|
| 76 | - $nbcols = ($entete[strlen($entete)-1]===$sep); |
|
| 77 | - foreach($lignes as $v) $nbcols &= ($v[strlen($v)-1]===$sep); |
|
| 75 | + while (true) { |
|
| 76 | + $nbcols = ($entete[strlen($entete) - 1] === $sep); |
|
| 77 | + foreach ($lignes as $v) $nbcols &= ($v[strlen($v) - 1] === $sep); |
|
| 78 | 78 | if (!$nbcols) break; |
| 79 | - $entete = substr($entete,0,-1); |
|
| 80 | - foreach($lignes as $k=>$v) $lignes[$k] = substr($v,0,-1); |
|
| 79 | + $entete = substr($entete, 0, -1); |
|
| 80 | + foreach ($lignes as $k=>$v) $lignes[$k] = substr($v, 0, -1); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - foreach($lignes as &$l) { |
|
| 83 | + foreach ($lignes as &$l) { |
|
| 84 | 84 | $l = explode($sep, $l); |
| 85 | 85 | } |
| 86 | 86 | return array(explode($sep, $entete), $lignes); |
@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | return $r[1].resolve_path($r[2]); |
| 51 | 51 | |
| 52 | 52 | # L'url site spip est un lien absolu aussi |
| 53 | - if ($lien == $GLOBALS['meta']['adresse_site']){ |
|
| 53 | + if ($lien == $GLOBALS['meta']['adresse_site']) { |
|
| 54 | 54 | return $lien; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -60,29 +60,29 @@ discard block |
||
| 60 | 60 | $debut = $regs[1]; |
| 61 | 61 | $dir = !strlen($regs[2]) ? '/' : $regs[2]; |
| 62 | 62 | $mot = $regs[3]; |
| 63 | - $get = isset($regs[4])?$regs[4]:""; |
|
| 64 | - $hash = isset($regs[5])?$regs[5]:""; |
|
| 63 | + $get = isset($regs[4]) ? $regs[4] : ""; |
|
| 64 | + $hash = isset($regs[5]) ? $regs[5] : ""; |
|
| 65 | 65 | } |
| 66 | - switch (substr($lien,0,1)) { |
|
| 66 | + switch (substr($lien, 0, 1)) { |
|
| 67 | 67 | case '/': |
| 68 | - return $debut . resolve_path($lien); |
|
| 68 | + return $debut.resolve_path($lien); |
|
| 69 | 69 | case '#': |
| 70 | - return $debut . resolve_path($dir.$mot.$get.$lien); |
|
| 70 | + return $debut.resolve_path($dir.$mot.$get.$lien); |
|
| 71 | 71 | case '': |
| 72 | - return $debut . resolve_path($dir.$mot.$get.$hash); |
|
| 72 | + return $debut.resolve_path($dir.$mot.$get.$hash); |
|
| 73 | 73 | default: |
| 74 | - return $debut . resolve_path($dir.$lien); |
|
| 74 | + return $debut.resolve_path($dir.$lien); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // un filtre pour transformer les URLs relatives en URLs absolues ; |
| 79 | 79 | // ne s'applique qu'aux #URL_XXXX |
| 80 | 80 | // http://doc.spip.org/@url_absolue |
| 81 | -function url_absolue($url, $base='') { |
|
| 81 | +function url_absolue($url, $base = '') { |
|
| 82 | 82 | if (strlen($url = trim($url)) == 0) |
| 83 | 83 | return ''; |
| 84 | 84 | if (!$base) |
| 85 | - $base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : ''); |
|
| 85 | + $base = url_de_base().(_DIR_RACINE ? _DIR_RESTREINT_ABS : ''); |
|
| 86 | 86 | return suivre_lien($base, $url); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -92,27 +92,27 @@ discard block |
||
| 92 | 92 | * @param string $url_absolue |
| 93 | 93 | * @return string |
| 94 | 94 | */ |
| 95 | -function protocole_implicite($url_absolue){ |
|
| 96 | - return preg_replace(";^[a-z]{3,7}://;i","//",$url_absolue); |
|
| 95 | +function protocole_implicite($url_absolue) { |
|
| 96 | + return preg_replace(";^[a-z]{3,7}://;i", "//", $url_absolue); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // un filtre pour transformer les URLs relatives en URLs absolues ; |
| 100 | 100 | // ne s'applique qu'aux textes contenant des liens |
| 101 | 101 | // http://doc.spip.org/@liens_absolus |
| 102 | -function liens_absolus($texte, $base='') { |
|
| 102 | +function liens_absolus($texte, $base = '') { |
|
| 103 | 103 | if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', |
| 104 | 104 | $texte, $liens, PREG_SET_ORDER)) { |
| 105 | 105 | if (!function_exists('extraire_attribut')) { |
| 106 | 106 | include_spip('inc/filtres'); |
| 107 | 107 | } |
| 108 | 108 | foreach ($liens as $lien) { |
| 109 | - foreach(array('href', 'src') as $attr) { |
|
| 109 | + foreach (array('href', 'src') as $attr) { |
|
| 110 | 110 | $href = extraire_attribut($lien[0], $attr); |
| 111 | - if (strlen($href)>0) { |
|
| 111 | + if (strlen($href) > 0) { |
|
| 112 | 112 | $abs = url_absolue($href, $base); |
| 113 | - if ($href != $abs and !preg_match('/^#/',$href)) { |
|
| 113 | + if ($href != $abs and !preg_match('/^#/', $href)) { |
|
| 114 | 114 | $texte_lien = inserer_attribut($lien[0], $attr, $abs); |
| 115 | - $texte = str_replace($lien[0],$texte_lien,$texte); |
|
| 115 | + $texte = str_replace($lien[0], $texte_lien, $texte); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // Ce filtre public va traiter les URL ou les <a href> |
| 127 | 127 | // |
| 128 | 128 | // http://doc.spip.org/@abs_url |
| 129 | -function abs_url($texte, $base='') { |
|
| 129 | +function abs_url($texte, $base = '') { |
|
| 130 | 130 | if ($GLOBALS['mode_abs_url'] == 'url') |
| 131 | 131 | return url_absolue($texte, $base); |
| 132 | 132 | else |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | * @param bool $double_encode |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | -function spip_htmlspecialchars($string, $flags=null, $encoding='ISO-8859-1', $double_encode = true){ |
|
| 145 | +function spip_htmlspecialchars($string, $flags = null, $encoding = 'ISO-8859-1', $double_encode = true) { |
|
| 146 | 146 | if (is_null($flags)) { |
| 147 | 147 | if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50400) |
| 148 | 148 | $flags = ENT_COMPAT; |
| 149 | 149 | else |
| 150 | - $flags = ENT_COMPAT|ENT_HTML401; |
|
| 150 | + $flags = ENT_COMPAT | ENT_HTML401; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50203) |
| 154 | - return htmlspecialchars($string,$flags,$encoding); |
|
| 154 | + return htmlspecialchars($string, $flags, $encoding); |
|
| 155 | 155 | else |
| 156 | - return htmlspecialchars($string,$flags,$encoding,$double_encode); |
|
| 156 | + return htmlspecialchars($string, $flags, $encoding, $double_encode); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -165,17 +165,17 @@ discard block |
||
| 165 | 165 | * @param bool $double_encode |
| 166 | 166 | * @return string |
| 167 | 167 | */ |
| 168 | -function spip_htmlentities($string,$flags=null,$encoding = 'ISO-8859-1',$double_encode = true){ |
|
| 168 | +function spip_htmlentities($string, $flags = null, $encoding = 'ISO-8859-1', $double_encode = true) { |
|
| 169 | 169 | if (is_null($flags)) { |
| 170 | 170 | if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50400) |
| 171 | 171 | $flags = ENT_COMPAT; |
| 172 | 172 | else |
| 173 | - $flags = ENT_COMPAT|ENT_HTML401; |
|
| 173 | + $flags = ENT_COMPAT | ENT_HTML401; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | if (!defined('PHP_VERSION_ID') OR PHP_VERSION_ID < 50203) |
| 177 | - return htmlentities($string,$flags,$encoding); |
|
| 177 | + return htmlentities($string, $flags, $encoding); |
|
| 178 | 178 | else |
| 179 | - return htmlentities($string,$flags,$encoding,$double_encode); |
|
| 179 | + return htmlentities($string, $flags, $encoding, $double_encode); |
|
| 180 | 180 | } |
| 181 | 181 | ?> |
@@ -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>'; |