Skip to content
Extraits de code Groupes Projets
Valider 2f802256 rédigé par ARNO*'s avatar ARNO*
Parcourir les fichiers

Le nettoyage par tidy est passe en amont, et stocke en cache.

parent a81b1254
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,7 +2,7 @@
$fond = "article";
$delais = 24 * 3600;
$xhtml = true;
include ("inc-public.php3");
?>
......@@ -217,7 +217,7 @@ function echappe_html($letexte, $source, $no_transform=false) {
$texte_fin = substr($texte_a_voir, $fin, strlen($texte_a_voir));
$traiter_math = "image";
$traiter_math = "mathml";
//$traiter_math = "mathml";
if ($traiter_math == "image") {
while((ereg("(\\$){2}([^$]+)(\\$){2}",$texte_milieu, $regs))) {
......
......@@ -38,9 +38,6 @@ function echappe_xhtml ($letexte) { // oui, c'est dingue... on echappe le mathml
function xhtml ($buffer) {
$config = array('indent' => TRUE,
'output-xhtml' => TRUE,
'wrap', 200);
if (version_tidy() == "1") {
include_ecrire("inc_texte.php3");
......@@ -48,11 +45,11 @@ function xhtml ($buffer) {
$buffer = $retour_echap[0];
$les_echap = $retour_echap[1];
// Options selon: http://tidy.sourceforge.net/docs/quickref.html
tidy_set_encoding ("utf8");
tidy_setopt('wrap', 0);
tidy_setopt('indent-spaces', 4);
tidy_setopt('output-xhtml', true);
tidy_setopt('add-xml-decl', true);
tidy_setopt('indent', 5);
$html = tidy_parse_string($buffer);
......@@ -74,4 +71,42 @@ function xhtml ($buffer) {
function xhtml_nettoyer_chaine ($buffer) {
if (version_tidy() == "1") {
include_ecrire("inc_texte.php3");
$retour_echap = echappe_xhtml ($buffer);
$buffer = $retour_echap[0];
$les_echap = $retour_echap[1];
// Options selon: http://tidy.sourceforge.net/docs/quickref.html
tidy_set_encoding ("utf8");
tidy_setopt('wrap', 0);
tidy_setopt('indent-spaces', 4);
tidy_setopt('output-xhtml', true);
tidy_setopt('indent', 5);
tidy_setopt('show-body-only', true);
$html = tidy_parse_string($buffer);
tidy_clean_repair();
$tidy = tidy_get_output();
$tidy = echappe_retour($tidy, $les_echap, "mathml");
return $tidy;
}
else if (version_tidy() == "2") {
$config = array('indent' => TRUE,
'output-xhtml' => TRUE,
'wrap' => 200,
'show-body-only' => TRUE);
$tidy = tidy_parse_string($buffer, $config, 'UTF8');
$tidy->cleanRepair();
return $tidy;
}
else return $buffer;
}
?>
\ No newline at end of file
......@@ -14,7 +14,7 @@ function bouton_admin($titre, $lien) {
$link = new Link($lien);
$link->delVar('submit');
echo $link->getForm('GET');
echo "<input type='submit' name='submit' value=\"".attribut_html($titre)."\" class='spip_bouton'>\n";
echo "<input type='submit' name='submit' value=\"".attribut_html($titre)."\" class='spip_bouton' />\n";
echo "</form>";
}
......@@ -53,7 +53,7 @@ function afficher_boutons_admin() {
echo $link->getForm('GET');
if ($GLOBALS['use_cache']) $pop = " *";
else $pop = "";
echo "<input type='submit' class='spip_bouton' name='submit' value=\"".attribut_html(_T('admin_recalculer')).$pop."\">";
echo "<input type='submit' class='spip_bouton' name='submit' value=\"".attribut_html(_T('admin_recalculer')).$pop."\"></input>";
echo "</form>\n";
if (lire_meta("activer_statistiques") != "non" AND $id_article AND ($GLOBALS['auteur_session']['statut'] == '0minirezo')) {
......@@ -64,6 +64,7 @@ function afficher_boutons_admin() {
echo "</div>";
lang_dselect();
}
......
......@@ -106,11 +106,6 @@ if ($ajout_forum) {
ajout_forum();
}
if ($xhtml){
include_ecrire('inc_tidy.php');
if (version_tidy() > 0) ob_start("xhtml");
}
if (!$use_cache) {
$lastmodified = time();
if (($lastmodified - lire_meta('date_purge_cache')) > 3600) {
......@@ -155,6 +150,10 @@ if (!$use_cache) {
$page = calculer_page_globale($fond);
$timer_b = explode(" ", microtime());
if ($page) {
if ($xhtml) {
include_ecrire("inc_tidy.php");
$page = xhtml($page);
}
$timer = ceil(1000 * ($timer_b[0] + $timer_b[1] - $timer_a[0] - $timer_a[1]));
$taille = ceil(strlen($page) / 1024);
spip_log("calcul ($timer ms): $chemin_cache ($taille ko, delai: $delais s)");
......@@ -202,11 +201,22 @@ else {
$flag_preserver |= $headers_only; // ne pas se fatiguer a envoyer des donnees
if (!$flag_preserver) {
if ($xhtml) {
// Si Mozilla et tidy actif, passer en "application/xhtml+xml"
// extremement risque: Mozilla passe en mode debugueur strict
// mais permet d'afficher du MathML directement dans le texte
// (et sauf erreur, c'est la bonne facon de declarer du xhtml)
include_ecrire("inc_tidy.php");
verif_butineur();
if ($browser_name == "MSIE")
if (version_tidy() > 0) {
if ($browser_name == "MSIE")
@Header("Content-Type: text/html; charset=".lire_meta('charset'));
else
@Header("Content-Type: application/xhtml+xml; charset=".lire_meta('charset'));
echo '<'.'?xml version="1.0" encoding="'.lire_meta('charset').'"?'.">\n";
} else {
@Header("Content-Type: text/html; charset=".lire_meta('charset'));
else
@Header("Content-Type: application/xhtml+xml; charset=".lire_meta('charset'));
}
} else {
@Header("Content-Type: text/html; charset=".lire_meta('charset'));
}
......@@ -230,12 +240,6 @@ if ($var_recherche)
fin_surligne($var_recherche, $mode_surligne);
if ($xhtml) {
include_ecrire('inc_tidy.php');
if (version_tidy() > 0) ob_end_flush();
}
// nettoie
if ($effacer_cache) @unlink($chemin_cache);
while (list(, $chemin_cache_supprime) = each($cache_supprimes))
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter