Completed
Push — master ( 312538...9be7c4 )
by cam
01:44
created
ecrire/inc/actions.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
43 43
  */
44 44
 function generer_action_auteur($action, $arg = '', $redirect = '', $mode = false, $att = '', $public = false) {
45
-	$securiser_action = charger_fonction('securiser_action', 'inc');
45
+    $securiser_action = charger_fonction('securiser_action', 'inc');
46 46
 
47
-	return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
47
+    return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
48 48
 }
49 49
 
50 50
 /**
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
  *     Code HTML du formulaire
78 78
  */
79 79
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
80
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
80
+    $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
81 81
 
82
-	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
82
+    return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83 83
 }
84 84
 
85 85
 /**
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
105 105
  */
106 106
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
107
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
107
+    $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
108 108
 
109
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
109
+    return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
110 110
 }
111 111
 
112 112
 
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
  *   passer "text/html" comme $content_type
124 124
  */
125 125
 function ajax_retour($corps, $content_type = null): void {
126
-	$xml = false;
127
-	if (is_null($content_type) || $content_type === true) {
128
-		$xml = true;
129
-		$content_type = 'text/html';
130
-	} elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) {
131
-		$content_type = 'text/html';
132
-	}
126
+    $xml = false;
127
+    if (is_null($content_type) || $content_type === true) {
128
+        $xml = true;
129
+        $content_type = 'text/html';
130
+    } elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) {
131
+        $content_type = 'text/html';
132
+    }
133 133
 
134
-	$e = '';
135
-	if (
136
-		isset($_COOKIE['spip_admin'])
137
-		&& (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps']))
138
-	) {
139
-		$e = erreur_squelette();
140
-	}
134
+    $e = '';
135
+    if (
136
+        isset($_COOKIE['spip_admin'])
137
+        && (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps']))
138
+    ) {
139
+        $e = erreur_squelette();
140
+    }
141 141
 
142
-	$c = $GLOBALS['meta']['charset'];
143
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
144
-	$debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
145
-	$fin = '';
142
+    $c = $GLOBALS['meta']['charset'];
143
+    header('Content-Type: ' . $content_type . '; charset=' . $c);
144
+    $debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
145
+    $fin = '';
146 146
 
147
-	echo $debut, $corps, $fin, $e;
147
+    echo $debut, $corps, $fin, $e;
148 148
 }
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @return string
27 27
  */
28 28
 function autosave_clean_value($val) {
29
-	return stripslashes(urldecode((string) $val));
29
+    return stripslashes(urldecode((string) $val));
30 30
 }
31 31
 
32 32
 /**
@@ -37,58 +37,58 @@  discard block
 block discarded – undo
37 37
  * @return array
38 38
  */
39 39
 function cvtautosave_formulaire_charger($flux) {
40
-	if (
41
-		is_array($flux['data'])
42
-		&& isset($flux['data']['_autosave_id'])
43
-		&& ($cle_autosave = $flux['data']['_autosave_id'])
44
-	) {
45
-		$form = $flux['args']['form'];
46
-		$je_suis_poste = $flux['args']['je_suis_poste'];
40
+    if (
41
+        is_array($flux['data'])
42
+        && isset($flux['data']['_autosave_id'])
43
+        && ($cle_autosave = $flux['data']['_autosave_id'])
44
+    ) {
45
+        $form = $flux['args']['form'];
46
+        $je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48
-		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
48
+        $cle_autosave = serialize($cle_autosave);
49
+        $cle_autosave = $form . '_' . md5($cle_autosave);
50 50
 
51
-		// si on a un backup en session et qu'on est au premier chargement, non poste
52
-		// on restitue les donnees
53
-		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
-			&& !$je_suis_poste
56
-		) {
57
-			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
-			foreach ($vars as $key => $val) {
59
-				if (isset($flux['data'][$key])) {
60
-					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
-						'autosave_clean_value',
62
-						$val
63
-					));
64
-				}
65
-			}
66
-		}
51
+        // si on a un backup en session et qu'on est au premier chargement, non poste
52
+        // on restitue les donnees
53
+        if (
54
+            isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
+            && !$je_suis_poste
56
+        ) {
57
+            parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
+            foreach ($vars as $key => $val) {
59
+                if (isset($flux['data'][$key])) {
60
+                    $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
+                        'autosave_clean_value',
62
+                        $val
63
+                    ));
64
+                }
65
+            }
66
+        }
67 67
 
68
-		// si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
-		// mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
-		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
-			terminer_actualiser_sessions();
72
-			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
75
-				// en court sleep pour etre certain que la concurrence est finie
76
-				sleep(1);
77
-				terminer_actualiser_sessions();
78
-			}
79
-		}
68
+        // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
+        // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
+        if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
+            terminer_actualiser_sessions();
72
+            // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
+            if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
+                session_set('session_autosave_' . $cle_autosave, null);
75
+                // en court sleep pour etre certain que la concurrence est finie
76
+                sleep(1);
77
+                terminer_actualiser_sessions();
78
+            }
79
+        }
80 80
 
81 81
 
82
-		/**
83
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
84
-		 */
85
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
-			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
82
+        /**
83
+         * Envoyer le input hidden et le bout de js qui l'utilisera
84
+         */
85
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
+            . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87 87
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89
-	}
89
+    }
90 90
 
91
-	return $flux;
91
+    return $flux;
92 92
 }
93 93
 
94 94
 /**
@@ -102,33 +102,33 @@  discard block
 block discarded – undo
102 102
  * @return array
103 103
  */
104 104
 function cvtautosave_formulaire_traiter($flux) {
105
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
-	// on elimine les donnees de la session
107
-	if ($cle_autosave = _request('autosave')) {
108
-		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
110
-	}
105
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
+    // on elimine les donnees de la session
107
+    if ($cle_autosave = _request('autosave')) {
108
+        include_spip('inc/session');
109
+        session_set('session_autosave_' . $cle_autosave, null);
110
+    }
111 111
 
112
-	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
-		// delai par defaut avant purge d'un backup de form : 72H
114
-		if (!defined('_AUTOSAVE_GB_DELAY')) {
115
-			define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
-		}
117
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
-		// purger aussi toutes les vieilles autosave
119
-		$session = $GLOBALS['visiteur_session'];
120
-		foreach ($session as $k => $v) {
121
-			if (str_starts_with((string) $k, 'session_autosave_')) {
122
-				$timestamp = 0;
123
-				if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) {
124
-					$timestamp = (int) $m[1];
125
-				}
126
-				if ($timestamp < $time_too_old) {
127
-					session_set($k, null);
128
-				}
129
-			}
130
-		}
131
-	}
112
+    if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
+        // delai par defaut avant purge d'un backup de form : 72H
114
+        if (!defined('_AUTOSAVE_GB_DELAY')) {
115
+            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
+        }
117
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
+        // purger aussi toutes les vieilles autosave
119
+        $session = $GLOBALS['visiteur_session'];
120
+        foreach ($session as $k => $v) {
121
+            if (str_starts_with((string) $k, 'session_autosave_')) {
122
+                $timestamp = 0;
123
+                if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) {
124
+                    $timestamp = (int) $m[1];
125
+                }
126
+                if ($timestamp < $time_too_old) {
127
+                    session_set($k, null);
128
+                }
129
+            }
130
+        }
131
+    }
132 132
 
133
-	return $flux;
133
+    return $flux;
134 134
 }
Please login to merge, or discard this patch.
ecrire/inc/bandeau.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 include_spip('inc/boutons');
@@ -38,33 +38,33 @@  discard block
 block discarded – undo
38 38
  *     contexte
39 39
  **/
40 40
 function definir_barre_contexte($contexte = null) {
41
-	if (is_null($contexte)) {
42
-		$contexte = $_GET;
43
-	} elseif (is_string($contexte)) {
44
-		$contexte = unserialize($contexte);
45
-	}
46
-	if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) {
47
-		if (!function_exists('trouver_objet_exec')) {
48
-			include_spip('inc/pipelines_ecrire');
49
-		}
50
-		if ($e = trouver_objet_exec($contexte['exec'])) {
51
-			$_id = $e['id_table_objet'];
52
-			if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53
-				$table = $e['table_objet_sql'];
54
-				$row = sql_fetsel('*', $table, "$_id=" . (int) $id);
55
-				if (isset($row['id_rubrique'])) {
56
-					$contexte['id_rubrique'] = $row['id_rubrique'];
57
-					if (isset($row['id_secteur'])) {
58
-						$contexte['id_secteur'] = $row['id_secteur'];
59
-					}
60
-				} elseif (isset($row['id_groupe'])) {
61
-					// TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
62
-					$contexte['id_groupe'] = $row['id_groupe'];
63
-				}
64
-			}
65
-		}
66
-	}
67
-	return $contexte;
41
+    if (is_null($contexte)) {
42
+        $contexte = $_GET;
43
+    } elseif (is_string($contexte)) {
44
+        $contexte = unserialize($contexte);
45
+    }
46
+    if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) {
47
+        if (!function_exists('trouver_objet_exec')) {
48
+            include_spip('inc/pipelines_ecrire');
49
+        }
50
+        if ($e = trouver_objet_exec($contexte['exec'])) {
51
+            $_id = $e['id_table_objet'];
52
+            if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53
+                $table = $e['table_objet_sql'];
54
+                $row = sql_fetsel('*', $table, "$_id=" . (int) $id);
55
+                if (isset($row['id_rubrique'])) {
56
+                    $contexte['id_rubrique'] = $row['id_rubrique'];
57
+                    if (isset($row['id_secteur'])) {
58
+                        $contexte['id_secteur'] = $row['id_secteur'];
59
+                    }
60
+                } elseif (isset($row['id_groupe'])) {
61
+                    // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
62
+                    $contexte['id_groupe'] = $row['id_groupe'];
63
+                }
64
+            }
65
+        }
66
+    }
67
+    return $contexte;
68 68
 }
69 69
 
70 70
 /**
@@ -80,89 +80,89 @@  discard block
 block discarded – undo
80 80
  * @return array
81 81
  */
82 82
 function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) {
83
-	include_spip('inc/autoriser');
84
-	$boutons_admin = [];
83
+    include_spip('inc/autoriser');
84
+    $boutons_admin = [];
85 85
 
86
-	// les boutons du core, issus de ecrire/paquet.xml
87
-	$liste_boutons = [];
86
+    // les boutons du core, issus de ecrire/paquet.xml
87
+    $liste_boutons = [];
88 88
 
89
-	// ajouter les boutons issus des plugin via paquet.xml
90
-	if (
91
-		function_exists('boutons_plugins')
92
-		&& is_array($liste_boutons_plugins = boutons_plugins())
93
-	) {
94
-		$liste_boutons = &$liste_boutons_plugins;
95
-	}
89
+    // ajouter les boutons issus des plugin via paquet.xml
90
+    if (
91
+        function_exists('boutons_plugins')
92
+        && is_array($liste_boutons_plugins = boutons_plugins())
93
+    ) {
94
+        $liste_boutons = &$liste_boutons_plugins;
95
+    }
96 96
 
97
-	foreach ($liste_boutons as $id => $infos) {
98
-		$parent = '';
99
-		// les boutons principaux ne sont pas soumis a autorisation
100
-		if (
101
-			!isset($infos['parent'])
102
-			|| !($parent = $infos['parent'])
103
-			|| !$autorise
104
-			|| autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
105
-		) {
106
-			if (
107
-				$parent
108
-				&& ($parent = preg_replace(',^bando_,', 'menu_', (string) $parent))
109
-				&& isset($boutons_admin[$parent])
110
-			) {
111
-				$position = (isset($infos['position']) && strlen((string) $infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu);
112
-				if ($position < 0) {
113
-					$position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
114
-				}
115
-				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116
-					+ [
117
-						$id => new Bouton(
118
-							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
-							$infos['titre'],  // titre
120
-							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121
-							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122
-						)
123
-					]
124
-					+ array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
125
-			}
126
-			if (
127
-				!$parent
128
-				// provisoire, eviter les vieux boutons
129
-				&& !in_array($id, ['forum', 'statistiques_visites'])
130
-				&& (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
131
-			) {
132
-				$position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin);
133
-				$boutons_admin = array_slice($boutons_admin, 0, $position)
134
-					+ [
135
-						$id => new Bouton(
136
-							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
-							$infos['titre'],  // titre
138
-							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139
-							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140
-						)
141
-					]
142
-					+ array_slice($boutons_admin, $position, 100);
143
-			}
144
-		}
145
-	}
146
-	$boutons_admin = pipeline('ajouter_menus', $boutons_admin);
97
+    foreach ($liste_boutons as $id => $infos) {
98
+        $parent = '';
99
+        // les boutons principaux ne sont pas soumis a autorisation
100
+        if (
101
+            !isset($infos['parent'])
102
+            || !($parent = $infos['parent'])
103
+            || !$autorise
104
+            || autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
105
+        ) {
106
+            if (
107
+                $parent
108
+                && ($parent = preg_replace(',^bando_,', 'menu_', (string) $parent))
109
+                && isset($boutons_admin[$parent])
110
+            ) {
111
+                $position = (isset($infos['position']) && strlen((string) $infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu);
112
+                if ($position < 0) {
113
+                    $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
114
+                }
115
+                $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116
+                    + [
117
+                        $id => new Bouton(
118
+                            ($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
+                            $infos['titre'],  // titre
120
+                            (isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121
+                            (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122
+                        )
123
+                    ]
124
+                    + array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
125
+            }
126
+            if (
127
+                !$parent
128
+                // provisoire, eviter les vieux boutons
129
+                && !in_array($id, ['forum', 'statistiques_visites'])
130
+                && (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
131
+            ) {
132
+                $position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin);
133
+                $boutons_admin = array_slice($boutons_admin, 0, $position)
134
+                    + [
135
+                        $id => new Bouton(
136
+                            ($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
+                            $infos['titre'],  // titre
138
+                            (isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139
+                            (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140
+                        )
141
+                    ]
142
+                    + array_slice($boutons_admin, $position, 100);
143
+            }
144
+        }
145
+    }
146
+    $boutons_admin = pipeline('ajouter_menus', $boutons_admin);
147 147
 
148
-	// définir les favoris et positions d’origine
149
-	if ($boutons_admin) {
150
-		$menus_favoris = obtenir_menus_favoris();
151
-		$i = 1;
152
-		foreach ($boutons_admin as $key => $menu) {
153
-			$menu->favori = (int) table_valeur($menus_favoris, $key, false);
154
-			$menu->position = $i++;
155
-			if ($menu->sousmenu) {
156
-				$j = 1;
157
-				foreach ($menu->sousmenu as $key => $bouton) {
158
-					$bouton->favori = (int) table_valeur($menus_favoris, $key, false);
159
-					$bouton->position = $j++;
160
-				}
161
-			}
162
-		}
163
-	}
148
+    // définir les favoris et positions d’origine
149
+    if ($boutons_admin) {
150
+        $menus_favoris = obtenir_menus_favoris();
151
+        $i = 1;
152
+        foreach ($boutons_admin as $key => $menu) {
153
+            $menu->favori = (int) table_valeur($menus_favoris, $key, false);
154
+            $menu->position = $i++;
155
+            if ($menu->sousmenu) {
156
+                $j = 1;
157
+                foreach ($menu->sousmenu as $key => $bouton) {
158
+                    $bouton->favori = (int) table_valeur($menus_favoris, $key, false);
159
+                    $bouton->position = $j++;
160
+                }
161
+            }
162
+        }
163
+    }
164 164
 
165
-	return $boutons_admin;
165
+    return $boutons_admin;
166 166
 }
167 167
 
168 168
 /**
@@ -174,22 +174,22 @@  discard block
 block discarded – undo
174 174
  * @return Bouton[]
175 175
  */
176 176
 function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) {
177
-	foreach ($menus as $menu) {
178
-		if ($menu->sousmenu) {
179
-			$libelles = $isfavoris = $favoris = [];
180
-			foreach ($menu->sousmenu as $key => $item) {
181
-				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
182
-				$isfavoris[$key] = (bool) $item->favori;
183
-				$favoris[$key] = $item->favori;
184
-			}
185
-			if ($avec_favoris) {
186
-				array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
187
-			} else {
188
-				array_multisort($libelles, SORT_ASC, $menu->sousmenu);
189
-			}
190
-		}
191
-	}
192
-	return $menus;
177
+    foreach ($menus as $menu) {
178
+        if ($menu->sousmenu) {
179
+            $libelles = $isfavoris = $favoris = [];
180
+            foreach ($menu->sousmenu as $key => $item) {
181
+                $libelles[$key] = strtolower(translitteration(_T($item->libelle)));
182
+                $isfavoris[$key] = (bool) $item->favori;
183
+                $favoris[$key] = $item->favori;
184
+            }
185
+            if ($avec_favoris) {
186
+                array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
187
+            } else {
188
+                array_multisort($libelles, SORT_ASC, $menu->sousmenu);
189
+            }
190
+        }
191
+    }
192
+    return $menus;
193 193
 }
194 194
 
195 195
 /**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
  * @return Bouton[]
201 201
  */
202 202
 function trier_boutons_enfants_par_favoris_alpha($menus) {
203
-	return trier_boutons_enfants_par_alpha($menus, true);
203
+    return trier_boutons_enfants_par_alpha($menus, true);
204 204
 }
205 205
 
206 206
 
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
  * @return string
214 214
  */
215 215
 function bandeau_creer_url($url, $args = '', $contexte = null) {
216
-	if (!preg_match(',[\/\?],', $url)) {
217
-		$url = generer_url_ecrire($url, $args, true);
218
-		// recuperer les parametres du contexte demande par l'url sous la forme
219
-		// &truc=@machin@
220
-		// @machin@ etant remplace par _request('machin')
221
-		$url = str_replace('&amp;', '&', $url);
222
-		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223
-			if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
225
-			}
226
-			$val = _request($matches[2], $contexte);
227
-			$url = parametre_url($url, $matches[1], $val ?: '', '&');
228
-		}
229
-		$url = str_replace('&', '&amp;', $url);
230
-	}
216
+    if (!preg_match(',[\/\?],', $url)) {
217
+        $url = generer_url_ecrire($url, $args, true);
218
+        // recuperer les parametres du contexte demande par l'url sous la forme
219
+        // &truc=@machin@
220
+        // @machin@ etant remplace par _request('machin')
221
+        $url = str_replace('&amp;', '&', $url);
222
+        while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223
+            if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
+                $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
225
+            }
226
+            $val = _request($matches[2], $contexte);
227
+            $url = parametre_url($url, $matches[1], $val ?: '', '&');
228
+        }
229
+        $url = str_replace('&', '&amp;', $url);
230
+    }
231 231
 
232
-	return $url;
232
+    return $url;
233 233
 }
234 234
 
235 235
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
  *     Code HTML du bandeau
240 240
  */
241 241
 function inc_bandeau_dist() {
242
-	return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
242
+    return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
243 243
 }
244 244
 
245 245
 
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
  * @return array
249 249
  */
250 250
 function obtenir_menus_favoris() {
251
-	if (
252
-		isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
-		&& is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
254
-		&& $GLOBALS['visiteur_session']['prefs']['menus_favoris']
255
-	) {
256
-		return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
257
-	}
258
-	$definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
259
-	return $definir_menus_favoris();
251
+    if (
252
+        isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
+        && is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
254
+        && $GLOBALS['visiteur_session']['prefs']['menus_favoris']
255
+    ) {
256
+        return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
257
+    }
258
+    $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
259
+    return $definir_menus_favoris();
260 260
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 1 patch
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -10,291 +10,291 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 
17 17
 // methodes sql
18 18
 function inc_recherche_to_array_dist($recherche, $options = []) {
19 19
 
20
-	// options par defaut
21
-	$options = array_merge(
22
-		[
23
-			'score' => true,
24
-			'champs' => false,
25
-			'toutvoir' => false,
26
-			'matches' => false,
27
-			'jointures' => false
28
-		],
29
-		$options
30
-	);
20
+    // options par defaut
21
+    $options = array_merge(
22
+        [
23
+            'score' => true,
24
+            'champs' => false,
25
+            'toutvoir' => false,
26
+            'matches' => false,
27
+            'jointures' => false
28
+        ],
29
+        $options
30
+    );
31 31
 
32
-	include_spip('inc/rechercher');
33
-	include_spip('inc/autoriser');
32
+    include_spip('inc/rechercher');
33
+    include_spip('inc/autoriser');
34 34
 
35
-	$requete = [
36
-		'SELECT' => [],
37
-		'FROM' => [],
38
-		'WHERE' => [],
39
-		'GROUPBY' => [],
40
-		'ORDERBY' => [],
41
-		'LIMIT' => '',
42
-		'HAVING' => []
43
-	];
35
+    $requete = [
36
+        'SELECT' => [],
37
+        'FROM' => [],
38
+        'WHERE' => [],
39
+        'GROUPBY' => [],
40
+        'ORDERBY' => [],
41
+        'LIMIT' => '',
42
+        'HAVING' => []
43
+    ];
44 44
 
45
-	$table = sinon($options['table'], 'article');
46
-	if ($options['champs']) {
47
-		$champs = $options['champs'];
48
-	} else {
49
-		$l = liste_des_champs();
50
-		$champs = $l['article'];
51
-	}
52
-	$serveur = $options['serveur'];
45
+    $table = sinon($options['table'], 'article');
46
+    if ($options['champs']) {
47
+        $champs = $options['champs'];
48
+    } else {
49
+        $l = liste_des_champs();
50
+        $champs = $l['article'];
51
+    }
52
+    $serveur = $options['serveur'];
53 53
 
54
-	[$methode, $q, $preg] = expression_recherche($recherche, $options);
54
+    [$methode, $q, $preg] = expression_recherche($recherche, $options);
55 55
 
56
-	$jointures = $options['jointures']
57
-		? liste_des_jointures()
58
-		: [];
56
+    $jointures = $options['jointures']
57
+        ? liste_des_jointures()
58
+        : [];
59 59
 
60
-	$_id_table = id_table_objet($table);
60
+    $_id_table = id_table_objet($table);
61 61
 
62
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
63
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
64
-	if (str_contains((string) $_id_table, ',')) {
65
-		$_id_table = explode(',', (string) $_id_table);
66
-		$_id_table = reset($_id_table);
67
-	}
62
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
63
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
64
+    if (str_contains((string) $_id_table, ',')) {
65
+        $_id_table = explode(',', (string) $_id_table);
66
+        $_id_table = reset($_id_table);
67
+    }
68 68
 
69
-	$requete['SELECT'][] = 't.' . $_id_table;
70
-	$a = [];
71
-	// Recherche fulltext
72
-	foreach ($champs as $champ => $poids) {
73
-		if (is_array($champ)) {
74
-			spip_log('requetes imbriquees interdites');
75
-		} else {
76
-			if (!str_contains((string) $champ, '.')) {
77
-				$champ = "t.$champ";
78
-			}
79
-			$requete['SELECT'][] = $champ;
80
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
81
-		}
82
-	}
83
-	if ($a) {
84
-		$requete['WHERE'][] = implode(' OR ', $a);
85
-	}
86
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
69
+    $requete['SELECT'][] = 't.' . $_id_table;
70
+    $a = [];
71
+    // Recherche fulltext
72
+    foreach ($champs as $champ => $poids) {
73
+        if (is_array($champ)) {
74
+            spip_log('requetes imbriquees interdites');
75
+        } else {
76
+            if (!str_contains((string) $champ, '.')) {
77
+                $champ = "t.$champ";
78
+            }
79
+            $requete['SELECT'][] = $champ;
80
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
81
+        }
82
+    }
83
+    if ($a) {
84
+        $requete['WHERE'][] = implode(' OR ', $a);
85
+    }
86
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
87 87
 
88
-	$results = [];
88
+    $results = [];
89 89
 
90
-	$s = sql_select(
91
-		$requete['SELECT'],
92
-		$requete['FROM'],
93
-		$requete['WHERE'],
94
-		implode(' ', $requete['GROUPBY']),
95
-		$requete['ORDERBY'],
96
-		$requete['LIMIT'],
97
-		$requete['HAVING'],
98
-		$serveur
99
-	);
90
+    $s = sql_select(
91
+        $requete['SELECT'],
92
+        $requete['FROM'],
93
+        $requete['WHERE'],
94
+        implode(' ', $requete['GROUPBY']),
95
+        $requete['ORDERBY'],
96
+        $requete['LIMIT'],
97
+        $requete['HAVING'],
98
+        $serveur
99
+    );
100 100
 
101
-	while (
102
-		($t = sql_fetch($s, $serveur))
103
-		&& (!isset($t['score']) || $t['score'] > 0)
104
-	) {
105
-		$id = (int) $t[$_id_table];
101
+    while (
102
+        ($t = sql_fetch($s, $serveur))
103
+        && (!isset($t['score']) || $t['score'] > 0)
104
+    ) {
105
+        $id = (int) $t[$_id_table];
106 106
 
107
-		if ($options['toutvoir'] || autoriser('voir', $table, $id)) {
108
-			// indiquer les champs concernes
109
-			$champs_vus = [];
110
-			$score = 0;
111
-			$matches = [];
107
+        if ($options['toutvoir'] || autoriser('voir', $table, $id)) {
108
+            // indiquer les champs concernes
109
+            $champs_vus = [];
110
+            $score = 0;
111
+            $matches = [];
112 112
 
113
-			$vu = false;
114
-			foreach ($champs as $champ => $poids) {
115
-				$champ = explode('.', (string) $champ);
116
-				$champ = end($champ);
117
-				// translitteration_rapide uniquement si on est deja en utf-8
118
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
119
-				if (
120
-					$n =
121
-					($options['score'] || $options['matches'])
122
-						? preg_match_all($preg, (string) $value, $regs, PREG_SET_ORDER)
123
-						: preg_match($preg, (string) $value)
124
-				) {
125
-					$vu = true;
113
+            $vu = false;
114
+            foreach ($champs as $champ => $poids) {
115
+                $champ = explode('.', (string) $champ);
116
+                $champ = end($champ);
117
+                // translitteration_rapide uniquement si on est deja en utf-8
118
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
119
+                if (
120
+                    $n =
121
+                    ($options['score'] || $options['matches'])
122
+                        ? preg_match_all($preg, (string) $value, $regs, PREG_SET_ORDER)
123
+                        : preg_match($preg, (string) $value)
124
+                ) {
125
+                    $vu = true;
126 126
 
127
-					if ($options['champs']) {
128
-						$champs_vus[$champ] = $t[$champ];
129
-					}
130
-					if ($options['score']) {
131
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
132
-						$score += $poids * strlen(implode('', array_column($regs, 0)));
133
-					}
127
+                    if ($options['champs']) {
128
+                        $champs_vus[$champ] = $t[$champ];
129
+                    }
130
+                    if ($options['score']) {
131
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
132
+                        $score += $poids * strlen(implode('', array_column($regs, 0)));
133
+                    }
134 134
 
135
-					if ($options['matches']) {
136
-						$matches[$champ] = $regs;
137
-					}
135
+                    if ($options['matches']) {
136
+                        $matches[$champ] = $regs;
137
+                    }
138 138
 
139
-					if (!$options['champs'] && !$options['score'] && !$options['matches']) {
140
-						break;
141
-					}
142
-				}
143
-			}
139
+                    if (!$options['champs'] && !$options['score'] && !$options['matches']) {
140
+                        break;
141
+                    }
142
+                }
143
+            }
144 144
 
145
-			if ($vu) {
146
-				if (!isset($results)) {
147
-					$results = [];
148
-				}
149
-				$results[$id] = [];
150
-				if ($champs_vus) {
151
-					$results[$id]['champs'] = $champs_vus;
152
-				}
153
-				if ($score) {
154
-					$results[$id]['score'] = $score;
155
-				}
156
-				if ($matches) {
157
-					$results[$id]['matches'] = $matches;
158
-				}
159
-			}
160
-		}
161
-	}
145
+            if ($vu) {
146
+                if (!isset($results)) {
147
+                    $results = [];
148
+                }
149
+                $results[$id] = [];
150
+                if ($champs_vus) {
151
+                    $results[$id]['champs'] = $champs_vus;
152
+                }
153
+                if ($score) {
154
+                    $results[$id]['score'] = $score;
155
+                }
156
+                if ($matches) {
157
+                    $results[$id]['matches'] = $matches;
158
+                }
159
+            }
160
+        }
161
+    }
162 162
 
163 163
 
164
-	// Gerer les donnees associees
165
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
166
-	// on ne sait passer que par table de laison en 1 coup
167
-	if (
168
-		isset($jointures[$table])
169
-		&& ($joints = recherche_en_base(
170
-			$recherche,
171
-			$jointures[$table],
172
-			array_merge($options, ['jointures' => false])
173
-		))
174
-	) {
175
-		include_spip('action/editer_liens');
176
-		$trouver_table = charger_fonction('trouver_table', 'base');
177
-		$cle_depart = id_table_objet($table);
178
-		$table_depart = table_objet($table, $serveur);
179
-		$desc_depart = $trouver_table($table_depart, $serveur);
180
-		$depart_associable = objet_associable($table);
181
-		foreach ($joints as $table_liee => $ids_trouves) {
182
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
183
-			if (
184
-				!(
185
-				($rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true))
186
-				|| ($rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true))
187
-				|| ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true))
188
-				)
189
-			) {
190
-				$cle_arrivee = id_table_objet($table_liee);
191
-				$table_arrivee = table_objet($table_liee, $serveur);
192
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
193
-				// cas simple : $cle_depart dans la table_liee
194
-				if (isset($desc_arrivee['field'][$cle_depart])) {
195
-					$s = sql_select(
196
-						"$cle_depart, $cle_arrivee",
197
-						$desc_arrivee['table_sql'],
198
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
199
-						'',
200
-						'',
201
-						'',
202
-						'',
203
-						$serveur
204
-					);
205
-				} // cas simple : $cle_arrivee dans la table
206
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
207
-					$s = sql_select(
208
-						"$cle_depart, $cle_arrivee",
209
-						$desc_depart['table_sql'],
210
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
211
-						'',
212
-						'',
213
-						'',
214
-						'',
215
-						$serveur
216
-					);
217
-				}
218
-				// sinon cherchons une table de liaison
219
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
220
-				elseif ($l = objet_associable($table_liee)) {
221
-					[$primary, $table_liens] = $l;
222
-					$s = sql_select(
223
-						"id_objet as $cle_depart, $primary as $cle_arrivee",
224
-						$table_liens,
225
-						["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
226
-						'',
227
-						'',
228
-						'',
229
-						'',
230
-						$serveur
231
-					);
232
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
233
-				elseif ($l = $depart_associable) {
234
-					[$primary, $table_liens] = $l;
235
-					$s = sql_select(
236
-						"$primary as $cle_depart, id_objet as $cle_arrivee",
237
-						$table_liens,
238
-						["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
239
-						'',
240
-						'',
241
-						'',
242
-						'',
243
-						$serveur
244
-					);
245
-				} // cas table de liaison generique spip_xxx_yyy
246
-				elseif (
247
-					($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur))
248
-					|| ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur))
249
-				) {
250
-					$s = sql_select(
251
-						"$cle_depart,$cle_arrivee",
252
-						$t['table_sql'],
253
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
254
-						'',
255
-						'',
256
-						'',
257
-						'',
258
-						$serveur
259
-					);
260
-				}
261
-			} else {
262
-				[$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
263
-					$table,
264
-					$table_liee,
265
-					array_keys($ids_trouves),
266
-					$serveur
267
-				);
268
-			}
164
+    // Gerer les donnees associees
165
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
166
+    // on ne sait passer que par table de laison en 1 coup
167
+    if (
168
+        isset($jointures[$table])
169
+        && ($joints = recherche_en_base(
170
+            $recherche,
171
+            $jointures[$table],
172
+            array_merge($options, ['jointures' => false])
173
+        ))
174
+    ) {
175
+        include_spip('action/editer_liens');
176
+        $trouver_table = charger_fonction('trouver_table', 'base');
177
+        $cle_depart = id_table_objet($table);
178
+        $table_depart = table_objet($table, $serveur);
179
+        $desc_depart = $trouver_table($table_depart, $serveur);
180
+        $depart_associable = objet_associable($table);
181
+        foreach ($joints as $table_liee => $ids_trouves) {
182
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
183
+            if (
184
+                !(
185
+                ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true))
186
+                || ($rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true))
187
+                || ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true))
188
+                )
189
+            ) {
190
+                $cle_arrivee = id_table_objet($table_liee);
191
+                $table_arrivee = table_objet($table_liee, $serveur);
192
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
193
+                // cas simple : $cle_depart dans la table_liee
194
+                if (isset($desc_arrivee['field'][$cle_depart])) {
195
+                    $s = sql_select(
196
+                        "$cle_depart, $cle_arrivee",
197
+                        $desc_arrivee['table_sql'],
198
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
199
+                        '',
200
+                        '',
201
+                        '',
202
+                        '',
203
+                        $serveur
204
+                    );
205
+                } // cas simple : $cle_arrivee dans la table
206
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
207
+                    $s = sql_select(
208
+                        "$cle_depart, $cle_arrivee",
209
+                        $desc_depart['table_sql'],
210
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
211
+                        '',
212
+                        '',
213
+                        '',
214
+                        '',
215
+                        $serveur
216
+                    );
217
+                }
218
+                // sinon cherchons une table de liaison
219
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
220
+                elseif ($l = objet_associable($table_liee)) {
221
+                    [$primary, $table_liens] = $l;
222
+                    $s = sql_select(
223
+                        "id_objet as $cle_depart, $primary as $cle_arrivee",
224
+                        $table_liens,
225
+                        ["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
226
+                        '',
227
+                        '',
228
+                        '',
229
+                        '',
230
+                        $serveur
231
+                    );
232
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
233
+                elseif ($l = $depart_associable) {
234
+                    [$primary, $table_liens] = $l;
235
+                    $s = sql_select(
236
+                        "$primary as $cle_depart, id_objet as $cle_arrivee",
237
+                        $table_liens,
238
+                        ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
239
+                        '',
240
+                        '',
241
+                        '',
242
+                        '',
243
+                        $serveur
244
+                    );
245
+                } // cas table de liaison generique spip_xxx_yyy
246
+                elseif (
247
+                    ($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur))
248
+                    || ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur))
249
+                ) {
250
+                    $s = sql_select(
251
+                        "$cle_depart,$cle_arrivee",
252
+                        $t['table_sql'],
253
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
254
+                        '',
255
+                        '',
256
+                        '',
257
+                        '',
258
+                        $serveur
259
+                    );
260
+                }
261
+            } else {
262
+                [$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
263
+                    $table,
264
+                    $table_liee,
265
+                    array_keys($ids_trouves),
266
+                    $serveur
267
+                );
268
+            }
269 269
 
270
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
271
-				$id = $t[$cle_depart];
272
-				$joint = $ids_trouves[$t[$cle_arrivee]];
273
-				if (!isset($results)) {
274
-					$results = [];
275
-				}
276
-				if (!isset($results[$id])) {
277
-					$results[$id] = [];
278
-				}
279
-				if (isset($joint['score']) && $joint['score']) {
280
-					if (!isset($results[$id]['score'])) {
281
-						$results[$id]['score'] = 0;
282
-					}
283
-					$results[$id]['score'] += $joint['score'];
284
-				}
285
-				if (isset($joint['champs']) && $joint['champs']) {
286
-					foreach ($joint['champs'] as $c => $val) {
287
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
288
-					}
289
-				}
290
-				if (isset($joint['matches']) && $joint['matches']) {
291
-					foreach ($joint['matches'] as $c => $val) {
292
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
293
-					}
294
-				}
295
-			}
296
-		}
297
-	}
270
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
271
+                $id = $t[$cle_depart];
272
+                $joint = $ids_trouves[$t[$cle_arrivee]];
273
+                if (!isset($results)) {
274
+                    $results = [];
275
+                }
276
+                if (!isset($results[$id])) {
277
+                    $results[$id] = [];
278
+                }
279
+                if (isset($joint['score']) && $joint['score']) {
280
+                    if (!isset($results[$id]['score'])) {
281
+                        $results[$id]['score'] = 0;
282
+                    }
283
+                    $results[$id]['score'] += $joint['score'];
284
+                }
285
+                if (isset($joint['champs']) && $joint['champs']) {
286
+                    foreach ($joint['champs'] as $c => $val) {
287
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
288
+                    }
289
+                }
290
+                if (isset($joint['matches']) && $joint['matches']) {
291
+                    foreach ($joint['matches'] as $c => $val) {
292
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
293
+                    }
294
+                }
295
+            }
296
+        }
297
+    }
298 298
 
299
-	return $results;
299
+    return $results;
300 300
 }
Please login to merge, or discard this patch.
ecrire/inc/plonger.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,111 +10,111 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/texte');
17 17
 
18 18
 function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') {
19 19
 
20
-	if ($list) {
21
-		$id_rubrique = $list[$col - 1];
22
-	}
20
+    if ($list) {
21
+        $id_rubrique = $list[$col - 1];
22
+    }
23 23
 
24
-	$ret = '';
24
+    $ret = '';
25 25
 
26
-	# recherche les filles et petites-filles de la rubrique donnee
27
-	# en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
28
-	# deplace une rubrique, on peut la deplacer partout a partir de la
29
-	# racine... sauf vers elle-meme ou sa propre branche)
30
-	$ordre = [];
31
-	$rub = [];
26
+    # recherche les filles et petites-filles de la rubrique donnee
27
+    # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
28
+    # deplace une rubrique, on peut la deplacer partout a partir de la
29
+    # racine... sauf vers elle-meme ou sa propre branche)
30
+    $ordre = [];
31
+    $rub = [];
32 32
 
33
-	$res = sql_select(
34
-		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35
-		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
33
+    $res = sql_select(
34
+        'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35
+        'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
+        'rub1.id_parent = ' . sql_quote($id_rubrique) . '
37 37
 			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
38 38
 			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
39
-		'',
40
-		'0+rub1.titre,rub1.titre'
41
-	);
39
+        '',
40
+        '0+rub1.titre,rub1.titre'
41
+    );
42 42
 
43
-	while ($row = sql_fetch($res)) {
44
-		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
45
-			$rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
46
-			if ($row['id_parent'] == $id_rubrique) {
47
-				$t = trim((string) typo(supprimer_numero($row['titre'])));
48
-				if ($row['langue_choisie'] != 'oui') {
49
-					$t .= ' <small title="'
50
-						. traduire_nom_langue($row['lang'])
51
-						. '">[' . $row['lang'] . ']</small>';
52
-				}
53
-				$ordre[$row['id_rubrique']] = $t;
54
-			}
55
-		}
56
-	}
57
-	$next = $list[$col] ?? 0;
58
-	if ($ordre) {
59
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
60
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
43
+    while ($row = sql_fetch($res)) {
44
+        if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
45
+            $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
46
+            if ($row['id_parent'] == $id_rubrique) {
47
+                $t = trim((string) typo(supprimer_numero($row['titre'])));
48
+                if ($row['langue_choisie'] != 'oui') {
49
+                    $t .= ' <small title="'
50
+                        . traduire_nom_langue($row['lang'])
51
+                        . '">[' . $row['lang'] . ']</small>';
52
+                }
53
+                $ordre[$row['id_rubrique']] = $t;
54
+            }
55
+        }
56
+    }
57
+    $next = $list[$col] ?? 0;
58
+    if ($ordre) {
59
+        $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
60
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
+        $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
62 62
 
63
-		foreach ($ordre as $id => $titrebrut) {
64
-			$titre = supprimer_numero($titrebrut);
63
+        foreach ($ordre as $id => $titrebrut) {
64
+            $titre = supprimer_numero($titrebrut);
65 65
 
66
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67
-			if (isset($rub[$id]['enfants'])) {
68
-				$classe2 = " class='rub-ouverte'";
69
-				$url = "\nhref='$rec&amp;id=$id'";
70
-			} else {
71
-				$classe2 = $url = '';
72
-				$url = "\nhref='javascript:void(0)'";
73
-			}
66
+            $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67
+            if (isset($rub[$id]['enfants'])) {
68
+                $classe2 = " class='rub-ouverte'";
69
+                $url = "\nhref='$rec&amp;id=$id'";
70
+            } else {
71
+                $classe2 = $url = '';
72
+                $url = "\nhref='javascript:void(0)'";
73
+            }
74 74
 
75
-			$js_func = $do . '_selection_titre';
76
-			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77
-				. (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
75
+            $js_func = $do . '_selection_titre';
76
+            $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77
+                . (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
78 78
 # ce lien provoque la selection (directe) de la rubrique cliquee
79 79
 # et l'affichage de son titre dans le bandeau
80
-				. "\"\nondblclick=\""
81
-				. "$js_func(this."
82
-				. 'firstChild.nodeValue,'
83
-				. $id
84
-				. ",'selection_rubrique','id_parent');"
85
-				. "\nreturn aff_selection_provisoire($id,$args);"
86
-				. '"';
80
+                . "\"\nondblclick=\""
81
+                . "$js_func(this."
82
+                . 'firstChild.nodeValue,'
83
+                . $id
84
+                . ",'selection_rubrique','id_parent');"
85
+                . "\nreturn aff_selection_provisoire($id,$args);"
86
+                . '"';
87 87
 
88
-			$ret .= "<div class='"
89
-				. (($id == $next) ? 'item on' : 'item')
90
-				. "'><div class='"
91
-				. $classe1
92
-				. "'><div$classe2><a"
93
-				. $url
94
-				. $click
95
-				. '>'
96
-				. $titre
97
-				. '</a></div></div></div>';
98
-		}
99
-	}
88
+            $ret .= "<div class='"
89
+                . (($id == $next) ? 'item on' : 'item')
90
+                . "'><div class='"
91
+                . $classe1
92
+                . "'><div$classe2><a"
93
+                . $url
94
+                . $click
95
+                . '>'
96
+                . $titre
97
+                . '</a></div></div></div>';
98
+        }
99
+    }
100 100
 
101
-	$idom2 = $idom . '_col_' . ($col + 1);
102
-	$left = ($col * 250);
101
+    $idom2 = $idom . '_col_' . ($col + 1);
102
+    $left = ($col * 250);
103 103
 
104
-	return http_img_pack(
105
-		'loader.svg',
106
-		'',
107
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
108
-		. ($left - 30)
109
-		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
110
-	)
111
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
112
-	. ($left - 250)
113
-	. "px;'>"
114
-	. $ret
115
-	. "\n</div>\n<div id='$idom2'>"
116
-	. ($next
117
-		? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
118
-		: '')
119
-	. "\n</div>";
104
+    return http_img_pack(
105
+        'loader.svg',
106
+        '',
107
+        "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
108
+        . ($left - 30)
109
+        . "px; top: 2px; z-index: 2;' id='img_$idom2'"
110
+    )
111
+    . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
112
+    . ($left - 250)
113
+    . "px;'>"
114
+    . $ret
115
+    . "\n</div>\n<div id='$idom2'>"
116
+    . ($next
117
+        ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
118
+        : '')
119
+    . "\n</div>";
120 120
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_mime.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  **/
22 22
 
23 23
 if (!defined('_ECRIRE_INC_VERSION')) {
24
-	return;
24
+    return;
25 25
 }
26 26
 include_spip('inc/filtres');
27 27
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @return string Rien.
39 39
  **/
40 40
 function filtre_image_dist($t) {
41
-	return '';
41
+    return '';
42 42
 }
43 43
 
44 44
 /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
  * @return string Rien.
52 52
  **/
53 53
 function filtre_audio_dist($t) {
54
-	return '';
54
+    return '';
55 55
 }
56 56
 
57 57
 /**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
  * @return string Rien.
65 65
  **/
66 66
 function filtre_video_dist($t) {
67
-	return '';
67
+    return '';
68 68
 }
69 69
 
70 70
 /**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  * @return string Rien.
78 78
  **/
79 79
 function filtre_application_dist($t) {
80
-	return '';
80
+    return '';
81 81
 }
82 82
 
83 83
 /**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
  * @return string Rien.
91 91
  **/
92 92
 function filtre_message_dist($t) {
93
-	return '';
93
+    return '';
94 94
 }
95 95
 
96 96
 /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  * @return string Rien.
104 104
  **/
105 105
 function filtre_multipart_dist($t) {
106
-	return '';
106
+    return '';
107 107
 }
108 108
 
109 109
 /**
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
  * @return string Contenu échappé.
117 117
  **/
118 118
 function filtre_text_dist($t) {
119
-	static $t1 = ['&', '<', '>'];
120
-	static $t2 = ['&amp;', '&lt;', '&gt;'];
119
+    static $t1 = ['&', '<', '>'];
120
+    static $t2 = ['&amp;', '&lt;', '&gt;'];
121 121
 
122
-	return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>';
122
+    return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>';
123 123
 }
124 124
 
125 125
 /**
@@ -134,21 +134,21 @@  discard block
 block discarded – undo
134 134
  *     Tableau (formaté en SPIP)
135 135
  **/
136 136
 function filtre_text_csv_dist($t) {
137
-	include_spip('inc/csv');
138
-	[$entete, $lignes, $caption] = analyse_csv($t);
139
-	foreach ($lignes as &$l) {
140
-		$l = implode('|', $l);
141
-	}
142
-	$corps = implode("\n", $lignes) . "\n";
143
-	$corps = $caption .
144
-		"\n|{{" .
145
-		implode('}}|{{', $entete) .
146
-		'}}|' .
147
-		"\n|" .
148
-		str_replace("\n", "|\n|", $corps);
149
-	include_spip('inc/texte');
150
-
151
-	return propre($corps);
137
+    include_spip('inc/csv');
138
+    [$entete, $lignes, $caption] = analyse_csv($t);
139
+    foreach ($lignes as &$l) {
140
+        $l = implode('|', $l);
141
+    }
142
+    $corps = implode("\n", $lignes) . "\n";
143
+    $corps = $caption .
144
+        "\n|{{" .
145
+        implode('}}|{{', $entete) .
146
+        '}}|' .
147
+        "\n|" .
148
+        str_replace("\n", "|\n|", $corps);
149
+    include_spip('inc/texte');
150
+
151
+    return propre($corps);
152 152
 }
153 153
 
154 154
 /**
@@ -162,33 +162,33 @@  discard block
 block discarded – undo
162 162
  * @return string Code html sécurisé ou texte échappé
163 163
  **/
164 164
 function filtre_text_html_dist($t) {
165
-	if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) {
166
-		return appliquer_filtre($t, 'text/plain');
167
-	}
168
-
169
-	[, $h, $t] = $r;
170
-
171
-	$style = '';
172
-	// recuperer les styles internes
173
-	if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) {
174
-		$style = implode("\n", $r[1]);
175
-	}
176
-	// ... et externes
177
-
178
-	include_spip('inc/distant');
179
-	if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) {
180
-		foreach ($r[0] as $l) {
181
-			preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
182
-			$page = recuperer_url($m[1]);
183
-			$page = $page['page'] ?? '';
184
-			$style .= "\n/* $l */\n"
185
-				. str_replace('<', '', (string) $page);
186
-		}
187
-	}
188
-	// Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
189
-	$t = safehtml(preg_replace(',<script.*?</script>,is', '', $t));
190
-
191
-	return ($style ? "\n<style>" . $style . '</style>' : '') . $t;
165
+    if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) {
166
+        return appliquer_filtre($t, 'text/plain');
167
+    }
168
+
169
+    [, $h, $t] = $r;
170
+
171
+    $style = '';
172
+    // recuperer les styles internes
173
+    if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) {
174
+        $style = implode("\n", $r[1]);
175
+    }
176
+    // ... et externes
177
+
178
+    include_spip('inc/distant');
179
+    if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) {
180
+        foreach ($r[0] as $l) {
181
+            preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
182
+            $page = recuperer_url($m[1]);
183
+            $page = $page['page'] ?? '';
184
+            $style .= "\n/* $l */\n"
185
+                . str_replace('<', '', (string) $page);
186
+        }
187
+    }
188
+    // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
189
+    $t = safehtml(preg_replace(',<script.*?</script>,is', '', $t));
190
+
191
+    return ($style ? "\n<style>" . $style . '</style>' : '') . $t;
192 192
 }
193 193
 
194 194
 /**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  * @return string Code HTML des balises `<param>`
202 202
  **/
203 203
 function filtre_audio_x_pn_realaudio($id) {
204
-	return "
204
+    return "
205 205
 	<param name='controls' value='PositionSlider' />
206 206
 	<param name='controls' value='ImageWindow' />
207 207
 	<param name='controls' value='PlayButton' />
Please login to merge, or discard this patch.
ecrire/inc/rechercher.php 1 patch
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 defined('_RECHERCHE_LOCK_KEY') || define('_RECHERCHE_LOCK_KEY', 'fulltext');
@@ -34,195 +34,195 @@  discard block
 block discarded – undo
34 34
  * @return array Couples (type d'objet => Couples (champ => score))
35 35
  */
36 36
 function liste_des_champs() {
37
-	static $liste = null;
38
-	if (is_null($liste)) {
39
-		$liste = [];
40
-		// recuperer les tables_objets_sql declarees
41
-		include_spip('base/objets');
42
-		$tables_objets = lister_tables_objets_sql();
43
-		foreach ($tables_objets as $t => $infos) {
44
-			if ($infos['rechercher_champs']) {
45
-				$liste[$infos['type']] = $infos['rechercher_champs'];
46
-			}
47
-		}
48
-		// puis passer dans le pipeline
49
-		$liste = pipeline('rechercher_liste_des_champs', $liste);
50
-	}
51
-
52
-	return $liste;
37
+    static $liste = null;
38
+    if (is_null($liste)) {
39
+        $liste = [];
40
+        // recuperer les tables_objets_sql declarees
41
+        include_spip('base/objets');
42
+        $tables_objets = lister_tables_objets_sql();
43
+        foreach ($tables_objets as $t => $infos) {
44
+            if ($infos['rechercher_champs']) {
45
+                $liste[$infos['type']] = $infos['rechercher_champs'];
46
+            }
47
+        }
48
+        // puis passer dans le pipeline
49
+        $liste = pipeline('rechercher_liste_des_champs', $liste);
50
+    }
51
+
52
+    return $liste;
53 53
 }
54 54
 
55 55
 
56 56
 // Recherche des auteurs et mots-cles associes
57 57
 // en ne regardant que le titre ou le nom
58 58
 function liste_des_jointures() {
59
-	static $liste = null;
60
-	if (is_null($liste)) {
61
-		$liste = [];
62
-		// recuperer les tables_objets_sql declarees
63
-		include_spip('base/objets');
64
-		$tables_objets = lister_tables_objets_sql();
65
-		foreach ($tables_objets as $t => $infos) {
66
-			if ($infos['rechercher_jointures']) {
67
-				$liste[$infos['type']] = $infos['rechercher_jointures'];
68
-			}
69
-		}
70
-		// puis passer dans le pipeline
71
-		$liste = pipeline('rechercher_liste_des_jointures', $liste);
72
-	}
73
-
74
-	return $liste;
59
+    static $liste = null;
60
+    if (is_null($liste)) {
61
+        $liste = [];
62
+        // recuperer les tables_objets_sql declarees
63
+        include_spip('base/objets');
64
+        $tables_objets = lister_tables_objets_sql();
65
+        foreach ($tables_objets as $t => $infos) {
66
+            if ($infos['rechercher_jointures']) {
67
+                $liste[$infos['type']] = $infos['rechercher_jointures'];
68
+            }
69
+        }
70
+        // puis passer dans le pipeline
71
+        $liste = pipeline('rechercher_liste_des_jointures', $liste);
72
+    }
73
+
74
+    return $liste;
75 75
 }
76 76
 
77 77
 function expression_recherche($recherche, $options) {
78
-	// ne calculer qu'une seule fois l'expression par hit
79
-	// (meme si utilisee dans plusieurs boucles)
80
-	static $expression = [];
81
-	$key = serialize([$recherche, $options['preg_flags']]);
82
-	if (isset($expression[$key])) {
83
-		return $expression[$key];
84
-	}
85
-
86
-	$u = $GLOBALS['meta']['pcre_u'];
87
-	if ($u && !str_contains((string) $options['preg_flags'], (string) $u)) {
88
-		$options['preg_flags'] .= $u;
89
-	}
90
-	include_spip('inc/charsets');
91
-	$recherche = trim((string) $recherche);
92
-
93
-	// retirer les + de +truc et les * de truc*
94
-	$recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche);
95
-	$recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche);
96
-
97
-	$is_preg = false;
98
-	if (str_starts_with($recherche, '/') && str_ends_with($recherche, '/') && strlen($recherche) > 2) {
99
-		// c'est une preg
100
-		$recherche_trans = translitteration($recherche);
101
-		$preg = $recherche_trans . $options['preg_flags'];
102
-		$is_preg = true;
103
-	} else {
104
-		// s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP,
105
-		// sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un',
106
-		// 'une', 'des' ...)
107
-
108
-		// attention : plusieurs mots entre guillemets sont a rechercher tels quels
109
-		$recherche_trans = $recherche_mod = $recherche_org = $recherche;
110
-
111
-		// les expressions entre " " sont un mot a chercher tel quel
112
-		// -> on remplace les espaces par un \x1 et on enleve les guillemets
113
-		if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) {
114
-			foreach ($matches as $match) {
115
-				$word = preg_replace(',\s+,Uims', "\x1", $match);
116
-				$word = trim($word, '"');
117
-				$recherche_mod = str_replace($match, $word, $recherche_mod);
118
-			}
119
-		}
120
-
121
-		if (preg_match(',\s+,' . $u, $recherche_mod)) {
122
-			$is_preg = true;
123
-
124
-			$recherche_inter = '|';
125
-			$recherche_mots = explode(' ', $recherche_mod);
126
-			$min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4;
127
-			$petits_mots = true;
128
-			foreach ($recherche_mots as $mot) {
129
-				if (strlen($mot) >= $min_long) {
130
-					// echapper les caracteres de regexp qui sont eventuellement dans la recherche
131
-					$recherche_inter .= preg_quote($mot) . ' ';
132
-					$petits_mots = false;
133
-				}
134
-			}
135
-			$recherche_inter = str_replace("\x1", '\s', $recherche_inter);
136
-
137
-			// mais on cherche quand même l'expression complète, même si elle
138
-			// comporte des mots de moins de quatre lettres
139
-			$recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|');
140
-			if (!$recherche || $petits_mots) {
141
-				$recherche = preg_quote($recherche_org);
142
-			}
143
-			$recherche_trans = translitteration($recherche);
144
-		}
145
-
146
-		$preg = '/' . str_replace('/', '\\/', (string) $recherche_trans) . '/' . $options['preg_flags'];
147
-	}
148
-
149
-	// Si la chaine est inactive, on va utiliser LIKE pour aller plus vite
150
-	// ou si l'expression reguliere est invalide
151
-	if (!$is_preg || @preg_match($preg, '') === false) {
152
-		$methode = 'LIKE';
153
-		$u = $GLOBALS['meta']['pcre_u'];
154
-
155
-		// echapper les % et _
156
-		$q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche));
157
-
158
-		// eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses
159
-		$recherche = preg_quote($recherche, '/');
160
-		$recherche_trans = translitteration($recherche);
161
-		$recherche_mod = $recherche_trans;
162
-
163
-		// les expressions entre " " sont un mot a chercher tel quel
164
-		// -> on remplace les espaces par un _ et on enleve les guillemets
165
-		// corriger le like dans le $q
166
-		if (preg_match(',["][^"]+["],Uims', $q, $matches)) {
167
-			foreach ($matches as $match) {
168
-				$word = preg_replace(',\s+,Uims', '_', $match);
169
-				$word = trim($word, '"');
170
-				$q = str_replace($match, $word, $q);
171
-			}
172
-		}
173
-		// corriger la regexp
174
-		if (preg_match(',["][^"]+["],Uims', (string) $recherche_mod, $matches)) {
175
-			foreach ($matches as $match) {
176
-				$word = preg_replace(',\s+,Uims', '[\s]', $match);
177
-				$word = trim($word, '"');
178
-				$recherche_mod = str_replace($match, $word, (string) $recherche_mod);
179
-			}
180
-		}
181
-		$q = sql_quote(
182
-			'%'
183
-			. preg_replace(',\s+,' . $u, '%', $q)
184
-			. '%'
185
-		);
186
-
187
-		$preg = '/' . preg_replace(',\s+,' . $u, '.+', trim((string) $recherche_mod)) . '/' . $options['preg_flags'];
188
-	} else {
189
-		$methode = 'REGEXP';
190
-		$q = sql_quote(trim($recherche, '/'));
191
-	}
192
-
193
-	// tous les caracteres transliterables de $q sont remplaces par un joker
194
-	// permet de matcher en SQL meme si on est sensible aux accents (SQLite)
195
-	$q_t = $q;
196
-	for ($i = 0; $i < spip_strlen($q); $i++) {
197
-		$char = spip_substr($q, $i, 1);
198
-		if (
199
-			!is_ascii($char)
200
-			&& ($char_t = translitteration($char))
201
-			&& $char_t !== $char
202
-		) {
203
-			// on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes
204
-			// mais c'est un pis aller cf #4354
205
-			$q_t = str_replace($char, $is_preg ? '..?.?' : '_', (string) $q_t);
206
-		}
207
-	}
208
-
209
-	$q = $q_t;
210
-
211
-	// fix : SQLite 3 est sensible aux accents, on jokerise les caracteres
212
-	// les plus frequents qui peuvent etre accentues
213
-	// (oui c'est tres dicustable...)
214
-	if (
215
-		isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'])
216
-		&& str_starts_with((string) $GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite')
217
-	) {
218
-		$q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______');
219
-		// si il reste au moins un char significatif...
220
-		if (preg_match(",[^'%_.],", $q_t)) {
221
-			$q = $q_t;
222
-		}
223
-	}
224
-
225
-	return $expression[$key] = [$methode, $q, $preg];
78
+    // ne calculer qu'une seule fois l'expression par hit
79
+    // (meme si utilisee dans plusieurs boucles)
80
+    static $expression = [];
81
+    $key = serialize([$recherche, $options['preg_flags']]);
82
+    if (isset($expression[$key])) {
83
+        return $expression[$key];
84
+    }
85
+
86
+    $u = $GLOBALS['meta']['pcre_u'];
87
+    if ($u && !str_contains((string) $options['preg_flags'], (string) $u)) {
88
+        $options['preg_flags'] .= $u;
89
+    }
90
+    include_spip('inc/charsets');
91
+    $recherche = trim((string) $recherche);
92
+
93
+    // retirer les + de +truc et les * de truc*
94
+    $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche);
95
+    $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche);
96
+
97
+    $is_preg = false;
98
+    if (str_starts_with($recherche, '/') && str_ends_with($recherche, '/') && strlen($recherche) > 2) {
99
+        // c'est une preg
100
+        $recherche_trans = translitteration($recherche);
101
+        $preg = $recherche_trans . $options['preg_flags'];
102
+        $is_preg = true;
103
+    } else {
104
+        // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP,
105
+        // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un',
106
+        // 'une', 'des' ...)
107
+
108
+        // attention : plusieurs mots entre guillemets sont a rechercher tels quels
109
+        $recherche_trans = $recherche_mod = $recherche_org = $recherche;
110
+
111
+        // les expressions entre " " sont un mot a chercher tel quel
112
+        // -> on remplace les espaces par un \x1 et on enleve les guillemets
113
+        if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) {
114
+            foreach ($matches as $match) {
115
+                $word = preg_replace(',\s+,Uims', "\x1", $match);
116
+                $word = trim($word, '"');
117
+                $recherche_mod = str_replace($match, $word, $recherche_mod);
118
+            }
119
+        }
120
+
121
+        if (preg_match(',\s+,' . $u, $recherche_mod)) {
122
+            $is_preg = true;
123
+
124
+            $recherche_inter = '|';
125
+            $recherche_mots = explode(' ', $recherche_mod);
126
+            $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4;
127
+            $petits_mots = true;
128
+            foreach ($recherche_mots as $mot) {
129
+                if (strlen($mot) >= $min_long) {
130
+                    // echapper les caracteres de regexp qui sont eventuellement dans la recherche
131
+                    $recherche_inter .= preg_quote($mot) . ' ';
132
+                    $petits_mots = false;
133
+                }
134
+            }
135
+            $recherche_inter = str_replace("\x1", '\s', $recherche_inter);
136
+
137
+            // mais on cherche quand même l'expression complète, même si elle
138
+            // comporte des mots de moins de quatre lettres
139
+            $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|');
140
+            if (!$recherche || $petits_mots) {
141
+                $recherche = preg_quote($recherche_org);
142
+            }
143
+            $recherche_trans = translitteration($recherche);
144
+        }
145
+
146
+        $preg = '/' . str_replace('/', '\\/', (string) $recherche_trans) . '/' . $options['preg_flags'];
147
+    }
148
+
149
+    // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite
150
+    // ou si l'expression reguliere est invalide
151
+    if (!$is_preg || @preg_match($preg, '') === false) {
152
+        $methode = 'LIKE';
153
+        $u = $GLOBALS['meta']['pcre_u'];
154
+
155
+        // echapper les % et _
156
+        $q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche));
157
+
158
+        // eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses
159
+        $recherche = preg_quote($recherche, '/');
160
+        $recherche_trans = translitteration($recherche);
161
+        $recherche_mod = $recherche_trans;
162
+
163
+        // les expressions entre " " sont un mot a chercher tel quel
164
+        // -> on remplace les espaces par un _ et on enleve les guillemets
165
+        // corriger le like dans le $q
166
+        if (preg_match(',["][^"]+["],Uims', $q, $matches)) {
167
+            foreach ($matches as $match) {
168
+                $word = preg_replace(',\s+,Uims', '_', $match);
169
+                $word = trim($word, '"');
170
+                $q = str_replace($match, $word, $q);
171
+            }
172
+        }
173
+        // corriger la regexp
174
+        if (preg_match(',["][^"]+["],Uims', (string) $recherche_mod, $matches)) {
175
+            foreach ($matches as $match) {
176
+                $word = preg_replace(',\s+,Uims', '[\s]', $match);
177
+                $word = trim($word, '"');
178
+                $recherche_mod = str_replace($match, $word, (string) $recherche_mod);
179
+            }
180
+        }
181
+        $q = sql_quote(
182
+            '%'
183
+            . preg_replace(',\s+,' . $u, '%', $q)
184
+            . '%'
185
+        );
186
+
187
+        $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim((string) $recherche_mod)) . '/' . $options['preg_flags'];
188
+    } else {
189
+        $methode = 'REGEXP';
190
+        $q = sql_quote(trim($recherche, '/'));
191
+    }
192
+
193
+    // tous les caracteres transliterables de $q sont remplaces par un joker
194
+    // permet de matcher en SQL meme si on est sensible aux accents (SQLite)
195
+    $q_t = $q;
196
+    for ($i = 0; $i < spip_strlen($q); $i++) {
197
+        $char = spip_substr($q, $i, 1);
198
+        if (
199
+            !is_ascii($char)
200
+            && ($char_t = translitteration($char))
201
+            && $char_t !== $char
202
+        ) {
203
+            // on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes
204
+            // mais c'est un pis aller cf #4354
205
+            $q_t = str_replace($char, $is_preg ? '..?.?' : '_', (string) $q_t);
206
+        }
207
+    }
208
+
209
+    $q = $q_t;
210
+
211
+    // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres
212
+    // les plus frequents qui peuvent etre accentues
213
+    // (oui c'est tres dicustable...)
214
+    if (
215
+        isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'])
216
+        && str_starts_with((string) $GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite')
217
+    ) {
218
+        $q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______');
219
+        // si il reste au moins un char significatif...
220
+        if (preg_match(",[^'%_.],", $q_t)) {
221
+            $q = $q_t;
222
+        }
223
+    }
224
+
225
+    return $expression[$key] = [$methode, $q, $preg];
226 226
 }
227 227
 
228 228
 
@@ -249,136 +249,136 @@  discard block
 block discarded – undo
249 249
  * @return array
250 250
  */
251 251
 function recherche_en_base($recherche = '', $tables = null, $options = [], $serveur = '') {
252
-	include_spip('base/abstract_sql');
253
-
254
-	if (!is_array($tables)) {
255
-		$liste = liste_des_champs();
256
-
257
-		if (is_string($tables) && $tables != '') {
258
-			$toutes = [];
259
-			foreach (explode(',', $tables) as $t) {
260
-				$t = trim($t);
261
-				if (isset($liste[$t])) {
262
-					$toutes[$t] = $liste[$t];
263
-				}
264
-			}
265
-			$tables = $toutes;
266
-			unset($toutes);
267
-		} else {
268
-			$tables = $liste;
269
-		}
270
-	}
271
-
272
-	if (!strlen($recherche) || $tables === []) {
273
-		return [];
274
-	}
275
-
276
-	include_spip('inc/autoriser');
277
-
278
-	// options par defaut
279
-	$options = array_merge(
280
-		[
281
-		'preg_flags' => 'UimsS',
282
-		'toutvoir' => false,
283
-		'champs' => false,
284
-		'score' => false,
285
-		'matches' => false,
286
-		'jointures' => false,
287
-		'serveur' => $serveur
288
-		],
289
-		$options
290
-	);
291
-
292
-	$results = [];
293
-
294
-	// Utiliser l'iterateur (DATA:recherche)
295
-	// pour recuperer les couples (id_objet, score)
296
-	// Le resultat est au format {
297
-	//      id1 = { 'score' => x, attrs => { } },
298
-	//      id2 = { 'score' => x, attrs => { } },
299
-	// }
300
-
301
-	include_spip('inc/recherche_to_array');
302
-
303
-	foreach ($tables as $table => $champs) {
304
-		# lock via memoization, si dispo
305
-		if (function_exists('cache_lock')) {
306
-			cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche);
307
-		}
308
-
309
-		spip_timer('rech');
310
-
311
-		# TODO : ici plutot charger un iterateur via l'API iterateurs
312
-		$to_array = charger_fonction('recherche_to_array', 'inc');
313
-		$results[$table] = $to_array(
314
-			$recherche,
315
-			array_merge($options, ['table' => $table, 'champs' => $champs])
316
-		);
317
-		##var_dump($results[$table]);
318
-
319
-
320
-		spip_log(
321
-			"recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'),
322
-			'recherche'
323
-		);
324
-
325
-		if (isset($lock)) {
326
-			cache_unlock($lock);
327
-		}
328
-	}
329
-
330
-	return $results;
252
+    include_spip('base/abstract_sql');
253
+
254
+    if (!is_array($tables)) {
255
+        $liste = liste_des_champs();
256
+
257
+        if (is_string($tables) && $tables != '') {
258
+            $toutes = [];
259
+            foreach (explode(',', $tables) as $t) {
260
+                $t = trim($t);
261
+                if (isset($liste[$t])) {
262
+                    $toutes[$t] = $liste[$t];
263
+                }
264
+            }
265
+            $tables = $toutes;
266
+            unset($toutes);
267
+        } else {
268
+            $tables = $liste;
269
+        }
270
+    }
271
+
272
+    if (!strlen($recherche) || $tables === []) {
273
+        return [];
274
+    }
275
+
276
+    include_spip('inc/autoriser');
277
+
278
+    // options par defaut
279
+    $options = array_merge(
280
+        [
281
+        'preg_flags' => 'UimsS',
282
+        'toutvoir' => false,
283
+        'champs' => false,
284
+        'score' => false,
285
+        'matches' => false,
286
+        'jointures' => false,
287
+        'serveur' => $serveur
288
+        ],
289
+        $options
290
+    );
291
+
292
+    $results = [];
293
+
294
+    // Utiliser l'iterateur (DATA:recherche)
295
+    // pour recuperer les couples (id_objet, score)
296
+    // Le resultat est au format {
297
+    //      id1 = { 'score' => x, attrs => { } },
298
+    //      id2 = { 'score' => x, attrs => { } },
299
+    // }
300
+
301
+    include_spip('inc/recherche_to_array');
302
+
303
+    foreach ($tables as $table => $champs) {
304
+        # lock via memoization, si dispo
305
+        if (function_exists('cache_lock')) {
306
+            cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche);
307
+        }
308
+
309
+        spip_timer('rech');
310
+
311
+        # TODO : ici plutot charger un iterateur via l'API iterateurs
312
+        $to_array = charger_fonction('recherche_to_array', 'inc');
313
+        $results[$table] = $to_array(
314
+            $recherche,
315
+            array_merge($options, ['table' => $table, 'champs' => $champs])
316
+        );
317
+        ##var_dump($results[$table]);
318
+
319
+
320
+        spip_log(
321
+            "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'),
322
+            'recherche'
323
+        );
324
+
325
+        if (isset($lock)) {
326
+            cache_unlock($lock);
327
+        }
328
+    }
329
+
330
+    return $results;
331 331
 }
332 332
 
333 333
 
334 334
 // Effectue une recherche sur toutes les tables de la base de donnees
335 335
 function remplace_en_base($recherche = '', $remplace = null, $tables = null, $options = []) {
336
-	include_spip('inc/modifier');
337
-
338
-	// options par defaut
339
-	$options = array_merge(
340
-		[
341
-		'preg_flags' => 'UimsS',
342
-		'toutmodifier' => false
343
-		],
344
-		$options
345
-	);
346
-	$options['champs'] = true;
347
-
348
-
349
-	if (!is_array($tables)) {
350
-		$tables = liste_des_champs();
351
-	}
352
-
353
-	$results = recherche_en_base($recherche, $tables, $options);
354
-
355
-	$preg = '/' . str_replace('/', '\\/', (string) $recherche) . '/' . $options['preg_flags'];
356
-
357
-	foreach ($results as $table => $r) {
358
-		$_id_table = id_table_objet($table);
359
-		foreach ($r as $id => $x) {
360
-			if ($options['toutmodifier'] || autoriser('modifier', $table, $id)) {
361
-				$modifs = [];
362
-				foreach ($x['champs'] as $key => $val) {
363
-					if ($key == $_id_table) {
364
-						continue;
365
-					}
366
-					$repl = preg_replace($preg, (string) $remplace, (string) $val);
367
-					if ($repl != $val) {
368
-						$modifs[$key] = $repl;
369
-					}
370
-				}
371
-				if ($modifs) {
372
-					objet_modifier_champs(
373
-						$table,
374
-						$id,
375
-						[
376
-							'champs' => array_keys($modifs),
377
-						],
378
-						$modifs
379
-					);
380
-				}
381
-			}
382
-		}
383
-	}
336
+    include_spip('inc/modifier');
337
+
338
+    // options par defaut
339
+    $options = array_merge(
340
+        [
341
+        'preg_flags' => 'UimsS',
342
+        'toutmodifier' => false
343
+        ],
344
+        $options
345
+    );
346
+    $options['champs'] = true;
347
+
348
+
349
+    if (!is_array($tables)) {
350
+        $tables = liste_des_champs();
351
+    }
352
+
353
+    $results = recherche_en_base($recherche, $tables, $options);
354
+
355
+    $preg = '/' . str_replace('/', '\\/', (string) $recherche) . '/' . $options['preg_flags'];
356
+
357
+    foreach ($results as $table => $r) {
358
+        $_id_table = id_table_objet($table);
359
+        foreach ($r as $id => $x) {
360
+            if ($options['toutmodifier'] || autoriser('modifier', $table, $id)) {
361
+                $modifs = [];
362
+                foreach ($x['champs'] as $key => $val) {
363
+                    if ($key == $_id_table) {
364
+                        continue;
365
+                    }
366
+                    $repl = preg_replace($preg, (string) $remplace, (string) $val);
367
+                    if ($repl != $val) {
368
+                        $modifs[$key] = $repl;
369
+                    }
370
+                }
371
+                if ($modifs) {
372
+                    objet_modifier_champs(
373
+                        $table,
374
+                        $id,
375
+                        [
376
+                            'champs' => array_keys($modifs),
377
+                        ],
378
+                        $modifs
379
+                    );
380
+                }
381
+            }
382
+        }
383
+    }
384 384
 }
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/boutons');
17 17
 include_spip('base/objets');
18 18
 
19 19
 function inc_icone_renommer_dist($fond, $fonction) {
20
-	$size = 24;
21
-	if (
22
-		preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', (string) $fond, $match)
23
-		&& (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
-	) {
25
-		if (isset($match[1]) && $match[1]) {
26
-			$size = $match[1];
27
-		}
28
-		$type = substr((string) $fond, 0, -strlen($match[0]));
29
-		if (!isset($match[2]) || !$match[2]) {
30
-			$fond .= '.png';
31
-		}
32
-	} else {
33
-		$type = $fond;
34
-		$fond .= '.png';
35
-	}
20
+    $size = 24;
21
+    if (
22
+        preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', (string) $fond, $match)
23
+        && (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
+    ) {
25
+        if (isset($match[1]) && $match[1]) {
26
+            $size = $match[1];
27
+        }
28
+        $type = substr((string) $fond, 0, -strlen($match[0]));
29
+        if (!isset($match[2]) || !$match[2]) {
30
+            $fond .= '.png';
31
+        }
32
+    } else {
33
+        $type = $fond;
34
+        $fond .= '.png';
35
+    }
36 36
 
37
-	$rtl = false;
38
-	if (preg_match(',[-_]rtl$,i', (string) $type, $match)) {
39
-		$rtl = true;
40
-		$type = substr((string) $type, 0, -strlen($match[0]));
41
-	}
37
+    $rtl = false;
38
+    if (preg_match(',[-_]rtl$,i', (string) $type, $match)) {
39
+        $rtl = true;
40
+        $type = substr((string) $type, 0, -strlen($match[0]));
41
+    }
42 42
 
43
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
-	// et ne finit pas par un s, sauf si c'est une exception declaree
45
-	$type = objet_type($type, false);
43
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
+    // et ne finit pas par un s, sauf si c'est une exception declaree
45
+    $type = objet_type($type, false);
46 46
 
47
-	$dir = 'images/';
48
-	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
50
-		$dir = dirname((string) $icone);
51
-		$fond = $icone;
47
+    $dir = 'images/';
48
+    $f = "$type-$size.png";
49
+    if ($icone = find_in_theme($dir . $f)) {
50
+        $dir = dirname((string) $icone);
51
+        $fond = $icone;
52 52
 
53
-		if (
54
-			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56
-			&& file_exists($fr)
57
-		) {
58
-			$fond = $fr;
59
-		}
53
+        if (
54
+            $rtl
55
+            && ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56
+            && file_exists($fr)
57
+        ) {
58
+            $fond = $fr;
59
+        }
60 60
 
61
-		$action = $fonction;
62
-		if ($action == 'supprimer.gif') {
63
-			$action = 'del';
64
-		} elseif ($action == 'creer.gif') {
65
-			$action = 'new';
66
-		} elseif ($action == 'edit.gif') {
67
-			$action = 'edit';
68
-		}
61
+        $action = $fonction;
62
+        if ($action == 'supprimer.gif') {
63
+            $action = 'del';
64
+        } elseif ($action == 'creer.gif') {
65
+            $action = 'new';
66
+        } elseif ($action == 'edit.gif') {
67
+            $action = 'edit';
68
+        }
69 69
 
70
-		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
-			$fonction = $action;
73
-		}
70
+        $fonction = '';
71
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+            $fonction = $action;
73
+        }
74 74
 
75
-		// c'est bon !
76
-		return [$fond, $fonction];
77
-	}
75
+        // c'est bon !
76
+        return [$fond, $fonction];
77
+    }
78 78
 
79
-	return [$fond, $fonction];
79
+    return [$fond, $fonction];
80 80
 }
Please login to merge, or discard this patch.
ecrire/inc/journal.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
  * @param array $opt
24 24
  */
25 25
 function inc_journal_dist($phrase, $opt = []) {
26
-	if (!strlen((string) $phrase)) {
27
-		return;
28
-	}
29
-	if ($opt) {
30
-		$phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt));
31
-	}
32
-	spip_log($phrase, 'journal');
26
+    if (!strlen((string) $phrase)) {
27
+        return;
28
+    }
29
+    if ($opt) {
30
+        $phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt));
31
+    }
32
+    spip_log($phrase, 'journal');
33 33
 }
Please login to merge, or discard this patch.