Completed
Push — master ( 11f8d8...e4a3b1 )
by cam
01:03
created
ecrire/inc/pipelines.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 if (test_espace_prive()) {
22
-	include_spip('inc/pipelines_ecrire');
22
+    include_spip('inc/pipelines_ecrire');
23 23
 }
24 24
 
25 25
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
  * @return string          Contenu qui sera inséré dans le head HTML
46 46
  **/
47 47
 function f_jQuery($texte) {
48
-	$x = '';
49
-	$jquery_plugins = pipeline(
50
-		'jquery_plugins',
51
-		[
52
-			'javascript/jquery.js',
53
-			'javascript/jquery.form.js',
54
-			'javascript/jquery.autosave.js',
55
-			'javascript/jquery.placeholder-label.js',
56
-			'javascript/ajaxCallback.js',
57
-			'javascript/js.cookie.js',
58
-		]
59
-	);
60
-	foreach (array_unique($jquery_plugins) as $script) {
61
-		if ($script = find_in_path(supprimer_timestamp($script))) {
62
-			$script = timestamp($script);
63
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
-		}
65
-	}
48
+    $x = '';
49
+    $jquery_plugins = pipeline(
50
+        'jquery_plugins',
51
+        [
52
+            'javascript/jquery.js',
53
+            'javascript/jquery.form.js',
54
+            'javascript/jquery.autosave.js',
55
+            'javascript/jquery.placeholder-label.js',
56
+            'javascript/ajaxCallback.js',
57
+            'javascript/js.cookie.js',
58
+        ]
59
+    );
60
+    foreach (array_unique($jquery_plugins) as $script) {
61
+        if ($script = find_in_path(supprimer_timestamp($script))) {
62
+            $script = timestamp($script);
63
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
+        }
65
+    }
66 66
 
67
-	$texte = $x . $texte;
67
+    $texte = $x . $texte;
68 68
 
69
-	return $texte;
69
+    return $texte;
70 70
 }
71 71
 
72 72
 
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
  * @return string         Contenu de la page envoyée au navigateur
86 86
  **/
87 87
 function f_surligne($texte) {
88
-	if (!$GLOBALS['html']) {
89
-		return $texte;
90
-	}
91
-	$rech = _request('var_recherche');
92
-	if (
93
-		!$rech
94
-		and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
-			or !_SURLIGNE_RECHERCHE_REFERERS
96
-			or !isset($_SERVER['HTTP_REFERER']))
97
-	) {
98
-		return $texte;
99
-	}
100
-	include_spip('inc/surligne');
88
+    if (!$GLOBALS['html']) {
89
+        return $texte;
90
+    }
91
+    $rech = _request('var_recherche');
92
+    if (
93
+        !$rech
94
+        and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
+            or !_SURLIGNE_RECHERCHE_REFERERS
96
+            or !isset($_SERVER['HTTP_REFERER']))
97
+    ) {
98
+        return $texte;
99
+    }
100
+    include_spip('inc/surligne');
101 101
 
102
-	if (isset($_SERVER['HTTP_REFERER'])) {
103
-		$_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
-	}
105
-	if ($rech) {
106
-		$rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
-	}
102
+    if (isset($_SERVER['HTTP_REFERER'])) {
103
+        $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
+    }
105
+    if ($rech) {
106
+        $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
+    }
108 108
 
109
-	return surligner_mots($texte, $rech);
109
+    return surligner_mots($texte, $rech);
110 110
 }
111 111
 
112 112
 /**
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
  * @return string         Contenu de la page envoyée au navigateur
124 124
  **/
125 125
 function f_tidy($texte) {
126
-	/**
127
-	 * Indentation à faire ?
128
-	 *
129
-	 * - true : actif.
130
-	 * - false par défaut.
131
-	 */
126
+    /**
127
+     * Indentation à faire ?
128
+     *
129
+     * - true : actif.
130
+     * - false par défaut.
131
+     */
132 132
 
133
-	if (
134
-		$GLOBALS['xhtml'] # tidy demande
135
-		and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
-		and strlen($texte)
137
-		and !headers_sent()
138
-	) {
139
-		# Compatibilite ascendante
140
-		if (!is_string($GLOBALS['xhtml'])) {
141
-			$GLOBALS['xhtml'] = 'tidy';
142
-		}
133
+    if (
134
+        $GLOBALS['xhtml'] # tidy demande
135
+        and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
+        and strlen($texte)
137
+        and !headers_sent()
138
+    ) {
139
+        # Compatibilite ascendante
140
+        if (!is_string($GLOBALS['xhtml'])) {
141
+            $GLOBALS['xhtml'] = 'tidy';
142
+        }
143 143
 
144
-		if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
-			spip_log("tidy absent, l'indenteur SPIP le remplace");
146
-			$f = charger_fonction('sax', 'xml');
147
-		}
144
+        if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
+            spip_log("tidy absent, l'indenteur SPIP le remplace");
146
+            $f = charger_fonction('sax', 'xml');
147
+        }
148 148
 
149
-		return $f($texte);
150
-	}
149
+        return $f($texte);
150
+    }
151 151
 
152
-	return $texte;
152
+    return $texte;
153 153
 }
154 154
 
155 155
 
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
  * @return string         Contenu de la page envoyée au navigateur
169 169
  **/
170 170
 function f_insert_head($texte) {
171
-	if (!$GLOBALS['html']) {
172
-		return $texte;
173
-	}
174
-	include_spip('public/admin'); // pour strripos
171
+    if (!$GLOBALS['html']) {
172
+        return $texte;
173
+    }
174
+    include_spip('public/admin'); // pour strripos
175 175
 
176
-	($pos = stripos($texte, '</head>'))
177
-	|| ($pos = stripos($texte, '<body>'))
178
-	|| ($pos = 0);
176
+    ($pos = stripos($texte, '</head>'))
177
+    || ($pos = stripos($texte, '<body>'))
178
+    || ($pos = 0);
179 179
 
180
-	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
-		$texte = substr_replace($texte, $insert, $pos, 0);
183
-	}
180
+    if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
+        $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+        $texte = substr_replace($texte, $insert, $pos, 0);
183
+    }
184 184
 
185
-	return $texte;
185
+    return $texte;
186 186
 }
187 187
 
188 188
 
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
  * @return string         Contenu de la page envoyée au navigateur
199 199
  **/
200 200
 function f_admin($texte) {
201
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
-		include_spip('inc/filtres'); // pour http_img_pack
203
-		$x = "<div class='spip-previsu' "
204
-			. http_style_background('preview-32.png', '', 32)
205
-			. '>'
206
-			. _T('previsualisation')
207
-			. '</div>';
208
-		if (!$pos = stripos($texte, '</body>')) {
209
-			$pos = strlen($texte);
210
-		}
211
-		$texte = substr_replace($texte, $x, $pos, 0);
212
-		// pas de preview en fenetre enfant
213
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
-		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
-			$pos = -1;
216
-		}
217
-		$texte = substr_replace($texte, $x, $pos + 1, 0);
218
-	}
201
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
+        include_spip('inc/filtres'); // pour http_img_pack
203
+        $x = "<div class='spip-previsu' "
204
+            . http_style_background('preview-32.png', '', 32)
205
+            . '>'
206
+            . _T('previsualisation')
207
+            . '</div>';
208
+        if (!$pos = stripos($texte, '</body>')) {
209
+            $pos = strlen($texte);
210
+        }
211
+        $texte = substr_replace($texte, $x, $pos, 0);
212
+        // pas de preview en fenetre enfant
213
+        $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+        if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
+            $pos = -1;
216
+        }
217
+        $texte = substr_replace($texte, $x, $pos + 1, 0);
218
+    }
219 219
 
220
-	if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
-		include_spip('public/admin');
222
-		$texte = affiche_boutons_admin($texte);
223
-	}
224
-	if (_request('var_mode') == 'noajax') {
225
-		$texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
-	}
220
+    if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
+        include_spip('public/admin');
222
+        $texte = affiche_boutons_admin($texte);
223
+    }
224
+    if (_request('var_mode') == 'noajax') {
225
+        $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
+    }
227 227
 
228
-	return $texte;
228
+    return $texte;
229 229
 }
230 230
 
231 231
 /**
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  * @return array $flux  Description et contenu de l'inclusion
244 244
  **/
245 245
 function f_recuperer_fond($flux) {
246
-	if (!test_espace_prive()) {
247
-		return $flux;
248
-	}
246
+    if (!test_espace_prive()) {
247
+        return $flux;
248
+    }
249 249
 
250
-	return f_afficher_blocs_ecrire($flux);
250
+    return f_afficher_blocs_ecrire($flux);
251 251
 }
252 252
 
253 253
 /**
@@ -261,30 +261,30 @@  discard block
 block discarded – undo
261 261
  * @return string         Contenu de la page envoyée au navigateur
262 262
  */
263 263
 function f_queue($texte) {
264
-	// eviter une inclusion si rien a faire
265
-	if (
266
-		_request('action') == 'cron'
267
-		or queue_sleep_time_to_next_job() > 0
268
-		or defined('_DEBUG_BLOCK_QUEUE')
269
-	) {
270
-		return $texte;
271
-	}
264
+    // eviter une inclusion si rien a faire
265
+    if (
266
+        _request('action') == 'cron'
267
+        or queue_sleep_time_to_next_job() > 0
268
+        or defined('_DEBUG_BLOCK_QUEUE')
269
+    ) {
270
+        return $texte;
271
+    }
272 272
 
273
-	include_spip('inc/queue');
274
-	$code = queue_affichage_cron();
273
+    include_spip('inc/queue');
274
+    $code = queue_affichage_cron();
275 275
 
276
-	// si rien a afficher
277
-	// ou si on est pas dans une page html, on ne sait rien faire de mieux
278
-	if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
-		return $texte;
280
-	}
276
+    // si rien a afficher
277
+    // ou si on est pas dans une page html, on ne sait rien faire de mieux
278
+    if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
+        return $texte;
280
+    }
281 281
 
282
-	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
-	if (($p = strpos($texte, '</body>')) !== false) {
284
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
-	} else {
286
-		$texte .= $code;
287
-	}
282
+    // inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
+    if (($p = strpos($texte, '</body>')) !== false) {
284
+        $texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+    } else {
286
+        $texte .= $code;
287
+    }
288 288
 
289
-	return $texte;
289
+    return $texte;
290 290
 }
Please login to merge, or discard this patch.
ecrire/inc/pipelines_ecrire.php 1 patch
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -36,36 +36,36 @@  discard block
 block discarded – undo
36 36
  * @return string          Contenu complété des scripts javascripts, dont jQuery
37 37
  **/
38 38
 function f_jQuery_prive($texte) {
39
-	$x = '';
40
-	$jquery_plugins = pipeline(
41
-		'jquery_plugins',
42
-		[
43
-			'prive/javascript/jquery.js',
44
-			'prive/javascript/jquery.form.js',
45
-			'prive/javascript/jquery.autosave.js',
46
-			'prive/javascript/jquery.placeholder-label.js',
47
-			'prive/javascript/ajaxCallback.js',
48
-			'prive/javascript/js.cookie.js',
49
-			'prive/javascript/spip_barre.js',
50
-		]
51
-	);
52
-	foreach (array_unique($jquery_plugins) as $script) {
53
-		if ($script = find_in_path(supprimer_timestamp($script))) {
54
-			$script = timestamp($script);
55
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
56
-		}
57
-	}
58
-	// inserer avant le premier script externe ou a la fin
59
-	if (
60
-		preg_match(',<script[^><]*src=,', $texte, $match)
61
-		and $p = strpos($texte, (string) $match[0])
62
-	) {
63
-		$texte = substr_replace($texte, $x, $p, 0);
64
-	} else {
65
-		$texte .= $x;
66
-	}
39
+    $x = '';
40
+    $jquery_plugins = pipeline(
41
+        'jquery_plugins',
42
+        [
43
+            'prive/javascript/jquery.js',
44
+            'prive/javascript/jquery.form.js',
45
+            'prive/javascript/jquery.autosave.js',
46
+            'prive/javascript/jquery.placeholder-label.js',
47
+            'prive/javascript/ajaxCallback.js',
48
+            'prive/javascript/js.cookie.js',
49
+            'prive/javascript/spip_barre.js',
50
+        ]
51
+    );
52
+    foreach (array_unique($jquery_plugins) as $script) {
53
+        if ($script = find_in_path(supprimer_timestamp($script))) {
54
+            $script = timestamp($script);
55
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
56
+        }
57
+    }
58
+    // inserer avant le premier script externe ou a la fin
59
+    if (
60
+        preg_match(',<script[^><]*src=,', $texte, $match)
61
+        and $p = strpos($texte, (string) $match[0])
62
+    ) {
63
+        $texte = substr_replace($texte, $x, $p, 0);
64
+    } else {
65
+        $texte .= $x;
66
+    }
67 67
 
68
-	return $texte;
68
+    return $texte;
69 69
 }
70 70
 
71 71
 
@@ -78,43 +78,43 @@  discard block
 block discarded – undo
78 78
  * @return string
79 79
  */
80 80
 function affichage_final_prive_title_auto($texte) {
81
-	if (
82
-		strpos($texte, '<title>') === false
83
-		and
84
-		(preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
85
-			or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
86
-		and $match = textebrut(trim($match[1]))
87
-		and ($p = strpos($texte, '<head>')) !== false
88
-	) {
89
-		if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
90
-			$nom_site_spip = _T('info_mon_site_spip');
91
-		}
81
+    if (
82
+        strpos($texte, '<title>') === false
83
+        and
84
+        (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
85
+            or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
86
+        and $match = textebrut(trim($match[1]))
87
+        and ($p = strpos($texte, '<head>')) !== false
88
+    ) {
89
+        if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
90
+            $nom_site_spip = _T('info_mon_site_spip');
91
+        }
92 92
 
93
-		$titre = '<title>['
94
-			. $nom_site_spip
95
-			. '] ' . $match
96
-			. '</title>';
93
+        $titre = '<title>['
94
+            . $nom_site_spip
95
+            . '] ' . $match
96
+            . '</title>';
97 97
 
98
-		$texte = substr_replace($texte, $titre, $p + 6, 0);
99
-	}
98
+        $texte = substr_replace($texte, $titre, $p + 6, 0);
99
+    }
100 100
 
101
-	return $texte;
101
+    return $texte;
102 102
 }
103 103
 
104 104
 
105 105
 // Fonction standard pour le pipeline 'boite_infos'
106 106
 // https://code.spip.net/@f_boite_infos
107 107
 function f_boite_infos($flux) {
108
-	$args = $flux['args'];
109
-	$type = $args['type'];
110
-	unset($args['row']);
111
-	if (!trouver_fond($type, 'prive/objets/infos/')) {
112
-		$type = 'objet';
113
-	}
114
-	$args['espace_prive'] = 1;
115
-	$flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
108
+    $args = $flux['args'];
109
+    $type = $args['type'];
110
+    unset($args['row']);
111
+    if (!trouver_fond($type, 'prive/objets/infos/')) {
112
+        $type = 'objet';
113
+    }
114
+    $args['espace_prive'] = 1;
115
+    $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
116 116
 
117
-	return $flux;
117
+    return $flux;
118 118
 }
119 119
 
120 120
 
@@ -133,97 +133,97 @@  discard block
 block discarded – undo
133 133
  * @return array Données du pipeline
134 134
  */
135 135
 function f_afficher_blocs_ecrire($flux) {
136
-	static $o = [];
137
-	if (is_string($fond = $flux['args']['fond'])) {
138
-		$exec = $flux['args']['contexte']['exec'] ?? _request('exec');
139
-		if (!isset($o[$exec])) {
140
-			$o[$exec] = trouver_objet_exec($exec);
141
-		}
142
-		// cas particulier
143
-		if ($exec == 'infos_perso') {
144
-			$flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
145
-		}
146
-		$typepage = ($flux['args']['contexte']['type-page'] ?? $exec);
147
-		if ($fond == "prive/squelettes/navigation/$typepage") {
148
-			$flux['data']['texte'] = pipeline(
149
-				'affiche_gauche',
150
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
151
-			);
152
-		} elseif ($fond == "prive/squelettes/extra/$typepage") {
153
-			include_spip('inc/presentation_mini');
154
-			$flux['data']['texte'] = pipeline(
155
-				'affiche_droite',
156
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
157
-			) . liste_objets_bloques(
158
-				$exec,
159
-				$flux['args']['contexte']
160
-			);
161
-		} elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
162
-			// id non defini sur les formulaire de nouveaux objets
163
-			$id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
164
-			$flux['data']['texte'] = pipeline(
165
-				'affiche_hierarchie',
166
-				['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
167
-			);
168
-		} elseif ($fond == "prive/squelettes/contenu/$typepage") {
169
-			// Préparation du marqueur affiche_milieu
170
-			// Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
171
-			$est_page_objet = !empty($o[$exec]['type']);
172
-			$est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
173
-			$encapsuler_milieu = ($est_page_objet and !$est_en_edition);
174
-			$flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
175
-				$flux['data']['texte'],
176
-				'<!--affiche_milieu-->',
177
-				'<div id=["\']wysiwyg',
178
-				$encapsuler_milieu ? '<div class="affiche_milieu">' : '',
179
-				$encapsuler_milieu ? '</div>' : ''
180
-			);
181
-			if (
182
-				$o[$exec]
183
-				and $objet = $o[$exec]['type']
184
-				and $o[$exec]['edition'] == false
185
-				and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
186
-				and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
187
-			) {
188
-				// inserer le formulaire de traduction
189
-				$flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
190
-					'prive/objets/editer/traductions',
191
-					['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
192
-				) . '<!--affiche_milieu-->', $flux['data']['texte']);
193
-				$flux['data']['texte'] = pipeline('afficher_fiche_objet', [
194
-					'args' => [
195
-						'contexte' => $flux['args']['contexte'],
196
-						'type' => $objet,
197
-						'id' => $id
198
-					],
199
-					'data' => $flux['data']['texte']
200
-				]);
201
-			}
202
-			$flux['data']['texte'] = pipeline(
203
-				'affiche_milieu',
204
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
205
-			);
206
-		} elseif ($fond == 'prive/squelettes/inclure/pied') {
207
-			$flux['data']['texte'] = pipeline(
208
-				'affiche_pied',
209
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
210
-			);
211
-		} elseif (
212
-			strncmp($fond, 'prive/objets/contenu/', 21) == 0
213
-			and $objet = basename($fond)
214
-			and $objet == substr($fond, 21)
215
-			and isset($o[$objet])
216
-			and $o[$objet]
217
-		) {
218
-			$id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
219
-			$flux['data']['texte'] = pipeline('afficher_contenu_objet', [
220
-				'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
221
-				'data' => $flux['data']['texte']
222
-			]);
223
-		}
224
-	}
136
+    static $o = [];
137
+    if (is_string($fond = $flux['args']['fond'])) {
138
+        $exec = $flux['args']['contexte']['exec'] ?? _request('exec');
139
+        if (!isset($o[$exec])) {
140
+            $o[$exec] = trouver_objet_exec($exec);
141
+        }
142
+        // cas particulier
143
+        if ($exec == 'infos_perso') {
144
+            $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
145
+        }
146
+        $typepage = ($flux['args']['contexte']['type-page'] ?? $exec);
147
+        if ($fond == "prive/squelettes/navigation/$typepage") {
148
+            $flux['data']['texte'] = pipeline(
149
+                'affiche_gauche',
150
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
151
+            );
152
+        } elseif ($fond == "prive/squelettes/extra/$typepage") {
153
+            include_spip('inc/presentation_mini');
154
+            $flux['data']['texte'] = pipeline(
155
+                'affiche_droite',
156
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
157
+            ) . liste_objets_bloques(
158
+                $exec,
159
+                $flux['args']['contexte']
160
+            );
161
+        } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
162
+            // id non defini sur les formulaire de nouveaux objets
163
+            $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
164
+            $flux['data']['texte'] = pipeline(
165
+                'affiche_hierarchie',
166
+                ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
167
+            );
168
+        } elseif ($fond == "prive/squelettes/contenu/$typepage") {
169
+            // Préparation du marqueur affiche_milieu
170
+            // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
171
+            $est_page_objet = !empty($o[$exec]['type']);
172
+            $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
173
+            $encapsuler_milieu = ($est_page_objet and !$est_en_edition);
174
+            $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
175
+                $flux['data']['texte'],
176
+                '<!--affiche_milieu-->',
177
+                '<div id=["\']wysiwyg',
178
+                $encapsuler_milieu ? '<div class="affiche_milieu">' : '',
179
+                $encapsuler_milieu ? '</div>' : ''
180
+            );
181
+            if (
182
+                $o[$exec]
183
+                and $objet = $o[$exec]['type']
184
+                and $o[$exec]['edition'] == false
185
+                and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
186
+                and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
187
+            ) {
188
+                // inserer le formulaire de traduction
189
+                $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
190
+                    'prive/objets/editer/traductions',
191
+                    ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
192
+                ) . '<!--affiche_milieu-->', $flux['data']['texte']);
193
+                $flux['data']['texte'] = pipeline('afficher_fiche_objet', [
194
+                    'args' => [
195
+                        'contexte' => $flux['args']['contexte'],
196
+                        'type' => $objet,
197
+                        'id' => $id
198
+                    ],
199
+                    'data' => $flux['data']['texte']
200
+                ]);
201
+            }
202
+            $flux['data']['texte'] = pipeline(
203
+                'affiche_milieu',
204
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
205
+            );
206
+        } elseif ($fond == 'prive/squelettes/inclure/pied') {
207
+            $flux['data']['texte'] = pipeline(
208
+                'affiche_pied',
209
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
210
+            );
211
+        } elseif (
212
+            strncmp($fond, 'prive/objets/contenu/', 21) == 0
213
+            and $objet = basename($fond)
214
+            and $objet == substr($fond, 21)
215
+            and isset($o[$objet])
216
+            and $o[$objet]
217
+        ) {
218
+            $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
219
+            $flux['data']['texte'] = pipeline('afficher_contenu_objet', [
220
+                'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
221
+                'data' => $flux['data']['texte']
222
+            ]);
223
+        }
224
+    }
225 225
 
226
-	return $flux;
226
+    return $flux;
227 227
 }
228 228
 
229 229
 /**
@@ -251,36 +251,36 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string {
253 253
 
254
-	if ($texte) {
255
-		$encapsuler = (($ouvrir and $fermer) ? true : false);
256
-		$marqueur_pos = strpos($texte, $marqueur);
257
-		$full_marqueur = "$ouvrir$marqueur$fermer";
254
+    if ($texte) {
255
+        $encapsuler = (($ouvrir and $fermer) ? true : false);
256
+        $marqueur_pos = strpos($texte, $marqueur);
257
+        $full_marqueur = "$ouvrir$marqueur$fermer";
258 258
 
259
-		// Le marqueur est absent : on l'ajoute avant l'élément indiqué
260
-		if ($marqueur_pos  === false) {
261
-			$texte = preg_replace(
262
-				",$inserer_avant,",
263
-				"$full_marqueur\\0",
264
-				$texte
265
-			);
266
-		// Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
267
-		// Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
268
-		// Il ne faut donc aucun espace blanc en trop.
269
-		} elseif (
270
-			$marqueur_pos !== false
271
-			and $encapsuler
272
-			and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
273
-		) {
274
-			$texte = substr_replace(
275
-				$texte,
276
-				$full_marqueur,
277
-				$marqueur_pos,
278
-				strlen($marqueur)
279
-			);
280
-		}
281
-	}
259
+        // Le marqueur est absent : on l'ajoute avant l'élément indiqué
260
+        if ($marqueur_pos  === false) {
261
+            $texte = preg_replace(
262
+                ",$inserer_avant,",
263
+                "$full_marqueur\\0",
264
+                $texte
265
+            );
266
+        // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
267
+        // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
268
+        // Il ne faut donc aucun espace blanc en trop.
269
+        } elseif (
270
+            $marqueur_pos !== false
271
+            and $encapsuler
272
+            and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
273
+        ) {
274
+            $texte = substr_replace(
275
+                $texte,
276
+                $full_marqueur,
277
+                $marqueur_pos,
278
+                strlen($marqueur)
279
+            );
280
+        }
281
+    }
282 282
 
283
-	return $texte;
283
+    return $texte;
284 284
 }
285 285
 
286 286
 /**
@@ -291,23 +291,23 @@  discard block
 block discarded – undo
291 291
  * @return string
292 292
  */
293 293
 function f_queue_affiche_milieu($flux) {
294
-	$args = $flux['args'];
295
-	$res = '';
296
-	foreach ($args as $key => $arg) {
297
-		if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
298
-			$objet = preg_replace(',^id_,', '', $key);
299
-			$res .= recuperer_fond(
300
-				'modeles/object_jobs_list',
301
-				['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
302
-				['ajax' => true]
303
-			);
304
-		}
305
-	}
306
-	if ($res) {
307
-		$flux['data'] = $res . $flux['data'];
308
-	}
294
+    $args = $flux['args'];
295
+    $res = '';
296
+    foreach ($args as $key => $arg) {
297
+        if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
298
+            $objet = preg_replace(',^id_,', '', $key);
299
+            $res .= recuperer_fond(
300
+                'modeles/object_jobs_list',
301
+                ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
302
+                ['ajax' => true]
303
+            );
304
+        }
305
+    }
306
+    if ($res) {
307
+        $flux['data'] = $res . $flux['data'];
308
+    }
309 309
 
310
-	return $flux;
310
+    return $flux;
311 311
 }
312 312
 
313 313
 /**
@@ -321,39 +321,39 @@  discard block
 block discarded – undo
321 321
  * @return array|bool
322 322
  */
323 323
 function trouver_objet_exec(string $exec) {
324
-	static $objet_exec = [];
325
-	if (!$exec) {
326
-		return false;
327
-	}
328
-	// cas particulier
329
-	if ($exec === 'infos_perso') {
330
-		$exec = 'auteur';
331
-		set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
332
-	}
333
-	if (!isset($objet_exec[$exec])) {
334
-		$objet_exec[$exec] = false;
335
-		$infos = lister_tables_objets_sql();
336
-		foreach ($infos as $t => $info) {
337
-			if ($exec === $info['url_edit'] and $info['editable']) {
338
-				return $objet_exec[$exec] = [
339
-					'edition' => $exec == $info['url_voir'] ? '' : true,
340
-					'table_objet_sql' => $t,
341
-					'table' => $info['table_objet'],
342
-					'type' => $info['type'],
343
-					'id_table_objet' => id_table_objet($info['type'])
344
-				];
345
-			}
346
-			if ($exec === $info['url_voir']) {
347
-				return $objet_exec[$exec] = [
348
-					'edition' => false,
349
-					'table_objet_sql' => $t,
350
-					'table' => $info['table_objet'],
351
-					'type' => $info['type'],
352
-					'id_table_objet' => id_table_objet($info['type'])
353
-				];
354
-			}
355
-		}
356
-	}
324
+    static $objet_exec = [];
325
+    if (!$exec) {
326
+        return false;
327
+    }
328
+    // cas particulier
329
+    if ($exec === 'infos_perso') {
330
+        $exec = 'auteur';
331
+        set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
332
+    }
333
+    if (!isset($objet_exec[$exec])) {
334
+        $objet_exec[$exec] = false;
335
+        $infos = lister_tables_objets_sql();
336
+        foreach ($infos as $t => $info) {
337
+            if ($exec === $info['url_edit'] and $info['editable']) {
338
+                return $objet_exec[$exec] = [
339
+                    'edition' => $exec == $info['url_voir'] ? '' : true,
340
+                    'table_objet_sql' => $t,
341
+                    'table' => $info['table_objet'],
342
+                    'type' => $info['type'],
343
+                    'id_table_objet' => id_table_objet($info['type'])
344
+                ];
345
+            }
346
+            if ($exec === $info['url_voir']) {
347
+                return $objet_exec[$exec] = [
348
+                    'edition' => false,
349
+                    'table_objet_sql' => $t,
350
+                    'table' => $info['table_objet'],
351
+                    'type' => $info['type'],
352
+                    'id_table_objet' => id_table_objet($info['type'])
353
+                ];
354
+            }
355
+        }
356
+    }
357 357
 
358
-	return $objet_exec[$exec];
358
+    return $objet_exec[$exec];
359 359
 }
Please login to merge, or discard this patch.