Completed
Push — master ( 8ac1c9...4b0d59 )
by cam
01:18
created
ecrire/plugins/afficher_repertoires.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 				$id = substr(md5($plug), 0, 16);
61 61
 				$res .= $ligne_plug(
62 62
 					$url_page,
63
-					str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug),
63
+					str_replace(_DIR_PLUGINS, '', _DIR_RACINE.$plug),
64 64
 					$actif,
65 65
 					'menu-entree'
66
-				) . "\n";
66
+				)."\n";
67 67
 				unset($liste_plugins[$key]);
68 68
 			}
69 69
 		}
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	$chemin = '';
107 107
 	if (count($tcom)) {
108
-		$chemin .= implode('/', $tcom) . '/';
108
+		$chemin .= implode('/', $tcom).'/';
109 109
 	}
110 110
 	// ouvrir les repertoires jusqu'a la cible
111 111
 	while ($open = array_shift($ttarg)) {
112
-		$visible = @isset($deplie[$chemin . $open]);
113
-		$chemin .= $open . '/';
112
+		$visible = @isset($deplie[$chemin.$open]);
113
+		$chemin .= $open.'/';
114 114
 		$output .= '<li>';
115 115
 		$output .= bouton_block_depliable($chemin, $visible);
116 116
 		$output .= debut_block_depliable($visible);
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -11,110 +11,110 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function plugins_afficher_repertoires_dist($url_page, $liste_plugins, $liste_plugins_actifs) {
18
-	$ligne_plug = charger_fonction('afficher_plugin', 'plugins');
19
-	$racine = basename(_DIR_PLUGINS);
20
-	$init_dir = $current_dir = '';
21
-	// liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
22
-	// des qu'un path est deja note deplie on s'arrete
23
-	$deplie = [$racine => true];
24
-	$fast_liste_plugins_actifs = [];
25
-	foreach ($liste_plugins_actifs as $key => $plug) {
26
-		$chemin_plug = chemin_plug($racine, $plug);
27
-		$fast_liste_plugins_actifs[$chemin_plug] = true;
28
-		$dir = dirname($chemin_plug);
29
-		$maxiter = 100;
30
-		while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) {
31
-			$deplie[$dir] = true;
32
-			$dir = dirname($dir);
33
-		}
34
-	}
18
+    $ligne_plug = charger_fonction('afficher_plugin', 'plugins');
19
+    $racine = basename(_DIR_PLUGINS);
20
+    $init_dir = $current_dir = '';
21
+    // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
22
+    // des qu'un path est deja note deplie on s'arrete
23
+    $deplie = [$racine => true];
24
+    $fast_liste_plugins_actifs = [];
25
+    foreach ($liste_plugins_actifs as $key => $plug) {
26
+        $chemin_plug = chemin_plug($racine, $plug);
27
+        $fast_liste_plugins_actifs[$chemin_plug] = true;
28
+        $dir = dirname($chemin_plug);
29
+        $maxiter = 100;
30
+        while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) {
31
+            $deplie[$dir] = true;
32
+            $dir = dirname($dir);
33
+        }
34
+    }
35 35
 
36
-	// index repertoires --> plugin
37
-	$dir_index = [];
38
-	foreach ($liste_plugins as $key => $plug) {
39
-		$liste_plugins[$key] = chemin_plug($racine, $plug);
40
-		$dir_index[dirname($liste_plugins[$key])][] = $key;
41
-	}
36
+    // index repertoires --> plugin
37
+    $dir_index = [];
38
+    foreach ($liste_plugins as $key => $plug) {
39
+        $liste_plugins[$key] = chemin_plug($racine, $plug);
40
+        $dir_index[dirname($liste_plugins[$key])][] = $key;
41
+    }
42 42
 
43
-	$visible = @isset($deplie[$current_dir]);
44
-	$maxiter = 1000;
43
+    $visible = @isset($deplie[$current_dir]);
44
+    $maxiter = 1000;
45 45
 
46
-	$res = '';
47
-	while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) {
48
-		// le rep suivant
49
-		$dir = dirname(reset($liste_plugins));
50
-		if ($dir != $current_dir) {
51
-			$res .= tree_open_close_dir($current_dir, $dir, $deplie);
52
-		}
46
+    $res = '';
47
+    while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) {
48
+        // le rep suivant
49
+        $dir = dirname(reset($liste_plugins));
50
+        if ($dir != $current_dir) {
51
+            $res .= tree_open_close_dir($current_dir, $dir, $deplie);
52
+        }
53 53
 
54
-		// d'abord tous les plugins du rep courant
55
-		if (isset($dir_index[$current_dir])) {
56
-			foreach ($dir_index[$current_dir] as $key) {
57
-				$plug = $liste_plugins[$key];
58
-				$actif = @isset($fast_liste_plugins_actifs[$plug]);
59
-				$id = substr(md5($plug), 0, 16);
60
-				$res .= $ligne_plug(
61
-					$url_page,
62
-					str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug),
63
-					$actif,
64
-					'menu-entree'
65
-				) . "\n";
66
-				unset($liste_plugins[$key]);
67
-			}
68
-		}
69
-	}
70
-	$res .= tree_open_close_dir($current_dir, $init_dir, true);
54
+        // d'abord tous les plugins du rep courant
55
+        if (isset($dir_index[$current_dir])) {
56
+            foreach ($dir_index[$current_dir] as $key) {
57
+                $plug = $liste_plugins[$key];
58
+                $actif = @isset($fast_liste_plugins_actifs[$plug]);
59
+                $id = substr(md5($plug), 0, 16);
60
+                $res .= $ligne_plug(
61
+                    $url_page,
62
+                    str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug),
63
+                    $actif,
64
+                    'menu-entree'
65
+                ) . "\n";
66
+                unset($liste_plugins[$key]);
67
+            }
68
+        }
69
+    }
70
+    $res .= tree_open_close_dir($current_dir, $init_dir, true);
71 71
 
72
-	return "<ul class='menu-liste plugins'>"
73
-	. $res
74
-	. '</ul>';
72
+    return "<ul class='menu-liste plugins'>"
73
+    . $res
74
+    . '</ul>';
75 75
 }
76 76
 
77 77
 
78 78
 // vraiment n'importe quoi la gestion des chemins des plugins
79 79
 // une fonction pour aider...
80 80
 function chemin_plug($racine, $plug) {
81
-	return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
81
+    return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
82 82
 }
83 83
 
84 84
 function tree_open_close_dir(&$current, $target, $deplie = []) {
85
-	if ($current == $target) {
86
-		return '';
87
-	}
88
-	$tcur = explode('/', $current);
89
-	$ttarg = explode('/', $target);
90
-	$tcom = [];
91
-	$output = '';
92
-	// la partie commune
93
-	while (reset($tcur) == reset($ttarg)) {
94
-		$tcom[] = array_shift($tcur);
95
-		array_shift($ttarg);
96
-	}
97
-	// fermer les repertoires courant jusqu'au point de fork
98
-	while ($close = array_pop($tcur)) {
99
-		$output .= "</ul>\n";
100
-		$output .= fin_block();
101
-		$output .= "</li>\n";
102
-	}
103
-	$chemin = '';
104
-	if (count($tcom)) {
105
-		$chemin .= implode('/', $tcom) . '/';
106
-	}
107
-	// ouvrir les repertoires jusqu'a la cible
108
-	while ($open = array_shift($ttarg)) {
109
-		$visible = @isset($deplie[$chemin . $open]);
110
-		$chemin .= $open . '/';
111
-		$output .= '<li>';
112
-		$output .= bouton_block_depliable($chemin, $visible);
113
-		$output .= debut_block_depliable($visible);
85
+    if ($current == $target) {
86
+        return '';
87
+    }
88
+    $tcur = explode('/', $current);
89
+    $ttarg = explode('/', $target);
90
+    $tcom = [];
91
+    $output = '';
92
+    // la partie commune
93
+    while (reset($tcur) == reset($ttarg)) {
94
+        $tcom[] = array_shift($tcur);
95
+        array_shift($ttarg);
96
+    }
97
+    // fermer les repertoires courant jusqu'au point de fork
98
+    while ($close = array_pop($tcur)) {
99
+        $output .= "</ul>\n";
100
+        $output .= fin_block();
101
+        $output .= "</li>\n";
102
+    }
103
+    $chemin = '';
104
+    if (count($tcom)) {
105
+        $chemin .= implode('/', $tcom) . '/';
106
+    }
107
+    // ouvrir les repertoires jusqu'a la cible
108
+    while ($open = array_shift($ttarg)) {
109
+        $visible = @isset($deplie[$chemin . $open]);
110
+        $chemin .= $open . '/';
111
+        $output .= '<li>';
112
+        $output .= bouton_block_depliable($chemin, $visible);
113
+        $output .= debut_block_depliable($visible);
114 114
 
115
-		$output .= "<ul>\n";
116
-	}
117
-	$current = $target;
115
+        $output .= "<ul>\n";
116
+    }
117
+    $current = $target;
118 118
 
119
-	return $output;
119
+    return $output;
120 120
 }
Please login to merge, or discard this patch.
ecrire/plugins/infos_paquet.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return array
26 26
  */
27 27
 function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) {
28
-	static $process = [ // tableau constant
28
+	static $process = [// tableau constant
29 29
 		'debut' => 'paquet_debutElement',
30 30
 		'fin' => 'paquet_finElement',
31 31
 		'text' => 'paquet_textElement'
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 			unset($tree['']);
48 48
 		}
49 49
 
50
-		$tree['slogan'] = $tree['prefix'] . '_slogan';
51
-		$tree['description'] = $tree['prefix'] . '_description';
50
+		$tree['slogan'] = $tree['prefix'].'_slogan';
51
+		$tree['description'] = $tree['prefix'].'_description';
52 52
 		paquet_readable_files($tree, "$dir_plugins$plug/");
53 53
 		if (!$tree['chemin']) {
54 54
 			$tree['chemin'] = [];
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	// Prendre les messages d'erreur sans les numeros de lignes
81 81
 	$msg = array_column($vxml->err, 0);
82 82
 	$t = _T('plugins_erreur', ['plugins' => $plug]);
83
-	array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>');
83
+	array_unshift($msg, $t." <ul class='erreur_xml'><li>".reset($msg).'</li></ul>');
84 84
 
85 85
 	return ['erreur' => $msg];
86 86
 }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 function paquet_readable_files(&$tree, $dir) {
97 97
 	$prefix = strtolower($tree['prefix']);
98 98
 
99
-	$tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : [];
100
-	$tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : [];
101
-	$tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : [];
99
+	$tree['options'] = (is_readable($dir.$f = ($prefix.'_options.php'))) ? [$f] : [];
100
+	$tree['fonctions'] = (is_readable($dir.$f = ($prefix.'_fonctions.php'))) ? [$f] : [];
101
+	$tree['install'] = (is_readable($dir.$f = ($prefix.'_administrations.php'))) ? [$f] : [];
102 102
 }
103 103
 
104 104
 /**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	$texte = trim($phraseur->versions[$n]['']);
187 187
 	$phraseur->versions[$n][''] = '';
188 188
 
189
-	$f = 'info_paquet_' . $name;
189
+	$f = 'info_paquet_'.$name;
190 190
 	if (function_exists($f)) {
191 191
 		$f($phraseur, $attrs, $texte);
192 192
 	} elseif (!$attrs) {
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -25,64 +25,64 @@  discard block
 block discarded – undo
25 25
  * @return array
26 26
  */
27 27
 function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) {
28
-	static $process = [ // tableau constant
29
-		'debut' => 'paquet_debutElement',
30
-		'fin' => 'paquet_finElement',
31
-		'text' => 'paquet_textElement'
32
-	];
33
-
34
-	$valider_xml = charger_fonction('valider', 'xml');
35
-	$vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8');
36
-	if (!$vxml->err) {
37
-		// On veut toutes les variantes selon la version de SPIP
38
-		if (!$plug) {
39
-			return $vxml->versions;
40
-		}
41
-
42
-		// compatibilite avec l'existant:
43
-		$tree = $vxml->versions['0'];
44
-
45
-		// l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca.
46
-		if (isset($tree['']) and !strlen($tree[''])) {
47
-			unset($tree['']);
48
-		}
49
-
50
-		$tree['slogan'] = $tree['prefix'] . '_slogan';
51
-		$tree['description'] = $tree['prefix'] . '_description';
52
-		paquet_readable_files($tree, "$dir_plugins$plug/");
53
-		if (!$tree['chemin']) {
54
-			$tree['chemin'] = [];
55
-		}
56
-
57
-		// On verifie qu'il existe des balises spip qu'il faudrait rajouter dans
58
-		// la structure d'infos du paquet en fonction de la version spip courante
59
-		if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) {
60
-			$vspip = $GLOBALS['spip_version_branche'];
61
-			foreach ($vxml->versions as $_compatibilite => $_version) {
62
-				if (
63
-					($_version['balise'] == 'spip')
64
-					and (plugin_version_compatible($_compatibilite, $vspip, 'spip'))
65
-				) {
66
-					// on merge les sous-balises de la balise spip compatible avec celles de la
67
-					// balise paquet
68
-					foreach ($_version as $_index => $_balise) {
69
-						if ($_index and $_index != 'balise') {
70
-							$tree[$_index] = array_merge($tree[$_index], $_balise);
71
-						}
72
-					}
73
-				}
74
-			}
75
-		}
76
-
77
-		return $tree;
78
-	}
79
-
80
-	// Prendre les messages d'erreur sans les numeros de lignes
81
-	$msg = array_column($vxml->err, 0);
82
-	$t = _T('plugins_erreur', ['plugins' => $plug]);
83
-	array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>');
84
-
85
-	return ['erreur' => $msg];
28
+    static $process = [ // tableau constant
29
+        'debut' => 'paquet_debutElement',
30
+        'fin' => 'paquet_finElement',
31
+        'text' => 'paquet_textElement'
32
+    ];
33
+
34
+    $valider_xml = charger_fonction('valider', 'xml');
35
+    $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8');
36
+    if (!$vxml->err) {
37
+        // On veut toutes les variantes selon la version de SPIP
38
+        if (!$plug) {
39
+            return $vxml->versions;
40
+        }
41
+
42
+        // compatibilite avec l'existant:
43
+        $tree = $vxml->versions['0'];
44
+
45
+        // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca.
46
+        if (isset($tree['']) and !strlen($tree[''])) {
47
+            unset($tree['']);
48
+        }
49
+
50
+        $tree['slogan'] = $tree['prefix'] . '_slogan';
51
+        $tree['description'] = $tree['prefix'] . '_description';
52
+        paquet_readable_files($tree, "$dir_plugins$plug/");
53
+        if (!$tree['chemin']) {
54
+            $tree['chemin'] = [];
55
+        }
56
+
57
+        // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans
58
+        // la structure d'infos du paquet en fonction de la version spip courante
59
+        if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) {
60
+            $vspip = $GLOBALS['spip_version_branche'];
61
+            foreach ($vxml->versions as $_compatibilite => $_version) {
62
+                if (
63
+                    ($_version['balise'] == 'spip')
64
+                    and (plugin_version_compatible($_compatibilite, $vspip, 'spip'))
65
+                ) {
66
+                    // on merge les sous-balises de la balise spip compatible avec celles de la
67
+                    // balise paquet
68
+                    foreach ($_version as $_index => $_balise) {
69
+                        if ($_index and $_index != 'balise') {
70
+                            $tree[$_index] = array_merge($tree[$_index], $_balise);
71
+                        }
72
+                    }
73
+                }
74
+            }
75
+        }
76
+
77
+        return $tree;
78
+    }
79
+
80
+    // Prendre les messages d'erreur sans les numeros de lignes
81
+    $msg = array_column($vxml->err, 0);
82
+    $t = _T('plugins_erreur', ['plugins' => $plug]);
83
+    array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>');
84
+
85
+    return ['erreur' => $msg];
86 86
 }
87 87
 
88 88
 /**
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
  * @return void
95 95
  */
96 96
 function paquet_readable_files(&$tree, $dir) {
97
-	$prefix = strtolower($tree['prefix']);
97
+    $prefix = strtolower($tree['prefix']);
98 98
 
99
-	$tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : [];
100
-	$tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : [];
101
-	$tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : [];
99
+    $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : [];
100
+    $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : [];
101
+    $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : [];
102 102
 }
103 103
 
104 104
 /**
@@ -115,35 +115,35 @@  discard block
 block discarded – undo
115 115
  * @param array $attrs
116 116
  */
117 117
 function paquet_debutElement($phraseur, $name, $attrs) {
118
-	xml_debutElement($phraseur, $name, $attrs);
119
-	if ($phraseur->err) {
120
-		return;
121
-	}
122
-	if (($name == 'paquet') or ($name == 'spip')) {
123
-		if ($name == 'spip') {
124
-			$n = $attrs['compatibilite'];
125
-			$attrs = [];
126
-		} else {
127
-			$n = '0';
128
-			$phraseur->contenu['paquet'] = $attrs;
129
-			$attrs['menu'] = [];
130
-			$attrs['chemin'] = [];
131
-			$attrs['necessite'] = [];
132
-			$attrs['lib'] = [];
133
-			$attrs['onglet'] = [];
134
-			$attrs['procure'] = [];
135
-			$attrs['pipeline'] = [];
136
-			$attrs['utilise'] = [];
137
-			$attrs['style'] = [];
138
-			$attrs['script'] = [];
139
-			$attrs['genie'] = [];
140
-		}
141
-		$phraseur->contenu['compatible'] = $n;
142
-		$phraseur->versions[$phraseur->contenu['compatible']] = $attrs;
143
-	} else {
144
-		$phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs;
145
-	}
146
-	$phraseur->versions[$phraseur->contenu['compatible']][''] = '';
118
+    xml_debutElement($phraseur, $name, $attrs);
119
+    if ($phraseur->err) {
120
+        return;
121
+    }
122
+    if (($name == 'paquet') or ($name == 'spip')) {
123
+        if ($name == 'spip') {
124
+            $n = $attrs['compatibilite'];
125
+            $attrs = [];
126
+        } else {
127
+            $n = '0';
128
+            $phraseur->contenu['paquet'] = $attrs;
129
+            $attrs['menu'] = [];
130
+            $attrs['chemin'] = [];
131
+            $attrs['necessite'] = [];
132
+            $attrs['lib'] = [];
133
+            $attrs['onglet'] = [];
134
+            $attrs['procure'] = [];
135
+            $attrs['pipeline'] = [];
136
+            $attrs['utilise'] = [];
137
+            $attrs['style'] = [];
138
+            $attrs['script'] = [];
139
+            $attrs['genie'] = [];
140
+        }
141
+        $phraseur->contenu['compatible'] = $n;
142
+        $phraseur->versions[$phraseur->contenu['compatible']] = $attrs;
143
+    } else {
144
+        $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs;
145
+    }
146
+    $phraseur->versions[$phraseur->contenu['compatible']][''] = '';
147 147
 }
148 148
 
149 149
 /**
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
  * @param string $data
156 156
  */
157 157
 function paquet_textElement($phraseur, $data) {
158
-	xml_textElement($phraseur, $data);
159
-	if ($phraseur->err or !(trim($data))) {
160
-		return;
161
-	}
162
-	$phraseur->versions[$phraseur->contenu['compatible']][''] .= $data;
158
+    xml_textElement($phraseur, $data);
159
+    if ($phraseur->err or !(trim($data))) {
160
+        return;
161
+    }
162
+    $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data;
163 163
 }
164 164
 
165 165
 /**
@@ -171,32 +171,32 @@  discard block
 block discarded – undo
171 171
  * @param string $name
172 172
  */
173 173
 function paquet_finElement($phraseur, $name) {
174
-	if ($phraseur->err) {
175
-		return;
176
-	}
177
-	$n = $phraseur->contenu['compatible'];
178
-
179
-	if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) {
180
-		$attrs = $phraseur->versions[$n][$name][0];
181
-		unset($phraseur->versions[$n][$name][0]);
182
-	} else {
183
-		$attrs = [];
184
-	}
185
-
186
-	$texte = trim($phraseur->versions[$n]['']);
187
-	$phraseur->versions[$n][''] = '';
188
-
189
-	$f = 'info_paquet_' . $name;
190
-	if (function_exists($f)) {
191
-		$f($phraseur, $attrs, $texte);
192
-	} elseif (!$attrs) {
193
-		$phraseur->versions[$n][$name] = $texte;
194
-	} else {
195
-		// Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici
196
-		$phraseur->versions[$n][$name][$attrs['nom']] = $attrs;
197
-		#	  echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]);
198
-	}
199
-	xml_finElement($phraseur, $name, $attrs);
174
+    if ($phraseur->err) {
175
+        return;
176
+    }
177
+    $n = $phraseur->contenu['compatible'];
178
+
179
+    if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) {
180
+        $attrs = $phraseur->versions[$n][$name][0];
181
+        unset($phraseur->versions[$n][$name][0]);
182
+    } else {
183
+        $attrs = [];
184
+    }
185
+
186
+    $texte = trim($phraseur->versions[$n]['']);
187
+    $phraseur->versions[$n][''] = '';
188
+
189
+    $f = 'info_paquet_' . $name;
190
+    if (function_exists($f)) {
191
+        $f($phraseur, $attrs, $texte);
192
+    } elseif (!$attrs) {
193
+        $phraseur->versions[$n][$name] = $texte;
194
+    } else {
195
+        // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici
196
+        $phraseur->versions[$n][$name][$attrs['nom']] = $attrs;
197
+        #	  echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]);
198
+    }
199
+    xml_finElement($phraseur, $name, $attrs);
200 200
 }
201 201
 
202 202
 /**
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
  * @param string $texte
209 209
  */
210 210
 function info_paquet_licence($phraseur, $attrs, $texte) {
211
-	if (isset($attrs['lien'])) {
212
-		$lien = $attrs['lien'];
213
-	} else {
214
-		$lien = '';
215
-	}
216
-	$n = $phraseur->contenu['compatible'];
217
-	$phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien];
211
+    if (isset($attrs['lien'])) {
212
+        $lien = $attrs['lien'];
213
+    } else {
214
+        $lien = '';
215
+    }
216
+    $n = $phraseur->contenu['compatible'];
217
+    $phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien];
218 218
 }
219 219
 
220 220
 /**
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
  * @param string $texte
227 227
  */
228 228
 function info_paquet_chemin($phraseur, $attrs, $texte) {
229
-	$n = $phraseur->contenu['compatible'];
230
-	if (isset($attrs['path'])) {
231
-		if (isset($attrs['type'])) {
232
-			$phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']];
233
-		} else {
234
-			$phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']];
235
-		}
236
-	}
229
+    $n = $phraseur->contenu['compatible'];
230
+    if (isset($attrs['path'])) {
231
+        if (isset($attrs['type'])) {
232
+            $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']];
233
+        } else {
234
+            $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']];
235
+        }
236
+    }
237 237
 }
238 238
 
239 239
 
@@ -247,24 +247,24 @@  discard block
 block discarded – undo
247 247
  * @param string $texte
248 248
  */
249 249
 function info_paquet_auteur($phraseur, $attrs, $texte) {
250
-	#  echo 'auteur ', $texte;  var_dump($attrs);
251
-	if (isset($attrs['mail'])) {
252
-		if (strpos($attrs['mail'], '@')) {
253
-			$attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']);
254
-		}
255
-		$mail = $attrs['mail'];
256
-	} else {
257
-		$mail = '';
258
-	}
259
-
260
-	if (isset($attrs['lien'])) {
261
-		$lien = $attrs['lien'];
262
-	} else {
263
-		$lien = '';
264
-	}
265
-
266
-	$n = $phraseur->contenu['compatible'];
267
-	$phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail];
250
+    #  echo 'auteur ', $texte;  var_dump($attrs);
251
+    if (isset($attrs['mail'])) {
252
+        if (strpos($attrs['mail'], '@')) {
253
+            $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']);
254
+        }
255
+        $mail = $attrs['mail'];
256
+    } else {
257
+        $mail = '';
258
+    }
259
+
260
+    if (isset($attrs['lien'])) {
261
+        $lien = $attrs['lien'];
262
+    } else {
263
+        $lien = '';
264
+    }
265
+
266
+    $n = $phraseur->contenu['compatible'];
267
+    $phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail];
268 268
 }
269 269
 
270 270
 /**
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function info_paquet_credit($phraseur, $attrs, $texte) {
279 279
 
280
-	if (isset($attrs['lien'])) {
281
-		$lien = $attrs['lien'];
282
-	} else {
283
-		$lien = '';
284
-	}
280
+    if (isset($attrs['lien'])) {
281
+        $lien = $attrs['lien'];
282
+    } else {
283
+        $lien = '';
284
+    }
285 285
 
286
-	$n = $phraseur->contenu['compatible'];
287
-	$phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien];
286
+    $n = $phraseur->contenu['compatible'];
287
+    $phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien];
288 288
 }
289 289
 
290 290
 /**
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
  * @param string $texte
297 297
  */
298 298
 function info_paquet_copyright($phraseur, $attrs, $texte) {
299
-	$n = $phraseur->contenu['compatible'];
300
-	$phraseur->versions[$n]['copyright'][] = $texte;
299
+    $n = $phraseur->contenu['compatible'];
300
+    $phraseur->versions[$n]['copyright'][] = $texte;
301 301
 }
302 302
 
303 303
 /**
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
  * @param string $texte
310 310
  */
311 311
 function info_paquet_paquet($phraseur, $attrs, $texte) {
312
-	$n = 0;
313
-	$phraseur->versions[$n]['dtd'] = 'paquet';
314
-	$phraseur->versions[$n]['balise'] = 'paquet';
312
+    $n = 0;
313
+    $phraseur->versions[$n]['dtd'] = 'paquet';
314
+    $phraseur->versions[$n]['balise'] = 'paquet';
315 315
 }
316 316
 
317 317
 /**
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
  * @param string $texte
324 324
  **/
325 325
 function info_paquet_traduire($phraseur, $attrs, $texte) {
326
-	$n = $phraseur->contenu['compatible'];
327
-	$phraseur->versions[$n]['traduire'][] = $attrs;
326
+    $n = $phraseur->contenu['compatible'];
327
+    $phraseur->versions[$n]['traduire'][] = $attrs;
328 328
 }
329 329
 
330 330
 /**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
  * @param string $texte
337 337
  */
338 338
 function info_paquet_spip($phraseur, $attrs, $texte) {
339
-	$n = $phraseur->contenu['compatible'];
340
-	$phraseur->versions[$n]['balise'] = 'spip';
339
+    $n = $phraseur->contenu['compatible'];
340
+    $phraseur->versions[$n]['balise'] = 'spip';
341 341
 }
342 342
 
343 343
 
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
  * @param string $texte
350 350
  */
351 351
 function info_paquet_pipeline($phraseur, $attrs, $texte) {
352
-	$n = $phraseur->contenu['compatible'];
353
-	$phraseur->versions[$n]['pipeline'][] = $attrs;
352
+    $n = $phraseur->contenu['compatible'];
353
+    $phraseur->versions[$n]['pipeline'][] = $attrs;
354 354
 }
355 355
 
356 356
 
@@ -363,23 +363,23 @@  discard block
 block discarded – undo
363 363
  * @param string $texte
364 364
  */
365 365
 function info_paquet_style($phraseur, $attrs, $texte) {
366
-	$lien = $chemin = $type = $media = '';
367
-
368
-	include_spip('inc/utils');
369
-	if (tester_url_absolue($attrs['source'])) {
370
-		$lien = $attrs['source'];
371
-	} else {
372
-		$chemin = $attrs['source'];
373
-	}
374
-	if (isset($attrs['type'])) {
375
-		$type = $attrs['type'];
376
-	}
377
-	if (isset($attrs['media'])) {
378
-		$media = $attrs['media'];
379
-	}
380
-
381
-	$n = $phraseur->contenu['compatible'];
382
-	$phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media];
366
+    $lien = $chemin = $type = $media = '';
367
+
368
+    include_spip('inc/utils');
369
+    if (tester_url_absolue($attrs['source'])) {
370
+        $lien = $attrs['source'];
371
+    } else {
372
+        $chemin = $attrs['source'];
373
+    }
374
+    if (isset($attrs['type'])) {
375
+        $type = $attrs['type'];
376
+    }
377
+    if (isset($attrs['media'])) {
378
+        $media = $attrs['media'];
379
+    }
380
+
381
+    $n = $phraseur->contenu['compatible'];
382
+    $phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media];
383 383
 }
384 384
 
385 385
 
@@ -392,20 +392,20 @@  discard block
 block discarded – undo
392 392
  * @param string $texte
393 393
  */
394 394
 function info_paquet_script($phraseur, $attrs, $texte) {
395
-	$lien = $chemin = $type = $media = '';
396
-
397
-	include_spip('inc/utils');
398
-	if (tester_url_absolue($attrs['source'])) {
399
-		$lien = $attrs['source'];
400
-	} else {
401
-		$chemin = $attrs['source'];
402
-	}
403
-	if (isset($attrs['type'])) {
404
-		$type = $attrs['type'];
405
-	}
406
-
407
-	$n = $phraseur->contenu['compatible'];
408
-	$phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type];
395
+    $lien = $chemin = $type = $media = '';
396
+
397
+    include_spip('inc/utils');
398
+    if (tester_url_absolue($attrs['source'])) {
399
+        $lien = $attrs['source'];
400
+    } else {
401
+        $chemin = $attrs['source'];
402
+    }
403
+    if (isset($attrs['type'])) {
404
+        $type = $attrs['type'];
405
+    }
406
+
407
+    $n = $phraseur->contenu['compatible'];
408
+    $phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type];
409 409
 }
410 410
 
411 411
 /**
@@ -416,6 +416,6 @@  discard block
 block discarded – undo
416 416
  * @param string $texte
417 417
  */
418 418
 function info_paquet_genie($phraseur, $attrs, $texte) {
419
-	$n = $phraseur->contenu['compatible'];
420
-	$phraseur->versions[$n]['genie'][] = $attrs;
419
+    $n = $phraseur->contenu['compatible'];
420
+    $phraseur->versions[$n]['genie'][] = $attrs;
421 421
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_nom_plugin.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 	// numerotons les occurences d'un meme prefix
40 40
 	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
-	$id = $info['prefix'] . $versions[$info['prefix']];
41
+	$id = $info['prefix'].$versions[$info['prefix']];
42 42
 
43 43
 	$class = $class_li;
44 44
 	$class .= $actif ? ' actif' : '';
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	$prefix = $info['prefix'];
56 56
 	$dir = "$dir_plugins$plug_file/lang/$prefix";
57 57
 	$desc = plugin_propre($info['description'], $dir);
58
-	$url_stat = parametre_url($url_page, 'plugin', $dir_plugins . $plug_file);
58
+	$url_stat = parametre_url($url_page, 'plugin', $dir_plugins.$plug_file);
59 59
 
60
-	$s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>';
61
-	$s .= " <span class='version'>" . $info['version'] . '</span>';
62
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>';
60
+	$s .= "<strong class='nom'>".typo($info['nom']).'</strong>';
61
+	$s .= " <span class='version'>".$info['version'].'</span>';
62
+	$s .= " <span class='etat'> - ".plugin_etat_en_clair($info['etat']).'</span>';
63 63
 	$s .= '</div>';
64 64
 
65 65
 	if ($erreur) {
66
-		$s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>';
66
+		$s .= "<div class='erreur'>".join('<br >', $info['erreur']).'</div>';
67 67
 	}
68 68
 
69 69
 	$s .= '</li>';
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,61 +11,61 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 include_spip('inc/texte');
18 18
 include_spip('plugins/afficher_plugin');
19 19
 
20 20
 function plugins_afficher_nom_plugin_dist(
21
-	$url_page,
22
-	$plug_file,
23
-	$checked,
24
-	$actif,
25
-	$expose = false,
26
-	$class_li = 'item',
27
-	$dir_plugins = _DIR_PLUGINS
21
+    $url_page,
22
+    $plug_file,
23
+    $checked,
24
+    $actif,
25
+    $expose = false,
26
+    $class_li = 'item',
27
+    $dir_plugins = _DIR_PLUGINS
28 28
 ) {
29
-	static $id_input = 0;
30
-	static $versions = [];
29
+    static $id_input = 0;
30
+    static $versions = [];
31 31
 
32
-	$erreur = false;
33
-	$s = '';
32
+    $erreur = false;
33
+    $s = '';
34 34
 
35
-	$get_infos = charger_fonction('get_infos', 'plugins');
36
-	$info = $get_infos($plug_file, false, $dir_plugins);
35
+    $get_infos = charger_fonction('get_infos', 'plugins');
36
+    $info = $get_infos($plug_file, false, $dir_plugins);
37 37
 
38
-	// numerotons les occurences d'un meme prefix
39
-	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
40
-	$id = $info['prefix'] . $versions[$info['prefix']];
38
+    // numerotons les occurences d'un meme prefix
39
+    $versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
40
+    $id = $info['prefix'] . $versions[$info['prefix']];
41 41
 
42
-	$class = $class_li;
43
-	$class .= $actif ? ' actif' : '';
44
-	$class .= $expose ? ' on' : '';
45
-	$erreur = isset($info['erreur']);
46
-	if ($erreur) {
47
-		$class .= ' error';
48
-	}
49
-	$s .= "<li id='$id' class='$class'>";
42
+    $class = $class_li;
43
+    $class .= $actif ? ' actif' : '';
44
+    $class .= $expose ? ' on' : '';
45
+    $erreur = isset($info['erreur']);
46
+    if ($erreur) {
47
+        $class .= ' error';
48
+    }
49
+    $s .= "<li id='$id' class='$class'>";
50 50
 
51
-	// Cartouche Resume
52
-	$s .= "<div class='resume'>";
51
+    // Cartouche Resume
52
+    $s .= "<div class='resume'>";
53 53
 
54
-	$prefix = $info['prefix'];
55
-	$dir = "$dir_plugins$plug_file/lang/$prefix";
56
-	$desc = plugin_propre($info['description'], $dir);
57
-	$url_stat = parametre_url($url_page, 'plugin', $dir_plugins . $plug_file);
54
+    $prefix = $info['prefix'];
55
+    $dir = "$dir_plugins$plug_file/lang/$prefix";
56
+    $desc = plugin_propre($info['description'], $dir);
57
+    $url_stat = parametre_url($url_page, 'plugin', $dir_plugins . $plug_file);
58 58
 
59
-	$s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>';
60
-	$s .= " <span class='version'>" . $info['version'] . '</span>';
61
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>';
62
-	$s .= '</div>';
59
+    $s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>';
60
+    $s .= " <span class='version'>" . $info['version'] . '</span>';
61
+    $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>';
62
+    $s .= '</div>';
63 63
 
64
-	if ($erreur) {
65
-		$s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>';
66
-	}
64
+    if ($erreur) {
65
+        $s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>';
66
+    }
67 67
 
68
-	$s .= '</li>';
68
+    $s .= '</li>';
69 69
 
70
-	return $s;
70
+    return $s;
71 71
 }
Please login to merge, or discard this patch.
ecrire/plugins/get_infos.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	static $filecache = '';
38 38
 
39 39
 	if ($cache === '') {
40
-		$filecache = _DIR_TMP . 'plugin_xml_cache.gz';
40
+		$filecache = _DIR_TMP.'plugin_xml_cache.gz';
41 41
 		if (is_file($filecache)) {
42 42
 			lire_fichier($filecache, $contenu);
43 43
 			$cache = unserialize($contenu);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	if (isset($ret['prefix']) and $ret['prefix'] == 'spip') {
129 129
 		$ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()];
130 130
 		foreach (get_loaded_extensions() as $ext) {
131
-			$ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)];
131
+			$ret['procure']['php:'.$ext] = ['nom' => 'php:'.$ext, 'version' => phpversion($ext)];
132 132
 		}
133 133
 	}
134 134
 	$diff = ($ret != $pcache);
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -33,110 +33,110 @@  discard block
 block discarded – undo
33 33
  * @return array
34 34
  */
35 35
 function plugins_get_infos_dist($plug = false, $reload = false, $dir = _DIR_PLUGINS, $clean_old = false) {
36
-	$contenu = null;
37
-	$res = null;
38
-	static $cache = '';
39
-	static $filecache = '';
40
-
41
-	if ($cache === '') {
42
-		$filecache = _DIR_TMP . 'plugin_xml_cache.gz';
43
-		if (is_file($filecache)) {
44
-			lire_fichier($filecache, $contenu);
45
-			$cache = unserialize($contenu);
46
-		}
47
-		if (!is_array($cache)) {
48
-			$cache = [];
49
-		}
50
-	}
51
-
52
-	if (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') {
53
-		$reload = true;
54
-	}
55
-
56
-	if ($plug === false) {
57
-		ecrire_fichier($filecache, serialize($cache));
58
-
59
-		return $cache;
60
-	} elseif (is_string($plug)) {
61
-		$res = plugins_get_infos_un($plug, $reload, $dir, $cache);
62
-	} elseif (is_array($plug)) {
63
-		$res = false;
64
-		if (!$reload) {
65
-			$reload = -1;
66
-		}
67
-		foreach ($plug as $nom) {
68
-			$res |= plugins_get_infos_un($nom, $reload, $dir, $cache);
69
-		}
70
-
71
-		// Nettoyer le cache des vieux plugins qui ne sont plus la
72
-		if ($clean_old and isset($cache[$dir]) and is_countable($cache[$dir]) ? count($cache[$dir]) : 0) {
73
-			foreach (array_keys($cache[$dir]) as $p) {
74
-				if (!in_array($p, $plug)) {
75
-					unset($cache[$dir][$p]);
76
-				}
77
-			}
78
-		}
79
-	}
80
-	if ($res) {
81
-		ecrire_fichier($filecache, serialize($cache));
82
-	}
83
-	if (!isset($cache[$dir])) {
84
-		return [];
85
-	}
86
-	if (is_string($plug)) {
87
-		return $cache[$dir][$plug] ?? [];
88
-	} else {
89
-		return $cache[$dir];
90
-	}
36
+    $contenu = null;
37
+    $res = null;
38
+    static $cache = '';
39
+    static $filecache = '';
40
+
41
+    if ($cache === '') {
42
+        $filecache = _DIR_TMP . 'plugin_xml_cache.gz';
43
+        if (is_file($filecache)) {
44
+            lire_fichier($filecache, $contenu);
45
+            $cache = unserialize($contenu);
46
+        }
47
+        if (!is_array($cache)) {
48
+            $cache = [];
49
+        }
50
+    }
51
+
52
+    if (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') {
53
+        $reload = true;
54
+    }
55
+
56
+    if ($plug === false) {
57
+        ecrire_fichier($filecache, serialize($cache));
58
+
59
+        return $cache;
60
+    } elseif (is_string($plug)) {
61
+        $res = plugins_get_infos_un($plug, $reload, $dir, $cache);
62
+    } elseif (is_array($plug)) {
63
+        $res = false;
64
+        if (!$reload) {
65
+            $reload = -1;
66
+        }
67
+        foreach ($plug as $nom) {
68
+            $res |= plugins_get_infos_un($nom, $reload, $dir, $cache);
69
+        }
70
+
71
+        // Nettoyer le cache des vieux plugins qui ne sont plus la
72
+        if ($clean_old and isset($cache[$dir]) and is_countable($cache[$dir]) ? count($cache[$dir]) : 0) {
73
+            foreach (array_keys($cache[$dir]) as $p) {
74
+                if (!in_array($p, $plug)) {
75
+                    unset($cache[$dir][$p]);
76
+                }
77
+            }
78
+        }
79
+    }
80
+    if ($res) {
81
+        ecrire_fichier($filecache, serialize($cache));
82
+    }
83
+    if (!isset($cache[$dir])) {
84
+        return [];
85
+    }
86
+    if (is_string($plug)) {
87
+        return $cache[$dir][$plug] ?? [];
88
+    } else {
89
+        return $cache[$dir];
90
+    }
91 91
 }
92 92
 
93 93
 
94 94
 function plugins_get_infos_un($plug, $reload, $dir, &$cache) {
95
-	if (!is_readable($file = "$dir$plug/paquet.xml")) {
96
-		return false;
97
-	}
98
-	$time = intval(@filemtime($file));
99
-	if ($time < 0) {
100
-		return false;
101
-	}
102
-	$md5 = md5_file($file);
103
-
104
-	$pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => ''];
105
-
106
-	// si le cache est valide
107
-	if (
108
-		(intval($reload) <= 0)
109
-		and ($time > 0)
110
-		and ($time <= $pcache['filemtime'])
111
-		and $md5 == $pcache['md5_file']
112
-	) {
113
-		return false;
114
-	}
115
-
116
-	// si on arrive pas a lire le fichier, se contenter du cache
117
-	if (!($texte = spip_file_get_contents($file))) {
118
-		return false;
119
-	}
120
-
121
-	$f = charger_fonction('infos_paquet', 'plugins');
122
-	$ret = $f($texte, $plug, $dir);
123
-	$ret['filemtime'] = $time;
124
-	$ret['md5_file'] = $md5;
125
-	// Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent
126
-	// utiliser un necessite php. SPIP procure donc la version php courante du serveur.
127
-	// chaque librairie php est aussi procurée, par exemple 'php:curl'.
128
-	if (isset($ret['prefix']) and $ret['prefix'] == 'spip') {
129
-		$ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()];
130
-		foreach (get_loaded_extensions() as $ext) {
131
-			$ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)];
132
-		}
133
-	}
134
-	$diff = ($ret != $pcache);
135
-
136
-	if ($diff) {
137
-		$cache[$dir][$plug] = $ret;
95
+    if (!is_readable($file = "$dir$plug/paquet.xml")) {
96
+        return false;
97
+    }
98
+    $time = intval(@filemtime($file));
99
+    if ($time < 0) {
100
+        return false;
101
+    }
102
+    $md5 = md5_file($file);
103
+
104
+    $pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => ''];
105
+
106
+    // si le cache est valide
107
+    if (
108
+        (intval($reload) <= 0)
109
+        and ($time > 0)
110
+        and ($time <= $pcache['filemtime'])
111
+        and $md5 == $pcache['md5_file']
112
+    ) {
113
+        return false;
114
+    }
115
+
116
+    // si on arrive pas a lire le fichier, se contenter du cache
117
+    if (!($texte = spip_file_get_contents($file))) {
118
+        return false;
119
+    }
120
+
121
+    $f = charger_fonction('infos_paquet', 'plugins');
122
+    $ret = $f($texte, $plug, $dir);
123
+    $ret['filemtime'] = $time;
124
+    $ret['md5_file'] = $md5;
125
+    // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent
126
+    // utiliser un necessite php. SPIP procure donc la version php courante du serveur.
127
+    // chaque librairie php est aussi procurée, par exemple 'php:curl'.
128
+    if (isset($ret['prefix']) and $ret['prefix'] == 'spip') {
129
+        $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()];
130
+        foreach (get_loaded_extensions() as $ext) {
131
+            $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)];
132
+        }
133
+    }
134
+    $diff = ($ret != $pcache);
135
+
136
+    if ($diff) {
137
+        $cache[$dir][$plug] = $ret;
138 138
 #       echo count($cache[$dir]), $dir,$plug, " $reloadc<br>";
139
-	}
139
+    }
140 140
 
141
-	return $diff;
141
+    return $diff;
142 142
 }
Please login to merge, or discard this patch.
ecrire/lang/public_es.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -4,123 +4,123 @@
 block discarded – undo
4 4
 // ** ne pas modifier le fichier **
5 5
 
6 6
 if (!defined('_ECRIRE_INC_VERSION')) {
7
-	return;
7
+    return;
8 8
 }
9 9
 
10 10
 $GLOBALS[$GLOBALS['idx_lang']] = array(
11 11
 
12
-	// A
13
-	'accueil_site' => 'Portada del sitio',
14
-	'article' => 'Artículo',
15
-	'articles' => 'Artículos',
16
-	'articles_auteur' => 'Artículos de esta autora o autor',
17
-	'articles_populaires' => 'Los artículos más populares',
18
-	'articles_rubrique' => 'Artículos de esta sección',
19
-	'aucun_article' => 'No hay ningún artículo en esta dirección ',
20
-	'aucun_auteur' => 'No hay autor ni autora en esta dirección ',
21
-	'aucun_site' => 'No hay ningún sitio en esta dirección',
22
-	'aucune_breve' => 'No hay ninguna breve en esta dirección',
23
-	'aucune_rubrique' => 'No hay ninguna sección en esta dirección',
24
-	'auteur' => 'Autor o autora',
25
-	'autres' => 'Otros',
26
-	'autres_breves' => 'Otros breves',
27
-	'autres_groupes_mots_clefs' => 'Otros grupos de palabras clave',
28
-	'autres_sites' => 'Otros sitios',
29
-
30
-	// B
31
-	'bonjour' => 'Hola',
32
-
33
-	// C
34
-	'commenter_site' => 'Comentar este sitio',
35
-	'contact' => 'Contacto',
36
-	'copie_document_impossible' => 'Imposible copiar el documento',
37
-
38
-	// D
39
-	'date' => 'Fecha',
40
-	'dernier_ajout' => 'Última actualización',
41
-	'dernieres_breves' => 'Últimos breves',
42
-	'derniers_articles' => 'Últimos artículos',
43
-	'derniers_commentaires' => 'Últimos comentarios',
44
-	'derniers_messages_forum' => 'Últimos mensajes publicados en los foros',
45
-
46
-	// E
47
-	'edition_mode_texte' => 'Edición en modo texto de',
48
-	'en_reponse' => 'En respuesta a:',
49
-	'en_resume' => 'En resumen',
50
-	'envoyer_message' => 'Enviar un mensaje',
51
-	'espace_prive' => 'Espacio privado',
52
-
53
-	// F
54
-	'formats_acceptes' => 'Formatos aceptados: @formats@.',
55
-
56
-	// H
57
-	'hierarchie_site' => 'Jerarquía del sitio',
58
-
59
-	// J
60
-	'jours' => 'días',
61
-
62
-	// L
63
-	'lien_connecter' => 'Conectarse',
64
-
65
-	// M
66
-	'meme_auteur' => 'Del mismo autor',
67
-	'meme_rubrique' => 'En la misma sección',
68
-	'memes_auteurs' => 'De los mismos autores',
69
-	'message' => 'Mensaje',
70
-	'messages_forum' => 'Mensajes',
71
-	'messages_recents' => 'Los mensajes más recientes del foro',
72
-	'mots_clef' => 'Palabra clave',
73
-	'mots_clefs' => 'Palabras clave',
74
-	'mots_clefs_meme_groupe' => 'Palabras claves en el mismo grupo',
75
-
76
-	// N
77
-	'navigation' => 'Navegación',
78
-	'nom' => 'Nombre',
79
-	'nouveautes' => 'Las novedades',
80
-	'nouveautes_web' => 'Novedades en la web',
81
-	'nouveaux_articles' => 'Nuevos artículos',
82
-	'nouvelles_breves' => 'Nuevas breves',
83
-
84
-	// P
85
-	'page_precedente' => 'Página anterior',
86
-	'page_suivante' => 'Página siguiente',
87
-	'par_auteur' => 'por ',
88
-	'participer_site' => 'Puedes participar en la vida de este sitio y proponer artículos inscribiéndote aqui. De inmediato recibirás un correo electrónico con tus claves de acceso al espacio privado del sitio.',
89
-	'plan_site' => 'Mapa del sitio',
90
-	'popularite' => 'Popularidad',
91
-	'poster_message' => 'Publicar un mensaje',
92
-	'proposer_site' => 'Proponga un sitio para añadir en esta sección:',
93
-
94
-	// R
95
-	'repondre_article' => 'Comentar este artículo',
96
-	'repondre_breve' => 'Comentar esta breve',
97
-	'resultats_recherche' => 'Resultados de la búsqueda',
98
-	'retour_debut_forums' => 'Volver al inicio del foro',
99
-	'rss_abonnement' => 'Copie la siguiente URL en su agregador:',
100
-	'rss_abonnement_titre' => 'Suscribirse',
101
-	'rss_abonnement_titre_page' => 'Suscribirse a',
102
-	'rss_explication' => 'Un feed RSS recoge información actualizada de un sitio. Proporciona el contenido de las entradas, comentarios o un extracto de los mismos, así como un enlace a las versiones completas y alguna otra información. Este feed está pensado para ser leído por un agregador RSS.',
103
-	'rss_explication_titre' => '¿Qué es un feed RSS?',
104
-	'rubrique' => 'Sección',
105
-	'rubriques' => 'Secciones',
106
-
107
-	// S
108
-	'signatures_petition' => 'Firmas',
109
-	'site_realise_avec_spip' => 'Sitio desarrollado con SPIP',
110
-	'sites_web' => 'Sitios Web',
111
-	'sous_rubriques' => 'Subsección',
112
-	'spam' => 'Spam',
113
-	'suite' => 'continuar',
114
-	'sur_web' => 'Del web',
115
-	'syndiquer_rubrique' => 'Sindicar esta sección',
116
-	'syndiquer_site' => 'Sindicar el sitio completo',
117
-
118
-	// T
119
-	'texte_lettre_information' => 'Este es el boletín de información del sitio',
120
-	'texte_lettre_information_2' => 'Este boletín reseña las novedades publicadas desde ',
121
-
122
-	// V
123
-	'ver_imprimer' => 'Versión para imprimir',
124
-	'voir_en_ligne' => 'Ver en línea',
125
-	'voir_squelette' => 'ver el esqueleto de esta página'
12
+    // A
13
+    'accueil_site' => 'Portada del sitio',
14
+    'article' => 'Artículo',
15
+    'articles' => 'Artículos',
16
+    'articles_auteur' => 'Artículos de esta autora o autor',
17
+    'articles_populaires' => 'Los artículos más populares',
18
+    'articles_rubrique' => 'Artículos de esta sección',
19
+    'aucun_article' => 'No hay ningún artículo en esta dirección ',
20
+    'aucun_auteur' => 'No hay autor ni autora en esta dirección ',
21
+    'aucun_site' => 'No hay ningún sitio en esta dirección',
22
+    'aucune_breve' => 'No hay ninguna breve en esta dirección',
23
+    'aucune_rubrique' => 'No hay ninguna sección en esta dirección',
24
+    'auteur' => 'Autor o autora',
25
+    'autres' => 'Otros',
26
+    'autres_breves' => 'Otros breves',
27
+    'autres_groupes_mots_clefs' => 'Otros grupos de palabras clave',
28
+    'autres_sites' => 'Otros sitios',
29
+
30
+    // B
31
+    'bonjour' => 'Hola',
32
+
33
+    // C
34
+    'commenter_site' => 'Comentar este sitio',
35
+    'contact' => 'Contacto',
36
+    'copie_document_impossible' => 'Imposible copiar el documento',
37
+
38
+    // D
39
+    'date' => 'Fecha',
40
+    'dernier_ajout' => 'Última actualización',
41
+    'dernieres_breves' => 'Últimos breves',
42
+    'derniers_articles' => 'Últimos artículos',
43
+    'derniers_commentaires' => 'Últimos comentarios',
44
+    'derniers_messages_forum' => 'Últimos mensajes publicados en los foros',
45
+
46
+    // E
47
+    'edition_mode_texte' => 'Edición en modo texto de',
48
+    'en_reponse' => 'En respuesta a:',
49
+    'en_resume' => 'En resumen',
50
+    'envoyer_message' => 'Enviar un mensaje',
51
+    'espace_prive' => 'Espacio privado',
52
+
53
+    // F
54
+    'formats_acceptes' => 'Formatos aceptados: @formats@.',
55
+
56
+    // H
57
+    'hierarchie_site' => 'Jerarquía del sitio',
58
+
59
+    // J
60
+    'jours' => 'días',
61
+
62
+    // L
63
+    'lien_connecter' => 'Conectarse',
64
+
65
+    // M
66
+    'meme_auteur' => 'Del mismo autor',
67
+    'meme_rubrique' => 'En la misma sección',
68
+    'memes_auteurs' => 'De los mismos autores',
69
+    'message' => 'Mensaje',
70
+    'messages_forum' => 'Mensajes',
71
+    'messages_recents' => 'Los mensajes más recientes del foro',
72
+    'mots_clef' => 'Palabra clave',
73
+    'mots_clefs' => 'Palabras clave',
74
+    'mots_clefs_meme_groupe' => 'Palabras claves en el mismo grupo',
75
+
76
+    // N
77
+    'navigation' => 'Navegación',
78
+    'nom' => 'Nombre',
79
+    'nouveautes' => 'Las novedades',
80
+    'nouveautes_web' => 'Novedades en la web',
81
+    'nouveaux_articles' => 'Nuevos artículos',
82
+    'nouvelles_breves' => 'Nuevas breves',
83
+
84
+    // P
85
+    'page_precedente' => 'Página anterior',
86
+    'page_suivante' => 'Página siguiente',
87
+    'par_auteur' => 'por ',
88
+    'participer_site' => 'Puedes participar en la vida de este sitio y proponer artículos inscribiéndote aqui. De inmediato recibirás un correo electrónico con tus claves de acceso al espacio privado del sitio.',
89
+    'plan_site' => 'Mapa del sitio',
90
+    'popularite' => 'Popularidad',
91
+    'poster_message' => 'Publicar un mensaje',
92
+    'proposer_site' => 'Proponga un sitio para añadir en esta sección:',
93
+
94
+    // R
95
+    'repondre_article' => 'Comentar este artículo',
96
+    'repondre_breve' => 'Comentar esta breve',
97
+    'resultats_recherche' => 'Resultados de la búsqueda',
98
+    'retour_debut_forums' => 'Volver al inicio del foro',
99
+    'rss_abonnement' => 'Copie la siguiente URL en su agregador:',
100
+    'rss_abonnement_titre' => 'Suscribirse',
101
+    'rss_abonnement_titre_page' => 'Suscribirse a',
102
+    'rss_explication' => 'Un feed RSS recoge información actualizada de un sitio. Proporciona el contenido de las entradas, comentarios o un extracto de los mismos, así como un enlace a las versiones completas y alguna otra información. Este feed está pensado para ser leído por un agregador RSS.',
103
+    'rss_explication_titre' => '¿Qué es un feed RSS?',
104
+    'rubrique' => 'Sección',
105
+    'rubriques' => 'Secciones',
106
+
107
+    // S
108
+    'signatures_petition' => 'Firmas',
109
+    'site_realise_avec_spip' => 'Sitio desarrollado con SPIP',
110
+    'sites_web' => 'Sitios Web',
111
+    'sous_rubriques' => 'Subsección',
112
+    'spam' => 'Spam',
113
+    'suite' => 'continuar',
114
+    'sur_web' => 'Del web',
115
+    'syndiquer_rubrique' => 'Sindicar esta sección',
116
+    'syndiquer_site' => 'Sindicar el sitio completo',
117
+
118
+    // T
119
+    'texte_lettre_information' => 'Este es el boletín de información del sitio',
120
+    'texte_lettre_information_2' => 'Este boletín reseña las novedades publicadas desde ',
121
+
122
+    // V
123
+    'ver_imprimer' => 'Versión para imprimir',
124
+    'voir_en_ligne' => 'Ver en línea',
125
+    'voir_squelette' => 'ver el esqueleto de esta página'
126 126
 );
Please login to merge, or discard this patch.
ecrire/action/editer_liens.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -398,8 +398,7 @@  discard block
 block discarded – undo
398 398
 			if (lien_triables($table_lien)) {
399 399
 				if (isset($qualif['rang_lien'])) {
400 400
 					$rang = $qualif['rang_lien'];
401
-				}
402
-				else {
401
+				} else {
403 402
 					$where = lien_where($primary, $id, $objet, $id_objet);
404 403
 					// si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul
405 404
 					if (!$rang = intval(sql_getfetsel('rang_lien', $table_lien, $where))) {
@@ -545,8 +544,7 @@  discard block
 block discarded – undo
545 544
 		$desc = $trouver_table($table_lien);
546 545
 		if ($desc and isset($desc['field']['rang_lien'])) {
547 546
 			$triables[$table_lien] = true;
548
-		}
549
-		else {
547
+		} else {
550 548
 			$triables[$table_lien] = false;
551 549
 		}
552 550
 	}
Please login to merge, or discard this patch.
Indentation   +574 added lines, -574 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  */
30 30
 
31 31
 if (!defined('_ECRIRE_INC_VERSION')) {
32
-	return;
32
+    return;
33 33
 }
34 34
 
35 35
 // charger la gestion les rôles sur les objets
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
  *     - array(clé primaire, nom de la table de lien) si associable
48 48
  */
49 49
 function objet_associable($objet) {
50
-	$trouver_table = charger_fonction('trouver_table', 'base');
51
-	$table_sql = table_objet_sql($objet);
52
-
53
-	$l = '';
54
-	if (
55
-		$primary = id_table_objet($objet)
56
-		and $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false])
57
-		and !preg_match(',[^\w],', $primary)
58
-		and !preg_match(',[^\w],', $l)
59
-	) {
60
-		return [$primary, $l];
61
-	}
62
-
63
-	spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
64
-
65
-	return false;
50
+    $trouver_table = charger_fonction('trouver_table', 'base');
51
+    $table_sql = table_objet_sql($objet);
52
+
53
+    $l = '';
54
+    if (
55
+        $primary = id_table_objet($objet)
56
+        and $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false])
57
+        and !preg_match(',[^\w],', $primary)
58
+        and !preg_match(',[^\w],', $l)
59
+    ) {
60
+        return [$primary, $l];
61
+    }
62
+
63
+    spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
64
+
65
+    return false;
66 66
 }
67 67
 
68 68
 /**
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
  * @return bool|int
89 89
  */
90 90
 function objet_associer($objets_source, $objets_lies, $qualif = null) {
91
-	$modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif);
91
+    $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif);
92 92
 
93
-	if ($qualif) {
94
-		objet_qualifier_liens($objets_source, $objets_lies, $qualif);
95
-	}
93
+    if ($qualif) {
94
+        objet_qualifier_liens($objets_source, $objets_lies, $qualif);
95
+    }
96 96
 
97
-	return $modifs; // pas d'erreur
97
+    return $modifs; // pas d'erreur
98 98
 }
99 99
 
100 100
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
  * @return bool|int
129 129
  */
130 130
 function objet_dissocier($objets_source, $objets_lies, $cond = null) {
131
-	return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond);
131
+    return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond);
132 132
 }
133 133
 
134 134
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
  * @return bool|int
154 154
  */
155 155
 function objet_qualifier_liens($objets_source, $objets_lies, $qualif) {
156
-	return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif);
156
+    return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif);
157 157
 }
158 158
 
159 159
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
  *     Liste des trouvailles
189 189
  */
190 190
 function objet_trouver_liens($objets_source, $objets_lies, $cond = null) {
191
-	return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond);
191
+    return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond);
192 192
 }
193 193
 
194 194
 
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
  * @return int
213 213
  */
214 214
 function objet_optimiser_liens($objets_source, $objets_lies) {
215
-	spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG);
216
-	return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies);
215
+    spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG);
216
+    return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies);
217 217
 }
218 218
 
219 219
 
@@ -233,37 +233,37 @@  discard block
 block discarded – undo
233 233
  *     Nombre de liens copiés
234 234
  */
235 235
 function objet_dupliquer_liens($objet, $id_source, $id_cible, $types = null, $exclure_types = null) {
236
-	include_spip('base/objets');
237
-	$tables = lister_tables_objets_sql();
238
-	$n = 0;
239
-	foreach ($tables as $table_sql => $infos) {
240
-		if (
241
-			(is_null($types) or in_array($infos['type'], $types))
242
-			and (is_null($exclure_types) or !in_array($infos['type'], $exclure_types))
243
-		) {
244
-			if (objet_associable($infos['type'])) {
245
-				$liens = (($infos['type'] == $objet) ?
246
-					objet_trouver_liens([$objet => $id_source], '*')
247
-					:
248
-					objet_trouver_liens([$infos['type'] => '*'], [$objet => $id_source]));
249
-				foreach ($liens as $lien) {
250
-					$n++;
251
-					if ($infos['type'] == $objet) {
252
-						if (
253
-							(is_null($types) or in_array($lien['objet'], $types))
254
-							and (is_null($exclure_types) or !in_array($lien['objet'], $exclure_types))
255
-						) {
256
-							objet_associer([$objet => $id_cible], [$lien['objet'] => $lien[$lien['objet']]], $lien);
257
-						}
258
-					} else {
259
-						objet_associer([$infos['type'] => $lien[$infos['type']]], [$objet => $id_cible], $lien);
260
-					}
261
-				}
262
-			}
263
-		}
264
-	}
265
-
266
-	return $n;
236
+    include_spip('base/objets');
237
+    $tables = lister_tables_objets_sql();
238
+    $n = 0;
239
+    foreach ($tables as $table_sql => $infos) {
240
+        if (
241
+            (is_null($types) or in_array($infos['type'], $types))
242
+            and (is_null($exclure_types) or !in_array($infos['type'], $exclure_types))
243
+        ) {
244
+            if (objet_associable($infos['type'])) {
245
+                $liens = (($infos['type'] == $objet) ?
246
+                    objet_trouver_liens([$objet => $id_source], '*')
247
+                    :
248
+                    objet_trouver_liens([$infos['type'] => '*'], [$objet => $id_source]));
249
+                foreach ($liens as $lien) {
250
+                    $n++;
251
+                    if ($infos['type'] == $objet) {
252
+                        if (
253
+                            (is_null($types) or in_array($lien['objet'], $types))
254
+                            and (is_null($exclure_types) or !in_array($lien['objet'], $exclure_types))
255
+                        ) {
256
+                            objet_associer([$objet => $id_cible], [$lien['objet'] => $lien[$lien['objet']]], $lien);
257
+                        }
258
+                    } else {
259
+                        objet_associer([$infos['type'] => $lien[$infos['type']]], [$objet => $id_cible], $lien);
260
+                    }
261
+                }
262
+            }
263
+        }
264
+    }
265
+
266
+    return $n;
267 267
 }
268 268
 
269 269
 /**
@@ -305,38 +305,38 @@  discard block
 block discarded – undo
305 305
  * @return bool|int|array
306 306
  */
307 307
 function objet_traiter_liaisons($operation, $objets_source, $objets_lies, $set = null) {
308
-	// accepter une syntaxe minimale pour supprimer tous les liens
309
-	if ($objets_lies == '*') {
310
-		$objets_lies = ['*' => '*'];
311
-	}
312
-	$modifs = 0; // compter le nombre de modifications
313
-	$echec = null;
314
-	foreach ($objets_source as $objet => $ids) {
315
-		if ($a = objet_associable($objet)) {
316
-			[$primary, $l] = $a;
317
-			if (!is_array($ids)) {
318
-				$ids = [$ids];
319
-			} elseif (reset($ids) == 'NOT') {
320
-				// si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
321
-				$where = lien_where($primary, $ids, '*', '*');
322
-				$ids = sql_allfetsel($primary, $l, $where);
323
-				$ids = array_map('reset', $ids);
324
-			}
325
-			foreach ($ids as $id) {
326
-				$res = $operation($objet, $primary, $l, $id, $objets_lies, $set);
327
-				if ($res === false) {
328
-					spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR);
329
-					$echec = true;
330
-				} else {
331
-					$modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res);
332
-				}
333
-			}
334
-		} else {
335
-			$echec = true;
336
-		}
337
-	}
338
-
339
-	return ($echec ? false : $modifs); // pas d'erreur
308
+    // accepter une syntaxe minimale pour supprimer tous les liens
309
+    if ($objets_lies == '*') {
310
+        $objets_lies = ['*' => '*'];
311
+    }
312
+    $modifs = 0; // compter le nombre de modifications
313
+    $echec = null;
314
+    foreach ($objets_source as $objet => $ids) {
315
+        if ($a = objet_associable($objet)) {
316
+            [$primary, $l] = $a;
317
+            if (!is_array($ids)) {
318
+                $ids = [$ids];
319
+            } elseif (reset($ids) == 'NOT') {
320
+                // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
321
+                $where = lien_where($primary, $ids, '*', '*');
322
+                $ids = sql_allfetsel($primary, $l, $where);
323
+                $ids = array_map('reset', $ids);
324
+            }
325
+            foreach ($ids as $id) {
326
+                $res = $operation($objet, $primary, $l, $id, $objets_lies, $set);
327
+                if ($res === false) {
328
+                    spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR);
329
+                    $echec = true;
330
+                } else {
331
+                    $modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res);
332
+                }
333
+            }
334
+        } else {
335
+            $echec = true;
336
+        }
337
+    }
338
+
339
+    return ($echec ? false : $modifs); // pas d'erreur
340 340
 }
341 341
 
342 342
 
@@ -365,117 +365,117 @@  discard block
 block discarded – undo
365 365
  *     Nombre d'insertions faites, false si échec.
366 366
  */
367 367
 function lien_insert($objet_source, $primary, $table_lien, $id, $objets, $qualif) {
368
-	$ins = 0;
369
-	$echec = null;
370
-	if (is_null($qualif)) {
371
-		$qualif = [];
372
-	}
373
-
374
-	foreach ($objets as $objet => $id_objets) {
375
-		if (!is_array($id_objets)) {
376
-			$id_objets = [$id_objets];
377
-		}
378
-
379
-		// role, colonne, where par défaut
380
-		[$role, $colonne_role, $cond] =
381
-			roles_trouver_dans_qualif($objet_source, $objet, $qualif);
382
-
383
-		foreach ($id_objets as $id_objet) {
384
-			$objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
385
-
386
-			$insertions = [
387
-				'id_objet' => $id_objet,
388
-				'objet' => $objet,
389
-				$primary => $id
390
-			];
391
-			// rôle en plus s'il est défini
392
-			if ($role) {
393
-				$insertions += [
394
-					$colonne_role => $role
395
-				];
396
-			}
397
-
398
-			if (lien_triables($table_lien)) {
399
-				if (isset($qualif['rang_lien'])) {
400
-					$rang = $qualif['rang_lien'];
401
-				}
402
-				else {
403
-					$where = lien_where($primary, $id, $objet, $id_objet);
404
-					// si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul
405
-					if (!$rang = intval(sql_getfetsel('rang_lien', $table_lien, $where))) {
406
-						$where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
407
-						$rang = intval(sql_getfetsel('max(rang_lien)', $table_lien, $where));
408
-						// si aucun lien n'a de rang, on en introduit pas, on garde zero
409
-						if ($rang > 0) {
410
-							$rang = intval($rang) + 1;
411
-						}
412
-					}
413
-				}
414
-				$insertions['rang_lien'] = $rang;
415
-			}
416
-
417
-			$args = [
418
-				'table_lien' => $table_lien,
419
-				'objet_source' => $objet_source,
420
-				'id_objet_source' => $id,
421
-				'objet' => $objet,
422
-				'id_objet' => $id_objet,
423
-				'role' => $role,
424
-				'colonne_role' => $colonne_role,
425
-				'action' => 'insert',
426
-			];
427
-
428
-			// Envoyer aux plugins
429
-			$insertions = pipeline(
430
-				'pre_edition_lien',
431
-				[
432
-					'args' => $args,
433
-					'data' => $insertions
434
-				]
435
-			);
436
-			$args['id_objet'] = $insertions['id_objet'];
437
-
438
-			$where = lien_where($primary, $id, $objet, $id_objet, $cond);
439
-
440
-			if (
441
-				($id_objet = intval($insertions['id_objet']) or in_array($objet, ['site', 'rubrique']))
442
-				and !sql_getfetsel($primary, $table_lien, $where)
443
-			) {
444
-				if (lien_triables($table_lien) and isset($insertions['rang_lien']) and intval($insertions['rang_lien'])) {
445
-					$where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
446
-					$where_meme_lien = implode(' AND ', $where_meme_lien);
447
-					// on decale les liens de rang_lien>=la valeur inseree pour faire la place
448
-					// sauf sur le meme lien avec un role eventuellement different
449
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($insertions['rang_lien']), "NOT($where_meme_lien)"]);
450
-					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
451
-				}
452
-
453
-				$e = sql_insertq($table_lien, $insertions);
454
-				if ($e !== false) {
455
-					$ins++;
456
-					lien_propage_date_modif($objet, $id_objet);
457
-					lien_propage_date_modif($objet_source, $id);
458
-					// Envoyer aux plugins
459
-					pipeline(
460
-						'post_edition_lien',
461
-						[
462
-							'args' => $args,
463
-							'data' => $insertions
464
-						]
465
-					);
466
-				} else {
467
-					$echec = true;
468
-				}
469
-			}
470
-		}
471
-	}
472
-	// si on a fait des insertions, on reordonne les liens concernes
473
-	// pas la peine si $qualif['rang_lien'] etait fournie, on va passer dans lien_set a suivre et donc finir le recomptage
474
-	if ($ins > 0 and empty($qualif['rang_lien'])) {
475
-		lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
476
-	}
477
-
478
-	return ($echec ? false : $ins);
368
+    $ins = 0;
369
+    $echec = null;
370
+    if (is_null($qualif)) {
371
+        $qualif = [];
372
+    }
373
+
374
+    foreach ($objets as $objet => $id_objets) {
375
+        if (!is_array($id_objets)) {
376
+            $id_objets = [$id_objets];
377
+        }
378
+
379
+        // role, colonne, where par défaut
380
+        [$role, $colonne_role, $cond] =
381
+            roles_trouver_dans_qualif($objet_source, $objet, $qualif);
382
+
383
+        foreach ($id_objets as $id_objet) {
384
+            $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
385
+
386
+            $insertions = [
387
+                'id_objet' => $id_objet,
388
+                'objet' => $objet,
389
+                $primary => $id
390
+            ];
391
+            // rôle en plus s'il est défini
392
+            if ($role) {
393
+                $insertions += [
394
+                    $colonne_role => $role
395
+                ];
396
+            }
397
+
398
+            if (lien_triables($table_lien)) {
399
+                if (isset($qualif['rang_lien'])) {
400
+                    $rang = $qualif['rang_lien'];
401
+                }
402
+                else {
403
+                    $where = lien_where($primary, $id, $objet, $id_objet);
404
+                    // si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul
405
+                    if (!$rang = intval(sql_getfetsel('rang_lien', $table_lien, $where))) {
406
+                        $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
407
+                        $rang = intval(sql_getfetsel('max(rang_lien)', $table_lien, $where));
408
+                        // si aucun lien n'a de rang, on en introduit pas, on garde zero
409
+                        if ($rang > 0) {
410
+                            $rang = intval($rang) + 1;
411
+                        }
412
+                    }
413
+                }
414
+                $insertions['rang_lien'] = $rang;
415
+            }
416
+
417
+            $args = [
418
+                'table_lien' => $table_lien,
419
+                'objet_source' => $objet_source,
420
+                'id_objet_source' => $id,
421
+                'objet' => $objet,
422
+                'id_objet' => $id_objet,
423
+                'role' => $role,
424
+                'colonne_role' => $colonne_role,
425
+                'action' => 'insert',
426
+            ];
427
+
428
+            // Envoyer aux plugins
429
+            $insertions = pipeline(
430
+                'pre_edition_lien',
431
+                [
432
+                    'args' => $args,
433
+                    'data' => $insertions
434
+                ]
435
+            );
436
+            $args['id_objet'] = $insertions['id_objet'];
437
+
438
+            $where = lien_where($primary, $id, $objet, $id_objet, $cond);
439
+
440
+            if (
441
+                ($id_objet = intval($insertions['id_objet']) or in_array($objet, ['site', 'rubrique']))
442
+                and !sql_getfetsel($primary, $table_lien, $where)
443
+            ) {
444
+                if (lien_triables($table_lien) and isset($insertions['rang_lien']) and intval($insertions['rang_lien'])) {
445
+                    $where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
446
+                    $where_meme_lien = implode(' AND ', $where_meme_lien);
447
+                    // on decale les liens de rang_lien>=la valeur inseree pour faire la place
448
+                    // sauf sur le meme lien avec un role eventuellement different
449
+                    $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($insertions['rang_lien']), "NOT($where_meme_lien)"]);
450
+                    sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
451
+                }
452
+
453
+                $e = sql_insertq($table_lien, $insertions);
454
+                if ($e !== false) {
455
+                    $ins++;
456
+                    lien_propage_date_modif($objet, $id_objet);
457
+                    lien_propage_date_modif($objet_source, $id);
458
+                    // Envoyer aux plugins
459
+                    pipeline(
460
+                        'post_edition_lien',
461
+                        [
462
+                            'args' => $args,
463
+                            'data' => $insertions
464
+                        ]
465
+                    );
466
+                } else {
467
+                    $echec = true;
468
+                }
469
+            }
470
+        }
471
+    }
472
+    // si on a fait des insertions, on reordonne les liens concernes
473
+    // pas la peine si $qualif['rang_lien'] etait fournie, on va passer dans lien_set a suivre et donc finir le recomptage
474
+    if ($ins > 0 and empty($qualif['rang_lien'])) {
475
+        lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
476
+    }
477
+
478
+    return ($echec ? false : $ins);
479 479
 }
480 480
 
481 481
 
@@ -488,47 +488,47 @@  discard block
 block discarded – undo
488 488
  * @param array|string $objets
489 489
  */
490 490
 function lien_ordonner($objet_source, $primary, $table_lien, $id, $objets) {
491
-	if (!lien_triables($table_lien)) {
492
-		return;
493
-	}
494
-
495
-	$deja_reordonne = [];
496
-
497
-	foreach ($objets as $objet => $id_objets) {
498
-		if (!is_array($id_objets)) {
499
-			$id_objets = [$id_objets];
500
-		}
501
-
502
-		foreach ($id_objets as $id_objet) {
503
-			if (empty($deja_reordonne[$id][$objet][$id_objet])) {
504
-				$objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
505
-
506
-				$where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
507
-				$liens = sql_allfetsel("$primary, id_objet, objet, rang_lien", $table_lien, $where, '', 'rang_lien');
508
-
509
-				$rangs = array_column($liens, 'rang_lien');
510
-				if (count($rangs) and (max($rangs) > 0 or min($rangs) < 0)) {
511
-					$rang = 1;
512
-					foreach ($liens as $lien) {
513
-						if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) {
514
-							$where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . intval($rang)]);
515
-							sql_updateq($table_lien, ['rang_lien' => $rang], $where);
516
-
517
-							if (empty($deja_reordonne[$lien[$primary]])) {
518
-								$deja_reordonne[$lien[$primary]] = [];
519
-							}
520
-							if (empty($deja_reordonne[$lien[$primary]][$lien['objet']])) {
521
-								$deja_reordonne[$lien[$primary]][$lien['objet']] = [];
522
-							}
523
-							$deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']] = $rang;
524
-
525
-							$rang++;
526
-						}
527
-					}
528
-				}
529
-			}
530
-		}
531
-	}
491
+    if (!lien_triables($table_lien)) {
492
+        return;
493
+    }
494
+
495
+    $deja_reordonne = [];
496
+
497
+    foreach ($objets as $objet => $id_objets) {
498
+        if (!is_array($id_objets)) {
499
+            $id_objets = [$id_objets];
500
+        }
501
+
502
+        foreach ($id_objets as $id_objet) {
503
+            if (empty($deja_reordonne[$id][$objet][$id_objet])) {
504
+                $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite
505
+
506
+                $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet);
507
+                $liens = sql_allfetsel("$primary, id_objet, objet, rang_lien", $table_lien, $where, '', 'rang_lien');
508
+
509
+                $rangs = array_column($liens, 'rang_lien');
510
+                if (count($rangs) and (max($rangs) > 0 or min($rangs) < 0)) {
511
+                    $rang = 1;
512
+                    foreach ($liens as $lien) {
513
+                        if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) {
514
+                            $where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . intval($rang)]);
515
+                            sql_updateq($table_lien, ['rang_lien' => $rang], $where);
516
+
517
+                            if (empty($deja_reordonne[$lien[$primary]])) {
518
+                                $deja_reordonne[$lien[$primary]] = [];
519
+                            }
520
+                            if (empty($deja_reordonne[$lien[$primary]][$lien['objet']])) {
521
+                                $deja_reordonne[$lien[$primary]][$lien['objet']] = [];
522
+                            }
523
+                            $deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']] = $rang;
524
+
525
+                            $rang++;
526
+                        }
527
+                    }
528
+                }
529
+            }
530
+        }
531
+    }
532 532
 }
533 533
 
534 534
 
@@ -539,18 +539,18 @@  discard block
 block discarded – undo
539 539
  * @return mixed
540 540
  */
541 541
 function lien_triables($table_lien) {
542
-	static $triables = [];
543
-	if (!isset($triables[$table_lien])) {
544
-		$trouver_table = charger_fonction('trouver_table', 'base');
545
-		$desc = $trouver_table($table_lien);
546
-		if ($desc and isset($desc['field']['rang_lien'])) {
547
-			$triables[$table_lien] = true;
548
-		}
549
-		else {
550
-			$triables[$table_lien] = false;
551
-		}
552
-	}
553
-	return $triables[$table_lien];
542
+    static $triables = [];
543
+    if (!isset($triables[$table_lien])) {
544
+        $trouver_table = charger_fonction('trouver_table', 'base');
545
+        $desc = $trouver_table($table_lien);
546
+        if ($desc and isset($desc['field']['rang_lien'])) {
547
+            $triables[$table_lien] = true;
548
+        }
549
+        else {
550
+            $triables[$table_lien] = false;
551
+        }
552
+    }
553
+    return $triables[$table_lien];
554 554
 }
555 555
 
556 556
 
@@ -566,52 +566,52 @@  discard block
 block discarded – undo
566 566
  * @return array                        Liste des conditions
567 567
  */
568 568
 function lien_where($primary, $id_source, $objet, $id_objet, $cond = []) {
569
-	if (
570
-		(!is_array($id_source) and !strlen($id_source))
571
-		or !strlen($objet)
572
-		or (!is_array($id_objet) and !strlen($id_objet))
573
-	) {
574
-		return ['0=1'];
575
-	} // securite
576
-
577
-	$not = '';
578
-	if (is_array($id_source) and reset($id_source) == 'NOT') {
579
-		$not = array_shift($id_source);
580
-		$id_source = reset($id_source);
581
-	}
582
-
583
-	$where = $cond;
584
-
585
-	if ($id_source !== '*') {
586
-		$where[] = (is_array($id_source) ? sql_in(
587
-			addslashes($primary),
588
-			array_map('intval', $id_source),
589
-			$not
590
-		) : addslashes($primary) . ($not ? '<>' : '=') . intval($id_source));
591
-	} elseif ($not) {
592
-		$where[] = '0=1';
593
-	} // idiot mais quand meme
594
-
595
-	$not = '';
596
-	if (is_array($id_objet) and reset($id_objet) == 'NOT') {
597
-		$not = array_shift($id_objet);
598
-		$id_objet = reset($id_objet);
599
-	}
600
-
601
-	if ($objet !== '*') {
602
-		$where[] = 'objet=' . sql_quote($objet);
603
-	}
604
-	if ($id_objet !== '*') {
605
-		$where[] = (is_array($id_objet) ? sql_in(
606
-			'id_objet',
607
-			array_map('intval', $id_objet),
608
-			$not
609
-		) : 'id_objet' . ($not ? '<>' : '=') . intval($id_objet));
610
-	} elseif ($not) {
611
-		$where[] = '0=1';
612
-	} // idiot mais quand meme
613
-
614
-	return $where;
569
+    if (
570
+        (!is_array($id_source) and !strlen($id_source))
571
+        or !strlen($objet)
572
+        or (!is_array($id_objet) and !strlen($id_objet))
573
+    ) {
574
+        return ['0=1'];
575
+    } // securite
576
+
577
+    $not = '';
578
+    if (is_array($id_source) and reset($id_source) == 'NOT') {
579
+        $not = array_shift($id_source);
580
+        $id_source = reset($id_source);
581
+    }
582
+
583
+    $where = $cond;
584
+
585
+    if ($id_source !== '*') {
586
+        $where[] = (is_array($id_source) ? sql_in(
587
+            addslashes($primary),
588
+            array_map('intval', $id_source),
589
+            $not
590
+        ) : addslashes($primary) . ($not ? '<>' : '=') . intval($id_source));
591
+    } elseif ($not) {
592
+        $where[] = '0=1';
593
+    } // idiot mais quand meme
594
+
595
+    $not = '';
596
+    if (is_array($id_objet) and reset($id_objet) == 'NOT') {
597
+        $not = array_shift($id_objet);
598
+        $id_objet = reset($id_objet);
599
+    }
600
+
601
+    if ($objet !== '*') {
602
+        $where[] = 'objet=' . sql_quote($objet);
603
+    }
604
+    if ($id_objet !== '*') {
605
+        $where[] = (is_array($id_objet) ? sql_in(
606
+            'id_objet',
607
+            array_map('intval', $id_objet),
608
+            $not
609
+        ) : 'id_objet' . ($not ? '<>' : '=') . intval($id_objet));
610
+    } elseif ($not) {
611
+        $where[] = '0=1';
612
+    } // idiot mais quand meme
613
+
614
+    return $where;
615 615
 }
616 616
 
617 617
 /**
@@ -626,13 +626,13 @@  discard block
 block discarded – undo
626 626
  */
627 627
 function lien_rang_where($table_lien, $primary, $id_source, $objet, $id_objet, $cond = []) {
628 628
 
629
-	// si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc
630
-	if (function_exists($f = 'lien_rang_where_' . $table_lien)) {
631
-		return $f($primary, $id_source, $objet, $id_objet, $cond);
632
-	}
629
+    // si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc
630
+    if (function_exists($f = 'lien_rang_where_' . $table_lien)) {
631
+        return $f($primary, $id_source, $objet, $id_objet, $cond);
632
+    }
633 633
 
634
-	// par defaut c'est un rang compté pour tous les id_source d'un couple objet-id_objet
635
-	return lien_where($primary, '*', $objet, $id_objet, $cond);
634
+    // par defaut c'est un rang compté pour tous les id_source d'un couple objet-id_objet
635
+    return lien_where($primary, '*', $objet, $id_objet, $cond);
636 636
 }
637 637
 
638 638
 /**
@@ -663,90 +663,90 @@  discard block
 block discarded – undo
663 663
  */
664 664
 function lien_delete($objet_source, $primary, $table_lien, $id, $objets, $cond = null) {
665 665
 
666
-	$retire = [];
667
-	$dels = 0;
668
-	$echec = false;
669
-	if (is_null($cond)) {
670
-		$cond = [];
671
-	}
672
-
673
-	foreach ($objets as $objet => $id_objets) {
674
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
675
-		if (!is_array($id_objets) or reset($id_objets) == 'NOT') {
676
-			$id_objets = [$id_objets];
677
-		}
678
-		foreach ($id_objets as $id_objet) {
679
-			[$cond, $colonne_role, $role] = roles_creer_condition_role($objet_source, $objet, $cond);
680
-			// id_objet peut valoir '*'
681
-			$where = lien_where($primary, $id, $objet, $id_objet, $cond);
682
-
683
-			// lire les liens existants pour propager la date de modif
684
-			$select = "$primary,id_objet,objet";
685
-			if ($colonne_role) {
686
-				$select .= ",$colonne_role";
687
-			}
688
-			$liens = sql_allfetsel($select, $table_lien, $where);
689
-
690
-			// iterer sur les liens pour permettre aux plugins de gerer
691
-			foreach ($liens as $l) {
692
-				$args = [
693
-					'table_lien' => $table_lien,
694
-					'objet_source' => $objet_source,
695
-					'id_objet_source' => $l[$primary],
696
-					'objet' => $l['objet'],
697
-					'id_objet' => $l['id_objet'],
698
-					'colonne_role' => $colonne_role,
699
-					'role' => ($colonne_role ? $l[$colonne_role] : ''),
700
-					'action' => 'delete',
701
-				];
702
-
703
-				// Envoyer aux plugins
704
-				$l = pipeline(
705
-					'pre_edition_lien',
706
-					[
707
-						'args' => $args,
708
-						'data' => $l
709
-					]
710
-				);
711
-				$args['id_objet'] = $id_o = $l['id_objet'];
712
-
713
-				if ($id_o = intval($l['id_objet']) or in_array($l['objet'], ['site', 'rubrique'])) {
714
-					$where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond);
715
-					$e = sql_delete($table_lien, $where);
716
-					if ($e !== false) {
717
-						$dels += $e;
718
-						lien_propage_date_modif($l['objet'], $id_o);
719
-						lien_propage_date_modif($objet_source, $l[$primary]);
720
-					} else {
721
-						$echec = true;
722
-					}
723
-					$retire[] = [
724
-						'source' => [$objet_source => $l[$primary]],
725
-						'lien' => [$l['objet'] => $id_o],
726
-						'type' => $l['objet'],
727
-						'role' => ($colonne_role ? $l[$colonne_role] : ''),
728
-						'id' => $id_o
729
-					];
730
-					// Envoyer aux plugins
731
-					pipeline(
732
-						'post_edition_lien',
733
-						[
734
-							'args' => $args,
735
-							'data' => $l
736
-						]
737
-					);
738
-				}
739
-			}
740
-		}
741
-	}
742
-	// si on a supprime des liens, on reordonne les liens concernes
743
-	if ($dels) {
744
-		lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
745
-	}
746
-
747
-	pipeline('trig_supprimer_objets_lies', $retire);
748
-
749
-	return ($echec ? false : $dels);
666
+    $retire = [];
667
+    $dels = 0;
668
+    $echec = false;
669
+    if (is_null($cond)) {
670
+        $cond = [];
671
+    }
672
+
673
+    foreach ($objets as $objet => $id_objets) {
674
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
675
+        if (!is_array($id_objets) or reset($id_objets) == 'NOT') {
676
+            $id_objets = [$id_objets];
677
+        }
678
+        foreach ($id_objets as $id_objet) {
679
+            [$cond, $colonne_role, $role] = roles_creer_condition_role($objet_source, $objet, $cond);
680
+            // id_objet peut valoir '*'
681
+            $where = lien_where($primary, $id, $objet, $id_objet, $cond);
682
+
683
+            // lire les liens existants pour propager la date de modif
684
+            $select = "$primary,id_objet,objet";
685
+            if ($colonne_role) {
686
+                $select .= ",$colonne_role";
687
+            }
688
+            $liens = sql_allfetsel($select, $table_lien, $where);
689
+
690
+            // iterer sur les liens pour permettre aux plugins de gerer
691
+            foreach ($liens as $l) {
692
+                $args = [
693
+                    'table_lien' => $table_lien,
694
+                    'objet_source' => $objet_source,
695
+                    'id_objet_source' => $l[$primary],
696
+                    'objet' => $l['objet'],
697
+                    'id_objet' => $l['id_objet'],
698
+                    'colonne_role' => $colonne_role,
699
+                    'role' => ($colonne_role ? $l[$colonne_role] : ''),
700
+                    'action' => 'delete',
701
+                ];
702
+
703
+                // Envoyer aux plugins
704
+                $l = pipeline(
705
+                    'pre_edition_lien',
706
+                    [
707
+                        'args' => $args,
708
+                        'data' => $l
709
+                    ]
710
+                );
711
+                $args['id_objet'] = $id_o = $l['id_objet'];
712
+
713
+                if ($id_o = intval($l['id_objet']) or in_array($l['objet'], ['site', 'rubrique'])) {
714
+                    $where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond);
715
+                    $e = sql_delete($table_lien, $where);
716
+                    if ($e !== false) {
717
+                        $dels += $e;
718
+                        lien_propage_date_modif($l['objet'], $id_o);
719
+                        lien_propage_date_modif($objet_source, $l[$primary]);
720
+                    } else {
721
+                        $echec = true;
722
+                    }
723
+                    $retire[] = [
724
+                        'source' => [$objet_source => $l[$primary]],
725
+                        'lien' => [$l['objet'] => $id_o],
726
+                        'type' => $l['objet'],
727
+                        'role' => ($colonne_role ? $l[$colonne_role] : ''),
728
+                        'id' => $id_o
729
+                    ];
730
+                    // Envoyer aux plugins
731
+                    pipeline(
732
+                        'post_edition_lien',
733
+                        [
734
+                            'args' => $args,
735
+                            'data' => $l
736
+                        ]
737
+                    );
738
+                }
739
+            }
740
+        }
741
+    }
742
+    // si on a supprime des liens, on reordonne les liens concernes
743
+    if ($dels) {
744
+        lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
745
+    }
746
+
747
+    pipeline('trig_supprimer_objets_lies', $retire);
748
+
749
+    return ($echec ? false : $dels);
750 750
 }
751 751
 
752 752
 
@@ -769,67 +769,67 @@  discard block
 block discarded – undo
769 769
  * @return bool|int
770 770
  */
771 771
 function lien_optimise($objet_source, $primary, $table_lien, $id, $objets) {
772
-	include_spip('genie/optimiser');
773
-	$echec = false;
774
-	$dels = 0;
775
-	foreach ($objets as $objet => $id_objets) {
776
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
777
-		if (!is_array($id_objets) or reset($id_objets) == 'NOT') {
778
-			$id_objets = [$id_objets];
779
-		}
780
-		foreach ($id_objets as $id_objet) {
781
-			$where = lien_where($primary, $id, $objet, $id_objet);
782
-			# les liens vers un objet inexistant
783
-			$r = sql_select('DISTINCT objet', $table_lien, $where);
784
-			while ($t = sql_fetch($r)) {
785
-				$type = $t['objet'];
786
-				$spip_table_objet = table_objet_sql($type);
787
-				$id_table_objet = id_table_objet($type);
788
-				$res = sql_select(
789
-					"L.$primary AS id,L.id_objet",
790
-					// la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
791
-					// du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
792
-					// il faut les eliminier en repetant la condition dans le where L.objet='xxx'
793
-					"$table_lien AS L
772
+    include_spip('genie/optimiser');
773
+    $echec = false;
774
+    $dels = 0;
775
+    foreach ($objets as $objet => $id_objets) {
776
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
777
+        if (!is_array($id_objets) or reset($id_objets) == 'NOT') {
778
+            $id_objets = [$id_objets];
779
+        }
780
+        foreach ($id_objets as $id_objet) {
781
+            $where = lien_where($primary, $id, $objet, $id_objet);
782
+            # les liens vers un objet inexistant
783
+            $r = sql_select('DISTINCT objet', $table_lien, $where);
784
+            while ($t = sql_fetch($r)) {
785
+                $type = $t['objet'];
786
+                $spip_table_objet = table_objet_sql($type);
787
+                $id_table_objet = id_table_objet($type);
788
+                $res = sql_select(
789
+                    "L.$primary AS id,L.id_objet",
790
+                    // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
791
+                    // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
792
+                    // il faut les eliminier en repetant la condition dans le where L.objet='xxx'
793
+                    "$table_lien AS L
794 794
 									LEFT JOIN $spip_table_objet AS O
795 795
 										ON (O.$id_table_objet=L.id_objet AND L.objet=" . sql_quote($type) . ')',
796
-					'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL"
797
-				);
798
-				// sur une cle primaire composee, pas d'autres solutions que de virer un a un
799
-				while ($row = sql_fetch($res)) {
800
-					if ($primary === 'id_document' and in_array($type, ['site', 'rubrique']) and !intval($row['id_objet'])) {
801
-						continue; // gaffe, c'est le logo du site ou des rubriques!
802
-					}
803
-					$e = sql_delete(
804
-						$table_lien,
805
-						["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)]
806
-					);
807
-					if ($e != false) {
808
-						$dels += $e;
809
-						spip_log(
810
-							'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien",
811
-							'genie' . _LOG_INFO_IMPORTANTE
812
-						);
813
-					}
814
-				}
815
-			}
816
-
817
-			# les liens depuis un objet inexistant
818
-			$table_source = table_objet_sql($objet_source);
819
-			// filtrer selon $id, $objet, $id_objet eventuellement fournis
820
-			// (en general '*' pour chaque)
821
-			$where = lien_where("L.$primary", $id, $objet, $id_objet);
822
-			$where[] = "O.$primary IS NULL";
823
-			$res = sql_select(
824
-				"L.$primary AS id",
825
-				"$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
826
-				$where
827
-			);
828
-			$dels += optimiser_sansref($table_lien, $primary, $res);
829
-		}
830
-	}
831
-
832
-	return ($echec ? false : $dels);
796
+                    'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL"
797
+                );
798
+                // sur une cle primaire composee, pas d'autres solutions que de virer un a un
799
+                while ($row = sql_fetch($res)) {
800
+                    if ($primary === 'id_document' and in_array($type, ['site', 'rubrique']) and !intval($row['id_objet'])) {
801
+                        continue; // gaffe, c'est le logo du site ou des rubriques!
802
+                    }
803
+                    $e = sql_delete(
804
+                        $table_lien,
805
+                        ["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)]
806
+                    );
807
+                    if ($e != false) {
808
+                        $dels += $e;
809
+                        spip_log(
810
+                            'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien",
811
+                            'genie' . _LOG_INFO_IMPORTANTE
812
+                        );
813
+                    }
814
+                }
815
+            }
816
+
817
+            # les liens depuis un objet inexistant
818
+            $table_source = table_objet_sql($objet_source);
819
+            // filtrer selon $id, $objet, $id_objet eventuellement fournis
820
+            // (en general '*' pour chaque)
821
+            $where = lien_where("L.$primary", $id, $objet, $id_objet);
822
+            $where[] = "O.$primary IS NULL";
823
+            $res = sql_select(
824
+                "L.$primary AS id",
825
+                "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
826
+                $where
827
+            );
828
+            $dels += optimiser_sansref($table_lien, $primary, $res);
829
+        }
830
+    }
831
+
832
+    return ($echec ? false : $dels);
833 833
 }
834 834
 
835 835
 
@@ -861,92 +861,92 @@  discard block
 block discarded – undo
861 861
  *     Nombre de modifications faites, false si échec.
862 862
  */
863 863
 function lien_set($objet_source, $primary, $table_lien, $id, $objets, $qualif) {
864
-	$echec = null;
865
-	$ok = 0;
866
-	$reordonner = false;
867
-	if (!$qualif) {
868
-		return false;
869
-	}
870
-	// nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
871
-	unset($qualif[$primary]);
872
-	unset($qualif[$objet_source]);
873
-	if (isset($qualif['objet'])) {
874
-		unset($qualif[$qualif['objet']]);
875
-	}
876
-	unset($qualif['objet']);
877
-	unset($qualif['id_objet']);
878
-	foreach ($objets as $objet => $id_objets) {
879
-		// role, colonne, where par défaut
880
-		[$role, $colonne_role, $cond] =
881
-			roles_trouver_dans_qualif($objet_source, $objet, $qualif);
882
-
883
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
884
-		if (!is_array($id_objets) or reset($id_objets) == 'NOT') {
885
-			$id_objets = [$id_objets];
886
-		}
887
-		foreach ($id_objets as $id_objet) {
888
-			$args = [
889
-				'table_lien' => $table_lien,
890
-				'objet_source' => $objet_source,
891
-				'id_objet_source' => $id,
892
-				'objet' => $objet,
893
-				'id_objet' => $id_objet,
894
-				'role' => $role,
895
-				'colonne_role' => $colonne_role,
896
-				'action' => 'modifier',
897
-			];
898
-
899
-			// Envoyer aux plugins
900
-			$qualif = pipeline(
901
-				'pre_edition_lien',
902
-				[
903
-					'args' => $args,
904
-					'data' => $qualif,
905
-				]
906
-			);
907
-			$args['id_objet'] = $id_objet;
908
-
909
-			if (lien_triables($table_lien) and isset($qualif['rang_lien'])) {
910
-				if (intval($qualif['rang_lien'])) {
911
-					// on decale les liens de rang_lien>=la valeur inseree pour faire la place
912
-					// sauf sur le meme lien avec un role eventuellement different
913
-					$where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
914
-					$where_meme_lien = implode(' AND ', $where_meme_lien);
915
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($qualif['rang_lien']), "NOT($where_meme_lien)"]);
916
-					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
917
-				}
918
-				// tous les liens de même rôle recoivent le rang indiqué aussi
919
-				if (roles_colonne($objet_source, $objet)) {
920
-					$w = lien_where($primary, $id, $objet, $id_objet);
921
-					sql_updateq($table_lien, ['rang_lien' => intval($qualif['rang_lien'])], $w);
922
-				}
923
-				$reordonner = true;
924
-			}
925
-
926
-			$where = lien_where($primary, $id, $objet, $id_objet, $cond);
927
-			$e = sql_updateq($table_lien, $qualif, $where);
928
-
929
-			if ($e === false) {
930
-				$echec = true;
931
-			} else {
932
-				// Envoyer aux plugins
933
-				pipeline(
934
-					'post_edition_lien',
935
-					[
936
-						'args' => $args,
937
-						'data' => $qualif
938
-					]
939
-				);
940
-				$ok++;
941
-			}
942
-		}
943
-	}
944
-	// si on a fait des modif de rang, on reordonne les liens concernes
945
-	if ($reordonner) {
946
-		lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
947
-	}
948
-
949
-	return ($echec ? false : $ok);
864
+    $echec = null;
865
+    $ok = 0;
866
+    $reordonner = false;
867
+    if (!$qualif) {
868
+        return false;
869
+    }
870
+    // nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
871
+    unset($qualif[$primary]);
872
+    unset($qualif[$objet_source]);
873
+    if (isset($qualif['objet'])) {
874
+        unset($qualif[$qualif['objet']]);
875
+    }
876
+    unset($qualif['objet']);
877
+    unset($qualif['id_objet']);
878
+    foreach ($objets as $objet => $id_objets) {
879
+        // role, colonne, where par défaut
880
+        [$role, $colonne_role, $cond] =
881
+            roles_trouver_dans_qualif($objet_source, $objet, $qualif);
882
+
883
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
884
+        if (!is_array($id_objets) or reset($id_objets) == 'NOT') {
885
+            $id_objets = [$id_objets];
886
+        }
887
+        foreach ($id_objets as $id_objet) {
888
+            $args = [
889
+                'table_lien' => $table_lien,
890
+                'objet_source' => $objet_source,
891
+                'id_objet_source' => $id,
892
+                'objet' => $objet,
893
+                'id_objet' => $id_objet,
894
+                'role' => $role,
895
+                'colonne_role' => $colonne_role,
896
+                'action' => 'modifier',
897
+            ];
898
+
899
+            // Envoyer aux plugins
900
+            $qualif = pipeline(
901
+                'pre_edition_lien',
902
+                [
903
+                    'args' => $args,
904
+                    'data' => $qualif,
905
+                ]
906
+            );
907
+            $args['id_objet'] = $id_objet;
908
+
909
+            if (lien_triables($table_lien) and isset($qualif['rang_lien'])) {
910
+                if (intval($qualif['rang_lien'])) {
911
+                    // on decale les liens de rang_lien>=la valeur inseree pour faire la place
912
+                    // sauf sur le meme lien avec un role eventuellement different
913
+                    $where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
914
+                    $where_meme_lien = implode(' AND ', $where_meme_lien);
915
+                    $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($qualif['rang_lien']), "NOT($where_meme_lien)"]);
916
+                    sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
917
+                }
918
+                // tous les liens de même rôle recoivent le rang indiqué aussi
919
+                if (roles_colonne($objet_source, $objet)) {
920
+                    $w = lien_where($primary, $id, $objet, $id_objet);
921
+                    sql_updateq($table_lien, ['rang_lien' => intval($qualif['rang_lien'])], $w);
922
+                }
923
+                $reordonner = true;
924
+            }
925
+
926
+            $where = lien_where($primary, $id, $objet, $id_objet, $cond);
927
+            $e = sql_updateq($table_lien, $qualif, $where);
928
+
929
+            if ($e === false) {
930
+                $echec = true;
931
+            } else {
932
+                // Envoyer aux plugins
933
+                pipeline(
934
+                    'post_edition_lien',
935
+                    [
936
+                        'args' => $args,
937
+                        'data' => $qualif
938
+                    ]
939
+                );
940
+                $ok++;
941
+            }
942
+        }
943
+    }
944
+    // si on a fait des modif de rang, on reordonne les liens concernes
945
+    if ($reordonner) {
946
+        lien_ordonner($objet_source, $primary, $table_lien, $id, $objets);
947
+    }
948
+
949
+    return ($echec ? false : $ok);
950 950
 }
951 951
 
952 952
 /**
@@ -976,23 +976,23 @@  discard block
 block discarded – undo
976 976
  * @return array
977 977
  */
978 978
 function lien_find($objet_source, $primary, $table_lien, $id, $objets, $cond = null) {
979
-	$trouve = [];
980
-	foreach ($objets as $objet => $id_objets) {
981
-		$objet = ($objet == '*') ? $objet : objet_type($objet); # securite
982
-		// gerer les roles s'il y en a dans $cond
983
-		[$cond] = roles_creer_condition_role($objet_source, $objet, $cond, true);
984
-		// lien_where prend en charge les $id_objets sous forme int ou array
985
-		$where = lien_where($primary, $id, $objet, $id_objets, $cond);
986
-		$liens = sql_allfetsel('*', $table_lien, $where);
987
-		// ajouter les entrees objet_source et objet cible par convenance
988
-		foreach ($liens as $l) {
989
-			$l[$objet_source] = $l[$primary];
990
-			$l[$l['objet']] = $l['id_objet'];
991
-			$trouve[] = $l;
992
-		}
993
-	}
994
-
995
-	return $trouve;
979
+    $trouve = [];
980
+    foreach ($objets as $objet => $id_objets) {
981
+        $objet = ($objet == '*') ? $objet : objet_type($objet); # securite
982
+        // gerer les roles s'il y en a dans $cond
983
+        [$cond] = roles_creer_condition_role($objet_source, $objet, $cond, true);
984
+        // lien_where prend en charge les $id_objets sous forme int ou array
985
+        $where = lien_where($primary, $id, $objet, $id_objets, $cond);
986
+        $liens = sql_allfetsel('*', $table_lien, $where);
987
+        // ajouter les entrees objet_source et objet cible par convenance
988
+        foreach ($liens as $l) {
989
+            $l[$objet_source] = $l[$primary];
990
+            $l[$l['objet']] = $l['id_objet'];
991
+            $trouve[] = $l;
992
+        }
993
+    }
994
+
995
+    return $trouve;
996 996
 }
997 997
 
998 998
 /**
@@ -1003,26 +1003,26 @@  discard block
 block discarded – undo
1003 1003
  * @param array|int $ids
1004 1004
  */
1005 1005
 function lien_propage_date_modif($objet, $ids) {
1006
-	static $done = [];
1007
-	$hash = md5($objet . serialize($ids));
1008
-
1009
-	// sql_updateq, peut être un rien lent.
1010
-	// On évite de l'appeler 2 fois sur les mêmes choses
1011
-	if (isset($done[$hash])) {
1012
-		return;
1013
-	}
1014
-
1015
-	$trouver_table = charger_fonction('trouver_table', 'base');
1016
-
1017
-	$table = table_objet_sql($objet);
1018
-	if (
1019
-		$desc = $trouver_table($table)
1020
-		and isset($desc['field']['date_modif'])
1021
-	) {
1022
-		$primary = id_table_objet($objet);
1023
-		$where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids));
1024
-		sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where);
1025
-	}
1026
-
1027
-	$done[$hash] = true;
1006
+    static $done = [];
1007
+    $hash = md5($objet . serialize($ids));
1008
+
1009
+    // sql_updateq, peut être un rien lent.
1010
+    // On évite de l'appeler 2 fois sur les mêmes choses
1011
+    if (isset($done[$hash])) {
1012
+        return;
1013
+    }
1014
+
1015
+    $trouver_table = charger_fonction('trouver_table', 'base');
1016
+
1017
+    $table = table_objet_sql($objet);
1018
+    if (
1019
+        $desc = $trouver_table($table)
1020
+        and isset($desc['field']['date_modif'])
1021
+    ) {
1022
+        $primary = id_table_objet($objet);
1023
+        $where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids));
1024
+        sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where);
1025
+    }
1026
+
1027
+    $done[$hash] = true;
1028 1028
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	$l = '';
54 54
 	if (
55 55
 		$primary = id_table_objet($objet)
56
-		and $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false])
56
+		and $trouver_table($l = $table_sql.'_liens', '', true, ['log_missing' => false])
57 57
 		and !preg_match(',[^\w],', $primary)
58 58
 		and !preg_match(',[^\w],', $l)
59 59
 	) {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
  * @return int
213 213
  */
214 214
 function objet_optimiser_liens($objets_source, $objets_lies) {
215
-	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
+	spip_log('objet_optimiser_liens : '.json_encode($objets_source, JSON_THROW_ON_ERROR).', '.json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie'._LOG_DEBUG);
216 216
 	return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies);
217 217
 }
218 218
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 					$where_meme_lien = implode(' AND ', $where_meme_lien);
447 447
 					// on decale les liens de rang_lien>=la valeur inseree pour faire la place
448 448
 					// sauf sur le meme lien avec un role eventuellement different
449
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($insertions['rang_lien']), "NOT($where_meme_lien)"]);
449
+					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>='.intval($insertions['rang_lien']), "NOT($where_meme_lien)"]);
450 450
 					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
451 451
 				}
452 452
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 					$rang = 1;
512 512
 					foreach ($liens as $lien) {
513 513
 						if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) {
514
-							$where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . intval($rang)]);
514
+							$where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!='.intval($rang)]);
515 515
 							sql_updateq($table_lien, ['rang_lien' => $rang], $where);
516 516
 
517 517
 							if (empty($deja_reordonne[$lien[$primary]])) {
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 			addslashes($primary),
588 588
 			array_map('intval', $id_source),
589 589
 			$not
590
-		) : addslashes($primary) . ($not ? '<>' : '=') . intval($id_source));
590
+		) : addslashes($primary).($not ? '<>' : '=').intval($id_source));
591 591
 	} elseif ($not) {
592 592
 		$where[] = '0=1';
593 593
 	} // idiot mais quand meme
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
 	}
600 600
 
601 601
 	if ($objet !== '*') {
602
-		$where[] = 'objet=' . sql_quote($objet);
602
+		$where[] = 'objet='.sql_quote($objet);
603 603
 	}
604 604
 	if ($id_objet !== '*') {
605 605
 		$where[] = (is_array($id_objet) ? sql_in(
606 606
 			'id_objet',
607 607
 			array_map('intval', $id_objet),
608 608
 			$not
609
-		) : 'id_objet' . ($not ? '<>' : '=') . intval($id_objet));
609
+		) : 'id_objet'.($not ? '<>' : '=').intval($id_objet));
610 610
 	} elseif ($not) {
611 611
 		$where[] = '0=1';
612 612
 	} // idiot mais quand meme
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 function lien_rang_where($table_lien, $primary, $id_source, $objet, $id_objet, $cond = []) {
628 628
 
629 629
 	// si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc
630
-	if (function_exists($f = 'lien_rang_where_' . $table_lien)) {
630
+	if (function_exists($f = 'lien_rang_where_'.$table_lien)) {
631 631
 		return $f($primary, $id_source, $objet, $id_objet, $cond);
632 632
 	}
633 633
 
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 					// il faut les eliminier en repetant la condition dans le where L.objet='xxx'
793 793
 					"$table_lien AS L
794 794
 									LEFT JOIN $spip_table_objet AS O
795
-										ON (O.$id_table_objet=L.id_objet AND L.objet=" . sql_quote($type) . ')',
796
-					'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL"
795
+										ON (O.$id_table_objet=L.id_objet AND L.objet=".sql_quote($type).')',
796
+					'L.objet='.sql_quote($type)." AND O.$id_table_objet IS NULL"
797 797
 				);
798 798
 				// sur une cle primaire composee, pas d'autres solutions que de virer un a un
799 799
 				while ($row = sql_fetch($res)) {
@@ -802,13 +802,13 @@  discard block
 block discarded – undo
802 802
 					}
803 803
 					$e = sql_delete(
804 804
 						$table_lien,
805
-						["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)]
805
+						["$primary=".$row['id'], 'id_objet='.$row['id_objet'], 'objet='.sql_quote($type)]
806 806
 					);
807 807
 					if ($e != false) {
808 808
 						$dels += $e;
809 809
 						spip_log(
810
-							'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien",
811
-							'genie' . _LOG_INFO_IMPORTANTE
810
+							'lien_optimise: Entree '.$row['id'].'/'.$row['id_objet']."/$type supprimee dans la table $table_lien",
811
+							'genie'._LOG_INFO_IMPORTANTE
812 812
 						);
813 813
 					}
814 814
 				}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 					// sauf sur le meme lien avec un role eventuellement different
913 913
 					$where_meme_lien = lien_where($primary, $id, $objet, $id_objet);
914 914
 					$where_meme_lien = implode(' AND ', $where_meme_lien);
915
-					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($qualif['rang_lien']), "NOT($where_meme_lien)"]);
915
+					$w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>='.intval($qualif['rang_lien']), "NOT($where_meme_lien)"]);
916 916
 					sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w);
917 917
 				}
918 918
 				// tous les liens de même rôle recoivent le rang indiqué aussi
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
  */
1005 1005
 function lien_propage_date_modif($objet, $ids) {
1006 1006
 	static $done = [];
1007
-	$hash = md5($objet . serialize($ids));
1007
+	$hash = md5($objet.serialize($ids));
1008 1008
 
1009 1009
 	// sql_updateq, peut être un rien lent.
1010 1010
 	// On évite de l'appeler 2 fois sur les mêmes choses
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 		and isset($desc['field']['date_modif'])
1021 1021
 	) {
1022 1022
 		$primary = id_table_objet($objet);
1023
-		$where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids));
1023
+		$where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=".intval($ids));
1024 1024
 		sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where);
1025 1025
 	}
1026 1026
 
Please login to merge, or discard this patch.
ecrire/inc/headers.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 		(!$equiv and !spip_cookie_envoye()) or (
80 80
 			   (!empty($_SERVER['SERVER_SOFTWARE'])
81 81
 				   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
82
-				   and preg_match('/' . _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SOFTWARE']))
82
+				   and preg_match('/'._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE.'/i', $_SERVER['SERVER_SOFTWARE']))
83 83
 			or (!empty($_SERVER['SERVER_SIGNATURE'])
84 84
 				   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
85
-				   and preg_match('/' . _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SIGNATURE']))
85
+				   and preg_match('/'._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE.'/i', $_SERVER['SERVER_SIGNATURE']))
86 86
 			or function_exists('apache_getenv')
87 87
 			or defined('_SERVER_APACHE')
88 88
 		)
89 89
 	) {
90
-		@header('Location: ' . $url);
90
+		@header('Location: '.$url);
91 91
 		$equiv = '';
92 92
 	} else {
93
-		@header('Refresh: 0; url=' . $url);
93
+		@header('Refresh: 0; url='.$url);
94 94
 		if (isset($GLOBALS['meta']['charset'])) {
95
-			@header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
95
+			@header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']);
96 96
 		}
97 97
 		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
98 98
 	}
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	html_lang_attributes(), '
105 105
 <head>',
106 106
 	$equiv, '
107
-<title>HTTP ' . $status . '</title>
108
-' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . '
107
+<title>HTTP ' . $status.'</title>
108
+' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset='.$GLOBALS['meta']['charset'].'">' : '').'
109 109
 </head>
110 110
 <body>
111
-<h1>HTTP ' . $status . '</h1>
111
+<h1>HTTP ' . $status.'</h1>
112 112
 <a href="',
113 113
 	quote_amp($url),
114 114
 	'">',
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		# en theorie on devrait faire ca tout le temps, mais quand la chaine
145 145
 		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
146 146
 		if ($url[0] == '?') {
147
-			$url = url_de_base() . $url;
147
+			$url = url_de_base().$url;
148 148
 		}
149 149
 		$url = str_replace('&amp;', '&', $url);
150 150
 		spip_log("redirige formulaire ajax: $url");
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 		if ($format == 'ajaxform') {
153 153
 			return [
154 154
 				// on renvoie un lien masque qui sera traite par ajaxCallback.js
155
-				'<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
155
+				'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
156 156
 				// et un message au cas ou
157
-				'<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
157
+				'<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
158 158
 			];
159 159
 		} else // format message texte, tout en js inline
160 160
 		{
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 				"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
164 164
 				. http_img_pack('loader.svg', '', " class='loader'")
165 165
 				. '<br />'
166
-				. '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
166
+				. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
167 167
 		}
168 168
 	}
169 169
 }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
 	header("Content-Type: text/html; charset=$charset");
224 224
 	header('Expires: 0');
225
-	header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
225
+	header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
226 226
 	header('Cache-Control: no-cache, must-revalidate');
227 227
 	header('Pragma: no-cache');
228 228
 }
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -38,133 +38,133 @@  discard block
 block discarded – undo
38 38
  * @param int $status Code de redirection (301 ou 302)
39 39
  **/
40 40
 function redirige_par_entete($url, $equiv = '', $status = 302) {
41
-	if (!in_array($status, [301, 302])) {
42
-		$status = 302;
43
-	}
44
-
45
-	$url = trim(strtr($url, "\n\r", '  '));
46
-	# si l'url de redirection est relative, on la passe en absolue
47
-	if (!preg_match(',^(\w+:)?//,', $url)) {
48
-		include_spip('inc/filtres_mini');
49
-		$url = url_absolue($url);
50
-	}
51
-
52
-	if (defined('_AJAX') and _AJAX) {
53
-		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
54
-	}
55
-
56
-	// ne pas laisser passer n'importe quoi dans l'url
57
-	$url = str_replace(['<', '"'], ['&lt;', '&quot;'], $url);
58
-	$url = str_replace(["\r", "\n", ' '], ['%0D', '%0A', '%20'], $url);
59
-	while (strpos($url, '%0A') !== false) {
60
-		$url = str_replace('%0A', '', $url);
61
-	}
62
-	// interdire les url inline avec des pseudo-protocoles :
63
-	if (
64
-		(preg_match(',data:,i', $url) and preg_match('/base64\s*,/i', $url))
65
-		or preg_match(',(javascript|mailto):,i', $url)
66
-	) {
67
-		$url = './';
68
-	}
69
-
70
-	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
71
-	include_spip('inc/cookie');
72
-	if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) {
73
-		define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)');
74
-	}
75
-	if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) {
76
-		define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx');
77
-	}
78
-	if (
79
-		(!$equiv and !spip_cookie_envoye()) or (
80
-			   (!empty($_SERVER['SERVER_SOFTWARE'])
81
-				   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
82
-				   and preg_match('/' . _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SOFTWARE']))
83
-			or (!empty($_SERVER['SERVER_SIGNATURE'])
84
-				   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
85
-				   and preg_match('/' . _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SIGNATURE']))
86
-			or function_exists('apache_getenv')
87
-			or defined('_SERVER_APACHE')
88
-		)
89
-	) {
90
-		@header('Location: ' . $url);
91
-		$equiv = '';
92
-	} else {
93
-		@header('Refresh: 0; url=' . $url);
94
-		if (isset($GLOBALS['meta']['charset'])) {
95
-			@header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
96
-		}
97
-		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
98
-	}
99
-	include_spip('inc/lang');
100
-	if ($status != 302) {
101
-		http_response_code($status);
102
-	}
103
-	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n",
104
-	html_lang_attributes(), '
41
+    if (!in_array($status, [301, 302])) {
42
+        $status = 302;
43
+    }
44
+
45
+    $url = trim(strtr($url, "\n\r", '  '));
46
+    # si l'url de redirection est relative, on la passe en absolue
47
+    if (!preg_match(',^(\w+:)?//,', $url)) {
48
+        include_spip('inc/filtres_mini');
49
+        $url = url_absolue($url);
50
+    }
51
+
52
+    if (defined('_AJAX') and _AJAX) {
53
+        $url = parametre_url($url, 'var_ajax_redir', 1, '&');
54
+    }
55
+
56
+    // ne pas laisser passer n'importe quoi dans l'url
57
+    $url = str_replace(['<', '"'], ['&lt;', '&quot;'], $url);
58
+    $url = str_replace(["\r", "\n", ' '], ['%0D', '%0A', '%20'], $url);
59
+    while (strpos($url, '%0A') !== false) {
60
+        $url = str_replace('%0A', '', $url);
61
+    }
62
+    // interdire les url inline avec des pseudo-protocoles :
63
+    if (
64
+        (preg_match(',data:,i', $url) and preg_match('/base64\s*,/i', $url))
65
+        or preg_match(',(javascript|mailto):,i', $url)
66
+    ) {
67
+        $url = './';
68
+    }
69
+
70
+    // Il n'y a que sous Apache que setcookie puis redirection fonctionne
71
+    include_spip('inc/cookie');
72
+    if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) {
73
+        define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)');
74
+    }
75
+    if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) {
76
+        define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx');
77
+    }
78
+    if (
79
+        (!$equiv and !spip_cookie_envoye()) or (
80
+                (!empty($_SERVER['SERVER_SOFTWARE'])
81
+                   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
82
+                   and preg_match('/' . _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SOFTWARE']))
83
+            or (!empty($_SERVER['SERVER_SIGNATURE'])
84
+                   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
85
+                   and preg_match('/' . _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE . '/i', $_SERVER['SERVER_SIGNATURE']))
86
+            or function_exists('apache_getenv')
87
+            or defined('_SERVER_APACHE')
88
+        )
89
+    ) {
90
+        @header('Location: ' . $url);
91
+        $equiv = '';
92
+    } else {
93
+        @header('Refresh: 0; url=' . $url);
94
+        if (isset($GLOBALS['meta']['charset'])) {
95
+            @header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
96
+        }
97
+        $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
98
+    }
99
+    include_spip('inc/lang');
100
+    if ($status != 302) {
101
+        http_response_code($status);
102
+    }
103
+    echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n",
104
+    html_lang_attributes(), '
105 105
 <head>',
106
-	$equiv, '
106
+    $equiv, '
107 107
 <title>HTTP ' . $status . '</title>
108 108
 ' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . '
109 109
 </head>
110 110
 <body>
111 111
 <h1>HTTP ' . $status . '</h1>
112 112
 <a href="',
113
-	quote_amp($url),
114
-	'">',
115
-	_T('navigateur_pas_redirige'),
116
-	'</a></body></html>';
113
+    quote_amp($url),
114
+    '">',
115
+    _T('navigateur_pas_redirige'),
116
+    '</a></body></html>';
117 117
 
118
-	spip_log("redirige $status: $url");
118
+    spip_log("redirige $status: $url");
119 119
 
120
-	exit;
120
+    exit;
121 121
 }
122 122
 
123 123
 function redirige_formulaire($url, $equiv = '', $format = 'message') {
124
-	if (
125
-		!_AJAX
126
-		and !headers_sent()
127
-		and !_request('var_ajax')
128
-	) {
129
-		redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
130
-	} // si c'est une ancre, fixer simplement le window.location.hash
131
-	elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
132
-		return [
133
-			// on renvoie un lien masque qui sera traite par ajaxCallback.js
134
-			"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
135
-			// et rien dans le message ok
136
-			''
137
-		];
138
-	} else {
139
-		// ne pas laisser passer n'importe quoi dans l'url
140
-		$url = str_replace(['<', '"'], ['&lt;', '&quot;'], $url);
141
-
142
-		$url = strtr($url, "\n\r", '  ');
143
-		# en theorie on devrait faire ca tout le temps, mais quand la chaine
144
-		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
145
-		if ($url[0] == '?') {
146
-			$url = url_de_base() . $url;
147
-		}
148
-		$url = str_replace('&amp;', '&', $url);
149
-		spip_log("redirige formulaire ajax: $url");
150
-		include_spip('inc/filtres');
151
-		if ($format == 'ajaxform') {
152
-			return [
153
-				// on renvoie un lien masque qui sera traite par ajaxCallback.js
154
-				'<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
155
-				// et un message au cas ou
156
-				'<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
157
-			];
158
-		} else // format message texte, tout en js inline
159
-		{
160
-			return
161
-				// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
162
-				"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
163
-				. http_img_pack('loader.svg', '', " class='loader'")
164
-				. '<br />'
165
-				. '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
166
-		}
167
-	}
124
+    if (
125
+        !_AJAX
126
+        and !headers_sent()
127
+        and !_request('var_ajax')
128
+    ) {
129
+        redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
130
+    } // si c'est une ancre, fixer simplement le window.location.hash
131
+    elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
132
+        return [
133
+            // on renvoie un lien masque qui sera traite par ajaxCallback.js
134
+            "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
135
+            // et rien dans le message ok
136
+            ''
137
+        ];
138
+    } else {
139
+        // ne pas laisser passer n'importe quoi dans l'url
140
+        $url = str_replace(['<', '"'], ['&lt;', '&quot;'], $url);
141
+
142
+        $url = strtr($url, "\n\r", '  ');
143
+        # en theorie on devrait faire ca tout le temps, mais quand la chaine
144
+        # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
145
+        if ($url[0] == '?') {
146
+            $url = url_de_base() . $url;
147
+        }
148
+        $url = str_replace('&amp;', '&', $url);
149
+        spip_log("redirige formulaire ajax: $url");
150
+        include_spip('inc/filtres');
151
+        if ($format == 'ajaxform') {
152
+            return [
153
+                // on renvoie un lien masque qui sera traite par ajaxCallback.js
154
+                '<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
155
+                // et un message au cas ou
156
+                '<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
157
+            ];
158
+        } else // format message texte, tout en js inline
159
+        {
160
+            return
161
+                // ie poste les formulaires dans une iframe, il faut donc rediriger son parent
162
+                "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
163
+                . http_img_pack('loader.svg', '', " class='loader'")
164
+                . '<br />'
165
+                . '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
166
+        }
167
+    }
168 168
 }
169 169
 
170 170
 /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
  * @return void
186 186
  **/
187 187
 function redirige_url_ecrire($script = '', $args = '', $equiv = '') {
188
-	return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
188
+    return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
189 189
 }
190 190
 /**
191 191
  * Renvoie au client le header HTTP avec le message correspondant au code indiqué.
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  *     Code d'erreur
201 201
  **/
202 202
 function http_status($status) {
203
-	http_response_code($status);
203
+    http_response_code($status);
204 204
 }
205 205
 
206 206
 // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
207 207
 function http_no_cache() {
208
-	if (headers_sent()) {
209
-		spip_log('http_no_cache arrive trop tard');
210
-
211
-		return;
212
-	}
213
-	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
214
-
215
-	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
216
-	// il faudrait aussi pour Safari
217
-	// header("Cache-Control: post-check=0, pre-check=0", false)
218
-	// mais ca ne respecte pas
219
-	// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
220
-
221
-	header("Content-Type: text/html; charset=$charset");
222
-	header('Expires: 0');
223
-	header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
224
-	header('Cache-Control: no-cache, must-revalidate');
225
-	header('Pragma: no-cache');
208
+    if (headers_sent()) {
209
+        spip_log('http_no_cache arrive trop tard');
210
+
211
+        return;
212
+    }
213
+    $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
214
+
215
+    // selon http://developer.apple.com/internet/safari/faq.html#anchor5
216
+    // il faudrait aussi pour Safari
217
+    // header("Cache-Control: post-check=0, pre-check=0", false)
218
+    // mais ca ne respecte pas
219
+    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
220
+
221
+    header("Content-Type: text/html; charset=$charset");
222
+    header('Expires: 0');
223
+    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
224
+    header('Cache-Control: no-cache, must-revalidate');
225
+    header('Pragma: no-cache');
226 226
 }
Please login to merge, or discard this patch.
prive/formulaires/configurer_articles.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,65 +11,65 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function formulaires_configurer_articles_charger_dist() {
18
-	$valeurs = [];
19
-	foreach (
20
-		[
21
-			'articles_surtitre',
22
-			'articles_soustitre',
23
-			'articles_descriptif',
24
-			'articles_chapeau',
25
-			'articles_texte',
26
-			'articles_ps',
27
-			'articles_redac',
28
-			'articles_urlref',
29
-			'post_dates',
30
-			'articles_redirection',
31
-		] as $m
32
-	) {
33
-		$valeurs[$m] = $GLOBALS['meta'][$m];
34
-	}
18
+    $valeurs = [];
19
+    foreach (
20
+        [
21
+            'articles_surtitre',
22
+            'articles_soustitre',
23
+            'articles_descriptif',
24
+            'articles_chapeau',
25
+            'articles_texte',
26
+            'articles_ps',
27
+            'articles_redac',
28
+            'articles_urlref',
29
+            'post_dates',
30
+            'articles_redirection',
31
+        ] as $m
32
+    ) {
33
+        $valeurs[$m] = $GLOBALS['meta'][$m];
34
+    }
35 35
 
36
-	return $valeurs;
36
+    return $valeurs;
37 37
 }
38 38
 
39 39
 
40 40
 function formulaires_configurer_articles_traiter_dist() {
41
-	$res = ['editable' => true];
42
-	$purger_skel = false;
43
-	// Purger les squelettes si un changement de meta les affecte
44
-	if ($i = _request('post_dates') and ($i != $GLOBALS['meta']['post_dates'])) {
45
-		$purger_skel = true;
46
-	}
41
+    $res = ['editable' => true];
42
+    $purger_skel = false;
43
+    // Purger les squelettes si un changement de meta les affecte
44
+    if ($i = _request('post_dates') and ($i != $GLOBALS['meta']['post_dates'])) {
45
+        $purger_skel = true;
46
+    }
47 47
 
48
-	foreach (
49
-		[
50
-			'articles_surtitre',
51
-			'articles_soustitre',
52
-			'articles_descriptif',
53
-			'articles_chapeau',
54
-			'articles_texte',
55
-			'articles_ps',
56
-			'articles_redac',
57
-			'articles_urlref',
58
-			'post_dates',
59
-			'articles_redirection',
60
-		] as $m
61
-	) {
62
-		if (!is_null($v = _request($m))) {
63
-			ecrire_meta($m, $v == 'oui' ? 'oui' : 'non');
64
-		}
65
-	}
48
+    foreach (
49
+        [
50
+            'articles_surtitre',
51
+            'articles_soustitre',
52
+            'articles_descriptif',
53
+            'articles_chapeau',
54
+            'articles_texte',
55
+            'articles_ps',
56
+            'articles_redac',
57
+            'articles_urlref',
58
+            'post_dates',
59
+            'articles_redirection',
60
+        ] as $m
61
+    ) {
62
+        if (!is_null($v = _request($m))) {
63
+            ecrire_meta($m, $v == 'oui' ? 'oui' : 'non');
64
+        }
65
+    }
66 66
 
67
-	if ($purger_skel) {
68
-		include_spip('inc/invalideur');
69
-		purger_repertoire(_DIR_SKELS);
70
-	}
67
+    if ($purger_skel) {
68
+        include_spip('inc/invalideur');
69
+        purger_repertoire(_DIR_SKELS);
70
+    }
71 71
 
72
-	$res['message_ok'] = _T('config_info_enregistree');
72
+    $res['message_ok'] = _T('config_info_enregistree');
73 73
 
74
-	return $res;
74
+    return $res;
75 75
 }
Please login to merge, or discard this patch.
prive/formulaires/configurer_avertisseur.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/presentation');
17 17
 
18 18
 function formulaires_configurer_avertisseur_charger_dist() {
19
-	$valeurs = [];
20
-	foreach (
21
-		[
22
-			'articles_modif',
23
-		] as $m
24
-	) {
25
-		$valeurs[$m] = $GLOBALS['meta'][$m];
26
-	}
27
-
28
-	return $valeurs;
19
+    $valeurs = [];
20
+    foreach (
21
+        [
22
+            'articles_modif',
23
+        ] as $m
24
+    ) {
25
+        $valeurs[$m] = $GLOBALS['meta'][$m];
26
+    }
27
+
28
+    return $valeurs;
29 29
 }
30 30
 
31 31
 
32 32
 function formulaires_configurer_avertisseur_traiter_dist() {
33
-	$res = ['editable' => true];
34
-	foreach (
35
-		[
36
-			'articles_modif',
37
-		] as $m
38
-	) {
39
-		if (!is_null($v = _request($m))) {
40
-			ecrire_meta($m, $v == 'oui' ? 'oui' : 'non');
41
-		}
42
-	}
43
-
44
-	$res['message_ok'] = _T('config_info_enregistree');
45
-
46
-	return $res;
33
+    $res = ['editable' => true];
34
+    foreach (
35
+        [
36
+            'articles_modif',
37
+        ] as $m
38
+    ) {
39
+        if (!is_null($v = _request($m))) {
40
+            ecrire_meta($m, $v == 'oui' ? 'oui' : 'non');
41
+        }
42
+    }
43
+
44
+    $res['message_ok'] = _T('config_info_enregistree');
45
+
46
+    return $res;
47 47
 }
Please login to merge, or discard this patch.