Completed
Push — master ( e0a449...105b0e )
by cam
04:25
created
ecrire/inc/editer.php 1 patch
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 include_spip('base/abstract_sql');
23 23
 
@@ -59,56 +59,56 @@  discard block
 block discarded – undo
59 59
  *     Retour des traitements.
60 60
  **/
61 61
 function formulaires_editer_objet_traiter(
62
-	$type,
63
-	$id = 'new',
64
-	$id_parent = 0,
65
-	$lier_trad = 0,
66
-	$retour = '',
67
-	$config_fonc = 'articles_edit_config',
68
-	$row = array(),
69
-	$hidden = ''
62
+    $type,
63
+    $id = 'new',
64
+    $id_parent = 0,
65
+    $lier_trad = 0,
66
+    $retour = '',
67
+    $config_fonc = 'articles_edit_config',
68
+    $row = array(),
69
+    $hidden = ''
70 70
 ) {
71 71
 
72
-	$res = array();
73
-	// eviter la redirection forcee par l'action...
74
-	set_request('redirect');
75
-	if ($action_editer = charger_fonction("editer_$type", 'action', true)) {
76
-		list($id, $err) = $action_editer($id);
77
-	} else {
78
-		$action_editer = charger_fonction('editer_objet', 'action');
79
-		list($id, $err) = $action_editer($id, $type);
80
-	}
81
-	$id_table_objet = id_table_objet($type);
82
-	$res[$id_table_objet] = $id;
83
-	if ($err or !$id) {
84
-		$res['message_erreur'] = ($err ? $err : _T('erreur'));
85
-	} else {
86
-		// Un lien de trad a prendre en compte
87
-		if ($lier_trad) {
88
-			// referencer la traduction
89
-			$referencer_traduction = charger_fonction('referencer_traduction', 'action');
90
-			$referencer_traduction($type, $id, $lier_trad);
91
-			// actions de recopie de champs / liens sur le nouvel objet créé
92
-			$completer_traduction = charger_fonction('completer_traduction', 'inc');
93
-			$err = $completer_traduction($type, $id, $lier_trad);
94
-			if ($err) {
95
-				$res['message_erreur'] = $err;
96
-				return $res;
97
-			}
98
-		}
99
-
100
-		$res['message_ok'] = _T('info_modification_enregistree');
101
-		if ($retour) {
102
-			if (strncmp($retour, 'javascript:', 11) == 0) {
103
-				$res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>';
104
-				$res['editable'] = true;
105
-			} else {
106
-				$res['redirect'] = parametre_url($retour, $id_table_objet, $id);
107
-			}
108
-		}
109
-	}
110
-
111
-	return $res;
72
+    $res = array();
73
+    // eviter la redirection forcee par l'action...
74
+    set_request('redirect');
75
+    if ($action_editer = charger_fonction("editer_$type", 'action', true)) {
76
+        list($id, $err) = $action_editer($id);
77
+    } else {
78
+        $action_editer = charger_fonction('editer_objet', 'action');
79
+        list($id, $err) = $action_editer($id, $type);
80
+    }
81
+    $id_table_objet = id_table_objet($type);
82
+    $res[$id_table_objet] = $id;
83
+    if ($err or !$id) {
84
+        $res['message_erreur'] = ($err ? $err : _T('erreur'));
85
+    } else {
86
+        // Un lien de trad a prendre en compte
87
+        if ($lier_trad) {
88
+            // referencer la traduction
89
+            $referencer_traduction = charger_fonction('referencer_traduction', 'action');
90
+            $referencer_traduction($type, $id, $lier_trad);
91
+            // actions de recopie de champs / liens sur le nouvel objet créé
92
+            $completer_traduction = charger_fonction('completer_traduction', 'inc');
93
+            $err = $completer_traduction($type, $id, $lier_trad);
94
+            if ($err) {
95
+                $res['message_erreur'] = $err;
96
+                return $res;
97
+            }
98
+        }
99
+
100
+        $res['message_ok'] = _T('info_modification_enregistree');
101
+        if ($retour) {
102
+            if (strncmp($retour, 'javascript:', 11) == 0) {
103
+                $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>';
104
+                $res['editable'] = true;
105
+            } else {
106
+                $res['redirect'] = parametre_url($retour, $id_table_objet, $id);
107
+            }
108
+        }
109
+    }
110
+
111
+    return $res;
112 112
 }
113 113
 
114 114
 /**
@@ -132,29 +132,29 @@  discard block
 block discarded – undo
132 132
  *     Tableau des erreurs
133 133
  **/
134 134
 function formulaires_editer_objet_verifier($type, $id = 'new', $oblis = array()) {
135
-	$erreurs = array();
136
-	if (intval($id)) {
137
-		$conflits = controler_contenu($type, $id);
138
-		if ($conflits and count($conflits)) {
139
-			foreach ($conflits as $champ => $conflit) {
140
-				if (!isset($erreurs[$champ])) {
141
-					$erreurs[$champ] = '';
142
-				}
143
-				$erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>';
144
-			}
145
-		}
146
-	}
147
-	foreach ($oblis as $obli) {
148
-		$value = _request($obli);
149
-		if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) {
150
-			if (!isset($erreurs[$obli])) {
151
-				$erreurs[$obli] = '';
152
-			}
153
-			$erreurs[$obli] .= _T('info_obligatoire');
154
-		}
155
-	}
156
-
157
-	return $erreurs;
135
+    $erreurs = array();
136
+    if (intval($id)) {
137
+        $conflits = controler_contenu($type, $id);
138
+        if ($conflits and count($conflits)) {
139
+            foreach ($conflits as $champ => $conflit) {
140
+                if (!isset($erreurs[$champ])) {
141
+                    $erreurs[$champ] = '';
142
+                }
143
+                $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>';
144
+            }
145
+        }
146
+    }
147
+    foreach ($oblis as $obli) {
148
+        $value = _request($obli);
149
+        if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) {
150
+            if (!isset($erreurs[$obli])) {
151
+                $erreurs[$obli] = '';
152
+            }
153
+            $erreurs[$obli] .= _T('info_obligatoire');
154
+        }
155
+    }
156
+
157
+    return $erreurs;
158 158
 }
159 159
 
160 160
 /**
@@ -198,145 +198,145 @@  discard block
 block discarded – undo
198 198
  *     Environnement du formulaire.
199 199
  **/
200 200
 function formulaires_editer_objet_charger(
201
-	$type,
202
-	$id = 'new',
203
-	$id_parent = 0,
204
-	$lier_trad = 0,
205
-	$retour = '',
206
-	$config_fonc = 'articles_edit_config',
207
-	$row = array(),
208
-	$hidden = ''
201
+    $type,
202
+    $id = 'new',
203
+    $id_parent = 0,
204
+    $lier_trad = 0,
205
+    $retour = '',
206
+    $config_fonc = 'articles_edit_config',
207
+    $row = array(),
208
+    $hidden = ''
209 209
 ) {
210 210
 
211
-	$table_objet = table_objet($type);
212
-	$table_objet_sql = table_objet_sql($type);
213
-	$id_table_objet = id_table_objet($type);
214
-
215
-	// on accepte pas une fonction de config inconnue si elle vient d'un modele
216
-	if ($config_fonc
217
-	  and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config'])
218
-	  and $config_fonc !== $table_objet . '_edit_config') {
219
-		if ($args = test_formulaire_inclus_par_modele()
220
-		  and in_array($config_fonc, $args)) {
221
-			$config_fonc = '';
222
-		}
223
-	}
224
-
225
-	$new = !is_numeric($id);
226
-	$lang_default = '';
227
-	// Appel direct dans un squelette
228
-	if (!$row) {
229
-		if (!$new or $lier_trad) {
230
-			if ($select = charger_fonction('precharger_' . $type, 'inc', true)) {
231
-				$row = $select($id, $id_parent, $lier_trad);
232
-				// si on a une fonction precharger, elle pu faire un reglage de langue
233
-				$lang_default = (!empty($row['lang']) ? $row['lang'] : null);
234
-			} else {
235
-				$row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id));
236
-			}
237
-			if (!$new) {
238
-				$md5 = controles_md5($row);
239
-			}
240
-		}
241
-		if (!$row) {
242
-			$row = array();
243
-			$trouver_table = charger_fonction('trouver_table', 'base');
244
-			if ($desc = $trouver_table($table_objet)) {
245
-				foreach ($desc['field'] as $k => $v) {
246
-					$row[$k] = '';
247
-				}
248
-			}
249
-		}
250
-	}
251
-
252
-	// Gaffe: sans ceci, on ecrase systematiquement l'article d'origine
253
-	// (et donc: pas de lien de traduction)
254
-	$id = ($new or $lier_trad)
255
-		? 'oui'
256
-		: $row[$id_table_objet];
257
-	$row[$id_table_objet] = $id;
258
-
259
-	$contexte = $row;
260
-	if (strlen($id_parent) && is_numeric($id_parent) && (!isset($contexte['id_parent']) or $new)) {
261
-		if (!isset($contexte['id_parent'])) {
262
-			unset($contexte['id_rubrique']);
263
-		}
264
-		$contexte['id_parent'] = $id_parent;
265
-	} elseif (!isset($contexte['id_parent'])) {
266
-		// id_rubrique dans id_parent si possible
267
-		if (isset($contexte['id_rubrique'])) {
268
-			$contexte['id_parent'] = $contexte['id_rubrique'];
269
-			unset($contexte['id_rubrique']);
270
-		} else {
271
-			$contexte['id_parent'] = '';
272
-		}
273
-		if (!$contexte['id_parent']
274
-			and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true)
275
-		) {
276
-			$contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row);
277
-		}
278
-	}
279
-
280
-	$config = array();
281
-	if ($config_fonc) {
282
-		$contexte['config'] = $config = $config_fonc($contexte);
283
-		if (!$lang_default) {
284
-			$lang_default = $config['langue'];
285
-		}
286
-	}
287
-	$config = $config + array(
288
-		'lignes' => 0,
289
-		'langue' => '',
290
-	);
291
-
292
-	$att_text = " class='textarea' "
293
-		. " rows='"
294
-		. ($config['lignes'] + 15)
295
-		. "' cols='40'";
296
-	if (isset($contexte['texte'])) {
297
-		list($contexte['texte'], $contexte['_texte_trop_long']) = editer_texte_recolle($contexte['texte'], $att_text);
298
-	}
299
-
300
-	// on veut conserver la langue de l'interface ;
301
-	// on passe cette donnee sous un autre nom, au cas ou le squelette
302
-	// voudrait l'exploiter
303
-	if (isset($contexte['lang'])) {
304
-		$contexte['langue'] = $contexte['lang'];
305
-		unset($contexte['lang']);
306
-	}
307
-
308
-	$contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" .
309
-		(!$lier_trad ? '' :
310
-			("\n<input type='hidden' name='lier_trad' value='" .
311
-				$lier_trad .
312
-				"' />" .
313
-				"\n<input type='hidden' name='changer_lang' value='" .
314
-				$lang_default .
315
-				"' />"))
316
-		. $hidden
317
-		. (isset($md5) ? $md5 : '');
318
-
319
-	// preciser que le formulaire doit passer dans un pipeline
320
-	$contexte['_pipeline'] = array('editer_contenu_objet', array('type' => $type, 'id' => $id));
321
-
322
-	// preciser que le formulaire doit etre securise auteur/action
323
-	// n'est plus utile lorsque l'action accepte l'id en argument direct
324
-	// on le garde pour compat
325
-	$contexte['_action'] = array("editer_$type", $id);
326
-
327
-	// et in fine placer l'autorisation
328
-	if (intval($id)){
329
-		if (!autoriser('modifier', $type, intval($id))){
330
-			$valeurs['editable'] = '';
331
-		}
332
-	}
333
-	else {
334
-		if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) {
335
-			$valeurs['editable'] = '';
336
-		}
337
-	}
338
-
339
-	return $contexte;
211
+    $table_objet = table_objet($type);
212
+    $table_objet_sql = table_objet_sql($type);
213
+    $id_table_objet = id_table_objet($type);
214
+
215
+    // on accepte pas une fonction de config inconnue si elle vient d'un modele
216
+    if ($config_fonc
217
+      and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config'])
218
+      and $config_fonc !== $table_objet . '_edit_config') {
219
+        if ($args = test_formulaire_inclus_par_modele()
220
+          and in_array($config_fonc, $args)) {
221
+            $config_fonc = '';
222
+        }
223
+    }
224
+
225
+    $new = !is_numeric($id);
226
+    $lang_default = '';
227
+    // Appel direct dans un squelette
228
+    if (!$row) {
229
+        if (!$new or $lier_trad) {
230
+            if ($select = charger_fonction('precharger_' . $type, 'inc', true)) {
231
+                $row = $select($id, $id_parent, $lier_trad);
232
+                // si on a une fonction precharger, elle pu faire un reglage de langue
233
+                $lang_default = (!empty($row['lang']) ? $row['lang'] : null);
234
+            } else {
235
+                $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id));
236
+            }
237
+            if (!$new) {
238
+                $md5 = controles_md5($row);
239
+            }
240
+        }
241
+        if (!$row) {
242
+            $row = array();
243
+            $trouver_table = charger_fonction('trouver_table', 'base');
244
+            if ($desc = $trouver_table($table_objet)) {
245
+                foreach ($desc['field'] as $k => $v) {
246
+                    $row[$k] = '';
247
+                }
248
+            }
249
+        }
250
+    }
251
+
252
+    // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine
253
+    // (et donc: pas de lien de traduction)
254
+    $id = ($new or $lier_trad)
255
+        ? 'oui'
256
+        : $row[$id_table_objet];
257
+    $row[$id_table_objet] = $id;
258
+
259
+    $contexte = $row;
260
+    if (strlen($id_parent) && is_numeric($id_parent) && (!isset($contexte['id_parent']) or $new)) {
261
+        if (!isset($contexte['id_parent'])) {
262
+            unset($contexte['id_rubrique']);
263
+        }
264
+        $contexte['id_parent'] = $id_parent;
265
+    } elseif (!isset($contexte['id_parent'])) {
266
+        // id_rubrique dans id_parent si possible
267
+        if (isset($contexte['id_rubrique'])) {
268
+            $contexte['id_parent'] = $contexte['id_rubrique'];
269
+            unset($contexte['id_rubrique']);
270
+        } else {
271
+            $contexte['id_parent'] = '';
272
+        }
273
+        if (!$contexte['id_parent']
274
+            and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true)
275
+        ) {
276
+            $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row);
277
+        }
278
+    }
279
+
280
+    $config = array();
281
+    if ($config_fonc) {
282
+        $contexte['config'] = $config = $config_fonc($contexte);
283
+        if (!$lang_default) {
284
+            $lang_default = $config['langue'];
285
+        }
286
+    }
287
+    $config = $config + array(
288
+        'lignes' => 0,
289
+        'langue' => '',
290
+    );
291
+
292
+    $att_text = " class='textarea' "
293
+        . " rows='"
294
+        . ($config['lignes'] + 15)
295
+        . "' cols='40'";
296
+    if (isset($contexte['texte'])) {
297
+        list($contexte['texte'], $contexte['_texte_trop_long']) = editer_texte_recolle($contexte['texte'], $att_text);
298
+    }
299
+
300
+    // on veut conserver la langue de l'interface ;
301
+    // on passe cette donnee sous un autre nom, au cas ou le squelette
302
+    // voudrait l'exploiter
303
+    if (isset($contexte['lang'])) {
304
+        $contexte['langue'] = $contexte['lang'];
305
+        unset($contexte['lang']);
306
+    }
307
+
308
+    $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" .
309
+        (!$lier_trad ? '' :
310
+            ("\n<input type='hidden' name='lier_trad' value='" .
311
+                $lier_trad .
312
+                "' />" .
313
+                "\n<input type='hidden' name='changer_lang' value='" .
314
+                $lang_default .
315
+                "' />"))
316
+        . $hidden
317
+        . (isset($md5) ? $md5 : '');
318
+
319
+    // preciser que le formulaire doit passer dans un pipeline
320
+    $contexte['_pipeline'] = array('editer_contenu_objet', array('type' => $type, 'id' => $id));
321
+
322
+    // preciser que le formulaire doit etre securise auteur/action
323
+    // n'est plus utile lorsque l'action accepte l'id en argument direct
324
+    // on le garde pour compat
325
+    $contexte['_action'] = array("editer_$type", $id);
326
+
327
+    // et in fine placer l'autorisation
328
+    if (intval($id)){
329
+        if (!autoriser('modifier', $type, intval($id))){
330
+            $valeurs['editable'] = '';
331
+        }
332
+    }
333
+    else {
334
+        if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) {
335
+            $valeurs['editable'] = '';
336
+        }
337
+    }
338
+
339
+    return $contexte;
340 340
 }
341 341
 
342 342
 /**
@@ -347,29 +347,29 @@  discard block
 block discarded – undo
347 347
  * @return array
348 348
  */
349 349
 function coupe_trop_long($texte) {
350
-	$aider = charger_fonction('aider', 'inc');
351
-	if (strlen($texte) > 28 * 1024) {
352
-		$texte = str_replace("\r\n", "\n", $texte);
353
-		$pos = strpos($texte, "\n\n", 28 * 1024);  // coupe para > 28 ko
354
-		if ($pos > 0 and $pos < 32 * 1024) {
355
-			$debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n";
356
-			$suite = substr($texte, $pos + 2);
357
-		} else {
358
-			$pos = strpos($texte, ' ', 28 * 1024);  // sinon coupe espace
359
-			if (!($pos > 0 and $pos < 32 * 1024)) {
360
-				$pos = 28 * 1024;  // au pire (pas d'espace trouv'e)
361
-				$decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere
362
-			} else {
363
-				$decalage = 1;
364
-			}
365
-			$debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un
366
-			$suite = substr($texte, $pos + $decalage);
367
-		}
368
-
369
-		return (array($debut, $suite));
370
-	} else {
371
-		return (array($texte, ''));
372
-	}
350
+    $aider = charger_fonction('aider', 'inc');
351
+    if (strlen($texte) > 28 * 1024) {
352
+        $texte = str_replace("\r\n", "\n", $texte);
353
+        $pos = strpos($texte, "\n\n", 28 * 1024);  // coupe para > 28 ko
354
+        if ($pos > 0 and $pos < 32 * 1024) {
355
+            $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n";
356
+            $suite = substr($texte, $pos + 2);
357
+        } else {
358
+            $pos = strpos($texte, ' ', 28 * 1024);  // sinon coupe espace
359
+            if (!($pos > 0 and $pos < 32 * 1024)) {
360
+                $pos = 28 * 1024;  // au pire (pas d'espace trouv'e)
361
+                $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere
362
+            } else {
363
+                $decalage = 1;
364
+            }
365
+            $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un
366
+            $suite = substr($texte, $pos + $decalage);
367
+        }
368
+
369
+        return (array($debut, $suite));
370
+    } else {
371
+        return (array($texte, ''));
372
+    }
373 373
 }
374 374
 
375 375
 /**
@@ -380,24 +380,24 @@  discard block
 block discarded – undo
380 380
  * @return array
381 381
  */
382 382
 function editer_texte_recolle($texte, $att_text) {
383
-	if ((strlen($texte) < 29 * 1024)
384
-		or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE'))
385
-	) {
386
-		return array($texte, '');
387
-	}
388
-
389
-	include_spip('inc/barre');
390
-	$textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n";
391
-	$nombre = 0;
392
-
393
-	while (strlen($texte) > 29 * 1024) {
394
-		$nombre++;
395
-		list($texte1, $texte) = coupe_trop_long($texte);
396
-		$textes_supplement .= '<br />' .
397
-			"<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n";
398
-	}
399
-
400
-	return array($texte, $textes_supplement);
383
+    if ((strlen($texte) < 29 * 1024)
384
+        or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE'))
385
+    ) {
386
+        return array($texte, '');
387
+    }
388
+
389
+    include_spip('inc/barre');
390
+    $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n";
391
+    $nombre = 0;
392
+
393
+    while (strlen($texte) > 29 * 1024) {
394
+        $nombre++;
395
+        list($texte1, $texte) = coupe_trop_long($texte);
396
+        $textes_supplement .= '<br />' .
397
+            "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n";
398
+    }
399
+
400
+    return array($texte, $textes_supplement);
401 401
 }
402 402
 
403 403
 /**
@@ -408,17 +408,17 @@  discard block
 block discarded – undo
408 408
  * @param int $longueur
409 409
  */
410 410
 function titre_automatique($champ_titre, $champs_contenu, $longueur = null) {
411
-	if (!_request($champ_titre)) {
412
-		$titrer_contenu = charger_fonction('titrer_contenu', 'inc');
413
-		if (!is_null($longueur)) {
414
-			$t = $titrer_contenu($champs_contenu, null, $longueur);
415
-		} else {
416
-			$t = $titrer_contenu($champs_contenu);
417
-		}
418
-		if ($t) {
419
-			set_request($champ_titre, $t);
420
-		}
421
-	}
411
+    if (!_request($champ_titre)) {
412
+        $titrer_contenu = charger_fonction('titrer_contenu', 'inc');
413
+        if (!is_null($longueur)) {
414
+            $t = $titrer_contenu($champs_contenu, null, $longueur);
415
+        } else {
416
+            $t = $titrer_contenu($champs_contenu);
417
+        }
418
+        if ($t) {
419
+            set_request($champ_titre, $t);
420
+        }
421
+    }
422 422
 }
423 423
 
424 424
 /**
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
  * @return string
439 439
  */
440 440
 function inc_titrer_contenu_dist($champs_contenu, $c = null, $longueur = 50) {
441
-	// trouver un champ texte non vide
442
-	$t = '';
443
-	foreach ($champs_contenu as $champ) {
444
-		if ($t = _request($champ, $c)) {
445
-			break;
446
-		}
447
-	}
448
-
449
-	if ($t) {
450
-		include_spip('inc/texte_mini');
451
-		$t = couper($t, $longueur, '...');
452
-	}
453
-
454
-	return $t;
441
+    // trouver un champ texte non vide
442
+    $t = '';
443
+    foreach ($champs_contenu as $champ) {
444
+        if ($t = _request($champ, $c)) {
445
+            break;
446
+        }
447
+    }
448
+
449
+    if ($t) {
450
+        include_spip('inc/texte_mini');
451
+        $t = couper($t, $longueur, '...');
452
+    }
453
+
454
+    return $t;
455 455
 }
456 456
 
457 457
 /**
@@ -474,30 +474,30 @@  discard block
 block discarded – undo
474 474
  *      - array sinon couples ('$prefixe$colonne => md5)
475 475
  **/
476 476
 function controles_md5($data, $prefixe = 'ctr_', $format = 'html') {
477
-	if (!is_array($data)) {
478
-		return false;
479
-	}
480
-
481
-	$ctr = array();
482
-	foreach ($data as $key => $val) {
483
-		$m = md5($val);
484
-		$k = $prefixe . $key;
485
-
486
-		switch ($format) {
487
-			case 'html':
488
-				$ctr[$k] = "<input type='hidden' value='$m' name='$k' />";
489
-				break;
490
-			default:
491
-				$ctr[$k] = $m;
492
-				break;
493
-		}
494
-	}
495
-
496
-	if ($format == 'html') {
497
-		return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n";
498
-	} else {
499
-		return $ctr;
500
-	}
477
+    if (!is_array($data)) {
478
+        return false;
479
+    }
480
+
481
+    $ctr = array();
482
+    foreach ($data as $key => $val) {
483
+        $m = md5($val);
484
+        $k = $prefixe . $key;
485
+
486
+        switch ($format) {
487
+            case 'html':
488
+                $ctr[$k] = "<input type='hidden' value='$m' name='$k' />";
489
+                break;
490
+            default:
491
+                $ctr[$k] = $m;
492
+                break;
493
+        }
494
+    }
495
+
496
+    if ($format == 'html') {
497
+        return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n";
498
+    } else {
499
+        return $ctr;
500
+    }
501 501
 }
502 502
 
503 503
 /**
@@ -536,79 +536,79 @@  discard block
 block discarded – undo
536 536
  *     - post : le contenu posté
537 537
  **/
538 538
 function controler_contenu($type, $id, $options = array(), $c = false, $serveur = '') {
539
-	include_spip('inc/filtres');
540
-
541
-	$table_objet = table_objet($type);
542
-	$spip_table_objet = table_objet_sql($type);
543
-	$trouver_table = charger_fonction('trouver_table', 'base');
544
-	$desc = $trouver_table($table_objet, $serveur);
545
-
546
-	// Appels incomplets (sans $c)
547
-	if (!is_array($c)) {
548
-		foreach ($desc['field'] as $champ => $ignore) {
549
-			if (_request($champ)) {
550
-				$c[$champ] = _request($champ);
551
-			}
552
-		}
553
-	}
554
-
555
-	// Securite : certaines variables ne sont jamais acceptees ici
556
-	// car elles ne relevent pas de autoriser(article, modifier) ;
557
-	// il faut passer par instituer_XX()
558
-	// TODO: faut-il passer ces variables interdites
559
-	// dans un fichier de description separe ?
560
-	unset($c['statut']);
561
-	unset($c['id_parent']);
562
-	unset($c['id_rubrique']);
563
-	unset($c['id_secteur']);
564
-
565
-	// Gerer les champs non vides
566
-	if (isset($options['nonvide']) and is_array($options['nonvide'])) {
567
-		foreach ($options['nonvide'] as $champ => $sinon) {
568
-			if ($c[$champ] === '') {
569
-				$c[$champ] = $sinon;
570
-			}
571
-		}
572
-	}
573
-
574
-	// N'accepter que les champs qui existent
575
-	// [TODO] ici aussi on peut valider les contenus en fonction du type
576
-	$champs = array();
577
-	foreach ($desc['field'] as $champ => $ignore) {
578
-		if (isset($c[$champ])) {
579
-			$champs[$champ] = $c[$champ];
580
-		}
581
-	}
582
-
583
-	// Nettoyer les valeurs
584
-	$champs = array_map('corriger_caracteres', $champs);
585
-
586
-	// Envoyer aux plugins
587
-	$champs = pipeline(
588
-		'pre_edition',
589
-		array(
590
-			'args' => array(
591
-				'table' => $spip_table_objet, // compatibilite
592
-				'table_objet' => $table_objet,
593
-				'spip_table_objet' => $spip_table_objet,
594
-				'type' => $type,
595
-				'id_objet' => $id,
596
-				'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ?
597
-				'action' => 'controler',
598
-				'serveur' => $serveur,
599
-			),
600
-			'data' => $champs
601
-		)
602
-	);
603
-
604
-	if (!$champs) {
605
-		return false;
606
-	}
607
-
608
-	// Verifier si les mises a jour sont pertinentes, datees, en conflit etc
609
-	$conflits = controler_md5($champs, $_POST, $type, $id, $serveur, isset($options['prefix']) ? $options['prefix'] : 'ctr_');
610
-
611
-	return $conflits;
539
+    include_spip('inc/filtres');
540
+
541
+    $table_objet = table_objet($type);
542
+    $spip_table_objet = table_objet_sql($type);
543
+    $trouver_table = charger_fonction('trouver_table', 'base');
544
+    $desc = $trouver_table($table_objet, $serveur);
545
+
546
+    // Appels incomplets (sans $c)
547
+    if (!is_array($c)) {
548
+        foreach ($desc['field'] as $champ => $ignore) {
549
+            if (_request($champ)) {
550
+                $c[$champ] = _request($champ);
551
+            }
552
+        }
553
+    }
554
+
555
+    // Securite : certaines variables ne sont jamais acceptees ici
556
+    // car elles ne relevent pas de autoriser(article, modifier) ;
557
+    // il faut passer par instituer_XX()
558
+    // TODO: faut-il passer ces variables interdites
559
+    // dans un fichier de description separe ?
560
+    unset($c['statut']);
561
+    unset($c['id_parent']);
562
+    unset($c['id_rubrique']);
563
+    unset($c['id_secteur']);
564
+
565
+    // Gerer les champs non vides
566
+    if (isset($options['nonvide']) and is_array($options['nonvide'])) {
567
+        foreach ($options['nonvide'] as $champ => $sinon) {
568
+            if ($c[$champ] === '') {
569
+                $c[$champ] = $sinon;
570
+            }
571
+        }
572
+    }
573
+
574
+    // N'accepter que les champs qui existent
575
+    // [TODO] ici aussi on peut valider les contenus en fonction du type
576
+    $champs = array();
577
+    foreach ($desc['field'] as $champ => $ignore) {
578
+        if (isset($c[$champ])) {
579
+            $champs[$champ] = $c[$champ];
580
+        }
581
+    }
582
+
583
+    // Nettoyer les valeurs
584
+    $champs = array_map('corriger_caracteres', $champs);
585
+
586
+    // Envoyer aux plugins
587
+    $champs = pipeline(
588
+        'pre_edition',
589
+        array(
590
+            'args' => array(
591
+                'table' => $spip_table_objet, // compatibilite
592
+                'table_objet' => $table_objet,
593
+                'spip_table_objet' => $spip_table_objet,
594
+                'type' => $type,
595
+                'id_objet' => $id,
596
+                'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ?
597
+                'action' => 'controler',
598
+                'serveur' => $serveur,
599
+            ),
600
+            'data' => $champs
601
+        )
602
+    );
603
+
604
+    if (!$champs) {
605
+        return false;
606
+    }
607
+
608
+    // Verifier si les mises a jour sont pertinentes, datees, en conflit etc
609
+    $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, isset($options['prefix']) ? $options['prefix'] : 'ctr_');
610
+
611
+    return $conflits;
612 612
 }
613 613
 
614 614
 
@@ -638,63 +638,63 @@  discard block
 block discarded – undo
638 638
  *     - post : le contenu posté
639 639
  **/
640 640
 function controler_md5(&$champs, $ctr, $type, $id, $serveur, $prefix = 'ctr_') {
641
-	$spip_table_objet = table_objet_sql($type);
642
-	$id_table_objet = id_table_objet($type);
643
-
644
-	// Controle des MD5 envoyes
645
-	// On elimine les donnees non modifiees par le formulaire (mais
646
-	// potentiellement modifiees entre temps par un autre utilisateur)
647
-	foreach ($champs as $key => $val) {
648
-		if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) {
649
-			if (is_scalar($val) and $m == md5($val)) {
650
-				unset($champs[$key]);
651
-			}
652
-		}
653
-	}
654
-	if (!$champs) {
655
-		return;
656
-	}
657
-
658
-	// On veut savoir si notre modif va avoir un impact
659
-	// par rapport aux donnees contenues dans la base
660
-	// (qui peuvent etre differentes de celles ayant servi a calculer le ctr)
661
-	$s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur);
662
-	$intact = true;
663
-	foreach ($champs as $ch => $val) {
664
-		$intact &= ($s[$ch] == $val);
665
-	}
666
-	if ($intact) {
667
-		return;
668
-	}
669
-
670
-	// Detection de conflits :
671
-	// On verifie si notre modif ne provient pas d'un formulaire
672
-	// genere a partir de donnees modifiees dans l'intervalle ; ici
673
-	// on compare a ce qui est dans la base, et on bloque en cas
674
-	// de conflit.
675
-	$ctrh = $ctrq = $conflits = array();
676
-	foreach (array_keys($champs) as $key) {
677
-		if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) {
678
-			$ctrh[$key] = $m;
679
-			$ctrq[] = $key;
680
-		}
681
-	}
682
-	if ($ctrq) {
683
-		$ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur);
684
-		foreach ($ctrh as $key => $m) {
685
-			if ($m != md5($ctrq[$key])
686
-				and $champs[$key] !== $ctrq[$key]
687
-			) {
688
-				$conflits[$key] = array(
689
-					'base' => $ctrq[$key],
690
-					'post' => $champs[$key]
691
-				);
692
-				unset($champs[$key]); # stocker quand meme les modifs ?
693
-			}
694
-		}
695
-	}
696
-
697
-	return $conflits;
641
+    $spip_table_objet = table_objet_sql($type);
642
+    $id_table_objet = id_table_objet($type);
643
+
644
+    // Controle des MD5 envoyes
645
+    // On elimine les donnees non modifiees par le formulaire (mais
646
+    // potentiellement modifiees entre temps par un autre utilisateur)
647
+    foreach ($champs as $key => $val) {
648
+        if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) {
649
+            if (is_scalar($val) and $m == md5($val)) {
650
+                unset($champs[$key]);
651
+            }
652
+        }
653
+    }
654
+    if (!$champs) {
655
+        return;
656
+    }
657
+
658
+    // On veut savoir si notre modif va avoir un impact
659
+    // par rapport aux donnees contenues dans la base
660
+    // (qui peuvent etre differentes de celles ayant servi a calculer le ctr)
661
+    $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur);
662
+    $intact = true;
663
+    foreach ($champs as $ch => $val) {
664
+        $intact &= ($s[$ch] == $val);
665
+    }
666
+    if ($intact) {
667
+        return;
668
+    }
669
+
670
+    // Detection de conflits :
671
+    // On verifie si notre modif ne provient pas d'un formulaire
672
+    // genere a partir de donnees modifiees dans l'intervalle ; ici
673
+    // on compare a ce qui est dans la base, et on bloque en cas
674
+    // de conflit.
675
+    $ctrh = $ctrq = $conflits = array();
676
+    foreach (array_keys($champs) as $key) {
677
+        if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) {
678
+            $ctrh[$key] = $m;
679
+            $ctrq[] = $key;
680
+        }
681
+    }
682
+    if ($ctrq) {
683
+        $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur);
684
+        foreach ($ctrh as $key => $m) {
685
+            if ($m != md5($ctrq[$key])
686
+                and $champs[$key] !== $ctrq[$key]
687
+            ) {
688
+                $conflits[$key] = array(
689
+                    'base' => $ctrq[$key],
690
+                    'post' => $champs[$key]
691
+                );
692
+                unset($champs[$key]); # stocker quand meme les modifs ?
693
+            }
694
+        }
695
+    }
696
+
697
+    return $conflits;
698 698
 }
699 699
 
700 700
 /**
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
  * @return string
707 707
  */
708 708
 function display_conflit_champ($x) {
709
-	if (strstr($x, "\n") or strlen($x) > 80) {
710
-		return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n";
711
-	} else {
712
-		return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n";
713
-	}
709
+    if (strstr($x, "\n") or strlen($x) > 80) {
710
+        return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n";
711
+    } else {
712
+        return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n";
713
+    }
714 714
 }
715 715
 
716 716
 /**
@@ -728,57 +728,57 @@  discard block
 block discarded – undo
728 728
  * @return string
729 729
  */
730 730
 function signaler_conflits_edition($conflits, $redirect = '') {
731
-	include_spip('inc/minipres');
732
-	include_spip('inc/revisions');
733
-	include_spip('afficher_diff/champ');
734
-	include_spip('inc/suivi_versions');
735
-	include_spip('inc/diff');
736
-	$diffs = array();
737
-	foreach ($conflits as $champ => $a) {
738
-		// probleme de stockage ou conflit d'edition ?
739
-		$base = isset($a['save']) ? $a['save'] : $a['base'];
740
-
741
-		$diff = new Diff(new DiffTexte);
742
-		$n = preparer_diff($a['post']);
743
-		$o = preparer_diff($base);
744
-		$d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o))));
745
-
746
-		$titre = isset($a['save']) ? _L(
747
-			'Echec lors de l\'enregistrement du champ @champ@',
748
-			array('champ' => $champ)
749
-		) : $champ;
750
-
751
-		$diffs[] = "<h2>$titre</h2>\n"
752
-			. '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n"
753
-			. "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n"
754
-			. '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>'
755
-			. display_conflit_champ($a['post'])
756
-			. '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>'
757
-			. display_conflit_champ($base);
758
-	}
759
-
760
-	if ($redirect) {
761
-		$id = uniqid(rand());
762
-		$redirect = "<form action='$redirect' method='get'
731
+    include_spip('inc/minipres');
732
+    include_spip('inc/revisions');
733
+    include_spip('afficher_diff/champ');
734
+    include_spip('inc/suivi_versions');
735
+    include_spip('inc/diff');
736
+    $diffs = array();
737
+    foreach ($conflits as $champ => $a) {
738
+        // probleme de stockage ou conflit d'edition ?
739
+        $base = isset($a['save']) ? $a['save'] : $a['base'];
740
+
741
+        $diff = new Diff(new DiffTexte);
742
+        $n = preparer_diff($a['post']);
743
+        $o = preparer_diff($base);
744
+        $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o))));
745
+
746
+        $titre = isset($a['save']) ? _L(
747
+            'Echec lors de l\'enregistrement du champ @champ@',
748
+            array('champ' => $champ)
749
+        ) : $champ;
750
+
751
+        $diffs[] = "<h2>$titre</h2>\n"
752
+            . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n"
753
+            . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n"
754
+            . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>'
755
+            . display_conflit_champ($a['post'])
756
+            . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>'
757
+            . display_conflit_champ($base);
758
+    }
759
+
760
+    if ($redirect) {
761
+        $id = uniqid(rand());
762
+        $redirect = "<form action='$redirect' method='get'
763 763
 			id='$id'
764 764
 			style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n"
765
-			. form_hidden($redirect)
766
-			. "<input type='submit' value='" . _T('icone_retour') . "' />
765
+            . form_hidden($redirect)
766
+            . "<input type='submit' value='" . _T('icone_retour') . "' />
767 767
 		</form>\n";
768 768
 
769
-		// pour les documents, on est probablement en ajax : il faut ajaxer
770
-		if (_AJAX) {
771
-			$redirect .= '<script type="text/javascript">'
772
-				. 'setTimeout(function(){$("#' . $id . '")
769
+        // pour les documents, on est probablement en ajax : il faut ajaxer
770
+        if (_AJAX) {
771
+            $redirect .= '<script type="text/javascript">'
772
+                . 'setTimeout(function(){$("#' . $id . '")
773 773
 			.ajaxForm({target:$("#' . $id . '").parent()});
774 774
 			}, 200);'
775
-				. "</script>\n";
776
-		}
777
-	}
775
+                . "</script>\n";
776
+        }
777
+    }
778 778
 
779
-	echo minipres(
780
-		_T('titre_conflit_edition'),
781
-		'<style>
779
+    echo minipres(
780
+        _T('titre_conflit_edition'),
781
+        '<style>
782 782
 .diff-para-deplace { background: #e8e8ff; }
783 783
 .diff-para-ajoute { background: #d0ffc0; color: #000; }
784 784
 .diff-para-supprime { background: #ffd0c0; color: #904040; text-decoration: line-through; }
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
 .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; }
790 790
 .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; }
791 791
 </style>'
792
-		. '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>'
793
-		. '<p>' . _T('texte_conflit_edition_correction') . '</p>'
794
-		. "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>"
795
-		. join("\n", $diffs)
796
-		. "</div>\n"
797
-
798
-		. $redirect
799
-	);
792
+        . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>'
793
+        . '<p>' . _T('texte_conflit_edition_correction') . '</p>'
794
+        . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>"
795
+        . join("\n", $diffs)
796
+        . "</div>\n"
797
+
798
+        . $redirect
799
+    );
800 800
 }
Please login to merge, or discard this patch.
prive/formulaires/editer_rubrique.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/actions');
@@ -47,30 +47,30 @@  discard block
 block discarded – undo
47 47
  *     Environnement du formulaire
48 48
  **/
49 49
 function formulaires_editer_rubrique_charger_dist(
50
-	$id_rubrique = 'new',
51
-	$id_parent = 0,
52
-	$retour = '',
53
-	$lier_trad = 0,
54
-	$config_fonc = 'rubriques_edit_config',
55
-	$row = array(),
56
-	$hidden = ''
50
+    $id_rubrique = 'new',
51
+    $id_parent = 0,
52
+    $retour = '',
53
+    $lier_trad = 0,
54
+    $config_fonc = 'rubriques_edit_config',
55
+    $row = array(),
56
+    $hidden = ''
57 57
 ) {
58
-	$valeurs = formulaires_editer_objet_charger(
59
-		'rubrique',
60
-		$id_rubrique,
61
-		$id_parent,
62
-		$lier_trad,
63
-		$retour,
64
-		$config_fonc,
65
-		$row,
66
-		$hidden
67
-	);
68
-
69
-	if (intval($id_rubrique) and !autoriser('modifier', 'rubrique', intval($id_rubrique))) {
70
-		$valeurs['editable'] = '';
71
-	}
72
-
73
-	return $valeurs;
58
+    $valeurs = formulaires_editer_objet_charger(
59
+        'rubrique',
60
+        $id_rubrique,
61
+        $id_parent,
62
+        $lier_trad,
63
+        $retour,
64
+        $config_fonc,
65
+        $row,
66
+        $hidden
67
+    );
68
+
69
+    if (intval($id_rubrique) and !autoriser('modifier', 'rubrique', intval($id_rubrique))) {
70
+        $valeurs['editable'] = '';
71
+    }
72
+
73
+    return $valeurs;
74 74
 }
75 75
 
76 76
 /**
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
  *     Configuration pour le formulaire
83 83
  */
84 84
 function rubriques_edit_config($row) {
85
-	global $spip_lang;
85
+    global $spip_lang;
86 86
 
87
-	$config = $GLOBALS['meta'];
88
-	$config['lignes'] = 8;
89
-	$config['langue'] = $spip_lang;
87
+    $config = $GLOBALS['meta'];
88
+    $config['lignes'] = 8;
89
+    $config['langue'] = $spip_lang;
90 90
 
91
-	$config['restreint'] = (!$GLOBALS['connect_toutes_rubriques']);
91
+    $config['restreint'] = (!$GLOBALS['connect_toutes_rubriques']);
92 92
 
93
-	return $config;
93
+    return $config;
94 94
 }
95 95
 
96 96
 /**
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
  *     Hash du formulaire
116 116
  */
117 117
 function formulaires_editer_rubrique_identifier_dist(
118
-	$id_rubrique = 'new',
119
-	$id_parent = 0,
120
-	$retour = '',
121
-	$lier_trad = 0,
122
-	$config_fonc = 'rubriques_edit_config',
123
-	$row = array(),
124
-	$hidden = ''
118
+    $id_rubrique = 'new',
119
+    $id_parent = 0,
120
+    $retour = '',
121
+    $lier_trad = 0,
122
+    $config_fonc = 'rubriques_edit_config',
123
+    $row = array(),
124
+    $hidden = ''
125 125
 ) {
126
-	return serialize(array(intval($id_rubrique), $lier_trad));
126
+    return serialize(array(intval($id_rubrique), $lier_trad));
127 127
 }
128 128
 
129 129
 /**
@@ -149,32 +149,32 @@  discard block
 block discarded – undo
149 149
  *     Erreurs du formulaire
150 150
  **/
151 151
 function formulaires_editer_rubrique_verifier_dist(
152
-	$id_rubrique = 'new',
153
-	$id_parent = 0,
154
-	$retour = '',
155
-	$lier_trad = 0,
156
-	$config_fonc = 'rubriques_edit_config',
157
-	$row = array(),
158
-	$hidden = ''
152
+    $id_rubrique = 'new',
153
+    $id_parent = 0,
154
+    $retour = '',
155
+    $lier_trad = 0,
156
+    $config_fonc = 'rubriques_edit_config',
157
+    $row = array(),
158
+    $hidden = ''
159 159
 ) {
160
-	// auto-renseigner le titre si il n'existe pas
161
-	titre_automatique('titre', array('descriptif', 'texte'));
162
-	// on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_rubrique si vide
163
-	$erreurs = formulaires_editer_objet_verifier('rubrique', $id_rubrique, array());
164
-
165
-	// s'assurer qu'on ne s'auto-designe pas comme parent !
166
-	if (intval($id_rubrique)
167
-	  and empty($erreurs['id_parent'])
168
-		and $id_parent = _request('id_parent')) {
169
-		include_spip('inc/rubriques');
170
-		$branche = calcul_branche_in($id_rubrique);
171
-		$branche = explode(',', $branche);
172
-		if (in_array($id_parent, $branche)) {
173
-			$erreurs['id_parent'] = _L("Impossible de déplacer une rubrique dans sa propre branche, on tourne en rond !");
174
-		}
175
-	}
176
-
177
-	return $erreurs;
160
+    // auto-renseigner le titre si il n'existe pas
161
+    titre_automatique('titre', array('descriptif', 'texte'));
162
+    // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_rubrique si vide
163
+    $erreurs = formulaires_editer_objet_verifier('rubrique', $id_rubrique, array());
164
+
165
+    // s'assurer qu'on ne s'auto-designe pas comme parent !
166
+    if (intval($id_rubrique)
167
+      and empty($erreurs['id_parent'])
168
+        and $id_parent = _request('id_parent')) {
169
+        include_spip('inc/rubriques');
170
+        $branche = calcul_branche_in($id_rubrique);
171
+        $branche = explode(',', $branche);
172
+        if (in_array($id_parent, $branche)) {
173
+            $erreurs['id_parent'] = _L("Impossible de déplacer une rubrique dans sa propre branche, on tourne en rond !");
174
+        }
175
+    }
176
+
177
+    return $erreurs;
178 178
 }
179 179
 
180 180
 /**
@@ -200,22 +200,22 @@  discard block
 block discarded – undo
200 200
  *     Retour des traitements
201 201
  **/
202 202
 function formulaires_editer_rubrique_traiter_dist(
203
-	$id_rubrique = 'new',
204
-	$id_parent = 0,
205
-	$retour = '',
206
-	$lier_trad = 0,
207
-	$config_fonc = 'rubriques_edit_config',
208
-	$row = array(),
209
-	$hidden = ''
203
+    $id_rubrique = 'new',
204
+    $id_parent = 0,
205
+    $retour = '',
206
+    $lier_trad = 0,
207
+    $config_fonc = 'rubriques_edit_config',
208
+    $row = array(),
209
+    $hidden = ''
210 210
 ) {
211
-	return formulaires_editer_objet_traiter(
212
-		'rubrique',
213
-		$id_rubrique,
214
-		$id_parent,
215
-		$lier_trad,
216
-		$retour,
217
-		$config_fonc,
218
-		$row,
219
-		$hidden
220
-	);
211
+    return formulaires_editer_objet_traiter(
212
+        'rubrique',
213
+        $id_rubrique,
214
+        $id_parent,
215
+        $lier_trad,
216
+        $retour,
217
+        $config_fonc,
218
+        $row,
219
+        $hidden
220
+    );
221 221
 }
Please login to merge, or discard this patch.