X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fecrire%2Fpublic%2Fformat_html.php;fp=www%2Fecrire%2Fpublic%2Fformat_html.php;h=e2aaa4044aeebac9df8c0ea8cab761f80b5ee5a5;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=9efb9fc308c4a9d3314490b8600ee9e2325f6faf;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/ecrire/public/format_html.php b/www/ecrire/public/format_html.php index 9efb9fc3..e2aaa404 100644 --- a/www/ecrire/public/format_html.php +++ b/www/ecrire/public/format_html.php @@ -3,120 +3,132 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2016 * + * Copyright (c) 2001-2017 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, 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. * \***************************************************************************/ -if (!defined('_ECRIRE_INC_VERSION')) return; +if (!defined('_ECRIRE_INC_VERSION')) { + return; +} -function format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) -{ +function format_boucle_html($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) { $avant = $avant ? "$avant" : ""; $apres = $apres ? "$apres" : ""; $altern = $altern ? "$altern" : ""; - if (!$corps) $corps = " />"; else $corps = ">$corps"; + if (!$corps) { + $corps = " />"; + } else { + $corps = ">$corps"; + } + return "$avant"); + $args = !$args ? '' : ("{" . join(", ", $args) . "}"); + + return (""); } -function format_polyglotte_html ($args, $prof) -{ - $contenu = array(); - foreach($args as $l=>$t) - $contenu[]= ($l ? "[$l]" : '') . $t; +function format_polyglotte_html($args, $prof) { + $contenu = array(); + foreach ($args as $l => $t) { + $contenu[] = ($l ? "[$l]" : '') . $t; + } + return ("" . join(" ", $contenu) . ""); } -function format_idiome_html ($nom, $module, $args, $filtres, $prof) -{ - foreach ($args as $k => $v) $args[$k] = "$k=$v"; +function format_idiome_html($nom, $module, $args, $filtres, $prof) { + foreach ($args as $k => $v) { + $args[$k] = "$k=$v"; + } $args = (!$args ? '' : ('{' . join(',', $args) . '}')); + return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); } -function format_champ_html ($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) -{ +function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) { $nom = "#" - . ($boucle ? ($boucle . ":") : "") - . $nom - . $etoile - . $args - . $filtres; + . ($boucle ? ($boucle . ":") : "") + . $nom + . $etoile + . $args + . $filtres; // Determiner si c'est un champ etendu, - $s = ($avant OR $apres OR $filtres - OR (strpos($args, '(#') !==false)); + $s = ($avant or $apres or $filtres + or (strpos($args, '(#') !== false)); return ($s ? "[$avant($nom)$apres]" : $nom); } -function format_critere_html ($critere) -{ +function format_critere_html($critere) { foreach ($critere as $k => $crit) { $crit_s = ''; foreach ($crit as $operande) { list($type, $valeur) = $operande; - if ($type == 'champ' AND $valeur[0]=='[') { - $valeur = substr($valeur,1,-1); - if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) - $valeur = substr($valeur,1,-1); + if ($type == 'champ' and $valeur[0] == '[') { + $valeur = substr($valeur, 1, -1); + if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) { + $valeur = substr($valeur, 1, -1); + } } $crit_s .= $valeur; } $critere[$k] = $crit_s; } + return (!$critere ? "" : ("{" . join(",", $critere) . "}")); } -function format_liste_html ($fonc, $args, $prof) -{ - return ((($fonc!=='') ? "|$fonc" : $fonc) - . (!$args ? "" : ("{" . join(",", $args) . "}"))); +function format_liste_html($fonc, $args, $prof) { + return ((($fonc !== '') ? "|$fonc" : $fonc) + . (!$args ? "" : ("{" . join(",", $args) . "}"))); } // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes -function format_suite_html ($args) -{ - for($i=0; $i < count($args)-1; $i++) { +function format_suite_html($args) { + for ($i = 0; $i < count($args) - 1; $i++) { list($texte, $type) = $args[$i]; - list($texte2, $type2) = $args[$i+1]; - if (!$texte OR !$texte2) continue; - $c1 = substr($texte,-1); + list($texte2, $type2) = $args[$i + 1]; + if (!$texte or !$texte2) { + continue; + } + $c1 = substr($texte, -1); if ($type2 !== 'texte') { - // si un texte se termine par ( et est suivi d'un champ - // ou assimiles, forcer la notation pleine - if ($c1 == '(' AND substr($texte2,0,1) == '#') - $args[$i+1][0] = '[(' . $texte2 . ')]'; + // si un texte se termine par ( et est suivi d'un champ + // ou assimiles, forcer la notation pleine + if ($c1 == '(' and substr($texte2, 0, 1) == '#') { + $args[$i + 1][0] = '[(' . $texte2 . ')]'; + } } else { - if ($type == 'texte') continue; + if ($type == 'texte') { + continue; + } // si un champ ou assimiles est suivi d'un texte // et si celui-ci commence par un caractere de champ // forcer la notation pleine - if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') - OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) + if (($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|') + or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2)) + ) { $args[$i][0] = '[(' . $texte . ')]'; + } } } + return join("", array_map('array_shift', $args)); } -function format_texte_html ($texte) -{ +function format_texte_html($texte) { return $texte; } - -?>