X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fpublic%2Fformat_html.php;fp=www%2Fecrire%2Fpublic%2Fformat_html.php;h=9d19c163c5eb804ed37c8793d00031edf07ce256;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/public/format_html.php b/www/ecrire/public/format_html.php new file mode 100644 index 0000000..9d19c16 --- /dev/null +++ b/www/ecrire/public/format_html.php @@ -0,0 +1,122 @@ +$avant" : ""; + $apres = $apres ? "$apres" : ""; + $altern = $altern ? "$altern" : ""; + if (!$corps) $corps = " />"; else $corps = ">$corps"; + return "$avant"); +} + +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"; + $args = (!$args ? '' : ('{' . join(',', $args) . '}')); + return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); +} + +function format_champ_html ($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) +{ + $nom = "#" + . ($boucle ? ($boucle . ":") : "") + . $nom + . $etoile + . $args + . $filtres; + + // Determiner si c'est un champ etendu, + + $s = ($avant OR $apres OR $filtres + OR (strpos($args, '(#') !==false)); + + return ($s ? "[$avant($nom)$apres]" : $nom); +} + +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); + } + $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) . "}"))); +} + +// 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++) { + list($texte, $type) = $args[$i]; + 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 . ')]'; + } else { + 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))) + $args[$i][0] = '[(' . $texte . ')]'; + } + } + return join("", array_map('array_shift', $args)); +} + +function format_texte_html ($texte) +{ + return $texte; +} + +?>