Completed
Push — spip-3.0 ( cd2822...016705 )
by cam
08:31
created
ecrire/oo/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,6 @@
 block discarded – undo
3 3
 // ACCESSIBILITE
4 4
 // la page /oo offre une lecture en mode "texte seul"
5 5
 
6
-header("Location: ../?action=preferer&arg=display:4&redirect=" . urlencode(str_replace('/oo','', $_SERVER['REQUEST_URI'])));
6
+header("Location: ../?action=preferer&arg=display:4&redirect=".urlencode(str_replace('/oo', '', $_SERVER['REQUEST_URI'])));
7 7
 
8 8
 ?>
Please login to merge, or discard this patch.
ecrire/prive.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	// On reexecute pour deboucher sur le include public.
27 27
 	// autrement on insiste
28 28
 		if (is_array($var_auth)) {
29
-			$var_auth = '../?' . $_SERVER['QUERY_STRING'];
29
+			$var_auth = '../?'.$_SERVER['QUERY_STRING'];
30 30
 			spip_setcookie('spip_session', $_COOKIE['spip_session'], time() + 3600 * 24 * 14);
31 31
 		}
32 32
 		include_spip('inc/headers');
Please login to merge, or discard this patch.
ecrire/inc/lang_liste.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	'cpf_dom' => "Kreyòl",
51 51
 	'cpf_hat' => "Kreyòl (Peyi Dayiti)",
52 52
 	'cs' => "čeština",
53
-	'cy' => "Cymraeg",	# welsh, gallois
53
+	'cy' => "Cymraeg", # welsh, gallois
54 54
 	'da' => "dansk",
55 55
 	'de' => "Deutsch",
56 56
 	'dz' => "Bhutani",
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	'hi' => "हिंदी",
92 92
 	'hr' => "hrvatski",
93 93
 	'hu' => "magyar",
94
-	'hy' => "Հայերեն",// Arménien
94
+	'hy' => "Հայերեն", // Arménien
95 95
 	'ia' => "Interlingua",
96 96
 	'id' => "Indonesia",
97 97
 	'ie' => "Interlingue",
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	'ka' => "ქართული",
106 106
 	'kk' => "қазақ тілі", // Kazakh
107 107
 	'kl' => "kalaallisut",
108
-	'km' => "ភាសាខ្មែរ",// Khmer
108
+	'km' => "ភាសាខ្មែរ", // Khmer
109 109
 	'kn' => "Kannada",
110 110
 	'ko' => "한국어",
111 111
 	'kok' => "कोंकणी", // Konkani
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	'sh_latn' => 'srpskohrvastski',
176 176
 	'sh_cyrl' => 'Српскохрватски',
177 177
 	'si' => "Sinhalese",
178
-	'sk' => "slovenčina",	// (Slovakia)
179
-	'sl' => "slovenščina",	// (Slovenia)
178
+	'sk' => "slovenčina", // (Slovakia)
179
+	'sl' => "slovenščina", // (Slovenia)
180 180
 	'sm' => "Samoan",
181 181
 	'sn' => "Shona",
182 182
 	'so' => "Somali",
Please login to merge, or discard this patch.
ecrire/inc/invalideur.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -24,21 +24,21 @@  discard block
 block discarded – undo
24 24
 // Donne le nombre de fichiers dans un repertoire (plat, pour aller vite)
25 25
 // false si erreur
26 26
 // http://doc.spip.org/@nombre_de_fichiers_repertoire
27
-function nombre_de_fichiers_repertoire($dir,$nb_estim_taille = 20) {
27
+function nombre_de_fichiers_repertoire($dir, $nb_estim_taille = 20) {
28 28
 	$taille = 0; // mesurer la taille de N fichiers au hasard dans le repertoire
29 29
 	$nb = $nb_estim_taille;
30 30
 	if (!$h = @opendir($dir)) return false;
31 31
 	$total = 0;
32 32
 	while (($fichier = @readdir($h)) !== false)
33
-		if ($fichier[0]!='.' AND !is_dir("$dir/$fichier")){
33
+		if ($fichier[0] != '.' AND !is_dir("$dir/$fichier")) {
34 34
 			$total++;
35
-			if ($nb AND rand(1,10)==1){
35
+			if ($nb AND rand(1, 10) == 1) {
36 36
 				$taille += filesize("$dir/$fichier");
37 37
 				$nb--;
38 38
 			}
39 39
 		}
40 40
 	closedir($h);
41
-	return array($total,$taille?$taille/($nb_estim_taille-$nb):_TAILLE_MOYENNE_FICHIER_CACHE);
41
+	return array($total, $taille ? $taille / ($nb_estim_taille - $nb) : _TAILLE_MOYENNE_FICHIER_CACHE);
42 42
 }
43 43
 
44 44
 // Indique la taille du repertoire cache ; pour de gros volumes,
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 function taille_du_cache() {
48 48
 	$total = 0;
49 49
 	$taille = 0;
50
-	for ($i=0;$i<16;$i++) {
50
+	for ($i = 0; $i < 16; $i++) {
51 51
 		$l = dechex($i);
52 52
 		$dir = sous_repertoire(_DIR_CACHE, $l);
53
-		list($n,$s) = nombre_de_fichiers_repertoire($dir);
53
+		list($n, $s) = nombre_de_fichiers_repertoire($dir);
54 54
 		$total += $n;
55 55
 		$taille += $s;
56 56
 	}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 // la condition est generalement "id='objet/id_objet'"
63 63
 // ici on se contente de noter la date de mise a jour dans les metas
64 64
 // http://doc.spip.org/@suivre_invalideur
65
-function suivre_invalideur($cond, $modif=true) {
65
+function suivre_invalideur($cond, $modif = true) {
66 66
 	if (!$modif)
67 67
 		return;
68 68
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
  * @return int
109 109
  *     Nombre de fichiers supprimés
110 110
 **/
111
-function purger_repertoire($dir, $options=array()) {
111
+function purger_repertoire($dir, $options = array()) {
112 112
 	$handle = @opendir($dir);
113 113
 	if (!$handle) return;
114 114
 
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 		if ($fichier[0] == '.') continue;
120 120
 		$chemin = "$dir/$fichier";
121 121
 		if (is_file($chemin)) {
122
-			if (  (!isset($options['atime']) OR (@fileatime($chemin) < $options['atime']))
122
+			if ((!isset($options['atime']) OR (@fileatime($chemin) < $options['atime']))
123 123
 				AND (!isset($options['mtime']) OR (@filemtime($chemin) < $options['mtime']))
124 124
 			  ) {
125 125
 				supprimer_fichier($chemin);
126
-				$total ++;
126
+				$total++;
127 127
 			}
128 128
 		}
129
-		else if (is_dir($chemin)){
129
+		else if (is_dir($chemin)) {
130 130
 			$opts = $options;
131 131
 			if (isset($otpions['limit']))
132 132
 				$otps['limit'] = $otpions['limit'] - $total;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				spip_unlink($chemin);
136 136
 		}
137 137
 
138
-		if (isset($options['limit']) AND $total>=$options['limit'])
138
+		if (isset($options['limit']) AND $total >= $options['limit'])
139 139
 			break;
140 140
 	}
141 141
 	closedir($handle);
@@ -155,20 +155,20 @@  discard block
 block discarded – undo
155 155
 	global $quota_cache;
156 156
 	$encore = false;
157 157
 
158
-	$tour_quota_cache = intval(1+$GLOBALS['meta']['tour_quota_cache'])%16;
158
+	$tour_quota_cache = intval(1 + $GLOBALS['meta']['tour_quota_cache']) % 16;
159 159
 	ecrire_meta('tour_quota_cache', $tour_quota_cache);
160 160
 
161 161
 	$l = dechex($tour_quota_cache);
162 162
 	$dir = sous_repertoire(_DIR_CACHE, $l);
163
-	list($nombre,$taille) = nombre_de_fichiers_repertoire($dir);
163
+	list($nombre, $taille) = nombre_de_fichiers_repertoire($dir);
164 164
 	$total_cache = $taille * $nombre;
165 165
 	spip_log("Taille du CACHE estimee ($l): "
166
-		.(intval(16*$total_cache/(1024*1024/10))/10)." Mo","invalideur");
166
+		.(intval(16 * $total_cache / (1024 * 1024 / 10)) / 10)." Mo", "invalideur");
167 167
 
168 168
 	// Nombre max de fichiers a supprimer
169 169
 	if ($quota_cache > 0
170 170
 	AND $taille > 0) {
171
-		$trop = $total_cache - ($quota_cache/16)*1024*1024;
171
+		$trop = $total_cache - ($quota_cache / 16) * 1024 * 1024;
172 172
 		$trop = 3 * intval($trop / $taille);
173 173
 		if ($trop > 0) {
174 174
 			$n = purger_repertoire($dir,
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 					'subdir' => true // supprimer les vieux sous repertoire de session (avant [15851])
179 179
 				)
180 180
 			);
181
-			spip_log("$dir : $n/$trop caches supprimes [taille moyenne $taille]","invalideur");
182
-			$total_cache = intval(max(0,(16*$total_cache) - $n*$taille)/(1024*1024)*10)/10;
183
-			spip_log("cache restant estime : $total_cache Mo, ratio ".$total_cache/$quota_cache,"invalideur");
181
+			spip_log("$dir : $n/$trop caches supprimes [taille moyenne $taille]", "invalideur");
182
+			$total_cache = intval(max(0, (16 * $total_cache) - $n * $taille) / (1024 * 1024) * 10) / 10;
183
+			spip_log("cache restant estime : $total_cache Mo, ratio ".$total_cache / $quota_cache, "invalideur");
184 184
 
185 185
 			// redemander la main pour eviter que le cache ne gonfle trop
186 186
 			// mais pas si on ne peut pas purger car les fichiers sont trops recents
187 187
 			if (
188
-			  $total_cache/$quota_cache>1.5
189
-			  AND $n*50>$trop) {
188
+			  $total_cache / $quota_cache > 1.5
189
+			  AND $n * 50 > $trop) {
190 190
 				$encore = true;
191
-				spip_log("Il faut encore purger","invalideur");
191
+				spip_log("Il faut encore purger", "invalideur");
192 192
 			}
193 193
 		}
194 194
 	}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	"|^([0-9a-f]/)?([0-9]+/)?[^.][\-_\%0-9a-z]+--[0-9a-f]+(\.gz)?$|i",
209 209
 	$cache)) {
210 210
 		// supprimer le fichier (de facon propre)
211
-		supprimer_fichier(_DIR_CACHE . $cache);
211
+		supprimer_fichier(_DIR_CACHE.$cache);
212 212
 	} else
213 213
 		spip_log("Nom de fichier cache incorrect : $cache");
214 214
 }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 // Calcul des pages : noter dans la base les liens d'invalidation
251 251
 // http://doc.spip.org/@maj_invalideurs
252
-function maj_invalideurs ($fichier, &$page) { }
252
+function maj_invalideurs($fichier, &$page) { }
253 253
 
254 254
 // les invalideurs sont de la forme "objet/id_objet"
255 255
 // http://doc.spip.org/@insere_invalideur
Please login to merge, or discard this patch.
ecrire/inc/xml.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -13,31 +13,31 @@  discard block
 block discarded – undo
13 13
 if (!defined('_ECRIRE_INC_VERSION')) return;
14 14
 
15 15
 // http://doc.spip.org/@spip_xml_load
16
-function spip_xml_load($fichier, $strict=true, $clean=true, $taille_max = 1048576, $datas='', $profondeur = -1){
16
+function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1048576, $datas = '', $profondeur = -1) {
17 17
 	$contenu = "";
18
-	if (preg_match(",^(http|ftp)://,",$fichier)){
18
+	if (preg_match(",^(http|ftp)://,", $fichier)) {
19 19
 		include_spip('inc/distant');
20
-		$contenu = recuperer_page($fichier,false,false,$taille_max, $datas);
20
+		$contenu = recuperer_page($fichier, false, false, $taille_max, $datas);
21 21
 	}
22
-	else lire_fichier ($fichier, $contenu);
22
+	else lire_fichier($fichier, $contenu);
23 23
 	$arbre = array();
24 24
 	if ($contenu)
25 25
 		$arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur);
26 26
 		
27
-	return count($arbre)?$arbre:false;
27
+	return count($arbre) ? $arbre : false;
28 28
 }
29 29
 
30 30
 if (!defined('_SPIP_XML_TAG_SPLIT')) define('_SPIP_XML_TAG_SPLIT', "{<([^:>][^>]*?)>}sS");
31 31
 // http://doc.spip.org/@spip_xml_parse
32
-function spip_xml_parse(&$texte, $strict=true, $clean=true, $profondeur = -1){
32
+function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) {
33 33
 	$out = array();
34 34
   // enlever les commentaires
35 35
   $charset = 'AUTO';
36
-  if ($clean===true){
37
-  	if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im",$texte,$regs))
36
+  if ($clean === true) {
37
+  	if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs))
38 38
   		$charset = $regs[2];
39
-	  $texte = preg_replace(',<!--(.*?)-->,is','',$texte);
40
-	  $texte = preg_replace(',<\?(.*?)\?>,is','',$texte);
39
+	  $texte = preg_replace(',<!--(.*?)-->,is', '', $texte);
40
+	  $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte);
41 41
 		include_spip('inc/charsets');
42 42
 		$clean = $charset;
43 43
 		//$texte = importer_charset($texte,$charset);
@@ -46,128 +46,128 @@  discard block
 block discarded – undo
46 46
   $txt = $texte;
47 47
 
48 48
 	// tant qu'il y a des tags
49
-	$chars = preg_split(_SPIP_XML_TAG_SPLIT,$txt,2,PREG_SPLIT_DELIM_CAPTURE);
50
-	while(count($chars)>=2){
49
+	$chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
50
+	while (count($chars) >= 2) {
51 51
 		// tag ouvrant
52 52
 		//$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE);
53 53
 	
54 54
 		// $before doit etre vide ou des espaces uniquements!
55 55
 		$before = trim($chars[0]);
56 56
 
57
-		if (strlen($before)>0)
58
-			return importer_charset($texte,$charset);//$texte; // before non vide, donc on est dans du texte
57
+		if (strlen($before) > 0)
58
+			return importer_charset($texte, $charset); //$texte; // before non vide, donc on est dans du texte
59 59
 	
60 60
 		$tag = rtrim($chars[1]);
61 61
 		$txt = $chars[2];
62 62
 		
63
-		if (strncmp($tag,'![CDATA[',8)==0) return importer_charset($texte,$charset);//$texte;
64
-		if(substr($tag,-1)=='/'){ // self closing tag
65
-			$tag = rtrim(substr($tag,0,strlen($tag)-1));
66
-			$out[$tag][]="";
63
+		if (strncmp($tag, '![CDATA[', 8) == 0) return importer_charset($texte, $charset); //$texte;
64
+		if (substr($tag, -1) == '/') { // self closing tag
65
+			$tag = rtrim(substr($tag, 0, strlen($tag) - 1));
66
+			$out[$tag][] = "";
67 67
 		}
68
-		else{
69
-			$closing_tag = preg_split(",\s|\t|\n|\r,",trim($tag));
70
-			$closing_tag=reset($closing_tag);
68
+		else {
69
+			$closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag));
70
+			$closing_tag = reset($closing_tag);
71 71
 			// tag fermant
72 72
 			$ncclos = strlen("</$closing_tag>");
73
-			$p = strpos($txt,"</$closing_tag>");
74
-			if ($p!==FALSE  AND (strpos($txt,"<")<$p)){
75
-				$nclose =0; $nopen = 0;
73
+			$p = strpos($txt, "</$closing_tag>");
74
+			if ($p !== FALSE AND (strpos($txt, "<") < $p)) {
75
+				$nclose = 0; $nopen = 0;
76 76
 				$d = 0;
77 77
 				while (
78
-					$p!==FALSE
79
-					AND ($morceau = substr($txt,$d,$p-$d))
80
-					AND (($nopen+=preg_match_all("{<".preg_quote($closing_tag)."(\s*>|\s[^>]*[^/>]>)}is",$morceau,$matches,PREG_SET_ORDER))>$nclose)
81
-					){
78
+					$p !== FALSE
79
+					AND ($morceau = substr($txt, $d, $p - $d))
80
+					AND (($nopen += preg_match_all("{<".preg_quote($closing_tag)."(\s*>|\s[^>]*[^/>]>)}is", $morceau, $matches, PREG_SET_ORDER)) > $nclose)
81
+					) {
82 82
 					$nclose++;
83
-					$d=$p+$ncclos;
84
-					$p = strpos($txt,"</$closing_tag>",$d);
83
+					$d = $p + $ncclos;
84
+					$p = strpos($txt, "</$closing_tag>", $d);
85 85
 				}
86 86
 			}
87
-			if ($p===FALSE){
88
-				if ($strict){
89
-					$out[$tag][]="erreur : tag fermant $tag manquant::$txt"; 
87
+			if ($p === FALSE) {
88
+				if ($strict) {
89
+					$out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; 
90 90
 					return $out;
91 91
 				}
92
-				else return importer_charset($texte,$charset);//$texte // un tag qui constitue du texte a reporter dans $before
92
+				else return importer_charset($texte, $charset); //$texte // un tag qui constitue du texte a reporter dans $before
93 93
 			}
94
-			$content = substr($txt,0,$p);
95
-			$txt = substr($txt,$p+$ncclos);
96
-			if ($profondeur==0 OR strpos($content,"<")===FALSE) // eviter une recursion si pas utile
97
-				$out[$tag][] = importer_charset($content,$charset);//$content;
94
+			$content = substr($txt, 0, $p);
95
+			$txt = substr($txt, $p + $ncclos);
96
+			if ($profondeur == 0 OR strpos($content, "<") === FALSE) // eviter une recursion si pas utile
97
+				$out[$tag][] = importer_charset($content, $charset); //$content;
98 98
 			else
99
-				$out[$tag][]=spip_xml_parse($content, $strict, $clean, $profondeur-1);
99
+				$out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1);
100 100
 		}
101
-		$chars = preg_split(_SPIP_XML_TAG_SPLIT,$txt,2,PREG_SPLIT_DELIM_CAPTURE);
101
+		$chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
102 102
 	}
103
-	if (count($out)&&(strlen(trim($txt))==0))
103
+	if (count($out) && (strlen(trim($txt)) == 0))
104 104
 		return $out;
105 105
 	else
106
-		return importer_charset($texte,$charset);//$texte;
106
+		return importer_charset($texte, $charset); //$texte;
107 107
 }
108 108
 
109 109
 // http://doc.spip.org/@spip_xml_aplatit
110
-function spip_xml_aplatit($arbre,$separateur = " "){
110
+function spip_xml_aplatit($arbre, $separateur = " ") {
111 111
 	$s = "";
112 112
 	if (is_array($arbre))
113
-		foreach($arbre as $tag=>$feuille){
114
-			if (is_array($feuille)){
115
-				if ($tag!==intval($tag)){
113
+		foreach ($arbre as $tag=>$feuille) {
114
+			if (is_array($feuille)) {
115
+				if ($tag !== intval($tag)) {
116 116
 					$f = spip_xml_aplatit($feuille, $separateur);
117 117
 					if (strlen($f)) {
118
-						$tagf = explode(" ",$tag);
118
+						$tagf = explode(" ", $tag);
119 119
 						$tagf = $tagf[0];
120
-						$s.="<$tag>$f</$tagf>";
120
+						$s .= "<$tag>$f</$tagf>";
121 121
 					}
122
-					else $s.="<$tag />";
122
+					else $s .= "<$tag />";
123 123
 				}
124 124
 				else
125
-					$s.=spip_xml_aplatit($feuille);
125
+					$s .= spip_xml_aplatit($feuille);
126 126
 				$s .= $separateur;
127 127
 			}
128 128
 			else
129
-				$s.="$feuille$separateur";
129
+				$s .= "$feuille$separateur";
130 130
 		}
131 131
 	return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s;
132 132
 }
133 133
 
134 134
 // http://doc.spip.org/@spip_xml_tagname
135
-function spip_xml_tagname($tag){
136
-	if (preg_match(',^([a-z][\w:]*),i',$tag,$reg))
135
+function spip_xml_tagname($tag) {
136
+	if (preg_match(',^([a-z][\w:]*),i', $tag, $reg))
137 137
 		return $reg[1];
138 138
 	return "";
139 139
 }
140 140
 // http://doc.spip.org/@spip_xml_decompose_tag
141
-function spip_xml_decompose_tag($tag){
141
+function spip_xml_decompose_tag($tag) {
142 142
 	$tagname = spip_xml_tagname($tag);
143 143
 	$liste = array();
144
-	$p=strpos($tag,' ');
145
-	$tag = substr($tag,$p);
146
-	$p=strpos($tag,'=');
147
-	while($p!==false){
148
-		$attr = trim(substr($tag,0,$p));
149
-		$tag = ltrim(substr($tag,$p+1));
144
+	$p = strpos($tag, ' ');
145
+	$tag = substr($tag, $p);
146
+	$p = strpos($tag, '=');
147
+	while ($p !== false) {
148
+		$attr = trim(substr($tag, 0, $p));
149
+		$tag = ltrim(substr($tag, $p + 1));
150 150
 		$quote = $tag{0};
151
-		$p=strpos($tag,$quote,1);
152
-		$cont = substr($tag,1,$p-1);
151
+		$p = strpos($tag, $quote, 1);
152
+		$cont = substr($tag, 1, $p - 1);
153 153
 		$liste[$attr] = $cont;
154
-		$tag = substr($tag,$p+1);
155
-		$p=strpos($tag,'=');
154
+		$tag = substr($tag, $p + 1);
155
+		$p = strpos($tag, '=');
156 156
 	}
157
-	return array($tagname,$liste);
157
+	return array($tagname, $liste);
158 158
 }
159 159
 
160 160
 // http://doc.spip.org/@spip_xml_match_nodes
161
-function spip_xml_match_nodes($regexp,&$arbre,&$matches,$init=true){
161
+function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) {
162 162
 	if ($init)
163 163
 		$matches = array();
164
-	if(is_array($arbre) && count($arbre))
165
-		foreach(array_keys($arbre) as $tag){
166
-			if (preg_match($regexp,$tag))
164
+	if (is_array($arbre) && count($arbre))
165
+		foreach (array_keys($arbre) as $tag) {
166
+			if (preg_match($regexp, $tag))
167 167
 				$matches[$tag] = &$arbre[$tag];
168 168
 			if (is_array($arbre[$tag]))
169
-				foreach(array_keys($arbre[$tag]) as $occurences)
170
-					spip_xml_match_nodes($regexp,$arbre[$tag][$occurences],$matches,false);
169
+				foreach (array_keys($arbre[$tag]) as $occurences)
170
+					spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false);
171 171
 		}
172 172
 	return (count($matches));
173 173
 }
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	// celle du texte) et public (spip_lang est la langue du texte)
26 26
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
27 27
 
28
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
28
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
29 29
 	if ($dir == 'rtl') $p .= '_rtl';
30 30
 
31 31
 	if (!isset($GLOBALS[$p])) {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	.'d[ltd]|script|noscript|map|button|fieldset|style');
49 49
 
50 50
 if (!defined('_BALISES_BLOCS_REGEXP'))
51
-	define('_BALISES_BLOCS_REGEXP',',</?('._BALISES_BLOCS.')[>[:space:]],iS');
51
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
52 52
 
53 53
 //
54 54
 // Echapper les elements perilleux en les passant en base64
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
 // une $source differente ; le script detecte automagiquement si ce qu'on
59 59
 // echappe est un div ou un span
60 60
 // http://doc.spip.org/@code_echappement
61
-function code_echappement($rempl, $source='', $no_transform=false, $mode=NULL) {
61
+function code_echappement($rempl, $source = '', $no_transform = false, $mode = NULL) {
62 62
 	if (!strlen($rempl)) return '';
63 63
 
64 64
 	// Tester si on echappe en span ou en div
65
-	if (is_null($mode) OR !in_array($mode,array('div','span')))
65
+	if (is_null($mode) OR !in_array($mode, array('div', 'span')))
66 66
 		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
67 67
 
68 68
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
69 69
 	$taille = 30000;
70 70
 	$return = "";
71
-	for($i = 0; $i < strlen($rempl); $i += $taille) {
71
+	for ($i = 0; $i < strlen($rempl); $i += $taille) {
72 72
 		// Convertir en base64 et cacher dans un attribut
73 73
 		// utiliser les " pour eviter le re-encodage de ' et &#8217
74 74
 		$base64 = base64_encode(substr($rempl, $i, $taille));
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 // Echapper les <code>...</ code>
90 90
 // http://doc.spip.org/@traiter_echap_code_dist
91 91
 function traiter_echap_code_dist($regs) {
92
-	list(,,$att,$corps) = $regs;
92
+	list(,, $att, $corps) = $regs;
93 93
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
94 94
 
95 95
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
96
-	if (is_int(strpos($echap,"\n"))) {
96
+	if (is_int(strpos($echap, "\n"))) {
97 97
 		// supprimer les sauts de ligne debut/fin
98 98
 		// (mais pas les espaces => ascii art).
99 99
 		$echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", "", $echap);
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 function traiter_echap_cadre_dist($regs) {
116 116
 	$echap = trim(entites_html($regs[3]));
117 117
 	// compter les lignes un peu plus finement qu'avec les \n
118
-	$lignes = explode("\n",trim($echap));
118
+	$lignes = explode("\n", trim($echap));
119 119
 	$n = 0;
120
-	foreach($lignes as $l)
121
-		$n+=floor(strlen($l)/60)+1;
122
-	$n = max($n,2);
120
+	foreach ($lignes as $l)
121
+		$n += floor(strlen($l) / 60) + 1;
122
+	$n = max($n, 2);
123 123
 	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
124 124
 	return $echap;
125 125
 }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 function traiter_echap_script_dist($regs) {
133 133
 	// rendre joli (et inactif) si c'est un script language=php
134 134
 	if (preg_match(',<script\b[^>]+php,ims', $regs[0]))
135
-		return highlight_string($regs[0],true);
135
+		return highlight_string($regs[0], true);
136 136
 
137 137
 	// Cas normal : le script passe tel quel
138 138
 	return $regs[0];
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 // - pour $source voir commentaire infra (echappe_retour)
158 158
 // - pour $no_transform voir le filtre post_autobr dans inc/filtres
159 159
 // http://doc.spip.org/@echappe_html
160
-function echappe_html($letexte, $source='', $no_transform=false,
161
-$preg='') {
160
+function echappe_html($letexte, $source = '', $no_transform = false,
161
+$preg = '') {
162 162
 	if (!is_string($letexte) or !strlen($letexte))
163 163
 		return $letexte;
164 164
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 	}
174 174
 
175
-	if (($preg OR strpos($letexte,"<")!==false)
175
+	if (($preg OR strpos($letexte, "<") !== false)
176 176
 	  AND preg_match_all($preg ? $preg : _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)) {
177 177
 		foreach ($matches as $regs) {
178 178
 			// echappements tels quels ?
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 			else if (function_exists($f = $f.'_dist'))
187 187
 				$echap = $f($regs);
188 188
 
189
-			$p = strpos($letexte,$regs[0]);
190
-			$letexte = substr_replace($letexte,code_echappement($echap, $source, $no_transform),$p,strlen($regs[0]));
189
+			$p = strpos($letexte, $regs[0]);
190
+			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
191 191
 		}
192 192
 	}
193 193
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	// code mort sauf si on a personalise _PROTEGE_BLOCS sans y mettre <math>
199 199
 	// eviter la rupture de compat en branche 3.0
200 200
 	// a supprimer en branche 3.1
201
-	if (strpos($preg ? $preg : _PROTEGE_BLOCS,'code')!==false){
201
+	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'code') !== false) {
202 202
 		if (strpos($letexte, "<math>") !== false) {
203 203
 			include_spip('inc/math');
204 204
 			$letexte = traiter_math($letexte, $source);
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 	// seulement si on a echappe les <script>
210 210
 	// (derogatoire car on ne peut pas faire passer < ? ... ? >
211 211
 	// dans une callback autonommee
212
-	if (strpos($preg ? $preg : _PROTEGE_BLOCS,'script')!==false){
213
-		if (strpos($letexte,"<"."?")!==false AND preg_match_all(',<[?].*($|[?]>),UisS',
212
+	if (strpos($preg ? $preg : _PROTEGE_BLOCS, 'script') !== false) {
213
+		if (strpos($letexte, "<"."?") !== false AND preg_match_all(',<[?].*($|[?]>),UisS',
214 214
 		$letexte, $matches, PREG_SET_ORDER))
215 215
 		foreach ($matches as $regs) {
216 216
 			$letexte = str_replace($regs[0],
217
-				code_echappement(highlight_string($regs[0],true), $source),
217
+				code_echappement(highlight_string($regs[0], true), $source),
218 218
 				$letexte);
219 219
 		}
220 220
 	}
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes
228 228
 // par propre() : exemple dans multi et dans typo()
229 229
 // http://doc.spip.org/@echappe_retour
230
-function echappe_retour($letexte, $source='', $filtre = "") {
231
-	if (strpos($letexte,"base64$source")) {
230
+function echappe_retour($letexte, $source = '', $filtre = "") {
231
+	if (strpos($letexte, "base64$source")) {
232 232
 		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
233 233
 		$max_prof = 5;
234
-		while (strpos($letexte,"<")!==false
234
+		while (strpos($letexte, "<") !== false
235 235
 			AND
236 236
 		  preg_match_all(',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
237 237
 		$letexte, $regs, PREG_SET_ORDER)
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
241 241
 				// recherche d'attributs supplementaires
242 242
 				$at = array();
243
-				foreach(array('lang', 'dir') as $attr) {
243
+				foreach (array('lang', 'dir') as $attr) {
244 244
 					if ($a = extraire_attribut($reg[0], $attr))
245 245
 						$at[$attr] = $a;
246 246
 				}
247 247
 				if ($at) {
248 248
 					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
249
-					foreach($at as $attr => $a)
249
+					foreach ($at as $attr => $a)
250 250
 						$rempl = inserer_attribut($rempl, $attr, $a);
251 251
 				}
252 252
 				if ($filtre) $rempl = $filtre($rempl);
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 // Reinserer le javascript de confiance (venant des modeles)
261 261
 
262 262
 // http://doc.spip.org/@echappe_retour_modeles
263
-function echappe_retour_modeles($letexte, $interdire_scripts=false)
263
+function echappe_retour_modeles($letexte, $interdire_scripts = false)
264 264
 {
265 265
 	$letexte = echappe_retour($letexte);
266 266
 
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 
274 274
 
275 275
 // http://doc.spip.org/@couper
276
-function couper($texte, $taille=50, $suite = '&nbsp;(...)') {
277
-	if (!($length=strlen($texte)) OR $taille <= 0) return '';
278
-	$offset = 400 + 2*$taille;
279
-	while ($offset<$length
280
-		AND strlen(preg_replace(",<[^>]+>,Uims","",substr($texte,0,$offset)))<$taille)
281
-		$offset = 2*$offset;
282
-	if (	$offset<$length
283
-			&& ($p_tag_ouvrant = strpos($texte,'<',$offset))!==NULL){
284
-		$p_tag_fermant = strpos($texte,'>',$offset);
285
-		if ($p_tag_fermant && ($p_tag_fermant<$p_tag_ouvrant))
286
-			$offset = $p_tag_fermant+1; // prolonger la coupe jusqu'au tag fermant suivant eventuel
276
+function couper($texte, $taille = 50, $suite = '&nbsp;(...)') {
277
+	if (!($length = strlen($texte)) OR $taille <= 0) return '';
278
+	$offset = 400 + 2 * $taille;
279
+	while ($offset < $length
280
+		AND strlen(preg_replace(",<[^>]+>,Uims", "", substr($texte, 0, $offset))) < $taille)
281
+		$offset = 2 * $offset;
282
+	if ($offset < $length
283
+			&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== NULL) {
284
+		$p_tag_fermant = strpos($texte, '>', $offset);
285
+		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant))
286
+			$offset = $p_tag_fermant + 1; // prolonger la coupe jusqu'au tag fermant suivant eventuel
287 287
 	}
288 288
 	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
289 289
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 
301 301
 	// supprimer les tags
302 302
 	$texte = supprimer_tags($texte);
303
-	$texte = trim(str_replace("\n"," ", $texte));
304
-	$texte .= "\n";	// marquer la fin
303
+	$texte = trim(str_replace("\n", " ", $texte));
304
+	$texte .= "\n"; // marquer la fin
305 305
 
306 306
 	// travailler en accents charset
307 307
 	$texte = unicode2charset(html2unicode($texte, /* secure */ true));
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
 
312 312
 	// corriger la longueur de coupe
313 313
 	// en fonction de la presence de caracteres utf
314
-	if ($GLOBALS['meta']['charset']=='utf-8'){
314
+	if ($GLOBALS['meta']['charset'] == 'utf-8') {
315 315
 		$long = charset2unicode($texte);
316
-		$long = spip_substr($long, 0, max($taille,1));
316
+		$long = spip_substr($long, 0, max($taille, 1));
317 317
 		$nbcharutf = preg_match_all('/(&#[0-9]{3,5};)/S', $long, $matches);
318 318
 		$taille += $nbcharutf;
319 319
 	}
320 320
 
321 321
 
322 322
 	// couper au mot precedent
323
-	$long = spip_substr($texte, 0, max($taille-4,1));
323
+	$long = spip_substr($texte, 0, max($taille - 4, 1));
324 324
 	$u = $GLOBALS['meta']['pcre_u'];
325 325
 	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
326 326
 	$points = $suite;
327 327
 
328 328
 	// trop court ? ne pas faire de (...)
329
-	if (spip_strlen($court) < max(0.75 * $taille,2)) {
329
+	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
330 330
 		$points = '';
331 331
 		$long = spip_substr($texte, 0, $taille);
332 332
 		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
@@ -351,37 +351,37 @@  discard block
 block discarded – undo
351 351
 
352 352
 // http://doc.spip.org/@protege_js_modeles
353 353
 function protege_js_modeles($t) {
354
-	if (isset($GLOBALS['visiteur_session'])){
355
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)){
356
-			if (!defined('_PROTEGE_JS_MODELES')){
354
+	if (isset($GLOBALS['visiteur_session'])) {
355
+		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
356
+			if (!defined('_PROTEGE_JS_MODELES')) {
357 357
 				include_spip('inc/acces');
358
-				define('_PROTEGE_JS_MODELES',creer_uniqid());
358
+				define('_PROTEGE_JS_MODELES', creer_uniqid());
359 359
 			}
360 360
 			foreach ($r as $regs)
361
-				$t = str_replace($regs[0],code_echappement($regs[0],'javascript'._PROTEGE_JS_MODELES),$t);
361
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
362 362
 		}
363
-		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)){
364
-			if (!defined('_PROTEGE_PHP_MODELES')){
363
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
364
+			if (!defined('_PROTEGE_PHP_MODELES')) {
365 365
 				include_spip('inc/acces');
366
-				define('_PROTEGE_PHP_MODELES',creer_uniqid());
366
+				define('_PROTEGE_PHP_MODELES', creer_uniqid());
367 367
 			}
368 368
 			foreach ($r as $regs)
369
-				$t = str_replace($regs[0],code_echappement($regs[0],'php'._PROTEGE_PHP_MODELES),$t);
369
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
370 370
 		}
371 371
 	}
372 372
 	return $t;
373 373
 }
374 374
 
375 375
 
376
-function echapper_faux_tags($letexte){
377
-	if (strpos($letexte,'<')===false)
376
+function echapper_faux_tags($letexte) {
377
+	if (strpos($letexte, '<') === false)
378 378
 		return $letexte;
379
-  $textMatches = preg_split (',(</?[a-z!][^<>]*>),', $letexte, null, PREG_SPLIT_DELIM_CAPTURE);
379
+  $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, null, PREG_SPLIT_DELIM_CAPTURE);
380 380
 
381 381
   $letexte = "";
382 382
   while (count($textMatches)) {
383 383
   	// un texte a echapper
384
-  	$letexte .= str_replace("<",'&lt;',array_shift($textMatches));
384
+  	$letexte .= str_replace("<", '&lt;', array_shift($textMatches));
385 385
   	// un tag html qui a servit a faite le split
386 386
  		$letexte .= array_shift($textMatches);
387 387
   }
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
  * @param string $texte
397 397
  * @return string
398 398
  */
399
-function echapper_html_suspect($texte){
400
-	if (strpos($texte,'<')===false OR strpos($texte,'=')===false)
399
+function echapper_html_suspect($texte) {
400
+	if (strpos($texte, '<') === false OR strpos($texte, '=') === false)
401 401
 		return $texte;
402 402
 
403 403
 	// on teste sur strlen car safehtml supprime le contenu dangereux
404 404
 	// mais il peut aussi changer des ' en " sur les attributs html,
405 405
 	// donc un test d'egalite est trop strict
406
-	if (strlen(safehtml($texte))!==strlen($texte)){
407
-		$texte = str_replace("<","&lt;",$texte);
406
+	if (strlen(safehtml($texte)) !== strlen($texte)) {
407
+		$texte = str_replace("<", "&lt;", $texte);
408 408
 	}
409 409
 
410 410
 	return $texte;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	if (!$t OR !is_string($t))
434 434
 		return $t;
435 435
 	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
436
-	if (strpos($t,'<')===false)
436
+	if (strpos($t, '<') === false)
437 437
 		return str_replace("\x00", '', $t);
438 438
 
439 439
 	$t = interdire_scripts($t); // jolifier le php
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 // Sert aussi a nettoyer un texte qu'on veut mettre dans un <a> etc.
454 454
 // TODO: gerer les modeles ?
455 455
 // http://doc.spip.org/@supprime_img
456
-function supprime_img($letexte, $message=NULL) {
457
-	if ($message===NULL) $message = '(' . _T('img_indisponible') . ')';
456
+function supprime_img($letexte, $message = NULL) {
457
+	if ($message === NULL) $message = '('._T('img_indisponible').')';
458 458
 	return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
459 459
 		$message, $letexte);
460 460
 }
Please login to merge, or discard this patch.
ecrire/inc/precharger_objet.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *                             dans la declaration de l'objet
30 30
  * @return array couples cles / valeurs des champs du formulaire à charger.
31 31
 **/
32
-function precharger_objet($type, $id_objet, $id_rubrique=0, $lier_trad=0, $champ_titre = 'titre') {
32
+function precharger_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') {
33 33
 	global $connect_id_rubrique, $spip_lang;
34 34
 	
35 35
 	$table = table_objet_sql($type);
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 
50 50
 	// si demande de traduction
51 51
 	// on recupere les valeurs de la traduction
52
-	if ($lier_trad){
53
-		if ($select = charger_fonction("precharger_traduction_" . $type,'inc',true))
52
+	if ($lier_trad) {
53
+		if ($select = charger_fonction("precharger_traduction_".$type, 'inc', true))
54 54
 			$row = $select($id_objet, $id_rubrique, $lier_trad);
55 55
 		else
56 56
 			$row = precharger_traduction_objet($type, $id_objet, $id_rubrique, $lier_trad, $champ_titre);
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 				$row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", 1);
75 75
 				$row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique'];
76 76
 			}
77
-			if (!autoriser('creerarticledans','rubrique',$row['id_rubrique'] )){
77
+			if (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique'])) {
78 78
 				// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
79 79
 				$res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0");
80
-				while (!autoriser('creerarticledans','rubrique',$row['id_rubrique'] ) && $row_rub = sql_fetch($res)){
80
+				while (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique']) && $row_rub = sql_fetch($res)) {
81 81
 					$row['id_rubrique'] = $row_rub['id_rubrique'];
82 82
 				}
83 83
 			}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	// recuperer le secteur, pour affecter les bons champs extras
88 88
 	if ($id_rubrique and $is_secteur) {
89 89
 		if (!$row['id_secteur']) {
90
-			$row_rub = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=" . sql_quote($id_rubrique));
90
+			$row_rub = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=".sql_quote($id_rubrique));
91 91
 			$row['id_secteur'] = $row_rub;
92 92
 		}
93 93
 	}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
  * 
109 109
  * @return array couples cles / valeurs des champs du formulaire à charger
110 110
 **/
111
-function precharger_traduction_objet($type, $id_objet, $id_rubrique=0, $lier_trad=0, $champ_titre = 'titre') {
111
+function precharger_traduction_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') {
112 112
 	$table = table_objet_sql($type);
113 113
 	$_id_objet = id_table_objet($table);
114 114
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			// Si le menu de langues est autorise sur l'objet,
141 141
 			// on peut changer la langue quelle que soit la rubrique
142 142
 			// donc on reste dans la meme rubrique
143
-			if (in_array($table, explode(',',$GLOBALS['meta']['multi_objets']))) {
143
+			if (in_array($table, explode(',', $GLOBALS['meta']['multi_objets']))) {
144 144
 				$row['id_rubrique'] = $row['id_rubrique']; # explicite :-)
145 145
 
146 146
 			// Sinon, chercher la rubrique la plus adaptee pour
Please login to merge, or discard this patch.
ecrire/inc/cvt_configurer.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
  * @param array $flux
21 21
  * @return array
22 22
  */
23
-function cvtconf_formulaire_charger($flux){
23
+function cvtconf_formulaire_charger($flux) {
24 24
 	if (
25 25
 		$form = $flux['args']['form']
26
-		and strncmp($form,'configurer_',11)==0 // un #FORMULAIRE_CONFIGURER_XXX
26
+		and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
27 27
 	) {
28 28
 		// Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé
29 29
 		include_spip('inc/autoriser');
30
-		if (!autoriser('configurer', '_'.substr($form,11))) {
30
+		if (!autoriser('configurer', '_'.substr($form, 11))) {
31 31
 			return false;
32 32
 		}
33 33
 		
34 34
 		// S'il n'y a pas de fonction charger(), on génère un contexte automatiquement
35
-		if (!charger_fonction("charger","formulaires/$form/",true)) {
35
+		if (!charger_fonction("charger", "formulaires/$form/", true)) {
36 36
 			$flux['data'] = cvtconf_formulaires_configurer_recense($form);
37 37
 			$flux['data']['editable'] = true;
38
-			if (_request('var_mode')=='configurer' AND autoriser('webmestre')){
38
+			if (_request('var_mode') == 'configurer' AND autoriser('webmestre')) {
39 39
 				if (!_AJAX) var_dump($flux['data']);
40 40
 				// reinjecter pour la trace au traitement
41 41
 				$flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />";
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
  * @param array $flux
52 52
  * @return array
53 53
  */
54
-function cvtconf_formulaire_traiter($flux){
54
+function cvtconf_formulaire_traiter($flux) {
55 55
 	if ($form = $flux['args']['form']
56
-	  AND strncmp($form,'configurer_',11)==0 // un #FORMULAIRE_CONFIGURER_XXX
57
-		AND !charger_fonction("traiter","formulaires/$form/",true) // sans fonction traiter()
56
+	  AND strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
57
+		AND !charger_fonction("traiter", "formulaires/$form/", true) // sans fonction traiter()
58 58
 		) {
59
-		$trace = cvtconf_formulaires_configurer_enregistre($form,$flux['args']['args']);
60
-		$flux['data'] = array('message_ok'=>_T('config_info_enregistree').$trace,'editable'=>true);
59
+		$trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']);
60
+		$flux['data'] = array('message_ok'=>_T('config_info_enregistree').$trace, 'editable'=>true);
61 61
 	}
62 62
 	return $flux;
63 63
 }
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
  *   arguments de l'appel de la fonction traiter ($args = func_get_args();)
75 75
  * @return string
76 76
  */
77
-function cvtconf_formulaires_configurer_enregistre($form,$args){
77
+function cvtconf_formulaires_configurer_enregistre($form, $args) {
78 78
 		$valeurs = array();
79 79
 		// charger les valeurs
80 80
 		// ce qui permet de prendre en charge une fonction charger() existante
81 81
 		// qui prend alors la main sur l'auto detection
82
-		if ($charger_valeurs = charger_fonction("charger","formulaires/$form/",true))
83
-			$valeurs = call_user_func_array($charger_valeurs,$args);
82
+		if ($charger_valeurs = charger_fonction("charger", "formulaires/$form/", true))
83
+			$valeurs = call_user_func_array($charger_valeurs, $args);
84 84
 		$valeurs = pipeline(
85 85
 			'formulaire_charger',
86 86
 			array(
87
-				'args'=>array('form'=>$form,'args'=>$args,'je_suis_poste'=>false),
87
+				'args'=>array('form'=>$form, 'args'=>$args, 'je_suis_poste'=>false),
88 88
 				'data'=>$valeurs)
89 89
 		);
90 90
 		// ne pas stocker editable !
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
 		// recuperer les valeurs postees
94 94
 		$store = array();
95
-		foreach($valeurs as $k=>$v){
96
-			if (substr($k,0,1)!=='_')
95
+		foreach ($valeurs as $k=>$v) {
96
+			if (substr($k, 0, 1) !== '_')
97 97
 				$store[$k] = _request($k);
98 98
 		}
99 99
 
100
-		return cvtconf_configurer_stocker($form,$valeurs,$store);
100
+		return cvtconf_configurer_stocker($form, $valeurs, $store);
101 101
 }
102 102
 
103 103
 /**
@@ -112,26 +112,26 @@  discard block
 block discarded – undo
112 112
  * @param array $valeurs
113 113
  * @return array
114 114
  */
115
-function cvtconf_definir_configurer_conteneur($form,$valeurs) {
115
+function cvtconf_definir_configurer_conteneur($form, $valeurs) {
116 116
 		// stocker en base
117 117
 		// par defaut, dans un casier serialize dans spip_meta (idem CFG)
118
-		$casier = substr($form,11);
118
+		$casier = substr($form, 11);
119 119
 		$table = 'meta';
120 120
 		$prefixe = '';
121 121
 		$stockage = '';
122 122
 
123 123
 		if (isset($valeurs['_meta_casier']))   $casier   = $valeurs['_meta_casier'];
124 124
 		if (isset($valeurs['_meta_prefixe']))  $prefixe  = $valeurs['_meta_prefixe'];
125
-		if (isset($valeurs['_meta_stockage'])) $stockage = $valeurs['_meta_stockage'] . '::';
125
+		if (isset($valeurs['_meta_stockage'])) $stockage = $valeurs['_meta_stockage'].'::';
126 126
 			
127 127
 		// si on indique juste une table, il faut vider les autres proprietes
128 128
 		// car par defaut on utilise ni casier ni prefixe dans ce cas
129 129
 		if (isset($valeurs['_meta_table'])) {
130 130
 			$table = $valeurs['_meta_table'];
131
-			$casier = (isset($valeurs['_meta_casier'])?$valeurs['_meta_casier']:'');
131
+			$casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : '');
132 132
 		}
133 133
 	
134
-		return array($table,$casier,$prefixe,$stockage);
134
+		return array($table, $casier, $prefixe, $stockage);
135 135
 }
136 136
 
137 137
 /**
@@ -141,39 +141,39 @@  discard block
 block discarded – undo
141 141
  * @param string $form
142 142
  * @return array
143 143
  */
144
-function cvtconf_formulaires_configurer_recense($form){
144
+function cvtconf_formulaires_configurer_recense($form) {
145 145
 	$valeurs = array('editable'=>' ');
146 146
 
147 147
 	// sinon cas analyse du squelette
148
-	if ($f = find_in_path($form.'.' . _EXTENSION_SQUELETTES, 'formulaires/')
148
+	if ($f = find_in_path($form.'.'._EXTENSION_SQUELETTES, 'formulaires/')
149 149
 		AND lire_fichier($f, $contenu)) {
150 150
 
151
-		for ($i=0;$i<2;$i++) {
151
+		for ($i = 0; $i < 2; $i++) {
152 152
 			// a la seconde iteration, evaluer le fond avec les valeurs deja trouvees
153 153
 			// permet de trouver aussi les name="#GET{truc}"
154
-			if ($i==1) $contenu = recuperer_fond("formulaires/$form",$valeurs);
154
+			if ($i == 1) $contenu = recuperer_fond("formulaires/$form", $valeurs);
155 155
 
156
-			$balises = array_merge(extraire_balises($contenu,'input'),
157
-				extraire_balises($contenu,'textarea'),
158
-				extraire_balises($contenu,'select'));
156
+			$balises = array_merge(extraire_balises($contenu, 'input'),
157
+				extraire_balises($contenu, 'textarea'),
158
+				extraire_balises($contenu, 'select'));
159 159
 
160
-			foreach($balises as $b) {
160
+			foreach ($balises as $b) {
161 161
 				if ($n = extraire_attribut($b, 'name')
162
-					AND preg_match(",^([\w\-]+)(\[\w*\])?$,",$n,$r)
163
-					AND !in_array($n,array('formulaire_action','formulaire_action_args'))
164
-					AND extraire_attribut($b,'type')!=='submit') {
162
+					AND preg_match(",^([\w\-]+)(\[\w*\])?$,", $n, $r)
163
+					AND !in_array($n, array('formulaire_action', 'formulaire_action_args'))
164
+					AND extraire_attribut($b, 'type') !== 'submit') {
165 165
 						$valeurs[$r[1]] = '';
166 166
 						// recuperer les valeurs _meta_xx qui peuvent etre fournies
167 167
 						// en input hidden dans le squelette
168
-						if (strncmp($r[1],'_meta_',6)==0)
169
-							$valeurs[$r[1]] = extraire_attribut($b,'value');
168
+						if (strncmp($r[1], '_meta_', 6) == 0)
169
+							$valeurs[$r[1]] = extraire_attribut($b, 'value');
170 170
 					}
171 171
 			}
172 172
 		}
173 173
 	}
174 174
 
175 175
 
176
-	cvtconf_configurer_lire_meta($form,$valeurs);
176
+	cvtconf_configurer_lire_meta($form, $valeurs);
177 177
 	return $valeurs;
178 178
 }
179 179
 
@@ -184,21 +184,21 @@  discard block
 block discarded – undo
184 184
  * @param array $store
185 185
  * @return string
186 186
  */
187
-function cvtconf_configurer_stocker($form,$valeurs,$store) {
187
+function cvtconf_configurer_stocker($form, $valeurs, $store) {
188 188
 	$trace = '';
189
-	list($table,$casier,$prefixe,$stockage) = cvtconf_definir_configurer_conteneur($form,$valeurs);
189
+	list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs);
190 190
 	// stocker en base
191 191
 	// par defaut, dans un casier serialize dans spip_meta (idem CFG)
192 192
 	if (!isset($GLOBALS[$table]))
193 193
 		lire_metas($table);
194 194
 
195
-	$prefixe = ($prefixe?$prefixe.'_':'');
195
+	$prefixe = ($prefixe ? $prefixe.'_' : '');
196 196
 	$table = ($table) ? "/$table/" : ""; 
197
-	$casier = ($casier) ? rtrim($casier,'/').'/' : ""; // slash final, sinon rien
197
+	$casier = ($casier) ? rtrim($casier, '/').'/' : ""; // slash final, sinon rien
198 198
 	
199
-	foreach($store as $k=>$v){
199
+	foreach ($store as $k=>$v) {
200 200
 		ecrire_config("$stockage$table$prefixe$casier$k", $v);
201
-		if (_request('var_mode')=='configurer' AND autoriser('webmestre')){
201
+		if (_request('var_mode') == 'configurer' AND autoriser('webmestre')) {
202 202
 			$trace .= "<br />table $table : ".$prefixe.$k." = $v;";
203 203
 		}
204 204
 	}
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
  * @param string $form
211 211
  * @param array $valeurs
212 212
  */
213
-function cvtconf_configurer_lire_meta($form,&$valeurs) {
214
-	list($table,$casier,$prefixe,$stockage) = cvtconf_definir_configurer_conteneur($form,$valeurs);
213
+function cvtconf_configurer_lire_meta($form, &$valeurs) {
214
+	list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs);
215 215
 
216 216
 	$table = ($table) ? "/$table/" : ""; 
217
-	$prefixe = ($prefixe?$prefixe.'_':'');
217
+	$prefixe = ($prefixe ? $prefixe.'_' : '');
218 218
 	if ($casier) {
219 219
 		$meta = lire_config("$stockage$table$prefixe$casier");
220 220
 		$prefixe = '';
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 		$meta = lire_config("$stockage$table");
225 225
 	}
226 226
 
227
-	foreach($valeurs as $k=>$v){
228
-		if (substr($k,0,1)!=='_')
229
-		$valeurs[$k] = (isset($meta[$prefixe.$k])?$meta[$prefixe.$k]:'');
227
+	foreach ($valeurs as $k=>$v) {
228
+		if (substr($k, 0, 1) !== '_')
229
+		$valeurs[$k] = (isset($meta[$prefixe.$k]) ? $meta[$prefixe.$k] : '');
230 230
 	}
231 231
 }
232 232
 
Please login to merge, or discard this patch.
ecrire/inc/notifications.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
  * @param array $options
25 25
  *   options de notification, interpretees en fonction de la notification
26 26
  */
27
-function inc_notifications_dist($quoi, $id=0, $options=array()) {
27
+function inc_notifications_dist($quoi, $id = 0, $options = array()) {
28 28
 
29 29
 	// charger les fichiers qui veulent ajouter des definitions
30 30
 	// ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ...
31
-	pipeline('notifications',array('args'=>array('quoi'=>$quoi,'id'=>$id,'options'=>$options)));
31
+	pipeline('notifications', array('args'=>array('quoi'=>$quoi, 'id'=>$id, 'options'=>$options)));
32 32
 
33
-	if ($notification = charger_fonction($quoi,'notifications',true)) {
33
+	if ($notification = charger_fonction($quoi, 'notifications', true)) {
34 34
 		spip_log("$notification($quoi,$id"
35
-			.($options?",".serialize($options):"")
36
-			.")",'notifications');
35
+			.($options ? ",".serialize($options) : "")
36
+			.")", 'notifications');
37 37
 		$notification($quoi, $id, $options);
38 38
 	}
39 39
 }
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
  * @param array $emails
48 48
  * @param array $exclure
49 49
  */
50
-function notifications_nettoyer_emails(&$emails, $exclure = array()){
50
+function notifications_nettoyer_emails(&$emails, $exclure = array()) {
51 51
 	// filtrer et unifier
52 52
 	include_spip('inc/filtres');
53
-	$emails = array_unique(array_filter(array_map('email_valide',array_map('trim', $emails))));
54
-	if ($exclure AND count($exclure)){
53
+	$emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails))));
54
+	if ($exclure AND count($exclure)) {
55 55
 		// nettoyer les exclusions d'abord
56 56
 		notifications_nettoyer_emails($exclure);
57 57
 		// faire un diff
58
-		$emails = array_diff($emails,$exclure);
58
+		$emails = array_diff($emails, $exclure);
59 59
 	}
60 60
 }
61 61
 
@@ -69,31 +69,31 @@  discard block
 block discarded – undo
69 69
  * @param string $from
70 70
  * @param string $headers
71 71
  */
72
-function notifications_envoyer_mails($emails, $texte, $sujet="", $from = "", $headers = ""){
72
+function notifications_envoyer_mails($emails, $texte, $sujet = "", $from = "", $headers = "") {
73 73
 	// rien a faire si pas de texte !
74 74
 	if (!strlen($texte))
75 75
 		return;
76 76
 
77 77
 	// si on ne specifie qu'un email, le mettre dans un tableau
78 78
 	if (!is_array($emails))
79
-		$emails = explode(',',$emails);
79
+		$emails = explode(',', $emails);
80 80
 
81 81
 	notifications_nettoyer_emails($emails);
82 82
 
83 83
 	// tester si le mail est deja en html
84
-	if (strpos($texte,"<")!==false // eviter les tests suivants si possible
84
+	if (strpos($texte, "<") !== false // eviter les tests suivants si possible
85 85
 		AND $ttrim = trim($texte)
86
-		AND substr($ttrim,0,1)=="<"
87
-	  AND substr($ttrim,-1,1)==">"
88
-	  AND stripos($ttrim,"</html>")!==false){
86
+		AND substr($ttrim, 0, 1) == "<"
87
+	  AND substr($ttrim, -1, 1) == ">"
88
+	  AND stripos($ttrim, "</html>") !== false) {
89 89
 
90
-		if(!strlen($sujet)){
90
+		if (!strlen($sujet)) {
91 91
 			// dans ce cas on ruse un peu : extraire le sujet du title
92
-			if (preg_match(",<title>(.*)</title>,Uims",$texte,$m))
92
+			if (preg_match(",<title>(.*)</title>,Uims", $texte, $m))
93 93
 				$sujet = $m[1];
94 94
 			else {
95 95
 				// fallback, on prend le body si on le trouve
96
-				if (preg_match(",<body[^>]*>(.*)</body>,Uims",$texte,$m))
96
+				if (preg_match(",<body[^>]*>(.*)</body>,Uims", $texte, $m))
97 97
 					$ttrim = $m[1];
98 98
 
99 99
 				// et on extrait la premiere ligne de vrai texte...
@@ -102,35 +102,35 @@  discard block
 block discarded – undo
102 102
 				$ttrim = str_replace("\r\n", "\r", $ttrim);
103 103
 				$ttrim = str_replace("\r", "\n", $ttrim);
104 104
 				// decouper
105
-				$ttrim = explode("\n",trim($ttrim));
105
+				$ttrim = explode("\n", trim($ttrim));
106 106
 				// extraire la premiere ligne de texte brut
107 107
 				$sujet = array_shift($ttrim);
108 108
 			}
109 109
 		}
110 110
 
111 111
 		// si besoin on ajoute le content-type dans les headers
112
-		if (stripos($headers,"Content-Type")===false)
112
+		if (stripos($headers, "Content-Type") === false)
113 113
 			$headers .= "Content-Type: text/html\n";
114 114
 	}
115 115
 
116 116
 	// si le sujet est vide, extraire la premiere ligne du corps
117 117
 	// du mail qui est donc du texte
118
-	if (!strlen($sujet)){
118
+	if (!strlen($sujet)) {
119 119
 		// nettoyer un peu les retours chariots
120 120
 		$texte = str_replace("\r\n", "\r", $texte);
121 121
 		$texte = str_replace("\r", "\n", $texte);
122 122
 		// decouper
123
-		$texte = explode("\n",trim($texte));
123
+		$texte = explode("\n", trim($texte));
124 124
 		// extraire la premiere ligne
125 125
 		$sujet = array_shift($texte);
126
-		$texte = trim(implode("\n",$texte));
126
+		$texte = trim(implode("\n", $texte));
127 127
 	}
128 128
 
129
-	$envoyer_mail = charger_fonction('envoyer_mail','inc');
130
-	foreach($emails as $email){
129
+	$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
130
+	foreach ($emails as $email) {
131 131
 		// passer dans un pipeline qui permet un ajout eventuel
132 132
 		// (url de suivi des notifications par exemple)
133
-		$envoi = pipeline('notifications_envoyer_mails',array('email'=>$email,'sujet'=>$sujet,'texte'=>$texte));
133
+		$envoi = pipeline('notifications_envoyer_mails', array('email'=>$email, 'sujet'=>$sujet, 'texte'=>$texte));
134 134
 		$email = $envoi['email'];
135 135
 
136 136
 		job_queue_add('envoyer_mail', ">$email : ".$envoi['sujet'], array($email, $envoi['sujet'], $envoi['texte'], $from, $headers), 'inc/');
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
  * @return string
151 151
  */
152 152
 function email_notification_objet($id_objet, $type_objet, $modele) {
153
-	$envoyer_mail = charger_fonction('envoyer_mail','inc'); // pour nettoyer_titre_email
153
+	$envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email
154 154
 	$id_type = id_table_objet($type_objet);
155
-	return recuperer_fond($modele,array($id_type=>$id_objet,"id"=>$id_objet));
155
+	return recuperer_fond($modele, array($id_type=>$id_objet, "id"=>$id_objet));
156 156
 }
157 157
 
158 158
 /**
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
  * @return string
167 167
  */
168 168
 function email_notification_article($id_article, $modele) {
169
-	$envoyer_mail = charger_fonction('envoyer_mail','inc'); // pour nettoyer_titre_email
169
+	$envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email
170 170
 
171
-	return recuperer_fond($modele,array('id_article'=>$id_article));
171
+	return recuperer_fond($modele, array('id_article'=>$id_article));
172 172
 }
173 173
 
174 174
 // Compatibilite, ne plus utiliser
Please login to merge, or discard this patch.