Completed
Push — master ( 92f140...7db589 )
by cam
05:28 queued 21s
created
ecrire/public/styliser_par_z.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@
 block discarded – undo
236 236
  * @param string $type
237 237
  * @param string $ext
238 238
  * @param bool $echafauder
239
- * @return mixed
239
+ * @return string|boolean
240 240
  */
241 241
 function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) {
242 242
 	if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) {
Please login to merge, or discard this patch.
Indentation   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @package SPIP\Core\Public\Styliser
20 20
  **/
21 21
 if (!defined("_ECRIRE_INC_VERSION")) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -29,181 +29,181 @@  discard block
 block discarded – undo
29 29
  * @return array Données modifiées du pipeline
30 30
  */
31 31
 function public_styliser_par_z_dist($flux) {
32
-	static $prefix_path = null;
33
-	static $prefix_length;
34
-	static $z_blocs;
35
-	static $apl_constant;
36
-	static $page;
37
-	static $disponible = array();
38
-	static $echafauder;
39
-	static $prepend = "";
40
-
41
-	if (!isset($prefix_path)) {
42
-		$z_blocs = z_blocs(test_espace_prive());
43
-		if (test_espace_prive()) {
44
-			$prefix_path = "prive/squelettes/";
45
-			$prefix_length = strlen($prefix_path);
46
-			$apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD';
47
-			$page = 'exec';
48
-			$echafauder = charger_fonction('echafauder', 'prive', true);
49
-			define('_ZCORE_EXCLURE_PATH', '');
50
-		} else {
51
-			$prefix_path = "";
52
-			$prefix_length = 0;
53
-			$apl_constant = '_Z_AJAX_PARALLEL_LOAD';
54
-			$page = _SPIP_PAGE;
55
-			$echafauder = charger_fonction('echafauder', 'public', true);
56
-			define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST,
57
-						'/') : ''));
58
-		}
59
-		$prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : "");
60
-	}
61
-	$z_contenu = reset($z_blocs); // contenu par defaut
62
-
63
-	$fond = $flux['args']['fond'];
64
-
65
-	if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) {
66
-		$fond = substr($fond, $prefix_length);
67
-		$squelette = $flux['data'];
68
-		$ext = $flux['args']['ext'];
69
-		// Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax
70
-		if (defined('_Z_AJAX_PARALLEL_LOAD_OK')
71
-			and $dir = explode('/', $fond)
72
-			and count($dir) == 2 // pas un sous repertoire
73
-			and $dir = reset($dir)
74
-			and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z
75
-			and defined($apl_constant)
76
-			and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL
77
-			and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
78
-		) {
79
-			$flux['data'] = $pipe;
80
-
81
-			return $flux;
82
-		}
83
-
84
-		// surcharger aussi les squelettes venant de squelettes-dist/
85
-		if ($squelette and !z_fond_valide($squelette)) {
86
-			$squelette = "";
87
-			$echafauder = "";
88
-		}
89
-		if ($prepend) {
90
-			$squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext"));
91
-			if ($squelette) {
92
-				$flux['data'] = $squelette;
93
-			}
94
-		}
95
-
96
-		// gerer les squelettes non trouves
97
-		// -> router vers les /dist.html
98
-		// ou scaffolding ou page automatique les contenus
99
-		if (!$squelette) {
100
-
101
-			// si on est sur un ?page=XX non trouve
102
-			if ((isset($flux['args']['contexte'][$page])
103
-					and $flux['args']['contexte'][$page] == $fond)
104
-				or (isset($flux['args']['contexte']['type-page'])
105
-					and $flux['args']['contexte']['type-page'] == $fond)
106
-				or ($fond == 'sommaire'
107
-					and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page]))
108
-			) {
109
-
110
-				// si on est sur un ?page=XX non trouve
111
-				// se brancher sur contenu/xx si il existe
112
-				// ou si c'est un objet spip, associe a une table, utiliser le fond homonyme
113
-				if (!isset($disponible[$fond])) {
114
-					$disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder);
115
-				}
116
-
117
-				if ($disponible[$fond]) {
118
-					$flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext"));
119
-				}
120
-			}
121
-
122
-			// echafaudage :
123
-			// si c'est un fond de contenu d'un objet en base
124
-			// generer un fond automatique a la volee pour les webmestres
125
-			elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) {
126
-				$type = substr($fond, strlen($z_contenu) + 1);
127
-				if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
128
-					$type = $flux['args']['contexte'][$page];
129
-				}
130
-				if (!isset($disponible[$type])) {
131
-					$disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
132
-				}
133
-				if (is_string($disponible[$type])) {
134
-					$flux['data'] = $disponible[$type];
135
-				} elseif ($echafauder
136
-					and include_spip('inc/autoriser')
137
-					and isset($GLOBALS['visiteur_session']['statut']) // performance
138
-					and autoriser('echafauder', $type)
139
-					and $is = $disponible[$type]
140
-					and is_array($is)
141
-				) {
142
-					$flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext);
143
-				} else {
144
-					$flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext,
145
-						$echafauder));
146
-				}
147
-			}
148
-
149
-			// sinon, si on demande un fond non trouve dans un des autres blocs
150
-			// et si il y a bien un contenu correspondant ou echafaudable
151
-			// se rabbatre sur le dist.html du bloc concerne
152
-			else {
153
-				if ($dir = explode('/', $fond)
154
-					and $dir = reset($dir)
155
-					and $dir !== $z_contenu
156
-					and in_array($dir, $z_blocs)
157
-				) {
158
-					$type = substr($fond, strlen("$dir/"));
159
-					if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
160
-						$type = $flux['args']['contexte'][$page];
161
-					}
162
-					if ($type !== 'page' and !isset($disponible[$type])) {
163
-						$disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
164
-					}
165
-					if ($type == 'page' or $disponible[$type]) {
166
-						$flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext);
167
-					}
168
-				}
169
-			}
170
-			$squelette = $flux['data'];
171
-		}
172
-		// layout specifiques par type et compositions :
173
-		// body-article.html
174
-		// body-sommaire.html
175
-		// pour des raisons de perfo, les declinaisons doivent etre dans le
176
-		// meme dossier que body.html
177
-		if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) {
178
-			if (isset($flux['args']['contexte']['type-page'])
179
-				and (
180
-					(isset($flux['args']['contexte']['composition'])
181
-						and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext"))
182
-					or
183
-					file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext")
184
-				)
185
-			) {
186
-				$flux['data'] = $f;
187
-			}
188
-		} elseif ($fond == 'structure'
189
-			and z_sanitize_var_zajax()
190
-			and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext")
191
-		) {
192
-			$flux['data'] = substr($f, 0, -strlen(".$ext"));
193
-		} // chercher le fond correspondant a la composition
194
-		elseif (isset($flux['args']['contexte']['composition'])
195
-			and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond))
196
-			and $dir = substr($fond, $prefix_length)
197
-			and $dir = explode('/', $dir)
198
-			and $dir = reset($dir)
199
-			and in_array($dir, $z_blocs)
200
-			and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext")
201
-		) {
202
-			$flux['data'] = substr($f, 0, -strlen(".$ext"));
203
-		}
204
-	}
205
-
206
-	return $flux;
32
+    static $prefix_path = null;
33
+    static $prefix_length;
34
+    static $z_blocs;
35
+    static $apl_constant;
36
+    static $page;
37
+    static $disponible = array();
38
+    static $echafauder;
39
+    static $prepend = "";
40
+
41
+    if (!isset($prefix_path)) {
42
+        $z_blocs = z_blocs(test_espace_prive());
43
+        if (test_espace_prive()) {
44
+            $prefix_path = "prive/squelettes/";
45
+            $prefix_length = strlen($prefix_path);
46
+            $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD';
47
+            $page = 'exec';
48
+            $echafauder = charger_fonction('echafauder', 'prive', true);
49
+            define('_ZCORE_EXCLURE_PATH', '');
50
+        } else {
51
+            $prefix_path = "";
52
+            $prefix_length = 0;
53
+            $apl_constant = '_Z_AJAX_PARALLEL_LOAD';
54
+            $page = _SPIP_PAGE;
55
+            $echafauder = charger_fonction('echafauder', 'public', true);
56
+            define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST,
57
+                        '/') : ''));
58
+        }
59
+        $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : "");
60
+    }
61
+    $z_contenu = reset($z_blocs); // contenu par defaut
62
+
63
+    $fond = $flux['args']['fond'];
64
+
65
+    if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) {
66
+        $fond = substr($fond, $prefix_length);
67
+        $squelette = $flux['data'];
68
+        $ext = $flux['args']['ext'];
69
+        // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax
70
+        if (defined('_Z_AJAX_PARALLEL_LOAD_OK')
71
+            and $dir = explode('/', $fond)
72
+            and count($dir) == 2 // pas un sous repertoire
73
+            and $dir = reset($dir)
74
+            and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z
75
+            and defined($apl_constant)
76
+            and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL
77
+            and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
78
+        ) {
79
+            $flux['data'] = $pipe;
80
+
81
+            return $flux;
82
+        }
83
+
84
+        // surcharger aussi les squelettes venant de squelettes-dist/
85
+        if ($squelette and !z_fond_valide($squelette)) {
86
+            $squelette = "";
87
+            $echafauder = "";
88
+        }
89
+        if ($prepend) {
90
+            $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext"));
91
+            if ($squelette) {
92
+                $flux['data'] = $squelette;
93
+            }
94
+        }
95
+
96
+        // gerer les squelettes non trouves
97
+        // -> router vers les /dist.html
98
+        // ou scaffolding ou page automatique les contenus
99
+        if (!$squelette) {
100
+
101
+            // si on est sur un ?page=XX non trouve
102
+            if ((isset($flux['args']['contexte'][$page])
103
+                    and $flux['args']['contexte'][$page] == $fond)
104
+                or (isset($flux['args']['contexte']['type-page'])
105
+                    and $flux['args']['contexte']['type-page'] == $fond)
106
+                or ($fond == 'sommaire'
107
+                    and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page]))
108
+            ) {
109
+
110
+                // si on est sur un ?page=XX non trouve
111
+                // se brancher sur contenu/xx si il existe
112
+                // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme
113
+                if (!isset($disponible[$fond])) {
114
+                    $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder);
115
+                }
116
+
117
+                if ($disponible[$fond]) {
118
+                    $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext"));
119
+                }
120
+            }
121
+
122
+            // echafaudage :
123
+            // si c'est un fond de contenu d'un objet en base
124
+            // generer un fond automatique a la volee pour les webmestres
125
+            elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) {
126
+                $type = substr($fond, strlen($z_contenu) + 1);
127
+                if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
128
+                    $type = $flux['args']['contexte'][$page];
129
+                }
130
+                if (!isset($disponible[$type])) {
131
+                    $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
132
+                }
133
+                if (is_string($disponible[$type])) {
134
+                    $flux['data'] = $disponible[$type];
135
+                } elseif ($echafauder
136
+                    and include_spip('inc/autoriser')
137
+                    and isset($GLOBALS['visiteur_session']['statut']) // performance
138
+                    and autoriser('echafauder', $type)
139
+                    and $is = $disponible[$type]
140
+                    and is_array($is)
141
+                ) {
142
+                    $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext);
143
+                } else {
144
+                    $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext,
145
+                        $echafauder));
146
+                }
147
+            }
148
+
149
+            // sinon, si on demande un fond non trouve dans un des autres blocs
150
+            // et si il y a bien un contenu correspondant ou echafaudable
151
+            // se rabbatre sur le dist.html du bloc concerne
152
+            else {
153
+                if ($dir = explode('/', $fond)
154
+                    and $dir = reset($dir)
155
+                    and $dir !== $z_contenu
156
+                    and in_array($dir, $z_blocs)
157
+                ) {
158
+                    $type = substr($fond, strlen("$dir/"));
159
+                    if (($type == 'page') and isset($flux['args']['contexte'][$page])) {
160
+                        $type = $flux['args']['contexte'][$page];
161
+                    }
162
+                    if ($type !== 'page' and !isset($disponible[$type])) {
163
+                        $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
164
+                    }
165
+                    if ($type == 'page' or $disponible[$type]) {
166
+                        $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext);
167
+                    }
168
+                }
169
+            }
170
+            $squelette = $flux['data'];
171
+        }
172
+        // layout specifiques par type et compositions :
173
+        // body-article.html
174
+        // body-sommaire.html
175
+        // pour des raisons de perfo, les declinaisons doivent etre dans le
176
+        // meme dossier que body.html
177
+        if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) {
178
+            if (isset($flux['args']['contexte']['type-page'])
179
+                and (
180
+                    (isset($flux['args']['contexte']['composition'])
181
+                        and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext"))
182
+                    or
183
+                    file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext")
184
+                )
185
+            ) {
186
+                $flux['data'] = $f;
187
+            }
188
+        } elseif ($fond == 'structure'
189
+            and z_sanitize_var_zajax()
190
+            and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext")
191
+        ) {
192
+            $flux['data'] = substr($f, 0, -strlen(".$ext"));
193
+        } // chercher le fond correspondant a la composition
194
+        elseif (isset($flux['args']['contexte']['composition'])
195
+            and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond))
196
+            and $dir = substr($fond, $prefix_length)
197
+            and $dir = explode('/', $dir)
198
+            and $dir = reset($dir)
199
+            and in_array($dir, $z_blocs)
200
+            and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext")
201
+        ) {
202
+            $flux['data'] = substr($f, 0, -strlen(".$ext"));
203
+        }
204
+    }
205
+
206
+    return $flux;
207 207
 }
208 208
 
209 209
 /**
@@ -213,18 +213,18 @@  discard block
 block discarded – undo
213 213
  * @return array
214 214
  */
215 215
 function z_blocs($espace_prive = false) {
216
-	if ($espace_prive) {
217
-		return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array(
218
-			'contenu',
219
-			'navigation',
220
-			'extra',
221
-			'head',
222
-			'hierarchie',
223
-			'top'
224
-		));
225
-	}
226
-
227
-	return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu'));
216
+    if ($espace_prive) {
217
+        return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array(
218
+            'contenu',
219
+            'navigation',
220
+            'extra',
221
+            'head',
222
+            'hierarchie',
223
+            'top'
224
+        ));
225
+    }
226
+
227
+    return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu'));
228 228
 }
229 229
 
230 230
 /**
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
  * @return mixed
240 240
  */
241 241
 function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) {
242
-	if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) {
243
-		return $d;
244
-	}
242
+    if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) {
243
+        return $d;
244
+    }
245 245
 
246
-	return $echafauder ? z_echafaudable($type) : false;
246
+    return $echafauder ? z_echafaudable($type) : false;
247 247
 }
248 248
 
249 249
 /**
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
  *   `true` si on peut l'utiliser, `false` sinon.
258 258
  **/
259 259
 function z_fond_valide($squelette) {
260
-	if (!_ZCORE_EXCLURE_PATH
261
-		or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette)
262
-	) {
263
-		return true;
264
-	}
260
+    if (!_ZCORE_EXCLURE_PATH
261
+        or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette)
262
+    ) {
263
+        return true;
264
+    }
265 265
 
266
-	return false;
266
+    return false;
267 267
 }
268 268
 
269 269
 /**
@@ -281,14 +281,14 @@  discard block
 block discarded – undo
281 281
  * @return string
282 282
  */
283 283
 function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) {
284
-	if (
285
-		(defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f))
286
-		or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f))
287
-	) {
288
-		return substr($f, 0, -strlen(".$ext"));
289
-	}
290
-
291
-	return "";
284
+    if (
285
+        (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f))
286
+        or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f))
287
+    ) {
288
+        return substr($f, 0, -strlen(".$ext"));
289
+    }
290
+
291
+    return "";
292 292
 }
293 293
 
294 294
 /**
@@ -300,51 +300,51 @@  discard block
 block discarded – undo
300 300
  * @return bool
301 301
  */
302 302
 function z_echafaudable($type) {
303
-	static $pages = null;
304
-	static $echafaudable = array();
305
-	if (isset($echafaudable[$type])) {
306
-		return $echafaudable[$type];
307
-	}
308
-	if (preg_match(',[^\w],', $type)) {
309
-		return $echafaudable[$type] = false;
310
-	}
311
-
312
-	if (test_espace_prive()) {
313
-		if (!function_exists('trouver_objet_exec')) {
314
-			include_spip('inc/pipelines_ecrire');
315
-		}
316
-		if ($e = trouver_objet_exec($type)) {
317
-			return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e);
318
-		} else {
319
-			// peut etre c'est un exec=types qui liste tous les objets "type"
320
-			if (($t = objet_type($type, false)) !== $type
321
-				and $e = trouver_objet_exec($t)
322
-			) {
323
-				return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t);
324
-			}
325
-		}
326
-	} else {
327
-		if (is_null($pages)) {
328
-			$pages = array();
329
-			$liste = lister_tables_objets_sql();
330
-			foreach ($liste as $t => $d) {
331
-				if ($d['page']) {
332
-					$pages[$d['page']] = array($d['table_objet'], $t);
333
-				}
334
-			}
335
-		}
336
-		if (!isset($pages[$type])) {
337
-			return $echafaudable[$type] = false;
338
-		}
339
-		if (count($pages[$type]) == 2) {
340
-			$trouver_table = charger_fonction('trouver_table', 'base');
341
-			$pages[$type][] = $trouver_table(reset($pages[$type]));
342
-		}
343
-
344
-		return $echafaudable[$type] = $pages[$type];
345
-	}
346
-
347
-	return $echafaudable[$type] = false;
303
+    static $pages = null;
304
+    static $echafaudable = array();
305
+    if (isset($echafaudable[$type])) {
306
+        return $echafaudable[$type];
307
+    }
308
+    if (preg_match(',[^\w],', $type)) {
309
+        return $echafaudable[$type] = false;
310
+    }
311
+
312
+    if (test_espace_prive()) {
313
+        if (!function_exists('trouver_objet_exec')) {
314
+            include_spip('inc/pipelines_ecrire');
315
+        }
316
+        if ($e = trouver_objet_exec($type)) {
317
+            return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e);
318
+        } else {
319
+            // peut etre c'est un exec=types qui liste tous les objets "type"
320
+            if (($t = objet_type($type, false)) !== $type
321
+                and $e = trouver_objet_exec($t)
322
+            ) {
323
+                return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t);
324
+            }
325
+        }
326
+    } else {
327
+        if (is_null($pages)) {
328
+            $pages = array();
329
+            $liste = lister_tables_objets_sql();
330
+            foreach ($liste as $t => $d) {
331
+                if ($d['page']) {
332
+                    $pages[$d['page']] = array($d['table_objet'], $t);
333
+                }
334
+            }
335
+        }
336
+        if (!isset($pages[$type])) {
337
+            return $echafaudable[$type] = false;
338
+        }
339
+        if (count($pages[$type]) == 2) {
340
+            $trouver_table = charger_fonction('trouver_table', 'base');
341
+            $pages[$type][] = $trouver_table(reset($pages[$type]));
342
+        }
343
+
344
+        return $echafaudable[$type] = $pages[$type];
345
+    }
346
+
347
+    return $echafaudable[$type] = false;
348 348
 }
349 349
 
350 350
 
@@ -361,46 +361,46 @@  discard block
 block discarded – undo
361 361
  * @return string
362 362
  */
363 363
 function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) {
364
-	$scaffold = "";
365
-
366
-	// page objet ou objet_edit
367
-	if (is_array($desc_exec)) {
368
-		$type = $desc_exec['type'];
369
-		$primary = $desc_exec['id_table_objet'];
370
-
371
-		if ($desc_exec['edition'] === false) {
372
-			$fond = "objet";
373
-		} else {
374
-			$trouver_table = charger_fonction('trouver_table', 'base');
375
-			$desc = $trouver_table($table_sql);
376
-			if (isset($desc['field']['id_rubrique'])) {
377
-				$fond = 'objet_edit';
378
-			} else {
379
-				$fond = 'objet_edit.sans_rubrique';
380
-			}
381
-		}
382
-		$dir = z_blocs(test_espace_prive());
383
-		$dir = reset($dir);
384
-		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>";
385
-	} // page objets
386
-	elseif ($type = $desc_exec and strpos($type, "/") === false) {
387
-		$dir = z_blocs(test_espace_prive());
388
-		$dir = reset($dir);
389
-		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />";
390
-	}
391
-	// morceau d'objet : on fournit le fond de sibstitution dans $desc_exec
392
-	// et objet et tire de $table
393
-	elseif ($fond = $desc_exec) {
394
-		$dir = md5(dirname($fond));
395
-		$scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />";
396
-	}
397
-
398
-	$base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false);
399
-	$base_dir = sous_repertoire($base_dir, $dir, false);
400
-	$f = $base_dir . "$exec";
401
-	ecrire_fichier("$f.$ext", $scaffold);
402
-
403
-	return $f;
364
+    $scaffold = "";
365
+
366
+    // page objet ou objet_edit
367
+    if (is_array($desc_exec)) {
368
+        $type = $desc_exec['type'];
369
+        $primary = $desc_exec['id_table_objet'];
370
+
371
+        if ($desc_exec['edition'] === false) {
372
+            $fond = "objet";
373
+        } else {
374
+            $trouver_table = charger_fonction('trouver_table', 'base');
375
+            $desc = $trouver_table($table_sql);
376
+            if (isset($desc['field']['id_rubrique'])) {
377
+                $fond = 'objet_edit';
378
+            } else {
379
+                $fond = 'objet_edit.sans_rubrique';
380
+            }
381
+        }
382
+        $dir = z_blocs(test_espace_prive());
383
+        $dir = reset($dir);
384
+        $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>";
385
+    } // page objets
386
+    elseif ($type = $desc_exec and strpos($type, "/") === false) {
387
+        $dir = z_blocs(test_espace_prive());
388
+        $dir = reset($dir);
389
+        $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />";
390
+    }
391
+    // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec
392
+    // et objet et tire de $table
393
+    elseif ($fond = $desc_exec) {
394
+        $dir = md5(dirname($fond));
395
+        $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />";
396
+    }
397
+
398
+    $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false);
399
+    $base_dir = sous_repertoire($base_dir, $dir, false);
400
+    $f = $base_dir . "$exec";
401
+    ecrire_fichier("$f.$ext", $scaffold);
402
+
403
+    return $f;
404 404
 }
405 405
 
406 406
 /**
@@ -409,16 +409,16 @@  discard block
 block discarded – undo
409 409
  * @return bool|string
410 410
  */
411 411
 function z_sanitize_var_zajax() {
412
-	$z_ajax = _request('var_zajax');
413
-	if (!$z_ajax) {
414
-		return false;
415
-	}
416
-	if (!$z_blocs = z_blocs(test_espace_prive())
417
-		or !in_array($z_ajax, $z_blocs)
418
-	) {
419
-		set_request('var_zajax'); // enlever cette demande incongrue
420
-		$z_ajax = false;
421
-	}
422
-
423
-	return $z_ajax;
412
+    $z_ajax = _request('var_zajax');
413
+    if (!$z_ajax) {
414
+        return false;
415
+    }
416
+    if (!$z_blocs = z_blocs(test_espace_prive())
417
+        or !in_array($z_ajax, $z_blocs)
418
+    ) {
419
+        set_request('var_zajax'); // enlever cette demande incongrue
420
+        $z_ajax = false;
421
+    }
422
+
423
+    return $z_ajax;
424 424
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			$apl_constant = '_Z_AJAX_PARALLEL_LOAD';
54 54
 			$page = _SPIP_PAGE;
55 55
 			$echafauder = charger_fonction('echafauder', 'public', true);
56
-			define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST,
56
+			define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist'.(defined('_DIR_PLUGIN_DIST') ? '|\b'.rtrim(_DIR_PLUGIN_DIST,
57 57
 						'/') : ''));
58 58
 		}
59 59
 		$prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : "");
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z
75 75
 			and defined($apl_constant)
76 76
 			and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL
77
-			and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
77
+			and $pipe = z_trouver_bloc($prefix_path.$prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
78 78
 		) {
79 79
 			$flux['data'] = $pipe;
80 80
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			$echafauder = "";
88 88
 		}
89 89
 		if ($prepend) {
90
-			$squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext"));
90
+			$squelette = substr(find_in_path($prefix_path.$prepend."$fond.$ext"), 0, -strlen(".$ext"));
91 91
 			if ($squelette) {
92 92
 				$flux['data'] = $squelette;
93 93
 			}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 				// se brancher sur contenu/xx si il existe
112 112
 				// ou si c'est un objet spip, associe a une table, utiliser le fond homonyme
113 113
 				if (!isset($disponible[$fond])) {
114
-					$disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder);
114
+					$disponible[$fond] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $fond, $ext, $echafauder);
115 115
 				}
116 116
 
117 117
 				if ($disponible[$fond]) {
118
-					$flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext"));
118
+					$flux['data'] = substr(find_in_path($prefix_path."page.$ext"), 0, -strlen(".$ext"));
119 119
 				}
120 120
 			}
121 121
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 					$type = $flux['args']['contexte'][$page];
129 129
 				}
130 130
 				if (!isset($disponible[$type])) {
131
-					$disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
131
+					$disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder);
132 132
 				}
133 133
 				if (is_string($disponible[$type])) {
134 134
 					$flux['data'] = $disponible[$type];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 				) {
142 142
 					$flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext);
143 143
 				} else {
144
-					$flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext,
144
+					$flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, '404', $ext,
145 145
 						$echafauder));
146 146
 				}
147 147
 			}
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 						$type = $flux['args']['contexte'][$page];
161 161
 					}
162 162
 					if ($type !== 'page' and !isset($disponible[$type])) {
163
-						$disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder);
163
+						$disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder);
164 164
 					}
165 165
 					if ($type == 'page' or $disponible[$type]) {
166
-						$flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext);
166
+						$flux['data'] = z_trouver_bloc($prefix_path.$prepend, $dir, 'dist', $ext);
167 167
 					}
168 168
 				}
169 169
 			}
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
 			if (isset($flux['args']['contexte']['type-page'])
179 179
 				and (
180 180
 					(isset($flux['args']['contexte']['composition'])
181
-						and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext"))
181
+						and file_exists(($f = $squelette."-".$flux['args']['contexte']['type-page']."-".$flux['args']['contexte']['composition']).".$ext"))
182 182
 					or
183
-					file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext")
183
+					file_exists(($f = $squelette."-".$flux['args']['contexte']['type-page']).".$ext")
184 184
 				)
185 185
 			) {
186 186
 				$flux['data'] = $f;
187 187
 			}
188 188
 		} elseif ($fond == 'structure'
189 189
 			and z_sanitize_var_zajax()
190
-			and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext")
190
+			and $f = find_in_path($prefix_path.$prepend.'ajax'.".$ext")
191 191
 		) {
192 192
 			$flux['data'] = substr($f, 0, -strlen(".$ext"));
193 193
 		} // chercher le fond correspondant a la composition
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 			and $dir = explode('/', $dir)
198 198
 			and $dir = reset($dir)
199 199
 			and in_array($dir, $z_blocs)
200
-			and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext")
200
+			and $f = find_in_path($prefix_path.$prepend.$fond."-".$flux['args']['contexte']['composition'].".$ext")
201 201
 		) {
202 202
 			$flux['data'] = substr($f, 0, -strlen(".$ext"));
203 203
 		}
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
  **/
259 259
 function z_fond_valide($squelette) {
260 260
 	if (!_ZCORE_EXCLURE_PATH
261
-		or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette)
261
+		or !preg_match(',('._ZCORE_EXCLURE_PATH.')/,', $squelette)
262 262
 	) {
263 263
 		return true;
264 264
 	}
@@ -381,23 +381,23 @@  discard block
 block discarded – undo
381 381
 		}
382 382
 		$dir = z_blocs(test_espace_prive());
383 383
 		$dir = reset($dir);
384
-		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>";
384
+		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/".$fond.",objet=".$type.",id_objet=#".strtoupper($primary).",env}>";
385 385
 	} // page objets
386 386
 	elseif ($type = $desc_exec and strpos($type, "/") === false) {
387 387
 		$dir = z_blocs(test_espace_prive());
388 388
 		$dir = reset($dir);
389
-		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />";
389
+		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=".$type.",env} />";
390 390
 	}
391 391
 	// morceau d'objet : on fournit le fond de sibstitution dans $desc_exec
392 392
 	// et objet et tire de $table
393 393
 	elseif ($fond = $desc_exec) {
394 394
 		$dir = md5(dirname($fond));
395
-		$scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />";
395
+		$scaffold = "<INCLURE{fond=$fond,objet=".objet_type($table).",env} />";
396 396
 	}
397 397
 
398 398
 	$base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false);
399 399
 	$base_dir = sous_repertoire($base_dir, $dir, false);
400
-	$f = $base_dir . "$exec";
400
+	$f = $base_dir."$exec";
401 401
 	ecrire_fichier("$f.$ext", $scaffold);
402 402
 
403 403
 	return $f;
Please login to merge, or discard this patch.
ecrire/public/quete.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 /**
29 29
  * Retourne l'URL de redirection d'un article virtuel, seulement si il est publié
30 30
  *
31
- * @param $id_article
32
- * @param $connect
33
- * @return array|bool|null
31
+ * @param integer $id_article
32
+ * @param string $connect
33
+ * @return string
34 34
  */
35 35
 function quete_virtuel($id_article, $connect) {
36 36
 	return sql_getfetsel(
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
  * @uses quete_parent_lang()
123 123
  *
124 124
  * @param int $id_article
125
- * @param $serveur
125
+ * @param string $serveur
126 126
  * @return int
127 127
  */
128 128
 function quete_rubrique($id_article, $serveur) {
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
  *
294 294
  * @param int $id_document
295 295
  * @param string $serveur
296
- * @return array|bool|null
296
+ * @return string
297 297
  */
298 298
 function quete_fichier($id_document, $serveur = '') {
299 299
 	return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
Please login to merge, or discard this patch.
Spacing   +17 added lines, -18 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	return sql_getfetsel(
37 37
 		'virtuel',
38 38
 		'spip_articles',
39
-		array('id_article=' . intval($id_article), "statut='publie'"),
39
+		array('id_article='.intval($id_article), "statut='publie'"),
40 40
 		'',
41 41
 		'',
42 42
 		'',
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			$cache_quete[$connect][$table][$id] = sql_fetsel(
79 79
 				$cache_quete[$connect][$table]['_select'],
80 80
 				$table,
81
-				$cache_quete[$connect][$table]['_id'] . '=' . intval($id),
81
+				$cache_quete[$connect][$table]['_id'].'='.intval($id),
82 82
 				'',
83 83
 				'',
84 84
 				'',
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	return
172 172
 		(isset($GLOBALS['meta']['date_prochain_postdate'])
173 173
 			and $GLOBALS['meta']['date_prochain_postdate'] > time())
174
-			? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur)
174
+			? "$champ_date<".sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur)
175 175
 			: '1=1';
176 176
 }
177 177
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 				and $id_table = reset($objet)
230 230
 				and $objet = objet_type($id_table)
231 231
 			) {
232
-				$w = "$mstatut<>" . sql_quote($v);
232
+				$w = "$mstatut<>".sql_quote($v);
233 233
 
234 234
 				// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
235 235
 				// sinon l’auteur en session
@@ -243,22 +243,22 @@  discard block
 block discarded – undo
243 243
 				}
244 244
 
245 245
 				// dans ce cas (admin en general), pas de filtrage sur ce statut
246
-				if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) {
246
+				if (!autoriser('previsualiser'.$v, $objet, '', $id_auteur)) {
247 247
 					// si pas d'auteur identifie pas de sous-requete car pas d'article qui matche
248 248
 					if (!$id_auteur) {
249 249
 						$where[] = $w;
250 250
 					} else {
251 251
 						$primary = id_table_objet($objet);
252
-						$where[] = "($w OR $id_table.$primary IN (" . sql_get_select(
252
+						$where[] = "($w OR $id_table.$primary IN (".sql_get_select(
253 253
 								'ssss.id_objet',
254 254
 								'spip_auteurs_liens AS ssss',
255
-								'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur),
255
+								'ssss.objet='.sql_quote($objet).' AND ssss.id_auteur='.intval($id_auteur),
256 256
 								'',
257 257
 								'',
258 258
 								'',
259 259
 								'',
260 260
 								$serveur
261
-							) . '))';
261
+							).'))';
262 262
 					}
263 263
 				}
264 264
 			} // ignorer ce statut si on ne sait pas comment le filtrer
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
  * @return array|bool|null
297 297
  */
298 298
 function quete_fichier($id_document, $serveur = '') {
299
-	return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
299
+	return sql_getfetsel('fichier', 'spip_documents', ('id_document='.intval($id_document)), '', array(), '', '', $serveur);
300 300
 }
301 301
 
302 302
 /**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
  * @return array|bool
308 308
  */
309 309
 function quete_document($id_document, $serveur = '') {
310
-	return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
310
+	return sql_fetsel('*', 'spip_documents', ('id_document='.intval($id_document)), '', array(), '', '', $serveur);
311 311
 }
312 312
 
313 313
 /**
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
  * @return array|bool|null
319 319
  */
320 320
 function quete_meta($nom, $serveur) {
321
-	return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur);
321
+	return sql_getfetsel('valeur', 'spip_meta', 'nom='.sql_quote($nom), '', '', '', '', $serveur);
322 322
 }
323 323
 
324 324
 /**
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 				// qui permet de distinguer le changement de logo
373 373
 				// et placer un expire sur le dossier IMG/
374 374
 				$res = array(
375
-					$on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''),
376
-					($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''),
377
-					(!$taille ? '' : (' ' . $taille[3]))
375
+					$on['chemin'].($on['timestamp'] ? "?{$on['timestamp']}" : ''),
376
+					($off ? $off['chemin'].($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''),
377
+					(!$taille ? '' : (' '.$taille[3]))
378 378
 				);
379 379
 				$res['src'] = $res[0];
380 380
 				$res['logo_on'] = $res[0];
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	// si c'est une vignette type doc, la renvoyer direct
471 471
 	if (strcmp($logo, _DIR_PLUGINS) == 0
472 472
 		or strcmp($logo, _DIR_PLUGINS_DIST) == 0
473
-		or strcmp($logo, _DIR_RACINE . 'prive/') == 0
473
+		or strcmp($logo, _DIR_RACINE.'prive/') == 0
474 474
 	) {
475 475
 		return $logo;
476 476
 	}
@@ -589,8 +589,7 @@  discard block
 block discarded – undo
589 589
 	// qu'une fois (par squelette) et on conserve le resultat
590 590
 	// en static.
591 591
 	if (!isset($exposer[$m = md5(serialize($reference))][$prim])) {
592
-		$principal = isset($reference[$type]) ? $reference[$type] :
593
-			// cas de la pagination indecte @xx qui positionne la page avec l'id xx
592
+		$principal = isset($reference[$type]) ? $reference[$type] : // cas de la pagination indecte @xx qui positionne la page avec l'id xx
594 593
 			// et donne la reference dynamique @type=xx dans le contexte
595 594
 			(isset($reference["@$type"]) ? $reference["@$type"] : '');
596 595
 		// le parent fournit en argument est le parent de $id, pas celui de $principal
@@ -618,7 +617,7 @@  discard block
 block discarded – undo
618 617
 				$exposer[$m][$type][$principal] = true;
619 618
 				if ($type == 'id_mot') {
620 619
 					if (!$parent) {
621
-						$parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect);
620
+						$parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot='.intval($principal), '', '', '', '', $connect);
622 621
 					}
623 622
 					if ($parent) {
624 623
 						$exposer[$m]['id_groupe'][$parent] = true;
Please login to merge, or discard this patch.
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  **/
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
  * @return array|bool|null
34 34
  */
35 35
 function quete_virtuel($id_article, $connect) {
36
-	return sql_getfetsel(
37
-		'virtuel',
38
-		'spip_articles',
39
-		array('id_article=' . intval($id_article), "statut='publie'"),
40
-		'',
41
-		'',
42
-		'',
43
-		'',
44
-		$connect
45
-	);
36
+    return sql_getfetsel(
37
+        'virtuel',
38
+        'spip_articles',
39
+        array('id_article=' . intval($id_article), "statut='publie'"),
40
+        '',
41
+        '',
42
+        '',
43
+        '',
44
+        $connect
45
+    );
46 46
 }
47 47
 
48 48
 /**
@@ -57,38 +57,38 @@  discard block
 block discarded – undo
57 57
  * @return array
58 58
  */
59 59
 function quete_parent_lang($table, $id, $connect = '') {
60
-	static $cache_quete = array();
61
-
62
-	if (!isset($cache_quete[$connect][$table][$id])) {
63
-		if (!isset($cache_quete[$connect][$table]['_select'])) {
64
-			$trouver_table = charger_fonction('trouver_table', 'base');
65
-			if (!$desc = $trouver_table($table,
66
-					$connect) or !isset($desc['field']['id_rubrique'])
67
-			) {
68
-				// pas de parent rubrique, on passe
69
-				$cache_quete[$connect][$table]['_select'] = false;
70
-			} else {
71
-				$select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique');
72
-				$select .= isset($desc['field']['lang']) ? ', lang' : '';
73
-				$cache_quete[$connect][$table]['_select'] = $select;
74
-				$cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table));
75
-			}
76
-		}
77
-		if ($cache_quete[$connect][$table]['_select']) {
78
-			$cache_quete[$connect][$table][$id] = sql_fetsel(
79
-				$cache_quete[$connect][$table]['_select'],
80
-				$table,
81
-				$cache_quete[$connect][$table]['_id'] . '=' . intval($id),
82
-				'',
83
-				'',
84
-				'',
85
-				'',
86
-				$connect
87
-			);
88
-		}
89
-	}
90
-
91
-	return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null;
60
+    static $cache_quete = array();
61
+
62
+    if (!isset($cache_quete[$connect][$table][$id])) {
63
+        if (!isset($cache_quete[$connect][$table]['_select'])) {
64
+            $trouver_table = charger_fonction('trouver_table', 'base');
65
+            if (!$desc = $trouver_table($table,
66
+                    $connect) or !isset($desc['field']['id_rubrique'])
67
+            ) {
68
+                // pas de parent rubrique, on passe
69
+                $cache_quete[$connect][$table]['_select'] = false;
70
+            } else {
71
+                $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique');
72
+                $select .= isset($desc['field']['lang']) ? ', lang' : '';
73
+                $cache_quete[$connect][$table]['_select'] = $select;
74
+                $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table));
75
+            }
76
+        }
77
+        if ($cache_quete[$connect][$table]['_select']) {
78
+            $cache_quete[$connect][$table][$id] = sql_fetsel(
79
+                $cache_quete[$connect][$table]['_select'],
80
+                $table,
81
+                $cache_quete[$connect][$table]['_id'] . '=' . intval($id),
82
+                '',
83
+                '',
84
+                '',
85
+                '',
86
+                $connect
87
+            );
88
+        }
89
+    }
90
+
91
+    return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null;
92 92
 }
93 93
 
94 94
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
  * @return int
106 106
  */
107 107
 function quete_parent($id_rubrique, $connect = '') {
108
-	if (!$id_rubrique = intval($id_rubrique)) {
109
-		return 0;
110
-	}
111
-	$id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect);
112
-	return $id_parent ? $id_parent['id_parent'] : 0;
108
+    if (!$id_rubrique = intval($id_rubrique)) {
109
+        return 0;
110
+    }
111
+    $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect);
112
+    return $id_parent ? $id_parent['id_parent'] : 0;
113 113
 }
114 114
 
115 115
 /**
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
  * @return int
126 126
  */
127 127
 function quete_rubrique($id_article, $serveur) {
128
-	$id_parent = quete_parent_lang('spip_articles', $id_article, $serveur);
128
+    $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur);
129 129
 
130
-	return $id_parent['id_rubrique'];
130
+    return $id_parent['id_rubrique'];
131 131
 }
132 132
 
133 133
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
  * @return int
142 142
  */
143 143
 function quete_profondeur($id, $connect = '') {
144
-	$n = 0;
145
-	while ($id) {
146
-		$n++;
147
-		$id = quete_parent($id, $connect);
148
-	}
144
+    $n = 0;
145
+    while ($id) {
146
+        $n++;
147
+        $id = quete_parent($id, $connect);
148
+    }
149 149
 
150
-	return $n;
150
+    return $n;
151 151
 }
152 152
 
153 153
 
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
  *     Morceau de la requête SQL testant la date
164 164
  */
165 165
 function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) {
166
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) {
167
-		return '1=1';
168
-	}
169
-
170
-	return
171
-		(isset($GLOBALS['meta']['date_prochain_postdate'])
172
-			and $GLOBALS['meta']['date_prochain_postdate'] > time())
173
-			? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur)
174
-			: '1=1';
166
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) {
167
+        return '1=1';
168
+    }
169
+
170
+    return
171
+        (isset($GLOBALS['meta']['date_prochain_postdate'])
172
+            and $GLOBALS['meta']['date_prochain_postdate'] > time())
173
+            ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur)
174
+            : '1=1';
175 175
 }
176 176
 
177 177
 
@@ -191,100 +191,100 @@  discard block
 block discarded – undo
191 191
  * @return array|string
192 192
  */
193 193
 function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) {
194
-	static $cond = array();
195
-	$key = func_get_args();
196
-	$key = implode('-', $key);
197
-	if (isset($cond[$key])) {
198
-		return $cond[$key];
199
-	}
200
-
201
-	$liste_statuts = $publie;
202
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) {
203
-		$liste_statuts = $previsu;
204
-	}
205
-	$not = false;
206
-	if (strncmp($liste_statuts, '!', 1) == 0) {
207
-		$not = true;
208
-		$liste_statuts = substr($liste_statuts, 1);
209
-	}
210
-	// '' => ne rien afficher, '!'=> ne rien filtrer
211
-	if (!strlen($liste_statuts)) {
212
-		return $cond[$key] = ($not ? '1=1' : '0=1');
213
-	}
214
-
215
-	$liste_statuts = explode(',', $liste_statuts);
216
-	$where = array();
217
-	foreach ($liste_statuts as $k => $v) {
218
-		// filtrage /auteur pour limiter les objets d'un statut (prepa en general)
219
-		// a ceux de l'auteur identifie
220
-		if (strpos($v, '/') !== false) {
221
-			$v = explode('/', $v);
222
-			$filtre = end($v);
223
-			$v = reset($v);
224
-			$v = preg_replace(',\W,', '', $v);
225
-			if ($filtre == 'auteur'
226
-				and (strpos($mstatut, '.') !== false)
227
-				and $objet = explode('.', $mstatut)
228
-				and $id_table = reset($objet)
229
-				and $objet = objet_type($id_table)
230
-			) {
231
-				$w = "$mstatut<>" . sql_quote($v);
232
-
233
-				// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
234
-				// sinon l’auteur en session
235
-				include_spip('inc/securiser_action');
236
-				if ($desc = decrire_token_previsu()) {
237
-					$id_auteur = $desc['id_auteur'];
238
-				} elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) {
239
-					$id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']);
240
-				} else {
241
-					$id_auteur = null;
242
-				}
243
-
244
-				// dans ce cas (admin en general), pas de filtrage sur ce statut
245
-				if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) {
246
-					// si pas d'auteur identifie pas de sous-requete car pas d'article qui matche
247
-					if (!$id_auteur) {
248
-						$where[] = $w;
249
-					} else {
250
-						$primary = id_table_objet($objet);
251
-						$where[] = "($w OR $id_table.$primary IN (" . sql_get_select(
252
-								'ssss.id_objet',
253
-								'spip_auteurs_liens AS ssss',
254
-								'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur),
255
-								'',
256
-								'',
257
-								'',
258
-								'',
259
-								$serveur
260
-							) . '))';
261
-					}
262
-				}
263
-			} // ignorer ce statut si on ne sait pas comment le filtrer
264
-			else {
265
-				$v = '';
266
-			}
267
-		}
268
-		// securite
269
-		$liste_statuts[$k] = preg_replace(',\W,', '', $v);
270
-	}
271
-	$liste_statuts = array_filter($liste_statuts);
272
-	if (count($liste_statuts) == 1) {
273
-		$where[] = array('=', $mstatut, sql_quote(reset($liste_statuts), $serveur));
274
-	} else {
275
-		$where[] = sql_in($mstatut, $liste_statuts, $not, $serveur);
276
-	}
277
-
278
-	while (count($where) > 1) {
279
-		$and = array('AND', array_pop($where), array_pop($where));
280
-		$where[] = $and;
281
-	}
282
-	$cond[$key] = reset($where);
283
-	if ($not) {
284
-		$cond[$key] = array('NOT', $cond[$key]);
285
-	}
286
-
287
-	return $cond[$key];
194
+    static $cond = array();
195
+    $key = func_get_args();
196
+    $key = implode('-', $key);
197
+    if (isset($cond[$key])) {
198
+        return $cond[$key];
199
+    }
200
+
201
+    $liste_statuts = $publie;
202
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) {
203
+        $liste_statuts = $previsu;
204
+    }
205
+    $not = false;
206
+    if (strncmp($liste_statuts, '!', 1) == 0) {
207
+        $not = true;
208
+        $liste_statuts = substr($liste_statuts, 1);
209
+    }
210
+    // '' => ne rien afficher, '!'=> ne rien filtrer
211
+    if (!strlen($liste_statuts)) {
212
+        return $cond[$key] = ($not ? '1=1' : '0=1');
213
+    }
214
+
215
+    $liste_statuts = explode(',', $liste_statuts);
216
+    $where = array();
217
+    foreach ($liste_statuts as $k => $v) {
218
+        // filtrage /auteur pour limiter les objets d'un statut (prepa en general)
219
+        // a ceux de l'auteur identifie
220
+        if (strpos($v, '/') !== false) {
221
+            $v = explode('/', $v);
222
+            $filtre = end($v);
223
+            $v = reset($v);
224
+            $v = preg_replace(',\W,', '', $v);
225
+            if ($filtre == 'auteur'
226
+                and (strpos($mstatut, '.') !== false)
227
+                and $objet = explode('.', $mstatut)
228
+                and $id_table = reset($objet)
229
+                and $objet = objet_type($id_table)
230
+            ) {
231
+                $w = "$mstatut<>" . sql_quote($v);
232
+
233
+                // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
234
+                // sinon l’auteur en session
235
+                include_spip('inc/securiser_action');
236
+                if ($desc = decrire_token_previsu()) {
237
+                    $id_auteur = $desc['id_auteur'];
238
+                } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) {
239
+                    $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']);
240
+                } else {
241
+                    $id_auteur = null;
242
+                }
243
+
244
+                // dans ce cas (admin en general), pas de filtrage sur ce statut
245
+                if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) {
246
+                    // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche
247
+                    if (!$id_auteur) {
248
+                        $where[] = $w;
249
+                    } else {
250
+                        $primary = id_table_objet($objet);
251
+                        $where[] = "($w OR $id_table.$primary IN (" . sql_get_select(
252
+                                'ssss.id_objet',
253
+                                'spip_auteurs_liens AS ssss',
254
+                                'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur),
255
+                                '',
256
+                                '',
257
+                                '',
258
+                                '',
259
+                                $serveur
260
+                            ) . '))';
261
+                    }
262
+                }
263
+            } // ignorer ce statut si on ne sait pas comment le filtrer
264
+            else {
265
+                $v = '';
266
+            }
267
+        }
268
+        // securite
269
+        $liste_statuts[$k] = preg_replace(',\W,', '', $v);
270
+    }
271
+    $liste_statuts = array_filter($liste_statuts);
272
+    if (count($liste_statuts) == 1) {
273
+        $where[] = array('=', $mstatut, sql_quote(reset($liste_statuts), $serveur));
274
+    } else {
275
+        $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur);
276
+    }
277
+
278
+    while (count($where) > 1) {
279
+        $and = array('AND', array_pop($where), array_pop($where));
280
+        $where[] = $and;
281
+    }
282
+    $cond[$key] = reset($where);
283
+    if ($not) {
284
+        $cond[$key] = array('NOT', $cond[$key]);
285
+    }
286
+
287
+    return $cond[$key];
288 288
 }
289 289
 
290 290
 /**
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
  * @return array|bool|null
296 296
  */
297 297
 function quete_fichier($id_document, $serveur = '') {
298
-	return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
298
+    return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
299 299
 }
300 300
 
301 301
 /**
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
  * @return array|bool
307 307
  */
308 308
 function quete_document($id_document, $serveur = '') {
309
-	return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
309
+    return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur);
310 310
 }
311 311
 
312 312
 /**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
  * @return array|bool|null
318 318
  */
319 319
 function quete_meta($nom, $serveur) {
320
-	return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur);
320
+    return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur);
321 321
 }
322 322
 
323 323
 /**
@@ -343,66 +343,66 @@  discard block
 block discarded – undo
343 343
  *     Retourne soit un tableau, soit le chemin du fichier.
344 344
  */
345 345
 function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag) {
346
-	include_spip('base/objets');
347
-	$nom = strtolower($onoff);
348
-
349
-	$cle_objet = id_table_objet($cle_objet);
350
-
351
-	while (1) {
352
-		$objet = objet_type($cle_objet);
353
-
354
-		$on = quete_logo_objet($id, $objet, $nom);
355
-
356
-		if ($on) {
357
-			if ($flag) {
358
-				return basename($on['chemin']);
359
-			} else {
360
-				$taille = @spip_getimagesize($on['chemin']);
361
-
362
-				// Si on a déjà demandé un survol directement ($onoff = off)
363
-				// ou qu'on a demandé uniquement le normal ($onoff = on)
364
-				// alors on ne cherche pas du tout le survol ici
365
-				if ($onoff != 'ON') {
366
-					$off = '';
367
-				} else {
368
-					// Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol
369
-					$off = quete_logo_objet($id, $objet, 'off');
370
-				}
371
-
372
-				// on retourne une url du type IMG/artonXX?timestamp
373
-				// qui permet de distinguer le changement de logo
374
-				// et placer un expire sur le dossier IMG/
375
-				$res = array(
376
-					$on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''),
377
-					($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''),
378
-					(!$taille ? '' : (' ' . $taille[3]))
379
-				);
380
-				$res['src'] = $res[0];
381
-				$res['logo_on'] = $res[0];
382
-				$res['logo_off'] = $res[1];
383
-				$res['width'] = ($taille ? $taille[0] : '');
384
-				$res['height'] = ($taille ? $taille[1] : '');
385
-
386
-				return $res;
387
-			}
388
-		} else {
389
-			if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) {
390
-				return '';
391
-			} else {
392
-				if ($id_rubrique) {
393
-					$cle_objet = 'id_rubrique';
394
-					$id = $id_rubrique;
395
-					$id_rubrique = 0;
396
-				} else {
397
-					if ($id and $cle_objet == 'id_rubrique') {
398
-						$id = quete_parent($id);
399
-					} else {
400
-						return '';
401
-					}
402
-				}
403
-			}
404
-		}
405
-	}
346
+    include_spip('base/objets');
347
+    $nom = strtolower($onoff);
348
+
349
+    $cle_objet = id_table_objet($cle_objet);
350
+
351
+    while (1) {
352
+        $objet = objet_type($cle_objet);
353
+
354
+        $on = quete_logo_objet($id, $objet, $nom);
355
+
356
+        if ($on) {
357
+            if ($flag) {
358
+                return basename($on['chemin']);
359
+            } else {
360
+                $taille = @spip_getimagesize($on['chemin']);
361
+
362
+                // Si on a déjà demandé un survol directement ($onoff = off)
363
+                // ou qu'on a demandé uniquement le normal ($onoff = on)
364
+                // alors on ne cherche pas du tout le survol ici
365
+                if ($onoff != 'ON') {
366
+                    $off = '';
367
+                } else {
368
+                    // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol
369
+                    $off = quete_logo_objet($id, $objet, 'off');
370
+                }
371
+
372
+                // on retourne une url du type IMG/artonXX?timestamp
373
+                // qui permet de distinguer le changement de logo
374
+                // et placer un expire sur le dossier IMG/
375
+                $res = array(
376
+                    $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''),
377
+                    ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''),
378
+                    (!$taille ? '' : (' ' . $taille[3]))
379
+                );
380
+                $res['src'] = $res[0];
381
+                $res['logo_on'] = $res[0];
382
+                $res['logo_off'] = $res[1];
383
+                $res['width'] = ($taille ? $taille[0] : '');
384
+                $res['height'] = ($taille ? $taille[1] : '');
385
+
386
+                return $res;
387
+            }
388
+        } else {
389
+            if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) {
390
+                return '';
391
+            } else {
392
+                if ($id_rubrique) {
393
+                    $cle_objet = 'id_rubrique';
394
+                    $id = $id_rubrique;
395
+                    $id_rubrique = 0;
396
+                } else {
397
+                    if ($id and $cle_objet == 'id_rubrique') {
398
+                        $id = quete_parent($id);
399
+                    } else {
400
+                        return '';
401
+                    }
402
+                }
403
+            }
404
+        }
405
+    }
406 406
 }
407 407
 
408 408
 /**
@@ -416,37 +416,37 @@  discard block
 block discarded – undo
416 416
  * 		"on" ou "off" suivant le logo normal ou survol
417 417
  **/
418 418
 function quete_logo_objet($id_objet, $objet, $mode) {
419
-	static $chercher_logo;
420
-	if (is_null($chercher_logo)) {
421
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
422
-	}
423
-	$cle_objet = id_table_objet($objet);
424
-
425
-	// On cherche pas la méthode classique
426
-	$infos_logo = $chercher_logo($id_objet, $cle_objet, $mode);
427
-	// Si la méthode classique a trouvé quelque chose, on utilise le nouveau format
428
-	if (!empty($infos_logo)) {
429
-		$infos_logo = array(
430
-			'chemin' => $infos_logo[0],
431
-			'timestamp' => $infos_logo[4],
432
-		);
433
-	}
434
-
435
-	// On passe cette recherche de logo dans un pipeline
436
-	$infos_logo = pipeline(
437
-		'quete_logo_objet',
438
-		array(
439
-			'args' => array(
440
-				'id_objet' => $id_objet,
441
-				'objet' => $objet,
442
-				'cle_objet' => $cle_objet,
443
-				'mode' => $mode,
444
-			),
445
-			'data' => $infos_logo,
446
-		)
447
-	);
448
-
449
-	return $infos_logo;
419
+    static $chercher_logo;
420
+    if (is_null($chercher_logo)) {
421
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
422
+    }
423
+    $cle_objet = id_table_objet($objet);
424
+
425
+    // On cherche pas la méthode classique
426
+    $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode);
427
+    // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format
428
+    if (!empty($infos_logo)) {
429
+        $infos_logo = array(
430
+            'chemin' => $infos_logo[0],
431
+            'timestamp' => $infos_logo[4],
432
+        );
433
+    }
434
+
435
+    // On passe cette recherche de logo dans un pipeline
436
+    $infos_logo = pipeline(
437
+        'quete_logo_objet',
438
+        array(
439
+            'args' => array(
440
+                'id_objet' => $id_objet,
441
+                'objet' => $objet,
442
+                'cle_objet' => $cle_objet,
443
+                'mode' => $mode,
444
+            ),
445
+            'data' => $infos_logo,
446
+        )
447
+    );
448
+
449
+    return $infos_logo;
450 450
 }
451 451
 
452 452
 /**
@@ -459,24 +459,24 @@  discard block
 block discarded – undo
459 459
  * @return bool|string
460 460
  */
461 461
 function quete_logo_file($row, $connect = null) {
462
-	include_spip('inc/documents');
463
-	$logo = vignette_logo_document($row, $connect);
464
-	if (!$logo) {
465
-		$logo = image_du_document($row, $connect);
466
-	}
467
-	if (!$logo) {
468
-		$f = charger_fonction('vignette', 'inc');
469
-		$logo = $f($row['extension'], false);
470
-	}
471
-	// si c'est une vignette type doc, la renvoyer direct
472
-	if (strcmp($logo, _DIR_PLUGINS) == 0
473
-		or strcmp($logo, _DIR_PLUGINS_DIST) == 0
474
-		or strcmp($logo, _DIR_RACINE . 'prive/') == 0
475
-	) {
476
-		return $logo;
477
-	}
478
-
479
-	return get_spip_doc($logo);
462
+    include_spip('inc/documents');
463
+    $logo = vignette_logo_document($row, $connect);
464
+    if (!$logo) {
465
+        $logo = image_du_document($row, $connect);
466
+    }
467
+    if (!$logo) {
468
+        $f = charger_fonction('vignette', 'inc');
469
+        $logo = $f($row['extension'], false);
470
+    }
471
+    // si c'est une vignette type doc, la renvoyer direct
472
+    if (strcmp($logo, _DIR_PLUGINS) == 0
473
+        or strcmp($logo, _DIR_PLUGINS_DIST) == 0
474
+        or strcmp($logo, _DIR_RACINE . 'prive/') == 0
475
+    ) {
476
+        return $logo;
477
+    }
478
+
479
+    return get_spip_doc($logo);
480 480
 }
481 481
 
482 482
 /**
@@ -504,20 +504,20 @@  discard block
 block discarded – undo
504 504
  */
505 505
 function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, $connect = null) {
506 506
 
507
-	include_spip('inc/documents');
508
-	$logo = '';
509
-	if (!in_array($mode_logo, array('icone', 'apercu'))) {
510
-		$logo = vignette_logo_document($row, $connect);
511
-	}
512
-	// si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas
513
-	if ($mode_logo == 'vignette' and !$logo) {
514
-		return '';
515
-	}
516
-	if ($mode_logo == 'icone') {
517
-		$row['fichier'] = '';
518
-	}
519
-
520
-	return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect);
507
+    include_spip('inc/documents');
508
+    $logo = '';
509
+    if (!in_array($mode_logo, array('icone', 'apercu'))) {
510
+        $logo = vignette_logo_document($row, $connect);
511
+    }
512
+    // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas
513
+    if ($mode_logo == 'vignette' and !$logo) {
514
+        return '';
515
+    }
516
+    if ($mode_logo == 'icone') {
517
+        $row['fichier'] = '';
518
+    }
519
+
520
+    return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect);
521 521
 }
522 522
 
523 523
 /**
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
  */
530 530
 function quete_html_logo($logo, $align, $lien) {
531 531
 
532
-	if (!is_array($logo)) {
533
-		return '';
534
-	}
535
-
536
-	$contexte = [];
537
-	foreach ($logo as $k=>$v) {
538
-		if (!is_numeric($k)) {
539
-			$contexte[$k] = $v;
540
-		}
541
-	}
542
-	$contexte['align'] = $align;
543
-	$contexte['lien'] = $lien;
544
-	return recuperer_fond('modeles/logo', $contexte);
532
+    if (!is_array($logo)) {
533
+        return '';
534
+    }
535
+
536
+    $contexte = [];
537
+    foreach ($logo as $k=>$v) {
538
+        if (!is_numeric($k)) {
539
+            $contexte[$k] = $v;
540
+        }
541
+    }
542
+    $contexte['align'] = $align;
543
+    $contexte['lien'] = $lien;
544
+    return recuperer_fond('modeles/logo', $contexte);
545 545
 }
546 546
 
547 547
 /**
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
  * @return string|false
556 556
  */
557 557
 function document_spip_externe($fichier, $connect) {
558
-	if ($connect) {
559
-		$site = quete_meta('adresse_site', $connect);
560
-		if ($site) {
561
-			$dir = quete_meta('dir_img', $connect);
562
-			return "$site/$dir$fichier";
563
-		}
564
-	}
565
-	return false;
558
+    if ($connect) {
559
+        $site = quete_meta('adresse_site', $connect);
560
+        if ($site) {
561
+            $dir = quete_meta('dir_img', $connect);
562
+            return "$site/$dir$fichier";
563
+        }
564
+    }
565
+    return false;
566 566
 }
567 567
 
568 568
 /**
@@ -575,23 +575,23 @@  discard block
 block discarded – undo
575 575
  * @return string
576 576
  */
577 577
 function vignette_logo_document($row, $connect = '') {
578
-	if (!$row['id_vignette']) {
579
-		return '';
580
-	}
581
-	$fichier = quete_fichier($row['id_vignette'], $connect);
582
-	if ($url = document_spip_externe($fichier, $connect)) {
583
-		return $url;
584
-	}
585
-
586
-	$f = get_spip_doc($fichier);
587
-	if ($f and @file_exists($f)) {
588
-		return $f;
589
-	}
590
-	if ($row['mode'] !== 'vignette') {
591
-		return '';
592
-	}
593
-
594
-	return generer_url_entite($row['id_document'], 'document', '', '', $connect);
578
+    if (!$row['id_vignette']) {
579
+        return '';
580
+    }
581
+    $fichier = quete_fichier($row['id_vignette'], $connect);
582
+    if ($url = document_spip_externe($fichier, $connect)) {
583
+        return $url;
584
+    }
585
+
586
+    $f = get_spip_doc($fichier);
587
+    if ($f and @file_exists($f)) {
588
+        return $f;
589
+    }
590
+    if ($row['mode'] !== 'vignette') {
591
+        return '';
592
+    }
593
+
594
+    return generer_url_entite($row['id_document'], 'document', '', '', $connect);
595 595
 }
596 596
 
597 597
 /**
@@ -607,68 +607,68 @@  discard block
 block discarded – undo
607 607
  * @return bool|string
608 608
  */
609 609
 function calcul_exposer($id, $prim, $reference, $parent, $type, $connect = '') {
610
-	static $exposer = array();
611
-
612
-	// Que faut-il exposer ? Tous les elements de $reference
613
-	// ainsi que leur hierarchie ; on ne fait donc ce calcul
614
-	// qu'une fois (par squelette) et on conserve le resultat
615
-	// en static.
616
-	if (!isset($exposer[$m = md5(serialize($reference))][$prim])) {
617
-		$principal = isset($reference[$type]) ? $reference[$type] :
618
-			// cas de la pagination indecte @xx qui positionne la page avec l'id xx
619
-			// et donne la reference dynamique @type=xx dans le contexte
620
-			(isset($reference["@$type"]) ? $reference["@$type"] : '');
621
-		// le parent fournit en argument est le parent de $id, pas celui de $principal
622
-		// il n'est donc pas utile
623
-		$parent = 0;
624
-		if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant
625
-			$enfants = array('id_rubrique' => array('id_article'), 'id_groupe' => array('id_mot'));
626
-			if (isset($enfants[$type])) {
627
-				foreach ($enfants[$type] as $t) {
628
-					if (isset($reference[$t])
629
-						// cas de la reference donnee dynamiquement par la pagination
630
-						or isset($reference["@$t"])
631
-					) {
632
-						$type = $t;
633
-						$principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"];
634
-						continue;
635
-					}
636
-				}
637
-			}
638
-		}
639
-		$exposer[$m][$type] = array();
640
-		if ($principal) {
641
-			$principaux = is_array($principal) ? $principal : array($principal);
642
-			foreach ($principaux as $principal) {
643
-				$exposer[$m][$type][$principal] = true;
644
-				if ($type == 'id_mot') {
645
-					if (!$parent) {
646
-						$parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect);
647
-					}
648
-					if ($parent) {
649
-						$exposer[$m]['id_groupe'][$parent] = true;
650
-					}
651
-				} else {
652
-					if ($type != 'id_groupe') {
653
-						if (!$parent) {
654
-							if ($type == 'id_rubrique') {
655
-								$parent = $principal;
656
-							}
657
-							if ($type == 'id_article') {
658
-								$parent = quete_rubrique($principal, $connect);
659
-							}
660
-						}
661
-						do {
662
-							$exposer[$m]['id_rubrique'][$parent] = true;
663
-						} while ($parent = quete_parent($parent, $connect));
664
-					}
665
-				}
666
-			}
667
-		}
668
-	}
669
-
670
-	// And the winner is...
671
-	return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : '';
610
+    static $exposer = array();
611
+
612
+    // Que faut-il exposer ? Tous les elements de $reference
613
+    // ainsi que leur hierarchie ; on ne fait donc ce calcul
614
+    // qu'une fois (par squelette) et on conserve le resultat
615
+    // en static.
616
+    if (!isset($exposer[$m = md5(serialize($reference))][$prim])) {
617
+        $principal = isset($reference[$type]) ? $reference[$type] :
618
+            // cas de la pagination indecte @xx qui positionne la page avec l'id xx
619
+            // et donne la reference dynamique @type=xx dans le contexte
620
+            (isset($reference["@$type"]) ? $reference["@$type"] : '');
621
+        // le parent fournit en argument est le parent de $id, pas celui de $principal
622
+        // il n'est donc pas utile
623
+        $parent = 0;
624
+        if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant
625
+            $enfants = array('id_rubrique' => array('id_article'), 'id_groupe' => array('id_mot'));
626
+            if (isset($enfants[$type])) {
627
+                foreach ($enfants[$type] as $t) {
628
+                    if (isset($reference[$t])
629
+                        // cas de la reference donnee dynamiquement par la pagination
630
+                        or isset($reference["@$t"])
631
+                    ) {
632
+                        $type = $t;
633
+                        $principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"];
634
+                        continue;
635
+                    }
636
+                }
637
+            }
638
+        }
639
+        $exposer[$m][$type] = array();
640
+        if ($principal) {
641
+            $principaux = is_array($principal) ? $principal : array($principal);
642
+            foreach ($principaux as $principal) {
643
+                $exposer[$m][$type][$principal] = true;
644
+                if ($type == 'id_mot') {
645
+                    if (!$parent) {
646
+                        $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect);
647
+                    }
648
+                    if ($parent) {
649
+                        $exposer[$m]['id_groupe'][$parent] = true;
650
+                    }
651
+                } else {
652
+                    if ($type != 'id_groupe') {
653
+                        if (!$parent) {
654
+                            if ($type == 'id_rubrique') {
655
+                                $parent = $principal;
656
+                            }
657
+                            if ($type == 'id_article') {
658
+                                $parent = quete_rubrique($principal, $connect);
659
+                            }
660
+                        }
661
+                        do {
662
+                            $exposer[$m]['id_rubrique'][$parent] = true;
663
+                        } while ($parent = quete_parent($parent, $connect));
664
+                    }
665
+                }
666
+            }
667
+        }
668
+    }
669
+
670
+    // And the winner is...
671
+    return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : '';
672 672
 }
673 673
 
674 674
 /**
@@ -683,21 +683,21 @@  discard block
 block discarded – undo
683 683
  * @return int
684 684
  */
685 685
 function quete_debut_pagination($primary, $valeur, $pas, $iter) {
686
-	// on ne devrait pas arriver ici si la cle primaire est inexistante
687
-	// ou composee, mais verifions
688
-	if (!$primary or preg_match('/[,\s]/', $primary)) {
689
-		return 0;
690
-	}
691
-
692
-	$pos = 0;
693
-	while ($row = $iter->fetch() and $row[$primary] != $valeur) {
694
-		$pos++;
695
-	}
696
-	// si on a pas trouve
697
-	if (!$row or $row[$primary] != $valeur) {
698
-		return 0;
699
-	}
700
-
701
-	// sinon, calculer le bon numero de page
702
-	return floor($pos / $pas) * $pas;
686
+    // on ne devrait pas arriver ici si la cle primaire est inexistante
687
+    // ou composee, mais verifions
688
+    if (!$primary or preg_match('/[,\s]/', $primary)) {
689
+        return 0;
690
+    }
691
+
692
+    $pos = 0;
693
+    while ($row = $iter->fetch() and $row[$primary] != $valeur) {
694
+        $pos++;
695
+    }
696
+    // si on a pas trouve
697
+    if (!$row or $row[$primary] != $valeur) {
698
+        return 0;
699
+    }
700
+
701
+    // sinon, calculer le bon numero de page
702
+    return floor($pos / $pas) * $pas;
703 703
 }
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <?php
2
-	# appel SPIP
3
-	include('spip.php');
2
+    # appel SPIP
3
+    include('spip.php');
Please login to merge, or discard this patch.
prive/objets/liste/objets-trad_fonctions.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function lister_traductions($id_trad, $objet) {
18
-	$table_objet_sql = table_objet_sql($objet);
19
-	$primary = id_table_objet($objet);
18
+    $table_objet_sql = table_objet_sql($objet);
19
+    $primary = id_table_objet($objet);
20 20
 
21
-	$select = "$primary as id,lang";
22
-	$where = 'id_trad=' . intval($id_trad);
23
-	$trouver_table = charger_fonction('trouver_table','base');
24
-	$desc = $trouver_table($table_objet_sql);
25
-	if (isset($desc['field']['statut'])) {
26
-		$select .= ',statut';
27
-		$where .= ' AND statut!='.sql_quote('poubelle');
28
-	}
21
+    $select = "$primary as id,lang";
22
+    $where = 'id_trad=' . intval($id_trad);
23
+    $trouver_table = charger_fonction('trouver_table','base');
24
+    $desc = $trouver_table($table_objet_sql);
25
+    if (isset($desc['field']['statut'])) {
26
+        $select .= ',statut';
27
+        $where .= ' AND statut!='.sql_quote('poubelle');
28
+    }
29 29
 
30
-	$rows = sql_allfetsel($select, $table_objet_sql, $where);
31
-	lang_select();
30
+    $rows = sql_allfetsel($select, $table_objet_sql, $where);
31
+    lang_select();
32 32
 
33
-	return $rows;
33
+    return $rows;
34 34
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@
 block discarded – undo
19 19
 	$primary = id_table_objet($objet);
20 20
 
21 21
 	$select = "$primary as id,lang";
22
-	$where = 'id_trad=' . intval($id_trad);
23
-	$trouver_table = charger_fonction('trouver_table','base');
22
+	$where = 'id_trad='.intval($id_trad);
23
+	$trouver_table = charger_fonction('trouver_table', 'base');
24 24
 	$desc = $trouver_table($table_objet_sql);
25 25
 	if (isset($desc['field']['statut'])) {
26 26
 		$select .= ',statut';
Please login to merge, or discard this patch.
prive/objets/liste/auteurs_lies_fonctions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('prive/objets/liste/auteurs_fonctions');
Please login to merge, or discard this patch.
prive/objets/liste/objets-en-edition_fonctions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/drapeau_edition');
Please login to merge, or discard this patch.
prive/objets/liste/auteurs_fonctions.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@
 block discarded – undo
154 154
 	) {
155 155
 		return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
156 156
 	} elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
157
-		return 'mailto:' . $email;
157
+		return 'mailto:'.$email;
158 158
 	} else {
159 159
 		return '';
160 160
 	}
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Fonctions
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
  * @param bool $left
30 30
  */
31 31
 function critere_compteur_articles_filtres_dist($idb, &$boucles, $crit, $left = false) {
32
-	$boucle = &$boucles[$idb];
32
+    $boucle = &$boucles[$idb];
33 33
 
34
-	$_statut = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
34
+    $_statut = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
35 35
 
36
-	$not = '';
37
-	if ($crit->not) {
38
-		$not = ", 'NOT'";
39
-	}
40
-	$boucle->from['LAA'] = 'spip_auteurs_liens';
41
-	$boucle->from_type['LAA'] = 'left';
42
-	$boucle->join['LAA'] = array("'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''");
36
+    $not = '';
37
+    if ($crit->not) {
38
+        $not = ", 'NOT'";
39
+    }
40
+    $boucle->from['LAA'] = 'spip_auteurs_liens';
41
+    $boucle->from_type['LAA'] = 'left';
42
+    $boucle->join['LAA'] = array("'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''");
43 43
 
44
-	$boucle->from['articles'] = 'spip_articles';
45
-	$boucle->from_type['articles'] = 'left';
46
-	$boucle->join['articles'] = array(
47
-		"'LAA'",
48
-		"'id_article'",
49
-		"'id_objet'",
50
-		"'(articles.statut IS NULL OR '.sql_in('articles.statut',_q($_statut)$not).')'"
51
-	);
44
+    $boucle->from['articles'] = 'spip_articles';
45
+    $boucle->from_type['articles'] = 'left';
46
+    $boucle->join['articles'] = array(
47
+        "'LAA'",
48
+        "'id_article'",
49
+        "'id_objet'",
50
+        "'(articles.statut IS NULL OR '.sql_in('articles.statut',_q($_statut)$not).')'"
51
+    );
52 52
 
53
-	$boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles';
54
-	$boucle->group[] = 'auteurs.id_auteur';
53
+    $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles';
54
+    $boucle->group[] = 'auteurs.id_auteur';
55 55
 }
56 56
 
57 57
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  *     Pile complétée par le code à générer
70 70
  */
71 71
 function balise_COMPTEUR_ARTICLES_dist($p) {
72
-	return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres');
72
+    return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres');
73 73
 }
74 74
 
75 75
 
@@ -85,43 +85,43 @@  discard block
 block discarded – undo
85 85
  * @return string
86 86
  */
87 87
 function afficher_initiale($url, $initiale, $compteur, $debut, $pas) {
88
-	static $memo = null;
89
-	static $res = [];
90
-	$out = '';
91
-	if (!$memo
92
-		or (!$initiale and !$url)
93
-		or ($initiale !== $memo['initiale'])
94
-	) {
95
-		$newcompt = intval(floor(($compteur - 1) / $pas) * $pas);
96
-		// si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien
97
-		if (!$initiale and !$url and !$memo['compteur']) {
98
-			$memo = null;
99
-		}
100
-		if ($memo) {
101
-			$on = (($memo['compteur'] <= $debut)
102
-				and (
103
-					$newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
104
-				));
105
-			$res[] = lien_ou_expose($memo['url'], $memo['initiale'], $on, 'lien_pagination');
106
-		}
107
-		if ($initiale) {
108
-			$memo = array(
109
-				'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0,
110
-				'initiale' => $initiale,
111
-				'url' => parametre_url($url, 'i', $initiale),
112
-				'compteur' => $newcompt
113
-			);
114
-		}
115
-	}
116
-	if (!$initiale and !$url) {
117
-		if (count($res) > 1) {
118
-			$out = implode(' ', $res);
119
-		}
120
-		$memo = null;
121
-		$res = [];
122
-	}
88
+    static $memo = null;
89
+    static $res = [];
90
+    $out = '';
91
+    if (!$memo
92
+        or (!$initiale and !$url)
93
+        or ($initiale !== $memo['initiale'])
94
+    ) {
95
+        $newcompt = intval(floor(($compteur - 1) / $pas) * $pas);
96
+        // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien
97
+        if (!$initiale and !$url and !$memo['compteur']) {
98
+            $memo = null;
99
+        }
100
+        if ($memo) {
101
+            $on = (($memo['compteur'] <= $debut)
102
+                and (
103
+                    $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
104
+                ));
105
+            $res[] = lien_ou_expose($memo['url'], $memo['initiale'], $on, 'lien_pagination');
106
+        }
107
+        if ($initiale) {
108
+            $memo = array(
109
+                'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0,
110
+                'initiale' => $initiale,
111
+                'url' => parametre_url($url, 'i', $initiale),
112
+                'compteur' => $newcompt
113
+            );
114
+        }
115
+    }
116
+    if (!$initiale and !$url) {
117
+        if (count($res) > 1) {
118
+            $out = implode(' ', $res);
119
+        }
120
+        $memo = null;
121
+        $res = [];
122
+    }
123 123
 
124
-	return $out;
124
+    return $out;
125 125
 }
126 126
 
127 127
 /**
@@ -140,23 +140,23 @@  discard block
 block discarded – undo
140 140
  * @return string
141 141
  */
142 142
 function auteur_lien_messagerie($id_auteur, $en_ligne, $statut, $imessage, $email = '') {
143
-	static $time = null;
144
-	if (!in_array($statut, array('0minirezo', '1comite'))) {
145
-		return '';
146
-	}
143
+    static $time = null;
144
+    if (!in_array($statut, array('0minirezo', '1comite'))) {
145
+        return '';
146
+    }
147 147
 
148
-	if (is_null($time)) {
149
-		$time = time();
150
-	}
151
-	$parti = (($time - strtotime($en_ligne)) > 15 * 60);
148
+    if (is_null($time)) {
149
+        $time = time();
150
+    }
151
+    $parti = (($time - strtotime($en_ligne)) > 15 * 60);
152 152
 
153
-	if ($imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ?
154
-		and $GLOBALS['meta']['messagerie_agenda'] != 'non'
155
-	) {
156
-		return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
157
-	} elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
158
-		return 'mailto:' . $email;
159
-	} else {
160
-		return '';
161
-	}
153
+    if ($imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ?
154
+        and $GLOBALS['meta']['messagerie_agenda'] != 'non'
155
+    ) {
156
+        return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
157
+    } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
158
+        return 'mailto:' . $email;
159
+    } else {
160
+        return '';
161
+    }
162 162
 }
Please login to merge, or discard this patch.
prive/objets/liste/articles_fonctions.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,40 +11,40 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function defaut_tri_defined($defaut) {
18
-	if (!defined('_TRI_ARTICLES_RUBRIQUE')) {
19
-		return $defaut;
20
-	}
18
+    if (!defined('_TRI_ARTICLES_RUBRIQUE')) {
19
+        return $defaut;
20
+    }
21 21
 
22
-	$sens = 1;
23
-	$tri = trim(_TRI_ARTICLES_RUBRIQUE);
24
-	$tri = explode(' ', $tri);
25
-	if (strncasecmp(end($tri), 'DESC', 4) == 0) {
26
-		$sens = -1;
27
-		array_pop($tri);
28
-	} elseif (strncasecmp(end($tri), 'ASC', 3) == 0) {
29
-		$sens = 1;
30
-		array_pop($tri);
31
-	}
32
-	$tri = implode(' ', $tri);
33
-	$tri = array($tri => $sens);
34
-	foreach ($defaut as $n => $s) {
35
-		if (!isset($tri[$n])) {
36
-			$tri[$n] = $s;
37
-		}
38
-	}
22
+    $sens = 1;
23
+    $tri = trim(_TRI_ARTICLES_RUBRIQUE);
24
+    $tri = explode(' ', $tri);
25
+    if (strncasecmp(end($tri), 'DESC', 4) == 0) {
26
+        $sens = -1;
27
+        array_pop($tri);
28
+    } elseif (strncasecmp(end($tri), 'ASC', 3) == 0) {
29
+        $sens = 1;
30
+        array_pop($tri);
31
+    }
32
+    $tri = implode(' ', $tri);
33
+    $tri = array($tri => $sens);
34
+    foreach ($defaut as $n => $s) {
35
+        if (!isset($tri[$n])) {
36
+            $tri[$n] = $s;
37
+        }
38
+    }
39 39
 
40
-	return $tri;
40
+    return $tri;
41 41
 }
42 42
 
43 43
 function defaut_tri_par($par, $defaut) {
44
-	if (!defined('_TRI_ARTICLES_RUBRIQUE')) {
45
-		return $par;
46
-	}
47
-	$par = array_keys($defaut);
44
+    if (!defined('_TRI_ARTICLES_RUBRIQUE')) {
45
+        return $par;
46
+    }
47
+    $par = array_keys($defaut);
48 48
 
49
-	return reset($par);
49
+    return reset($par);
50 50
 }
Please login to merge, or discard this patch.
prive/formulaires/inc-instituer_auteur_fonctions.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package SPIP\Core\Formulaires
7 7
  **/
8 8
 if (!defined('_ECRIRE_INC_VERSION')) {
9
-	return;
9
+    return;
10 10
 }
11 11
 
12 12
 /**
@@ -23,31 +23,31 @@  discard block
 block discarded – undo
23 23
  *     Code HTML et javascript
24 24
  */
25 25
 function choisir_rubriques_admin_restreint(
26
-	$id_auteur,
27
-	$label = '',
28
-	$sel_css = '#liste_rubriques_restreintes',
29
-	$img_remove = ''
26
+    $id_auteur,
27
+    $label = '',
28
+    $sel_css = '#liste_rubriques_restreintes',
29
+    $img_remove = ''
30 30
 ) {
31
-	global $spip_lang;
32
-	$res = '';
33
-	// Ajouter une rubrique a un administrateur restreint
34
-	if ($chercher_rubrique = charger_fonction('chercher_rubrique', 'inc')
35
-		and $a = $chercher_rubrique(0, 'auteur', false)
36
-	) {
37
-		if ($img_remove) {
38
-			$img_remove = addslashes("<a href=\"#\" onclick=\"jQuery(this).parent().remove();return false;\" class=\"removelink\">$img_remove</a>");
39
-		}
31
+    global $spip_lang;
32
+    $res = '';
33
+    // Ajouter une rubrique a un administrateur restreint
34
+    if ($chercher_rubrique = charger_fonction('chercher_rubrique', 'inc')
35
+        and $a = $chercher_rubrique(0, 'auteur', false)
36
+    ) {
37
+        if ($img_remove) {
38
+            $img_remove = addslashes("<a href=\"#\" onclick=\"jQuery(this).parent().remove();return false;\" class=\"removelink\">$img_remove</a>");
39
+        }
40 40
 
41
-		$res =
42
-			"\n<div id='ajax_rubrique'>\n"
43
-			. "<label>$label</label>\n"
44
-			. "<input name='id_auteur' value='$id_auteur' type='hidden' />\n"
45
-			. $a
46
-			. "</div>\n"
41
+        $res =
42
+            "\n<div id='ajax_rubrique'>\n"
43
+            . "<label>$label</label>\n"
44
+            . "<input name='id_auteur' value='$id_auteur' type='hidden' />\n"
45
+            . $a
46
+            . "</div>\n"
47 47
 
48
-			// onchange = pour le menu
49
-			// l'evenement doit etre provoque a la main par le selecteur ajax
50
-			. "<script type='text/javascript'>/*<![CDATA[*/
48
+            // onchange = pour le menu
49
+            // l'evenement doit etre provoque a la main par le selecteur ajax
50
+            . "<script type='text/javascript'>/*<![CDATA[*/
51 51
 jQuery(function($){
52 52
 	$('#id_parent').on('change', function(){
53 53
 		var id_parent = parseInt(this.value);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	.attr('name','noname');
67 67
 });
68 68
 /*]]>*/</script>";
69
-	}
69
+    }
70 70
 
71
-	return $res;
71
+    return $res;
72 72
 }
Please login to merge, or discard this patch.