|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
/***************************************************************************\ |
|
|
|
|
* SPIP, Systeme de publication pour l'internet * |
|
|
|
|
* SPIP, Système de publication pour l'internet * |
|
|
|
|
* * |
|
|
|
|
* Copyright (c) 2001-2018 * |
|
|
|
|
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
|
|
|
|
* Copyright © avec tendresse depuis 2001 * |
|
|
|
|
* Arnaud Martin, Antoine Pitrou, Philippe Rivière, Emmanuel Saint-James * |
|
|
|
|
* * |
|
|
|
|
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
|
|
|
|
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
|
|
|
|
* Ce programme est un logiciel libre distribué sous licence GNU/GPL. * |
|
|
|
|
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. * |
|
|
|
|
\***************************************************************************/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -15,6 +15,7 @@
|
|
|
|
|
* |
|
|
|
|
* Surcharge de ecrire/inc/texte |
|
|
|
|
* |
|
|
|
|
* @package SPIP\Textwheel\Texte |
|
|
|
|
**/ |
|
|
|
|
|
|
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
|
|
@ -381,20 +382,37 @@ function traiter_tableau($bloc) {
|
|
|
|
|
$reg_line1 = ',^(\|(' . _RACCOURCI_TH_SPAN . '))+$,sS'; |
|
|
|
|
$reg_line_all = ',^(' . _RACCOURCI_TH_SPAN . ')$,sS'; |
|
|
|
|
$hc = $hl = array(); |
|
|
|
|
$thead_ok = false; |
|
|
|
|
foreach ($regs[1] as $ligne) { |
|
|
|
|
$l++; |
|
|
|
|
|
|
|
|
|
// Gestion de la premiere ligne : |
|
|
|
|
if ($l == 1) { |
|
|
|
|
// - <caption> et summary dans la premiere ligne : |
|
|
|
|
if (!$thead_ok and $l == 1) { |
|
|
|
|
// - <caption> et summary dans la premiere ligne (seulement si on n'a pas dépassé le premier thead) : |
|
|
|
|
// || caption | summary || (|summary est optionnel) |
|
|
|
|
if (preg_match(',^\|\|([^|]*)(\|(.*))?$,sS', rtrim($ligne, '|'), $cap)) { |
|
|
|
|
$cap = array_pad($cap, 4, null); |
|
|
|
|
$l = 0; |
|
|
|
|
$summary = ''; |
|
|
|
|
if ($describedby = trim($cap[3])) { |
|
|
|
|
if (!html5_permis()) { |
|
|
|
|
$summary = ' summary="' . entites_html(trim($cap[3])) . '"'; |
|
|
|
|
$describedby = ''; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$iddescribedby = 'dby'.$tabid; |
|
|
|
|
$summary = ' aria-describedby="'.$iddescribedby.'"'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($caption = trim($cap[1])) { |
|
|
|
|
if ($describedby) { |
|
|
|
|
$caption .= '<br /> <small id="'.$iddescribedby.'" class="summary offscreen">' . $describedby . '</small>'; |
|
|
|
|
} |
|
|
|
|
$debut_table .= "<caption>" . $caption . "</caption>\n"; |
|
|
|
|
} |
|
|
|
|
$summary = ' summary="' . entites_html(trim($cap[3])) . '"'; |
|
|
|
|
elseif ($describedby) { |
|
|
|
|
$debut_table .= '<caption id="'.$iddescribedby.'" class="summary offscreen"><small>' . $describedby . "</small></caption>\n"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// - <thead> sous la forme |{{titre}}|{{titre}}| |
|
|
|
|
// Attention thead oblige a avoir tbody |
|
|
|
@ -423,6 +441,7 @@ function traiter_tableau($bloc) {
|
|
|
|
|
$debut_table .= "<thead><tr class='row_first'>" . |
|
|
|
|
$ligne . "</tr></thead>\n"; |
|
|
|
|
$l = 0; |
|
|
|
|
$thead_ok = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -538,7 +557,15 @@ function traiter_tableau($bloc) {
|
|
|
|
|
$html = "<tr class='row_$class $class'>$ligne</tr>\n$html"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return "\n\n<table" . $GLOBALS['class_spip_plus'] . $summary . ">\n" |
|
|
|
|
$class = $GLOBALS['class_spip_plus']; |
|
|
|
|
if (!$class or strpos($GLOBALS['class_spip_plus'],'class=') === false) { |
|
|
|
|
$class = ' ' . trim('class="table" ' . $class); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
$class = str_replace('class="','class="table ', $class); |
|
|
|
|
$class = str_replace("class='","class='table ", $class); |
|
|
|
|
} |
|
|
|
|
return "\n\n<table" . $class . $summary . ">\n" |
|
|
|
|
. $debut_table |
|
|
|
|
. "<tbody>\n" |
|
|
|
|
. $html |
|
|
|
@ -596,6 +623,11 @@ function personnaliser_raccourcis(&$ruleset) {
|
|
|
|
|
$rule->replace[0] = preg_replace(',<[^>]*>,Uims', $GLOBALS['debut_intertitre'], $rule->replace[0]); |
|
|
|
|
$rule->replace[1] = preg_replace(',<[^>]*>,Uims', $GLOBALS['fin_intertitre'], $rule->replace[1]); |
|
|
|
|
$ruleset->addRules(array('intertitres' => $rule)); |
|
|
|
|
if ($rule = $ruleset->getRule('intertitres-compliques')) { |
|
|
|
|
$rule->replace[0] = preg_replace(',<[^>]*>,Uims', $GLOBALS['debut_intertitre'], $rule->replace[0]); |
|
|
|
|
$rule->replace[1] = preg_replace(',<[^>]*>,Uims', $GLOBALS['fin_intertitre'], $rule->replace[1]); |
|
|
|
|
$ruleset->addRules(array('intertitres-compliques' => $rule)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isset($GLOBALS['debut_gras']) and $rule = $ruleset->getRule('gras')) { |
|
|
|
|
$rule->replace[0] = preg_replace(',<[^>]*>,Uims', $GLOBALS['debut_gras'], $rule->replace[0]); |
|
|
|
@ -701,19 +733,22 @@ function traiter_raccourcis($t, $show_autobr = false) {
|
|
|
|
|
// car en css on ne sait pas styler l'element BR |
|
|
|
|
if ($ignorer_autobr and _AUTOBR) { |
|
|
|
|
if (is_null($img_br_no)) { |
|
|
|
|
$img_br_no = ($show_autobr ? http_img_pack("br-no" . aide_lang_dir($spip_lang, $spip_lang_rtl) . "-10.png", |
|
|
|
|
_T("tw:retour_ligne_ignore"), "class='br-no'", _T("tw:retour_ligne_ignore")) : ""); |
|
|
|
|
$img_br_no = ($show_autobr ? http_img_pack("br-no" . aide_lang_dir($spip_lang, $spip_lang_rtl) . "-10.png", '', |
|
|
|
|
"class='br-no'", _T("tw:retour_ligne_ignore")) : ""); |
|
|
|
|
$img_br_no = inserer_attribut($img_br_no, 'aria-label', _T("tw:retour_ligne_ignore")); |
|
|
|
|
} |
|
|
|
|
$t = str_replace(_AUTOBR, $img_br_no, $t); |
|
|
|
|
} |
|
|
|
|
if ($show_autobr and _AUTOBR) { |
|
|
|
|
if (is_null($img_br_manuel)) { |
|
|
|
|
$img_br_manuel = http_img_pack("br-manuel" . aide_lang_dir($spip_lang, $spip_lang_rtl) . "-10.png", |
|
|
|
|
_T("tw:retour_ligne_manuel"), "class='br-manuel'", _T("tw:retour_ligne_manuel")); |
|
|
|
|
$img_br_manuel = http_img_pack("br-manuel" . aide_lang_dir($spip_lang, $spip_lang_rtl) . "-10.png", '' , |
|
|
|
|
"class='br-manuel'", _T("tw:retour_ligne_manuel")); |
|
|
|
|
$img_br_manuel = inserer_attribut($img_br_manuel, 'aria-label', _T("tw:retour_ligne_manuel")); |
|
|
|
|
} |
|
|
|
|
if (is_null($img_br_auto)) { |
|
|
|
|
$img_br_auto = http_img_pack("br-auto" . aide_lang_dir($spip_lang, $spip_lang_rtl) . "-10.png", |
|
|
|
|
_T("tw:retour_ligne_auto"), "class='br-auto'", _T("tw:retour_ligne_auto")); |
|
|
|
|
$img_br_auto = http_img_pack("br-auto" . aide_lang_dir($spip_lang, $spip_lang_rtl) . "-10.png", '', |
|
|
|
|
"class='br-auto'", _T("tw:retour_ligne_auto")); |
|
|
|
|
$img_br_auto = inserer_attribut($img_br_auto, 'aria-label', _T("tw:retour_ligne_auto")); |
|
|
|
|
} |
|
|
|
|
if (false !== strpos(strtolower($t), '<br')) { |
|
|
|
|
$t = preg_replace("/<br\b.*>/UiS", "$img_br_manuel\\0", $t); |
|
|
|
@ -753,8 +788,7 @@ function propre($t, $connect = null, $env = array()) {
|
|
|
|
|
// ou il faut passer interdire_script explicitement |
|
|
|
|
// les appels dans les squelettes (de l'espace prive) fournissant un $connect |
|
|
|
|
// ne seront pas perturbes |
|
|
|
|
|
|
|
|
|
$interdire_script = ( empty($env) and $GLOBALS['filtrer_javascript'] == -1); |
|
|
|
|
$interdire_script = false; |
|
|
|
|
if (is_null($connect) and test_espace_prive()) { |
|
|
|
|
$connect = ''; |
|
|
|
|
$interdire_script = true; |
|
|
|
@ -765,10 +799,12 @@ function propre($t, $connect = null, $env = array()) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$t = pipeline('pre_echappe_html_propre', $t); |
|
|
|
|
|
|
|
|
|
$t = echappe_html($t); |
|
|
|
|
$t = expanser_liens($t, $connect, $env); |
|
|
|
|
|
|
|
|
|
$t = traiter_raccourcis($t, (isset($env['wysiwyg']) and $env['wysiwyg']) ? true : false); |
|
|
|
|
$t = traiter_raccourcis($t, (isset($env['wysiwyg']) and $env['wysiwyg']) ? true : false); |
|
|
|
|
|
|
|
|
|
// Dans l'espace prive on se mefie de tout contenu dangereux |
|
|
|
|
// avant echappement des balises <html> |
|
|
|
|
// https://core.spip.net/issues/3371 |
|
|
|
|