@@ -16,10 +16,10 @@ discard block |
||
| 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 |
||
| 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-migrate-3.2.0.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 | - 'javascript/jquery.cookie.js' |
|
| 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('jquery_plugins', |
|
| 50 | + array( |
|
| 51 | + 'javascript/jquery.js', |
|
| 52 | + 'javascript/jquery-migrate-3.2.0.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 | + 'javascript/jquery.cookie.js' |
|
| 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,27 +85,27 @@ discard block |
||
| 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 (!$rech |
|
| 93 | - and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 94 | - or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 95 | - or !isset($_SERVER['HTTP_REFERER'])) |
|
| 96 | - ) { |
|
| 97 | - return $texte; |
|
| 98 | - } |
|
| 99 | - include_spip('inc/surligne'); |
|
| 88 | + if (!$GLOBALS['html']) { |
|
| 89 | + return $texte; |
|
| 90 | + } |
|
| 91 | + $rech = _request('var_recherche'); |
|
| 92 | + if (!$rech |
|
| 93 | + and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 94 | + or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 95 | + or !isset($_SERVER['HTTP_REFERER'])) |
|
| 96 | + ) { |
|
| 97 | + return $texte; |
|
| 98 | + } |
|
| 99 | + include_spip('inc/surligne'); |
|
| 100 | 100 | |
| 101 | - if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 102 | - $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 103 | - } |
|
| 104 | - if ($rech){ |
|
| 105 | - $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 106 | - } |
|
| 101 | + if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 102 | + $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 103 | + } |
|
| 104 | + if ($rech){ |
|
| 105 | + $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - return surligner_mots($texte, $rech); |
|
| 108 | + return surligner_mots($texte, $rech); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -122,32 +122,32 @@ discard block |
||
| 122 | 122 | * @return string Contenu de la page envoyée au navigateur |
| 123 | 123 | **/ |
| 124 | 124 | function f_tidy($texte) { |
| 125 | - /** |
|
| 126 | - * Indentation à faire ? |
|
| 127 | - * |
|
| 128 | - * - true : actif. |
|
| 129 | - * - false par défaut. |
|
| 130 | - */ |
|
| 125 | + /** |
|
| 126 | + * Indentation à faire ? |
|
| 127 | + * |
|
| 128 | + * - true : actif. |
|
| 129 | + * - false par défaut. |
|
| 130 | + */ |
|
| 131 | 131 | |
| 132 | - if ($GLOBALS['xhtml'] # tidy demande |
|
| 133 | - and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 134 | - and strlen($texte) |
|
| 135 | - and !headers_sent() |
|
| 136 | - ) { |
|
| 137 | - # Compatibilite ascendante |
|
| 138 | - if (!is_string($GLOBALS['xhtml'])) { |
|
| 139 | - $GLOBALS['xhtml'] = 'tidy'; |
|
| 140 | - } |
|
| 132 | + if ($GLOBALS['xhtml'] # tidy demande |
|
| 133 | + and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 134 | + and strlen($texte) |
|
| 135 | + and !headers_sent() |
|
| 136 | + ) { |
|
| 137 | + # Compatibilite ascendante |
|
| 138 | + if (!is_string($GLOBALS['xhtml'])) { |
|
| 139 | + $GLOBALS['xhtml'] = 'tidy'; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 143 | - spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 144 | - $f = charger_fonction('sax', 'xml'); |
|
| 145 | - } |
|
| 142 | + if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 143 | + spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 144 | + $f = charger_fonction('sax', 'xml'); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return $f($texte); |
|
| 148 | - } |
|
| 147 | + return $f($texte); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - return $texte; |
|
| 150 | + return $texte; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -166,21 +166,21 @@ discard block |
||
| 166 | 166 | * @return string Contenu de la page envoyée au navigateur |
| 167 | 167 | **/ |
| 168 | 168 | function f_insert_head($texte) { |
| 169 | - if (!$GLOBALS['html']) { |
|
| 170 | - return $texte; |
|
| 171 | - } |
|
| 172 | - include_spip('public/admin'); // pour strripos |
|
| 169 | + if (!$GLOBALS['html']) { |
|
| 170 | + return $texte; |
|
| 171 | + } |
|
| 172 | + include_spip('public/admin'); // pour strripos |
|
| 173 | 173 | |
| 174 | - ($pos = stripos($texte, '</head>')) |
|
| 175 | - || ($pos = stripos($texte, '<body>')) |
|
| 176 | - || ($pos = 0); |
|
| 174 | + ($pos = stripos($texte, '</head>')) |
|
| 175 | + || ($pos = stripos($texte, '<body>')) |
|
| 176 | + || ($pos = 0); |
|
| 177 | 177 | |
| 178 | - if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 179 | - $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 180 | - $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 181 | - } |
|
| 178 | + if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 179 | + $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 180 | + $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - return $texte; |
|
| 183 | + return $texte; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -196,34 +196,34 @@ discard block |
||
| 196 | 196 | * @return string Contenu de la page envoyée au navigateur |
| 197 | 197 | **/ |
| 198 | 198 | function f_admin($texte) { |
| 199 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 200 | - include_spip('inc/filtres'); // pour http_img_pack |
|
| 201 | - $x = "<div class='spip-previsu' " |
|
| 202 | - . http_style_background('preview-32.png', '', 32) |
|
| 203 | - . ">" |
|
| 204 | - . _T('previsualisation') |
|
| 205 | - . "</div>"; |
|
| 206 | - if (!$pos = stripos($texte, '</body>')) { |
|
| 207 | - $pos = strlen($texte); |
|
| 208 | - } |
|
| 209 | - $texte = substr_replace($texte, $x, $pos, 0); |
|
| 210 | - // pas de preview en fenetre enfant |
|
| 211 | - $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes($GLOBALS['meta']['adresse_site'])."';}</script>"; |
|
| 212 | - if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 213 | - $pos = -1; |
|
| 214 | - } |
|
| 215 | - $texte = substr_replace($texte, $x, $pos+1, 0); |
|
| 216 | - } |
|
| 199 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 200 | + include_spip('inc/filtres'); // pour http_img_pack |
|
| 201 | + $x = "<div class='spip-previsu' " |
|
| 202 | + . http_style_background('preview-32.png', '', 32) |
|
| 203 | + . ">" |
|
| 204 | + . _T('previsualisation') |
|
| 205 | + . "</div>"; |
|
| 206 | + if (!$pos = stripos($texte, '</body>')) { |
|
| 207 | + $pos = strlen($texte); |
|
| 208 | + } |
|
| 209 | + $texte = substr_replace($texte, $x, $pos, 0); |
|
| 210 | + // pas de preview en fenetre enfant |
|
| 211 | + $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes($GLOBALS['meta']['adresse_site'])."';}</script>"; |
|
| 212 | + if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 213 | + $pos = -1; |
|
| 214 | + } |
|
| 215 | + $texte = substr_replace($texte, $x, $pos+1, 0); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 219 | - include_spip('public/admin'); |
|
| 220 | - $texte = affiche_boutons_admin($texte); |
|
| 221 | - } |
|
| 222 | - if (_request('var_mode') == 'noajax') { |
|
| 223 | - $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 224 | - } |
|
| 218 | + if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 219 | + include_spip('public/admin'); |
|
| 220 | + $texte = affiche_boutons_admin($texte); |
|
| 221 | + } |
|
| 222 | + if (_request('var_mode') == 'noajax') { |
|
| 223 | + $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - return $texte; |
|
| 226 | + return $texte; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | * @return array $flux Description et contenu de l'inclusion |
| 242 | 242 | **/ |
| 243 | 243 | function f_recuperer_fond($flux) { |
| 244 | - if (!test_espace_prive()) { |
|
| 245 | - return $flux; |
|
| 246 | - } |
|
| 244 | + if (!test_espace_prive()) { |
|
| 245 | + return $flux; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - return f_afficher_blocs_ecrire($flux); |
|
| 248 | + return f_afficher_blocs_ecrire($flux); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -259,29 +259,29 @@ discard block |
||
| 259 | 259 | * @return string Contenu de la page envoyée au navigateur |
| 260 | 260 | */ |
| 261 | 261 | function f_queue($texte) { |
| 262 | - // eviter une inclusion si rien a faire |
|
| 263 | - if (_request('action') == 'cron' |
|
| 264 | - or queue_sleep_time_to_next_job() > 0 |
|
| 265 | - or defined('_DEBUG_BLOCK_QUEUE') |
|
| 266 | - ) { |
|
| 267 | - return $texte; |
|
| 268 | - } |
|
| 262 | + // eviter une inclusion si rien a faire |
|
| 263 | + if (_request('action') == 'cron' |
|
| 264 | + or queue_sleep_time_to_next_job() > 0 |
|
| 265 | + or defined('_DEBUG_BLOCK_QUEUE') |
|
| 266 | + ) { |
|
| 267 | + return $texte; |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - include_spip('inc/queue'); |
|
| 271 | - $code = queue_affichage_cron(); |
|
| 270 | + include_spip('inc/queue'); |
|
| 271 | + $code = queue_affichage_cron(); |
|
| 272 | 272 | |
| 273 | - // si rien a afficher |
|
| 274 | - // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 275 | - if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 276 | - return $texte; |
|
| 277 | - } |
|
| 273 | + // si rien a afficher |
|
| 274 | + // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 275 | + if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 276 | + return $texte; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 280 | - if (($p = strpos($texte, '</body>')) !== false) { |
|
| 281 | - $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 282 | - } else { |
|
| 283 | - $texte .= $code; |
|
| 284 | - } |
|
| 279 | + // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 280 | + if (($p = strpos($texte, '</body>')) !== false) { |
|
| 281 | + $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 282 | + } else { |
|
| 283 | + $texte .= $code; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - return $texte; |
|
| 286 | + return $texte; |
|
| 287 | 287 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $texte = $x . $texte; |
|
| 67 | + $texte = $x.$texte; |
|
| 68 | 68 | |
| 69 | 69 | return $texte; |
| 70 | 70 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | if (isset($_SERVER['HTTP_REFERER'])) { |
| 102 | 102 | $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
| 103 | 103 | } |
| 104 | - if ($rech){ |
|
| 104 | + if ($rech) { |
|
| 105 | 105 | $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | || ($pos = 0); |
| 177 | 177 | |
| 178 | 178 | if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
| 179 | - $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 179 | + $insert = "\n".pipeline('insert_head', '<!-- f_insert_head -->')."\n"; |
|
| 180 | 180 | $texte = substr_replace($texte, $insert, $pos, 0); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
| 213 | 213 | $pos = -1; |
| 214 | 214 | } |
| 215 | - $texte = substr_replace($texte, $x, $pos+1, 0); |
|
| 215 | + $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
| 280 | 280 | if (($p = strpos($texte, '</body>')) !== false) { |
| 281 | - $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 281 | + $texte = substr($texte, 0, $p).$code.substr($texte, $p); |
|
| 282 | 282 | } else { |
| 283 | 283 | $texte .= $code; |
| 284 | 284 | } |