Completed
Push — spip-3.0 ( 0bbd73...b24c06 )
by cam
06:45
created
ecrire/inc/iconifier.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 include_spip('inc/actions');
16 16
 
17 17
 // http://doc.spip.org/@inc_iconifier_dist
18
-function inc_iconifier_dist($objet, $id,  $script, $visible=false, $flag_modif=true) {
18
+function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) {
19 19
 	// compat avec anciens appels
20 20
 	$objet = objet_type($objet);
21 21
 	
22
-	return recuperer_fond('prive/objets/editer/logo',array('objet'=>$objet,'id_objet'=>$id,'editable'=>$flag_modif));
22
+	return recuperer_fond('prive/objets/editer/logo', array('objet'=>$objet, 'id_objet'=>$id, 'editable'=>$flag_modif));
23 23
 }
24 24
 
25 25
 ?>
Please login to merge, or discard this patch.
ecrire/inc/filtres_mime.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@  discard block
 block discarded – undo
16 16
 // Fichier des filtres d'incrustation d'un document selon son type MIME
17 17
 // Les 7 familles de base ne font rien sauf celle des textes
18 18
 
19
-function filtre_image_dist($t) {return '';}
20
-function filtre_audio_dist($t) {return '';}
21
-function filtre_video_dist($t) {return '';}
22
-function filtre_application_dist($t) {return '';}
23
-function filtre_message_dist($t) {return '';}
24
-function filtre_multipart_dist($t) {return '';}
19
+function filtre_image_dist($t) {return ''; }
20
+function filtre_audio_dist($t) {return ''; }
21
+function filtre_video_dist($t) {return ''; }
22
+function filtre_application_dist($t) {return ''; }
23
+function filtre_message_dist($t) {return ''; }
24
+function filtre_multipart_dist($t) {return ''; }
25 25
 
26 26
 // http://doc.spip.org/@filtre_text_txt_dist
27 27
 function filtre_text_dist($t) {
28 28
 	static $t1 = array('&', '<', '>');
29 29
 	static $t2 = array('&amp;', '&lt;', '&gt;');
30
-	return '<pre>' . str_replace($t1, $t2, $t) . '</pre>';
30
+	return '<pre>'.str_replace($t1, $t2, $t).'</pre>';
31 31
 }
32 32
 
33 33
 // http://doc.spip.org/@filtre_text_csv_dist
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 	list($entete, $lignes) = analyse_csv($t);
37 37
 	foreach ($lignes as &$l)
38 38
 		$l = join('|', $l);
39
-	$corps = join("\n", $lignes) . "\n";
40
-	$corps = $caption .
41
-		"\n|{{" .
42
-		join('}}|{{',$entete) .
43
-		"}}|" .
44
-		"\n|" .
45
-		str_replace("\n", "|\n|",$corps);
46
-	$corps = str_replace('&#34#','&#34;',$corps);
39
+	$corps = join("\n", $lignes)."\n";
40
+	$corps = $caption.
41
+		"\n|{{".
42
+		join('}}|{{', $entete).
43
+		"}}|".
44
+		"\n|".
45
+		str_replace("\n", "|\n|", $corps);
46
+	$corps = str_replace('&#34#', '&#34;', $corps);
47 47
 	include_spip('inc/texte');
48 48
 	return propre($corps);
49 49
 }
@@ -54,26 +54,26 @@  discard block
 block discarded – undo
54 54
 function filtre_text_html_dist($t)
55 55
 {
56 56
 	if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r))
57
-		return appliquer_filtre($t,'text/plain');
57
+		return appliquer_filtre($t, 'text/plain');
58 58
 
59
-	list(,$h,$t) = $r;
59
+	list(,$h, $t) = $r;
60 60
 
61 61
 	$style = '';
62 62
 	// recuperer les styles internes
63 63
 	if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER))
64
-		$style =  join("\n",$r[1]);
64
+		$style = join("\n", $r[1]);
65 65
 	// ... et externes
66 66
 
67 67
 	include_spip('inc/distant');
68 68
 	if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER))
69
-		foreach($r[0] as $l) {
70
-			preg_match("/href='([^']*)'/", str_replace('"',"'",$l), $m);
69
+		foreach ($r[0] as $l) {
70
+			preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
71 71
 			$style .= "\n/* $l */\n"
72
-			. str_replace('<','',recuperer_page($m[1]));
72
+			. str_replace('<', '', recuperer_page($m[1]));
73 73
 		}
74 74
 	// Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
75
-	$t = safehtml(preg_replace(',<script'.'.*?</script>,is','',$t));
76
-	return (!$style ? '' : "\n<style>".$style."</style>") . $t;
75
+	$t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t));
76
+	return (!$style ? '' : "\n<style>".$style."</style>").$t;
77 77
 }
78 78
 
79 79
 // http://doc.spip.org/@filtre_audio_x_pn_realaudio
Please login to merge, or discard this patch.
ecrire/inc/json.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 		case is_null($var) :
29 29
 			return 'null';
30 30
 		case is_string($var) :
31
-			return '"' .addcslashes($var, "\"\\\n\r/") . '"';
31
+			return '"'.addcslashes($var, "\"\\\n\r/").'"';
32 32
 		case is_bool($var) :
33 33
 			return $var ? 'true' : 'false';
34 34
 		case is_scalar($var) :
35
-			return (string)$var;
36
-		case is_object( $var) :
35
+			return (string) $var;
36
+		case is_object($var) :
37 37
 			$var = get_object_vars($var);
38 38
 			$asso = true;
39 39
 		case is_array($var) :
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
 			if ($asso) {
47 47
 				$ret = '{';
48 48
 				foreach ($var as $key => $elt) {
49
-					$ret .= $sep . '"' . $key . '":' . var2js($elt);
49
+					$ret .= $sep.'"'.$key.'":'.var2js($elt);
50 50
 					$sep = ',';
51 51
 				}
52
-				return $ret ."}";
52
+				return $ret."}";
53 53
 			} else {
54 54
 				$ret = '[';
55 55
 				foreach ($var as $elt) {
56
-					$ret .= $sep . var2js($elt);
56
+					$ret .= $sep.var2js($elt);
57 57
 					$sep = ',';
58 58
 				}
59
-				return $ret ."]";
59
+				return $ret."]";
60 60
 			}
61 61
 	}
62 62
 	return false;
63 63
 }
64 64
 
65
-if(!function_exists('json_encode')) {
65
+if (!function_exists('json_encode')) {
66 66
 	function json_encode($v) { return var2js($v); }
67 67
 }
68 68
 
Please login to merge, or discard this patch.
ecrire/inc/meta.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@  discard block
 block discarded – undo
16 16
 // Recopie dans le tableau PHP global meta, car on en a souvent besoin
17 17
 
18 18
 // duree maximale du cache. Le double pour l'antidater
19
-define('_META_CACHE_TIME', 1<<24);
19
+define('_META_CACHE_TIME', 1 << 24);
20 20
 
21 21
 // http://doc.spip.org/@inc_meta_dist
22
-function inc_meta_dist($table='meta')
22
+function inc_meta_dist($table = 'meta')
23 23
 {
24 24
 	// Lire les meta, en cache si present, valide et lisible
25 25
 	// en cas d'install ne pas faire confiance au meta_cache eventuel
26 26
 	$cache = cache_meta($table);
27 27
 
28
-	if ((_request('exec')!=='install' OR !test_espace_prive())
28
+	if ((_request('exec') !== 'install' OR !test_espace_prive())
29 29
 	AND $new = jeune_fichier($cache, _META_CACHE_TIME)
30 30
 	AND lire_fichier_securise($cache, $meta)
31 31
 	AND $meta = @unserialize($meta))
32 32
 		$GLOBALS[$table] = $meta;
33 33
 
34 34
 	if (isset($GLOBALS[$table]['touch']) 
35
-	AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME))
35
+	AND ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME))
36 36
 		$GLOBALS[$table] = array();
37 37
 	// sinon lire en base
38 38
 	if (!$GLOBALS[$table]) $new = !lire_metas($table);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			include_spip('inc/acces');
48 48
 			renouvelle_alea();
49 49
 			$new = false; 
50
-		} else spip_log("impossible d'ecrire dans " . $cache);
50
+		} else spip_log("impossible d'ecrire dans ".$cache);
51 51
 	}
52 52
 	// et refaire le cache si on a du lire en base
53 53
 	if (!$new) touch_meta(false, $table);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 // pour eviter l'erreur fatale (serveur non encore configure)
58 58
 
59 59
 // http://doc.spip.org/@lire_metas
60
-function lire_metas($table='meta') {
60
+function lire_metas($table = 'meta') {
61 61
 
62 62
 	if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
63 63
 		include_spip('base/abstract_sql');
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
         sql_free($result);
68 68
 
69 69
 		if (!$GLOBALS[$table]['charset']
70
-		  OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
70
+		  OR $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
71 71
 		)
72 72
 			ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table);
73 73
 
74 74
 		// noter cette table de configuration dans les meta de SPIP
75
-		if ($table!=='meta') {
75
+		if ($table !== 'meta') {
76 76
 			$liste = unserialize($GLOBALS['meta']['tables_config']);
77 77
 			if (!$liste)
78 78
 				$liste = array();
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 // Mettre en cache la liste des meta, sauf les valeurs sensibles 
89 89
 // pour qu'elles ne soient pas visibiles dans un fichier.souvent en 777
90 90
 // http://doc.spip.org/@touch_meta
91
-function touch_meta($antidate= false, $table='meta'){
91
+function touch_meta($antidate = false, $table = 'meta') {
92 92
 	$file = cache_meta($table);
93 93
 	if (!$antidate OR !@touch($file, $antidate)) {
94 94
 		$r = $GLOBALS[$table];
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
 		// mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
99 99
 		// meme si son squelette est en cache
100 100
 		//unset($r['secret_du_site']);
101
-		if ($antidate) $r['touch']= $antidate;
101
+		if ($antidate) $r['touch'] = $antidate;
102 102
 		ecrire_fichier_securise($file, serialize($r));
103 103
 	}
104 104
 }
105 105
 
106 106
 // http://doc.spip.org/@effacer_meta
107
-function effacer_meta($nom, $table='meta') {
107
+function effacer_meta($nom, $table = 'meta') {
108 108
 	// section critique sur le cache:
109 109
 	// l'invalider avant et apres la MAJ de la BD
110 110
 	// c'est un peu moins bien qu'un vrai verrou mais ca suffira
111 111
 	// et utiliser une statique pour eviter des acces disques a repetition
112 112
 	static $touch = array();
113
-	$antidate = time() - (_META_CACHE_TIME<<4);
114
-	if (!isset($touch[$table])) {touch_meta($antidate, $table);}
115
-	sql_delete('spip_' . $table, "nom='$nom'");
113
+	$antidate = time() - (_META_CACHE_TIME << 4);
114
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); }
115
+	sql_delete('spip_'.$table, "nom='$nom'");
116 116
 	unset($GLOBALS[$table][$nom]);
117
-	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
117
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false; }
118 118
 }
119 119
 
120 120
 // http://doc.spip.org/@ecrire_meta
121
-function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') {
121
+function ecrire_meta($nom, $valeur, $importable = NULL, $table = 'meta') {
122 122
 
123 123
 	static $touch = array();
124 124
 	if (!$nom) return;
125 125
 	include_spip('base/abstract_sql');
126
-	$res = sql_select("*",'spip_' . $table,"nom=" . sql_quote($nom),'','','','','','continue');
126
+	$res = sql_select("*", 'spip_'.$table, "nom=".sql_quote($nom), '', '', '', '', '', 'continue');
127 127
 	// table pas encore installee, travailler en php seulement
128 128
 	if (!$res) {
129 129
 		$GLOBALS[$table][$nom] = $valeur;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 
139 139
 	$GLOBALS[$table][$nom] = $valeur;
140 140
 	// cf effacer pour comprendre le double touch
141
-	$antidate = time() - (_META_CACHE_TIME<<1);
142
-	if (!isset($touch[$table])) {touch_meta($antidate, $table);}
141
+	$antidate = time() - (_META_CACHE_TIME << 1);
142
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); }
143 143
 	$r = array('nom' => $nom, 'valeur' => $valeur);
144 144
 	// Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
145 145
 	if ($importable AND isset($row['impt'])) $r['impt'] = $importable;
146 146
 	if ($row) {
147
-		sql_updateq('spip_' . $table, $r,"nom=" . sql_quote($nom));
147
+		sql_updateq('spip_'.$table, $r, "nom=".sql_quote($nom));
148 148
 	} else {
149
-		sql_insertq('spip_' . $table, $r);
149
+		sql_insertq('spip_'.$table, $r);
150 150
 	}
151
-	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false;}
151
+	if (!isset($touch[$table])) {touch_meta($antidate, $table); $touch[$table] = false; }
152 152
 }
153 153
 
154
-function cache_meta($table='meta')
154
+function cache_meta($table = 'meta')
155 155
 {
156
-	return ($table=='meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
156
+	return ($table == 'meta') ? _FILE_META : (_DIR_CACHE.$table.'.php');
157 157
 }
158 158
 
159 159
 /**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
  * @param string $table
162 162
  */
163 163
 function installer_table_meta($table) {
164
-	$trouver_table = charger_fonction('trouver_table','base');
164
+	$trouver_table = charger_fonction('trouver_table', 'base');
165 165
 	if (!$trouver_table("spip_$table")) {
166 166
 		include_spip('base/auxiliaires');
167 167
 		include_spip('base/create');
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
  * @param string $table
179 179
  * @param bool $force
180 180
  */
181
-function supprimer_table_meta($table, $force=false) {
182
-	if ($table=='meta') return; // interdit !
181
+function supprimer_table_meta($table, $force = false) {
182
+	if ($table == 'meta') return; // interdit !
183 183
 
184 184
 	if ($force OR !sql_countsel("spip_$table")) {
185 185
 		unset($GLOBALS[$table]);
186 186
 		sql_drop_table("spip_$table");
187 187
 		// vider le cache des tables
188
-		$trouver_table = charger_fonction('trouver_table','base');
188
+		$trouver_table = charger_fonction('trouver_table', 'base');
189 189
 		$trouver_table('');
190 190
 	}
191 191
 }
Please login to merge, or discard this patch.
ecrire/inc/config.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
  * @param string $cfg
32 32
  * @return array
33 33
  */
34
-function expliquer_config($cfg){
34
+function expliquer_config($cfg) {
35 35
 	// par defaut, sur la table des meta
36 36
 	$table = 'meta';
37 37
 	$casier = null;
38 38
 	$sous_casier = array();
39
-	if (strlen($cfg)){
40
-		$cfg = explode('/',$cfg);
39
+	if (strlen($cfg)) {
40
+		$cfg = explode('/', $cfg);
41 41
 		// si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide ''
42
-		if (!reset($cfg) AND count($cfg)>1) {
42
+		if (!reset($cfg) AND count($cfg) > 1) {
43 43
 			array_shift($cfg);
44 44
 			$table = array_shift($cfg);
45 45
 			if (!isset($GLOBALS[$table]))
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		if (count($cfg))
53 53
 			$sous_casier = $cfg;
54 54
 	}
55
-	return array($table,$casier,$sous_casier);
55
+	return array($table, $casier, $sous_casier);
56 56
 }
57 57
 
58 58
 /**
@@ -74,33 +74,33 @@  discard block
 block discarded – undo
74 74
  * @param  boolean $unserialize  n'affecte que le dépôt 'meta'
75 75
  * @return string
76 76
  */
77
-function lire_config($cfg='', $def=null, $unserialize=true) {
77
+function lire_config($cfg = '', $def = null, $unserialize = true) {
78 78
 	// lire le stockage sous la forme /table/valeur
79 79
 	// ou valeur qui est en fait implicitement /meta/valeur
80 80
 	// ou casier/valeur qui est en fait implicitement /meta/casier/valeur
81 81
 
82 82
 	// traiter en priorite le cas simple et frequent
83 83
 	// de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni :
84
-	if ($cfg AND strpbrk($cfg,'/:')===false){
85
-		$r = isset($GLOBALS['meta'][$cfg])?
84
+	if ($cfg AND strpbrk($cfg, '/:') === false) {
85
+		$r = isset($GLOBALS['meta'][$cfg]) ?
86 86
 		  ((!$unserialize
87 87
 			// ne pas essayer de deserialiser autre chose qu'une chaine
88 88
 			OR !is_string($GLOBALS['meta'][$cfg])
89 89
 			// ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee
90
-			OR strpos($GLOBALS['meta'][$cfg],':')===false
91
-			OR ($t=unserialize($GLOBALS['meta'][$cfg]))===false)?$GLOBALS['meta'][$cfg]:$t)
90
+			OR strpos($GLOBALS['meta'][$cfg], ':') === false
91
+			OR ($t = unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t)
92 92
 		  :$def;
93 93
 		return $r;
94 94
 	}
95 95
 
96 96
 	// Brancher sur methodes externes si besoin
97
-	if ($cfg AND $p=strpos($cfg,'::')){
98
-		$methode = substr($cfg,0,$p);
97
+	if ($cfg AND $p = strpos($cfg, '::')) {
98
+		$methode = substr($cfg, 0, $p);
99 99
 		$lire_config = charger_fonction($methode, 'lire_config');
100
-		return $lire_config(substr($cfg,$p+2),$def,$unserialize);
100
+		return $lire_config(substr($cfg, $p + 2), $def, $unserialize);
101 101
 	}
102 102
 
103
-	list($table,$casier,$sous_casier) = expliquer_config($cfg);
103
+	list($table, $casier, $sous_casier) = expliquer_config($cfg);
104 104
 
105 105
 	if (!isset($GLOBALS[$table]))
106 106
 			return $def;
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	// le deserializer si demande
116 116
 	// ou si on a besoin
117 117
 	// d'un sous casier
118
-	$r = isset($r[$casier])?$r[$casier]:null;
118
+	$r = isset($r[$casier]) ? $r[$casier] : null;
119 119
 	if (($unserialize OR count($sous_casier)) AND $r AND is_string($r))
120
-		$r = (($t=unserialize($r))===false?$r:$t);
120
+		$r = (($t = unserialize($r)) === false ? $r : $t);
121 121
 
122 122
 	// aller chercher le sous_casier
123
-	while(!is_null($r) AND $casier = array_shift($sous_casier))
124
-		$r = isset($r[$casier])?$r[$casier]:null;
123
+	while (!is_null($r) AND $casier = array_shift($sous_casier))
124
+		$r = isset($r[$casier]) ? $r[$casier] : null;
125 125
 
126 126
 	if (is_null($r)) return $def;
127 127
 	return $r;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
  * @param bool $unserialize
138 138
  * @return mixed
139 139
  */
140
-function lire_config_metapack_dist($cfg='', $def=null, $unserialize=true) {
140
+function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) {
141 141
 	return lire_config($cfg, $def, $unserialize);
142 142
 }
143 143
 
@@ -149,27 +149,27 @@  discard block
 block discarded – undo
149 149
  * @param mixed $store
150 150
  * @return bool
151 151
  */
152
-function ecrire_config($cfg,$store) {
152
+function ecrire_config($cfg, $store) {
153 153
 	// Brancher sur methodes externes si besoin
154
-	if ($cfg AND $p=strpos($cfg,'::')){
155
-		$methode = substr($cfg,0,$p);
154
+	if ($cfg AND $p = strpos($cfg, '::')) {
155
+		$methode = substr($cfg, 0, $p);
156 156
 		$ecrire_config = charger_fonction($methode, 'ecrire_config');
157
-		return $ecrire_config(substr($cfg,$p+2),$store);
157
+		return $ecrire_config(substr($cfg, $p + 2), $store);
158 158
 	}
159 159
 	
160
-	list($table,$casier,$sous_casier) = expliquer_config($cfg);
160
+	list($table, $casier, $sous_casier) = expliquer_config($cfg);
161 161
 	// il faut au moins un casier pour ecrire
162 162
 	if (!$casier) return false;
163 163
 
164 164
 	// trouvons ou creons le pointeur sur le casier
165
-	$st = isset($GLOBALS[$table][$casier])?$GLOBALS[$table][$casier]:null;
165
+	$st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null;
166 166
 	if (!is_array($st) AND ($sous_casier OR is_array($store))) {
167 167
 		$st = unserialize($st);
168
-		if ($st===false) {
168
+		if ($st === false) {
169 169
 			// ne rien creer si c'est une demande d'effacement
170 170
 			if (is_null($store))
171 171
 				return false;
172
-			$st=array();
172
+			$st = array();
173 173
 		}
174 174
 	}
175 175
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	if ($c = $sous_casier) {
179 179
 		$sc = &$st;
180 180
 		$pointeurs = array();
181
-		while (count($c) AND $cc=array_shift($c)) {
181
+		while (count($c) AND $cc = array_shift($c)) {
182 182
 			// creer l'entree si elle n'existe pas
183 183
 			if (!isset($sc[$cc])) {
184 184
 				// si on essaye d'effacer une config qui n'existe pas
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		}
193 193
 
194 194
 		// si c'est une demande d'effacement
195
-		if (is_null($store)){
195
+		if (is_null($store)) {
196 196
 			$c = $sous_casier;
197 197
 			$sous = array_pop($c);
198 198
 			// effacer, et remonter pour effacer les parents vides
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 	if (is_null($store)) {
219 219
 		if (is_null($st) AND !$sous_casier)
220 220
 			return false; // la config n'existait deja pas !
221
-		effacer_meta ($casier, $table);
221
+		effacer_meta($casier, $table);
222 222
 		if (!count($GLOBALS[$table])
223
-			OR count($GLOBALS[$table])==1 AND isset($GLOBALS[$table]['charset'])) {
223
+			OR count($GLOBALS[$table]) == 1 AND isset($GLOBALS[$table]['charset'])) {
224 224
 			effacer_meta('charset', $table); // enlevons cette meta
225 225
 			supprimer_table_meta($table); // supprimons la table (si elle est bien vide)
226 226
 		}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		// si ce n'est pas une chaine
233 233
 		// il faut serializer
234 234
 		if (!is_string($store))
235
-			$store=serialize($store);
235
+			$store = serialize($store);
236 236
 		ecrire_meta($casier, $store, null, $table);
237 237
 	}
238 238
 	// verifier que lire_config($cfg)==$store ?
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
  * @param mixed $store
250 250
  * @return bool
251 251
  */
252
-function ecrire_config_metapack_dist($cfg,$store) {
252
+function ecrire_config_metapack_dist($cfg, $store) {
253 253
 	// cas particulier en metapack::
254 254
 	// si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre
255 255
 	// intacte en sortie ...
256
-	if (is_string($store) AND strpos($store,':') AND unserialize($store))
256
+	if (is_string($store) AND strpos($store, ':') AND unserialize($store))
257 257
 		$store = serialize($store);
258 258
 	return ecrire_config($cfg, $store);
259 259
 }
@@ -263,23 +263,23 @@  discard block
 block discarded – undo
263 263
  * @param string $cfg
264 264
  * @return bool
265 265
  */
266
-function effacer_config($cfg){
266
+function effacer_config($cfg) {
267 267
 	ecrire_config($cfg, null);
268 268
 	return true;
269 269
 }
270 270
 
271 271
 
272
-function lister_configurer($exclure = array()){
272
+function lister_configurer($exclure = array()) {
273 273
 	return array();
274 274
 	
275 275
 	// lister les pages de config deja dans les menus
276 276
 	$deja = array();
277
-	foreach($exclure as $id=>$b) {
277
+	foreach ($exclure as $id=>$b) {
278 278
 		$url = ($b['url'] ? $b['url'] : $id);
279 279
 		if (!$b['url'] or !isset($exclure[$url])) {
280
-			if (strncmp($url,'configurer_',11)==0) {
280
+			if (strncmp($url, 'configurer_', 11) == 0) {
281 281
 				$deja[$url] = $b;
282
-			} elseif($b['url']=='configurer' AND preg_match(',cfg=([a-z0-9_]+),i',$b['args'],$match)) {
282
+			} elseif ($b['url'] == 'configurer' AND preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) {
283 283
 				$deja["configurer_".$match[1]] = $b;
284 284
 			}
285 285
 		}
@@ -296,21 +296,21 @@  discard block
 block discarded – undo
296 296
 	// et construire un tableau des entrees qui ne sont pas dans $deja
297 297
 	$pages = find_all_in_path("prive/squelettes/contenu/", "configurer_.*[.]"._EXTENSION_SQUELETTES.'$');
298 298
 
299
-	foreach($pages as $page) {
300
-		$configurer = basename($page,"."._EXTENSION_SQUELETTES);
299
+	foreach ($pages as $page) {
300
+		$configurer = basename($page, "."._EXTENSION_SQUELETTES);
301 301
 		if (!isset($exclure[$configurer])) {
302 302
 			$liste[$configurer] = array(
303 303
 					'parent' => 'bando_configuration',
304 304
 					'url' => $configurer,
305 305
 					'titre' => _T("configurer:{$configurer}_titre"),
306
-					'icone' => find_in_theme($i="images/{$configurer}-16.png")?$i:$icone_defaut,
306
+					'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
307 307
 			);
308 308
 		}
309 309
 		$skels[$configurer] = $page;
310 310
 	}
311 311
 
312 312
 	// analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus
313
-	foreach($skels as $file) {
313
+	foreach ($skels as $file) {
314 314
 		$forms = array_merge($forms, lister_formulaires_configurer($file));
315 315
 	}
316 316
 	$forms = array_flip($forms);
@@ -318,17 +318,17 @@  discard block
 block discarded – undo
318 318
 	// trouver tous les formulaires/configurer_
319 319
 	// et construire un tableau des entrees
320 320
 	$pages = find_all_in_path("formulaires/", "configurer_.*[.]"._EXTENSION_SQUELETTES.'$');
321
-	foreach($pages as $page) {
322
-		$configurer = basename($page,"."._EXTENSION_SQUELETTES);
321
+	foreach ($pages as $page) {
322
+		$configurer = basename($page, "."._EXTENSION_SQUELETTES);
323 323
 		if (!isset($forms[$configurer])
324 324
 		  AND !isset($liste[$configurer])
325 325
 			AND !isset($exclure[$configurer]))
326 326
 			$liste[$configurer] = array(
327 327
 					'parent' => 'bando_configuration',
328 328
 					'url' => 'configurer',
329
-					'args' => 'cfg='.substr($configurer,11),
329
+					'args' => 'cfg='.substr($configurer, 11),
330 330
 					'titre' => _T("configurer:{$configurer}_titre"),
331
-					'icone' => find_in_theme($i="images/{$configurer}-16.png")?$i:$icone_defaut,
331
+					'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut,
332 332
 			);
333 333
 	}
334 334
 
@@ -347,27 +347,27 @@  discard block
 block discarded – undo
347 347
 	$forms = array();
348 348
 	
349 349
 	lire_fichier($file, $skel);
350
-	if (preg_match_all(",#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),", $skel, $matches,PREG_SET_ORDER)) {
351
-		$matches = array_map('end',$matches);
352
-		$matches = array_map('strtolower',$matches);
353
-		$forms = array_merge($forms,$matches);
350
+	if (preg_match_all(",#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),", $skel, $matches, PREG_SET_ORDER)) {
351
+		$matches = array_map('end', $matches);
352
+		$matches = array_map('strtolower', $matches);
353
+		$forms = array_merge($forms, $matches);
354 354
 	}
355 355
 
356 356
 	// evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent
357 357
 	// et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline
358
-	$config = basename(substr($file,0,-strlen("."._EXTENSION_SQUELETTES)));
358
+	$config = basename(substr($file, 0, -strlen("."._EXTENSION_SQUELETTES)));
359 359
 	spip_log('Calcul de '."prive/squelettes/contenu/$config");
360 360
 	$fond = recuperer_fond("prive/squelettes/contenu/$config", array("exec" => $config));
361 361
 	
362 362
 	// passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires...
363 363
 	// et donc que l'on puisse les referencer aussi !
364
-	$fond = pipeline('affiche_milieu', array('args'=>array("exec" => $config),'data'=>$fond));
364
+	$fond = pipeline('affiche_milieu', array('args'=>array("exec" => $config), 'data'=>$fond));
365 365
 
366 366
 	// recuperer les noms des formulaires presents.
367
-	if (is_array($inputs = extraire_balises($fond,"input"))) {
368
-		foreach($inputs as $i) {
369
-			if (extraire_attribut($i,'name')=='formulaire_action') {
370
-				$forms[] = ($c=extraire_attribut($i,'value'));
367
+	if (is_array($inputs = extraire_balises($fond, "input"))) {
368
+		foreach ($inputs as $i) {
369
+			if (extraire_attribut($i, 'name') == 'formulaire_action') {
370
+				$forms[] = ($c = extraire_attribut($i, 'value'));
371 371
 			}
372 372
 		}
373 373
 	}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 
416 416
 		'syndication_integrale' => 'oui',
417 417
 		'charset' => _DEFAULT_CHARSET,
418
-		'dir_img' => substr(_DIR_IMG,strlen(_DIR_RACINE)),
418
+		'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)),
419 419
 
420 420
 		'multi_rubriques' => 'non',
421 421
 		'multi_secteurs' => 'non',
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
 function actualise_metas($liste_meta)
440 440
 {
441 441
 	$meta_serveur =
442
-		array('version_installee','adresse_site','alea_ephemere_ancien','alea_ephemere','alea_ephemere_date','langue_site','langues_proposees','date_calcul_rubriques','derniere_modif','optimiser_table','drapeau_edition','creer_preview','taille_preview','creer_htpasswd','creer_htaccess','gd_formats_read','gd_formats',
443
-	'netpbm_formats','formats_graphiques','image_process','plugin_header','plugin');
442
+		array('version_installee', 'adresse_site', 'alea_ephemere_ancien', 'alea_ephemere', 'alea_ephemere_date', 'langue_site', 'langues_proposees', 'date_calcul_rubriques', 'derniere_modif', 'optimiser_table', 'drapeau_edition', 'creer_preview', 'taille_preview', 'creer_htpasswd', 'creer_htaccess', 'gd_formats_read', 'gd_formats',
443
+	'netpbm_formats', 'formats_graphiques', 'image_process', 'plugin_header', 'plugin');
444 444
 	// verifier le impt=non
445
-	sql_updateq('spip_meta',array('impt'=>'non'),sql_in('nom',$meta_serveur));
445
+	sql_updateq('spip_meta', array('impt'=>'non'), sql_in('nom', $meta_serveur));
446 446
 
447 447
 	while (list($nom, $valeur) = each($liste_meta)) {
448 448
 		if (!$GLOBALS['meta'][$nom]) {
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
 //
463 463
 
464 464
 // http://doc.spip.org/@appliquer_modifs_config
465
-function appliquer_modifs_config($purger_skel=false) {
465
+function appliquer_modifs_config($purger_skel = false) {
466 466
 
467
-	foreach(liste_metas() as $i => $v) {
468
-		if (($x =_request($i))!==NULL)
467
+	foreach (liste_metas() as $i => $v) {
468
+		if (($x = _request($i)) !== NULL)
469 469
 			ecrire_meta($i, $x);
470
-		elseif  (!isset($GLOBALS['meta'][$i]))
470
+		elseif (!isset($GLOBALS['meta'][$i]))
471 471
 			ecrire_meta($i, $v);
472 472
 	}
473 473
 
@@ -484,15 +484,15 @@  discard block
 block discarded – undo
484 484
  * @param  $adresse_site
485 485
  * @return void
486 486
  */
487
-function appliquer_adresse_site($adresse_site){
488
-	if ($adresse_site!==NULL){
489
-		if (!strlen($adresse_site)) {$GLOBALS['profondeur_url']=_DIR_RESTREINT?0:1;$adresse_site = url_de_base();}
487
+function appliquer_adresse_site($adresse_site) {
488
+	if ($adresse_site !== NULL) {
489
+		if (!strlen($adresse_site)) {$GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; $adresse_site = url_de_base(); }
490 490
 		$adresse_site = preg_replace(",/?\s*$,", "", $adresse_site);
491 491
 
492
-		if (!preg_match(",^[\w]+://,Uims",$adresse_site))
492
+		if (!preg_match(",^[\w]+://,Uims", $adresse_site))
493 493
 			$adresse_site = "http://$adresse_site";
494 494
 
495
-		ecrire_meta('adresse_site',$adresse_site);
495
+		ecrire_meta('adresse_site', $adresse_site);
496 496
 	}
497 497
 	return $adresse_site;
498 498
 }
Please login to merge, or discard this patch.
ecrire/inc/layer.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 if (!defined('_ECRIRE_INC_VERSION')) return;
14 14
 
15 15
 // http://doc.spip.org/@cadre_depliable
16
-function cadre_depliable($icone,$titre,$deplie,$contenu,$ids='',$style_cadre='r'){
17
-	$bouton = bouton_block_depliable($titre,$deplie,$ids);
16
+function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') {
17
+	$bouton = bouton_block_depliable($titre, $deplie, $ids);
18 18
 	return 
19
-		debut_cadre($style_cadre,$icone,'',$bouton, '', '', false)
20
-		. debut_block_depliable($deplie,$ids)
19
+		debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
20
+		. debut_block_depliable($deplie, $ids)
21 21
 		. "<div class='cadre_padding'>\n"
22 22
 		. $contenu
23 23
 		. "</div>\n"
@@ -26,21 +26,21 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 // http://doc.spip.org/@block_parfois_visible
29
-function block_parfois_visible($nom, $invite, $masque, $style='', $visible=false){
29
+function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) {
30 30
 	return "\n"
31
-	. bouton_block_depliable($invite,$visible,$nom)
32
-	. debut_block_depliable($visible,$nom)
31
+	. bouton_block_depliable($invite, $visible, $nom)
32
+	. debut_block_depliable($visible, $nom)
33 33
 	. $masque
34 34
 	. fin_block();
35 35
 }
36 36
 
37 37
 // http://doc.spip.org/@debut_block_depliable
38
-function debut_block_depliable($deplie,$id=""){
39
-	$class=' blocdeplie';
38
+function debut_block_depliable($deplie, $id = "") {
39
+	$class = ' blocdeplie';
40 40
 	// si on n'accepte pas js, ne pas fermer
41 41
 	if (!$deplie)
42
-		$class=" blocreplie";
43
-	return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>";	
42
+		$class = " blocreplie";
43
+	return "<div ".($id ? "id='$id' " : "")."class='bloc_depliable$class'>";	
44 44
 }
45 45
 // http://doc.spip.org/@fin_block
46 46
 function fin_block() {
@@ -50,31 +50,31 @@  discard block
 block discarded – undo
50 50
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page 
51 51
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
52 52
 // http://doc.spip.org/@bouton_block_depliable
53
-function bouton_block_depliable($texte,$deplie,$ids=""){
54
-	$bouton_id = 'b'.substr(md5($texte.microtime()),0,8);
53
+function bouton_block_depliable($texte, $deplie, $ids = "") {
54
+	$bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8);
55 55
 
56
-	$class = ($deplie===true)?" deplie":(($deplie==-1)?" impliable":" replie");
57
-	if (strlen($ids)){
58
-		$cible = explode(',',$ids);
59
-		$cible = '#'.implode(",#",$cible);
56
+	$class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie");
57
+	if (strlen($ids)) {
58
+		$cible = explode(',', $ids);
59
+		$cible = '#'.implode(",#", $cible);
60 60
 	}
61
-	else{
61
+	else {
62 62
 		$cible = "#$bouton_id + div.bloc_depliable";
63 63
 	}
64 64
 
65
-	$b = (strpos($texte,"<h")===false?'h3':'div');
65
+	$b = (strpos($texte, "<h") === false ? 'h3' : 'div');
66 66
 	return "<$b "
67
-	  .($bouton_id?"id='$bouton_id' ":"")
67
+	  .($bouton_id ? "id='$bouton_id' " : "")
68 68
 	  ."class='titrem$class'"
69
-	  . (($deplie===-1)
70
-	  	?""
69
+	  . (($deplie === -1)
70
+	  	? ""
71 71
 	  	:" onmouseover=\"jQuery(this).depliant('$cible');\""
72 72
 	  )
73 73
 	  .">"
74 74
 	  // une ancre pour rendre accessible au clavier le depliage du sous bloc
75 75
 	  . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
76 76
 	  . "$texte</$b>"
77
-	  . http_script( ($deplie==='incertain')
77
+	  . http_script(($deplie === 'incertain')
78 78
 			? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});"
79 79
 			: '');
80 80
 }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	$GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
95 95
 	$browser_barre = '';
96 96
 
97
-	if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) {
97
+	if (!preg_match(",opera,i", $browser_description) && preg_match(",opera,i", $browser_name)) {
98 98
 		$browser_name = "Opera";
99 99
 		$browser_version = $match[2];
100 100
 		$browser_barre = ($browser_version >= 8.5);
Please login to merge, or discard this patch.
ecrire/inc/charger_php_extension.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 // - 3) si l'on peut, on charge le module par la fonction dl()
16 16
 //
17 17
 // http://doc.spip.org/@inc_charger_php_extension_dist
18
-function inc_charger_php_extension_dist($module){
18
+function inc_charger_php_extension_dist($module) {
19 19
 	if (extension_loaded($module)) {
20 20
 		return true;
21 21
 	}
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 
57 57
 	/* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */
58 58
 	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
59
-		$module_file = 'php_' . $module . '.dll';
60
-	} elseif (PHP_OS=='HP-UX') {
61
-		$module_file = $module . '.sl';
59
+		$module_file = 'php_'.$module.'.dll';
60
+	} elseif (PHP_OS == 'HP-UX') {
61
+		$module_file = $module.'.sl';
62 62
 	} else {
63
-		$module_file = $module . '.so';
63
+		$module_file = $module.'.so';
64 64
 	}
65 65
 
66 66
 	return @dl($module_file);
Please login to merge, or discard this patch.
ecrire/inc/lien.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 // et en plus on veut pouvoir les passer en pipeline
21 21
 //
22 22
 
23
-function inc_lien_dist($lien, $texte='', $class='', $title='', $hlang='', $rel='', $connect='', $env=array()) {
23
+function inc_lien_dist($lien, $texte = '', $class = '', $title = '', $hlang = '', $rel = '', $connect = '', $env = array()) {
24 24
 
25 25
 	return $lien;
26 26
 }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 define('_RACCOURCI_LIEN', "/\[([^][]*?([[]\w*[]][^][]*)*)->(>?)([^]]*)\]/msS");
33 33
 
34 34
 // http://doc.spip.org/@expanser_liens
35
-function expanser_liens($t, $connect='', $env=array()){
35
+function expanser_liens($t, $connect = '', $env = array()) {
36 36
 
37 37
 	$t = pipeline('pre_liens', $t);
38 38
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 // Meme analyse mais pour eliminer les liens
46 46
 // et ne laisser que leur titre, a expliciter si ce n'est fait
47 47
 // http://doc.spip.org/@nettoyer_raccourcis_typo
48
-function nettoyer_raccourcis_typo($texte, $connect='')
48
+function nettoyer_raccourcis_typo($texte, $connect = '')
49 49
 {
50 50
 
51 51
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 // la langue et la bulle eventuelles
59 59
 // http://doc.spip.org/@traiter_raccourci_lien_atts
60 60
 function traiter_raccourci_lien_atts($texte) {
61
-	$bulle='';
62
-	$hlang='';
61
+	$bulle = '';
62
+	$hlang = '';
63 63
 	return array(trim($texte), $bulle, $hlang);
64 64
 }
65 65
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  * @param bool $url
79 79
  * @return string
80 80
  */
81
-function virtuel_redirige($virtuel, $url=false){
81
+function virtuel_redirige($virtuel, $url = false) {
82 82
 	return $virtuel;
83 83
 }
84 84
 
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 // 'url':   seulement U  (i.e. generer_url_RACCOURCI)
94 94
 
95 95
 // http://doc.spip.org/@calculer_url
96
-function calculer_url ($ref, $texte='', $pour='url', $connect='', $echappe_typo = true) {
96
+function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
97 97
 	$r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
98 98
 	return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
99 99
 }
100 100
 
101
-define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
101
+define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS');
102 102
 
103 103
 // http://doc.spip.org/@traiter_lien_explicite
104
-function traiter_lien_explicite ($ref, $texte='', $pour='url', $connect='', $echappe_typo = true)
104
+function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true)
105 105
 {
106 106
 	if (preg_match(_EXTRAIRE_LIEN, $ref))
107
-		return ($pour != 'tout') ? '' : array('','','','');
107
+		return ($pour != 'tout') ? '' : array('', '', '', '');
108 108
 
109 109
 	$lien = entites_html(trim($ref));
110 110
 
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 		// evite l'affichage de trops longues urls.
115 115
 		$lien_court = charger_fonction('lien_court', 'inc');
116 116
 		$texte = $lien_court($texte);
117
-		if ($echappe_typo){
117
+		if ($echappe_typo) {
118 118
 			$texte = "<html>".quote_amp($texte)."</html>";
119 119
 		}
120 120
 	}
121 121
 
122 122
 	// petites corrections d'URL
123
-	if (preg_match('/^www\.[^@]+$/S',$lien))
123
+	if (preg_match('/^www\.[^@]+$/S', $lien))
124 124
 		$lien = "http://".$lien;
125 125
 	else if (strpos($lien, "@") && email_valide($lien)) {
126 126
 		if (!$texte) $texte = $lien;
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	return array('url' => $lien, 'titre' => $texte);
135 135
 }
136 136
 
137
-function liens_implicite_glose_dist($texte,$id,$type,$args,$ancre,$connect=''){
138
-	if (function_exists($f = 'glossaire_' . $ancre))
137
+function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') {
138
+	if (function_exists($f = 'glossaire_'.$ancre))
139 139
 		$url = $f($texte, $id);
140 140
 	else
141 141
 		$url = glossaire_std($texte);
@@ -143,34 +143,34 @@  discard block
 block discarded – undo
143 143
 }
144 144
 
145 145
 // http://doc.spip.org/@traiter_lien_implicite
146
-function traiter_lien_implicite ($ref, $texte='', $pour='url', $connect='')
146
+function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '')
147 147
 {
148 148
 	if (!($match = typer_raccourci($ref))) return false;
149 149
 	@list($type,,$id,,$args,,$ancre) = $match;
150 150
 # attention dans le cas des sites le lien doit pointer non pas sur
151 151
 # la page locale du site, mais directement sur le site lui-meme
152
-	if ($f = charger_fonction("implicite_$type","liens",true))
153
-		$url = $f($texte,$id,$type,$args,$ancre,$connect);
152
+	if ($f = charger_fonction("implicite_$type", "liens", true))
153
+		$url = $f($texte, $id, $type, $args, $ancre, $connect);
154 154
 	if (!$url)
155
-		$url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL);
155
+		$url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : NULL);
156 156
 	if (!$url) return false;
157 157
 	if (is_array($url)) {
158
-		@list($type,$id) = $url;
159
-		$url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL);
158
+		@list($type, $id) = $url;
159
+		$url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : NULL);
160 160
 	}
161 161
 	if ($pour === 'url') return $url;
162 162
 	$r = traiter_raccourci_titre($id, $type, $connect);
163
-	if ($r) $r['class'] =  ($type == 'site')?'spip_out':'spip_in';
163
+	if ($r) $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
164 164
 	if ($texte = trim($texte)) $r['titre'] = $texte;
165
-	if (!@$r['titre']) $r['titre'] =  _T($type) . " $id";
166
-	if ($pour=='titre') return $r['titre'];
165
+	if (!@$r['titre']) $r['titre'] = _T($type)." $id";
166
+	if ($pour == 'titre') return $r['titre'];
167 167
 	$r['url'] = $url;
168 168
 
169 169
 	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
170 170
 	if ($type == 'document'
171 171
 	AND $mime = sql_getfetsel('mime_type', 'spip_types_documents',
172
-			"extension IN (".sql_get_select("extension","spip_documents","id_document=".sql_quote($id)).")",
173
-			'','','','',$connect)
172
+			"extension IN (".sql_get_select("extension", "spip_documents", "id_document=".sql_quote($id)).")",
173
+			'', '', '', '', $connect)
174 174
 	)
175 175
 		$r['mime'] = $mime;
176 176
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 define('_RACCOURCI_URL', '/^\s*(\w*?)\s*(\d+)(\?(.*?))?(#([^\s]*))?\s*$/S');
183 183
 
184 184
 // http://doc.spip.org/@typer_raccourci
185
-function typer_raccourci ($lien) {
185
+function typer_raccourci($lien) {
186 186
 	if (!preg_match(_RACCOURCI_URL, $lien, $match)) return array();
187 187
 	$f = $match[1];
188 188
 	// valeur par defaut et alias historiques
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 }
200 200
 
201 201
 // Retourne le champ textuel associe a une cle primaire, et sa langue
202
-function traiter_raccourci_titre($id, $type, $connect=NULL)
202
+function traiter_raccourci_titre($id, $type, $connect = NULL)
203 203
 {
204 204
 	$trouver_table = charger_fonction('trouver_table', 'base');
205 205
 	$desc = $trouver_table(table_objet($type));
206 206
 	if (!($desc AND $s = $desc['titre'])) return array();
207 207
 	$_id = $desc['key']['PRIMARY KEY'];
208
-	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '','','','',$connect);
208
+	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
209 209
 	if (!$r) return array();
210 210
 	$r['titre'] = supprimer_numero($r['titre']);
211 211
 	if (!$r['titre']) $r['titre'] = $r['surnom'];
@@ -229,35 +229,35 @@  discard block
 block discarded – undo
229 229
 	.'\s*(<\/a>)?' # eventuel </a>
230 230
        );
231 231
 
232
-define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE .'@isS');
232
+define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS');
233 233
 
234 234
 // http://doc.spip.org/@traiter_modeles
235
-function traiter_modeles($texte, $doublons=false, $echap='', $connect='', $liens = null, $env = array()) {
235
+function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) {
236 236
 	// preserver la compatibilite : true = recherche des documents
237
-	if ($doublons===true)
238
-		$doublons = array('documents'=>array('doc','emb','img'));
237
+	if ($doublons === true)
238
+		$doublons = array('documents'=>array('doc', 'emb', 'img'));
239 239
 	// detecter les modeles (rapide)
240
-	if (strpos($texte,"<")!==false AND
240
+	if (strpos($texte, "<") !== false AND
241 241
 	  preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)) {
242 242
 		include_spip('public/assembler');
243
-		$wrap_embed_html = charger_fonction("wrap_embed_html","inc",true);
243
+		$wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true);
244 244
 		foreach ($matches as $match) {
245 245
 			// Recuperer l'appel complet (y compris un eventuel lien)
246 246
 
247
-			$a = strpos($texte,$match[0]);
247
+			$a = strpos($texte, $match[0]);
248 248
 			preg_match(_RACCOURCI_MODELE_DEBUT,
249 249
 			substr($texte, $a), $regs);
250
-			$regs[]=""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
250
+			$regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
251 251
 			list(,$mod, $type, $id, $params, $fin) = $regs;
252 252
 			if ($fin AND
253 253
 			preg_match('/<a\s[^<>]*>\s*$/i',
254 254
 					substr($texte, 0, $a), $r)) {
255 255
 				$lien = array(
256
-					'href' => extraire_attribut($r[0],'href'),
257
-					'class' => extraire_attribut($r[0],'class'),
258
-					'mime' => extraire_attribut($r[0],'type'),
259
-					'title' => extraire_attribut($r[0],'title'),
260
-					'hreflang' => extraire_attribut($r[0],'hreflang')
256
+					'href' => extraire_attribut($r[0], 'href'),
257
+					'class' => extraire_attribut($r[0], 'class'),
258
+					'mime' => extraire_attribut($r[0], 'type'),
259
+					'title' => extraire_attribut($r[0], 'title'),
260
+					'hreflang' => extraire_attribut($r[0], 'hreflang')
261 261
 				);
262 262
 				$n = strlen($r[0]);
263 263
 				$a -= $n;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			// calculer le modele
271 271
 			# hack indexation
272 272
 			if ($doublons)
273
-				$texte .= preg_replace(',[|][^|=]*,s',' ',$params);
273
+				$texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
274 274
 			# version normale
275 275
 			else {
276 276
 				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 					else {
295 295
 						$modele = "";
296 296
 						if (test_espace_prive()) {
297
-							$modele = entites_html(substr($texte,$a,$cherche));
297
+							$modele = entites_html(substr($texte, $a, $cherche));
298 298
 							if (!is_null($liens))
299 299
 								$modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>";
300 300
 						}
@@ -303,20 +303,20 @@  discard block
 block discarded – undo
303 303
 				// le remplacer dans le texte
304 304
 				if ($modele !== false) {
305 305
 					$modele = protege_js_modeles($modele);
306
-					if ($wrap_embed_html){
307
-						$modele = $wrap_embed_html($mod,$modele);
306
+					if ($wrap_embed_html) {
307
+						$modele = $wrap_embed_html($mod, $modele);
308 308
 					}
309 309
 					$rempl = code_echappement($modele, $echap);
310 310
 					$texte = substr($texte, 0, $a)
311 311
 						. $rempl
312
-						. substr($texte, $a+$cherche);
312
+						. substr($texte, $a + $cherche);
313 313
 				}
314 314
 			}
315 315
 
316 316
 			// hack pour tout l'espace prive
317
-			if (((!_DIR_RESTREINT) OR ($doublons)) AND ($id)){
318
-				foreach($doublons?$doublons:array('documents'=>array('doc','emb','img')) as $quoi=>$modeles)
319
-					if (in_array($type,$modeles))
317
+			if (((!_DIR_RESTREINT) OR ($doublons)) AND ($id)) {
318
+				foreach ($doublons ? $doublons : array('documents'=>array('doc', 'emb', 'img')) as $quoi=>$modeles)
319
+					if (in_array($type, $modeles))
320 320
 						$GLOBALS["doublons_{$quoi}_inclus"][] = $id;
321 321
 			}
322 322
 		}
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 //
20 20
 
21 21
 // http://doc.spip.org/@inc_selectionner_dist
22
-function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
22
+function inc_selectionner_dist($sel, $idom = "", $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
23 23
 
24 24
 	if ($recur) $recur = mini_hier($sel); else $sel = 0;
25 25
 
26 26
 	if ($aff_racine) {
27 27
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28
-		$idom3 = $idom . "_selection";
28
+		$idom3 = $idom."_selection";
29 29
 
30 30
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
31 31
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 					textebrut(_T('info_racine_site')))),
35 35
 				"\n\r", "  ");
36 36
 
37
-		$js_func = $do . '_selection_titre';
37
+		$js_func = $do.'_selection_titre';
38 38
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39 39
 
40 40
 		$aff_racine = "<div class='petite-racine item'>"
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		. "</a></div>";
50 50
 	}
51 51
 
52
-	$url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
52
+	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53 53
 
54 54
 	$plonger = charger_fonction('plonger', 'inc');
55 55
 	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 // http://doc.spip.org/@construire_selectionner_hierarchie
63
-function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
63
+function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '')
64 64
 {
65 65
 	global $spip_lang_right;
66 66
 
67
-	$idom1 = $idom . "_champ_recherche";
68
-	$idom2 = $idom . "_principal";
69
-	$idom3 = $idom . "_selection";
70
-	$idom4 = $idom . "_col_1";
71
-	$idom5 = 'img_' . $idom4;
67
+	$idom1 = $idom."_champ_recherche";
68
+	$idom2 = $idom."_principal";
69
+	$idom3 = $idom."_selection";
70
+	$idom4 = $idom."_col_1";
71
+	$idom5 = 'img_'.$idom4;
72 72
 	$idom6 = $idom."_fonc";
73 73
 
74 74
 	return "<div id='$idom'>"
75 75
 	. "<a id='$idom6' style='visibility: hidden;'"
76
-	. ($url_init ?  "\nhref='$url_init'" : '')
76
+	. ($url_init ? "\nhref='$url_init'" : '')
77 77
 	. "></a>"
78 78
 	. "<div class='recherche_rapide_parent'>"
79 79
 	. http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	. "')\"" 
105 105
 	. " />"
106 106
 	. "\n</div>"
107
-	. ($racine?"<div>$racine</div>":"")
107
+	. ($racine ? "<div>$racine</div>" : "")
108 108
 	. "<div id='"
109 109
 	.  $idom2
110 110
 	.  "'><div id='$idom4'"
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 }
115 115
 
116 116
 // http://doc.spip.org/@mini_hier
117
-function mini_hier ($id_rubrique) {
117
+function mini_hier($id_rubrique) {
118 118
 	
119 119
 	$liste = $id_rubrique;
120 120
 	$id_rubrique = intval($id_rubrique);
121
-	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122
-		$liste = $id_rubrique . ",$liste";
123
-	return explode(',',"0,$liste");
121
+	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = ".$id_rubrique))
122
+		$liste = $id_rubrique.",$liste";
123
+	return explode(',', "0,$liste");
124 124
 }
125 125
 
126 126
 ?>
Please login to merge, or discard this patch.