Completed
Push — master ( 350a8b...37aa61 )
by cam
01:39
created
ecrire/exec/info_plugin.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 if (!defined('_ECRIRE_INC_VERSION')) {
10
-	return;
10
+    return;
11 11
 }
12 12
 
13 13
 include_spip('inc/actions');
@@ -21,23 +21,23 @@  discard block
 block discarded – undo
21 21
  * @uses ajax_retour()
22 22
  */
23 23
 function exec_info_plugin_dist() {
24
-	if (!autoriser('configurer', '_plugins')) {
25
-		include_spip('inc/minipres');
26
-		echo minipres();
27
-	} else {
28
-		$plug = _DIR_RACINE . htmlspecialchars((string) _request('plugin'));
29
-		$get_infos = charger_fonction('get_infos', 'plugins');
30
-		$dir = '';
31
-		if (str_starts_with($plug, (string) _DIR_PLUGINS)) {
32
-			$dir = _DIR_PLUGINS;
33
-		} elseif (str_starts_with($plug, (string) _DIR_PLUGINS_DIST)) {
34
-			$dir = _DIR_PLUGINS_DIST;
35
-		}
36
-		if ($dir) {
37
-			$plug = substr($plug, strlen((string) $dir));
38
-		}
39
-		$info = $get_infos($plug, false, $dir);
40
-		$afficher_plugin = charger_fonction('afficher_plugin', 'plugins');
41
-		ajax_retour(affiche_bloc_plugin($plug, $info, $dir));
42
-	}
24
+    if (!autoriser('configurer', '_plugins')) {
25
+        include_spip('inc/minipres');
26
+        echo minipres();
27
+    } else {
28
+        $plug = _DIR_RACINE . htmlspecialchars((string) _request('plugin'));
29
+        $get_infos = charger_fonction('get_infos', 'plugins');
30
+        $dir = '';
31
+        if (str_starts_with($plug, (string) _DIR_PLUGINS)) {
32
+            $dir = _DIR_PLUGINS;
33
+        } elseif (str_starts_with($plug, (string) _DIR_PLUGINS_DIST)) {
34
+            $dir = _DIR_PLUGINS_DIST;
35
+        }
36
+        if ($dir) {
37
+            $plug = substr($plug, strlen((string) $dir));
38
+        }
39
+        $info = $get_infos($plug, false, $dir);
40
+        $afficher_plugin = charger_fonction('afficher_plugin', 'plugins');
41
+        ajax_retour(affiche_bloc_plugin($plug, $info, $dir));
42
+    }
43 43
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 		include_spip('inc/minipres');
26 26
 		echo minipres();
27 27
 	} else {
28
-		$plug = _DIR_RACINE . htmlspecialchars((string) _request('plugin'));
28
+		$plug = _DIR_RACINE.htmlspecialchars((string) _request('plugin'));
29 29
 		$get_infos = charger_fonction('get_infos', 'plugins');
30 30
 		$dir = '';
31 31
 		if (str_starts_with($plug, (string) _DIR_PLUGINS)) {
Please login to merge, or discard this patch.
ecrire/exec/rechercher.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 include_spip('inc/actions');
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  * @uses ajax_retour()
32 32
  **/
33 33
 function exec_rechercher_dist() {
34
-	$id = (int) _request('id');
35
-	$exclus = (int) _request('exclus');
36
-	$rac = spip_htmlentities(_request('rac'));
37
-	$type = _request('type');
38
-	$do = _request('do');
39
-	$r = preg_match('/^\w*$/', (string) $do) ? exec_rechercher_args($id, $type, $exclus, $rac, $do) : '';
40
-	ajax_retour($r);
34
+    $id = (int) _request('id');
35
+    $exclus = (int) _request('exclus');
36
+    $rac = spip_htmlentities(_request('rac'));
37
+    $type = _request('type');
38
+    $do = _request('do');
39
+    $r = preg_match('/^\w*$/', (string) $do) ? exec_rechercher_args($id, $type, $exclus, $rac, $do) : '';
40
+    ajax_retour($r);
41 41
 }
42 42
 
43 43
 /**
@@ -54,61 +54,61 @@  discard block
 block discarded – undo
54 54
  * @return string
55 55
  **/
56 56
 function exec_rechercher_args($id, $type, $exclus, $rac, $do) {
57
-	if (!$do) {
58
-		$do = 'aff';
59
-	}
60
-
61
-	$points = $rub = [];
62
-
63
-	$where = preg_split(',\s+,', $type);
64
-	if ($where) {
65
-		foreach ($where as $k => $v) {
66
-			$where[$k] = "'%" . substr(str_replace('%', '\%', sql_quote($v, '', 'string')), 1, -1) . "%'";
67
-		}
68
-		$where_titre = ('(titre LIKE ' . implode(' AND titre LIKE ', $where) . ')');
69
-		$where_desc = ('(descriptif LIKE ' . implode(' AND descriptif LIKE ', $where) . ')');
70
-		$where_id = ('(id_rubrique = ' . (int) $type . ')');
71
-
72
-		if ($exclus) {
73
-			include_spip('inc/rubriques');
74
-			$where_exclus = ' AND ' . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT');
75
-		} else {
76
-			$where_exclus = '';
77
-		}
78
-
79
-		foreach (
80
-			[
81
-				3 => $where_titre,
82
-				2 => $where_desc,
83
-				1 => $where_id,
84
-			] as $point => $recherche
85
-		) {
86
-			$res = sql_select('id_rubrique, id_parent, titre', 'spip_rubriques', "$recherche$where_exclus");
87
-			while ($row = sql_fetch($res)) {
88
-				$id_rubrique = $row['id_rubrique'];
89
-				if (!isset($rub[$id_rubrique])) {
90
-					$rub[$id_rubrique] = [];
91
-				}
92
-				$rub[$id_rubrique]['titre'] = typo($row['titre']);
93
-				$rub[$id_rubrique]['id_parent'] = $row['id_parent'];
94
-				if (!isset($points[$id_rubrique])) {
95
-					$points[$id_rubrique] = 0;
96
-				}
97
-				$points[$id_rubrique] += $point;
98
-			}
99
-		}
100
-	}
101
-
102
-	if ($points) {
103
-		arsort($points);
104
-		$style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'";
105
-		foreach ($rub as $k => $v) {
106
-			$rub[$k]['atts'] = ($v['id_parent'] ? $style : '')
107
-				. " class='petite-rubrique'";
108
-		}
109
-	}
110
-
111
-	return (proposer_item($points, $rub, $rac, $type, $do));
57
+    if (!$do) {
58
+        $do = 'aff';
59
+    }
60
+
61
+    $points = $rub = [];
62
+
63
+    $where = preg_split(',\s+,', $type);
64
+    if ($where) {
65
+        foreach ($where as $k => $v) {
66
+            $where[$k] = "'%" . substr(str_replace('%', '\%', sql_quote($v, '', 'string')), 1, -1) . "%'";
67
+        }
68
+        $where_titre = ('(titre LIKE ' . implode(' AND titre LIKE ', $where) . ')');
69
+        $where_desc = ('(descriptif LIKE ' . implode(' AND descriptif LIKE ', $where) . ')');
70
+        $where_id = ('(id_rubrique = ' . (int) $type . ')');
71
+
72
+        if ($exclus) {
73
+            include_spip('inc/rubriques');
74
+            $where_exclus = ' AND ' . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT');
75
+        } else {
76
+            $where_exclus = '';
77
+        }
78
+
79
+        foreach (
80
+            [
81
+                3 => $where_titre,
82
+                2 => $where_desc,
83
+                1 => $where_id,
84
+            ] as $point => $recherche
85
+        ) {
86
+            $res = sql_select('id_rubrique, id_parent, titre', 'spip_rubriques', "$recherche$where_exclus");
87
+            while ($row = sql_fetch($res)) {
88
+                $id_rubrique = $row['id_rubrique'];
89
+                if (!isset($rub[$id_rubrique])) {
90
+                    $rub[$id_rubrique] = [];
91
+                }
92
+                $rub[$id_rubrique]['titre'] = typo($row['titre']);
93
+                $rub[$id_rubrique]['id_parent'] = $row['id_parent'];
94
+                if (!isset($points[$id_rubrique])) {
95
+                    $points[$id_rubrique] = 0;
96
+                }
97
+                $points[$id_rubrique] += $point;
98
+            }
99
+        }
100
+    }
101
+
102
+    if ($points) {
103
+        arsort($points);
104
+        $style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'";
105
+        foreach ($rub as $k => $v) {
106
+            $rub[$k]['atts'] = ($v['id_parent'] ? $style : '')
107
+                . " class='petite-rubrique'";
108
+        }
109
+    }
110
+
111
+    return (proposer_item($points, $rub, $rac, $type, $do));
112 112
 }
113 113
 
114 114
 
@@ -131,37 +131,37 @@  discard block
 block discarded – undo
131 131
  **/
132 132
 function proposer_item($ids, $titles, $rac, $type, $do) {
133 133
 
134
-	if (!$ids) {
135
-		return "<br /><br /><div style='padding: 5px; color: red;'><b>"
136
-		. spip_htmlentities($type)
137
-		. '</b> :  ' . _T('avis_aucun_resultat') . '</div>';
138
-	}
139
-
140
-	$ret = '';
141
-	$info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id=");
142
-
143
-	$onClick = "aff_selection(this.firstChild.title,'$rac" . "_selection','$info', event)";
144
-
145
-	$ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');";
146
-
147
-	foreach (array_keys($ids) as $id) {
148
-		$titre = strtr(
149
-			str_replace("'", '&#8217;', str_replace('"', '&#34;', (string) textebrut($titles[$id]['titre']))),
150
-			"\n\r",
151
-			'  '
152
-		);
153
-
154
-		$ret .= "<div class='highlight off'\nonclick=\"changerhighlight(this); "
155
-			. $onClick
156
-			. "\"\nondblclick=\""
157
-			. $ondbClick
158
-			. $onClick
159
-			. ' "><div'
160
-			. $titles[$id]['atts']
161
-			. " title='$id'>&nbsp; "
162
-			. $titre
163
-			. '</div></div>';
164
-	}
165
-
166
-	return $ret;
134
+    if (!$ids) {
135
+        return "<br /><br /><div style='padding: 5px; color: red;'><b>"
136
+        . spip_htmlentities($type)
137
+        . '</b> :  ' . _T('avis_aucun_resultat') . '</div>';
138
+    }
139
+
140
+    $ret = '';
141
+    $info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id=");
142
+
143
+    $onClick = "aff_selection(this.firstChild.title,'$rac" . "_selection','$info', event)";
144
+
145
+    $ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');";
146
+
147
+    foreach (array_keys($ids) as $id) {
148
+        $titre = strtr(
149
+            str_replace("'", '&#8217;', str_replace('"', '&#34;', (string) textebrut($titles[$id]['titre']))),
150
+            "\n\r",
151
+            '  '
152
+        );
153
+
154
+        $ret .= "<div class='highlight off'\nonclick=\"changerhighlight(this); "
155
+            . $onClick
156
+            . "\"\nondblclick=\""
157
+            . $ondbClick
158
+            . $onClick
159
+            . ' "><div'
160
+            . $titles[$id]['atts']
161
+            . " title='$id'>&nbsp; "
162
+            . $titre
163
+            . '</div></div>';
164
+    }
165
+
166
+    return $ret;
167 167
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
 	$where = preg_split(',\s+,', $type);
64 64
 	if ($where) {
65 65
 		foreach ($where as $k => $v) {
66
-			$where[$k] = "'%" . substr(str_replace('%', '\%', sql_quote($v, '', 'string')), 1, -1) . "%'";
66
+			$where[$k] = "'%".substr(str_replace('%', '\%', sql_quote($v, '', 'string')), 1, -1)."%'";
67 67
 		}
68
-		$where_titre = ('(titre LIKE ' . implode(' AND titre LIKE ', $where) . ')');
69
-		$where_desc = ('(descriptif LIKE ' . implode(' AND descriptif LIKE ', $where) . ')');
70
-		$where_id = ('(id_rubrique = ' . (int) $type . ')');
68
+		$where_titre = ('(titre LIKE '.implode(' AND titre LIKE ', $where).')');
69
+		$where_desc = ('(descriptif LIKE '.implode(' AND descriptif LIKE ', $where).')');
70
+		$where_id = ('(id_rubrique = '.(int) $type.')');
71 71
 
72 72
 		if ($exclus) {
73 73
 			include_spip('inc/rubriques');
74
-			$where_exclus = ' AND ' . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT');
74
+			$where_exclus = ' AND '.sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT');
75 75
 		} else {
76 76
 			$where_exclus = '';
77 77
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 	if ($points) {
103 103
 		arsort($points);
104
-		$style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'";
104
+		$style = " style='background-image: url(".chemin_image('secteur-12.png').")'";
105 105
 		foreach ($rub as $k => $v) {
106 106
 			$rub[$k]['atts'] = ($v['id_parent'] ? $style : '')
107 107
 				. " class='petite-rubrique'";
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	if (!$ids) {
135 135
 		return "<br /><br /><div style='padding: 5px; color: red;'><b>"
136 136
 		. spip_htmlentities($type)
137
-		. '</b> :  ' . _T('avis_aucun_resultat') . '</div>';
137
+		. '</b> :  '._T('avis_aucun_resultat').'</div>';
138 138
 	}
139 139
 
140 140
 	$ret = '';
141 141
 	$info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id=");
142 142
 
143
-	$onClick = "aff_selection(this.firstChild.title,'$rac" . "_selection','$info', event)";
143
+	$onClick = "aff_selection(this.firstChild.title,'$rac"."_selection','$info', event)";
144 144
 
145 145
 	$ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');";
146 146
 
Please login to merge, or discard this patch.
ecrire/exec/selectionner.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Rubriques
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 include_spip('inc/actions');
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
  * @uses ajax_retour()
28 28
  **/
29 29
 function exec_selectionner_dist() {
30
-	$id = (int) _request('id');
31
-	$exclus = (int) _request('exclus');
32
-	$type = _request('type');
33
-	$rac = _request('racine');
34
-	$do = _request('do');
35
-	if (preg_match('/^\w*$/', (string) $do)) {
36
-		if (!$do) {
37
-			$do = 'aff';
38
-		}
30
+    $id = (int) _request('id');
31
+    $exclus = (int) _request('exclus');
32
+    $type = _request('type');
33
+    $rac = _request('racine');
34
+    $do = _request('do');
35
+    if (preg_match('/^\w*$/', (string) $do)) {
36
+        if (!$do) {
37
+            $do = 'aff';
38
+        }
39 39
 
40
-		$selectionner = charger_fonction('selectionner', 'inc');
40
+        $selectionner = charger_fonction('selectionner', 'inc');
41 41
 
42
-		$r = $selectionner($id, 'choix_parent', $exclus, $rac, $type != 'breve', $do);
43
-	} else {
44
-		$r = '';
45
-	}
46
-	ajax_retour($r);
42
+        $r = $selectionner($id, 'choix_parent', $exclus, $rac, $type != 'breve', $do);
43
+    } else {
44
+        $r = '';
45
+    }
46
+    ajax_retour($r);
47 47
 }
Please login to merge, or discard this patch.
ecrire/exec/admin_plugin.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/config');
@@ -36,26 +36,26 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function exec_admin_plugin_dist($retour = '') {
38 38
 
39
-	if (!autoriser('configurer', '_plugins')) {
40
-		include_spip('inc/minipres');
41
-		echo minipres();
42
-	} else {
43
-		// on fait la verif du path avant tout,
44
-		// et l'installation des qu'on est dans la colonne principale
45
-		// si jamais la liste des plugins actifs change, il faut faire un refresh du hit
46
-		// pour etre sur que les bons fichiers seront charges lors de l'install
47
-		$new = actualise_plugins_actifs();
48
-		if ($new && _request('actualise') < 2) {
49
-			include_spip('inc/headers');
50
-			if (isset($GLOBALS['fichier_php_compile_recent'])) {
51
-				// attendre eventuellement l'invalidation du cache opcode
52
-				spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
53
-			}
54
-			redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&'));
55
-		} else {
56
-			admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
57
-		}
58
-	}
39
+    if (!autoriser('configurer', '_plugins')) {
40
+        include_spip('inc/minipres');
41
+        echo minipres();
42
+    } else {
43
+        // on fait la verif du path avant tout,
44
+        // et l'installation des qu'on est dans la colonne principale
45
+        // si jamais la liste des plugins actifs change, il faut faire un refresh du hit
46
+        // pour etre sur que les bons fichiers seront charges lors de l'install
47
+        $new = actualise_plugins_actifs();
48
+        if ($new && _request('actualise') < 2) {
49
+            include_spip('inc/headers');
50
+            if (isset($GLOBALS['fichier_php_compile_recent'])) {
51
+                // attendre eventuellement l'invalidation du cache opcode
52
+                spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
53
+            }
54
+            redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&'));
55
+        } else {
56
+            admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
57
+        }
58
+    }
59 59
 }
60 60
 
61 61
 /**
@@ -80,132 +80,132 @@  discard block
 block discarded – undo
80 80
  *     Format d'affichage (liste ou arborescence)
81 81
  **/
82 82
 function admin_plug_args($quoi, $erreur, $format) {
83
-	$lpf = null;
84
-	$lcpas = null;
85
-	$lcpaffichesup = null;
86
-	if (!$quoi) {
87
-		$quoi = 'actifs';
88
-	}
89
-	// empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
90
-	// format brut par plugin
91
-	$GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
92
-	// format resume mis en forme
93
-	$erreur_activation = plugin_donne_erreurs();
94
-	$commencer_page = charger_fonction('commencer_page', 'inc');
95
-	echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin');
96
-
97
-	echo debut_gauche();
98
-	echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']);
99
-
100
-	echo pipeline(
101
-		'affiche_gauche',
102
-		[
103
-			'args' => ['exec' => 'admin_plugin'],
104
-			'data' => afficher_librairies()
105
-		]
106
-	);
107
-
108
-	echo debut_droite();
109
-	echo gros_titre(_T('icone_admin_plugin'), '');
110
-
111
-	// Barre d'onglets de premier niveau
112
-	echo barre_onglets('plugins', 'plugins_actifs');
113
-	// Barre d'onglets de second niveau
114
-	$onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin';
115
-	echo debut_onglet('onglets_simple second');
116
-	echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2);
117
-	echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2);
118
-	echo fin_onglet();
119
-
120
-	// message d'erreur au retour d'une operation
121
-	if ($erreur) {
122
-		echo "<div class='error'>" . spip_htmlspecialchars($erreur) . '</div>';
123
-	}
124
-	if ($erreur_activation) {
125
-		echo "<div class='error'>$erreur_activation</div>";
126
-	}
127
-
128
-	// la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
129
-	$actifs = (array) unserialize($GLOBALS['meta']['plugin']);
130
-	$lcpa = $actifs + (array) unserialize($GLOBALS['meta']['plugin_attente']);
131
-
132
-	// Les affichages se basent sur le repertoire, pas sur le nom
133
-	$actifs = liste_chemin_plugin($actifs, '');
134
-	if (defined('_DIR_PLUGINS_SUPPL')) {
135
-		$lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL);
136
-	}
137
-	$lcpa = liste_chemin_plugin($lcpa);
138
-
139
-	// on installe les plugins maintenant,
140
-	// cela permet aux scripts d'install de faire des affichages (moches...)
141
-	plugin_installes_meta();
142
-
143
-	echo "<div class='liste-plugins formulaire_spip'>";
144
-	echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins');
145
-
146
-	if ($quoi !== 'actifs') {
147
-		$lpf = liste_plugin_files();
148
-		if ($lpf) {
149
-			echo '<p>' . _T('texte_presente_plugin') . '</p>';
150
-		} else {
151
-			if (!@is_dir(_DIR_PLUGINS)) {
152
-				echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
153
-					. ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
154
-			}
155
-		}
156
-		$lcpaffiche = $lpf;
157
-		if (defined('_DIR_PLUGINS_SUPPL')) {
158
-			$lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
159
-		}
160
-	} else {
161
-		// la liste
162
-		// $quoi=='actifs'
163
-		$lcpaffiche = $lcpa;
164
-		if (defined('_DIR_PLUGINS_SUPPL')) {
165
-			$lcpaffichesup = $lcpas;
166
-		}
167
-	}
168
-
169
-	if ($quoi == 'actifs' || $lpf) {
170
-		$nb = is_countable($lcpa) ? count($lcpa) : 0;
171
-		if (defined('_DIR_PLUGINS_SUPPL')) {
172
-			$nb += is_countable($lcpas) ? count($lcpas) : 0;
173
-		}
174
-		echo '<h3>' . sinon(
175
-			singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
176
-			_T('plugins_actif_aucun')
177
-		) . '</h3>';
178
-	}
179
-
180
-	if (empty($format)) {
181
-		$format = 'liste';
182
-	} elseif (!in_array($format, ['liste', 'repertoires'])) {
183
-		$format = 'repertoires';
184
-	}
185
-
186
-	$afficher = charger_fonction("afficher_$format", 'plugins');
187
-	$corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs);
188
-	if (defined('_DIR_PLUGINS_SUPPL')) {
189
-		$corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
190
-	}
191
-
192
-	if ($corps) {
193
-		$corps .= "\n<div class='boutons' style='display:none;'>"
194
-			. "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
195
-			. "' />"
196
-			. '</div>';
197
-	}
198
-
199
-	echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps);
200
-
201
-	echo fin_cadre_trait_couleur();
202
-
203
-	if ($quoi == 'actifs') {
204
-		echo affiche_les_plugins_verrouilles($actifs);
205
-	}
206
-	echo '</div>';
207
-
208
-	echo http_script("
83
+    $lpf = null;
84
+    $lcpas = null;
85
+    $lcpaffichesup = null;
86
+    if (!$quoi) {
87
+        $quoi = 'actifs';
88
+    }
89
+    // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
90
+    // format brut par plugin
91
+    $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
92
+    // format resume mis en forme
93
+    $erreur_activation = plugin_donne_erreurs();
94
+    $commencer_page = charger_fonction('commencer_page', 'inc');
95
+    echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin');
96
+
97
+    echo debut_gauche();
98
+    echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']);
99
+
100
+    echo pipeline(
101
+        'affiche_gauche',
102
+        [
103
+            'args' => ['exec' => 'admin_plugin'],
104
+            'data' => afficher_librairies()
105
+        ]
106
+    );
107
+
108
+    echo debut_droite();
109
+    echo gros_titre(_T('icone_admin_plugin'), '');
110
+
111
+    // Barre d'onglets de premier niveau
112
+    echo barre_onglets('plugins', 'plugins_actifs');
113
+    // Barre d'onglets de second niveau
114
+    $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin';
115
+    echo debut_onglet('onglets_simple second');
116
+    echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2);
117
+    echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2);
118
+    echo fin_onglet();
119
+
120
+    // message d'erreur au retour d'une operation
121
+    if ($erreur) {
122
+        echo "<div class='error'>" . spip_htmlspecialchars($erreur) . '</div>';
123
+    }
124
+    if ($erreur_activation) {
125
+        echo "<div class='error'>$erreur_activation</div>";
126
+    }
127
+
128
+    // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
129
+    $actifs = (array) unserialize($GLOBALS['meta']['plugin']);
130
+    $lcpa = $actifs + (array) unserialize($GLOBALS['meta']['plugin_attente']);
131
+
132
+    // Les affichages se basent sur le repertoire, pas sur le nom
133
+    $actifs = liste_chemin_plugin($actifs, '');
134
+    if (defined('_DIR_PLUGINS_SUPPL')) {
135
+        $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL);
136
+    }
137
+    $lcpa = liste_chemin_plugin($lcpa);
138
+
139
+    // on installe les plugins maintenant,
140
+    // cela permet aux scripts d'install de faire des affichages (moches...)
141
+    plugin_installes_meta();
142
+
143
+    echo "<div class='liste-plugins formulaire_spip'>";
144
+    echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins');
145
+
146
+    if ($quoi !== 'actifs') {
147
+        $lpf = liste_plugin_files();
148
+        if ($lpf) {
149
+            echo '<p>' . _T('texte_presente_plugin') . '</p>';
150
+        } else {
151
+            if (!@is_dir(_DIR_PLUGINS)) {
152
+                echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
153
+                    . ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
154
+            }
155
+        }
156
+        $lcpaffiche = $lpf;
157
+        if (defined('_DIR_PLUGINS_SUPPL')) {
158
+            $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
159
+        }
160
+    } else {
161
+        // la liste
162
+        // $quoi=='actifs'
163
+        $lcpaffiche = $lcpa;
164
+        if (defined('_DIR_PLUGINS_SUPPL')) {
165
+            $lcpaffichesup = $lcpas;
166
+        }
167
+    }
168
+
169
+    if ($quoi == 'actifs' || $lpf) {
170
+        $nb = is_countable($lcpa) ? count($lcpa) : 0;
171
+        if (defined('_DIR_PLUGINS_SUPPL')) {
172
+            $nb += is_countable($lcpas) ? count($lcpas) : 0;
173
+        }
174
+        echo '<h3>' . sinon(
175
+            singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
176
+            _T('plugins_actif_aucun')
177
+        ) . '</h3>';
178
+    }
179
+
180
+    if (empty($format)) {
181
+        $format = 'liste';
182
+    } elseif (!in_array($format, ['liste', 'repertoires'])) {
183
+        $format = 'repertoires';
184
+    }
185
+
186
+    $afficher = charger_fonction("afficher_$format", 'plugins');
187
+    $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs);
188
+    if (defined('_DIR_PLUGINS_SUPPL')) {
189
+        $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
190
+    }
191
+
192
+    if ($corps) {
193
+        $corps .= "\n<div class='boutons' style='display:none;'>"
194
+            . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
195
+            . "' />"
196
+            . '</div>';
197
+    }
198
+
199
+    echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps);
200
+
201
+    echo fin_cadre_trait_couleur();
202
+
203
+    if ($quoi == 'actifs') {
204
+        echo affiche_les_plugins_verrouilles($actifs);
205
+    }
206
+    echo '</div>';
207
+
208
+    echo http_script("
209 209
 	jQuery(function(){
210 210
 		jQuery('.plugins li.item a[rel=info]').click(function(){
211 211
 			var li = jQuery(this).parents('li').eq(0);
@@ -231,15 +231,15 @@  discard block
 block discarded – undo
231 231
 	});
232 232
 	");
233 233
 
234
-	echo pipeline(
235
-		'affiche_milieu',
236
-		[
237
-			'args' => ['exec' => 'admin_plugin'],
238
-			'data' => ''
239
-		]
240
-	);
234
+    echo pipeline(
235
+        'affiche_milieu',
236
+        [
237
+            'args' => ['exec' => 'admin_plugin'],
238
+            'data' => ''
239
+        ]
240
+    );
241 241
 
242
-	echo fin_gauche(), fin_page();
242
+    echo fin_gauche(), fin_page();
243 243
 }
244 244
 
245 245
 /**
@@ -253,23 +253,23 @@  discard block
 block discarded – undo
253 253
  *     Code HTML
254 254
  **/
255 255
 function affiche_les_plugins_verrouilles($actifs) {
256
-	if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) {
257
-		return '';
258
-	}
259
-
260
-	$afficher = charger_fonction('afficher_liste', 'plugins');
261
-	$liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST);
262
-
263
-	return
264
-		"<div id='plugins_dist'>"
265
-		. debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
266
-		. '<p>'
267
-		. _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
268
-		. '<br />' . _T('plugin_info_plugins_dist_2')
269
-		. '</p>'
270
-		. $liste
271
-		. fin_cadre_trait_couleur()
272
-		. "</div>\n";
256
+    if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) {
257
+        return '';
258
+    }
259
+
260
+    $afficher = charger_fonction('afficher_liste', 'plugins');
261
+    $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST);
262
+
263
+    return
264
+        "<div id='plugins_dist'>"
265
+        . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
266
+        . '<p>'
267
+        . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
268
+        . '<br />' . _T('plugin_info_plugins_dist_2')
269
+        . '</p>'
270
+        . $liste
271
+        . fin_cadre_trait_couleur()
272
+        . "</div>\n";
273 273
 }
274 274
 
275 275
 /**
@@ -281,18 +281,18 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function afficher_librairies() {
283 283
 
284
-	if (!$libs = liste_librairies()) {
285
-		return '';
286
-	}
287
-	ksort($libs);
288
-	$res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
289
-	$res .= '<dl>';
290
-	foreach ($libs as $lib => $rep) {
291
-		$res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
292
-	}
293
-	$res .= '</dl>';
294
-
295
-	return $res . fin_cadre_enfonce();
284
+    if (!$libs = liste_librairies()) {
285
+        return '';
286
+    }
287
+    ksort($libs);
288
+    $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
289
+    $res .= '<dl>';
290
+    foreach ($libs as $lib => $rep) {
291
+        $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
292
+    }
293
+    $res .= '</dl>';
294
+
295
+    return $res . fin_cadre_enfonce();
296 296
 }
297 297
 
298 298
 
@@ -303,22 +303,22 @@  discard block
 block discarded – undo
303 303
  *     Tableau (nom de la lib => repertoire , ...)
304 304
  */
305 305
 function liste_librairies() {
306
-	$libs = [];
307
-	foreach (array_reverse(creer_chemin()) as $d) {
308
-		if (
309
-			is_dir($dir = $d . 'lib/')
310
-			&& ($t = opendir($dir))
311
-		) {
312
-			while (($f = readdir($t)) !== false) {
313
-				if (
314
-					$f[0] != '.'
315
-					&& is_dir("$dir/$f")
316
-				) {
317
-					$libs[$f] = $dir;
318
-				}
319
-			}
320
-		}
321
-	}
322
-
323
-	return $libs;
306
+    $libs = [];
307
+    foreach (array_reverse(creer_chemin()) as $d) {
308
+        if (
309
+            is_dir($dir = $d . 'lib/')
310
+            && ($t = opendir($dir))
311
+        ) {
312
+            while (($f = readdir($t)) !== false) {
313
+                if (
314
+                    $f[0] != '.'
315
+                    && is_dir("$dir/$f")
316
+                ) {
317
+                    $libs[$f] = $dir;
318
+                }
319
+            }
320
+        }
321
+    }
322
+
323
+    return $libs;
324 324
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
 	// message d'erreur au retour d'une operation
121 121
 	if ($erreur) {
122
-		echo "<div class='error'>" . spip_htmlspecialchars($erreur) . '</div>';
122
+		echo "<div class='error'>".spip_htmlspecialchars($erreur).'</div>';
123 123
 	}
124 124
 	if ($erreur_activation) {
125 125
 		echo "<div class='error'>$erreur_activation</div>";
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 	if ($quoi !== 'actifs') {
147 147
 		$lpf = liste_plugin_files();
148 148
 		if ($lpf) {
149
-			echo '<p>' . _T('texte_presente_plugin') . '</p>';
149
+			echo '<p>'._T('texte_presente_plugin').'</p>';
150 150
 		} else {
151 151
 			if (!@is_dir(_DIR_PLUGINS)) {
152
-				echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
153
-					. ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
152
+				echo '<p>'._T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
153
+					. ' &mdash; '._T('plugin_info_automatique_creer').'</p>';
154 154
 			}
155 155
 		}
156 156
 		$lcpaffiche = $lpf;
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 		if (defined('_DIR_PLUGINS_SUPPL')) {
172 172
 			$nb += is_countable($lcpas) ? count($lcpas) : 0;
173 173
 		}
174
-		echo '<h3>' . sinon(
174
+		echo '<h3>'.sinon(
175 175
 			singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
176 176
 			_T('plugins_actif_aucun')
177
-		) . '</h3>';
177
+		).'</h3>';
178 178
 	}
179 179
 
180 180
 	if (empty($format)) {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 	if ($corps) {
193 193
 		$corps .= "\n<div class='boutons' style='display:none;'>"
194
-			. "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
194
+			. "<input type='submit' class='submit save' value='"._T('bouton_enregistrer')
195 195
 			. "' />"
196 196
 			. '</div>';
197 197
 	}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		. debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
266 266
 		. '<p>'
267 267
 		. _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
268
-		. '<br />' . _T('plugin_info_plugins_dist_2')
268
+		. '<br />'._T('plugin_info_plugins_dist_2')
269 269
 		. '</p>'
270 270
 		. $liste
271 271
 		. fin_cadre_trait_couleur()
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
 	$res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
289 289
 	$res .= '<dl>';
290 290
 	foreach ($libs as $lib => $rep) {
291
-		$res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
291
+		$res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n";
292 292
 	}
293 293
 	$res .= '</dl>';
294 294
 
295
-	return $res . fin_cadre_enfonce();
295
+	return $res.fin_cadre_enfonce();
296 296
 }
297 297
 
298 298
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	$libs = [];
307 307
 	foreach (array_reverse(creer_chemin()) as $d) {
308 308
 		if (
309
-			is_dir($dir = $d . 'lib/')
309
+			is_dir($dir = $d.'lib/')
310 310
 			&& ($t = opendir($dir))
311 311
 		) {
312 312
 			while (($f = readdir($t)) !== false) {
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_objet.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -30,43 +30,43 @@  discard block
 block discarded – undo
30 30
  * @return string
31 31
  */
32 32
 function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur = '') {
33
-	if ($changer_lang) {
34
-		$table_objet_sql = table_objet_sql($objet);
35
-		$id_table_objet = id_table_objet($objet);
36
-		$trouver_table = charger_fonction('trouver_table', 'base');
37
-		$desc = $trouver_table($table_objet_sql, $serveur);
33
+    if ($changer_lang) {
34
+        $table_objet_sql = table_objet_sql($objet);
35
+        $id_table_objet = id_table_objet($objet);
36
+        $trouver_table = charger_fonction('trouver_table', 'base');
37
+        $desc = $trouver_table($table_objet_sql, $serveur);
38 38
 
39
-		$set = [];
40
-		if (isset($desc['field']['langue_choisie'])) {
41
-			$set['langue_choisie'] = 'oui';
42
-		}
39
+        $set = [];
40
+        if (isset($desc['field']['langue_choisie'])) {
41
+            $set['langue_choisie'] = 'oui';
42
+        }
43 43
 
44
-		if ($changer_lang != 'herit') {
45
-			$set['lang'] = $changer_lang;
46
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . (int) $id, [], $serveur);
47
-			include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
48
-			if ($table_objet_sql == 'spip_rubriques') {
49
-				calculer_langues_rubriques();
50
-			}
51
-			$langues = calculer_langues_utilisees($serveur);
52
-			ecrire_meta('langues_utilisees', $langues);
53
-		} else {
54
-			$langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
55
-			if (!$langue_parent) {
56
-				$langue_parent = $GLOBALS['meta']['langue_site'];
57
-			}
58
-			$changer_lang = $langue_parent;
59
-			$set['lang'] = $changer_lang;
60
-			if (isset($set['langue_choisie'])) {
61
-				$set['langue_choisie'] = 'non';
62
-			}
63
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . (int) $id, [], $serveur);
64
-			if ($table_objet_sql == 'spip_rubriques') {
65
-				include_spip('inc/rubriques');
66
-				calculer_langues_rubriques();
67
-			}
68
-		}
69
-	}
44
+        if ($changer_lang != 'herit') {
45
+            $set['lang'] = $changer_lang;
46
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . (int) $id, [], $serveur);
47
+            include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
48
+            if ($table_objet_sql == 'spip_rubriques') {
49
+                calculer_langues_rubriques();
50
+            }
51
+            $langues = calculer_langues_utilisees($serveur);
52
+            ecrire_meta('langues_utilisees', $langues);
53
+        } else {
54
+            $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
55
+            if (!$langue_parent) {
56
+                $langue_parent = $GLOBALS['meta']['langue_site'];
57
+            }
58
+            $changer_lang = $langue_parent;
59
+            $set['lang'] = $changer_lang;
60
+            if (isset($set['langue_choisie'])) {
61
+                $set['langue_choisie'] = 'non';
62
+            }
63
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . (int) $id, [], $serveur);
64
+            if ($table_objet_sql == 'spip_rubriques') {
65
+                include_spip('inc/rubriques');
66
+                calculer_langues_rubriques();
67
+            }
68
+        }
69
+    }
70 70
 
71
-	return $changer_lang;
71
+    return $changer_lang;
72 72
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 		if ($changer_lang != 'herit') {
45 45
 			$set['lang'] = $changer_lang;
46
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . (int) $id, [], $serveur);
46
+			sql_updateq($table_objet_sql, $set, "$id_table_objet=".(int) $id, [], $serveur);
47 47
 			include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
48 48
 			if ($table_objet_sql == 'spip_rubriques') {
49 49
 				calculer_langues_rubriques();
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			$langues = calculer_langues_utilisees($serveur);
52 52
 			ecrire_meta('langues_utilisees', $langues);
53 53
 		} else {
54
-			$langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
54
+			$langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique);
55 55
 			if (!$langue_parent) {
56 56
 				$langue_parent = $GLOBALS['meta']['langue_site'];
57 57
 			}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			if (isset($set['langue_choisie'])) {
61 61
 				$set['langue_choisie'] = 'non';
62 62
 			}
63
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . (int) $id, [], $serveur);
63
+			sql_updateq($table_objet_sql, $set, "$id_table_objet=".(int) $id, [], $serveur);
64 64
 			if ($table_objet_sql == 'spip_rubriques') {
65 65
 				include_spip('inc/rubriques');
66 66
 				calculer_langues_rubriques();
Please login to merge, or discard this patch.
ecrire/action/tester.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -29,100 +29,100 @@  discard block
 block discarded – undo
29 29
  * redirige sur l'image ainsi créée (sinon sur une image d'echec).
30 30
  **/
31 31
 function action_tester_dist() {
32
-	$arg = _request('arg');
32
+    $arg = _request('arg');
33 33
 
34
-	// verifier les formats acceptes par GD
35
-	if ($arg === 'gd2') {
36
-		$gd_formats = [];
34
+    // verifier les formats acceptes par GD
35
+    if ($arg === 'gd2') {
36
+        $gd_formats = [];
37 37
 
38
-		if (function_exists('imagetypes')) {
39
-			if (imagetypes() & IMG_GIF) {
40
-				$gd_formats[] = 'gif';
41
-			}
42
-			if (imagetypes() & IMG_JPG) {
43
-				$gd_formats[] = 'jpg';
44
-			}
45
-			if (imagetypes() & IMG_PNG) {
46
-				$gd_formats[] = 'png';
47
-			}
48
-			if (imagetypes() & IMG_WEBP) {
49
-				$gd_formats[] = 'webp';
50
-			}
51
-		}
38
+        if (function_exists('imagetypes')) {
39
+            if (imagetypes() & IMG_GIF) {
40
+                $gd_formats[] = 'gif';
41
+            }
42
+            if (imagetypes() & IMG_JPG) {
43
+                $gd_formats[] = 'jpg';
44
+            }
45
+            if (imagetypes() & IMG_PNG) {
46
+                $gd_formats[] = 'png';
47
+            }
48
+            if (imagetypes() & IMG_WEBP) {
49
+                $gd_formats[] = 'webp';
50
+            }
51
+        }
52 52
 
53
-		$gd_formats = implode(',', $gd_formats);
54
-		ecrire_meta('gd_formats_read', $gd_formats);
55
-		ecrire_meta('gd_formats', $gd_formats);
56
-	} elseif ($arg == 'netpbm') {
57
-		// verifier les formats netpbm
58
-		if (!defined('_PNMSCALE_COMMAND')) {
59
-			define('_PNMSCALE_COMMAND', 'pnmscale');
60
-		} // Securite : mes_options.php peut preciser le chemin absolu
61
-		if (_PNMSCALE_COMMAND == '') {
62
-			return;
63
-		}
64
-		$netpbm_formats = [];
53
+        $gd_formats = implode(',', $gd_formats);
54
+        ecrire_meta('gd_formats_read', $gd_formats);
55
+        ecrire_meta('gd_formats', $gd_formats);
56
+    } elseif ($arg == 'netpbm') {
57
+        // verifier les formats netpbm
58
+        if (!defined('_PNMSCALE_COMMAND')) {
59
+            define('_PNMSCALE_COMMAND', 'pnmscale');
60
+        } // Securite : mes_options.php peut preciser le chemin absolu
61
+        if (_PNMSCALE_COMMAND == '') {
62
+            return;
63
+        }
64
+        $netpbm_formats = [];
65 65
 
66
-		$jpegtopnm_command = str_replace(
67
-			'pnmscale',
68
-			'jpegtopnm',
69
-			(string) _PNMSCALE_COMMAND
70
-		);
71
-		$pnmtojpeg_command = str_replace(
72
-			'pnmscale',
73
-			'pnmtojpeg',
74
-			(string) _PNMSCALE_COMMAND
75
-		);
66
+        $jpegtopnm_command = str_replace(
67
+            'pnmscale',
68
+            'jpegtopnm',
69
+            (string) _PNMSCALE_COMMAND
70
+        );
71
+        $pnmtojpeg_command = str_replace(
72
+            'pnmscale',
73
+            'pnmtojpeg',
74
+            (string) _PNMSCALE_COMMAND
75
+        );
76 76
 
77
-		$vignette = _ROOT_IMG_PACK . 'test.jpg';
78
-		$dest = _DIR_VAR . 'test-jpg.jpg';
79
-		$commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
80
-		spip_log($commande);
81
-		exec($commande);
82
-		if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
83
-			$netpbm_formats[] = 'jpg';
84
-		}
85
-		$giftopnm_command = str_replace('pnmscale', 'giftopnm', (string) _PNMSCALE_COMMAND);
86
-		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', (string) _PNMSCALE_COMMAND);
87
-		$vignette = _ROOT_IMG_PACK . 'test.gif';
88
-		$dest = _DIR_VAR . 'test-gif.jpg';
89
-		$commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
90
-		spip_log($commande);
91
-		exec($commande);
92
-		if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
93
-			$netpbm_formats[] = 'gif';
94
-		}
77
+        $vignette = _ROOT_IMG_PACK . 'test.jpg';
78
+        $dest = _DIR_VAR . 'test-jpg.jpg';
79
+        $commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
80
+        spip_log($commande);
81
+        exec($commande);
82
+        if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
83
+            $netpbm_formats[] = 'jpg';
84
+        }
85
+        $giftopnm_command = str_replace('pnmscale', 'giftopnm', (string) _PNMSCALE_COMMAND);
86
+        $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', (string) _PNMSCALE_COMMAND);
87
+        $vignette = _ROOT_IMG_PACK . 'test.gif';
88
+        $dest = _DIR_VAR . 'test-gif.jpg';
89
+        $commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
90
+        spip_log($commande);
91
+        exec($commande);
92
+        if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
93
+            $netpbm_formats[] = 'gif';
94
+        }
95 95
 
96
-		$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', (string) _PNMSCALE_COMMAND);
97
-		$vignette = _ROOT_IMG_PACK . 'test.png';
98
-		$dest = _DIR_VAR . 'test-gif.jpg';
99
-		$commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
100
-		spip_log($commande);
101
-		exec($commande);
102
-		if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
103
-			$netpbm_formats[] = 'png';
104
-		}
96
+        $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', (string) _PNMSCALE_COMMAND);
97
+        $vignette = _ROOT_IMG_PACK . 'test.png';
98
+        $dest = _DIR_VAR . 'test-gif.jpg';
99
+        $commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
100
+        spip_log($commande);
101
+        exec($commande);
102
+        if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
103
+            $netpbm_formats[] = 'png';
104
+        }
105 105
 
106
-		ecrire_meta('netpbm_formats', implode(',', $netpbm_formats ?: []));
107
-	}
106
+        ecrire_meta('netpbm_formats', implode(',', $netpbm_formats ?: []));
107
+    }
108 108
 
109
-	// et maintenant envoyer la vignette de tests
110
-	if (in_array($arg, ['gd2', 'imagick', 'convert', 'netpbm'])) {
111
-		include_spip('inc/filtres');
112
-		include_spip('inc/filtres_images_mini');
113
-		$taille_preview = 150;
114
-		$image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg');
109
+    // et maintenant envoyer la vignette de tests
110
+    if (in_array($arg, ['gd2', 'imagick', 'convert', 'netpbm'])) {
111
+        include_spip('inc/filtres');
112
+        include_spip('inc/filtres_images_mini');
113
+        $taille_preview = 150;
114
+        $image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg');
115 115
 
116
-		$image['fichier_dest'] = _DIR_VAR . "test_$arg";
116
+        $image['fichier_dest'] = _DIR_VAR . "test_$arg";
117 117
 
118
-		if (
119
-			($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true))
120
-			&& $preview['width'] * $preview['height'] > 0
121
-		) {
122
-			redirige_par_entete($preview['fichier']);
123
-		}
124
-	}
118
+        if (
119
+            ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true))
120
+            && $preview['width'] * $preview['height'] > 0
121
+        ) {
122
+            redirige_par_entete($preview['fichier']);
123
+        }
124
+    }
125 125
 
126
-	# image echec
127
-	redirige_par_entete(chemin_image('echec-reducteur-xx.svg'));
126
+    # image echec
127
+    redirige_par_entete(chemin_image('echec-reducteur-xx.svg'));
128 128
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 			(string) _PNMSCALE_COMMAND
75 75
 		);
76 76
 
77
-		$vignette = _ROOT_IMG_PACK . 'test.jpg';
78
-		$dest = _DIR_VAR . 'test-jpg.jpg';
79
-		$commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
77
+		$vignette = _ROOT_IMG_PACK.'test.jpg';
78
+		$dest = _DIR_VAR.'test-jpg.jpg';
79
+		$commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest";
80 80
 		spip_log($commande);
81 81
 		exec($commande);
82 82
 		if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		}
85 85
 		$giftopnm_command = str_replace('pnmscale', 'giftopnm', (string) _PNMSCALE_COMMAND);
86 86
 		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', (string) _PNMSCALE_COMMAND);
87
-		$vignette = _ROOT_IMG_PACK . 'test.gif';
88
-		$dest = _DIR_VAR . 'test-gif.jpg';
89
-		$commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
87
+		$vignette = _ROOT_IMG_PACK.'test.gif';
88
+		$dest = _DIR_VAR.'test-gif.jpg';
89
+		$commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest";
90 90
 		spip_log($commande);
91 91
 		exec($commande);
92 92
 		if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 		}
95 95
 
96 96
 		$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', (string) _PNMSCALE_COMMAND);
97
-		$vignette = _ROOT_IMG_PACK . 'test.png';
98
-		$dest = _DIR_VAR . 'test-gif.jpg';
99
-		$commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest";
97
+		$vignette = _ROOT_IMG_PACK.'test.png';
98
+		$dest = _DIR_VAR.'test-gif.jpg';
99
+		$commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest";
100 100
 		spip_log($commande);
101 101
 		exec($commande);
102 102
 		if (($taille = @getimagesize($dest)) && $taille[1] == 10) {
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 		include_spip('inc/filtres');
112 112
 		include_spip('inc/filtres_images_mini');
113 113
 		$taille_preview = 150;
114
-		$image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg');
114
+		$image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg');
115 115
 
116
-		$image['fichier_dest'] = _DIR_VAR . "test_$arg";
116
+		$image['fichier_dest'] = _DIR_VAR."test_$arg";
117 117
 
118 118
 		if (
119 119
 			($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true))
Please login to merge, or discard this patch.
ecrire/action/tester_taille.php 1 patch
Indentation   +79 added lines, -79 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('inc/headers');
23 23
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
  *     Sortie du buffer
35 35
  **/
36 36
 function action_tester_taille_error_handler($output) {
37
-	// on est ici, donc echec lors de la creation de l'image
38
-	if (!empty($GLOBALS['redirect'])) {
39
-		return redirige_formulaire($GLOBALS['redirect']);
40
-	}
37
+    // on est ici, donc echec lors de la creation de l'image
38
+    if (!empty($GLOBALS['redirect'])) {
39
+        return redirige_formulaire($GLOBALS['redirect']);
40
+    }
41 41
 
42
-	return $output;
42
+    return $output;
43 43
 }
44 44
 
45 45
 
@@ -57,77 +57,77 @@  discard block
 block discarded – undo
57 57
  **/
58 58
 function action_tester_taille_dist() {
59 59
 
60
-	if (!autoriser('configurer')) {
61
-		return;
62
-	}
63
-
64
-	$taille = _request('arg');
65
-	$taille = explode('-', (string) $taille);
66
-
67
-	$GLOBALS['taille_max'] = end($taille);
68
-	$GLOBALS['taille_min'] = 0;
69
-	if (count($taille) > 1) {
70
-		$GLOBALS['taille_min'] = reset($taille);
71
-	}
72
-
73
-	// si l'intervalle est assez petit, on garde la valeur min
74
-	if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) {
75
-		$t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']);
76
-		if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) {
77
-			$t *= 0.9; // marge de securite
78
-			echo round($t / 1_000_000, 3) . ' Mpx';
79
-		} else {
80
-			// c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue"
81
-			$t = 0;
82
-			echo '&infin;';
83
-		}
84
-		ecrire_meta('max_taille_vignettes', $t, 'non');
85
-		die();
86
-	}
87
-
88
-	$taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2);
89
-
90
-	include_spip('inc/filtres');
91
-	// des inclusions representatives d'un hit prive et/ou public pour la conso memoire
92
-	include_spip('public/assembler');
93
-	include_spip('public/balises');
94
-	include_spip('public/boucles');
95
-	include_spip('public/cacher');
96
-	include_spip('public/compiler');
97
-	include_spip('public/composer');
98
-	include_spip('public/criteres');
99
-	include_spip('public/interfaces');
100
-	include_spip('public/parametrer');
101
-	include_spip('public/phraser_html');
102
-	include_spip('public/references');
103
-
104
-	include_spip('inc/presentation');
105
-	include_spip('inc/charsets');
106
-	include_spip('inc/documents');
107
-	include_spip('inc/header');
108
-	propre('<doc1>'); // charger propre avec le trairement d'un modele
109
-
110
-	$i = _request('i') + 1;
111
-	$image_source = chemin_image('test.png');
112
-	$GLOBALS['redirect'] = generer_url_action(
113
-		'tester_taille',
114
-		"i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test']
115
-	);
116
-
117
-	ob_start('action_tester_taille_error_handler');
118
-	filtrer('image_recadre', $image_source, $taille, $taille);
119
-	$GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
120
-
121
-	// si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee
122
-	// si $GLOBALS['taille_min']==0 (car on est au premier coup)
123
-	if ($GLOBALS['taille_min'] == 0) {
124
-		$taille = $GLOBALS['taille_max'];
125
-		filtrer('image_recadre', $image_source, $taille, $taille);
126
-		$GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
127
-	}
128
-	ob_end_clean();
129
-
130
-
131
-	// on est ici, donc pas de plantage
132
-	echo redirige_formulaire($GLOBALS['redirect']);
60
+    if (!autoriser('configurer')) {
61
+        return;
62
+    }
63
+
64
+    $taille = _request('arg');
65
+    $taille = explode('-', (string) $taille);
66
+
67
+    $GLOBALS['taille_max'] = end($taille);
68
+    $GLOBALS['taille_min'] = 0;
69
+    if (count($taille) > 1) {
70
+        $GLOBALS['taille_min'] = reset($taille);
71
+    }
72
+
73
+    // si l'intervalle est assez petit, on garde la valeur min
74
+    if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) {
75
+        $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']);
76
+        if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) {
77
+            $t *= 0.9; // marge de securite
78
+            echo round($t / 1_000_000, 3) . ' Mpx';
79
+        } else {
80
+            // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue"
81
+            $t = 0;
82
+            echo '&infin;';
83
+        }
84
+        ecrire_meta('max_taille_vignettes', $t, 'non');
85
+        die();
86
+    }
87
+
88
+    $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2);
89
+
90
+    include_spip('inc/filtres');
91
+    // des inclusions representatives d'un hit prive et/ou public pour la conso memoire
92
+    include_spip('public/assembler');
93
+    include_spip('public/balises');
94
+    include_spip('public/boucles');
95
+    include_spip('public/cacher');
96
+    include_spip('public/compiler');
97
+    include_spip('public/composer');
98
+    include_spip('public/criteres');
99
+    include_spip('public/interfaces');
100
+    include_spip('public/parametrer');
101
+    include_spip('public/phraser_html');
102
+    include_spip('public/references');
103
+
104
+    include_spip('inc/presentation');
105
+    include_spip('inc/charsets');
106
+    include_spip('inc/documents');
107
+    include_spip('inc/header');
108
+    propre('<doc1>'); // charger propre avec le trairement d'un modele
109
+
110
+    $i = _request('i') + 1;
111
+    $image_source = chemin_image('test.png');
112
+    $GLOBALS['redirect'] = generer_url_action(
113
+        'tester_taille',
114
+        "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test']
115
+    );
116
+
117
+    ob_start('action_tester_taille_error_handler');
118
+    filtrer('image_recadre', $image_source, $taille, $taille);
119
+    $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
120
+
121
+    // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee
122
+    // si $GLOBALS['taille_min']==0 (car on est au premier coup)
123
+    if ($GLOBALS['taille_min'] == 0) {
124
+        $taille = $GLOBALS['taille_max'];
125
+        filtrer('image_recadre', $image_source, $taille, $taille);
126
+        $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']);
127
+    }
128
+    ob_end_clean();
129
+
130
+
131
+    // on est ici, donc pas de plantage
132
+    echo redirige_formulaire($GLOBALS['redirect']);
133 133
 }
Please login to merge, or discard this patch.
ecrire/action/editer_liens.php 3 patches
Indentation   +558 added lines, -558 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 if (!defined('_ECRIRE_INC_VERSION')) {
31
-	return;
31
+    return;
32 32
 }
33 33
 
34 34
 // charger la gestion les rôles sur les objets
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
  *     - array(clé primaire, nom de la table de lien) si associable
47 47
  */
48 48
 function objet_associable($objet) {
49
-	$trouver_table = charger_fonction('trouver_table', 'base');
50
-	$table_sql = table_objet_sql($objet);
51
-
52
-	$l = '';
53
-	if (
54
-		($primary = id_table_objet($objet))
55
-		&& $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false])
56
-		&& !preg_match(',[^\w],', $primary)
57
-		&& !preg_match(',[^\w],', $l)
58
-	) {
59
-		return [$primary, $l];
60
-	}
61
-
62
-	spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
63
-
64
-	return false;
49
+    $trouver_table = charger_fonction('trouver_table', 'base');
50
+    $table_sql = table_objet_sql($objet);
51
+
52
+    $l = '';
53
+    if (
54
+        ($primary = id_table_objet($objet))
55
+        && $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false])
56
+        && !preg_match(',[^\w],', $primary)
57
+        && !preg_match(',[^\w],', $l)
58
+    ) {
59
+        return [$primary, $l];
60
+    }
61
+
62
+    spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
63
+
64
+    return false;
65 65
 }
66 66
 
67 67
 /**
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
  * @return bool|int
88 88
  */
89 89
 function objet_associer($objets_source, $objets_lies, $qualif = null) {
90
-	$modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif);
90
+    $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif);
91 91
 
92
-	if ($qualif) {
93
-		objet_qualifier_liens($objets_source, $objets_lies, $qualif);
94
-	}
92
+    if ($qualif) {
93
+        objet_qualifier_liens($objets_source, $objets_lies, $qualif);
94
+    }
95 95
 
96
-	return $modifs; // pas d'erreur
96
+    return $modifs; // pas d'erreur
97 97
 }
98 98
 
99 99
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
  * @return bool|int
128 128
  */
129 129
 function objet_dissocier($objets_source, $objets_lies, $cond = null) {
130
-	return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond);
130
+    return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond);
131 131
 }
132 132
 
133 133
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
  * @return bool|int
153 153
  */
154 154
 function objet_qualifier_liens($objets_source, $objets_lies, $qualif) {
155
-	return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif);
155
+    return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif);
156 156
 }
157 157
 
158 158
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
  *     Liste des trouvailles
188 188
  */
189 189
 function objet_trouver_liens($objets_source, $objets_lies, $cond = null) {
190
-	return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond);
190
+    return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond);
191 191
 }
192 192
 
193 193
 
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
  * @return int
212 212
  */
213 213
 function objet_optimiser_liens($objets_source, $objets_lies) {
214
-	spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG);
215
-	return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies);
214
+    spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG);
215
+    return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies);
216 216
 }
217 217
 
218 218
 
@@ -232,30 +232,30 @@  discard block
 block discarded – undo
232 232
  *     Nombre de liens copiés
233 233
  */
234 234
 function objet_dupliquer_liens($objet, $id_source, $id_cible, $types = null, $exclure_types = null) {
235
-	include_spip('base/objets');
236
-	$tables = lister_tables_objets_sql();
237
-	$n = 0;
238
-	foreach ($tables as $table_sql => $infos) {
239
-		if ((is_null($types) || in_array($infos['type'], $types)) && (is_null($exclure_types) || !in_array($infos['type'], $exclure_types)) && objet_associable($infos['type'])) {
240
-			$liens = (($infos['type'] == $objet)
241
-				? objet_trouver_liens([$objet => $id_source], '*')
242
-				: objet_trouver_liens([$infos['type'] => '*'], [$objet => $id_source]));
243
-			foreach ($liens as $lien) {
244
-				$n++;
245
-				if ($infos['type'] == $objet) {
246
-					if (
247
-						(is_null($types) || in_array($lien['objet'], $types)) && (is_null($exclure_types) || !in_array($lien['objet'], $exclure_types))
248
-					) {
249
-						objet_associer([$objet => $id_cible], [$lien['objet'] => $lien[$lien['objet']]], $lien);
250
-					}
251
-				} else {
252
-					objet_associer([$infos['type'] => $lien[$infos['type']]], [$objet => $id_cible], $lien);
253
-				}
254
-			}
255
-		}
256
-	}
257
-
258
-	return $n;
235
+    include_spip('base/objets');
236
+    $tables = lister_tables_objets_sql();
237
+    $n = 0;
238
+    foreach ($tables as $table_sql => $infos) {
239
+        if ((is_null($types) || in_array($infos['type'], $types)) && (is_null($exclure_types) || !in_array($infos['type'], $exclure_types)) && objet_associable($infos['type'])) {
240
+            $liens = (($infos['type'] == $objet)
241
+                ? objet_trouver_liens([$objet => $id_source], '*')
242
+                : objet_trouver_liens([$infos['type'] => '*'], [$objet => $id_source]));
243
+            foreach ($liens as $lien) {
244
+                $n++;
245
+                if ($infos['type'] == $objet) {
246
+                    if (
247
+                        (is_null($types) || in_array($lien['objet'], $types)) && (is_null($exclure_types) || !in_array($lien['objet'], $exclure_types))
248
+                    ) {
249
+                        objet_associer([$objet => $id_cible], [$lien['objet'] => $lien[$lien['objet']]], $lien);
250
+                    }
251
+                } else {
252
+                    objet_associer([$infos['type'] => $lien[$infos['type']]], [$objet => $id_cible], $lien);
253
+                }
254
+            }
255
+        }
256
+    }
257
+
258
+    return $n;
259 259
 }
260 260
 
261 261
 /**
@@ -297,38 +297,38 @@  discard block
 block discarded – undo
297 297
  * @return bool|int|array
298 298
  */
299 299
 function objet_traiter_liaisons($operation, $objets_source, $objets_lies, $set = null) {
300
-	// accepter une syntaxe minimale pour supprimer tous les liens
301
-	if ($objets_lies == '*') {
302
-		$objets_lies = ['*' => '*'];
303
-	}
304
-	$modifs = 0; // compter le nombre de modifications
305
-	$echec = null;
306
-	foreach ($objets_source as $objet => $ids) {
307
-		if ($a = objet_associable($objet)) {
308
-			[$primary, $l] = $a;
309
-			if (!is_array($ids)) {
310
-				$ids = [$ids];
311
-			} elseif (reset($ids) == 'NOT') {
312
-				// si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
313
-				$where = lien_where($primary, $ids, '*', '*');
314
-				$ids = sql_allfetsel($primary, $l, $where);
315
-				$ids = array_map('reset', $ids);
316
-			}
317
-			foreach ($ids as $id) {
318
-				$res = $operation($objet, $primary, $l, $id, $objets_lies, $set);
319
-				if ($res === false) {
320
-					spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR);
321
-					$echec = true;
322
-				} else {
323
-					$modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res);
324
-				}
325
-			}
326
-		} else {
327
-			$echec = true;
328
-		}
329
-	}
330
-
331
-	return ($echec ? false : $modifs); // pas d'erreur
300
+    // accepter une syntaxe minimale pour supprimer tous les liens
301
+    if ($objets_lies == '*') {
302
+        $objets_lies = ['*' => '*'];
303
+    }
304
+    $modifs = 0; // compter le nombre de modifications
305
+    $echec = null;
306
+    foreach ($objets_source as $objet => $ids) {
307
+        if ($a = objet_associable($objet)) {
308
+            [$primary, $l] = $a;
309
+            if (!is_array($ids)) {
310
+                $ids = [$ids];
311
+            } elseif (reset($ids) == 'NOT') {
312
+                // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
313
+                $where = lien_where($primary, $ids, '*', '*');
314
+                $ids = sql_allfetsel($primary, $l, $where);
315
+                $ids = array_map('reset', $ids);
316
+            }
317
+            foreach ($ids as $id) {
318
+                $res = $operation($objet, $primary, $l, $id, $objets_lies, $set);
319
+                if ($res === false) {
320
+                    spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR);
321
+                    $echec = true;
322
+                } else {
323
+                    $modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res);
324
+                }
325
+            }
326
+        } else {
327
+            $echec = true;
328
+        }
329
+    }
330
+
331
+    return ($echec ? false : $modifs); // pas d'erreur
332 332
 }
333 333
 
334 334
 
@@ -357,116 +357,116 @@  discard block
 block discarded – undo
357 357
  *     Nombre d'insertions faites, false si échec.
358 358
  */
359 359
 function lien_insert($objet_source, $primary, $table_lien, $id, $objets, $qualif) {
360
-	$ins = 0;
361
-	$echec = null;
362
-	if (is_null($qualif)) {
363
-		$qualif = [];
364
-	}
365
-
366
-	foreach ($objets as $objet => $id_objets) {
367
-		if (!is_array($id_objets)) {
368
-			$id_objets = [$id_objets];
369
-		}
370
-
371
-		// role, colonne, where par défaut
372
-		[$role, $colonne_role, $cond] =
373
-			roles_trouver_dans_qualif($objet_source, $objet, $qualif);
374
-
375
-		foreach ($id_objets as $id_objet) {
376
-			$objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
377
-
378
-			$insertions = [
379
-				'id_objet' => $id_objet,
380
-				'objet' => $objet,
381
-				$primary => $id
382
-			];
383
-			// rôle en plus s'il est défini
384
-			if ($role) {
385
-				$insertions += [
386
-					$colonne_role => $role
387
-				];
388
-			}
389
-
390
-			if (lien_triables($table_lien)) {
391
-				if (isset($qualif['rang_lien'])) {
392
-					$rang = $qualif['rang_lien'];
393
-				}
394
-				else {
395
-					$where = lien_where($primary, $id, $objet, $id_objet);
396
-					// si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul
397
-					if (!$rang = (int) sql_getfetsel('rang_lien', $table_lien, $where)) {
398
-						$where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
399
-						$rang = (int) sql_getfetsel('max(rang_lien)', $table_lien, $where);
400
-						// si aucun lien n'a de rang, on en introduit pas, on garde zero
401
-						if ($rang > 0) {
402
-							$rang = (int) $rang + 1;
403
-						}
404
-					}
405
-				}
406
-				$insertions['rang_lien'] = $rang;
407
-			}
408
-
409
-			$args = [
410
-				'table_lien' => $table_lien,
411
-				'objet_source' => $objet_source,
412
-				'id_objet_source' => $id,
413
-				'objet' => $objet,
414
-				'id_objet' => $id_objet,
415
-				'role' => $role,
416
-				'colonne_role' => $colonne_role,
417
-				'action' => 'insert',
418
-			];
419
-
420
-			// Envoyer aux plugins
421
-			$insertions = pipeline(
422
-				'pre_edition_lien',
423
-				[
424
-					'args' => $args,
425
-					'data' => $insertions
426
-				]
427
-			);
428
-			$args['id_objet'] = $insertions['id_objet'];
429
-
430
-			$where = lien_where($primary, $id, $objet, $id_objet, $cond);
431
-
432
-			if (
433
-				(($id_objet = (int) $insertions['id_objet']) || in_array($objet, ['site', 'rubrique'])) && !sql_getfetsel($primary, $table_lien, $where)
434
-			) {
435
-				if (lien_triables($table_lien) && isset($insertions['rang_lien']) && (int) $insertions['rang_lien']) {
436
-					$where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
437
-					$where_meme_lien = implode(' AND ', $where_meme_lien);
438
-					// on decale les liens de rang_lien>=la valeur inseree pour faire la place
439
-					// sauf sur le meme lien avec un role eventuellement different
440
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . (int) $insertions['rang_lien'], "NOT($where_meme_lien)"]);
441
-					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
442
-				}
443
-
444
-				$e = sql_insertq($table_lien, $insertions);
445
-				if ($e !== false) {
446
-					$ins++;
447
-					lien_propage_date_modif($objet, $id_objet);
448
-					lien_propage_date_modif($objet_source, $id);
449
-					// Envoyer aux plugins
450
-					pipeline(
451
-						'post_edition_lien',
452
-						[
453
-							'args' => $args,
454
-							'data' => $insertions
455
-						]
456
-					);
457
-				} else {
458
-					$echec = true;
459
-				}
460
-			}
461
-		}
462
-	}
463
-	// si on a fait des insertions, on reordonne les liens concernes
464
-	// pas la peine si $qualif['rang_lien'] etait fournie, on va passer dans lien_set a suivre et donc finir le recomptage
465
-	if ($ins > 0 && empty($qualif['rang_lien'])) {
466
-		lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
467
-	}
468
-
469
-	return ($echec ? false : $ins);
360
+    $ins = 0;
361
+    $echec = null;
362
+    if (is_null($qualif)) {
363
+        $qualif = [];
364
+    }
365
+
366
+    foreach ($objets as $objet => $id_objets) {
367
+        if (!is_array($id_objets)) {
368
+            $id_objets = [$id_objets];
369
+        }
370
+
371
+        // role, colonne, where par défaut
372
+        [$role, $colonne_role, $cond] =
373
+            roles_trouver_dans_qualif($objet_source, $objet, $qualif);
374
+
375
+        foreach ($id_objets as $id_objet) {
376
+            $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
377
+
378
+            $insertions = [
379
+                'id_objet' => $id_objet,
380
+                'objet' => $objet,
381
+                $primary => $id
382
+            ];
383
+            // rôle en plus s'il est défini
384
+            if ($role) {
385
+                $insertions += [
386
+                    $colonne_role => $role
387
+                ];
388
+            }
389
+
390
+            if (lien_triables($table_lien)) {
391
+                if (isset($qualif['rang_lien'])) {
392
+                    $rang = $qualif['rang_lien'];
393
+                }
394
+                else {
395
+                    $where = lien_where($primary, $id, $objet, $id_objet);
396
+                    // si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul
397
+                    if (!$rang = (int) sql_getfetsel('rang_lien', $table_lien, $where)) {
398
+                        $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
399
+                        $rang = (int) sql_getfetsel('max(rang_lien)', $table_lien, $where);
400
+                        // si aucun lien n'a de rang, on en introduit pas, on garde zero
401
+                        if ($rang > 0) {
402
+                            $rang = (int) $rang + 1;
403
+                        }
404
+                    }
405
+                }
406
+                $insertions['rang_lien'] = $rang;
407
+            }
408
+
409
+            $args = [
410
+                'table_lien' => $table_lien,
411
+                'objet_source' => $objet_source,
412
+                'id_objet_source' => $id,
413
+                'objet' => $objet,
414
+                'id_objet' => $id_objet,
415
+                'role' => $role,
416
+                'colonne_role' => $colonne_role,
417
+                'action' => 'insert',
418
+            ];
419
+
420
+            // Envoyer aux plugins
421
+            $insertions = pipeline(
422
+                'pre_edition_lien',
423
+                [
424
+                    'args' => $args,
425
+                    'data' => $insertions
426
+                ]
427
+            );
428
+            $args['id_objet'] = $insertions['id_objet'];
429
+
430
+            $where = lien_where($primary, $id, $objet, $id_objet, $cond);
431
+
432
+            if (
433
+                (($id_objet = (int) $insertions['id_objet']) || in_array($objet, ['site', 'rubrique'])) && !sql_getfetsel($primary, $table_lien, $where)
434
+            ) {
435
+                if (lien_triables($table_lien) && isset($insertions['rang_lien']) && (int) $insertions['rang_lien']) {
436
+                    $where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
437
+                    $where_meme_lien = implode(' AND ', $where_meme_lien);
438
+                    // on decale les liens de rang_lien>=la valeur inseree pour faire la place
439
+                    // sauf sur le meme lien avec un role eventuellement different
440
+                    $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . (int) $insertions['rang_lien'], "NOT($where_meme_lien)"]);
441
+                    sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
442
+                }
443
+
444
+                $e = sql_insertq($table_lien, $insertions);
445
+                if ($e !== false) {
446
+                    $ins++;
447
+                    lien_propage_date_modif($objet, $id_objet);
448
+                    lien_propage_date_modif($objet_source, $id);
449
+                    // Envoyer aux plugins
450
+                    pipeline(
451
+                        'post_edition_lien',
452
+                        [
453
+                            'args' => $args,
454
+                            'data' => $insertions
455
+                        ]
456
+                    );
457
+                } else {
458
+                    $echec = true;
459
+                }
460
+            }
461
+        }
462
+    }
463
+    // si on a fait des insertions, on reordonne les liens concernes
464
+    // pas la peine si $qualif['rang_lien'] etait fournie, on va passer dans lien_set a suivre et donc finir le recomptage
465
+    if ($ins > 0 && empty($qualif['rang_lien'])) {
466
+        lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
467
+    }
468
+
469
+    return ($echec ? false : $ins);
470 470
 }
471 471
 
472 472
 
@@ -479,47 +479,47 @@  discard block
 block discarded – undo
479 479
  * @param array|string $objets
480 480
  */
481 481
 function lien_ordonner($objet_source, $primary, $table_lien, $id, $objets) {
482
-	if (!lien_triables($table_lien)) {
483
-		return;
484
-	}
485
-
486
-	$deja_reordonne = [];
487
-
488
-	foreach ($objets as $objet => $id_objets) {
489
-		if (!is_array($id_objets)) {
490
-			$id_objets = [$id_objets];
491
-		}
492
-
493
-		foreach ($id_objets as $id_objet) {
494
-			if (empty($deja_reordonne[$id][$objet][$id_objet])) {
495
-				$objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
496
-
497
-				$where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
498
-				$liens = sql_allfetsel("$primary, id_objet, objet, rang_lien", $table_lien, $where, '', 'rang_lien');
499
-
500
-				$rangs = array_column($liens, 'rang_lien');
501
-				if (count($rangs) && (max($rangs) > 0 || min($rangs) < 0)) {
502
-					$rang = 1;
503
-					foreach ($liens as $lien) {
504
-						if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) {
505
-							$where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . (int) $rang]);
506
-							sql_updateq($table_lien, ['rang_lien' => $rang], $where);
507
-
508
-							if (empty($deja_reordonne[$lien[$primary]])) {
509
-								$deja_reordonne[$lien[$primary]] = [];
510
-							}
511
-							if (empty($deja_reordonne[$lien[$primary]][$lien['objet']])) {
512
-								$deja_reordonne[$lien[$primary]][$lien['objet']] = [];
513
-							}
514
-							$deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']] = $rang;
515
-
516
-							$rang++;
517
-						}
518
-					}
519
-				}
520
-			}
521
-		}
522
-	}
482
+    if (!lien_triables($table_lien)) {
483
+        return;
484
+    }
485
+
486
+    $deja_reordonne = [];
487
+
488
+    foreach ($objets as $objet => $id_objets) {
489
+        if (!is_array($id_objets)) {
490
+            $id_objets = [$id_objets];
491
+        }
492
+
493
+        foreach ($id_objets as $id_objet) {
494
+            if (empty($deja_reordonne[$id][$objet][$id_objet])) {
495
+                $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
496
+
497
+                $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
498
+                $liens = sql_allfetsel("$primary, id_objet, objet, rang_lien", $table_lien, $where, '', 'rang_lien');
499
+
500
+                $rangs = array_column($liens, 'rang_lien');
501
+                if (count($rangs) && (max($rangs) > 0 || min($rangs) < 0)) {
502
+                    $rang = 1;
503
+                    foreach ($liens as $lien) {
504
+                        if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) {
505
+                            $where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . (int) $rang]);
506
+                            sql_updateq($table_lien, ['rang_lien' => $rang], $where);
507
+
508
+                            if (empty($deja_reordonne[$lien[$primary]])) {
509
+                                $deja_reordonne[$lien[$primary]] = [];
510
+                            }
511
+                            if (empty($deja_reordonne[$lien[$primary]][$lien['objet']])) {
512
+                                $deja_reordonne[$lien[$primary]][$lien['objet']] = [];
513
+                            }
514
+                            $deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']] = $rang;
515
+
516
+                            $rang++;
517
+                        }
518
+                    }
519
+                }
520
+            }
521
+        }
522
+    }
523 523
 }
524 524
 
525 525
 
@@ -530,13 +530,13 @@  discard block
 block discarded – undo
530 530
  * @return mixed
531 531
  */
532 532
 function lien_triables($table_lien) {
533
-	static $triables = [];
534
-	if (!isset($triables[$table_lien])) {
535
-		$trouver_table = charger_fonction('trouver_table', 'base');
536
-		$desc = $trouver_table($table_lien);
537
-		$triables[$table_lien] = $desc && isset($desc['field']['rang_lien']);
538
-	}
539
-	return $triables[$table_lien];
533
+    static $triables = [];
534
+    if (!isset($triables[$table_lien])) {
535
+        $trouver_table = charger_fonction('trouver_table', 'base');
536
+        $desc = $trouver_table($table_lien);
537
+        $triables[$table_lien] = $desc && isset($desc['field']['rang_lien']);
538
+    }
539
+    return $triables[$table_lien];
540 540
 }
541 541
 
542 542
 
@@ -552,50 +552,50 @@  discard block
 block discarded – undo
552 552
  * @return array                        Liste des conditions
553 553
  */
554 554
 function lien_where($primary, $id_source, $objet, $id_objet, $cond = []) {
555
-	if (
556
-		!is_array($id_source) && !strlen($id_source) || !strlen($objet) || !is_array($id_objet) && !strlen($id_objet)
557
-	) {
558
-		return ['0=1'];
559
-	} // securite
560
-
561
-	$not = '';
562
-	if (is_array($id_source) && reset($id_source) == 'NOT') {
563
-		$not = array_shift($id_source);
564
-		$id_source = reset($id_source);
565
-	}
566
-
567
-	$where = $cond;
568
-
569
-	if ($id_source !== '*') {
570
-		$where[] = (is_array($id_source) ? sql_in(
571
-			addslashes($primary),
572
-			array_map('intval', $id_source),
573
-			$not
574
-		) : addslashes($primary) . ($not ? '<>' : '=') . (int) $id_source);
575
-	} elseif ($not) {
576
-		$where[] = '0=1';
577
-	} // idiot mais quand meme
578
-
579
-	$not = '';
580
-	if (is_array($id_objet) && reset($id_objet) == 'NOT') {
581
-		$not = array_shift($id_objet);
582
-		$id_objet = reset($id_objet);
583
-	}
584
-
585
-	if ($objet !== '*') {
586
-		$where[] = 'objet=' . sql_quote($objet);
587
-	}
588
-	if ($id_objet !== '*') {
589
-		$where[] = (is_array($id_objet) ? sql_in(
590
-			'id_objet',
591
-			array_map('intval', $id_objet),
592
-			$not
593
-		) : 'id_objet' . ($not ? '<>' : '=') . (int) $id_objet);
594
-	} elseif ($not) {
595
-		$where[] = '0=1';
596
-	} // idiot mais quand meme
597
-
598
-	return $where;
555
+    if (
556
+        !is_array($id_source) && !strlen($id_source) || !strlen($objet) || !is_array($id_objet) && !strlen($id_objet)
557
+    ) {
558
+        return ['0=1'];
559
+    } // securite
560
+
561
+    $not = '';
562
+    if (is_array($id_source) && reset($id_source) == 'NOT') {
563
+        $not = array_shift($id_source);
564
+        $id_source = reset($id_source);
565
+    }
566
+
567
+    $where = $cond;
568
+
569
+    if ($id_source !== '*') {
570
+        $where[] = (is_array($id_source) ? sql_in(
571
+            addslashes($primary),
572
+            array_map('intval', $id_source),
573
+            $not
574
+        ) : addslashes($primary) . ($not ? '<>' : '=') . (int) $id_source);
575
+    } elseif ($not) {
576
+        $where[] = '0=1';
577
+    } // idiot mais quand meme
578
+
579
+    $not = '';
580
+    if (is_array($id_objet) && reset($id_objet) == 'NOT') {
581
+        $not = array_shift($id_objet);
582
+        $id_objet = reset($id_objet);
583
+    }
584
+
585
+    if ($objet !== '*') {
586
+        $where[] = 'objet=' . sql_quote($objet);
587
+    }
588
+    if ($id_objet !== '*') {
589
+        $where[] = (is_array($id_objet) ? sql_in(
590
+            'id_objet',
591
+            array_map('intval', $id_objet),
592
+            $not
593
+        ) : 'id_objet' . ($not ? '<>' : '=') . (int) $id_objet);
594
+    } elseif ($not) {
595
+        $where[] = '0=1';
596
+    } // idiot mais quand meme
597
+
598
+    return $where;
599 599
 }
600 600
 
601 601
 /**
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
  */
611 611
 function lien_rang_where($table_lien, $primary, $id_source, $objet, $id_objet, $cond = []) {
612 612
 
613
-	// si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc
614
-	if (function_exists($f = 'lien_rang_where_' . $table_lien)) {
615
-		return $f($primary, $id_source, $objet, $id_objet, $cond);
616
-	}
613
+    // si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc
614
+    if (function_exists($f = 'lien_rang_where_' . $table_lien)) {
615
+        return $f($primary, $id_source, $objet, $id_objet, $cond);
616
+    }
617 617
 
618
-	// par defaut c'est un rang compté pour tous les id_source d'un couple objet-id_objet
619
-	return lien_where($primary, '*', $objet, $id_objet, $cond);
618
+    // par defaut c'est un rang compté pour tous les id_source d'un couple objet-id_objet
619
+    return lien_where($primary, '*', $objet, $id_objet, $cond);
620 620
 }
621 621
 
622 622
 /**
@@ -647,90 +647,90 @@  discard block
 block discarded – undo
647 647
  */
648 648
 function lien_delete($objet_source, $primary, $table_lien, $id, $objets, $cond = null) {
649 649
 
650
-	$retire = [];
651
-	$dels = 0;
652
-	$echec = false;
653
-	if (is_null($cond)) {
654
-		$cond = [];
655
-	}
656
-
657
-	foreach ($objets as $objet => $id_objets) {
658
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
659
-		if (!is_array($id_objets) || reset($id_objets) == 'NOT') {
660
-			$id_objets = [$id_objets];
661
-		}
662
-		foreach ($id_objets as $id_objet) {
663
-			[$cond, $colonne_role, $role] = roles_creer_condition_role($objet_source, $objet, $cond);
664
-			// id_objet peut valoir '*'
665
-			$where = lien_where($primary, $id, $objet, $id_objet, $cond);
666
-
667
-			// lire les liens existants pour propager la date de modif
668
-			$select = "$primary,id_objet,objet";
669
-			if ($colonne_role) {
670
-				$select .= ",$colonne_role";
671
-			}
672
-			$liens = sql_allfetsel($select, $table_lien, $where);
673
-
674
-			// iterer sur les liens pour permettre aux plugins de gerer
675
-			foreach ($liens as $l) {
676
-				$args = [
677
-					'table_lien' => $table_lien,
678
-					'objet_source' => $objet_source,
679
-					'id_objet_source' => $l[$primary],
680
-					'objet' => $l['objet'],
681
-					'id_objet' => $l['id_objet'],
682
-					'colonne_role' => $colonne_role,
683
-					'role' => ($colonne_role ? $l[$colonne_role] : ''),
684
-					'action' => 'delete',
685
-				];
686
-
687
-				// Envoyer aux plugins
688
-				$l = pipeline(
689
-					'pre_edition_lien',
690
-					[
691
-						'args' => $args,
692
-						'data' => $l
693
-					]
694
-				);
695
-				$args['id_objet'] = $id_o = $l['id_objet'];
696
-
697
-				if (($id_o = (int) $l['id_objet']) || in_array($l['objet'], ['site', 'rubrique'])) {
698
-					$where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond);
699
-					$e = sql_delete($table_lien, $where);
700
-					if ($e !== false) {
701
-						$dels += $e;
702
-						lien_propage_date_modif($l['objet'], $id_o);
703
-						lien_propage_date_modif($objet_source, $l[$primary]);
704
-					} else {
705
-						$echec = true;
706
-					}
707
-					$retire[] = [
708
-						'source' => [$objet_source => $l[$primary]],
709
-						'lien' => [$l['objet'] => $id_o],
710
-						'type' => $l['objet'],
711
-						'role' => ($colonne_role ? $l[$colonne_role] : ''),
712
-						'id' => $id_o
713
-					];
714
-					// Envoyer aux plugins
715
-					pipeline(
716
-						'post_edition_lien',
717
-						[
718
-							'args' => $args,
719
-							'data' => $l
720
-						]
721
-					);
722
-				}
723
-			}
724
-		}
725
-	}
726
-	// si on a supprime des liens, on reordonne les liens concernes
727
-	if ($dels) {
728
-		lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
729
-	}
730
-
731
-	pipeline('trig_supprimer_objets_lies', $retire);
732
-
733
-	return ($echec ? false : $dels);
650
+    $retire = [];
651
+    $dels = 0;
652
+    $echec = false;
653
+    if (is_null($cond)) {
654
+        $cond = [];
655
+    }
656
+
657
+    foreach ($objets as $objet => $id_objets) {
658
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
659
+        if (!is_array($id_objets) || reset($id_objets) == 'NOT') {
660
+            $id_objets = [$id_objets];
661
+        }
662
+        foreach ($id_objets as $id_objet) {
663
+            [$cond, $colonne_role, $role] = roles_creer_condition_role($objet_source, $objet, $cond);
664
+            // id_objet peut valoir '*'
665
+            $where = lien_where($primary, $id, $objet, $id_objet, $cond);
666
+
667
+            // lire les liens existants pour propager la date de modif
668
+            $select = "$primary,id_objet,objet";
669
+            if ($colonne_role) {
670
+                $select .= ",$colonne_role";
671
+            }
672
+            $liens = sql_allfetsel($select, $table_lien, $where);
673
+
674
+            // iterer sur les liens pour permettre aux plugins de gerer
675
+            foreach ($liens as $l) {
676
+                $args = [
677
+                    'table_lien' => $table_lien,
678
+                    'objet_source' => $objet_source,
679
+                    'id_objet_source' => $l[$primary],
680
+                    'objet' => $l['objet'],
681
+                    'id_objet' => $l['id_objet'],
682
+                    'colonne_role' => $colonne_role,
683
+                    'role' => ($colonne_role ? $l[$colonne_role] : ''),
684
+                    'action' => 'delete',
685
+                ];
686
+
687
+                // Envoyer aux plugins
688
+                $l = pipeline(
689
+                    'pre_edition_lien',
690
+                    [
691
+                        'args' => $args,
692
+                        'data' => $l
693
+                    ]
694
+                );
695
+                $args['id_objet'] = $id_o = $l['id_objet'];
696
+
697
+                if (($id_o = (int) $l['id_objet']) || in_array($l['objet'], ['site', 'rubrique'])) {
698
+                    $where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond);
699
+                    $e = sql_delete($table_lien, $where);
700
+                    if ($e !== false) {
701
+                        $dels += $e;
702
+                        lien_propage_date_modif($l['objet'], $id_o);
703
+                        lien_propage_date_modif($objet_source, $l[$primary]);
704
+                    } else {
705
+                        $echec = true;
706
+                    }
707
+                    $retire[] = [
708
+                        'source' => [$objet_source => $l[$primary]],
709
+                        'lien' => [$l['objet'] => $id_o],
710
+                        'type' => $l['objet'],
711
+                        'role' => ($colonne_role ? $l[$colonne_role] : ''),
712
+                        'id' => $id_o
713
+                    ];
714
+                    // Envoyer aux plugins
715
+                    pipeline(
716
+                        'post_edition_lien',
717
+                        [
718
+                            'args' => $args,
719
+                            'data' => $l
720
+                        ]
721
+                    );
722
+                }
723
+            }
724
+        }
725
+    }
726
+    // si on a supprime des liens, on reordonne les liens concernes
727
+    if ($dels) {
728
+        lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
729
+    }
730
+
731
+    pipeline('trig_supprimer_objets_lies', $retire);
732
+
733
+    return ($echec ? false : $dels);
734 734
 }
735 735
 
736 736
 
@@ -753,67 +753,67 @@  discard block
 block discarded – undo
753 753
  * @return bool|int
754 754
  */
755 755
 function lien_optimise($objet_source, $primary, $table_lien, $id, $objets) {
756
-	include_spip('genie/optimiser');
757
-	$echec = false;
758
-	$dels = 0;
759
-	foreach ($objets as $objet => $id_objets) {
760
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
761
-		if (!is_array($id_objets) || reset($id_objets) == 'NOT') {
762
-			$id_objets = [$id_objets];
763
-		}
764
-		foreach ($id_objets as $id_objet) {
765
-			$where = lien_where($primary, $id, $objet, $id_objet);
766
-			# les liens vers un objet inexistant
767
-			$r = sql_select('DISTINCT objet', $table_lien, $where);
768
-			while ($t = sql_fetch($r)) {
769
-				$type = $t['objet'];
770
-				$spip_table_objet = table_objet_sql($type);
771
-				$id_table_objet = id_table_objet($type);
772
-				$res = sql_select(
773
-					"L.$primary AS id,L.id_objet",
774
-					// la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
775
-					// du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
776
-					// il faut les eliminier en repetant la condition dans le where L.objet='xxx'
777
-					"$table_lien AS L
756
+    include_spip('genie/optimiser');
757
+    $echec = false;
758
+    $dels = 0;
759
+    foreach ($objets as $objet => $id_objets) {
760
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
761
+        if (!is_array($id_objets) || reset($id_objets) == 'NOT') {
762
+            $id_objets = [$id_objets];
763
+        }
764
+        foreach ($id_objets as $id_objet) {
765
+            $where = lien_where($primary, $id, $objet, $id_objet);
766
+            # les liens vers un objet inexistant
767
+            $r = sql_select('DISTINCT objet', $table_lien, $where);
768
+            while ($t = sql_fetch($r)) {
769
+                $type = $t['objet'];
770
+                $spip_table_objet = table_objet_sql($type);
771
+                $id_table_objet = id_table_objet($type);
772
+                $res = sql_select(
773
+                    "L.$primary AS id,L.id_objet",
774
+                    // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
775
+                    // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
776
+                    // il faut les eliminier en repetant la condition dans le where L.objet='xxx'
777
+                    "$table_lien AS L
778 778
 									LEFT JOIN $spip_table_objet AS O
779 779
 										ON (O.$id_table_objet=L.id_objet AND L.objet=" . sql_quote($type) . ')',
780
-					'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL"
781
-				);
782
-				// sur une cle primaire composee, pas d'autres solutions que de virer un a un
783
-				while ($row = sql_fetch($res)) {
784
-					if ($primary === 'id_document' && in_array($type, ['site', 'rubrique']) && !(int) $row['id_objet']) {
785
-						continue; // gaffe, c'est le logo du site ou des rubriques!
786
-					}
787
-					$e = sql_delete(
788
-						$table_lien,
789
-						["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)]
790
-					);
791
-					if ($e != false) {
792
-						$dels += $e;
793
-						spip_log(
794
-							'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien",
795
-							'genie' . _LOG_INFO_IMPORTANTE
796
-						);
797
-					}
798
-				}
799
-			}
800
-
801
-			# les liens depuis un objet inexistant
802
-			$table_source = table_objet_sql($objet_source);
803
-			// filtrer selon $id, $objet, $id_objet eventuellement fournis
804
-			// (en general '*' pour chaque)
805
-			$where = lien_where("L.$primary", $id, $objet, $id_objet);
806
-			$where[] = "O.$primary IS NULL";
807
-			$res = sql_select(
808
-				"L.$primary AS id",
809
-				"$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
810
-				$where
811
-			);
812
-			$dels += optimiser_sansref($table_lien, $primary, $res);
813
-		}
814
-	}
815
-
816
-	return ($echec ? false : $dels);
780
+                    'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL"
781
+                );
782
+                // sur une cle primaire composee, pas d'autres solutions que de virer un a un
783
+                while ($row = sql_fetch($res)) {
784
+                    if ($primary === 'id_document' && in_array($type, ['site', 'rubrique']) && !(int) $row['id_objet']) {
785
+                        continue; // gaffe, c'est le logo du site ou des rubriques!
786
+                    }
787
+                    $e = sql_delete(
788
+                        $table_lien,
789
+                        ["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)]
790
+                    );
791
+                    if ($e != false) {
792
+                        $dels += $e;
793
+                        spip_log(
794
+                            'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien",
795
+                            'genie' . _LOG_INFO_IMPORTANTE
796
+                        );
797
+                    }
798
+                }
799
+            }
800
+
801
+            # les liens depuis un objet inexistant
802
+            $table_source = table_objet_sql($objet_source);
803
+            // filtrer selon $id, $objet, $id_objet eventuellement fournis
804
+            // (en general '*' pour chaque)
805
+            $where = lien_where("L.$primary", $id, $objet, $id_objet);
806
+            $where[] = "O.$primary IS NULL";
807
+            $res = sql_select(
808
+                "L.$primary AS id",
809
+                "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
810
+                $where
811
+            );
812
+            $dels += optimiser_sansref($table_lien, $primary, $res);
813
+        }
814
+    }
815
+
816
+    return ($echec ? false : $dels);
817 817
 }
818 818
 
819 819
 
@@ -845,92 +845,92 @@  discard block
 block discarded – undo
845 845
  *     Nombre de modifications faites, false si échec.
846 846
  */
847 847
 function lien_set($objet_source, $primary, $table_lien, $id, $objets, $qualif) {
848
-	$echec = null;
849
-	$ok = 0;
850
-	$reordonner = false;
851
-	if (!$qualif) {
852
-		return false;
853
-	}
854
-	// nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
855
-	unset($qualif[$primary]);
856
-	unset($qualif[$objet_source]);
857
-	if (isset($qualif['objet'])) {
858
-		unset($qualif[$qualif['objet']]);
859
-	}
860
-	unset($qualif['objet']);
861
-	unset($qualif['id_objet']);
862
-	foreach ($objets as $objet => $id_objets) {
863
-		// role, colonne, where par défaut
864
-		[$role, $colonne_role, $cond] =
865
-			roles_trouver_dans_qualif($objet_source, $objet, $qualif);
866
-
867
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
868
-		if (!is_array($id_objets) || reset($id_objets) == 'NOT') {
869
-			$id_objets = [$id_objets];
870
-		}
871
-		foreach ($id_objets as $id_objet) {
872
-			$args = [
873
-				'table_lien' => $table_lien,
874
-				'objet_source' => $objet_source,
875
-				'id_objet_source' => $id,
876
-				'objet' => $objet,
877
-				'id_objet' => $id_objet,
878
-				'role' => $role,
879
-				'colonne_role' => $colonne_role,
880
-				'action' => 'modifier',
881
-			];
882
-
883
-			// Envoyer aux plugins
884
-			$qualif = pipeline(
885
-				'pre_edition_lien',
886
-				[
887
-					'args' => $args,
888
-					'data' => $qualif,
889
-				]
890
-			);
891
-			$args['id_objet'] = $id_objet;
892
-
893
-			if (lien_triables($table_lien) && isset($qualif['rang_lien'])) {
894
-				if ((int) $qualif['rang_lien']) {
895
-					// on decale les liens de rang_lien>=la valeur inseree pour faire la place
896
-					// sauf sur le meme lien avec un role eventuellement different
897
-					$where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
898
-					$where_meme_lien = implode(' AND ', $where_meme_lien);
899
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . (int) $qualif['rang_lien'], "NOT($where_meme_lien)"]);
900
-					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
901
-				}
902
-				// tous les liens de même rôle recoivent le rang indiqué aussi
903
-				if (roles_colonne($objet_source, $objet)) {
904
-					$w = lien_where($primary, $id, $objet, $id_objet);
905
-					sql_updateq($table_lien, ['rang_lien' => (int) $qualif['rang_lien']], $w);
906
-				}
907
-				$reordonner = true;
908
-			}
909
-
910
-			$where = lien_where($primary, $id, $objet, $id_objet, $cond);
911
-			$e = sql_updateq($table_lien, $qualif, $where);
912
-
913
-			if ($e === false) {
914
-				$echec = true;
915
-			} else {
916
-				// Envoyer aux plugins
917
-				pipeline(
918
-					'post_edition_lien',
919
-					[
920
-						'args' => $args,
921
-						'data' => $qualif
922
-					]
923
-				);
924
-				$ok++;
925
-			}
926
-		}
927
-	}
928
-	// si on a fait des modif de rang, on reordonne les liens concernes
929
-	if ($reordonner) {
930
-		lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
931
-	}
932
-
933
-	return ($echec ? false : $ok);
848
+    $echec = null;
849
+    $ok = 0;
850
+    $reordonner = false;
851
+    if (!$qualif) {
852
+        return false;
853
+    }
854
+    // nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
855
+    unset($qualif[$primary]);
856
+    unset($qualif[$objet_source]);
857
+    if (isset($qualif['objet'])) {
858
+        unset($qualif[$qualif['objet']]);
859
+    }
860
+    unset($qualif['objet']);
861
+    unset($qualif['id_objet']);
862
+    foreach ($objets as $objet => $id_objets) {
863
+        // role, colonne, where par défaut
864
+        [$role, $colonne_role, $cond] =
865
+            roles_trouver_dans_qualif($objet_source, $objet, $qualif);
866
+
867
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
868
+        if (!is_array($id_objets) || reset($id_objets) == 'NOT') {
869
+            $id_objets = [$id_objets];
870
+        }
871
+        foreach ($id_objets as $id_objet) {
872
+            $args = [
873
+                'table_lien' => $table_lien,
874
+                'objet_source' => $objet_source,
875
+                'id_objet_source' => $id,
876
+                'objet' => $objet,
877
+                'id_objet' => $id_objet,
878
+                'role' => $role,
879
+                'colonne_role' => $colonne_role,
880
+                'action' => 'modifier',
881
+            ];
882
+
883
+            // Envoyer aux plugins
884
+            $qualif = pipeline(
885
+                'pre_edition_lien',
886
+                [
887
+                    'args' => $args,
888
+                    'data' => $qualif,
889
+                ]
890
+            );
891
+            $args['id_objet'] = $id_objet;
892
+
893
+            if (lien_triables($table_lien) && isset($qualif['rang_lien'])) {
894
+                if ((int) $qualif['rang_lien']) {
895
+                    // on decale les liens de rang_lien>=la valeur inseree pour faire la place
896
+                    // sauf sur le meme lien avec un role eventuellement different
897
+                    $where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
898
+                    $where_meme_lien = implode(' AND ', $where_meme_lien);
899
+                    $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . (int) $qualif['rang_lien'], "NOT($where_meme_lien)"]);
900
+                    sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
901
+                }
902
+                // tous les liens de même rôle recoivent le rang indiqué aussi
903
+                if (roles_colonne($objet_source, $objet)) {
904
+                    $w = lien_where($primary, $id, $objet, $id_objet);
905
+                    sql_updateq($table_lien, ['rang_lien' => (int) $qualif['rang_lien']], $w);
906
+                }
907
+                $reordonner = true;
908
+            }
909
+
910
+            $where = lien_where($primary, $id, $objet, $id_objet, $cond);
911
+            $e = sql_updateq($table_lien, $qualif, $where);
912
+
913
+            if ($e === false) {
914
+                $echec = true;
915
+            } else {
916
+                // Envoyer aux plugins
917
+                pipeline(
918
+                    'post_edition_lien',
919
+                    [
920
+                        'args' => $args,
921
+                        'data' => $qualif
922
+                    ]
923
+                );
924
+                $ok++;
925
+            }
926
+        }
927
+    }
928
+    // si on a fait des modif de rang, on reordonne les liens concernes
929
+    if ($reordonner) {
930
+        lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
931
+    }
932
+
933
+    return ($echec ? false : $ok);
934 934
 }
935 935
 
936 936
 /**
@@ -960,23 +960,23 @@  discard block
 block discarded – undo
960 960
  * @return array
961 961
  */
962 962
 function lien_find($objet_source, $primary, $table_lien, $id, $objets, $cond = null) {
963
-	$trouve = [];
964
-	foreach ($objets as $objet => $id_objets) {
965
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
966
-		// gerer les roles s'il y en a dans $cond
967
-		[$cond] = roles_creer_condition_role($objet_source, $objet, $cond, true);
968
-		// lien_where prend en charge les $id_objets sous forme int ou array
969
-		$where = lien_where($primary, $id, $objet, $id_objets, $cond);
970
-		$liens = sql_allfetsel('*', $table_lien, $where);
971
-		// ajouter les entrees objet_source et objet cible par convenance
972
-		foreach ($liens as $l) {
973
-			$l[$objet_source] = $l[$primary];
974
-			$l[$l['objet']] = $l['id_objet'];
975
-			$trouve[] = $l;
976
-		}
977
-	}
978
-
979
-	return $trouve;
963
+    $trouve = [];
964
+    foreach ($objets as $objet => $id_objets) {
965
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
966
+        // gerer les roles s'il y en a dans $cond
967
+        [$cond] = roles_creer_condition_role($objet_source, $objet, $cond, true);
968
+        // lien_where prend en charge les $id_objets sous forme int ou array
969
+        $where = lien_where($primary, $id, $objet, $id_objets, $cond);
970
+        $liens = sql_allfetsel('*', $table_lien, $where);
971
+        // ajouter les entrees objet_source et objet cible par convenance
972
+        foreach ($liens as $l) {
973
+            $l[$objet_source] = $l[$primary];
974
+            $l[$l['objet']] = $l['id_objet'];
975
+            $trouve[] = $l;
976
+        }
977
+    }
978
+
979
+    return $trouve;
980 980
 }
981 981
 
982 982
 /**
@@ -987,25 +987,25 @@  discard block
 block discarded – undo
987 987
  * @param array|int $ids
988 988
  */
989 989
 function lien_propage_date_modif($objet, $ids) {
990
-	static $done = [];
991
-	$hash = md5($objet . serialize($ids));
992
-
993
-	// sql_updateq, peut être un rien lent.
994
-	// On évite de l'appeler 2 fois sur les mêmes choses
995
-	if (isset($done[$hash])) {
996
-		return;
997
-	}
998
-
999
-	$trouver_table = charger_fonction('trouver_table', 'base');
1000
-
1001
-	$table = table_objet_sql($objet);
1002
-	if (
1003
-		($desc = $trouver_table($table)) && isset($desc['field']['date_modif'])
1004
-	) {
1005
-		$primary = id_table_objet($objet);
1006
-		$where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . (int) $ids);
1007
-		sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where);
1008
-	}
1009
-
1010
-	$done[$hash] = true;
990
+    static $done = [];
991
+    $hash = md5($objet . serialize($ids));
992
+
993
+    // sql_updateq, peut être un rien lent.
994
+    // On évite de l'appeler 2 fois sur les mêmes choses
995
+    if (isset($done[$hash])) {
996
+        return;
997
+    }
998
+
999
+    $trouver_table = charger_fonction('trouver_table', 'base');
1000
+
1001
+    $table = table_objet_sql($objet);
1002
+    if (
1003
+        ($desc = $trouver_table($table)) && isset($desc['field']['date_modif'])
1004
+    ) {
1005
+        $primary = id_table_objet($objet);
1006
+        $where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . (int) $ids);
1007
+        sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where);
1008
+    }
1009
+
1010
+    $done[$hash] = true;
1011 1011
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	$l = '';
53 53
 	if (
54 54
 		($primary = id_table_objet($objet))
55
-		&& $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false])
55
+		&& $trouver_table($l = $table_sql.'_liens', '', true, ['log_missing' => false])
56 56
 		&& !preg_match(',[^\w],', $primary)
57 57
 		&& !preg_match(',[^\w],', $l)
58 58
 	) {
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
  * @return int
212 212
  */
213 213
 function objet_optimiser_liens($objets_source, $objets_lies) {
214
-	spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG);
214
+	spip_log('objet_optimiser_liens : '.json_encode($objets_source, JSON_THROW_ON_ERROR).', '.json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie'._LOG_DEBUG);
215 215
 	return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies);
216 216
 }
217 217
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 					$where_meme_lien = implode(' AND ', $where_meme_lien);
438 438
 					// on decale les liens de rang_lien>=la valeur inseree pour faire la place
439 439
 					// sauf sur le meme lien avec un role eventuellement different
440
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . (int) $insertions['rang_lien'], "NOT($where_meme_lien)"]);
440
+					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>='.(int) $insertions['rang_lien'], "NOT($where_meme_lien)"]);
441 441
 					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
442 442
 				}
443 443
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 					$rang = 1;
503 503
 					foreach ($liens as $lien) {
504 504
 						if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) {
505
-							$where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . (int) $rang]);
505
+							$where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!='.(int) $rang]);
506 506
 							sql_updateq($table_lien, ['rang_lien' => $rang], $where);
507 507
 
508 508
 							if (empty($deja_reordonne[$lien[$primary]])) {
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 			addslashes($primary),
572 572
 			array_map('intval', $id_source),
573 573
 			$not
574
-		) : addslashes($primary) . ($not ? '<>' : '=') . (int) $id_source);
574
+		) : addslashes($primary).($not ? '<>' : '=').(int) $id_source);
575 575
 	} elseif ($not) {
576 576
 		$where[] = '0=1';
577 577
 	} // idiot mais quand meme
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	}
584 584
 
585 585
 	if ($objet !== '*') {
586
-		$where[] = 'objet=' . sql_quote($objet);
586
+		$where[] = 'objet='.sql_quote($objet);
587 587
 	}
588 588
 	if ($id_objet !== '*') {
589 589
 		$where[] = (is_array($id_objet) ? sql_in(
590 590
 			'id_objet',
591 591
 			array_map('intval', $id_objet),
592 592
 			$not
593
-		) : 'id_objet' . ($not ? '<>' : '=') . (int) $id_objet);
593
+		) : 'id_objet'.($not ? '<>' : '=').(int) $id_objet);
594 594
 	} elseif ($not) {
595 595
 		$where[] = '0=1';
596 596
 	} // idiot mais quand meme
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 function lien_rang_where($table_lien, $primary, $id_source, $objet, $id_objet, $cond = []) {
612 612
 
613 613
 	// si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc
614
-	if (function_exists($f = 'lien_rang_where_' . $table_lien)) {
614
+	if (function_exists($f = 'lien_rang_where_'.$table_lien)) {
615 615
 		return $f($primary, $id_source, $objet, $id_objet, $cond);
616 616
 	}
617 617
 
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 					// il faut les eliminier en repetant la condition dans le where L.objet='xxx'
777 777
 					"$table_lien AS L
778 778
 									LEFT JOIN $spip_table_objet AS O
779
-										ON (O.$id_table_objet=L.id_objet AND L.objet=" . sql_quote($type) . ')',
780
-					'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL"
779
+										ON (O.$id_table_objet=L.id_objet AND L.objet=".sql_quote($type).')',
780
+					'L.objet='.sql_quote($type)." AND O.$id_table_objet IS NULL"
781 781
 				);
782 782
 				// sur une cle primaire composee, pas d'autres solutions que de virer un a un
783 783
 				while ($row = sql_fetch($res)) {
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
 					}
787 787
 					$e = sql_delete(
788 788
 						$table_lien,
789
-						["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)]
789
+						["$primary=".$row['id'], 'id_objet='.$row['id_objet'], 'objet='.sql_quote($type)]
790 790
 					);
791 791
 					if ($e != false) {
792 792
 						$dels += $e;
793 793
 						spip_log(
794
-							'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien",
795
-							'genie' . _LOG_INFO_IMPORTANTE
794
+							'lien_optimise: Entree '.$row['id'].'/'.$row['id_objet']."/$type supprimee dans la table $table_lien",
795
+							'genie'._LOG_INFO_IMPORTANTE
796 796
 						);
797 797
 					}
798 798
 				}
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 					// sauf sur le meme lien avec un role eventuellement different
897 897
 					$where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
898 898
 					$where_meme_lien = implode(' AND ', $where_meme_lien);
899
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . (int) $qualif['rang_lien'], "NOT($where_meme_lien)"]);
899
+					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>='.(int) $qualif['rang_lien'], "NOT($where_meme_lien)"]);
900 900
 					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
901 901
 				}
902 902
 				// tous les liens de même rôle recoivent le rang indiqué aussi
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
  */
989 989
 function lien_propage_date_modif($objet, $ids) {
990 990
 	static $done = [];
991
-	$hash = md5($objet . serialize($ids));
991
+	$hash = md5($objet.serialize($ids));
992 992
 
993 993
 	// sql_updateq, peut être un rien lent.
994 994
 	// On évite de l'appeler 2 fois sur les mêmes choses
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 		($desc = $trouver_table($table)) && isset($desc['field']['date_modif'])
1004 1004
 	) {
1005 1005
 		$primary = id_table_objet($objet);
1006
-		$where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . (int) $ids);
1006
+		$where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=".(int) $ids);
1007 1007
 		sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where);
1008 1008
 	}
1009 1009
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -390,8 +390,7 @@
 block discarded – undo
390 390
 			if (lien_triables($table_lien)) {
391 391
 				if (isset($qualif['rang_lien'])) {
392 392
 					$rang = $qualif['rang_lien'];
393
-				}
394
-				else {
393
+				} else {
395 394
 					$where = lien_where($primary, $id, $objet, $id_objet);
396 395
 					// si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul
397 396
 					if (!$rang = (int) sql_getfetsel('rang_lien', $table_lien, $where)) {
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_rubrique.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -24,41 +24,41 @@  discard block
 block discarded – undo
24 24
  **/
25 25
 function action_instituer_langue_rubrique_dist() {
26 26
 
27
-	$securiser_action = charger_fonction('securiser_action', 'inc');
28
-	$arg = $securiser_action();
29
-	$changer_lang = _request('changer_lang');
27
+    $securiser_action = charger_fonction('securiser_action', 'inc');
28
+    $arg = $securiser_action();
29
+    $changer_lang = _request('changer_lang');
30 30
 
31
-	[$id_rubrique, $id_parent] = preg_split('/\W/', (string) $arg);
31
+    [$id_rubrique, $id_parent] = preg_split('/\W/', (string) $arg);
32 32
 
33
-	if (
34
-		$changer_lang
35
-		&& $id_rubrique > 0
36
-		&& $GLOBALS['meta']['multi_rubriques'] == 'oui'
37
-		&& ($GLOBALS['meta']['multi_secteurs'] == 'non' || $id_parent == 0)
38
-	) {
39
-		if ($changer_lang != 'herit') {
40
-			sql_updateq(
41
-				'spip_rubriques',
42
-				['lang' => $changer_lang, 'langue_choisie' => 'oui'],
43
-				"id_rubrique=$id_rubrique"
44
-			);
45
-		} else {
46
-			if ($id_parent == 0) {
47
-				$langue_parent = $GLOBALS['meta']['langue_site'];
48
-			} else {
49
-				$langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent");
50
-			}
51
-			sql_updateq(
52
-				'spip_rubriques',
53
-				['lang' => $langue_parent, 'langue_choisie' => 'non'],
54
-				"id_rubrique=$id_rubrique"
55
-			);
56
-		}
57
-		include_spip('inc/rubriques');
58
-		calculer_langues_rubriques();
33
+    if (
34
+        $changer_lang
35
+        && $id_rubrique > 0
36
+        && $GLOBALS['meta']['multi_rubriques'] == 'oui'
37
+        && ($GLOBALS['meta']['multi_secteurs'] == 'non' || $id_parent == 0)
38
+    ) {
39
+        if ($changer_lang != 'herit') {
40
+            sql_updateq(
41
+                'spip_rubriques',
42
+                ['lang' => $changer_lang, 'langue_choisie' => 'oui'],
43
+                "id_rubrique=$id_rubrique"
44
+            );
45
+        } else {
46
+            if ($id_parent == 0) {
47
+                $langue_parent = $GLOBALS['meta']['langue_site'];
48
+            } else {
49
+                $langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent");
50
+            }
51
+            sql_updateq(
52
+                'spip_rubriques',
53
+                ['lang' => $langue_parent, 'langue_choisie' => 'non'],
54
+                "id_rubrique=$id_rubrique"
55
+            );
56
+        }
57
+        include_spip('inc/rubriques');
58
+        calculer_langues_rubriques();
59 59
 
60
-		// invalider les caches marques de cette rubrique
61
-		include_spip('inc/invalideur');
62
-		suivre_invalideur("id='rubrique/$id_rubrique'");
63
-	}
60
+        // invalider les caches marques de cette rubrique
61
+        include_spip('inc/invalideur');
62
+        suivre_invalideur("id='rubrique/$id_rubrique'");
63
+    }
64 64
 }
Please login to merge, or discard this patch.