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